summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--libmdoc.h13
-rw-r--r--mdoc_argv.c7
-rw-r--r--mdoc_macro.c24
-rw-r--r--mdoc_strings.c18
4 files changed, 36 insertions, 26 deletions
diff --git a/libmdoc.h b/libmdoc.h
index ee77dd68..af18b870 100644
--- a/libmdoc.h
+++ b/libmdoc.h
@@ -1,4 +1,4 @@
-/* $Id: libmdoc.h,v 1.45 2010/05/15 04:47:38 kristaps Exp $ */
+/* $Id: libmdoc.h,v 1.46 2010/05/15 08:54:04 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -131,6 +131,13 @@ enum margverr {
ARGV_WORD
};
+enum mdelim {
+ DELIM_NONE = 0,
+ DELIM_OPEN,
+ DELIM_MIDDLE,
+ DELIM_CLOSE
+};
+
extern const struct mdoc_macro *const mdoc_macros;
__BEGIN_DECLS
@@ -161,8 +168,8 @@ int mdoc_body_alloc(struct mdoc *, int, int, enum mdoct);
void mdoc_node_delete(struct mdoc *, struct mdoc_node *);
void mdoc_hash_init(void);
enum mdoct mdoc_hash_find(const char *);
-int mdoc_iscdelim(char);
-int mdoc_isdelim(const char *);
+enum mdelim mdoc_iscdelim(char);
+enum mdelim mdoc_isdelim(const char *);
size_t mdoc_isescape(const char *);
enum mdoc_sec mdoc_str2sec(const char *);
time_t mdoc_atotime(const char *);
diff --git a/mdoc_argv.c b/mdoc_argv.c
index cacc3a80..98d95d3c 100644
--- a/mdoc_argv.c
+++ b/mdoc_argv.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_argv.c,v 1.47 2010/05/15 04:47:38 kristaps Exp $ */
+/* $Id: mdoc_argv.c,v 1.48 2010/05/15 08:54:04 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -421,9 +421,10 @@ args(struct mdoc *m, int line, int *pos,
* we ONLY care about closing delimiters.
*/
- if ((fl & ARGS_DELIM) && mdoc_iscdelim(buf[*pos]) > 1) {
+ if ((fl & ARGS_DELIM) && DELIM_CLOSE == mdoc_iscdelim(buf[*pos])) {
for (i = *pos; buf[i]; ) {
- if (mdoc_iscdelim(buf[i]) < 2)
+ enum mdelim d = mdoc_iscdelim(buf[i]);
+ if (DELIM_NONE == d || DELIM_OPEN == d)
break;
i++;
if ('\0' == buf[i] || ' ' != buf[i])
diff --git a/mdoc_macro.c b/mdoc_macro.c
index ca6bbeab..3cdfca3a 100644
--- a/mdoc_macro.c
+++ b/mdoc_macro.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_macro.c,v 1.66 2010/05/15 06:48:13 kristaps Exp $ */
+/* $Id: mdoc_macro.c,v 1.67 2010/05/15 08:54:04 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -640,7 +640,7 @@ append_delims(struct mdoc *m, int line, int *pos, char *buf)
else if (ARGS_EOLN == ac)
break;
- assert(mdoc_isdelim(p));
+ assert(DELIM_NONE != mdoc_isdelim(p));
if ( ! mdoc_word_alloc(m, line, la, p))
return(0);
@@ -750,10 +750,11 @@ blk_exp_close(MACRO_PROT_ARGS)
static int
in_line(MACRO_PROT_ARGS)
{
- int la, lastpunct, cnt, d, nc, nl;
+ int la, lastpunct, cnt, nc, nl;
enum margverr av;
enum mdoct ntok;
enum margserr ac;
+ enum mdelim d;
struct mdoc_arg *arg;
char *p;
@@ -846,9 +847,9 @@ in_line(MACRO_PROT_ARGS)
* the word.
*/
- d = ARGS_QWORD == ac ? 0 : mdoc_isdelim(p);
+ d = ARGS_QWORD == ac ? DELIM_NONE : mdoc_isdelim(p);
- if (ARGS_QWORD != ac && d) {
+ if (ARGS_QWORD != ac && DELIM_NONE != d) {
if (0 == lastpunct && ! rew_elem(m, tok))
return(0);
lastpunct = 1;
@@ -858,7 +859,7 @@ in_line(MACRO_PROT_ARGS)
lastpunct = 0;
}
- if ( ! d)
+ if (DELIM_NONE == d)
cnt++;
if ( ! mdoc_word_alloc(m, line, la, p))
return(0);
@@ -1000,7 +1001,7 @@ blk_full(MACRO_PROT_ARGS)
ARGS_PHRASE != ac &&
ARGS_PPHRASE != ac &&
ARGS_QWORD != ac &&
- 1 == mdoc_isdelim(p)) {
+ DELIM_OPEN == mdoc_isdelim(p)) {
if ( ! mdoc_word_alloc(m, line, la, p))
return(0);
continue;
@@ -1133,7 +1134,7 @@ blk_part_imp(MACRO_PROT_ARGS)
break;
if (NULL == body && ARGS_QWORD != ac &&
- 1 == mdoc_isdelim(p)) {
+ DELIM_OPEN == mdoc_isdelim(p)) {
if ( ! mdoc_word_alloc(m, line, la, p))
return(0);
continue;
@@ -1252,7 +1253,7 @@ blk_part_exp(MACRO_PROT_ARGS)
/* Flush out leading punctuation. */
if (NULL == head && ARGS_QWORD != ac &&
- 1 == mdoc_isdelim(p)) {
+ DELIM_OPEN == mdoc_isdelim(p)) {
assert(NULL == body);
if ( ! mdoc_word_alloc(m, line, la, p))
return(0);
@@ -1397,7 +1398,7 @@ in_line_argn(MACRO_PROT_ARGS)
if ( ! (MDOC_IGNDELIM & mdoc_macros[tok].flags) &&
ARGS_QWORD != ac &&
- 0 == j && 1 == mdoc_isdelim(p)) {
+ 0 == j && DELIM_OPEN == mdoc_isdelim(p)) {
if ( ! mdoc_word_alloc(m, line, la, p))
return(0);
continue;
@@ -1425,7 +1426,8 @@ in_line_argn(MACRO_PROT_ARGS)
if ( ! (MDOC_IGNDELIM & mdoc_macros[tok].flags) &&
ARGS_QWORD != ac &&
- ! flushed && mdoc_isdelim(p)) {
+ ! flushed &&
+ DELIM_NONE != mdoc_isdelim(p)) {
if ( ! rew_elem(m, tok))
return(0);
flushed = 1;
diff --git a/mdoc_strings.c b/mdoc_strings.c
index ff8eba1f..2b669e29 100644
--- a/mdoc_strings.c
+++ b/mdoc_strings.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_strings.c,v 1.19 2010/05/12 08:41:17 kristaps Exp $ */
+/* $Id: mdoc_strings.c,v 1.20 2010/05/15 08:54:04 schwarze Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -57,17 +57,17 @@ static const char * const secnames[SEC__MAX] = {
* FIXME: this is repeated in print_text() (html.c) and term_word()
* (term.c).
*/
-int
+enum mdelim
mdoc_iscdelim(char p)
{
switch (p) {
- case('|'):
- /* FALLTHROUGH */
case('('):
/* FALLTHROUGH */
case('['):
- return(1);
+ return(DELIM_OPEN);
+ case('|'):
+ return(DELIM_MIDDLE);
case('.'):
/* FALLTHROUGH */
case(','):
@@ -83,16 +83,16 @@ mdoc_iscdelim(char p)
case(')'):
/* FALLTHROUGH */
case(']'):
- return(2);
+ return(DELIM_CLOSE);
default:
break;
}
- return(0);
+ return(DELIM_NONE);
}
-int
+enum mdelim
mdoc_isdelim(const char *p)
{
@@ -106,7 +106,7 @@ mdoc_isdelim(const char *p)
* is treated in exactly the same way as the vertical bar. This
* is the only function that checks for this.
*/
- return(0 == strcmp(p, "\\*(Ba"));
+ return(strcmp(p, "\\*(Ba") ? DELIM_NONE : DELIM_MIDDLE);
}