aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2021-07-11 22:35:10 +0200
committerJohn Ankarström <john@ankarstrom.se>2021-07-11 22:35:10 +0200
commitde1d7cd15a6792deca7b1d5f2ee1bf84d9751980 (patch)
tree8c11d8c5e0908896169378066eb7aad21029098a
parentf1f51e8cf736a3ef0ceb532116bb3c200b37f871 (diff)
downloadre-name-de1d7cd15a6792deca7b1d5f2ee1bf84d9751980.tar.gz
Read new file names from standard in first
Theoretically, this might be more efficient.
-rw-r--r--name.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/name.c b/name.c
index 57a467d..e74cd31 100644
--- a/name.c
+++ b/name.c
@@ -63,18 +63,18 @@ usage: fprintf(stderr, "usage: %s [-x]\n", name);
if(!(fp = fopen(file, "r")))
err(1, "fopen");
- /* Read original file names. */
- for(i = 0; i < MAXFILES && fgets(tmp, MAXLINE, fp); i++){
- tmp[strcspn(tmp, "\n")] = 0;
- strcpy(froms[i], tmp);
- }
-
/* Read new file names. */
for(j = 0; j < MAXFILES && fgets(tmp, MAXLINE, stdin); j++){
tmp[strcspn(tmp, "\n")] = 0;
strcpy(tos[j], tmp);
}
+ /* Read original file names. */
+ for(i = 0; i < MAXFILES && fgets(tmp, MAXLINE, fp); i++){
+ tmp[strcspn(tmp, "\n")] = 0;
+ strcpy(froms[i], tmp);
+ }
+
if(i != j){
fprintf(stderr, "%s: too %s lines\n",
name, j > i ? "many" : "few");