Fix some issues and do some code cleanup

This commit is contained in:
Justine Tunney 2022-05-23 10:15:53 -07:00
parent 1f229e4efc
commit 312ed5c67c
72 changed files with 880 additions and 982 deletions

View file

@ -19,7 +19,15 @@
#include "libc/stdio/stdio.h"
/**
* Reads line from stream.
* Reads line from stream, e.g.
*
* char *line = NULL;
* size_t linesize = 0;
* while (getline(&line, &linesize, stdin) > 0) {
* _chomp(line);
* printf("%s\n", line);
* }
* free(line);
*
* This function delegates to getdelim(), which provides further
* documentation. Concerning lines, please note the \n or \r\n are
@ -30,7 +38,7 @@
* NUL-termination is guaranteed FTMP
* @return number of bytes read, including delim, excluding NUL, or -1
* w/ errno on EOF or error; see ferror() and feof()
* @see xgetline(), getdelim(), gettok_r()
* @see fgetln(), xgetline(), getdelim(), gettok_r()
*/
ssize_t getline(char **line, size_t *n, FILE *f) {
return getdelim(line, n, '\n', f);