Module Name: src
Committed By: rillig
Date: Sat Jan 30 21:25:10 UTC 2021
Modified Files:
src/usr.bin/make: buf.h main.c var.c
Log Message:
make(1): inline Buf_Len
To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/usr.bin/make/buf.h
cvs rdiff -u -r1.519 -r1.520 src/usr.bin/make/main.c
cvs rdiff -u -r1.785 -r1.786 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/buf.h
diff -u src/usr.bin/make/buf.h:1.41 src/usr.bin/make/buf.h:1.42
--- src/usr.bin/make/buf.h:1.41 Sat Jan 30 21:18:14 2021
+++ src/usr.bin/make/buf.h Sat Jan 30 21:25:10 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: buf.h,v 1.41 2021/01/30 21:18:14 rillig Exp $ */
+/* $NetBSD: buf.h,v 1.42 2021/01/30 21:25:10 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -81,8 +81,8 @@
/* An automatically growing null-terminated buffer of characters. */
typedef struct Buffer {
- size_t cap; /* Allocated size of the buffer, including the null */
- size_t len; /* Number of bytes in buffer, excluding the null */
+ size_t cap; /* Allocated size of the buffer, including the '\0' */
+ size_t len; /* Number of bytes in buffer, excluding the '\0' */
char *data; /* The buffer itself (always null-terminated) */
} Buffer;
@@ -101,12 +101,6 @@ Buf_AddByte(Buffer *buf, char byte)
end[1] = '\0';
}
-MAKE_INLINE size_t
-Buf_Len(const Buffer *buf)
-{
- return buf->len;
-}
-
MAKE_INLINE Boolean
Buf_EndsWith(const Buffer *buf, char ch)
{
Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.519 src/usr.bin/make/main.c:1.520
--- src/usr.bin/make/main.c:1.519 Sat Jan 30 21:03:32 2021
+++ src/usr.bin/make/main.c Sat Jan 30 21:25:10 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.519 2021/01/30 21:03:32 rillig Exp $ */
+/* $NetBSD: main.c,v 1.520 2021/01/30 21:25:10 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -110,7 +110,7 @@
#include "trace.h"
/* "@(#)main.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: main.c,v 1.519 2021/01/30 21:03:32 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.520 2021/01/30 21:25:10 rillig Exp $");
#if defined(MAKE_NATIVE) && !defined(lint)
__COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
"The Regents of the University of California. "
@@ -1840,7 +1840,7 @@ Cmd_Exec(const char *cmd, const char **e
while ((pid = waitpid(cpid, &status, 0)) != cpid && pid >= 0)
JobReapChild(pid, status, FALSE);
- res_len = Buf_Len(&buf);
+ res_len = buf.len;
res = Buf_DoneData(&buf);
if (savederr != 0)
@@ -2025,7 +2025,7 @@ execDie(const char *af, const char *av)
Buf_AddStr(&buf, strerror(errno));
Buf_AddStr(&buf, ")\n");
- write_all(STDERR_FILENO, buf.data, Buf_Len(&buf));
+ write_all(STDERR_FILENO, buf.data, buf.len);
Buf_Done(&buf);
_exit(1);
Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.785 src/usr.bin/make/var.c:1.786
--- src/usr.bin/make/var.c:1.785 Sat Jan 30 21:03:32 2021
+++ src/usr.bin/make/var.c Sat Jan 30 21:25:10 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.785 2021/01/30 21:03:32 rillig Exp $ */
+/* $NetBSD: var.c,v 1.786 2021/01/30 21:25:10 rillig Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
#include "metachar.h"
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.785 2021/01/30 21:03:32 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.786 2021/01/30 21:25:10 rillig Exp $");
typedef enum VarFlags {
VAR_NONE = 0,
@@ -1745,7 +1745,7 @@ ModifyWords(const char *str,
for (i = 0; i < words.len; i++) {
modifyWord(words.words[i], &result, modifyWord_args);
- if (Buf_Len(&result.buf) > 0)
+ if (result.buf.len > 0)
SepBuf_Sep(&result);
}
@@ -2164,7 +2164,7 @@ ParseModifierPartSubst(
*pp = ++p;
if (out_length != NULL)
- *out_length = Buf_Len(&buf);
+ *out_length = buf.len;
*out_part = Buf_DoneData(&buf);
DEBUG1(VAR, "Modifier part: \"%s\"\n", *out_part);
@@ -3804,7 +3804,7 @@ ParseVarname(const char **pp, char start
}
}
*pp = p;
- *out_varname_len = Buf_Len(&buf);
+ *out_varname_len = buf.len;
return Buf_DoneData(&buf);
}