X-Git-Url: https://git.cameronkatri.com/mandoc.git/blobdiff_plain/71ddcd873082a3c68ed2be7b7661075fb09d5849..49ebebc92aace0e1d18aba716fa150daf7f311e1:/mandoc.c diff --git a/mandoc.c b/mandoc.c index d493c22f..da4a1606 100644 --- a/mandoc.c +++ b/mandoc.c @@ -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); - - 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); - } + pos = *ppos; - if ('\\' != p[0]) - return(DELIM_NONE); + if ('\\' == cp[pos] && '.' == cp[pos + 1]) + pos += 2; + else if ('.' == cp[pos] || '\'' == cp[pos]) + pos++; + else + return(0); - if (0 == strcmp(p + 1, ".")) - return(DELIM_CLOSE); - if (0 == strcmp(p + 1, "*(Ba")) - return(DELIM_MIDDLE); + while (' ' == cp[pos] || '\t' == cp[pos]) + pos++; - return(DELIM_NONE); + *ppos = pos; + return(1); }