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

Diff for /mandoc/manpath.c between version 1.24 and 1.27

version 1.24, 2015/04/28 16:13:45 version 1.27, 2015/10/11 21:12:55
Line 21 
Line 21 
 #include <sys/stat.h>  #include <sys/stat.h>
   
 #include <ctype.h>  #include <ctype.h>
   #include <err.h>
 #include <limits.h>  #include <limits.h>
 #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  #include <stdlib.h>
Line 29 
Line 30 
 #include "mandoc_aux.h"  #include "mandoc_aux.h"
 #include "manconf.h"  #include "manconf.h"
   
   #if !HAVE_MANPATH
 static  void     manconf_file(struct manconf *, const char *);  static  void     manconf_file(struct manconf *, const char *);
   #endif
 static  void     manpath_add(struct manpaths *, const char *, int);  static  void     manpath_add(struct manpaths *, const char *, int);
 static  void     manpath_parseline(struct manpaths *, char *, int);  static  void     manpath_parseline(struct manpaths *, char *, int);
   
Line 84  manconf_parse(struct manconf *conf, const char *file,
Line 87  manconf_parse(struct manconf *conf, const char *file,
         free(buf);          free(buf);
         pclose(stream);          pclose(stream);
 #else  #else
         char             manpath_default[] = MANPATH_DEFAULT;  
         char            *insert;          char            *insert;
   
         /* Always prepend -m. */          /* Always prepend -m. */
Line 104  manconf_parse(struct manconf *conf, const char *file,
Line 106  manconf_parse(struct manconf *conf, const char *file,
         /* No MANPATH; use man.conf(5) only. */          /* No MANPATH; use man.conf(5) only. */
         if (NULL == defp || '\0' == defp[0]) {          if (NULL == defp || '\0' == defp[0]) {
                 manconf_file(conf, file);                  manconf_file(conf, file);
                 if (conf->manpath.sz == 0)  
                         manpath_parseline(&conf->manpath, manpath_default, 0);  
                 return;                  return;
         }          }
   
Line 166  manpath_add(struct manpaths *dirs, const char *dir, in
Line 166  manpath_add(struct manpaths *dirs, const char *dir, in
         size_t           i;          size_t           i;
   
         if (NULL == (cp = realpath(dir, buf))) {          if (NULL == (cp = realpath(dir, buf))) {
                 if (complain) {                  if (complain)
                         fputs("manpath: ", stderr);                          warn("manpath: %s", dir);
                         perror(dir);  
                 }  
                 return;                  return;
         }          }
   
Line 178  manpath_add(struct manpaths *dirs, const char *dir, in
Line 176  manpath_add(struct manpaths *dirs, const char *dir, in
                         return;                          return;
   
         if (stat(cp, &sb) == -1) {          if (stat(cp, &sb) == -1) {
                 if (complain) {                  if (complain)
                         fputs("manpath: ", stderr);                          warn("manpath: %s", dir);
                         perror(dir);  
                 }  
                 return;                  return;
         }          }
   
Line 206  manconf_free(struct manconf *conf)
Line 202  manconf_free(struct manconf *conf)
         free(conf->output.style);          free(conf->output.style);
 }  }
   
   #if !HAVE_MANPATH
 static void  static void
 manconf_file(struct manconf *conf, const char *file)  manconf_file(struct manconf *conf, const char *file)
 {  {
         const char *const toks[] = { "manpath", "output", "_whatdb" };          const char *const toks[] = { "manpath", "output", "_whatdb" };
           char manpath_default[] = MANPATH_DEFAULT;
   
         FILE            *stream;          FILE            *stream;
         char            *cp, *ep;          char            *cp, *ep;
         size_t           len, tok;          size_t           len, tok;
   
         if ((stream = fopen(file, "r")) == NULL)          if ((stream = fopen(file, "r")) == NULL)
                 return;                  goto out;
   
         while ((cp = fgetln(stream, &len)) != NULL) {          while ((cp = fgetln(stream, &len)) != NULL) {
                 ep = cp + len;                  ep = cp + len;
Line 250  manconf_file(struct manconf *conf, const char *file)
Line 248  manconf_file(struct manconf *conf, const char *file)
                         /* FALLTHROUGH */                          /* FALLTHROUGH */
                 case 0:  /* manpath */                  case 0:  /* manpath */
                         manpath_add(&conf->manpath, cp, 0);                          manpath_add(&conf->manpath, cp, 0);
                           *manpath_default = '\0';
                         break;                          break;
                 case 1:  /* output */                  case 1:  /* output */
                         manconf_output(&conf->output, cp);                          manconf_output(&conf->output, cp);
Line 258  manconf_file(struct manconf *conf, const char *file)
Line 257  manconf_file(struct manconf *conf, const char *file)
                         break;                          break;
                 }                  }
         }          }
   
         fclose(stream);          fclose(stream);
   
   out:
           if (*manpath_default != '\0')
                   manpath_parseline(&conf->manpath, manpath_default, 0);
 }  }
   #endif
   
 void  void
 manconf_output(struct manoutput *conf, const char *cp)  manconf_output(struct manoutput *conf, const char *cp)

Legend:
Removed from v.1.24  
changed lines
  Added in v.1.27

CVSweb