summaryrefslogtreecommitdiffstats
path: root/roff.3
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2010-07-03 16:02:12 +0000
committerIngo Schwarze <schwarze@openbsd.org>2010-07-03 16:02:12 +0000
commitbb8eca89831f88bbc271b59fb94e94b2db26ee1e (patch)
treea89a66e8a581c86f4a5ddb4614cdc8fe37f318a7 /roff.3
parent63533c987d5ade538a926058188d4d64518a36f5 (diff)
downloadmandoc-bb8eca89831f88bbc271b59fb94e94b2db26ee1e.tar.gz
Rudimentary implementation of user-defined strings;
no time for more refinement right now. In particular, fixes terminfo(3) and mdoc.samples(7). ok kristaps@, who will add the HTML frontend bits
Diffstat (limited to 'roff.3')
-rw-r--r--roff.367
1 files changed, 67 insertions, 0 deletions
diff --git a/roff.3 b/roff.3
index d1460dd9..88031276 100644
--- a/roff.3
+++ b/roff.3
@@ -50,6 +50,15 @@
.Fc
.Ft void
.Fn roff_reset "struct roff *roff"
+.In regs.h
+.Ft "char *"
+.Fn roff_setstr "const char *name" "const char *string"
+.Ft "char *"
+.Fn roff_getstr "const char *name"
+.Ft "char *"
+.Fn roff_getstrn "const char *name" "size_t len"
+.Ft void
+.Fn roff_freestr void
.Sh DESCRIPTION
The
.Nm
@@ -145,6 +154,52 @@ Returns 0 on failure, 1 on success.
Signals that the parse is complete.
Returns 0 on failure, 1 on success.
.El
+.Sh USER-DEFINED STRINGS
+Strings defined by the
+.Xr roff 7
+.Sx \&ds
+instruction are saved using the
+.Fn roff_setstr
+function and retrieved using the
+.Fn roff_getstr
+and
+.Fn roff_getstrn
+functions.
+.Pp
+These functions take the name of the string to be accessed
+as their first argument.
+While
+.Fn roff_getstr
+requires the name to be null-terminated,
+.Fn roff_getstrn
+accepts non-terminated strings, but requires the length of the name
+to be specified.
+.Pp
+The second argument to
+.Fn roff_setstr
+is the new value of the string.
+It will be copied to internal storage, so both pointers to constant
+strings and pointers to volatile storage are acceptable.
+.Pp
+All of these functions return a pointer to the new value of the string
+in internal storage, which should be considered read-only, so use
+.Xr strdup 3
+on it as appropriate.
+The read functions return NULL when a string of the specified name
+is not available or empty, and
+.Fn roff_setstr
+returns NULL when memory allocation fails.
+In the latter case, the string will remain unset.
+.Pp
+The function
+.Fn roff_freestr
+clears all user-defined strings.
+It always succeeds.
+Both
+.Fn roff_reset
+and
+.Fn roff_free
+call it.
.Sh EXAMPLES
See
.Pa main.c
@@ -159,3 +214,15 @@ The
.Nm
library was written by
.An Kristaps Dzonsons Aq kristaps@bsd.lv .
+.Sh BUGS
+The implementation of user-defined strings needs improvement:
+.Bl -dash
+.It
+String values are taken literally and are not interpreted.
+.It
+Parsing of quoted strings is incomplete.
+.It
+The stings are stored internally using a singly linked list,
+which is fine for small numbers of strings,
+but ineffient when handling many strings.
+.El