Change the index file format to explicitly indicate the appropriate
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sat, 1 Nov 2008 16:01:10 +0000 (16:01 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Sat, 1 Nov 2008 16:01:10 +0000 (16:01 +0000)
path separator.

git-svn-id: svn://svn.tartarus.org/sgt/agedu@8242 cda61777-01e9-0310-a592-d414129be87e

agedu.c
trie.c
trie.h

diff --git a/agedu.c b/agedu.c
index d72c73d..18524d2 100644 (file)
--- a/agedu.c
+++ b/agedu.c
@@ -869,6 +869,7 @@ int main(int argc, char **argv)
            perror("agedu: mmap");
            return 1;
        }
+       pathsep = trie_pathsep(mappedfile);
 
        /*
         * Trim trailing slash, just in case.
@@ -900,6 +901,7 @@ int main(int argc, char **argv)
            perror("agedu: mmap");
            return 1;
        }
+       pathsep = trie_pathsep(mappedfile);
 
        /*
         * Trim trailing slash, just in case.
@@ -935,6 +937,7 @@ int main(int argc, char **argv)
            perror("agedu: mmap");
            return 1;
        }
+       pathsep = trie_pathsep(mappedfile);
 
        maxpathlen = trie_maxpathlen(mappedfile);
        buf = snewn(maxpathlen, char);
@@ -964,6 +967,7 @@ int main(int argc, char **argv)
            perror("agedu: mmap");
            return 1;
        }
+       pathsep = trie_pathsep(mappedfile);
 
        dcfg.address = httpserveraddr;
        dcfg.port = httpserverport;
diff --git a/trie.c b/trie.c
index 7061c74..acce8be 100644 (file)
--- a/trie.c
+++ b/trie.c
@@ -110,6 +110,7 @@ struct trie_header {
     off_t root, indexroot;
     int count;
     size_t maxpathlen;
+    int pathsep;
 };
 
 /* Union only used for computing alignment */
@@ -200,6 +201,7 @@ triebuild *triebuild_new(int fd)
     th.root = th.count = 0;
     th.indexroot = 0;
     th.maxpathlen = 0;
+    th.pathsep = (unsigned char)pathsep;
 
     tb_seek(tb, 0);
     tb_write(tb, &th, sizeof(th));
@@ -375,6 +377,7 @@ int triebuild_finish(triebuild *tb)
     th.root = triebuild_unwind(tb, 0, &th.count);
     th.indexroot = 0;
     th.maxpathlen = tb->maxpathlen;
+    th.pathsep = (unsigned char)pathsep;
 
     tb_seek(tb, 0);
     tb_write(tb, &th, sizeof(th));
@@ -496,6 +499,12 @@ unsigned long trie_count(const void *t)
     return hdr->count;
 }
 
+char trie_pathsep(const void *t)
+{
+    const struct trie_header *hdr = NODE(t, 0, trie_header);
+    return (char)hdr->pathsep;
+}
+
 struct triewalk_switch {
     const struct trie_switch *sw;
     int pos, depth, count;
diff --git a/trie.h b/trie.h
index 6d377b5..2f88291 100644 (file)
--- a/trie.h
+++ b/trie.h
@@ -55,6 +55,11 @@ void triebuild_free(triebuild *tb);
  */
 
 /*
+ * Return the path separator character in use in the trie.
+ */
+char trie_pathsep(const void *t);
+
+/*
  * Return the length of the longest pathname stored in the trie,
  * including its trailing NUL.
  */