commit 476b93db7503af63563f1dc4d0b7e061d357b77c
parent bb04822e943e0ef0df98359fe22269ca268bdabc
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Thu, 10 Dec 2015 21:14:13 +0100
Fix getfname()
Getfname() had some garbage from previous version, and it
also had a big issue storing the file name in the static
buffer, because it was not incrementing the pointer, so
it was always generating the same error message.
Diffstat:
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/ed.c b/ed.c
@@ -607,12 +607,9 @@ getfname(void)
char *bp;
static char fname[FILENAME_MAX];
- if ((c = input()) != '\n' && c != ' ' && c != '\0')
- error("invalid command suffix");
-
skipblank();
- for (bp = fname; bp < &fname[FILENAME_MAX]; *bp = c) {
- if ((c = input()) != EOF || c == '\n')
+ for (bp = fname; bp < &fname[FILENAME_MAX]; *bp++ = c) {
+ if ((c = input()) == EOF || c == '\n')
break;
}
if (bp == fname) {