about summary refs log tree commit diff
path: root/src/locale/catclose.c
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2019-08-07 21:15:53 -0400
committerRich Felker <dalias@aerifal.cx>2019-08-07 21:15:53 -0400
commit7590203c486d9002522019045d34ee3dee0a66f5 (patch)
tree5d0a587e9bdf2cafdac379f306e7be94447490c8 /src/locale/catclose.c
parentd0b547dfb5f7678cab6bc39dd736ed6454357ca4 (diff)
downloadmusl-7590203c486d9002522019045d34ee3dee0a66f5.tar.gz
musl-7590203c486d9002522019045d34ee3dee0a66f5.tar.xz
musl-7590203c486d9002522019045d34ee3dee0a66f5.zip
add non-stub implementation of catgets localization functions
these accept the netbsd/openbsd message catalog file format,
consisting of a sorted list of set headers and a sorted list of
message headers for each set, admitting trivial binary search for
lookups.

the gnu format was not chosen because it's unusably bad. it does not
admit efficient (log time or better) lookups; rather, it requires
linear search or hash table lookups, and the hash function is awful:
it's literally set_id*msg_id.
Diffstat (limited to 'src/locale/catclose.c')
-rw-r--r--src/locale/catclose.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/locale/catclose.c b/src/locale/catclose.c
index 02cd3e5c..54e24dd2 100644
--- a/src/locale/catclose.c
+++ b/src/locale/catclose.c
@@ -1,6 +1,14 @@
+#define _BSD_SOURCE
 #include <nl_types.h>
+#include <stdint.h>
+#include <endian.h>
+#include <sys/mman.h>
+
+#define V(p) be32toh(*(uint32_t *)(p))
 
 int catclose (nl_catd catd)
 {
+	char *map = (char *)catd;
+	munmap(map, V(map+8)+20);
 	return 0;
 }