diff options
-rw-r--r-- | man.c | 14 | ||||
-rw-r--r-- | mdoc.c | 13 |
2 files changed, 12 insertions, 15 deletions
@@ -480,14 +480,14 @@ man_pmacro(struct man *m, int ln, char *buf, int offs) ppos = i; - /* Copy the first word into a nil-terminated buffer. */ - - for (j = 0; j < 4; j++, i++) - if ('\0' == (mac[j] = buf[i])) - break; - else if (' ' == buf[i]) - break; + /* + * Copy the first word into a nil-terminated buffer. + * Stop copying when a tab, space, or eoln is encountered. + */ + j = 0; + while (j < 4 && '\0' != buf[i] && ' ' != buf[i] && '\t' != buf[i]) + mac[j++] = buf[i++]; mac[j] = '\0'; if (j == 4 || j < 1) { @@ -776,16 +776,13 @@ mdoc_pmacro(struct mdoc *m, int ln, char *buf, int offs) sv = i; /* - * Copy the first word into a nil-terminated buffer. Stop - * copying when a tab, space, or eoln is encountered. + * Copy the first word into a nil-terminated buffer. + * Stop copying when a tab, space, or eoln is encountered. */ - for (j = 0; j < 4; j++, i++) - if ('\0' == (mac[j] = buf[i])) - break; - else if (' ' == buf[i] || '\t' == buf[i]) - break; - + j = 0; + while (j < 4 && '\0' != buf[i] && ' ' != buf[i] && '\t' != buf[i]) + mac[j++] = buf[i++]; mac[j] = '\0'; if (j == 4 || j < 2) { |