MCPcopy Create free account
hub / github.com/GJDuck/e9patch / fgets_unlocked

Function fgets_unlocked

examples/stdlib.c:3625–3652  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3623}
3624
3625static char *fgets_unlocked(char *s, int size, FILE *stream)
3626{
3627 if (stdio_stream_read_init(stream) < 0)
3628 return NULL;
3629 int i;
3630 for (i = 0; i < size-1; i++)
3631 {
3632 int c;
3633 if (stream->read_ptr < stream->read_end)
3634 c = (int)*stream->read_ptr++;
3635 else
3636 {
3637 c = fgetc_unlocked(stream);
3638 if (feof_unlocked(stream))
3639 break;
3640 if (ferror_unlocked(stream))
3641 return NULL;
3642 }
3643 s[i] = c;
3644 if (c == '\n')
3645 {
3646 i++;
3647 break;
3648 }
3649 }
3650 s[i] = '\0';
3651 return s;
3652}
3653
3654static char *fgets(char *s, int size, FILE *stream)
3655{

Callers 1

fgetsFunction · 0.85

Calls 4

stdio_stream_read_initFunction · 0.85
fgetc_unlockedFunction · 0.85
feof_unlockedFunction · 0.85
ferror_unlockedFunction · 0.85

Tested by

no test coverage detected