Changeset: 272d9c5179ea for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=272d9c5179ea
Modified Files:
MonetDB5/src/mal/mal_linker.mx
Branch: Jun2010
Log Message:
ensure that module autoload scripts are globally ordered
(10_first.mal, 20_second.mal, etc.)
even if we have multiple prefixes and hence multiple autoload directories
diffs (47 lines):
diff -r 826d23f08b53 -r 272d9c5179ea MonetDB5/src/mal/mal_linker.mx
--- a/MonetDB5/src/mal/mal_linker.mx Fri May 28 17:01:31 2010 +0200
+++ b/MonetDB5/src/mal/mal_linker.mx Sat May 29 12:45:27 2010 +0200
@@ -324,9 +324,13 @@
an environment variable.
@c
static int
-cmpstr(const void *p1, const void *p2)
+cmpstr(const void *_p1, const void *_p2)
{
- return strcmp(*(char* const*)p1, *(char* const*)p2);
+ const char *p1 = *(char* const*)_p1;
+ const char *p2 = *(char* const*)_p2;
+ const char *f1 = strrchr(p1, (int) DIR_SEP);
+ const char *f2 = strrchr(p2, (int) DIR_SEP);
+ return strcmp(f1?f1:p1, f2?f2:p2);
}
#define MAXMULTISCRIPT 48
@@ -377,7 +381,6 @@
/* see if this is a directory, if so, recurse */
if (recurse == 1 && (rdir = opendir(fullname)) != NULL) {
struct dirent *e;
- int ps = lasts;
/* list *ext, sort, return */
while ((e = readdir(rdir)) != NULL) {
if (strcmp(e->d_name, "..") == 0 ||
strcmp(e->d_name, ".") == 0)
@@ -398,10 +401,6 @@
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);
} else {
strcat(fullname + i + 1, ext);
@@ -418,6 +417,8 @@
if (lasts > 0) {
size_t i = 0;
int c;
+ /* assure that an ordering such as 10_first, 20_second works */
+ qsort(strs, lasts, sizeof(char *), cmpstr);
for (c = 0; c < lasts; c++)
i += strlen(strs[c]) + 1; /* PATH_SEP or \0 */
fullname = GDKrealloc(fullname, i);
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list