Print this page
9718 update mandoc to 1.14.4
   1 /*      $Id: mansearch.c,v 1.76 2017/08/02 13:29:04 schwarze Exp $ */
   2 /*
   3  * Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv>
   4  * Copyright (c) 2013-2017 Ingo Schwarze <schwarze@openbsd.org>
   5  *
   6  * Permission to use, copy, modify, and distribute this software for any
   7  * purpose with or without fee is hereby granted, provided that the above
   8  * copyright notice and this permission notice appear in all copies.
   9  *
  10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
  11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
  13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  17  */
  18 #include "config.h"
  19 
  20 #include <sys/mman.h>
  21 #include <sys/types.h>


 171                         page = dbm_page_get(rp->page);
 172 
 173                         if (lstmatch(search->sec, page->sect) == 0 ||
 174                             lstmatch(search->arch, page->arch) == 0 ||
 175                             (search->argmode == ARG_NAME &&
 176                              rp->bits <= (int32_t)(NAME_SYN & NAME_MASK)))
 177                                 continue;
 178 
 179                         if (res == NULL) {
 180                                 cur = 1;
 181                                 break;
 182                         }
 183                         if (cur + 1 > maxres) {
 184                                 maxres += 1024;
 185                                 *res = mandoc_reallocarray(*res,
 186                                     maxres, sizeof(**res));
 187                         }
 188                         mpage = *res + cur;
 189                         mandoc_asprintf(&mpage->file, "%s/%s",
 190                             paths->paths[i], page->file + 1);










 191                         mpage->names = buildnames(page);
 192                         mpage->output = buildoutput(outkey, page);
 193                         mpage->ipath = i;
 194                         mpage->bits = rp->bits;
 195                         mpage->sec = *page->sect - '0';
 196                         if (mpage->sec < 0 || mpage->sec > 9)
 197                                 mpage->sec = 10;
 198                         mpage->form = *page->file;
 199                         free(rp);
 200                         cur++;
 201                 }
 202                 ohash_delete(htab);
 203                 free(htab);
 204                 dbm_close();
 205 
 206                 /*
 207                  * In man(1) mode, prefer matches in earlier trees
 208                  * over matches in later trees.
 209                  */
 210 


   1 /*      $Id: mansearch.c,v 1.77 2017/08/22 17:50:11 schwarze Exp $ */
   2 /*
   3  * Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv>
   4  * Copyright (c) 2013-2017 Ingo Schwarze <schwarze@openbsd.org>
   5  *
   6  * Permission to use, copy, modify, and distribute this software for any
   7  * purpose with or without fee is hereby granted, provided that the above
   8  * copyright notice and this permission notice appear in all copies.
   9  *
  10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
  11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR
  13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  17  */
  18 #include "config.h"
  19 
  20 #include <sys/mman.h>
  21 #include <sys/types.h>


 171                         page = dbm_page_get(rp->page);
 172 
 173                         if (lstmatch(search->sec, page->sect) == 0 ||
 174                             lstmatch(search->arch, page->arch) == 0 ||
 175                             (search->argmode == ARG_NAME &&
 176                              rp->bits <= (int32_t)(NAME_SYN & NAME_MASK)))
 177                                 continue;
 178 
 179                         if (res == NULL) {
 180                                 cur = 1;
 181                                 break;
 182                         }
 183                         if (cur + 1 > maxres) {
 184                                 maxres += 1024;
 185                                 *res = mandoc_reallocarray(*res,
 186                                     maxres, sizeof(**res));
 187                         }
 188                         mpage = *res + cur;
 189                         mandoc_asprintf(&mpage->file, "%s/%s",
 190                             paths->paths[i], page->file + 1);
 191                         if (access(chdir_status ? page->file + 1 :
 192                             mpage->file, R_OK) == -1) {
 193                                 warn("%s", mpage->file);
 194                                 warnx("outdated mandoc.db contains "
 195                                     "bogus %s entry, run makewhatis %s", 
 196                                     page->file + 1, paths->paths[i]);
 197                                 free(mpage->file);
 198                                 free(rp);
 199                                 continue;
 200                         }
 201                         mpage->names = buildnames(page);
 202                         mpage->output = buildoutput(outkey, page);
 203                         mpage->ipath = i;
 204                         mpage->bits = rp->bits;
 205                         mpage->sec = *page->sect - '0';
 206                         if (mpage->sec < 0 || mpage->sec > 9)
 207                                 mpage->sec = 10;
 208                         mpage->form = *page->file;
 209                         free(rp);
 210                         cur++;
 211                 }
 212                 ohash_delete(htab);
 213                 free(htab);
 214                 dbm_close();
 215 
 216                 /*
 217                  * In man(1) mode, prefer matches in earlier trees
 218                  * over matches in later trees.
 219                  */
 220