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.
This commit is contained in:
Guillem Jover 2015-09-22 16:22:56 +02:00
parent 41ff37bbcc
commit 151bc71d64
3 changed files with 12 additions and 1 deletions

View File

@ -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,

View 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

View 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