return max line length from buffer comprising newline-separated strings */
| 249 | |
| 250 | /* return max line length from buffer comprising newline-separated strings */ |
| 251 | int |
| 252 | str_lines_maxlen(const char *str) |
| 253 | { |
| 254 | const char *s1, *s2; |
| 255 | int len, max_len = 0; |
| 256 | |
| 257 | s1 = str; |
| 258 | while (s1 && *s1) { |
| 259 | s2 = strchr(s1, '\n'); |
| 260 | if (s2) { |
| 261 | len = (int) (s2 - s1); |
| 262 | s1 = s2 + 1; |
| 263 | } else { |
| 264 | len = (int) strlen(s1); |
| 265 | s1 = (char *) 0; |
| 266 | } |
| 267 | if (len > max_len) |
| 268 | max_len = len; |
| 269 | } |
| 270 | |
| 271 | return max_len; |
| 272 | } |
| 273 | |
| 274 | /* append a character to a string (in place): strcat(s, {c,'\0'}); */ |
| 275 | char * |