=================================================================== RCS file: /cvs/mandoc/mandoc.c,v retrieving revision 1.42 retrieving revision 1.44 diff -u -p -r1.42 -r1.44 --- mandoc/mandoc.c 2011/03/20 16:02:05 1.42 +++ mandoc/mandoc.c 2011/03/28 23:52:13 1.44 @@ -1,4 +1,4 @@ -/* $Id: mandoc.c,v 1.42 2011/03/20 16:02:05 kristaps Exp $ */ +/* $Id: mandoc.c,v 1.44 2011/03/28 23:52:13 kristaps Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons * Copyright (c) 2011 Ingo Schwarze @@ -507,52 +507,27 @@ mandoc_hyph(const char *start, const char *c) } /* - * Check if a string is a punctuation delimiter. This only applies to - * mdoc(7) documents, but as it's used in both front-ends and back-ends, - * it needs to go here (instead of, say, in libmdoc.h). + * Find out whether a line is a macro line or not. If it is, adjust the + * current position and return one; if it isn't, return zero and don't + * change the current position. */ -enum mdelim -mandoc_isdelim(const char *p) +int +mandoc_getcontrol(const char *cp, int *ppos) { + int pos; - if ('\0' == p[0]) - return(DELIM_NONE); + pos = *ppos; - if ('\0' == p[1]) - switch (p[0]) { - case('('): - /* FALLTHROUGH */ - case('['): - return(DELIM_OPEN); - case('|'): - return(DELIM_MIDDLE); - case('.'): - /* FALLTHROUGH */ - case(','): - /* FALLTHROUGH */ - case(';'): - /* FALLTHROUGH */ - case(':'): - /* FALLTHROUGH */ - case('?'): - /* FALLTHROUGH */ - case('!'): - /* FALLTHROUGH */ - case(')'): - /* FALLTHROUGH */ - case(']'): - return(DELIM_CLOSE); - default: - return(DELIM_NONE); - } + if ('\\' == cp[pos] && '.' == cp[pos + 1]) + pos += 2; + else if ('.' == cp[pos] || '\'' == cp[pos]) + pos++; + else + return(0); - if ('\\' != p[0]) - return(DELIM_NONE); + while (' ' == cp[pos] || '\t' == cp[pos]) + pos++; - if (0 == strcmp(p + 1, ".")) - return(DELIM_CLOSE); - if (0 == strcmp(p + 1, "*(Ba")) - return(DELIM_MIDDLE); - - return(DELIM_NONE); + *ppos = pos; + return(1); }