diff options
author | John Ankarström <john@ankarstrom.se> | 2021-07-10 18:12:48 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2021-07-10 18:12:48 +0200 |
commit | f731d36d9229a57844551ebcfe78c91a1e9a37ec (patch) | |
tree | c51f26524aed2fb72a3d28c2caf5558ed6a09bb2 | |
parent | ba5414545ed0cbce19bd305c5c21c4d159ef852f (diff) | |
download | re-name-f731d36d9229a57844551ebcfe78c91a1e9a37ec.tar.gz |
name.c: Remove superfluous strings from, to
-rw-r--r-- | name.c | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -19,8 +19,7 @@ void waitstdin(void); int main(int argc, char *argv[]) { - char file[30], *name, from[MAXLINE], *froms[MAXFILES], - *tmp, to[MAXLINE], *tos[MAXFILES]; + char file[30], *name, *froms[MAXFILES], *tmp, *tos[MAXFILES]; FILE *fp; int c, i, j, s, xflag; @@ -65,15 +64,15 @@ usage: fprintf(stderr, "usage: %s [-x]\n", name); err(1, "fopen"); /* Read original file names. */ - for (i = 0; fgets(from, MAXLINE, fp); i++) { - from[strcspn(from, "\n")] = 0; - strcpy(froms[i], from); + for (i = 0; fgets(tmp, MAXLINE, fp); i++) { + tmp[strcspn(tmp, "\n")] = 0; + strcpy(froms[i], tmp); } /* Read new file names. */ - for (j = 0; fgets(to, MAXLINE, stdin); j++) { - to[strcspn(to, "\n")] = 0; - strcpy(tos[j], to); + for (j = 0; fgets(tmp, MAXLINE, stdin); j++) { + tmp[strcspn(tmp, "\n")] = 0; + strcpy(tos[j], tmp); } if (i != j) { |