]> git.ipfire.org Git - thirdparty/libbsd.git/commitdiff
Add compile and link-time deprecation warnings for fgetln()
authorGuillem Jover <guillem@hadrons.org>
Tue, 22 Sep 2015 14:22:56 +0000 (16:22 +0200)
committerGuillem Jover <guillem@hadrons.org>
Wed, 23 Sep 2015 05:59:34 +0000 (07:59 +0200)
Although the current implementation in libbsd is probably one of the
safest ones around, it still poses some problems when used with many
file streams. This function has now a replacement, that is both more
standard and portable. Ask users to switch to getline(3) instead.

include/bsd/stdio.h
src/fgetln.c
test/Makefile.am

index e1f8fc3a88267123f672e6308209c1d44cabb35a..7697425e1bc3ef89dd0971de1a32dd0a18d9f653 100644 (file)
 __BEGIN_DECLS
 const char *fmtcheck(const char *, const char *);
 
-char *fgetln(FILE *fp, size_t *lenp);
+/* XXX: The function requires cooperation from the system libc to store the
+ * line buffer in the FILE struct itself. */
+char *fgetln(FILE *fp, size_t *lenp)
+       __attribute__((deprecated("This functions cannot be safely ported, "
+                                 "use getline(3) instead, as it is supported "
+                                 "by GNU and POSIX.1-2008.")));
 
 /*
  * Note: We diverge from the FreeBSD, OpenBSD and DragonFlyBSD declarations,
index 6de804bb75d58cd71cbf7ddcbe98dfdd32d1d449..5f646e4e5485c9d45db02878b8a9cc13d218b3fb 100644 (file)
@@ -30,6 +30,8 @@
 #include <sys/types.h>
 #include <string.h>
 
+#include "local-link.h"
+
 #ifdef HAVE_GETLINE
 struct filebuf {
        FILE *fp;
@@ -68,6 +70,9 @@ fgetln(FILE *stream, size_t *len)
                return fb->buf;
        }
 }
+libbsd_link_warning(fgetln,
+                    "This functions cannot be safely ported, use getline(3) "
+                    "instead, as it is supported by GNU and POSIX.1-2008.")
 #else
 #error "Function fgetln() needs to be ported."
 #endif
index 90861289d26bbfa629805fc61cc9d821fd31a38b..6d675e3b35347c822e11975fc8ab279cba231588 100644 (file)
@@ -27,6 +27,7 @@ check_PROGRAMS += proctitle
 endif
 
 fgetln_SOURCES = test-stream.c test-stream.h fgetln.c
+fgetln_CFLAGS = -Wno-deprecated-declarations
 fparseln_SOURCES = test-stream.c test-stream.h fparseln.c
 
 proctitle_init_SOURCES = proctitle.c