zearch: regular expression searching on grammar-compressed text

3 months ago (pevalme.github.io)

Corrected

More code for experimentation: https://github.com/s-maruyama/exrepair

    cd zearch-master
    ed Makefile <<__GGG__
    11c
    CC = gcc
    .
    4,6c
    CFLAGS = -static -s -I/usr/include -fcommon -O3 -march=native -flto -mtune=native
    # CFLAGS = -fcommon -flto -DNDEBUG -ggdb -fno-inline-functions
    LFLAGS = -L/usr/local/lib/ /usr/lib/libfa.a
    .
    w
    q
    __GGG__

    cd src
    ed main.c <<__HHH__
    750,751c
    if(mode=='q'){ret=run_boolean_zearch(minimize,argv[argc-1],argv[argc-2]);exit(ret);}else run_zearch(minimize,argv[argc-1],argv[argc-2]);
    .
    730,733c
    if(argc==4)if(argv[1][0]=='-')mode=argv[1][1];else mode='l';
    .
    707,728c
    if(argc!=3&&argc!=4)help();
    .
    703c
    int help(){
    fputs("Usage: zearch [OPTION] PATTERN RE-PAIR FILE\n",stderr);
    fputs("  -c: prints only a count of selected lines in RE-PAIR FILE\n",stderr);
    fputs("  -q: suppress all normal output\n",stderr);
    exit(0);
    }
    .
    525a
    int help();
    if(slp==NULL)help();
    .
    501c
    ret=1;
    .
    491c
    ret=0;
    .
    482c
    ret=0;
    .
    430a
    int help();
    if(slp==NULL)help();
    .
    419c
    if(mode=='c')printf("%d\n",ret+counting_overflows*COUNTER_TOP);
    .
    350c
    if(mode!='c'&&mode!='q'){
    .
    238,253d
    w
    q
    __HHH__

    ed nfa.c <<__III__
    103,104c
    extern unsigned int num_e_l;
    extern unsigned int num_e_r;
    .
    w
    q
    __III__

    ed stack.c <<__JJJ__
    56c
    s->data = (unsigned int*)realloc(s->data, sizeof(unsigned int) * s->size);
    .
    53c
    __attribute__((always_inline)) inline void stack_push(STACK *s, unsigned int n){
    .
    42,43c
    __attribute__((always_inline)) inline unsigned int stack_pop(STACK *s){
    unsigned int ret;
    .
    37c
    posix_memalign((void **)&s->data, 64, STACK_SIZE * sizeof(unsigned int));
    .
    w
    q
    __JJJ__

    ed stack.h <<__KKK__
    65c
    void stack_push(STACK *s, unsigned int n);
    .
    55c
    unsigned int stack_pop(STACK *s);
    .
    36c
    unsigned int *data;
    .
    5c
    * Each element is a unsigned int.
    .
    w
    q
    __KKK__

.

   cd zearch-master/
   ed Makefile <<__GGG__
   11c
   CC = gcc
   .
   4,6c
   CFLAGS = -static -s -I/usr/include -fcommon -O3 -march=native -flto -mtune=native
   # CFLAGS = -fcommon -flto -DNDEBUG -ggdb -fno-inline-functions
   LFLAGS = -L/usr/local/lib/ /usr/lib/libfa.a
   .
   w
   q
   __GGG__


   ed main.c <<__HHH__
   750,751c
   if(mode=='q'){ret=run_boolean_zearch(minimize,argv[argc-1],argv[argc-2]);exit(ret);}else run_zearch(minimize,argv[argc-1],argv[argc-2]);
   .
   730,733c
   if(argc==4)if(argv[1][0]=='-')mode=argv[1][1];else mode='l';
   .
   707,728c
   if(argc!=3&&argc!=4)help();
   .
   703c
   int help(){
   fputs("Usage: zearch [OPTION] PATTERN RE-PAIR FILE\n",stderr);
   fputs("  -c: prints only a count of selected lines in RE-PAIR FILE\n",stderr);
   fputs("  -q: suppress all normal output\n",stderr);
   exit(0);
   }
   .
   525a
   int help();
   if(slp==NULL)help();
   .
   501c
   ret=1;
   .
   491c
   ret=0;
   .
   482c
   ret=0;
   .
   430a
   int help();
   if(slp==NULL)help();
   .
   419c
   if(mode=='c')printf("%d\n",ret+counting_overflows*COUNTER_TOP);
   .
   350c
   if(mode!='c'&&mode!='q'){
   .
   238,253d
   w
   q
   __HHH__

   ed nfa.c <<__III__
   103,104c
   extern unsigned int num_e_l;
   extern unsigned int num_e_r;
   .
   diff -re zearch-master/src/stack.c zearch-master.new/src/stack.c
   56c
   s->data = (unsigned int*)realloc(s->data, sizeof(unsigned int) * s->size);
   .
   53c
   __attribute__((always_inline)) inline void stack_push(STACK *s, unsigned int n){
   .
   42,43c
   __attribute__((always_inline)) inline unsigned int stack_pop(STACK *s){
   unsigned int ret;
   .
   37c
   posix_memalign((void **)&s->data, 64, STACK_SIZE * sizeof(unsigned int));
   .
   w
   q
   __III__

   ed stack.h <<__JJJ__
   65c
   void stack_push(STACK *s, unsigned int n);
   .
   55c
   unsigned int stack_pop(STACK *s);
   .
   36c
   unsigned int *data;
   .
   5c
   * Each element is a unsigned int.
   .
   w
   q
   __JJJ__