Changeset: 96d56308afea for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=96d56308afea Modified Files: MonetDB5/src/mal/mal_linker.mx Branch: Jun2010 Log Message:
Try and solve autoloading problem as used by testing. Refine the recursive searching for autoload modules not to stop on the first found directory, but to keep on scanning in the mod_path for as long as there are entries. In this way all modules found in the entire mod_path are returned, instead of only the ones in the first directory found in the mod_path. Ordering is based first on mod_path order, then in each directory sorted by name. diffs (96 lines): diff -r 9e8b558da147 -r 96d56308afea MonetDB5/src/mal/mal_linker.mx --- a/MonetDB5/src/mal/mal_linker.mx Thu May 27 19:58:38 2010 +0200 +++ b/MonetDB5/src/mal/mal_linker.mx Thu May 27 22:11:33 2010 +0200 @@ -329,6 +329,7 @@ return strcmp(*(char* const*)p1, *(char* const*)p2); } +#define MAXMULTISCRIPT 48 static char * locate_file(const char *basename, const char *ext, const bit recurse) { @@ -336,6 +337,8 @@ char *fullname; size_t fullnamelen; size_t filelen = strlen(basename) + strlen(ext); + str strs[MAXMULTISCRIPT]; /* hardwired limit */ + int lasts = 0; if (mod_path == NULL) return NULL; @@ -374,9 +377,7 @@ /* see if this is a directory, if so, recurse */ if (recurse == 1 && (rdir = opendir(fullname)) != NULL) { struct dirent *e; - str strs[48]; /* hardwired limit */ - int lasts = 0; - int c; + int ps = lasts; /* list *ext, sort, return */ while ((e = readdir(rdir)) != NULL) { if (strcmp(e->d_name, "..") == 0 || strcmp(e->d_name, ".") == 0) @@ -394,38 +395,42 @@ fullname, DIR_SEP, GDKstrdup(e->d_name)); lasts++; } - if (lasts >= 48) + if (lasts >= MAXMULTISCRIPT) break; } + if (lasts - ps > 0) { + /* assure that an ordering such as 10_first, 20_second works */ + qsort(strs + ps, lasts - ps, sizeof(char *), cmpstr); + } (void)closedir(rdir); - if (lasts > 0) { - /* assure that an ordering such as 10_first, 20_second works */ - qsort(strs, lasts, sizeof(char *), cmpstr); - i = 0; - for (c = 0; c < lasts; c++) - i += strlen(strs[c]) + 1; /* PATH_SEP or \0 */ - fullname = GDKrealloc(fullname, i); - i = 0; - for (c = 0; c < lasts; c++) { - strcpy(fullname + i, strs[c]); - i += strlen(strs[c]); - fullname[i++] = PATH_SEP; - GDKfree(strs[c]); - } - fullname[i - 1] = '\0'; - return fullname; + } else { + strcat(fullname + i + 1, ext); + if ((fd = open(fullname, O_RDONLY)) >= 0) { + close(fd); + return GDKrealloc(fullname, strlen(fullname) + 1); } } - strcat(fullname + i + 1, ext); - if ((fd = open(fullname, O_RDONLY)) >= 0) { - close(fd); - return GDKrealloc(fullname, strlen(fullname) + 1); - } if ((mod_path = p) == NULL) break; while (*mod_path == PATH_SEP) mod_path++; } + if (lasts > 0) { + int i = 0; + int c; + for (c = 0; c < lasts; c++) + i += strlen(strs[c]) + 1; /* PATH_SEP or \0 */ + fullname = GDKrealloc(fullname, i); + i = 0; + for (c = 0; c < lasts; c++) { + strcpy(fullname + i, strs[c]); + i += strlen(strs[c]); + fullname[i++] = PATH_SEP; + GDKfree(strs[c]); + } + fullname[i - 1] = '\0'; + return fullname; + } /* not found */ GDKfree(fullname); return NULL; _______________________________________________ Checkin-list mailing list Checkin-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/checkin-list