Reading a line on a fd is way too tedious.
Linted according to the norminette
v3.3.51 rules.
The first version of GNL, score: 125.
A refinment of the GNL v1. Tested with gnlTester. Used in the libftx project.
The result of getline
analysis. Resulting in the following functions suitable for the libftx:
-
ssize_t ft_getline(char **lineptr, size_t *n, FILE *stream);
-
ssize_t ft_getdelim(char ** lineptr, size_t *n, int delim, FILE *stream);
"Yes" answers why to embed the aforementioned functions:
-
the ordinary
get_next_line
returns NULL both when the end of stream is reached and if an error occured - this is misleading, therefore error-prone; -
the return/status code is a good way to take: either a nonnegative number of bytes consumed or a negative error code - this strategy is cleaner than one immanent to the classic
get-next-line
contract.