Skip to content

Commit

Permalink
librc: Remove rc_getline.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
navi-desu committed Sep 19, 2024
1 parent 57adddf commit 3e6ec02
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 40 deletions.
10 changes: 0 additions & 10 deletions FEATURE-REMOVAL-SCHEDULE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

24 changes: 0 additions & 24 deletions src/librc/librc-misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
6 changes: 1 addition & 5 deletions src/librc/rc.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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(), 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
}
Expand Down
1 change: 0 additions & 1 deletion src/librc/rc.map
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ global:
rc_environ_fd;
rc_find_pids;
rc_getfile;
rc_getline;
rc_newer_than;
rc_older_than;
rc_proc_getent;
Expand Down

0 comments on commit 3e6ec02

Please sign in to comment.