summaryrefslogtreecommitdiffstats
path: root/strings.c
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2009-02-24 11:43:13 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2009-02-24 11:43:13 +0000
commit9e0f9f2ee7f854665c6fbf442ea8339bbce17ecb (patch)
treec5b5201797d9e59ac3a378e66b6411e1b2610d7a /strings.c
parent6229c59e2536a1921c81abefed1a37bfd01790b0 (diff)
downloadmandoc-9e0f9f2ee7f854665c6fbf442ea8339bbce17ecb.tar.gz
Escape-sequence validation in place (for nodes).
Diffstat (limited to 'strings.c')
-rw-r--r--strings.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/strings.c b/strings.c
index 2b7cd4fc..3e9415c5 100644
--- a/strings.c
+++ b/strings.c
@@ -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)
{