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

Diff for /mandoc/main.c between version 1.343 and 1.344

version 1.343, 2020/02/10 13:49:15 version 1.344, 2020/02/24 21:16:31
Line 98  static int    fs_lookup(const struct manpaths *,
Line 98  static int    fs_lookup(const struct manpaths *,
 static  int               fs_search(const struct mansearch *,  static  int               fs_search(const struct mansearch *,
                                 const struct manpaths *, const char *,                                  const struct manpaths *, const char *,
                                 struct manpage **, size_t *);                                  struct manpage **, size_t *);
   static  void              glob_esc(char **, const char *, const char *);
 static  void              outdata_alloc(struct outstate *, struct manoutput *);  static  void              outdata_alloc(struct outstate *, struct manoutput *);
 static  void              parse(struct mparse *, int, const char *,  static  void              parse(struct mparse *, int, const char *,
                                 struct outstate *, struct manoutput *);                                  struct outstate *, struct manoutput *);
Line 674  usage(enum argmode argmode)
Line 675  usage(enum argmode argmode)
         exit((int)MANDOCLEVEL_BADARG);          exit((int)MANDOCLEVEL_BADARG);
 }  }
   
   static void
   glob_esc(char **dst, const char *src, const char *suffix)
   {
           while (*src != '\0') {
                   if (strchr("*?[", *src) != NULL)
                           *(*dst)++ = '\\';
                   *(*dst)++ = *src++;
           }
           while (*suffix != '\0')
                   *(*dst)++ = *suffix++;
   }
   
 static int  static int
 fs_lookup(const struct manpaths *paths, size_t ipath,  fs_lookup(const struct manpaths *paths, size_t ipath,
         const char *sec, const char *arch, const char *name,          const char *sec, const char *arch, const char *name,
Line 682  fs_lookup(const struct manpaths *paths, size_t ipath,
Line 695  fs_lookup(const struct manpaths *paths, size_t ipath,
         struct stat      sb;          struct stat      sb;
         glob_t           globinfo;          glob_t           globinfo;
         struct manpage  *page;          struct manpage  *page;
         char            *file;          char            *file, *cp;
         int              globres;          int              globres;
         enum form        form;          enum form        form;
   
           const char *const slman = "/man";
           const char *const slash = "/";
           const char *const sglob = ".[01-9]*";
   
         form = FORM_SRC;          form = FORM_SRC;
         mandoc_asprintf(&file, "%s/man%s/%s.%s",          mandoc_asprintf(&file, "%s/man%s/%s.%s",
             paths->paths[ipath], sec, name, sec);              paths->paths[ipath], sec, name, sec);
Line 709  fs_lookup(const struct manpaths *paths, size_t ipath,
Line 726  fs_lookup(const struct manpaths *paths, size_t ipath,
                 free(file);                  free(file);
         }          }
   
         mandoc_asprintf(&file, "%s/man%s/%s.[01-9]*",          cp = file = mandoc_malloc(strlen(paths->paths[ipath]) * 2 +
             paths->paths[ipath], sec, name);              strlen(slman) + strlen(sec) * 2 + strlen(slash) +
               strlen(name) * 2 + strlen(sglob) + 1);
           glob_esc(&cp, paths->paths[ipath], slman);
           glob_esc(&cp, sec, slash);
           glob_esc(&cp, name, sglob);
           *cp = '\0';
         globres = glob(file, 0, NULL, &globinfo);          globres = glob(file, 0, NULL, &globinfo);
         if (globres != 0 && globres != GLOB_NOMATCH)          if (globres != 0 && globres != GLOB_NOMATCH)
                 mandoc_msg(MANDOCERR_GLOB, 0, 0,                  mandoc_msg(MANDOCERR_GLOB, 0, 0,

Legend:
Removed from v.1.343  
changed lines
  Added in v.1.344

CVSweb