summaryrefslogtreecommitdiffstats
path: root/usr.bin/sed
diff options
context:
space:
mode:
authorjoerg <joerg@FreeBSD.org>1996-11-17 00:22:54 +0000
committerjoerg <joerg@FreeBSD.org>1996-11-17 00:22:54 +0000
commitf420193dce02eeda13a8aee7d55c0ac92dd5fb04 (patch)
treed4b34fedbd5b973f5093403ba056f079b41928d6 /usr.bin/sed
parentbb1c47b9e6df5d3fe1cf2bef80db1ace0e07227d (diff)
downloadFreeBSD-src-f420193dce02eeda13a8aee7d55c0ac92dd5fb04.zip
FreeBSD-src-f420193dce02eeda13a8aee7d55c0ac92dd5fb04.tar.gz
Fix the C programmer's bug #1: EOF is of type `int', not `char'.
Strong 2.2 candidate. Submitted by: wosch
Diffstat (limited to 'usr.bin/sed')
-rw-r--r--usr.bin/sed/main.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/usr.bin/sed/main.c b/usr.bin/sed/main.c
index dbea504..bed4b18 100644
--- a/usr.bin/sed/main.c
+++ b/usr.bin/sed/main.c
@@ -274,8 +274,7 @@ mf_fgets(sp, spflag)
err(FATAL, "%s: %s",
fname, strerror(errno));
}
- if ((c = getc(f)) != EOF) {
- (void)ungetc(c, f);
+ if (!feof(f)) {
break;
}
(void)fclose(f);
@@ -289,8 +288,6 @@ mf_fgets(sp, spflag)
/*
* Use fgetln so that we can handle essentially infinite input data.
- * Can't use the pointer into the stdio buffer as the process space
- * because the ungetc() can cause it to move.
*/
p = fgetln(f, &len);
if (ferror(f))
@@ -299,7 +296,7 @@ mf_fgets(sp, spflag)
linenum++;
/* Advance to next non-empty file */
- while ((c = getc(f)) == EOF) {
+ while (feof(f)) {
(void)fclose(f);
files = files->next;
if (files == NULL) {
@@ -315,7 +312,6 @@ mf_fgets(sp, spflag)
err(FATAL, "%s: %s", fname, strerror(errno));
}
}
- (void)ungetc(c, f);
return (1);
}
OpenPOWER on IntegriCloud