]> git.cameronkatri.com Git - mandoc.git/blobdiff - mandocdb.c
Back out lorder, which doesn't seem necessary (?). I think this means all
[mandoc.git] / mandocdb.c
index 8a3409aef43a76220fd3d71c61caec20f5e6ddfd..ca5ff1300e137615e10d74ccdba4818c7325cf7f 100644 (file)
@@ -1,4 +1,4 @@
-/*     $Id: mandocdb.c,v 1.18 2011/12/01 21:05:49 kristaps Exp $ */
+/*     $Id: mandocdb.c,v 1.23 2011/12/03 18:47:09 kristaps Exp $ */
 /*
  * Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
  * Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>
 #include <string.h>
 #include <unistd.h>
 
-#ifdef __linux__
+#if defined(__linux__)
+# include <endian.h>
 # include <db_185.h>
+#elif defined(__APPLE__)
+# include <libkern/OSByteOrder.h>
+# include <db.h>
 #else
 # include <db.h>
 #endif
@@ -626,15 +630,13 @@ index_merge(const struct of *of, struct mparse *mp,
                 * into the database.
                 */
 
-               vbuf.rec = rec;
+               vbuf.rec = htobe32(rec);
                seq = R_FIRST;
                while (0 == (ch = (*hash->seq)(hash, &key, &val, seq))) {
                        seq = R_NEXT;
-
-                       vbuf.mask = *(uint64_t *)val.data;
+                       vbuf.mask = htobe64(*(uint64_t *)val.data);
                        val.size = sizeof(struct db_val);
                        val.data = &vbuf;
-
                        dbt_put(db, dbf, &key, &val);
                }
                if (ch < 0) {
@@ -732,7 +734,7 @@ index_prune(const struct of *ofile, DB *db, const char *dbf,
                                break;
 
                        vbuf = val.data;
-                       if (*maxrec != vbuf->rec)
+                       if (*maxrec != betoh32(vbuf->rec))
                                continue;
 
                        if ((ch = (*db->del)(db, &key, R_CURSOR)) < 0)