[BACK]Return to apropos.c CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

Diff for /mandoc/Attic/apropos.c between version 1.5 and 1.6

version 1.5, 2011/10/09 10:35:12 version 1.6, 2011/10/09 10:37:52
Line 290  out:
Line 290  out:
 static void  static void
 state_search(struct state *p, const struct opts *opts, char *q)  state_search(struct state *p, const struct opts *opts, char *q)
 {  {
         int              leaf, root, len, ch, rflags, dflag;          int              leaf, root, len, ch, dflag;
         struct mchars   *mc;          struct mchars   *mc;
         char            *buf;          char            *buf;
         size_t           bufsz;          size_t           bufsz;
Line 308  state_search(struct state *p, const struct opts *opts,
Line 308  state_search(struct state *p, const struct opts *opts,
         len = 0;          len = 0;
         buf = NULL;          buf = NULL;
         bufsz = 0;          bufsz = 0;
         ch = 0;  
         regp = NULL;          regp = NULL;
   
         /*          /*
Line 318  state_search(struct state *p, const struct opts *opts,
Line 317  state_search(struct state *p, const struct opts *opts,
   
         switch (opts->match) {          switch (opts->match) {
         case (MATCH_REGEX):          case (MATCH_REGEX):
                 rflags = REG_EXTENDED | REG_NOSUB |                  ch = REG_EXTENDED | REG_NOSUB |
                         (opts->insens ? REG_ICASE : 0);                          (opts->insens ? REG_ICASE : 0);
   
                 if (0 != regcomp(&reg, q, rflags)) {                  if (0 != regcomp(&reg, q, ch)) {
                         fprintf(stderr, "%s: Bad pattern\n", q);                          fprintf(stderr, "%s: Bad pattern\n", q);
                         return;                          return;
                 }                  }
Line 339  state_search(struct state *p, const struct opts *opts,
Line 338  state_search(struct state *p, const struct opts *opts,
                 break;                  break;
         }          }
   
         if (NULL == (mc = mchars_alloc())) {          mc = mchars_alloc();
                 perror(NULL);  
                 exit(EXIT_FAILURE);  
         }  
   
         /*          /*
          * Iterate over the entire keyword database.           * Iterate over the entire keyword database.
Line 466  send:
Line 462  send:
                 exit(EXIT_FAILURE);                  exit(EXIT_FAILURE);
         }          }
   
         /*          /* Sort our results. */
          * Sort our results.  
          * We do this post-scan (instead of an in-line sort) because  
          * it's more or less the same in terms of run-time.  Assuming we  
          * sort in-line with a tree versus post:  
          *  
          *  In-place: n * O(lg n)  
          *  After: n + O(n lg n)  
          *  
          * Whatever.  This also buys us simplicity.  
          */  
   
         switch (opts->sort) {          if (SORT_CAT == opts->sort)
         case (SORT_CAT):  
                 qsort(res, len, sizeof(struct res), sort_cat);                  qsort(res, len, sizeof(struct res), sort_cat);
                 break;          else
         default:  
                 qsort(res, len, sizeof(struct res), sort_title);                  qsort(res, len, sizeof(struct res), sort_title);
                 break;  
         }  
   
         state_output(res, len);          state_output(res, len);
   

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

CVSweb