Module Name: src
Committed By: rillig
Date: Fri Jan 5 21:56:55 UTC 2024
Modified Files:
src/usr.bin/make: str.h var.c
Log Message:
make: clean up string functions
No binary change.
To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/usr.bin/make/str.h
cvs rdiff -u -r1.1091 -r1.1092 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/str.h
diff -u src/usr.bin/make/str.h:1.18 src/usr.bin/make/str.h:1.19
--- src/usr.bin/make/str.h:1.18 Fri Jan 5 21:51:27 2024
+++ src/usr.bin/make/str.h Fri Jan 5 21:56:55 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: str.h,v 1.18 2024/01/05 21:51:27 rillig Exp $ */
+/* $NetBSD: str.h,v 1.19 2024/01/05 21:56:55 rillig Exp $ */
/*
Copyright (c) 2021 Roland Illig <[email protected]>
@@ -76,27 +76,24 @@ typedef struct StrMatchResult {
} StrMatchResult;
+/* Return a string that is the sole owner of str. */
MAKE_INLINE FStr
-FStr_Init(const char *str, void *freeIt)
+FStr_InitOwn(char *str)
{
FStr fstr;
fstr.str = str;
- fstr.freeIt = freeIt;
+ fstr.freeIt = str;
return fstr;
}
-/* Return a string that is the sole owner of str. */
-MAKE_INLINE FStr
-FStr_InitOwn(char *str)
-{
- return FStr_Init(str, str);
-}
-
/* Return a string that refers to the shared str. */
MAKE_INLINE FStr
FStr_InitRefer(const char *str)
{
- return FStr_Init(str, NULL);
+ FStr fstr;
+ fstr.str = str;
+ fstr.freeIt = NULL;
+ return fstr;
}
MAKE_INLINE void
@@ -190,7 +187,7 @@ Substring_SkipFirst(Substring sub, char
}
MAKE_STATIC const char *
-Substring_LastIndex(Substring sub, char ch)
+Substring_FindLast(Substring sub, char ch)
{
const char *p;
Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.1091 src/usr.bin/make/var.c:1.1092
--- src/usr.bin/make/var.c:1.1091 Fri Jan 5 21:51:27 2024
+++ src/usr.bin/make/var.c Fri Jan 5 21:56:55 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.1091 2024/01/05 21:51:27 rillig Exp $ */
+/* $NetBSD: var.c,v 1.1092 2024/01/05 21:56:55 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.1091 2024/01/05 21:51:27 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.1092 2024/01/05 21:56:55 rillig Exp $");
/*
* Variables are defined using one of the VAR=value assignments. Their
@@ -1328,7 +1328,7 @@ ModifyWord_Tail(Substring word, SepBuf *
static void
ModifyWord_Suffix(Substring word, SepBuf *buf, void *dummy MAKE_ATTR_UNUSED)
{
- const char *lastDot = Substring_LastIndex(word, '.');
+ const char *lastDot = Substring_FindLast(word, '.');
if (lastDot != NULL)
SepBuf_AddRange(buf, lastDot + 1, word.end);
}
@@ -1339,7 +1339,7 @@ ModifyWord_Root(Substring word, SepBuf *
{
const char *lastDot, *end;
- lastDot = Substring_LastIndex(word, '.');
+ lastDot = Substring_FindLast(word, '.');
end = lastDot != NULL ? lastDot : word.end;
SepBuf_AddRange(buf, word.start, end);
}