Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make make(1): reduce scope of local variables in brk...
details: https://anonhg.NetBSD.org/src/rev/ff9fb9d6d83b
branches: trunk
changeset: 936657:ff9fb9d6d83b
user: rillig <rillig%NetBSD.org@localhost>
date: Sat Aug 01 10:44:23 2020 +0000
description:
make(1): reduce scope of local variables in brk_string
This also removes the unused assignment to words_cap.
diffstat:
usr.bin/make/str.c | 30 ++++++++++++------------------
1 files changed, 12 insertions(+), 18 deletions(-)
diffs (68 lines):
diff -r a710b7b06691 -r ff9fb9d6d83b usr.bin/make/str.c
--- a/usr.bin/make/str.c Sat Aug 01 09:55:00 2020 +0000
+++ b/usr.bin/make/str.c Sat Aug 01 10:44:23 2020 +0000
@@ -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 @@
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) {
Home |
Main Index |
Thread Index |
Old Index