summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-01-07 10:05:24 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-01-07 10:05:24 +0000
commit2cc9df49aa3cd600a0b05463454254f8b25ef6c3 (patch)
tree04f7facd6cb077a98246ccb4af9c70fc98021315
parent1c4f59ae8201641e47be50ebf60ced81bf2cc5f2 (diff)
downloadmandoc-2cc9df49aa3cd600a0b05463454254f8b25ef6c3.tar.gz
mandoc-2cc9df49aa3cd600a0b05463454254f8b25ef6c3.tar.zst
mandoc-2cc9df49aa3cd600a0b05463454254f8b25ef6c3.zip
Check for white-space at end of stand-alone macro line.
-rw-r--r--man.c13
-rw-r--r--mdoc.c22
2 files changed, 25 insertions, 10 deletions
diff --git a/man.c b/man.c
index 4f02352b..8e9165f2 100644
--- a/man.c
+++ b/man.c
@@ -1,4 +1,4 @@
-/* $Id: man.c,v 1.47 2010/01/01 17:14:27 kristaps Exp $ */
+/* $Id: man.c,v 1.48 2010/01/07 10:05:24 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -378,6 +378,7 @@ man_ptext(struct man *m, int line, char *buf)
for (i = 0; ' ' == buf[i]; i++)
/* Skip leading whitespace. */ ;
+
if (0 == buf[i]) {
if ( ! pstring(m, line, 0, &buf[i], 0))
return(0);
@@ -463,7 +464,7 @@ man_pmacro(struct man *m, int ln, char *buf)
i++;
while (buf[i] && ' ' == buf[i])
i++;
- if (0 == buf[i])
+ if ('\0' == buf[i])
goto out;
}
@@ -472,7 +473,7 @@ man_pmacro(struct man *m, int ln, char *buf)
/* Copy the first word into a nil-terminated buffer. */
for (j = 0; j < 4; j++, i++) {
- if (0 == (mac[j] = buf[i]))
+ if ('\0' == (mac[j] = buf[i]))
break;
else if (' ' == buf[i])
break;
@@ -507,6 +508,12 @@ man_pmacro(struct man *m, int ln, char *buf)
while (buf[i] && ' ' == buf[i])
i++;
+ /* Trailing whitespace? */
+
+ if ('\0' == buf[i] && ' ' == buf[i - 1])
+ if ( ! man_pwarn(m, ln, i - 1, WTSPACE))
+ goto err;
+
/* Remove prior ELINE macro, if applicable. */
if (m->flags & MAN_ELINE) {
diff --git a/mdoc.c b/mdoc.c
index cd184b09..3dc159e6 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc.c,v 1.114 2010/01/01 17:14:29 kristaps Exp $ */
+/* $Id: mdoc.c,v 1.115 2010/01/07 10:05:24 kristaps Exp $ */
/*
* Copyright (c) 2008, 2009 Kristaps Dzonsons <kristaps@kth.se>
*
@@ -597,7 +597,8 @@ parsetext(struct mdoc *m, int line, char *buf)
for (i = 0; ' ' == buf[i]; i++)
/* Skip leading whitespace. */ ;
- if (0 == buf[i])
+
+ if ('\0' == buf[i])
return(mdoc_perr(m, line, 0, ENOBLANK));
/*
@@ -613,7 +614,8 @@ parsetext(struct mdoc *m, int line, char *buf)
if (i && ' ' == buf[i] && '\\' == buf[i - 1])
continue;
- buf[i++] = 0;
+ buf[i++] = '\0';
+
if ( ! pstring(m, line, j, &buf[j], (size_t)(i - j)))
return(0);
@@ -621,7 +623,7 @@ parsetext(struct mdoc *m, int line, char *buf)
/* Skip trailing whitespace. */ ;
j = i;
- if (0 == buf[i])
+ if ('\0' == buf[i])
break;
}
@@ -658,7 +660,7 @@ parsemacro(struct mdoc *m, int ln, char *buf)
/* Empty lines are ignored. */
- if (0 == buf[1])
+ if ('\0' == buf[1])
return(1);
i = 1;
@@ -669,14 +671,14 @@ parsemacro(struct mdoc *m, int ln, char *buf)
i++;
while (buf[i] && ' ' == buf[i])
i++;
- if (0 == buf[i])
+ if ('\0' == buf[i])
return(1);
}
/* Copy the first word into a nil-terminated buffer. */
for (j = 0; j < 4; j++, i++) {
- if (0 == (mac[j] = buf[i]))
+ if ('\0' == (mac[j] = buf[i]))
break;
else if (' ' == buf[i])
break;
@@ -707,6 +709,12 @@ parsemacro(struct mdoc *m, int ln, char *buf)
while (buf[i] && ' ' == buf[i])
i++;
+ /* Trailing whitespace? */
+
+ if ('\0' == buf[i] && ' ' == buf[i - 1])
+ if ( ! mdoc_pwarn(m, ln, i - 1, ETAILWS))
+ goto err;
+
/*
* Begin recursive parse sequence. Since we're at the start of
* the line, we don't need to do callable/parseable checks.