commit e272e3d3ba0df6ed75120cd93ff2ad645d493980
parent 476b93db7503af63563f1dc4d0b7e061d357b77c
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Thu, 10 Dec 2015 21:23:12 +0100
Simplify the logic about saved filename
Diffstat:
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/ed.c b/ed.c
@@ -507,8 +507,6 @@ doread(char *fname)
if (fp)
fclose(fp);
- if (savfname[0] == '\0')
- strcpy(savfname, fname);
if (!(fp = fopen(fname, "r")))
error("input/output error");
@@ -529,6 +527,11 @@ doread(char *fname)
fp = NULL;
if (fclose(aux))
error("input/output error");
+
+ if (savfname[0] == '\0') {
+ modflag = 0;
+ strcpy(savfname, fname);
+ }
}
static void
@@ -1111,9 +1114,7 @@ main(int argc, char *argv[])
if (*argv) {
if (strlen(*argv) >= FILENAME_MAX)
error("file name too long");
- strcpy(savfname, *argv);
- doread(savfname);
- modflag = 0;
+ doread(*argv);
}
}