# HG changeset patch # User Dan Winship # Date 1203529362 18000 # Node ID 3142795705a564bdd342ade388c1e7a4d21c9197 # Parent e56c83bda295c0b4fa12e6d71e5cafb573fb5849 Fix file importing code to not generate some duplicate directories build_file_tree() depends on the fact that the contents of a directory are sorted immediately after it in the file list, but '.' sorts before '/' lexicographically, so you'd actually end up with, eg: /etc/yum /etc/yum.conf /etc/yum/pluginconf.d which would cause a second entry for /etc/yum to be added to the file list. For now I've fixed this by make compare_filenames() do a special strcmp by hand, manually sorting '/' before anything else. diff -r e56c83bda295 -r 3142795705a5 razor.c --- a/razor.c Fri Feb 15 15:09:37 2008 -0500 +++ b/razor.c Wed Feb 20 12:42:42 2008 -0500 @@ -530,8 +530,29 @@ { const struct import_entry *e1 = p1; const struct import_entry *e2 = p2; + const char *n1 = e1->name; + const char *n2 = e2->name; - return strcmp(e1->name, e2->name); + /* Need to make sure that the contents of a directory + * are sorted immediately after it. So "foo/bar" has to + * sort before "foo.conf" + * + * FIXME: this is about 60% slower than strcmp + */ + while (*n1 && *n2) { + if (*n1 < *n2) + return *n2 == '/' ? 1 : -1; + else if (*n1 > *n2) + return *n1 == '/' ? -1 : 1; + n1++; + n2++; + } + if (*n1) + return 1; + else if (*n2) + return -1; + else + return 0; } static void