diff options
author | 2019-02-06 17:39:57 +0000 | |
---|---|---|
committer | 2019-02-06 17:39:57 +0000 | |
commit | aac18afaf1fdfbcfad293ffe3be14fc8655a5a44 (patch) | |
tree | e6c75f87238982635a05ea5e82d65b14814f7b5b | |
parent | Fix a possible mbuf leak in tcp_usrreq(). Make the error handling (diff) | |
download | wireguard-openbsd-aac18afaf1fdfbcfad293ffe3be14fc8655a5a44.tar.xz wireguard-openbsd-aac18afaf1fdfbcfad293ffe3be14fc8655a5a44.zip |
adjust style and comments in roff_getname(); no functional change
-rw-r--r-- | usr.bin/mandoc/roff.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/usr.bin/mandoc/roff.c b/usr.bin/mandoc/roff.c index bc60408efac..4b8198ca9e9 100644 --- a/usr.bin/mandoc/roff.c +++ b/usr.bin/mandoc/roff.c @@ -1,4 +1,4 @@ -/* $OpenBSD: roff.c,v 1.233 2019/01/05 09:10:24 schwarze Exp $ */ +/* $OpenBSD: roff.c,v 1.234 2019/02/06 17:39:57 schwarze Exp $ */ /* * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2010-2015, 2017-2019 Ingo Schwarze <schwarze@openbsd.org> @@ -3863,6 +3863,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) { @@ -3870,22 +3874,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); @@ -3894,7 +3896,8 @@ roff_getname(struct roff *r, char **cpp, int ln, int pos) } /* Read past spaces. */ - while (' ' == *cp) + + while (*cp == ' ') cp++; *cpp = cp; |