From: Guillem Jover Date: Tue, 22 Sep 2015 14:22:56 +0000 (+0200) Subject: Add compile and link-time deprecation warnings for fgetln() X-Git-Tag: 0.8.0~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=151bc71d64845a1798561e66fa62ee0d62f4a03c;p=thirdparty%2Flibbsd.git Add compile and link-time deprecation warnings for fgetln() 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. --- diff --git a/include/bsd/stdio.h b/include/bsd/stdio.h index e1f8fc3..7697425 100644 --- a/include/bsd/stdio.h +++ b/include/bsd/stdio.h @@ -44,7 +44,12 @@ __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, diff --git a/src/fgetln.c b/src/fgetln.c index 6de804b..5f646e4 100644 --- a/src/fgetln.c +++ b/src/fgetln.c @@ -30,6 +30,8 @@ #include #include +#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 diff --git a/test/Makefile.am b/test/Makefile.am index 9086128..6d675e3 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -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