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

Diff for /mandoc/mansearch.c between version 1.70 and 1.74

version 1.70, 2017/04/17 20:05:08 version 1.74, 2017/07/01 09:47:30
Line 104  mansearch(const struct mansearch *search,
Line 104  mansearch(const struct mansearch *search,
         }          }
   
         cur = maxres = 0;          cur = maxres = 0;
         *res = NULL;          if (res != NULL)
                   *res = NULL;
   
         outkey = KEY_Nd;          outkey = KEY_Nd;
         if (search->outkey != NULL)          if (search->outkey != NULL)
Line 155  mansearch(const struct mansearch *search,
Line 156  mansearch(const struct mansearch *search,
                 chdir_status = 1;                  chdir_status = 1;
   
                 if (dbm_open(MANDOC_DB) == -1) {                  if (dbm_open(MANDOC_DB) == -1) {
                         warn("%s/%s", paths->paths[i], MANDOC_DB);                          if (errno != ENOENT)
                                   warn("%s/%s", paths->paths[i], MANDOC_DB);
                         continue;                          continue;
                 }                  }
   
Line 172  mansearch(const struct mansearch *search,
Line 174  mansearch(const struct mansearch *search,
                             lstmatch(search->arch, page->arch) == 0)                              lstmatch(search->arch, page->arch) == 0)
                                 continue;                                  continue;
   
                           if (res == NULL) {
                                   cur = 1;
                                   break;
                           }
                         if (cur + 1 > maxres) {                          if (cur + 1 > maxres) {
                                 maxres += 1024;                                  maxres += 1024;
                                 *res = mandoc_reallocarray(*res,                                  *res = mandoc_reallocarray(*res,
Line 203  mansearch(const struct mansearch *search,
Line 209  mansearch(const struct mansearch *search,
                 if (cur && search->firstmatch)                  if (cur && search->firstmatch)
                         break;                          break;
         }          }
         qsort(*res, cur, sizeof(struct manpage), manpage_compare);          if (res != NULL)
                   qsort(*res, cur, sizeof(struct manpage), manpage_compare);
         if (chdir_status && getcwd_status && chdir(buf) == -1)          if (chdir_status && getcwd_status && chdir(buf) == -1)
                 warn("%s", buf);                  warn("%s", buf);
         exprfree(e);          exprfree(e);
         *sz = cur;          *sz = cur;
         return 1;          return res != NULL || cur;
 }  }
   
 /*  /*
Line 516  buildoutput(size_t im, struct dbm_page *page)
Line 523  buildoutput(size_t im, struct dbm_page *page)
                 output = mandoc_malloc(sz);                  output = mandoc_malloc(sz);
                 i = 0;                  i = 0;
                 lstcat(output, &i, input, " # ");                  lstcat(output, &i, input, " # ");
                   output[i++] = '\0';
                   assert(i == sz);
                 return output;                  return output;
         }          }
   
Line 670  exprterm(const struct mansearch *search, int argc, cha
Line 679  exprterm(const struct mansearch *search, int argc, cha
                 return e;                  return e;
         }          }
   
           if (strcmp("-i", argv[*argi]) == 0 && *argi + 1 < argc) {
                   cs = 0;
                   ++*argi;
           } else
                   cs = 1;
   
         e = mandoc_calloc(1, sizeof(*e));          e = mandoc_calloc(1, sizeof(*e));
         e->type = EXPR_TERM;          e->type = EXPR_TERM;
         e->bits = 0;          e->bits = 0;
Line 688  exprterm(const struct mansearch *search, int argc, cha
Line 703  exprterm(const struct mansearch *search, int argc, cha
          * If needed, request regular expression handling.           * If needed, request regular expression handling.
          */           */
   
         cs = 1;  
         if (search->argmode == ARG_WORD) {          if (search->argmode == ARG_WORD) {
                 e->bits = TYPE_Nm;                  e->bits = TYPE_Nm;
                 e->match.type = DBM_REGEX;                  e->match.type = DBM_REGEX;

Legend:
Removed from v.1.70  
changed lines
  Added in v.1.74

CVSweb