Module Name: src
Committed By: rillig
Date: Sat Aug 1 10:44:23 UTC 2020
Modified Files:
src/usr.bin/make: str.c
Log Message:
make(1): reduce scope of local variables in brk_string
This also removes the unused assignment to words_cap.
To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/usr.bin/make/str.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/str.c
diff -u src/usr.bin/make/str.c:1.53 src/usr.bin/make/str.c:1.54
--- src/usr.bin/make/str.c:1.53 Sun Jul 26 16:51:53 2020
+++ src/usr.bin/make/str.c Sat Aug 1 10:44:23 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: str.c,v 1.53 2020/07/26 16:51:53 rillig Exp $ */
+/* $NetBSD: str.c,v 1.54 2020/08/01 10:44:23 rillig Exp $ */
/*-
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: str.c,v 1.53 2020/07/26 16:51:53 rillig Exp $";
+static char rcsid[] = "$NetBSD: str.c,v 1.54 2020/08/01 10:44:23 rillig Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)str.c 5.8 (Berkeley) 6/1/90";
#else
-__RCSID("$NetBSD: str.c,v 1.53 2020/07/26 16:51:53 rillig Exp $");
+__RCSID("$NetBSD: str.c,v 1.54 2020/08/01 10:44:23 rillig Exp $");
#endif
#endif /* not lint */
#endif
@@ -142,32 +142,26 @@ char **
brk_string(const char *str, int *out_words_len, Boolean expand,
char **out_words_buf)
{
- char inquote;
- const char *str_p;
- size_t str_len;
- char **words;
- int words_len;
- int words_cap = 50;
- char *words_buf, *word_start, *word_end;
-
/* skip leading space chars. */
for (; *str == ' ' || *str == '\t'; ++str)
continue;
/* words_buf holds the words, separated by '\0'. */
- str_len = strlen(str);
- words_buf = bmake_malloc(strlen(str) + 1);
+ size_t str_len = strlen(str);
+ char *words_buf = bmake_malloc(strlen(str) + 1);
- words_cap = MAX((str_len / 5), 50);
- words = bmake_malloc((words_cap + 1) * sizeof(char *));
+ int words_cap = MAX((str_len / 5), 50);
+ char **words = bmake_malloc((words_cap + 1) * sizeof(char *));
/*
* copy the string; at the same time, parse backslashes,
* quotes and build the word list.
*/
- words_len = 0;
- inquote = '\0';
- word_start = word_end = words_buf;
+ int words_len = 0;
+ char inquote = '\0';
+ char *word_start = words_buf;
+ char *word_end = words_buf;
+ const char *str_p;
for (str_p = str;; ++str_p) {
char ch = *str_p;
switch(ch) {