diff options
author | Ingo Schwarze <schwarze@openbsd.org> | 2019-02-06 17:40:13 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@openbsd.org> | 2019-02-06 17:40:13 +0000 |
commit | 50896331bceb2d7578b7d71bbe8cc4a4d8452fc8 (patch) | |
tree | 6f7fd46475322a66485347d0f72ef254a312db4e | |
parent | a0f03465ebb77a4dc5d647d7b5d4f721d1127873 (diff) | |
download | mandoc-50896331bceb2d7578b7d71bbe8cc4a4d8452fc8.tar.gz mandoc-50896331bceb2d7578b7d71bbe8cc4a4d8452fc8.tar.zst mandoc-50896331bceb2d7578b7d71bbe8cc4a4d8452fc8.zip |
adjust style and comments in roff_getname(); no functional change
-rw-r--r-- | roff.c | 27 |
1 files changed, 15 insertions, 12 deletions
@@ -1,4 +1,4 @@ -/* $Id: roff.c,v 1.361 2019/01/05 09:10:32 schwarze Exp $ */ +/* $Id: roff.c,v 1.362 2019/02/06 17:40:13 schwarze Exp $ */ /* * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2015, 2017-2019 Ingo Schwarze <schwarze@openbsd.org> @@ -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; |