--- cvs-1.11.4/src/filesubr.c.orig Tue Sep 24 22:47:09 2002 +++ cvs-1.11.4/src/filesubr.c Fri Jan 17 20:59:20 2003 @@ -18,6 +18,7 @@ file system semantics. */ #include +#include #include "cvs.h" static int deep_remove_dir PROTO((const char *path)); @@ -969,8 +970,24 @@ const char *dir; const char *file; { - char *path = xmalloc (strlen (dir) + 1 + strlen(file) + 1); - sprintf (path, "%s/%s", dir, file); + char *path,*cfgdir; + struct stat st; + int isdot = (*file == '.'); + + if ( (path = getenv("CONFIG_DIR")) && path[0] ) { + cfgdir = xmalloc(strlen(dir) + 1 + strlen(path) + 1); + sprintf(cfgdir, "%s/%s", dir, path); + } else + cfgdir = NULL; + if ( cfgdir && (stat(cfgdir, &st) != -1) && S_ISDIR(st.st_mode) ) { + path = xmalloc(strlen(cfgdir) + 1 + strlen(file)-isdot + 1); + sprintf (path, "%s/%s", cfgdir, file+isdot); + } else { + path = xmalloc (strlen (dir) + 1 + strlen(file) + 1); + sprintf (path, "%s/%s", dir, file); + } + if (cfgdir) + free(cfgdir); return path; }