/[man-db]/man-db/src/manp.c
ViewVC logotype

Diff of /man-db/src/manp.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.29 by cjwatson, Wed Jul 30 21:16:21 2003 UTC revision 1.30 by cjwatson, Wed Jul 30 21:29:19 2003 UTC
# Line 127  static __inline__ char *has_mandir (cons Line 127  static __inline__ char *has_mandir (cons
127  static __inline__ char *fsstnd (const char *path);  static __inline__ char *fsstnd (const char *path);
128  static char *def_path (int flag);  static char *def_path (int flag);
129  static void add_dir_to_list (char **lp, const char *dir);  static void add_dir_to_list (char **lp, const char *dir);
130  static char **add_dir_to_path_list (char **mp, const char *p);  static char **add_dir_to_path_list (char **mphead, char **mp, const char *p);
131    
132    
133  static void add_to_list (const char *key, const char *cont, int flag)  static void add_to_list (const char *key, const char *cont, int flag)
# Line 347  static __inline__ void gripe_not_directo Line 347  static __inline__ void gripe_not_directo
347                  error (0, 0, _("warning: %s isn't a directory"), dir);                  error (0, 0, _("warning: %s isn't a directory"), dir);
348  }  }
349    
350    static void gripe_overlong_list (void)
351    {
352            error (FAIL, 0, _("manpath list too long"));
353    }
354    
355  /* accept a manpath list, separated with ':', return the associated  /* accept a manpath list, separated with ':', return the associated
356     catpath list */     catpath list */
# Line 943  static __inline__ char *get_manpath (cha Line 947  static __inline__ char *get_manpath (cha
947  static void add_dir_to_list (char **lp, const char *dir)  static void add_dir_to_list (char **lp, const char *dir)
948  {  {
949          int status;          int status;
950            int pos = 0;
951    
952          while (*lp != NULL) {          while (*lp != NULL) {
953                    if (pos > MAXDIRS - 1)
954                            gripe_overlong_list ();
955                  if (!strcmp (*lp, dir)) {                  if (!strcmp (*lp, dir)) {
956                          if (debug)                          if (debug)
957                                  fprintf (stderr,                                  fprintf (stderr,
# Line 953  static void add_dir_to_list (char **lp, Line 960  static void add_dir_to_list (char **lp,
960                          return;                          return;
961                  }                  }
962                  lp++;                  lp++;
963                    pos++;
964          }          }
965    
966          /* Not found -- add it. */          /* Not found -- add it. */
# Line 1002  static __inline__ char *has_mandir (cons Line 1010  static __inline__ char *has_mandir (cons
1010          return NULL;          return NULL;
1011  }  }
1012    
1013  static __inline__ char **add_dir_to_path_list (char **mp, const char *p)  static char **add_dir_to_path_list (char **mphead, char **mp, const char *p)
1014  {  {
1015          int status;          int status;
1016          char wd[PATH_MAX];          char wd[PATH_MAX];
1017          char *cwd = wd;          char *cwd = wd;
1018    
1019            if (mp - mphead > MAXDIRS - 1)
1020                    gripe_overlong_list ();
1021    
1022          status = is_directory (p);          status = is_directory (p);
1023    
1024          if (status < 0)          if (status < 0)
# Line 1037  static __inline__ char **add_dir_to_path Line 1048  static __inline__ char **add_dir_to_path
1048  void create_pathlist (const char *manp, char **mp)  void create_pathlist (const char *manp, char **mp)
1049  {  {
1050          const char *p, *end;          const char *p, *end;
1051            char **mphead = mp;
1052    
1053          /* Expand the manpath into a list for easier handling. */          /* Expand the manpath into a list for easier handling. */
1054    
1055          for (p = manp;; p = end + 1) {          for (p = manp;; p = end + 1) {
1056                  end = strchr (p, ':');                  end = strchr (p, ':');
1057                  if (end)                  if (end)
1058                          mp = add_dir_to_path_list (mp, xstrndup (p, end - p));                          mp = add_dir_to_path_list (mphead, mp,
1059                                                       xstrndup (p, end - p));
1060                  else {                  else {
1061                          mp = add_dir_to_path_list (mp, p);                          mp = add_dir_to_path_list (mphead, mp, p);
1062                          break;                          break;
1063                  }                  }
1064          }          }

Legend:
Removed from v.1.29  
changed lines
  Added in v.1.30

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26