From f731d36d9229a57844551ebcfe78c91a1e9a37ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Sat, 10 Jul 2021 18:12:48 +0200 Subject: name.c: Remove superfluous strings from, to --- name.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'name.c') diff --git a/name.c b/name.c index 26f6c8c..e9c13d7 100644 --- a/name.c +++ b/name.c @@ -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) { -- cgit v1.2.3