From 98982aacf0aa7545ab1423f476775a35cb6b63a1 Mon Sep 17 00:00:00 2001 From: Marc Espie Date: Tue, 24 Jul 2007 18:52:48 +0000 Subject: change Var_ParseSkip API to increment the position instead of returning a length, simplifies code. (warns a bit, symptom of some further issues to fix). okay millert@ --- usr.bin/make/arch.c | 11 +++-------- usr.bin/make/for.c | 2 +- usr.bin/make/main.c | 2 +- usr.bin/make/parse.c | 4 ++-- usr.bin/make/suff.c | 4 ++-- usr.bin/make/var.c | 23 ++++++++++++----------- usr.bin/make/var.h | 9 ++++----- usr.bin/make/varmodifiers.c | 2 +- usr.bin/make/varmodifiers.h | 2 +- 9 files changed, 27 insertions(+), 32 deletions(-) (limited to 'usr.bin') diff --git a/usr.bin/make/arch.c b/usr.bin/make/arch.c index 1975d1a4583..9edc2c7eca1 100644 --- a/usr.bin/make/arch.c +++ b/usr.bin/make/arch.c @@ -1,5 +1,5 @@ /* $OpenPackages$ */ -/* $OpenBSD: arch.c,v 1.56 2007/03/20 03:50:39 tedu Exp $ */ +/* $OpenBSD: arch.c,v 1.57 2007/07/24 18:52:47 espie Exp $ */ /* $NetBSD: arch.c,v 1.17 1996/11/06 17:58:59 christos Exp $ */ /* @@ -241,10 +241,7 @@ Arch_ParseArchive(char **linePtr, /* Pointer to start of specification */ for (cp = libName; *cp != '(' && *cp != '\0';) { if (*cp == '$') { - bool ok; - - cp += Var_ParseSkip(cp, ctxt, &ok); - if (ok == false) + if (!Var_ParseSkip(&cp, ctxt)) return false; subLibName = true; } else @@ -266,9 +263,7 @@ Arch_ParseArchive(char **linePtr, /* Pointer to start of specification */ memberName = cp; while (*cp != '\0' && *cp != ')' && !isspace(*cp)) { if (*cp == '$') { - bool ok; - cp += Var_ParseSkip(cp, ctxt, &ok); - if (ok == false) + if (!Var_ParseSkip(&cp, ctxt)) return false; doSubst = true; } else diff --git a/usr.bin/make/for.c b/usr.bin/make/for.c index a68e8edd29b..09982a7f595 100644 --- a/usr.bin/make/for.c +++ b/usr.bin/make/for.c @@ -1,5 +1,5 @@ /* $OpenPackages$ */ -/* $OpenBSD: for.c,v 1.32 2007/07/20 12:32:45 espie Exp $ */ +/* $OpenBSD: for.c,v 1.33 2007/07/24 18:52:47 espie Exp $ */ /* $NetBSD: for.c,v 1.4 1996/11/06 17:59:05 christos Exp $ */ /* diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c index ff52417a3cc..244f7b51ece 100644 --- a/usr.bin/make/main.c +++ b/usr.bin/make/main.c @@ -1,5 +1,5 @@ /* $OpenPackages$ */ -/* $OpenBSD: main.c,v 1.71 2007/07/21 14:41:07 espie Exp $ */ +/* $OpenBSD: main.c,v 1.72 2007/07/24 18:52:47 espie Exp $ */ /* $NetBSD: main.c,v 1.34 1997/03/24 20:56:36 gwr Exp $ */ /* diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c index c0834ca6ab7..b154544c34a 100644 --- a/usr.bin/make/parse.c +++ b/usr.bin/make/parse.c @@ -1,5 +1,5 @@ /* $OpenPackages$ */ -/* $OpenBSD: parse.c,v 1.73 2007/07/20 12:32:45 espie Exp $ */ +/* $OpenBSD: parse.c,v 1.74 2007/07/24 18:52:47 espie Exp $ */ /* $NetBSD: parse.c,v 1.29 1997/03/10 21:20:04 christos Exp $ */ /* @@ -609,7 +609,7 @@ ParseDoDependency(char *line) /* the line to parse */ * so we can safely advance beyond it...There should be * no errors in this, as they would have been discovered * in the initial Var_Subst and we wouldn't be here. */ - cp += Var_ParseSkip(cp, NULL, NULL); + Var_ParseSkip(&cp, NULL); else { /* We don't want to end a word on ':' or '!' if there is a * better match later on in the string. By "better" I mean diff --git a/usr.bin/make/suff.c b/usr.bin/make/suff.c index f00b13483dc..b8e3eb09add 100644 --- a/usr.bin/make/suff.c +++ b/usr.bin/make/suff.c @@ -1,5 +1,5 @@ /* $OpenPackages$ */ -/* $OpenBSD: suff.c,v 1.56 2006/09/24 09:04:05 espie Exp $ */ +/* $OpenBSD: suff.c,v 1.57 2007/07/24 18:52:47 espie Exp $ */ /* $NetBSD: suff.c,v 1.13 1996/11/06 17:59:25 christos Exp $ */ /* @@ -1199,7 +1199,7 @@ SuffExpandVarChildren(LstNode after, GNode *cgn, GNode *pgn) } else if (*cp2 == '$') /* Start of a variable spec -- contact variable module * to find the end so we can skip over it. */ - cp2 += Var_ParseSkip(cp2, &pgn->context, NULL); + Var_ParseSkip(&cp2, &pgn->context); else if (*cp2 == '\\' && cp2[1] != '\0') /* Escaped something -- skip over it. */ cp2+=2; diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c index 559f82d5076..1f135dab8bd 100644 --- a/usr.bin/make/var.c +++ b/usr.bin/make/var.c @@ -1,5 +1,5 @@ /* $OpenPackages$ */ -/* $OpenBSD: var.c,v 1.67 2007/07/22 17:56:50 espie Exp $ */ +/* $OpenBSD: var.c,v 1.68 2007/07/24 18:52:47 espie Exp $ */ /* $NetBSD: var.c,v 1.18 1997/03/18 19:24:46 christos Exp $ */ /* @@ -818,15 +818,17 @@ find_pos(int c) } } -size_t -Var_ParseSkip(const char *str, SymTable *ctxt, bool *result) +bool +Var_ParseSkip(const char **pstr, SymTable *ctxt) { - const char *tstr; /* Pointer into str */ - Var *v; /* Variable in invocation */ - char paren; /* Parenthesis or brace or nothing */ + const char *tstr; + Var *v; + char paren; + const char *str = *pstr; const char *start; size_t length; struct Name name; + bool result; v = NULL; start = str; @@ -849,14 +851,13 @@ Var_ParseSkip(const char *str, SymTable *ctxt, bool *result) length++; } - if (result != NULL) - *result = true; + result = true; if (*tstr == ':' && paren != '\0') if (VarModifiers_Apply(NULL, NULL, ctxt, true, NULL, tstr, paren, &length) == var_Error) - if (result != NULL) - *result = false; - return length; + result = false; + *pstr += length; + return result; } /* As of now, Var_ParseBuffer is just a wrapper around Var_Parse. For diff --git a/usr.bin/make/var.h b/usr.bin/make/var.h index c53c777feda..8eab4551a1a 100644 --- a/usr.bin/make/var.h +++ b/usr.bin/make/var.h @@ -101,11 +101,10 @@ extern char *Var_Parse(const char *, SymTable *, bool, size_t *, * callers who don't care don't need to. */ extern char var_Error[]; -/* length = Var_ParseSkip(varspec, ctxt, &ok); - * Parses a variable specification and returns the specification - * length. Fills ok if the varspec is correct, that pointer can be - * NULL if this information is not needed. */ -extern size_t Var_ParseSkip(const char *, SymTable *, bool *); +/* ok = Var_ParseSkip(&varspec, ctxt, &ok); + * Parses a variable specification and returns true if the varspec + * is correct. Advances pointer past specification. */ +extern bool Var_ParseSkip(const char **, SymTable *); /* ok = Var_ParseBuffer(buf, varspec, ctxt, undef_is_bad, &length); * Similar to Var_Parse, except the value is directly appended to diff --git a/usr.bin/make/varmodifiers.c b/usr.bin/make/varmodifiers.c index 2a24ef7f1e5..3efac907658 100644 --- a/usr.bin/make/varmodifiers.c +++ b/usr.bin/make/varmodifiers.c @@ -1,5 +1,5 @@ /* $OpenPackages$ */ -/* $OpenBSD: varmodifiers.c,v 1.15 2007/07/20 12:32:45 espie Exp $ */ +/* $OpenBSD: varmodifiers.c,v 1.16 2007/07/24 18:52:47 espie Exp $ */ /* $NetBSD: var.c,v 1.18 1997/03/18 19:24:46 christos Exp $ */ /* diff --git a/usr.bin/make/varmodifiers.h b/usr.bin/make/varmodifiers.h index f64f88f172a..057b109530f 100644 --- a/usr.bin/make/varmodifiers.h +++ b/usr.bin/make/varmodifiers.h @@ -2,7 +2,7 @@ #define VARMODIFIERS_H /* $OpenPackages$ */ -/* $OpenBSD: varmodifiers.h,v 1.4 2007/07/20 12:32:45 espie Exp $ */ +/* $OpenBSD: varmodifiers.h,v 1.5 2007/07/24 18:52:47 espie Exp $ */ /* * Copyright (c) 1999 Marc Espie. -- cgit v1.2.3