Module Name: src Committed By: rillig Date: Mon Dec 27 20:59:59 UTC 2021
Modified Files: src/usr.bin/make: main.c Log Message: make: clean up 'explode' Breaking out of the first 'for' loop was unnecessarily complicated. The call to strlen was not necessary since f already pointed at the end of the string. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.550 -r1.551 src/usr.bin/make/main.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/make/main.c diff -u src/usr.bin/make/main.c:1.550 src/usr.bin/make/main.c:1.551 --- src/usr.bin/make/main.c:1.550 Mon Dec 27 18:54:19 2021 +++ src/usr.bin/make/main.c Mon Dec 27 20:59:59 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.550 2021/12/27 18:54:19 rillig Exp $ */ +/* $NetBSD: main.c,v 1.551 2021/12/27 20:59:59 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -111,7 +111,7 @@ #include "trace.h" /* "@(#)main.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: main.c,v 1.550 2021/12/27 18:54:19 rillig Exp $"); +MAKE_RCSID("$NetBSD: main.c,v 1.551 2021/12/27 20:59:59 rillig Exp $"); #if defined(MAKE_NATIVE) && !defined(lint) __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " "The Regents of the University of California. " @@ -153,29 +153,24 @@ static HashTable cached_realpaths; static char * explode(const char *flags) { - size_t len; - char *nf, *st; - const char *f; + char *exploded, *ep; + const char *p; if (flags == NULL) return NULL; - for (f = flags; *f != '\0'; f++) - if (!ch_isalpha(*f)) - break; - - if (*f != '\0') - return bmake_strdup(flags); - - len = strlen(flags); - st = nf = bmake_malloc(len * 3 + 1); - while (*flags != '\0') { - *nf++ = '-'; - *nf++ = *flags++; - *nf++ = ' '; + for (p = flags; *p != '\0'; p++) + if (!ch_isalpha(*p)) + return bmake_strdup(flags); + + exploded = bmake_malloc((size_t)(p - flags) * 3 + 1); + for (p = flags, ep = exploded; *p != '\0'; p++) { + *ep++ = '-'; + *ep++ = *p; + *ep++ = ' '; } - *nf = '\0'; - return st; + *ep = '\0'; + return exploded; } MAKE_ATTR_DEAD static void