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: inline str_concat4
details: https://anonhg.NetBSD.org/src/rev/22000c0b2613
branches: trunk
changeset: 379420:22000c0b2613
user: rillig <rillig%NetBSD.org@localhost>
date: Sun May 30 21:16:54 2021 +0000
description:
make: inline str_concat4
This function is only ever used for forming strings of the form
"archive(member)".
No functional change.
diffstat:
usr.bin/make/arch.c | 26 +++++++++++++++++++-------
usr.bin/make/str.c | 20 ++------------------
usr.bin/make/str.h | 3 +--
3 files changed, 22 insertions(+), 27 deletions(-)
diffs (132 lines):
diff -r 124d6af64d9a -r 22000c0b2613 usr.bin/make/arch.c
--- a/usr.bin/make/arch.c Sun May 30 21:03:08 2021 +0000
+++ b/usr.bin/make/arch.c Sun May 30 21:16:54 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: arch.c,v 1.199 2021/04/03 11:08:40 rillig Exp $ */
+/* $NetBSD: arch.c,v 1.200 2021/05/30 21:16:54 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -126,7 +126,7 @@
#include "config.h"
/* "@(#)arch.c 8.2 (Berkeley) 1/2/94" */
-MAKE_RCSID("$NetBSD: arch.c,v 1.199 2021/04/03 11:08:40 rillig Exp $");
+MAKE_RCSID("$NetBSD: arch.c,v 1.200 2021/05/30 21:16:54 rillig Exp $");
typedef struct List ArchList;
typedef struct ListNode ArchListNode;
@@ -148,6 +148,7 @@ static FILE *ArchFindMember(const char *
static int ArchSVR4Entry(Arch *, char *, size_t, FILE *);
#endif
+
#ifdef CLEANUP
static void
ArchFree(void *ap)
@@ -167,6 +168,19 @@ ArchFree(void *ap)
}
#endif
+/* Return "archive(member)". */
+static char *
+FullName(const char *archive, const char *member)
+{
+ size_t len1 = strlen(archive);
+ size_t len3 = strlen(member);
+ char *result = bmake_malloc(len1 + 1 + len3 + 1 + 1);
+ memcpy(result, archive, len1);
+ memcpy(result + len1, "(", 1);
+ memcpy(result + len1 + 1, member, len3);
+ memcpy(result + len1 + 1 + len3, ")", 1 + 1);
+ return result;
+}
/*
* Parse an archive specification such as "archive.a(member1 member2.${EXT})",
@@ -312,7 +326,7 @@ Arch_ParseArchive(char **pp, GNodeList *
* Now form an archive spec and recurse to deal with
* nested variables and multi-word variable values.
*/
- fullName = str_concat4(libName.str, "(", memName, ")");
+ fullName = FullName(libName.str, memName);
p = fullName;
if (strchr(memName, '$') != NULL &&
@@ -342,8 +356,7 @@ Arch_ParseArchive(char **pp, GNodeList *
while (!Lst_IsEmpty(&members)) {
char *member = Lst_Dequeue(&members);
- char *fullname = str_concat4(libName.str, "(",
- member, ")");
+ char *fullname = FullName(libName.str, member);
free(member);
gn = Targ_GetNode(fullname);
@@ -355,8 +368,7 @@ Arch_ParseArchive(char **pp, GNodeList *
Lst_Done(&members);
} else {
- char *fullname = str_concat4(libName.str, "(", memName,
- ")");
+ char *fullname = FullName(libName.str, memName);
gn = Targ_GetNode(fullname);
free(fullname);
diff -r 124d6af64d9a -r 22000c0b2613 usr.bin/make/str.c
--- a/usr.bin/make/str.c Sun May 30 21:03:08 2021 +0000
+++ b/usr.bin/make/str.c Sun May 30 21:16:54 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: str.c,v 1.84 2021/04/11 19:05:06 rillig Exp $ */
+/* $NetBSD: str.c,v 1.85 2021/05/30 21:16:54 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -71,7 +71,7 @@
#include "make.h"
/* "@(#)str.c 5.8 (Berkeley) 6/1/90" */
-MAKE_RCSID("$NetBSD: str.c,v 1.84 2021/04/11 19:05:06 rillig Exp $");
+MAKE_RCSID("$NetBSD: str.c,v 1.85 2021/05/30 21:16:54 rillig Exp $");
/* Return the concatenation of s1 and s2, freshly allocated. */
char *
@@ -99,22 +99,6 @@ str_concat3(const char *s1, const char *
return result;
}
-/* Return the concatenation of s1, s2, s3 and s4, freshly allocated. */
-char *
-str_concat4(const char *s1, const char *s2, const char *s3, const char *s4)
-{
- size_t len1 = strlen(s1);
- size_t len2 = strlen(s2);
- size_t len3 = strlen(s3);
- size_t len4 = strlen(s4);
- char *result = bmake_malloc(len1 + len2 + len3 + len4 + 1);
- memcpy(result, s1, len1);
- memcpy(result + len1, s2, len2);
- memcpy(result + len1 + len2, s3, len3);
- memcpy(result + len1 + len2 + len3, s4, len4 + 1);
- return result;
-}
-
/*
* Fracture a string into an array of words (as delineated by tabs or spaces)
* taking quotation marks into account.
diff -r 124d6af64d9a -r 22000c0b2613 usr.bin/make/str.h
--- a/usr.bin/make/str.h Sun May 30 21:03:08 2021 +0000
+++ b/usr.bin/make/str.h Sun May 30 21:16:54 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: str.h,v 1.8 2021/04/14 17:39:11 rillig Exp $ */
+/* $NetBSD: str.h,v 1.9 2021/05/30 21:16:54 rillig Exp $ */
/*
Copyright (c) 2021 Roland Illig <rillig%NetBSD.org@localhost>
@@ -362,6 +362,5 @@ SubstringWords_Free(SubstringWords w)
char *str_concat2(const char *, const char *);
char *str_concat3(const char *, const char *, const char *);
-char *str_concat4(const char *, const char *, const char *, const char *);
bool Str_Match(const char *, const char *);
Home |
Main Index |
Thread Index |
Old Index