mirror of
https://gitlab.freedesktop.org/libbsd/libbsd.git
synced 2025-01-09 03:08:38 +01:00
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:
parent
41ff37bbcc
commit
151bc71d64
@ -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,
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user