MCPcopy Index your code
hub / github.com/NetHack/NetHack / mungspaces

Function mungspaces

src/hacklib.c:141–160  ·  view source on GitHub ↗

remove excess whitespace from a string buffer (in place) */

Source from the content-addressed store, hash-verified

139
140/* remove excess whitespace from a string buffer (in place) */
141char *
142mungspaces(char *bp)
143{
144 char c, *p, *p2;
145 boolean was_space = TRUE;
146
147 for (p = p2 = bp; (c = *p) != '\0'; p++) {
148 if (c == '\n')
149 break; /* treat newline the same as end-of-string */
150 if (c == '\t')
151 c = ' ';
152 if (c != ' ' || !was_space)
153 *p2++ = c;
154 was_space = (c == ' ');
155 }
156 if (was_space && p2 > bp)
157 p2--;
158 *p2 = '\0';
159 return bp;
160}
161
162/* skip leading whitespace; remove trailing whitespace, in place */
163char *

Callers 15

tty_get_ext_cmdFunction · 0.85
curses_asknameFunction · 0.85
curses_ext_cmdFunction · 0.85
update_valFunction · 0.85
optfn_fruitFunction · 0.85
optfn_glyphFunction · 0.85
optfn_pickup_typesFunction · 0.85
parse_role_optFunction · 0.85
wc_set_window_colorsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected