summaryrefslogtreecommitdiffstats
path: root/mandoc.h
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-04-09 15:29:40 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-04-09 15:29:40 +0000
commit523c7db3c47602feb761c95b387c6c93138264f5 (patch)
treeb36433935eca0c86910b6a754aef3fa1363fe8bb /mandoc.h
parente99813aa631956ea6bc1323879f2817f2fe6f761 (diff)
downloadmandoc-523c7db3c47602feb761c95b387c6c93138264f5.tar.gz
Remove a2roffdeco() and mandoc_special() functions and replace them with
a public (mandoc.h) function mandoc_escape(), which merges the functionality of both prior functions. Reason: code duplication. The a2roffdeco() and mandoc_special() functions were pretty much the same thing and both quite complex. This allows one function to receive improvements in (e.g.) subexpression handling and performance, instead of having to replicate functionality. As such, the mandoc_escape() function already handles a superset of the escapes handled in previous versions and has improvements in performance (using strcspn(), for example) and reliable handling of subexpressions. This code Works For Me, but may need work to catch any regressions. Since the benefits are great (leaner code, simpler API), I'd rather have it in-tree than floating as a patch.
Diffstat (limited to 'mandoc.h')
-rw-r--r--mandoc.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/mandoc.h b/mandoc.h
index 60e05a34..a838c325 100644
--- a/mandoc.h
+++ b/mandoc.h
@@ -288,6 +288,20 @@ enum mparset {
MPARSE_MAN /* assume -man */
};
+enum mandoc_esc {
+ ESCAPE_ERROR = 0, /* bail! unparsable escape */
+ ESCAPE_IGNORE, /* escape to be ignored */
+ ESCAPE_SPECIAL, /* a regular special character */
+ ESCAPE_PREDEF, /* a predefined special character */
+ ESCAPE_FONT, /* a generic font mode */
+ ESCAPE_FONTBOLD, /* bold font mode */
+ ESCAPE_FONTITALIC, /* italic font mode */
+ ESCAPE_FONTROMAN, /* roman font mode */
+ ESCAPE_FONTPREV, /* previous font mode */
+ ESCAPE_NUMBERED, /* a numbered glyph */
+ ESCAPE_NOSPACE /* suppress space if the last on a line */
+};
+
typedef void (*mandocmsg)(enum mandocerr, enum mandoclevel,
const char *, int, int, const char *);
@@ -310,6 +324,8 @@ void *mandoc_calloc(size_t, size_t);
void *mandoc_malloc(size_t);
void *mandoc_realloc(void *, size_t);
+enum mandoc_esc mandoc_escape(const char **, const char **, int *);
+
__END_DECLS
#endif /*!MANDOC_H*/