summaryrefslogtreecommitdiffstats
path: root/usr.bin/make
diff options
context:
space:
mode:
authorharti <harti@FreeBSD.org>2005-02-10 17:00:16 +0000
committerharti <harti@FreeBSD.org>2005-02-10 17:00:16 +0000
commitbe46f93f56153812adc48ad7be2b2203743dec81 (patch)
tree434cdeb6cfeff34660177ab21691e9402855cfc3 /usr.bin/make
parent9b44db51a104b1b3b4ea144b022138e0c109d97d (diff)
downloadFreeBSD-src-be46f93f56153812adc48ad7be2b2203743dec81.zip
FreeBSD-src-be46f93f56153812adc48ad7be2b2203743dec81.tar.gz
Mostly stylistic nits in preparation for splitting up Var_Parse:
use a more consistent style with regard to *str and str[0]; simplify code by introducing a temporary variable; shift a break around and add braces where appropriate. Submitted by: Max Okumoto <okumoto@ucsd.edu>
Diffstat (limited to 'usr.bin/make')
-rw-r--r--usr.bin/make/var.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c
index 1ef766f..5e9f3db 100644
--- a/usr.bin/make/var.c
+++ b/usr.bin/make/var.c
@@ -1755,15 +1755,15 @@ Var_Subst(const char *var, char *str, GNode *ctxt, Boolean undefErr)
errorReported = FALSE;
while (*str) {
- if (var == NULL && (*str == '$') && (str[1] == '$')) {
+ if (var == NULL && (str[0] == '$') && (str[1] == '$')) {
/*
* A dollar sign may be escaped either with another dollar sign.
* In such a case, we skip over the escape character and store the
* dollar sign into the buffer directly.
*/
- str++;
- Buf_AddByte(buf, (Byte)*str);
- str++;
+ Buf_AddByte(buf, (Byte)str[0]);
+ str += 2;
+
} else if (str[0] != '$') {
/*
* Skip as many characters as possible -- either to the end of
@@ -1784,15 +1784,19 @@ Var_Subst(const char *var, char *str, GNode *ctxt, Boolean undefErr)
int expand;
for (;;) {
if (str[1] != OPEN_PAREN && str[1] != OPEN_BRACE) {
- if (str[1] != var[0] || var[1] != '\0') {
+ /*
+ * Single letter variable name
+ */
+ if (var[1] != '\0' || var[0] != str[1]) {
Buf_AddBytes(buf, 2, (const Byte *)str);
str += 2;
expand = FALSE;
- } else
+ } else {
expand = TRUE;
- break;
+ }
} else {
- const char *p = str + 2;
+ size_t ln;
+ const char *p = str + 2;
/*
* Scan up to the end of the variable name.
@@ -1816,23 +1820,23 @@ Var_Subst(const char *var, char *str, GNode *ctxt, Boolean undefErr)
continue;
}
- if (strncmp(var, str + 2, p - str - 2) != 0 ||
- var[p - str - 2] != '\0') {
+ ln = p - (str + 2);
+ if (var[ln] != '\0' || strncmp(var, str + 2, ln) != 0) {
/*
* Not the variable we want to expand, scan
* until the next variable
*/
- for (;*p != '$' && *p != '\0'; p++)
- continue;
+ while (*p != '$' && *p != '\0')
+ p++;
Buf_AppendRange(buf, str, p);
str = p;
expand = FALSE;
- }
- else
+ } else {
expand = TRUE;
- break;
+ }
}
+ break;
}
if (!expand)
continue;
OpenPOWER on IntegriCloud