/[groff]/groff/src/libs/libgroff/searchpath.cpp
ViewVC logotype

Diff of /groff/src/libs/libgroff/searchpath.cpp

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

revision 1.3 by wlemb, Sat Dec 6 13:09:41 2003 UTC revision 1.4 by wl, Sat Apr 2 12:49:11 2005 UTC
# Line 1  Line 1 
1  // -*- C++ -*-  // -*- C++ -*-
2  /* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001, 2003  /* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2001, 2003, 2005
3     Free Software Foundation, Inc.     Free Software Foundation, Inc.
4       Written by James Clark (jjc@jclark.com)       Written by James Clark (jjc@jclark.com)
5    
# Line 28  Foundation, 59 Temple Place - Suite 330, Line 28  Foundation, 59 Temple Place - Suite 330,
28  #include "searchpath.h"  #include "searchpath.h"
29  #include "nonposix.h"  #include "nonposix.h"
30    
31    #ifdef _WIN32
32    # include "relocate.h"
33    #else
34    # define relocate(path) strsave(path)
35    #endif
36    
37  search_path::search_path(const char *envvar, const char *standard,  search_path::search_path(const char *envvar, const char *standard,
38                           int add_home, int add_current)                           int add_home, int add_current)
39  {  {
# Line 108  FILE *search_path::open_file(const char Line 114  FILE *search_path::open_file(const char
114      if (!end)      if (!end)
115        end = strchr(p, '\0');        end = strchr(p, '\0');
116      int need_slash = end > p && strchr(DIR_SEPS, end[-1]) == 0;      int need_slash = end > p && strchr(DIR_SEPS, end[-1]) == 0;
117      char *path = new char[(end - p) + need_slash + namelen + 1];      char *origpath = new char[(end - p) + need_slash + namelen + 1];
118      memcpy(path, p, end - p);      memcpy(origpath, p, end - p);
119      if (need_slash)      if (need_slash)
120        path[end - p] = '/';        origpath[end - p] = '/';
121      strcpy(path + (end - p) + need_slash, name);      strcpy(origpath + (end - p) + need_slash, name);
122    #if 0
123        fprintf(stderr, "origpath `%s'\n", origpath);
124    #endif
125        char *path = relocate(origpath);
126        a_delete origpath;
127  #if 0  #if 0
128      fprintf(stderr, "trying `%s'\n", path);      fprintf(stderr, "trying `%s'\n", path);
129  #endif  #endif
# Line 160  FILE *search_path::open_file_cautious(co Line 171  FILE *search_path::open_file_cautious(co
171      if (!end)      if (!end)
172        end = strchr(p, '\0');        end = strchr(p, '\0');
173      int need_slash = end > p && strchr(DIR_SEPS, end[-1]) == 0;      int need_slash = end > p && strchr(DIR_SEPS, end[-1]) == 0;
174      char *path = new char[(end - p) + need_slash + namelen + 1];      char *origpath = new char[(end - p) + need_slash + namelen + 1];
175      memcpy(path, p, end - p);      memcpy(origpath, p, end - p);
176      if (need_slash)      if (need_slash)
177        path[end - p] = '/';        origpath[end - p] = '/';
178      strcpy(path + (end - p) + need_slash, name);      strcpy(origpath + (end - p) + need_slash, name);
179    #if 0
180        fprintf(stderr, "origpath `%s'\n", origpath);
181    #endif
182        char *path = relocate(origpath);
183        a_delete origpath;
184  #if 0  #if 0
185      fprintf(stderr, "trying `%s'\n", path);      fprintf(stderr, "trying `%s'\n", path);
186  #endif  #endif

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

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