summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorharti <harti@FreeBSD.org>2005-02-04 13:34:16 +0000
committerharti <harti@FreeBSD.org>2005-02-04 13:34:16 +0000
commit6861248dfcd7d5c6641f437335516c106f83df33 (patch)
tree8f4d2441bdfa94ac38f4f284b8ac56d81e8a6fb3
parent7403bf4c90000b970a2aa9da9e5c116a4aac5bb8 (diff)
downloadFreeBSD-src-6861248dfcd7d5c6641f437335516c106f83df33.zip
FreeBSD-src-6861248dfcd7d5c6641f437335516c106f83df33.tar.gz
None of the users of Buf_Discard used it to get rid of only a part of
the buffer. So replace Buf_Discard by Buf_Clear which just gets rid of the entire contents. Submitted by: Max Okumoto <okumoto@ucsd.edu>
-rw-r--r--usr.bin/make/buf.c35
-rw-r--r--usr.bin/make/buf.h2
-rw-r--r--usr.bin/make/parse.c2
-rw-r--r--usr.bin/make/var.c2
4 files changed, 13 insertions, 28 deletions
diff --git a/usr.bin/make/buf.c b/usr.bin/make/buf.c
index b9a4a43..c4294bd 100644
--- a/usr.bin/make/buf.c
+++ b/usr.bin/make/buf.c
@@ -165,31 +165,6 @@ Buf_GetAll(Buffer *bp, size_t *numBytesPtr)
/*-
*-----------------------------------------------------------------------
- * Buf_Discard --
- * Throw away bytes in a buffer.
- *
- * Results:
- * None.
- *
- * Side Effects:
- * The bytes are discarded.
- *
- *-----------------------------------------------------------------------
- */
-void
-Buf_Discard(Buffer *bp, size_t numBytes)
-{
-
- if ((size_t)(bp->inPtr - bp->outPtr) <= numBytes) {
- bp->inPtr = bp->outPtr = bp->buffer;
- bp->left = bp->size;
- *bp->inPtr = 0;
- } else
- bp->outPtr += numBytes;
-}
-
-/*-
- *-----------------------------------------------------------------------
* Buf_Size --
* Returns the number of bytes in the given buffer. Doesn't include
* the null-terminating byte.
@@ -286,3 +261,13 @@ Buf_ReplaceLastByte(Buffer *buf, Byte byte)
else
*(buf->inPtr - 1) = byte;
}
+
+void
+Buf_Clear(Buffer *bp)
+{
+ bp->inPtr = bp->buffer;
+ bp->outPtr = bp->buffer;
+ bp->left = bp->size;
+ bp->inPtr[0] = '\0';
+}
+
diff --git a/usr.bin/make/buf.h b/usr.bin/make/buf.h
index db25f70..9c1df40 100644
--- a/usr.bin/make/buf.h
+++ b/usr.bin/make/buf.h
@@ -83,7 +83,7 @@ typedef struct Buffer {
void Buf_OvAddByte(Buffer *, Byte);
void Buf_AddBytes(Buffer *, size_t, const Byte *);
Byte *Buf_GetAll(Buffer *, size_t *);
-void Buf_Discard(Buffer *, size_t);
+void Buf_Clear(Buffer *);
size_t Buf_Size(Buffer *);
Buffer *Buf_Init(size_t);
void Buf_Destroy(Buffer *, Boolean);
diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c
index 346ee90..d9856cd 100644
--- a/usr.bin/make/parse.c
+++ b/usr.bin/make/parse.c
@@ -2018,7 +2018,7 @@ ParseSkipLine(int skip, int keep_newline)
buf = Buf_Init(MAKE_BSIZE);
do {
- Buf_Discard(buf, lineLength);
+ Buf_Clear(buf);
lastc = '\0';
while (((c = ParseReadc()) != '\n' || lastc == '\\')
diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c
index 9004c3d..10680ae 100644
--- a/usr.bin/make/var.c
+++ b/usr.bin/make/var.c
@@ -436,7 +436,7 @@ Var_Set(const char *name, const char *val, GNode *ctxt)
if (v == NULL) {
VarAdd(n, val, ctxt);
} else {
- Buf_Discard(v->val, Buf_Size(v->val));
+ Buf_Clear(v->val);
Buf_AddBytes(v->val, strlen(val), (const Byte *)val);
DEBUGF(VAR, ("%s:%s = %s\n", ctxt->name, n, val));
OpenPOWER on IntegriCloud