char *fgets(FAR char *buf, int buflen, FILE *stream) { /* Handle negative buffer size */ if (buflen < 0) { return NULL; } /* Let lib_fgets() do the heavy lifting */ else { return lib_fgets(buf, (size_t)buflen, stream, true, false); } }
FAR char *gets_s(FAR char *s, rsize_t n) { /* Handle the case where n is out of range as required */ if (n < 1 || n > RSIZE_MAX) { /* Set n=1, i.e., room only for the NUL terminator */ n = 1; } /* Then let lib_fgets() do the heavy lifting */ return lib_fgets(s, (size_t)n, stdin, false, true); }