Skip to content

Commit e4a2302

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 8659380 commit e4a2302

File tree

12 files changed

+7
-106
lines changed

12 files changed

+7
-106
lines changed

lib/Makefile.am

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ libshadow_la_SOURCES = \
9999
find_new_uid.c \
100100
find_new_sub_gids.c \
101101
find_new_sub_uids.c \
102-
fputsx.c \
103102
fs/mkstemp/fmkomstemp.c \
104103
fs/mkstemp/fmkomstemp.h \
105104
fs/mkstemp/mkomstemp.c \

lib/commonio.c

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

642-
while (db->ops->fgets(buf, buflen, db->fp) != NULL) {
642+
while (fgets(buf, buflen, db->fp) != NULL) {
643643
struct commonio_entry *p;
644644

645645
while ( (strrchr (buf, '\n') == NULL)
@@ -652,9 +652,8 @@ int commonio_open (struct commonio_db *db, int mode)
652652
goto cleanup_errno;
653653

654654
len = strlen (buf);
655-
if (db->ops->fgets(buf + len, buflen - len, db->fp) == NULL) {
655+
if (fgets(buf + len, buflen - len, db->fp) == NULL)
656656
goto cleanup_buf;
657-
}
658657
}
659658
stpsep(buf, "\n");
660659

@@ -872,9 +871,9 @@ static int write_all (const struct commonio_db *db)
872871
return -1;
873872
}
874873
} else if (NULL != p->line) {
875-
if (db->ops->fputs (p->line, db->fp) == EOF) {
874+
if (fputs(p->line, db->fp) == EOF)
876875
return -1;
877-
}
876+
878877
if (putc ('\n', db->fp) == EOF) {
879878
return -1;
880879
}

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 & 68 deletions
This file was deleted.

lib/groupio.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,6 @@ static struct commonio_ops group_ops = {
101101
group_getname,
102102
group_parse,
103103
group_put,
104-
fgetsx,
105-
fputsx,
106104
group_open_hook,
107105
group_close_hook
108106
};

lib/gshadow.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ sgetsgent(const char *s)
119119
return NULL;
120120
}
121121

122-
if (fgetsx(buf, buflen, fp) == NULL)
122+
if (fgets(buf, buflen, fp) == NULL)
123123
return NULL;
124124

125125
while ( (strrchr(buf, '\n') == NULL)
@@ -134,7 +134,7 @@ sgetsgent(const char *s)
134134
buflen *= 2;
135135

136136
len = strlen (buf);
137-
if (fgetsx(&buf[len], buflen - len, fp) == NULL)
137+
if (fgets(&buf[len], buflen - len, fp) == NULL)
138138
return NULL;
139139
}
140140
stpsep(buf, "\n");
@@ -233,11 +233,7 @@ int putsgent (const struct sgrp *sgrp, FILE * fp)
233233
}
234234
stpcpy(cp, "\n");
235235

236-
/*
237-
* Output using the function which understands the line
238-
* continuation conventions.
239-
*/
240-
if (fputsx (buf, fp) == EOF) {
236+
if (fputs(buf, fp) == EOF) {
241237
free (buf);
242238
return -1;
243239
}

lib/prototypes.h

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

156-
/* fputsx.c */
157-
ATTR_ACCESS(write_only, 1, 2)
158-
extern /*@null@*/char *fgetsx(/*@returned@*/char *restrict, int, FILE *restrict);
159-
extern int fputsx (const char *, FILE *);
160-
161156
/* groupio.c */
162157
extern void __gr_del_entry (const struct commonio_entry *ent);
163158
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
@@ -198,8 +198,6 @@ static struct commonio_ops gshadow_ops = {
198198
gshadow_getname,
199199
gshadow_parse,
200200
gshadow_put,
201-
fgetsx,
202-
fputsx,
203201
NULL, /* open_hook */
204202
NULL /* close_hook */
205203
};

lib/shadowio.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ static struct commonio_ops shadow_ops = {
7474
shadow_getname,
7575
shadow_parse,
7676
shadow_put,
77-
fgets,
78-
fputs,
7977
NULL, /* open_hook */
8078
NULL /* close_hook */
8179
};

lib/subordinateio.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,6 @@ static struct commonio_ops subordinate_ops = {
138138
NULL, /* getname */
139139
subordinate_parse, /* parse */
140140
subordinate_put, /* put */
141-
fgets, /* fgets */
142-
fputs, /* fputs */
143141
NULL, /* open_hook */
144142
NULL, /* close_hook */
145143
};

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)