version 1.53, 2007/09/17 09:28:36 |
version 1.54, 2007/09/17 12:04:29 |
|
|
LstNode ln; /* a list element */ |
LstNode ln; /* a list element */ |
char *file; /* the current filename to check */ |
char *file; /* the current filename to check */ |
char *temp; /* index into file */ |
char *temp; /* index into file */ |
const char *cp; /* index of first slash, if any */ |
const char *basename; |
bool hasSlash; |
bool hasSlash; |
struct stat stb;/* Buffer for stat, if necessary */ |
struct stat stb;/* Buffer for stat, if necessary */ |
struct file_stamp *entry; |
struct file_stamp *entry; |
|
|
|
|
/* Find the final component of the name and note whether name has a |
/* Find the final component of the name and note whether name has a |
* slash in it */ |
* slash in it */ |
cp = Str_rchri(name, ename, '/'); |
basename = Str_rchri(name, ename, '/'); |
if (cp) { |
if (basename) { |
hasSlash = true; |
hasSlash = true; |
cp++; |
basename++; |
} else { |
} else { |
hasSlash = false; |
hasSlash = false; |
cp = name; |
basename = name; |
} |
} |
|
|
hv = ohash_interval(cp, &ename); |
hv = ohash_interval(basename, &ename); |
|
|
if (DEBUG(DIR)) |
if (DEBUG(DIR)) |
printf("Searching for %s...", name); |
printf("Searching for %s...", name); |
|
|
* the file in the current directory before anywhere else |
* the file in the current directory before anywhere else |
* and we always return exactly what the caller specified. */ |
* and we always return exactly what the caller specified. */ |
if (checkCurdirFirst && |
if (checkCurdirFirst && |
(!hasSlash || (cp - name == 2 && *name == '.')) && |
(!hasSlash || (basename - name == 2 && *name == '.')) && |
find_file_hashi(dot, cp, ename, hv) != NULL) { |
find_file_hashi(dot, basename, ename, hv) != NULL) { |
if (DEBUG(DIR)) |
if (DEBUG(DIR)) |
printf("in '.'\n"); |
printf("in '.'\n"); |
return Str_dupi(name, ename); |
return Str_dupi(name, ename); |
|
|
p = (struct PathEntry *)Lst_Datum(ln); |
p = (struct PathEntry *)Lst_Datum(ln); |
if (DEBUG(DIR)) |
if (DEBUG(DIR)) |
printf("%s...", p->name); |
printf("%s...", p->name); |
if (find_file_hashi(p, cp, ename, hv) != NULL) { |
if (find_file_hashi(p, basename, ename, hv) != NULL) { |
if (DEBUG(DIR)) |
if (DEBUG(DIR)) |
printf("here..."); |
printf("here..."); |
if (hasSlash) { |
if (hasSlash) { |
|
|
* part of one of the components of p along |
* part of one of the components of p along |
* with all the rest of them (*p1 != '/'). */ |
* with all the rest of them (*p1 != '/'). */ |
p1 = p->name + strlen(p->name) - 1; |
p1 = p->name + strlen(p->name) - 1; |
p2 = cp - 2; |
p2 = basename - 2; |
while (p2 >= name && p1 >= p->name && |
while (p2 >= name && p1 >= p->name && |
*p1 == *p2) { |
*p1 == *p2) { |
p1--; |
p1--; |
|
|
continue; |
continue; |
} |
} |
} |
} |
file = Str_concati(p->name, strchr(p->name, '\0'), cp, |
file = Str_concati(p->name, strchr(p->name, '\0'), |
ename, '/'); |
basename, ename, '/'); |
if (DEBUG(DIR)) |
if (DEBUG(DIR)) |
printf("returning %s\n", file); |
printf("returning %s\n", file); |
return file; |
return file; |
|
|
for (p1 = p->name, p2 = name; *p1 && *p1 == *p2; |
for (p1 = p->name, p2 = name; *p1 && *p1 == *p2; |
p1++, p2++) |
p1++, p2++) |
continue; |
continue; |
if (*p1 == '\0' && p2 == cp - 1) { |
if (*p1 == '\0' && p2 == basename - 1) { |
if (DEBUG(DIR)) |
if (DEBUG(DIR)) |
printf("has to be here but isn't -- returning NULL\n"); |
printf("has to be here but isn't -- returning NULL\n"); |
return NULL; |
return NULL; |