Skip to content

Commit 5cf1004

Browse files
lib/, po/: Remove fgetsx() and fputsx()
It seems they never worked correctly. Let's keep it simple and remove support for escaped newlines. Closes: <#1055> Reported-by: Chris Hofstaedtler <[email protected]> Signed-off-by: Alejandro Colomar <[email protected]>
1 parent 5991bd9 commit 5cf1004

File tree

12 files changed

+7
-107
lines changed

12 files changed

+7
-107
lines changed

lib/Makefile.am

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ libshadow_la_SOURCES = \
102102
find_new_uid.c \
103103
find_new_sub_gids.c \
104104
find_new_sub_uids.c \
105-
fputsx.c \
106105
get_pid.c \
107106
getdate.h \
108107
getdate.y \

lib/commonio.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ int commonio_open (struct commonio_db *db, int mode)
642642
if (NULL == buf)
643643
goto cleanup_errno;
644644

645-
while (db->ops->fgets(buf, buflen, db->fp) != NULL) {
645+
while (fgets(buf, buflen, db->fp) != NULL) {
646646
struct commonio_entry *p;
647647

648648
while ( (strrchr (buf, '\n') == NULL)
@@ -655,9 +655,8 @@ int commonio_open (struct commonio_db *db, int mode)
655655
goto cleanup_errno;
656656

657657
len = strlen (buf);
658-
if (db->ops->fgets(buf + len, buflen - len, db->fp) == NULL) {
658+
if (fgets(buf + len, buflen - len, db->fp) == NULL)
659659
goto cleanup_buf;
660-
}
661660
}
662661
stpsep(buf, "\n");
663662

@@ -877,9 +876,9 @@ static int write_all (const struct commonio_db *db)
877876
return -1;
878877
}
879878
} else if (NULL != p->line) {
880-
if (db->ops->fputs (p->line, db->fp) == EOF) {
879+
if (fputs(p->line, db->fp) == EOF)
881880
return -1;
882-
}
881+
883882
if (putc ('\n', db->fp) == EOF) {
884883
return -1;
885884
}

lib/commonio.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,6 @@ struct commonio_ops {
6060
*/
6161
int (*put) (const void *, FILE *);
6262

63-
/*
64-
* fgets and fputs (can be replaced by versions that
65-
* understand line continuation conventions).
66-
*/
67-
ATTR_ACCESS(write_only, 1, 2)
68-
/*@null@*/char *(*fgets)(/*@returned@*/char *restrict s, int n,
69-
FILE *restrict stream);
70-
int (*fputs) (const char *, FILE *);
71-
7263
/*
7364
* open_hook and close_hook.
7465
* If non NULL, these functions will be called after the database

lib/fputsx.c

Lines changed: 0 additions & 69 deletions
This file was deleted.

lib/groupio.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@ static struct commonio_ops group_ops = {
9898
group_getname,
9999
group_parse,
100100
group_put,
101-
fgetsx,
102-
fputsx,
103101
group_open_hook,
104102
group_close_hook
105103
};

lib/gshadow.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ void endsgent (void)
155155
return NULL;
156156
}
157157

158-
if (fgetsx(buf, buflen, fp) == NULL)
158+
if (fgets(buf, buflen, fp) == NULL)
159159
return NULL;
160160

161161
while ( (strrchr(buf, '\n') == NULL)
@@ -170,7 +170,7 @@ void endsgent (void)
170170
buflen *= 2;
171171

172172
len = strlen (buf);
173-
if (fgetsx(&buf[len], buflen - len, fp) == NULL)
173+
if (fgets(&buf[len], buflen - len, fp) == NULL)
174174
return NULL;
175175
}
176176
stpsep(buf, "\n");
@@ -269,11 +269,7 @@ int putsgent (const struct sgrp *sgrp, FILE * fp)
269269
}
270270
stpcpy(cp, "\n");
271271

272-
/*
273-
* Output using the function which understands the line
274-
* continuation conventions.
275-
*/
276-
if (fputsx (buf, fp) == EOF) {
272+
if (fputs(buf, fp) == EOF) {
277273
free (buf);
278274
return -1;
279275
}

lib/prototypes.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,6 @@ extern int getrange (const char *range,
157157
/* gettime.c */
158158
extern time_t gettime (void);
159159

160-
/* fputsx.c */
161-
ATTR_ACCESS(write_only, 1, 2)
162-
extern /*@null@*/char *fgetsx(/*@returned@*/char *restrict, int, FILE *restrict);
163-
extern int fputsx (const char *, FILE *);
164-
165160
/* groupio.c */
166161
extern void __gr_del_entry (const struct commonio_entry *ent);
167162
extern /*@observer@*/const struct commonio_db *__gr_get_db (void);

lib/pwio.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ static struct commonio_ops passwd_ops = {
7373
passwd_getname,
7474
passwd_parse,
7575
passwd_put,
76-
fgets,
77-
fputs,
7876
NULL, /* open_hook */
7977
NULL /* close_hook */
8078
};

lib/sgroupio.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,6 @@ static struct commonio_ops gshadow_ops = {
197197
gshadow_getname,
198198
gshadow_parse,
199199
gshadow_put,
200-
fgetsx,
201-
fputsx,
202200
NULL, /* open_hook */
203201
NULL /* close_hook */
204202
};

lib/shadowio.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ static struct commonio_ops shadow_ops = {
7272
shadow_getname,
7373
shadow_parse,
7474
shadow_put,
75-
fgets,
76-
fputs,
7775
NULL, /* open_hook */
7876
NULL /* close_hook */
7977
};

lib/subordinateio.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,6 @@ static struct commonio_ops subordinate_ops = {
148148
NULL, /* getname */
149149
subordinate_parse, /* parse */
150150
subordinate_put, /* put */
151-
fgets, /* fgets */
152-
fputs, /* fputs */
153151
NULL, /* open_hook */
154152
NULL, /* close_hook */
155153
};

po/POTFILES.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ lib/find_new_gid.c
2121
lib/find_new_sub_gids.c
2222
lib/find_new_sub_uids.c
2323
lib/find_new_uid.c
24-
lib/fputsx.c
2524
lib/getdef.c
2625
lib/getgr_nam_gid.c
2726
lib/getrange.c

0 commit comments

Comments
 (0)