=================================================================== RCS file: /cvs/mandoc/mandoc.c,v retrieving revision 1.22 retrieving revision 1.25 diff -u -p -r1.22 -r1.25 --- mandoc/mandoc.c 2010/07/18 12:10:08 1.22 +++ mandoc/mandoc.c 2010/07/21 20:35:03 1.25 @@ -1,4 +1,4 @@ -/* $Id: mandoc.c,v 1.22 2010/07/18 12:10:08 kristaps Exp $ */ +/* $Id: mandoc.c,v 1.25 2010/07/21 20:35:03 kristaps Exp $ */ /* * Copyright (c) 2008, 2009, 2010 Kristaps Dzonsons * @@ -48,6 +48,49 @@ mandoc_special(char *p) p++; switch (*p++) { +#if 0 + case ('Z'): + /* FALLTHROUGH */ + case ('X'): + /* FALLTHROUGH */ + case ('x'): + /* FALLTHROUGH */ + case ('w'): + /* FALLTHROUGH */ + case ('v'): + /* FALLTHROUGH */ + case ('S'): + /* FALLTHROUGH */ + case ('R'): + /* FALLTHROUGH */ + case ('o'): + /* FALLTHROUGH */ + case ('N'): + /* FALLTHROUGH */ + case ('l'): + /* FALLTHROUGH */ + case ('L'): + /* FALLTHROUGH */ + case ('H'): + /* FALLTHROUGH */ + case ('h'): + /* FALLTHROUGH */ + case ('D'): + /* FALLTHROUGH */ + case ('C'): + /* FALLTHROUGH */ + case ('b'): + /* FALLTHROUGH */ + case ('B'): + /* FALLTHROUGH */ + case ('a'): + /* FALLTHROUGH */ + case ('A'): + if (*p++ != '\'') + return(0); + term = '\''; + break; +#endif case ('s'): if (ASCII_HYPH == *p) *p = '-'; @@ -83,6 +126,22 @@ mandoc_special(char *p) if (0 == i) return(0); break; +#if 0 + case ('Y'): + /* FALLTHROUGH */ + case ('V'): + /* FALLTHROUGH */ + case ('$'): + /* FALLTHROUGH */ + case ('n'): + /* FALLTHROUGH */ + case ('k'): + /* FALLTHROUGH */ +#endif + case ('M'): + /* FALLTHROUGH */ + case ('m'): + /* FALLTHROUGH */ case ('f'): /* FALLTHROUGH */ case ('F'): @@ -117,13 +176,13 @@ mandoc_special(char *p) for ( ; *p && term != *p; p++) if (ASCII_HYPH == *p) *p = '-'; - return(*p ? p - sv : 0); + return(*p ? (int)(p - sv) : 0); } for (i = 0; *p && i < len; i++, p++) if (ASCII_HYPH == *p) *p = '-'; - return(i == len ? p - sv : 0); + return(i == len ? (int)(p - sv) : 0); } @@ -240,8 +299,10 @@ mandoc_a2time(int flags, const char *p) int -mandoc_eos(const char *p, size_t sz) +mandoc_eos(const char *p, size_t sz, int enclosed) { + const char *q; + int found; if (0 == sz) return(0); @@ -252,8 +313,9 @@ mandoc_eos(const char *p, size_t sz) * propogate outward. */ - for ( ; sz; sz--) { - switch (p[(int)sz - 1]) { + found = 0; + for (q = p + (int)sz - 1; q >= p; q--) { + switch (*q) { case ('\"'): /* FALLTHROUGH */ case ('\''): @@ -261,22 +323,22 @@ mandoc_eos(const char *p, size_t sz) case (']'): /* FALLTHROUGH */ case (')'): + if (0 == found) + enclosed = 1; break; case ('.'): - /* Escaped periods. */ - if (sz > 1 && '\\' == p[(int)sz - 2]) - return(0); /* FALLTHROUGH */ case ('!'): /* FALLTHROUGH */ case ('?'): - return(1); + found = 1; + break; default: - return(0); + return(found && (!enclosed || isalnum(*q))); } } - return(0); + return(found && !enclosed); }