Skip to content

Commit 6f21acd

Browse files
committed
Use gnulib getline if system implementation not available
Assisted-by: Cursor
1 parent a17a590 commit 6f21acd

5 files changed

Lines changed: 92 additions & 84 deletions

File tree

lib/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,5 @@
7171
/verify.h
7272
/warn-on-use.h
7373
/xalloc-oversized.h
74+
/getdelim.c
75+
/getline.c

lib/Makefile

Lines changed: 86 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
# --no-libtool \
4848
# --macro-prefix=gl \
4949
# error \
50+
# getline \
5051
# getopt-gnu
5152

5253

@@ -133,18 +134,20 @@ host_triplet = x86_64-pc-linux-gnu
133134
#am__append_3 = error.c
134135
am__append_4 = fcntl.c
135136
#am__append_5 = fstat.c
136-
#am__append_6 = getdtablesize.c
137-
#am__append_7 = getopt.c getopt1.c
138-
am__append_8 = getprogname.c
139-
#am__append_9 = lstat.c
140-
#am__append_10 = msvc-inval.c
141-
#am__append_11 = msvc-nothrow.c
142-
#am__append_12 = open.c
143-
#am__append_13 = stat.c
144-
#am__append_14 = stdio-read.c
145-
#am__append_15 = stdio-write.c
146-
#am__append_16 = strerror.c
147-
#am__append_17 = strerror-override.c
137+
#am__append_6 = getdelim.c
138+
#am__append_7 = getdtablesize.c
139+
#am__append_8 = getline.c
140+
#am__append_9 = getopt.c getopt1.c
141+
am__append_10 = getprogname.c
142+
#am__append_11 = lstat.c
143+
#am__append_12 = msvc-inval.c
144+
#am__append_13 = msvc-nothrow.c
145+
#am__append_14 = open.c
146+
#am__append_15 = stat.c
147+
#am__append_16 = stdio-read.c
148+
#am__append_17 = stdio-write.c
149+
#am__append_18 = strerror.c
150+
#am__append_19 = strerror-override.c
148151
subdir = lib
149152
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
150153
am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \
@@ -158,7 +161,8 @@ am__aclocal_m4_deps = $(top_srcdir)/m4/00gnulib.m4 \
158161
$(top_srcdir)/m4/extensions.m4 \
159162
$(top_srcdir)/m4/extern-inline.m4 $(top_srcdir)/m4/fcntl-o.m4 \
160163
$(top_srcdir)/m4/fcntl.m4 $(top_srcdir)/m4/fcntl_h.m4 \
161-
$(top_srcdir)/m4/fstat.m4 $(top_srcdir)/m4/getdtablesize.m4 \
164+
$(top_srcdir)/m4/fstat.m4 $(top_srcdir)/m4/getdelim.m4 \
165+
$(top_srcdir)/m4/getdtablesize.m4 $(top_srcdir)/m4/getline.m4 \
162166
$(top_srcdir)/m4/getopt.m4 $(top_srcdir)/m4/getprogname.m4 \
163167
$(top_srcdir)/m4/gnulib-common.m4 \
164168
$(top_srcdir)/m4/gnulib-comp.m4 \
@@ -202,43 +206,47 @@ libgnu_a_AR = $(AR) $(ARFLAGS)
202206
libgnu_a_RANLIB = $(RANLIB)
203207
am__DEPENDENCIES_1 =
204208
am__libgnu_a_SOURCES_DIST = basename-lgpl.c cloexec.c close.c dup2.c \
205-
error.c fcntl.c fd-hook.c fstat.c getdtablesize.c getopt.c \
206-
getopt1.c getprogname.c gettext.h idx.h lstat.c malloca.c \
207-
msvc-inval.c msvc-nothrow.c open.c stat.c stat-time.c \
208-
stdio-read.c stdio-write.c stdlib.c strerror.c \
209+
error.c fcntl.c fd-hook.c fstat.c getdelim.c getdtablesize.c \
210+
getline.c getopt.c getopt1.c getprogname.c gettext.h idx.h \
211+
lstat.c malloca.c msvc-inval.c msvc-nothrow.c open.c stat.c \
212+
stat-time.c stdio-read.c stdio-write.c stdlib.c strerror.c \
209213
strerror-override.c unistd.c
210214
#am__objects_1 = libgnu_a-close.$(OBJEXT)
211215
#am__objects_2 = libgnu_a-dup2.$(OBJEXT)
212216
#am__objects_3 = libgnu_a-error.$(OBJEXT)
213217
am__objects_4 = libgnu_a-fcntl.$(OBJEXT)
214218
#am__objects_5 = libgnu_a-fstat.$(OBJEXT)
215-
#am__objects_6 = libgnu_a-getdtablesize.$(OBJEXT)
216-
#am__objects_7 = libgnu_a-getopt.$(OBJEXT) \
219+
#am__objects_6 = \
220+
# libgnu_a-getdelim.$(OBJEXT)
221+
#am__objects_7 = libgnu_a-getdtablesize.$(OBJEXT)
222+
#am__objects_8 = libgnu_a-getline.$(OBJEXT)
223+
#am__objects_9 = libgnu_a-getopt.$(OBJEXT) \
217224
# libgnu_a-getopt1.$(OBJEXT)
218-
am__objects_8 = \
225+
am__objects_10 = \
219226
libgnu_a-getprogname.$(OBJEXT)
220-
#am__objects_9 = libgnu_a-lstat.$(OBJEXT)
221-
#am__objects_10 = \
227+
#am__objects_11 = libgnu_a-lstat.$(OBJEXT)
228+
#am__objects_12 = \
222229
# libgnu_a-msvc-inval.$(OBJEXT)
223-
#am__objects_11 = libgnu_a-msvc-nothrow.$(OBJEXT)
224-
#am__objects_12 = libgnu_a-open.$(OBJEXT)
225-
#am__objects_13 = libgnu_a-stat.$(OBJEXT)
226-
#am__objects_14 = \
230+
#am__objects_13 = libgnu_a-msvc-nothrow.$(OBJEXT)
231+
#am__objects_14 = libgnu_a-open.$(OBJEXT)
232+
#am__objects_15 = libgnu_a-stat.$(OBJEXT)
233+
#am__objects_16 = \
227234
# libgnu_a-stdio-read.$(OBJEXT)
228-
#am__objects_15 = \
235+
#am__objects_17 = \
229236
# libgnu_a-stdio-write.$(OBJEXT)
230-
#am__objects_16 = \
237+
#am__objects_18 = \
231238
# libgnu_a-strerror.$(OBJEXT)
232-
#am__objects_17 = libgnu_a-strerror-override.$(OBJEXT)
239+
#am__objects_19 = libgnu_a-strerror-override.$(OBJEXT)
233240
am_libgnu_a_OBJECTS = libgnu_a-basename-lgpl.$(OBJEXT) \
234241
libgnu_a-cloexec.$(OBJEXT) $(am__objects_1) $(am__objects_2) \
235242
$(am__objects_3) $(am__objects_4) libgnu_a-fd-hook.$(OBJEXT) \
236243
$(am__objects_5) $(am__objects_6) $(am__objects_7) \
237-
$(am__objects_8) $(am__objects_9) libgnu_a-malloca.$(OBJEXT) \
238-
$(am__objects_10) $(am__objects_11) $(am__objects_12) \
239-
$(am__objects_13) libgnu_a-stat-time.$(OBJEXT) \
240-
$(am__objects_14) $(am__objects_15) libgnu_a-stdlib.$(OBJEXT) \
241-
$(am__objects_16) $(am__objects_17) libgnu_a-unistd.$(OBJEXT)
244+
$(am__objects_8) $(am__objects_9) $(am__objects_10) \
245+
$(am__objects_11) libgnu_a-malloca.$(OBJEXT) $(am__objects_12) \
246+
$(am__objects_13) $(am__objects_14) $(am__objects_15) \
247+
libgnu_a-stat-time.$(OBJEXT) $(am__objects_16) \
248+
$(am__objects_17) libgnu_a-stdlib.$(OBJEXT) $(am__objects_18) \
249+
$(am__objects_19) libgnu_a-unistd.$(OBJEXT)
242250
libgnu_a_OBJECTS = $(am_libgnu_a_OBJECTS)
243251
AM_V_P = $(am__v_P_$(V))
244252
am__v_P_ = $(am__v_P_$(AM_DEFAULT_VERBOSITY))
@@ -259,9 +267,10 @@ am__depfiles_remade = ./$(DEPDIR)/libgnu_a-basename-lgpl.Po \
259267
./$(DEPDIR)/libgnu_a-cloexec.Po ./$(DEPDIR)/libgnu_a-close.Po \
260268
./$(DEPDIR)/libgnu_a-dup2.Po ./$(DEPDIR)/libgnu_a-error.Po \
261269
./$(DEPDIR)/libgnu_a-fcntl.Po ./$(DEPDIR)/libgnu_a-fd-hook.Po \
262-
./$(DEPDIR)/libgnu_a-fstat.Po \
270+
./$(DEPDIR)/libgnu_a-fstat.Po ./$(DEPDIR)/libgnu_a-getdelim.Po \
263271
./$(DEPDIR)/libgnu_a-getdtablesize.Po \
264-
./$(DEPDIR)/libgnu_a-getopt.Po ./$(DEPDIR)/libgnu_a-getopt1.Po \
272+
./$(DEPDIR)/libgnu_a-getline.Po ./$(DEPDIR)/libgnu_a-getopt.Po \
273+
./$(DEPDIR)/libgnu_a-getopt1.Po \
265274
./$(DEPDIR)/libgnu_a-getprogname.Po \
266275
./$(DEPDIR)/libgnu_a-lstat.Po ./$(DEPDIR)/libgnu_a-malloca.Po \
267276
./$(DEPDIR)/libgnu_a-msvc-inval.Po \
@@ -503,13 +512,13 @@ GL_GNULIB_FZPRINTF = 0
503512
GL_GNULIB_GETC = 1
504513
GL_GNULIB_GETCHAR = 1
505514
GL_GNULIB_GETCWD = 0
506-
GL_GNULIB_GETDELIM = 0
515+
GL_GNULIB_GETDELIM = 1
507516
GL_GNULIB_GETDOMAINNAME = 0
508517
GL_GNULIB_GETDTABLESIZE = 1
509518
GL_GNULIB_GETENTROPY = 0
510519
GL_GNULIB_GETGROUPS = 0
511520
GL_GNULIB_GETHOSTNAME = 0
512-
GL_GNULIB_GETLINE = 0
521+
GL_GNULIB_GETLINE = 1
513522
GL_GNULIB_GETLOADAVG = 0
514523
GL_GNULIB_GETLOCALENAME_L = 0
515524
GL_GNULIB_GETLOCALENAME_L_UNSAFE = 0
@@ -1340,10 +1349,11 @@ AM_CFLAGS =
13401349
libgnu_a_SOURCES = basename-lgpl.c cloexec.c $(am__append_1) \
13411350
$(am__append_2) $(am__append_3) $(am__append_4) fd-hook.c \
13421351
$(am__append_5) $(am__append_6) $(am__append_7) \
1343-
$(am__append_8) gettext.h idx.h $(am__append_9) malloca.c \
1344-
$(am__append_10) $(am__append_11) $(am__append_12) \
1345-
$(am__append_13) stat-time.c $(am__append_14) $(am__append_15) \
1346-
stdlib.c $(am__append_16) $(am__append_17) unistd.c
1352+
$(am__append_8) $(am__append_9) $(am__append_10) gettext.h \
1353+
idx.h $(am__append_11) malloca.c $(am__append_12) \
1354+
$(am__append_13) $(am__append_14) $(am__append_15) stat-time.c \
1355+
$(am__append_16) $(am__append_17) stdlib.c $(am__append_18) \
1356+
$(am__append_19) unistd.c
13471357
libgnu_a_CFLAGS = $(AM_CFLAGS) $(GL_CFLAG_GNULIB_WARNINGS) $(GL_CFLAG_ALLOW_WARNINGS)
13481358
libgnu_a_LIBADD = $(gl_libgnu_LIBOBJS)
13491359
libgnu_a_DEPENDENCIES = $(gl_libgnu_LIBOBJS)
@@ -1455,7 +1465,9 @@ include ./$(DEPDIR)/libgnu_a-error.Po # am--include-marker
14551465
include ./$(DEPDIR)/libgnu_a-fcntl.Po # am--include-marker
14561466
include ./$(DEPDIR)/libgnu_a-fd-hook.Po # am--include-marker
14571467
include ./$(DEPDIR)/libgnu_a-fstat.Po # am--include-marker
1468+
include ./$(DEPDIR)/libgnu_a-getdelim.Po # am--include-marker
14581469
include ./$(DEPDIR)/libgnu_a-getdtablesize.Po # am--include-marker
1470+
include ./$(DEPDIR)/libgnu_a-getline.Po # am--include-marker
14591471
include ./$(DEPDIR)/libgnu_a-getopt.Po # am--include-marker
14601472
include ./$(DEPDIR)/libgnu_a-getopt1.Po # am--include-marker
14611473
include ./$(DEPDIR)/libgnu_a-getprogname.Po # am--include-marker
@@ -1608,6 +1620,20 @@ libgnu_a-fstat.obj: fstat.c
16081620
# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
16091621
# $(AM_V_CC_no)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgnu_a_CFLAGS) $(CFLAGS) -c -o libgnu_a-fstat.obj `if test -f 'fstat.c'; then $(CYGPATH_W) 'fstat.c'; else $(CYGPATH_W) '$(srcdir)/fstat.c'; fi`
16101622

1623+
libgnu_a-getdelim.o: getdelim.c
1624+
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgnu_a_CFLAGS) $(CFLAGS) -MT libgnu_a-getdelim.o -MD -MP -MF $(DEPDIR)/libgnu_a-getdelim.Tpo -c -o libgnu_a-getdelim.o `test -f 'getdelim.c' || echo '$(srcdir)/'`getdelim.c
1625+
$(AM_V_at)$(am__mv) $(DEPDIR)/libgnu_a-getdelim.Tpo $(DEPDIR)/libgnu_a-getdelim.Po
1626+
# $(AM_V_CC)source='getdelim.c' object='libgnu_a-getdelim.o' libtool=no \
1627+
# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
1628+
# $(AM_V_CC_no)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgnu_a_CFLAGS) $(CFLAGS) -c -o libgnu_a-getdelim.o `test -f 'getdelim.c' || echo '$(srcdir)/'`getdelim.c
1629+
1630+
libgnu_a-getdelim.obj: getdelim.c
1631+
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgnu_a_CFLAGS) $(CFLAGS) -MT libgnu_a-getdelim.obj -MD -MP -MF $(DEPDIR)/libgnu_a-getdelim.Tpo -c -o libgnu_a-getdelim.obj `if test -f 'getdelim.c'; then $(CYGPATH_W) 'getdelim.c'; else $(CYGPATH_W) '$(srcdir)/getdelim.c'; fi`
1632+
$(AM_V_at)$(am__mv) $(DEPDIR)/libgnu_a-getdelim.Tpo $(DEPDIR)/libgnu_a-getdelim.Po
1633+
# $(AM_V_CC)source='getdelim.c' object='libgnu_a-getdelim.obj' libtool=no \
1634+
# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
1635+
# $(AM_V_CC_no)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgnu_a_CFLAGS) $(CFLAGS) -c -o libgnu_a-getdelim.obj `if test -f 'getdelim.c'; then $(CYGPATH_W) 'getdelim.c'; else $(CYGPATH_W) '$(srcdir)/getdelim.c'; fi`
1636+
16111637
libgnu_a-getdtablesize.o: getdtablesize.c
16121638
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgnu_a_CFLAGS) $(CFLAGS) -MT libgnu_a-getdtablesize.o -MD -MP -MF $(DEPDIR)/libgnu_a-getdtablesize.Tpo -c -o libgnu_a-getdtablesize.o `test -f 'getdtablesize.c' || echo '$(srcdir)/'`getdtablesize.c
16131639
$(AM_V_at)$(am__mv) $(DEPDIR)/libgnu_a-getdtablesize.Tpo $(DEPDIR)/libgnu_a-getdtablesize.Po
@@ -1622,6 +1648,20 @@ libgnu_a-getdtablesize.obj: getdtablesize.c
16221648
# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
16231649
# $(AM_V_CC_no)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgnu_a_CFLAGS) $(CFLAGS) -c -o libgnu_a-getdtablesize.obj `if test -f 'getdtablesize.c'; then $(CYGPATH_W) 'getdtablesize.c'; else $(CYGPATH_W) '$(srcdir)/getdtablesize.c'; fi`
16241650

1651+
libgnu_a-getline.o: getline.c
1652+
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgnu_a_CFLAGS) $(CFLAGS) -MT libgnu_a-getline.o -MD -MP -MF $(DEPDIR)/libgnu_a-getline.Tpo -c -o libgnu_a-getline.o `test -f 'getline.c' || echo '$(srcdir)/'`getline.c
1653+
$(AM_V_at)$(am__mv) $(DEPDIR)/libgnu_a-getline.Tpo $(DEPDIR)/libgnu_a-getline.Po
1654+
# $(AM_V_CC)source='getline.c' object='libgnu_a-getline.o' libtool=no \
1655+
# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
1656+
# $(AM_V_CC_no)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgnu_a_CFLAGS) $(CFLAGS) -c -o libgnu_a-getline.o `test -f 'getline.c' || echo '$(srcdir)/'`getline.c
1657+
1658+
libgnu_a-getline.obj: getline.c
1659+
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgnu_a_CFLAGS) $(CFLAGS) -MT libgnu_a-getline.obj -MD -MP -MF $(DEPDIR)/libgnu_a-getline.Tpo -c -o libgnu_a-getline.obj `if test -f 'getline.c'; then $(CYGPATH_W) 'getline.c'; else $(CYGPATH_W) '$(srcdir)/getline.c'; fi`
1660+
$(AM_V_at)$(am__mv) $(DEPDIR)/libgnu_a-getline.Tpo $(DEPDIR)/libgnu_a-getline.Po
1661+
# $(AM_V_CC)source='getline.c' object='libgnu_a-getline.obj' libtool=no \
1662+
# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
1663+
# $(AM_V_CC_no)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgnu_a_CFLAGS) $(CFLAGS) -c -o libgnu_a-getline.obj `if test -f 'getline.c'; then $(CYGPATH_W) 'getline.c'; else $(CYGPATH_W) '$(srcdir)/getline.c'; fi`
1664+
16251665
libgnu_a-getopt.o: getopt.c
16261666
$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libgnu_a_CFLAGS) $(CFLAGS) -MT libgnu_a-getopt.o -MD -MP -MF $(DEPDIR)/libgnu_a-getopt.Tpo -c -o libgnu_a-getopt.o `test -f 'getopt.c' || echo '$(srcdir)/'`getopt.c
16271667
$(AM_V_at)$(am__mv) $(DEPDIR)/libgnu_a-getopt.Tpo $(DEPDIR)/libgnu_a-getopt.Po
@@ -2097,7 +2137,9 @@ distclean: distclean-recursive
20972137
-rm -f ./$(DEPDIR)/libgnu_a-fcntl.Po
20982138
-rm -f ./$(DEPDIR)/libgnu_a-fd-hook.Po
20992139
-rm -f ./$(DEPDIR)/libgnu_a-fstat.Po
2140+
-rm -f ./$(DEPDIR)/libgnu_a-getdelim.Po
21002141
-rm -f ./$(DEPDIR)/libgnu_a-getdtablesize.Po
2142+
-rm -f ./$(DEPDIR)/libgnu_a-getline.Po
21012143
-rm -f ./$(DEPDIR)/libgnu_a-getopt.Po
21022144
-rm -f ./$(DEPDIR)/libgnu_a-getopt1.Po
21032145
-rm -f ./$(DEPDIR)/libgnu_a-getprogname.Po
@@ -2168,7 +2210,9 @@ maintainer-clean: maintainer-clean-recursive
21682210
-rm -f ./$(DEPDIR)/libgnu_a-fcntl.Po
21692211
-rm -f ./$(DEPDIR)/libgnu_a-fd-hook.Po
21702212
-rm -f ./$(DEPDIR)/libgnu_a-fstat.Po
2213+
-rm -f ./$(DEPDIR)/libgnu_a-getdelim.Po
21712214
-rm -f ./$(DEPDIR)/libgnu_a-getdtablesize.Po
2215+
-rm -f ./$(DEPDIR)/libgnu_a-getline.Po
21722216
-rm -f ./$(DEPDIR)/libgnu_a-getopt.Po
21732217
-rm -f ./$(DEPDIR)/libgnu_a-getopt1.Po
21742218
-rm -f ./$(DEPDIR)/libgnu_a-getprogname.Po

m4/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,5 @@
6767
/warn-on-use.m4
6868
/wint_t.m4
6969
/zzgnulib.m4
70+
/getdelim.m4
71+
/getline.m4

m4/gnulib-cache.m4

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,14 @@
3838
# --no-libtool \
3939
# --macro-prefix=gl \
4040
# error \
41+
# getline \
4142
# getopt-gnu
4243

4344
# Specification in the form of a few gnulib-tool.m4 macro invocations:
4445
gl_LOCAL_DIR([])
4546
gl_MODULES([
4647
error
48+
getline
4749
getopt-gnu
4850
])
4951
gl_AVOID([])

src/util.c

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -334,49 +334,7 @@ FILE * xpipe(const char * cmd, pid_t *pid, const char *mode, char *const argv[])
334334
return res;
335335
}
336336

337-
/*
338-
* stuff needed for non-GNU systems
339-
*/
340-
341-
#ifndef HAVE_GETLINE
342-
#define GLSTEP 512
343-
344-
/* suboptimal implementation of glibc's getline() */
345-
ssize_t getline(char **line, size_t *n, FILE *f)
346-
{
347-
char *p;
348-
size_t len;
349-
350-
if (*line == NULL || *n < 2) {
351-
p = realloc(*line, GLSTEP);
352-
if (!p)
353-
return -1;
354-
*line = p;
355-
*n = GLSTEP;
356-
}
357-
358-
p = fgets(*line, *n, f);
359-
if (!p)
360-
return -1;
361-
362-
len = strlen(p);
363-
while ((*line)[len - 1] != '\n') {
364-
p = realloc(*line, *n + GLSTEP);
365-
if (!p)
366-
return -1;
367-
*line = p;
368-
*n += GLSTEP;
369-
370-
p = fgets(p + len, *n - len, f);
371-
if (!p)
372-
break;
373337

374-
len = len + strlen(p);
375-
}
376-
return (ssize_t) len;
377-
}
378-
379-
#endif
380338

381339
char *progname = "(null)"; /* for error() */
382340
void set_progname(const char *s)

0 commit comments

Comments
 (0)