diff --git a/lib/Makefile.am b/lib/Makefile.am index 89ccc0e35..ce0025e19 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -102,7 +102,6 @@ libshadow_la_SOURCES = \ find_new_uid.c \ find_new_sub_gids.c \ find_new_sub_uids.c \ - fputsx.c \ get_pid.c \ getdate.h \ getdate.y \ diff --git a/lib/commonio.c b/lib/commonio.c index ef8512037..73f7674b8 100644 --- a/lib/commonio.c +++ b/lib/commonio.c @@ -642,7 +642,7 @@ int commonio_open (struct commonio_db *db, int mode) if (NULL == buf) goto cleanup_errno; - while (db->ops->fgets(buf, buflen, db->fp) != NULL) { + while (fgets(buf, buflen, db->fp) != NULL) { struct commonio_entry *p; while ( (strrchr (buf, '\n') == NULL) @@ -655,9 +655,8 @@ int commonio_open (struct commonio_db *db, int mode) goto cleanup_errno; len = strlen (buf); - if (db->ops->fgets(buf + len, buflen - len, db->fp) == NULL) { + if (fgets(buf + len, buflen - len, db->fp) == NULL) goto cleanup_buf; - } } stpsep(buf, "\n"); @@ -877,9 +876,9 @@ static int write_all (const struct commonio_db *db) return -1; } } else if (NULL != p->line) { - if (db->ops->fputs (p->line, db->fp) == EOF) { + if (fputs(p->line, db->fp) == EOF) return -1; - } + if (putc ('\n', db->fp) == EOF) { return -1; } diff --git a/lib/commonio.h b/lib/commonio.h index fedbefa3d..0afa59958 100644 --- a/lib/commonio.h +++ b/lib/commonio.h @@ -60,15 +60,6 @@ struct commonio_ops { */ int (*put) (const void *, FILE *); - /* - * fgets and fputs (can be replaced by versions that - * understand line continuation conventions). - */ - ATTR_ACCESS(write_only, 1, 2) - /*@null@*/char *(*fgets)(/*@returned@*/char *restrict s, int n, - FILE *restrict stream); - int (*fputs) (const char *, FILE *); - /* * open_hook and close_hook. * If non NULL, these functions will be called after the database diff --git a/lib/fputsx.c b/lib/fputsx.c deleted file mode 100644 index 325702c2f..000000000 --- a/lib/fputsx.c +++ /dev/null @@ -1,69 +0,0 @@ -/* - * SPDX-FileCopyrightText: 1990 - 1994, Julianne Frances Haugh - * SPDX-FileCopyrightText: 1996 - 1999, Marek Michałkiewicz - * SPDX-FileCopyrightText: 2005 , Tomasz Kłoczko - * SPDX-FileCopyrightText: 2008 , Nicolas François - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include - -#include -#include -#include - -#include "defines.h" -#include "prototypes.h" - -#ident "$Id$" - - -/*@null@*/char * -fgetsx(/*@returned@*/char *restrict buf, int cnt, FILE *restrict f) -{ - char *cp = buf; - char *ep; - - while (cnt > 0) { - if (fgets(cp, cnt, f) == NULL) { - if (cp == buf) { - return NULL; - } else { - break; - } - } - ep = strrchr (cp, '\\'); - if ((NULL != ep) && (*(ep + 1) == '\n')) { - cnt -= ep - cp; - if (cnt > 0) - cp = stpcpy(ep, ""); - } else { - break; - } - } - return buf; -} - -int fputsx (const char *s, FILE * stream) -{ - int i; - - for (i = 0; '\0' != *s; i++, s++) { - if (putc (*s, stream) == EOF) { - return EOF; - } - -#if 0 /* The standard getgr*() can't handle that. --marekm */ - if (i > (BUFSIZ / 2)) { - if (putc ('\\', stream) == EOF || - putc ('\n', stream) == EOF) - return EOF; - - i = 0; - } -#endif - } - return 0; -} - diff --git a/lib/groupio.c b/lib/groupio.c index 3984b4af5..2585a62a1 100644 --- a/lib/groupio.c +++ b/lib/groupio.c @@ -98,8 +98,6 @@ static struct commonio_ops group_ops = { group_getname, group_parse, group_put, - fgetsx, - fputsx, group_open_hook, group_close_hook }; diff --git a/lib/gshadow.c b/lib/gshadow.c index eb0f3b82c..6faa3dfed 100644 --- a/lib/gshadow.c +++ b/lib/gshadow.c @@ -155,7 +155,7 @@ void endsgent (void) return NULL; } - if (fgetsx(buf, buflen, fp) == NULL) + if (fgets(buf, buflen, fp) == NULL) return NULL; while ( (strrchr(buf, '\n') == NULL) @@ -170,7 +170,7 @@ void endsgent (void) buflen *= 2; len = strlen (buf); - if (fgetsx(&buf[len], buflen - len, fp) == NULL) + if (fgets(&buf[len], buflen - len, fp) == NULL) return NULL; } stpsep(buf, "\n"); @@ -269,11 +269,7 @@ int putsgent (const struct sgrp *sgrp, FILE * fp) } stpcpy(cp, "\n"); - /* - * Output using the function which understands the line - * continuation conventions. - */ - if (fputsx (buf, fp) == EOF) { + if (fputs(buf, fp) == EOF) { free (buf); return -1; } diff --git a/lib/prototypes.h b/lib/prototypes.h index 6b978a975..2f6b0c5ac 100644 --- a/lib/prototypes.h +++ b/lib/prototypes.h @@ -157,11 +157,6 @@ extern int getrange (const char *range, /* gettime.c */ extern time_t gettime (void); -/* fputsx.c */ -ATTR_ACCESS(write_only, 1, 2) -extern /*@null@*/char *fgetsx(/*@returned@*/char *restrict, int, FILE *restrict); -extern int fputsx (const char *, FILE *); - /* groupio.c */ extern void __gr_del_entry (const struct commonio_entry *ent); extern /*@observer@*/const struct commonio_db *__gr_get_db (void); diff --git a/lib/pwio.c b/lib/pwio.c index 3497c7545..1e9231ebc 100644 --- a/lib/pwio.c +++ b/lib/pwio.c @@ -73,8 +73,6 @@ static struct commonio_ops passwd_ops = { passwd_getname, passwd_parse, passwd_put, - fgets, - fputs, NULL, /* open_hook */ NULL /* close_hook */ }; diff --git a/lib/sgroupio.c b/lib/sgroupio.c index acb140d87..229cc2364 100644 --- a/lib/sgroupio.c +++ b/lib/sgroupio.c @@ -197,8 +197,6 @@ static struct commonio_ops gshadow_ops = { gshadow_getname, gshadow_parse, gshadow_put, - fgetsx, - fputsx, NULL, /* open_hook */ NULL /* close_hook */ }; diff --git a/lib/shadowio.c b/lib/shadowio.c index d2c3b4730..5fe6c1443 100644 --- a/lib/shadowio.c +++ b/lib/shadowio.c @@ -72,8 +72,6 @@ static struct commonio_ops shadow_ops = { shadow_getname, shadow_parse, shadow_put, - fgets, - fputs, NULL, /* open_hook */ NULL /* close_hook */ }; diff --git a/lib/subordinateio.c b/lib/subordinateio.c index f19687ee9..c5da34838 100644 --- a/lib/subordinateio.c +++ b/lib/subordinateio.c @@ -148,8 +148,6 @@ static struct commonio_ops subordinate_ops = { NULL, /* getname */ subordinate_parse, /* parse */ subordinate_put, /* put */ - fgets, /* fgets */ - fputs, /* fputs */ NULL, /* open_hook */ NULL, /* close_hook */ }; diff --git a/po/POTFILES.in b/po/POTFILES.in index 3aff87b2d..6d6ae48ab 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -21,7 +21,6 @@ lib/find_new_gid.c lib/find_new_sub_gids.c lib/find_new_sub_uids.c lib/find_new_uid.c -lib/fputsx.c lib/getdef.c lib/getgr_nam_gid.c lib/getrange.c