MCPcopy Create free account
hub / github.com/coreboot/coreboot / compat_getline

Function compat_getline

util/kconfig/confdata.c:334–366  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

332}
333
334static ssize_t compat_getline(char **lineptr, size_t *n, FILE *stream)
335{
336 char *line = *lineptr;
337 size_t slen = 0;
338
339 for (;;) {
340 int c = getc(stream);
341
342 switch (c) {
343 case '\n':
344 if (add_byte(c, &line, slen, n) < 0)
345 goto e_out;
346 slen++;
347 /* fall through */
348 case EOF:
349 if (add_byte('\0', &line, slen, n) < 0)
350 goto e_out;
351 *lineptr = line;
352 if (slen == 0)
353 return -1;
354 return slen;
355 default:
356 if (add_byte(c, &line, slen, n) < 0)
357 goto e_out;
358 slen++;
359 }
360 }
361
362e_out:
363 line[slen-1] = '\0';
364 *lineptr = line;
365 return -1;
366}
367
368/* like getline(), but the newline character is stripped away */
369static ssize_t getline_stripped(char **lineptr, size_t *n, FILE *stream)

Callers 1

getline_strippedFunction · 0.85

Calls 1

add_byteFunction · 0.70

Tested by

no test coverage detected