summaryrefslogtreecommitdiffstats
path: root/usr.bin/make/buf.c
diff options
context:
space:
mode:
authorharti <harti@FreeBSD.org>2005-03-22 07:42:51 +0000
committerharti <harti@FreeBSD.org>2005-03-22 07:42:51 +0000
commit5ced7169a6c0ad9cfdc99da1258e2d72c7386a08 (patch)
tree00de8b941375c54579520e916e38bdfcf3e87560 /usr.bin/make/buf.c
parent831661f9ab9c66b94d3b80d3931121aa4b98ef3f (diff)
downloadFreeBSD-src-5ced7169a6c0ad9cfdc99da1258e2d72c7386a08.zip
FreeBSD-src-5ced7169a6c0ad9cfdc99da1258e2d72c7386a08.tar.gz
Two new functions: Buf_Data() returns a reference to the data in
the buffer and Buf_AppendBuf() appends a copy of one buffer to another buffer. Patch: 7.146,7.147 Submitted by: Max Okumoto <okumoto@ucsd.edu>
Diffstat (limited to 'usr.bin/make/buf.c')
-rw-r--r--usr.bin/make/buf.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/usr.bin/make/buf.c b/usr.bin/make/buf.c
index 0da71e7..b4e86dd 100644
--- a/usr.bin/make/buf.c
+++ b/usr.bin/make/buf.c
@@ -71,6 +71,18 @@ Buf_Size(const Buffer *buf)
}
/**
+ * Returns a reference to the data contained in the buffer.
+ *
+ * @note Adding data to the Buffer object may invalidate the reference.
+ */
+inline char *
+Buf_Data(const Buffer *bp)
+{
+
+ return (bp->buf);
+}
+
+/**
* Expand the buffer to hold the number of additional bytes, plus
* space to store a terminating NULL byte.
*/
@@ -223,11 +235,22 @@ Buf_Append(Buffer *bp, const char str[])
}
/**
+ * Append characters in buf to Buffer object
+ */
+void
+Buf_AppendBuf(Buffer *bp, const Buffer *buf)
+{
+
+ Buf_AddBytes(bp, Buf_Size(buf), buf->buf);
+}
+
+/**
* Append characters between str and end to Buffer object.
*/
void
Buf_AppendRange(Buffer *bp, const char str[], const char *end)
{
+
Buf_AddBytes(bp, end - str, str);
}
OpenPOWER on IntegriCloud