Probably about time I had a central header file containing misc stuff.
[sgt/agedu] / trie.c
diff --git a/trie.c b/trie.c
index acce8be..b044df4 100644 (file)
--- a/trie.c
+++ b/trie.c
 #include <sys/types.h>
 #include <unistd.h>
 
+#include "agedu.h"
 #include "malloc.h"
 #include "trie.h"
 
 #define alignof(typ) ( offsetof(struct { char c; typ t; }, t) )
 
-extern char pathsep;
-
 /*
  * Compare functions for pathnames. Returns the relative order of
  * the names, like strcmp; also passes back the offset of the
@@ -617,3 +616,12 @@ off_t trie_get_index_offset(const void *t)
 {
     return ((const struct trie_header *)t)->indexroot;
 }
+
+void make_successor(char *pathbuf)
+{
+    int len = strlen(pathbuf);
+    if (len > 0 && pathbuf[len-1] == pathsep)
+       len--;
+    pathbuf[len] = '\001';
+    pathbuf[len+1] = '\0';
+}