Improve backwards compatibility with GNU Make

This commit is contained in:
Justine Tunney 2021-05-02 07:48:59 -07:00
parent fabf7f9f02
commit 1f2288be6e
18 changed files with 412 additions and 96 deletions

View file

@ -25,16 +25,18 @@
*
* @return allocated line that needs free() and usually chomp() too,
* or NULL on ferror() or feof()
* @see getline() for a more difficult api
* @see getdelim() for a more difficult api
* @see chomp()
*/
char *xgetline(FILE *f) {
char *res;
size_t n, got;
char *p;
size_t n;
ssize_t m;
n = 0;
res = NULL;
if ((got = getdelim(&res, &n, '\n', f)) <= 0) {
free(res);
res = NULL;
p = 0;
if ((m = getdelim(&p, &n, '\n', f)) <= 0) {
free(p);
p = 0;
}
return res;
return p;
}