remove excess whitespace from a string buffer (in place) */
| 139 | |
| 140 | /* remove excess whitespace from a string buffer (in place) */ |
| 141 | char * |
| 142 | mungspaces(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 */ |
| 163 | char * |
no outgoing calls
no test coverage detected