MCPcopy Create free account
hub / github.com/NetHack/NetHack / str_lines_maxlen

Function str_lines_maxlen

src/hacklib.c:251–272  ·  view source on GitHub ↗

return max line length from buffer comprising newline-separated strings */

Source from the content-addressed store, hash-verified

249
250/* return max line length from buffer comprising newline-separated strings */
251int
252str_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'}); */
275char *

Callers 1

mapfrag_fromstrFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected