aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-12-02 00:21:56 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-12-02 00:21:56 +0000
commitb505ecce3956d6be1ab0554257d7ce9ead09ff89 (patch)
treef3fb355188472d17ff0826c27fc73d4b50e523ba
parentba6b743ba088a1ee889f6315c05711d3e4505d61 (diff)
downloadmandoc-b505ecce3956d6be1ab0554257d7ce9ead09ff89.tar.gz
mandoc-b505ecce3956d6be1ab0554257d7ce9ead09ff89.tar.zst
mandoc-b505ecce3956d6be1ab0554257d7ce9ead09ff89.zip
This is a little gross: Linux and Apple need lots some cajoling to work
with byte-swapping. Tested on Mac. Any Linux machines somebody can test on? Anybody? While here, note the correct byte-size in mandocdb(8) and also note field widths and endianness. The btree is now endian-neutral.
-rw-r--r--apropos_db.c12
-rw-r--r--config.h.post10
-rw-r--r--mandocdb.812
-rw-r--r--mandocdb.c8
4 files changed, 32 insertions, 10 deletions
diff --git a/apropos_db.c b/apropos_db.c
index 4a305e59..856bde34 100644
--- a/apropos_db.c
+++ b/apropos_db.c
@@ -1,4 +1,4 @@
-/* $Id: apropos_db.c,v 1.18 2011/12/01 23:55:58 kristaps Exp $ */
+/* $Id: apropos_db.c,v 1.19 2011/12/02 00:21:56 kristaps Exp $ */
/*
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -15,6 +15,10 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#include <assert.h>
#include <fcntl.h>
#include <regex.h>
@@ -24,8 +28,12 @@
#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
diff --git a/config.h.post b/config.h.post
index 3cdf9a78..62ce4ea6 100644
--- a/config.h.post
+++ b/config.h.post
@@ -15,6 +15,16 @@
# endif
#endif
+#if defined(__APPLE__)
+# define htobe32(x) OSSwapHostToBigInt32(x)
+# define betoh32(x) OSSwapBigToHostInt32(x)
+# define htobe64(x) OSSwapHostToBigInt64(x)
+# define betoh64(x) OSSwapBigToHostInt64(x)
+#elif defined(__linux__)
+# define betoh32(x) be32toh(x)
+# define betoh64(x) be64toh(x)
+#endif
+
#ifndef HAVE_STRLCAT
extern size_t strlcat(char *, const char *, size_t);
#endif
diff --git a/mandocdb.8 b/mandocdb.8
index 4c0ef876..e8e84ec8 100644
--- a/mandocdb.8
+++ b/mandocdb.8
@@ -1,4 +1,4 @@
-.\" $Id: mandocdb.8,v 1.10 2011/12/01 21:05:49 kristaps Exp $
+.\" $Id: mandocdb.8,v 1.11 2011/12/02 00:21:56 kristaps Exp $
.\"
.\" Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
.\"
@@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: December 1 2011 $
+.Dd $Mdocdate: December 2 2011 $
.Dt MANDOCDB 8
.Os
.Sh NAME
@@ -137,11 +137,11 @@ The keyword database,
is a
.Xr btree 3
database of NUL-terminated keywords (record length is non-zero string
-length plus one) mapping to a 8-byte binary field consisting of the
-keyword type and source
+length plus one) mapping to a 12-byte binary field consisting of the
+64-bit keyword type and 32-bit source
.Sx Index Database
-record number.
-The type, a 64-bit bit-mask in host order, consists of the following
+record number, both in network-byte order.
+The typet bit-mask consists of the following
values mapping into
.Xr mdoc 7
macro identifiers:
diff --git a/mandocdb.c b/mandocdb.c
index bea93986..b81867c5 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -1,4 +1,4 @@
-/* $Id: mandocdb.c,v 1.20 2011/12/01 23:55:58 kristaps Exp $ */
+/* $Id: mandocdb.c,v 1.21 2011/12/02 00:21:56 kristaps Exp $ */
/*
* Copyright (c) 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011 Ingo Schwarze <schwarze@openbsd.org>
@@ -33,8 +33,12 @@
#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