From 068ffda2dd62e65f290392ca6f4c8ee26c6cef1e Mon Sep 17 00:00:00 2001 From: "Anna (navi) Figueiredo Gomes" Date: Thu, 19 Sep 2024 13:37:24 +0200 Subject: [PATCH] librc: Remove rc_getline. getline(3) got standardized in posix 2008 and is common place on all libc implementations now a days, and rc_getline is tagged for removal for ages now. --- FEATURE-REMOVAL-SCHEDULE.md | 10 ---------- src/librc/librc-misc.c | 24 ------------------------ src/librc/rc.h.in | 6 +----- src/librc/rc.map | 1 - 4 files changed, 1 insertion(+), 40 deletions(-) diff --git a/FEATURE-REMOVAL-SCHEDULE.md b/FEATURE-REMOVAL-SCHEDULE.md index 0d82c3a3a..b2e67025a 100644 --- a/FEATURE-REMOVAL-SCHEDULE.md +++ b/FEATURE-REMOVAL-SCHEDULE.md @@ -67,13 +67,3 @@ Who: If you have a c program that links to librc and uses functions from there, this section will list API functions which are deprecated and will be removed along with the reason they are being removed. - -## rc_getline() - -When: 1.0 - -Why: The getline() function was standardized in POSIX.1-2008, so it - should be available on POSIX systems. - -Who: - diff --git a/src/librc/librc-misc.c b/src/librc/librc-misc.c index 846280fc4..4c1bb0742 100644 --- a/src/librc/librc-misc.c +++ b/src/librc/librc-misc.c @@ -102,30 +102,6 @@ rc_getfile(const char *file, char **buffer, size_t *len) return ret; } -ssize_t -rc_getline(char **line, size_t *len, FILE *fp) -{ - char *p; - size_t last = 0; - - while (!feof(fp)) { - if (*line == NULL || last != 0) { - *len += BUFSIZ; - *line = xrealloc(*line, *len); - } - p = *line + last; - memset(p, 0, BUFSIZ); - if (fgets(p, BUFSIZ, fp) == NULL) - break; - last += strlen(p); - if (last && (*line)[last - 1] == '\n') { - (*line)[last - 1] = '\0'; - break; - } - } - return last; -} - char * rc_proc_getent(const char *ent RC_UNUSED) { diff --git a/src/librc/rc.h.in b/src/librc/rc.h.in index d90943b65..b87e8e609 100644 --- a/src/librc/rc.h.in +++ b/src/librc/rc.h.in @@ -602,13 +602,9 @@ typedef LIST_HEAD(rc_pidlist, rc_pid) RC_PIDLIST; * @return NULL terminated list of pids */ RC_PIDLIST *rc_find_pids(const char *, const char *const *, uid_t, pid_t); -/* Basically the same as rc_getline() below, it just returns multiple lines */ +/* Basically the same as getline() below, it just returns multiple lines */ bool rc_getfile(const char *, char **, size_t *); -/* getline is a handy glibc function that not all libcs have, so - * we have our own */ -ssize_t rc_getline(char **, size_t *, FILE *); - /* __END_DECLS */ #ifdef __cplusplus } diff --git a/src/librc/rc.map b/src/librc/rc.map index 0012d8a67..14b3a5ca7 100644 --- a/src/librc/rc.map +++ b/src/librc/rc.map @@ -15,7 +15,6 @@ global: rc_environ_fd; rc_find_pids; rc_getfile; - rc_getline; rc_newer_than; rc_older_than; rc_proc_getent;