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: use more practical data type in RegexReplace
details: https://anonhg.NetBSD.org/src/rev/47492a9f0edf
branches: trunk
changeset: 984111:47492a9f0edf
user: rillig <rillig%NetBSD.org@localhost>
date: Mon Jun 21 18:25:20 2021 +0000
description:
make: use more practical data type in RegexReplace
While size_t is most appropriate for array indexes, make needs to be
compatible with C90, which does not support the %zu printf conversion.
To avoid type casts, use a simple unsigned int here, which is more than
enough for storing a single decimal digit.
No functional change.
diffstat:
usr.bin/make/var.c | 13 ++++++-------
1 files changed, 6 insertions(+), 7 deletions(-)
diffs (46 lines):
diff -r e441d00febaf -r 47492a9f0edf usr.bin/make/var.c
--- a/usr.bin/make/var.c Mon Jun 21 18:12:49 2021 +0000
+++ b/usr.bin/make/var.c Mon Jun 21 18:25:20 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.937 2021/06/21 18:12:49 rillig Exp $ */
+/* $NetBSD: var.c,v 1.938 2021/06/21 18:25:20 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -140,7 +140,7 @@
#include "metachar.h"
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.937 2021/06/21 18:12:49 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.938 2021/06/21 18:25:20 rillig Exp $");
/*
* Variables are defined using one of the VAR=value assignments. Their
@@ -1594,7 +1594,7 @@
const regmatch_t *m, size_t nsub)
{
const char *rp;
- size_t n;
+ unsigned int n;
for (rp = replace; *rp != '\0'; rp++) {
if (*rp == '\\' && (rp[1] == '&' || rp[1] == '\\')) {
@@ -1615,15 +1615,14 @@
}
/* \0 to \9 backreference */
- n = (size_t)(rp[1] - '0');
+ n = rp[1] - '0';
rp++;
if (n >= nsub) {
- Error("No subexpression \\%u", (unsigned)n);
+ Error("No subexpression \\%u", n);
} else if (m[n].rm_so == -1) {
if (opts.strict) {
- Error("No match for subexpression \\%u",
- (unsigned)n);
+ Error("No match for subexpression \\%u", n);
}
} else {
SepBuf_AddBytesBetween(buf,
Home |
Main Index |
Thread Index |
Old Index