Module Name: src Committed By: rillig Date: Fri Jun 23 05:21:10 UTC 2023
Modified Files: src/usr.bin/make: cond.c var.c Log Message: make: clean up variable and function names No functional change. To generate a diff of this commit: cvs rdiff -u -r1.352 -r1.353 src/usr.bin/make/cond.c cvs rdiff -u -r1.1058 -r1.1059 src/usr.bin/make/var.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/cond.c diff -u src/usr.bin/make/cond.c:1.352 src/usr.bin/make/cond.c:1.353 --- src/usr.bin/make/cond.c:1.352 Fri Jun 23 04:56:54 2023 +++ src/usr.bin/make/cond.c Fri Jun 23 05:21:10 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.352 2023/06/23 04:56:54 rillig Exp $ */ +/* $NetBSD: cond.c,v 1.353 2023/06/23 05:21:10 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -92,7 +92,7 @@ #include "dir.h" /* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: cond.c,v 1.352 2023/06/23 04:56:54 rillig Exp $"); +MAKE_RCSID("$NetBSD: cond.c,v 1.353 2023/06/23 05:21:10 rillig Exp $"); /* * Conditional expressions conform to this grammar: @@ -1265,7 +1265,7 @@ ParseVarnameGuard(const char **pp, const Guard * Cond_ExtractGuard(const char *line) { - const char *p, *name; + const char *p, *varname; Substring dir; enum GuardKind kind; Guard *guard; @@ -1281,16 +1281,14 @@ Cond_ExtractGuard(const char *line) if (Substring_Equals(dir, "if")) { if (skip_string(&p, "!defined(")) { - if (ParseVarnameGuard(&p, &name) + if (ParseVarnameGuard(&p, &varname) && strcmp(p, ")") == 0) goto found_variable; } else if (skip_string(&p, "!target(")) { - name = p; + const char *arg_p = p; free(ParseWord(&p, false)); if (strcmp(p, ")") == 0) { - char *target; - p = name; - target = ParseWord(&p, true); + char *target = ParseWord(&arg_p, true); guard = bmake_malloc(sizeof(*guard)); guard->kind = GK_TARGET; guard->name = target; @@ -1298,7 +1296,7 @@ Cond_ExtractGuard(const char *line) } } } else if (Substring_Equals(dir, "ifndef")) { - if (ParseVarnameGuard(&p, &name) && *p == '\0') + if (ParseVarnameGuard(&p, &varname) && *p == '\0') goto found_variable; } return NULL; @@ -1307,7 +1305,7 @@ found_variable: kind = GK_VARIABLE; guard = bmake_malloc(sizeof(*guard)); guard->kind = kind; - guard->name = bmake_strsedup(name, p); + guard->name = bmake_strsedup(varname, p); return guard; } Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.1058 src/usr.bin/make/var.c:1.1059 --- src/usr.bin/make/var.c:1.1058 Fri Jun 23 04:56:54 2023 +++ src/usr.bin/make/var.c Fri Jun 23 05:21:10 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1058 2023/06/23 04:56:54 rillig Exp $ */ +/* $NetBSD: var.c,v 1.1059 2023/06/23 05:21:10 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -139,7 +139,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.1058 2023/06/23 04:56:54 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1059 2023/06/23 05:21:10 rillig Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -1536,7 +1536,7 @@ nosub: #ifndef NO_REGEX /* Print the error caused by a regcomp or regexec call. */ static void -VarREError(int reerr, const regex_t *pat, const char *str) +RegexError(int reerr, const regex_t *pat, const char *str) { size_t errlen = regerror(reerr, pat, NULL, 0); char *errbuf = bmake_malloc(errlen); @@ -1621,7 +1621,7 @@ again: if (xrv == 0) goto ok; if (xrv != REG_NOMATCH) - VarREError(xrv, &args->re, "Unexpected regex error"); + RegexError(xrv, &args->re, "Unexpected regex error"); no_match: SepBuf_AddRange(buf, wp, word.end); return; @@ -1792,7 +1792,7 @@ SubstringWords_JoinFree(SubstringWords w * If quoteDollar is set, also quote and double any '$' characters. */ static void -VarQuote(const char *str, bool quoteDollar, LazyBuf *buf) +QuoteShell(const char *str, bool quoteDollar, LazyBuf *buf) { const char *p; @@ -1818,7 +1818,7 @@ VarQuote(const char *str, bool quoteDoll * algorithm. Output is encoded as 8 hex digits, in Little Endian order. */ static char * -VarHash(const char *str) +Hash(const char *str) { static const char hexdigits[16] = "0123456789abcdef"; const unsigned char *ustr = (const unsigned char *)str; @@ -1878,7 +1878,7 @@ VarHash(const char *str) } static char * -VarStrftime(const char *fmt, time_t t, bool gmt) +FormatTime(const char *fmt, time_t t, bool gmt) { char buf[BUFSIZ]; @@ -2575,7 +2575,7 @@ ApplyModifier_Time(const char **pp, ModC expr = ch->expr; if (Expr_ShouldEval(expr)) - Expr_SetValueOwn(expr, VarStrftime(Expr_Str(expr), t, gmt)); + Expr_SetValueOwn(expr, FormatTime(Expr_Str(expr), t, gmt)); return AMR_OK; } @@ -2589,7 +2589,7 @@ ApplyModifier_Hash(const char **pp, ModC *pp += 4; if (ModChain_ShouldEval(ch)) - Expr_SetValueOwn(ch->expr, VarHash(Expr_Str(ch->expr))); + Expr_SetValueOwn(ch->expr, Hash(Expr_Str(ch->expr))); return AMR_OK; } @@ -3009,7 +3009,7 @@ ApplyModifier_Regex(const char **pp, Mod error = regcomp(&args.re, re.str, REG_EXTENDED); if (error != 0) { - VarREError(error, &args.re, "Regex compilation error"); + RegexError(error, &args.re, "Regex compilation error"); LazyBuf_Done(&replaceBuf); FStr_Done(&re); return AMR_CLEANUP; @@ -3045,7 +3045,7 @@ ApplyModifier_Quote(const char **pp, Mod if (!ModChain_ShouldEval(ch)) return AMR_OK; - VarQuote(Expr_Str(ch->expr), quoteDollar, &buf); + QuoteShell(Expr_Str(ch->expr), quoteDollar, &buf); if (buf.data != NULL) Expr_SetValue(ch->expr, LazyBuf_DoneGet(&buf)); else