summaryrefslogtreecommitdiffstats
path: root/roff.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2019-02-06 17:40:13 +0000
committerIngo Schwarze <schwarze@openbsd.org>2019-02-06 17:40:13 +0000
commit3b603764164fcabf9c701ff02e59f9410c580ae8 (patch)
tree723794620c6bbd19cc834f4c0a9891a9e9574664 /roff.c
parent427d1cd9034623f69d06f46263f6330f77606663 (diff)
downloadmandoc-3b603764164fcabf9c701ff02e59f9410c580ae8.tar.gz
adjust style and comments in roff_getname(); no functional change
Diffstat (limited to 'roff.c')
-rw-r--r--roff.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/roff.c b/roff.c
index 91c87149..d0156977 100644
--- a/roff.c
+++ b/roff.c
@@ -3865,6 +3865,10 @@ roff_renamed(ROFF_ARGS)
return ROFF_CONT;
}
+/*
+ * Measure the length in bytes of the roff identifier at *cpp
+ * and advance the pointer to the next word.
+ */
static size_t
roff_getname(struct roff *r, char **cpp, int ln, int pos)
{
@@ -3872,22 +3876,20 @@ roff_getname(struct roff *r, char **cpp, int ln, int pos)
size_t namesz;
name = *cpp;
- if ('\0' == *name)
+ if (*name == '\0')
return 0;
- /* Read until end of name and terminate it with NUL. */
+ /* Advance cp to the byte after the end of the name. */
+
for (cp = name; 1; cp++) {
- if ('\0' == *cp || ' ' == *cp) {
- namesz = cp - name;
+ namesz = cp - name;
+ if (*cp == '\0' || *cp == ' ')
break;
- }
- if ('\\' != *cp)
+ if (*cp != '\\')
continue;
- namesz = cp - name;
- if ('{' == cp[1] || '}' == cp[1])
+ if (cp[1] == '{' || cp[1] == '}')
break;
- cp++;
- if ('\\' == *cp)
+ if (*++cp == '\\')
continue;
mandoc_msg(MANDOCERR_NAMESC, ln, pos,
"%.*s", (int)(cp - name + 1), name);
@@ -3896,7 +3898,8 @@ roff_getname(struct roff *r, char **cpp, int ln, int pos)
}
/* Read past spaces. */
- while (' ' == *cp)
+
+ while (*cp == ' ')
cp++;
*cpp = cp;