summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--argv.c17
-rw-r--r--mdoc.323
-rw-r--r--strings.c10
-rw-r--r--term.c4
-rw-r--r--validate.c8
5 files changed, 41 insertions, 21 deletions
diff --git a/argv.c b/argv.c
index e9eafffc..663d5d5e 100644
--- a/argv.c
+++ b/argv.c
@@ -1,4 +1,4 @@
-/* $Id: argv.c,v 1.30 2009/02/24 11:43:13 kristaps Exp $ */
+/* $Id: argv.c,v 1.31 2009/02/24 13:46:54 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -267,7 +267,7 @@ static int
args(struct mdoc *mdoc, int line,
int *pos, char *buf, int fl, char **v)
{
- int i, c;
+ int i;
char *p, *pp;
assert(*pos > 0);
@@ -290,14 +290,11 @@ args(struct mdoc *mdoc, int line,
*/
if ((fl & ARGS_DELIM) && mdoc_iscdelim(buf[*pos])) {
- for (i = *pos; (c = buf[i]); ) {
- if ( ! mdoc_iscdelim(c))
+ for (i = *pos; buf[i]; ) {
+ if ( ! mdoc_iscdelim(buf[i]))
break;
i++;
- if (0 == buf[i] || ! isspace(c))
- break;
- i++;
- while (buf[i] && isspace(c))
+ while (buf[i] && isspace((int)buf[i]))
i++;
}
if (0 == buf[i]) {
@@ -404,8 +401,8 @@ args(struct mdoc *mdoc, int line,
/* Do non-tabsep look-ahead here. */
if ( ! (ARGS_TABSEP & fl))
- while ((c = buf[*pos])) {
- if (isspace(c))
+ while (buf[*pos]) {
+ if (isspace((int)buf[*pos]))
if ('\\' != buf[*pos - 1])
break;
(*pos)++;
diff --git a/mdoc.3 b/mdoc.3
index 059d8cf5..0adf9302 100644
--- a/mdoc.3
+++ b/mdoc.3
@@ -1,4 +1,4 @@
-.\" $Id: mdoc.3,v 1.9 2009/02/23 15:19:47 kristaps Exp $
+.\" $Id: mdoc.3,v 1.10 2009/02/24 13:46:54 kristaps Exp $
.\"
.\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
.\"
@@ -16,7 +16,7 @@
.\" TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
.\" PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: February 23 2009 $
+.Dd $Mdocdate: February 24 2009 $
.Dt mdoc 3
.Os
.\" SECTION
@@ -89,7 +89,9 @@ This section further defines the
.Sx Functions
and
.Sx Variables
-available to programmers. The last sub-section,
+available to programmers. Following that,
+.Sx Character Encoding
+describes input format. Lastly,
.Sx Abstract Syntax Tree ,
documents the output tree.
.\" SUBSECTION
@@ -174,6 +176,21 @@ An array of string-ified token names.
An array of string-ified token argument names.
.El
.\" SUBSECTION
+.Ss Character Encoding
+The
+.Xr mdoc 3
+library accepts only printable ASCII characters as defined by
+.Xr isprint 3 .
+Non-ASCII character sequences are escaped with an escape character
+.Sq \\
+and followed by either an open-parenthesis
+.Sq \&(
+for two-character sequences; an open-bracket
+.Sq \&[
+for n-character sequences (terminated at a close-bracket
+.Sq \&] ) ;
+or one of a small set of single characters for other escapes.
+.\" SUBSECTION
.Ss Abstract Syntax Tree
The
.Nm
diff --git a/strings.c b/strings.c
index c3b0403d..fe400b37 100644
--- a/strings.c
+++ b/strings.c
@@ -1,4 +1,4 @@
-/* $Id: strings.c,v 1.16 2009/02/24 11:43:13 kristaps Exp $ */
+/* $Id: strings.c,v 1.17 2009/02/24 13:46:54 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -55,14 +55,16 @@ mdoc_isescape(const char *p)
/* FALLTHROUGH */
case (' '):
/* FALLTHROUGH */
+ case ('&'):
+ /* FALLTHROUGH */
case ('.'):
/* FALLTHROUGH */
case ('e'):
return(2);
case ('('):
- if (0 == *++p)
+ if (0 == *++p || ! isgraph(*p))
return(0);
- if (0 == *++p)
+ if (0 == *++p || ! isgraph(*p))
return(0);
return(4);
case ('['):
@@ -72,7 +74,7 @@ mdoc_isescape(const char *p)
}
for (c = 3, p++; *p && ']' != *p; p++, c++)
- if (isspace(*p))
+ if ( ! isgraph(*p))
break;
return(*p == ']' ? c : 0);
diff --git a/term.c b/term.c
index 46514e4d..4d3be795 100644
--- a/term.c
+++ b/term.c
@@ -1,4 +1,4 @@
-/* $Id: term.c,v 1.12 2009/02/23 15:19:47 kristaps Exp $ */
+/* $Id: term.c,v 1.13 2009/02/24 13:46:54 kristaps Exp $ */
/*
* Copyright (c) 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -1054,7 +1054,7 @@ termp_sq_pre(DECL_ARGS)
if (MDOC_BODY != node->type)
return(1);
- word(p, "`");
+ word(p, "\'");
p->flags |= TERMP_NOSPACE;
return(1);
}
diff --git a/validate.c b/validate.c
index cbc02554..439a232d 100644
--- a/validate.c
+++ b/validate.c
@@ -1,4 +1,4 @@
-/* $Id: validate.c,v 1.55 2009/02/24 12:20:52 kristaps Exp $ */
+/* $Id: validate.c,v 1.56 2009/02/24 13:46:54 kristaps Exp $ */
/*
* Copyright (c) 2008 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -17,6 +17,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
#include <assert.h>
+#include <ctype.h>
#include <stdlib.h>
#include "private.h"
@@ -396,6 +397,9 @@ check_text(struct mdoc *mdoc, size_t line, size_t pos, const char *p)
size_t c;
for ( ; *p; p++) {
+ if ( ! isprint(*p) && '\t' != *p)
+ return(mdoc_perr(mdoc, line, pos,
+ "invalid characters"));
if ('\\' != *p)
continue;
if ((c = mdoc_isescape(p))) {
@@ -403,7 +407,7 @@ check_text(struct mdoc *mdoc, size_t line, size_t pos, const char *p)
continue;
}
return(mdoc_perr(mdoc, line, pos,
- "invalid escape sequence"));
+ "invalid escape sequence"));
}
return(1);