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: clean up eat_dots for meta mode
details: https://anonhg.NetBSD.org/src/rev/97391fb26a24
branches: trunk
changeset: 359830:97391fb26a24
user: rillig <rillig%NetBSD.org@localhost>
date: Wed Jan 26 12:16:03 2022 +0000
description:
make: clean up eat_dots for meta mode
No binary change.
diffstat:
usr.bin/make/meta.c | 25 +++++--------------------
1 files changed, 5 insertions(+), 20 deletions(-)
diffs (54 lines):
diff -r d99233b7b958 -r 97391fb26a24 usr.bin/make/meta.c
--- a/usr.bin/make/meta.c Wed Jan 26 11:48:53 2022 +0000
+++ b/usr.bin/make/meta.c Wed Jan 26 12:16:03 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: meta.c,v 1.192 2022/01/15 19:34:07 rillig Exp $ */
+/* $NetBSD: meta.c,v 1.193 2022/01/26 12:16:03 rillig Exp $ */
/*
* Implement 'meta' mode.
@@ -205,31 +205,16 @@
* we use this, to clean up ./ and ../
*/
static void
-eat_dots(char *buf, size_t bufsz, int dots)
+eat_dots(char *buf, size_t bufsz, const char *eat, size_t eatlen)
{
char *cp;
char *cp2;
- const char *eat;
- size_t eatlen;
-
- switch (dots) {
- case 1:
- eat = "/./";
- eatlen = 2;
- break;
- case 2:
- eat = "/../";
- eatlen = 3;
- break;
- default:
- return;
- }
do {
cp = strstr(buf, eat);
if (cp != NULL) {
cp2 = cp + eatlen;
- if (dots == 2 && cp > buf) {
+ if (eatlen == 3 && cp > buf) {
do {
cp--;
} while (cp > buf && *cp != '/');
@@ -284,8 +269,8 @@
} else {
snprintf(buf, sizeof buf, "%s/%s", cwd, tname);
}
- eat_dots(buf, sizeof buf, 1); /* ./ */
- eat_dots(buf, sizeof buf, 2); /* ../ */
+ eat_dots(buf, sizeof buf, "/./", 2);
+ eat_dots(buf, sizeof buf, "/../", 3);
tname = buf;
}
}
Home |
Main Index |
Thread Index |
Old Index