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(1): inline Buf_GetAll



details:   https://anonhg.NetBSD.org/src/rev/87f5dea93410
branches:  trunk
changeset: 980281:87f5dea93410
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Jan 30 21:03:32 2021 +0000

description:
make(1): inline Buf_GetAll

diffstat:

 usr.bin/make/buf.c  |  19 ++-----------------
 usr.bin/make/buf.h  |   3 +--
 usr.bin/make/main.c |   6 +++---
 usr.bin/make/var.c  |  18 ++++++++----------
 4 files changed, 14 insertions(+), 32 deletions(-)

diffs (158 lines):

diff -r e74311321d6a -r 87f5dea93410 usr.bin/make/buf.c
--- a/usr.bin/make/buf.c        Sat Jan 30 20:59:29 2021 +0000
+++ b/usr.bin/make/buf.c        Sat Jan 30 21:03:32 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: buf.c,v 1.49 2021/01/30 20:59:29 rillig Exp $  */
+/*     $NetBSD: buf.c,v 1.50 2021/01/30 21:03:32 rillig Exp $  */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -75,7 +75,7 @@
 #include "make.h"
 
 /*     "@(#)buf.c      8.1 (Berkeley) 6/6/93"  */
-MAKE_RCSID("$NetBSD: buf.c,v 1.49 2021/01/30 20:59:29 rillig Exp $");
+MAKE_RCSID("$NetBSD: buf.c,v 1.50 2021/01/30 21:03:32 rillig Exp $");
 
 /* Make space in the buffer for adding at least 16 more bytes. */
 void
@@ -135,21 +135,6 @@
        Buf_AddBytes(buf, str, len);
 }
 
-/*
- * Get the data (usually a string) from the buffer.
- * The returned data is valid until the next modifying operation
- * on the buffer.
- *
- * Returns the data and optionally the length of the data.
- */
-char *
-Buf_GetAll(Buffer *buf, size_t *out_len)
-{
-       if (out_len != NULL)
-               *out_len = buf->len;
-       return buf->data;
-}
-
 /* Mark the buffer as empty, so it can be filled with data again. */
 void
 Buf_Empty(Buffer *buf)
diff -r e74311321d6a -r 87f5dea93410 usr.bin/make/buf.h
--- a/usr.bin/make/buf.h        Sat Jan 30 20:59:29 2021 +0000
+++ b/usr.bin/make/buf.h        Sat Jan 30 21:03:32 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: buf.h,v 1.39 2021/01/30 20:53:29 rillig Exp $  */
+/*     $NetBSD: buf.h,v 1.40 2021/01/30 21:03:32 rillig Exp $  */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -122,7 +122,6 @@
 void Buf_AddBytesBetween(Buffer *, const char *, const char *);
 void Buf_AddStr(Buffer *, const char *);
 void Buf_AddInt(Buffer *, int);
-char *Buf_GetAll(Buffer *, size_t *);
 void Buf_Empty(Buffer *);
 void Buf_Init(Buffer *);
 void Buf_InitSize(Buffer *, size_t);
diff -r e74311321d6a -r 87f5dea93410 usr.bin/make/main.c
--- a/usr.bin/make/main.c       Sat Jan 30 20:59:29 2021 +0000
+++ b/usr.bin/make/main.c       Sat Jan 30 21:03:32 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.518 2021/01/30 20:53:29 rillig Exp $        */
+/*     $NetBSD: main.c,v 1.519 2021/01/30 21:03:32 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.518 2021/01/30 20:53:29 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.519 2021/01/30 21:03:32 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
            "The Regents of the University of California.  "
@@ -2025,7 +2025,7 @@
        Buf_AddStr(&buf, strerror(errno));
        Buf_AddStr(&buf, ")\n");
 
-       write_all(STDERR_FILENO, Buf_GetAll(&buf, NULL), Buf_Len(&buf));
+       write_all(STDERR_FILENO, buf.data, Buf_Len(&buf));
 
        Buf_Done(&buf);
        _exit(1);
diff -r e74311321d6a -r 87f5dea93410 usr.bin/make/var.c
--- a/usr.bin/make/var.c        Sat Jan 30 20:59:29 2021 +0000
+++ b/usr.bin/make/var.c        Sat Jan 30 21:03:32 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.784 2021/01/30 20:53:29 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.785 2021/01/30 21:03:32 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.784 2021/01/30 20:53:29 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.785 2021/01/30 21:03:32 rillig Exp $");
 
 typedef enum VarFlags {
        VAR_NONE        = 0,
@@ -1086,8 +1086,7 @@
                Buf_AddByte(&v->val, ' ');
                Buf_AddStr(&v->val, val);
 
-               DEBUG3(VAR, "%s:%s = %s\n",
-                   ctxt->name, name, Buf_GetAll(&v->val, NULL));
+               DEBUG3(VAR, "%s:%s = %s\n", ctxt->name, name, v->val.data);
 
                if (v->flags & VAR_FROM_ENV) {
                        /*
@@ -1160,7 +1159,7 @@
        if (v == NULL)
                return FStr_InitRefer(NULL);
 
-       value = Buf_GetAll(&v->val, NULL);
+       value = v->val.data;
        return VarFreeEnv(v, FALSE)
            ? FStr_InitOwn(value)
            : FStr_InitRefer(value);
@@ -1174,7 +1173,7 @@
 Var_ValueDirect(const char *name, GNode *ctxt)
 {
        Var *v = VarFind(name, ctxt, FALSE);
-       return v != NULL ? Buf_GetAll(&v->val, NULL) : NULL;
+       return v != NULL ? v->val.data : NULL;
 }
 
 
@@ -4187,7 +4186,7 @@
         * the then-current value of the variable.  This might also invoke
         * undefined behavior.
         */
-       value = FStr_InitRefer(Buf_GetAll(&v->val, NULL));
+       value = FStr_InitRefer(v->val.data);
 
        /*
         * Before applying any modifiers, expand any nested expressions from
@@ -4243,7 +4242,7 @@
                                    ? var_Error : varUndefined);
                        }
                }
-               if (value.str != Buf_GetAll(&v->val, NULL))
+               if (value.str != v->val.data)
                        Buf_Done(&v->val);
                FStr_Done(&v->name);
                free(v);
@@ -4415,8 +4414,7 @@
        for (i = 0; i < vec.len; i++) {
                const char *varname = varnames[i];
                Var *var = HashTable_FindValue(&ctxt->vars, varname);
-               debug_printf("%-16s = %s\n",
-                   varname, Buf_GetAll(&var->val, NULL));
+               debug_printf("%-16s = %s\n", varname, var->val.data);
        }
 
        Vector_Done(&vec);



Home | Main Index | Thread Index | Old Index