diff options
author | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-02-24 11:43:13 +0000 |
---|---|---|
committer | Kristaps Dzonsons <kristaps@bsd.lv> | 2009-02-24 11:43:13 +0000 |
commit | 9e0f9f2ee7f854665c6fbf442ea8339bbce17ecb (patch) | |
tree | c5b5201797d9e59ac3a378e66b6411e1b2610d7a /strings.c | |
parent | 6229c59e2536a1921c81abefed1a37bfd01790b0 (diff) | |
download | mandoc-9e0f9f2ee7f854665c6fbf442ea8339bbce17ecb.tar.gz |
Escape-sequence validation in place (for nodes).
Diffstat (limited to 'strings.c')
-rw-r--r-- | strings.c | 44 |
1 files changed, 44 insertions, 0 deletions
@@ -35,6 +35,50 @@ extern char *strptime(const char *, const char *, struct tm *); #endif + +size_t +mdoc_isescape(const char *p) +{ + size_t c; + + if ('\\' != *p++) + return(0); + + switch (*p) { + case ('\\'): + /* FALLTHROUGH */ + case ('\''): + /* FALLTHROUGH */ + case ('`'): + /* FALLTHROUGH */ + case ('-'): + /* FALLTHROUGH */ + case (' '): + /* FALLTHROUGH */ + case ('.'): + /* FALLTHROUGH */ + case ('e'): + return(2); + case ('('): + if (0 == *++p) + return(0); + if (0 == *++p) + return(0); + return(4); + case ('['): + break; + default: + return(0); + } + + for (c = 3, p++; *p && ']' != *p; p++, c++) + if (isspace(*p)) + break; + + return(*p == ']' ? c : 0); +} + + int mdoc_iscdelim(char p) { |