]>
Commit | Line | Data |
---|---|---|
eca1808b JB |
1 | --- cvs-1.11.4/src/filesubr.c.orig Tue Sep 24 22:47:09 2002 |
2 | +++ cvs-1.11.4/src/filesubr.c Fri Jan 17 20:59:20 2003 | |
3 | @@ -18,6 +18,7 @@ | |
4 | file system semantics. */ | |
5804a068 | 5 | |
eca1808b | 6 | #include <assert.h> |
5804a068 TO |
7 | +#include <sys/stat.h> |
8 | #include "cvs.h" | |
5804a068 | 9 | |
eca1808b JB |
10 | static int deep_remove_dir PROTO((const char *path)); |
11 | @@ -969,8 +970,24 @@ | |
12 | const char *dir; | |
13 | const char *file; | |
5804a068 | 14 | { |
eca1808b JB |
15 | - char *path = xmalloc (strlen (dir) + 1 + strlen(file) + 1); |
16 | - sprintf (path, "%s/%s", dir, file); | |
17 | + char *path,*cfgdir; | |
5804a068 | 18 | + struct stat st; |
eca1808b JB |
19 | + int isdot = (*file == '.'); |
20 | + | |
21 | + if ( (path = getenv("CONFIG_DIR")) && path[0] ) { | |
22 | + cfgdir = xmalloc(strlen(dir) + 1 + strlen(path) + 1); | |
23 | + sprintf(cfgdir, "%s/%s", dir, path); | |
24 | + } else | |
25 | + cfgdir = NULL; | |
0ede5f01 | 26 | + if ( cfgdir && (stat(cfgdir, &st) != -1) && S_ISDIR(st.st_mode) ) { |
eca1808b JB |
27 | + path = xmalloc(strlen(cfgdir) + 1 + strlen(file)-isdot + 1); |
28 | + sprintf (path, "%s/%s", cfgdir, file+isdot); | |
29 | + } else { | |
30 | + path = xmalloc (strlen (dir) + 1 + strlen(file) + 1); | |
31 | + sprintf (path, "%s/%s", dir, file); | |
ecade4f5 | 32 | + } |
eca1808b JB |
33 | + if (cfgdir) |
34 | + free(cfgdir); | |
35 | return path; | |
36 | } | |
506d24d5 | 37 |