summaryrefslogtreecommitdiffstats
path: root/mchars_alloc.3
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2015-10-13 22:59:54 +0000
committerIngo Schwarze <schwarze@openbsd.org>2015-10-13 22:59:54 +0000
commitb26f648a71b3259c793410232a0d3bbdd0aa54e3 (patch)
tree38c696a975659d4498c81dddfc966f0e30bc6326 /mchars_alloc.3
parent35c8bbbbc8de3992d8c2d207662d365f4d566865 (diff)
downloadmandoc-b26f648a71b3259c793410232a0d3bbdd0aa54e3.tar.gz
Major character table cleanup:
* Use ohash(3) rather than a hand-rolled hash table. * Make the character table static in the chars.c module: There is no need to pass a pointer around, we most certainly never want to use two different character tables concurrently. * No need to keep the characters in a separate file chars.in; that merely encourages downstream porters to mess with them. * Sort the characters to agree with the mandoc_chars(7) manual page. * Specify Unicode codepoints in hex, not decimal (that's the detail that originally triggered this patch). No functional change, minus 100 LOC, and i don't see a performance change.
Diffstat (limited to 'mchars_alloc.3')
-rw-r--r--mchars_alloc.327
1 files changed, 9 insertions, 18 deletions
diff --git a/mchars_alloc.3 b/mchars_alloc.3
index 44442e4a..cbdf081e 100644
--- a/mchars_alloc.3
+++ b/mchars_alloc.3
@@ -25,17 +25,13 @@
.Nm mchars_spec2cp ,
.Nm mchars_spec2str
.Nd character table for mandoc
-.Sh LIBRARY
-.Lb libmandoc
.Sh SYNOPSIS
.In sys/types.h
.In mandoc.h
-.Ft "struct mchars *"
-.Fn mchars_alloc "void"
.Ft void
-.Fo mchars_free
-.Fa "struct mchars *table"
-.Fc
+.Fn mchars_alloc void
+.Ft void
+.Fn mchars_free void
.Ft char
.Fo mchars_num2char
.Fa "const char *decimal"
@@ -48,13 +44,11 @@
.Fc
.Ft int
.Fo mchars_spec2cp
-.Fa "const struct mchars *table"
.Fa "const char *name"
.Fa "size_t sz"
.Fc
.Ft "const char *"
.Fo mchars_spec2str
-.Fa "const struct mchars *table"
.Fa "const char *name"
.Fa "size_t sz"
.Fa "size_t *rsz"
@@ -135,9 +129,9 @@ escape sequences.
.Pp
The function
.Fn mchars_alloc
-allocates an opaque
-.Vt "struct mchars *"
-table object for subsequent use by the following two lookup functions.
+initializes a static
+.Vt "struct ohash"
+object for subsequent use by the following two lookup functions.
When no longer needed, this object can be destroyed with
.Fn mchars_free .
.Pp
@@ -149,9 +143,7 @@ special character
.Fa name
consisting of
.Fa sz
-characters in the
-.Fa table
-and returns the corresponding Unicode codepoint.
+characters and returns the corresponding Unicode codepoint.
If the
.Ar name
is not recognized, \-1 is returned.
@@ -175,9 +167,7 @@ special character
.Fa name
consisting of
.Fa sz
-characters in the
-.Fa table
-and returns an ASCII string representation.
+characters and returns an ASCII string representation.
The length of the representation is returned in
.Fa rsz .
In many cases, the meaning of such ASCII representations
@@ -215,6 +205,7 @@ These funtions are implemented in the file
.Sh SEE ALSO
.Xr mandoc 1 ,
.Xr mandoc_escape 3 ,
+.Xr ohash_init 3 ,
.Xr mandoc_char 7 ,
.Xr roff 7
.Sh HISTORY