From 36f41bc1ace9a986d9f021a777c6b9cfe6b62f9c Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 18 May 2016 15:44:39 +0200 Subject: murun: Add Buffer#writeBuffer to allow for concatenating buffers. --- docs/mutool/run.html | 2 ++ source/tools/murun.c | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/docs/mutool/run.html b/docs/mutool/run.html index 23286f07..c9ab103e 100644 --- a/docs/mutool/run.html +++ b/docs/mutool/run.html @@ -109,6 +109,8 @@ only store bytes.
Append arguments to the end of the buffer, separated by spaces, ending with a newline.
Buffer#write(...)
Append arguments to the end of the buffer, separated by spaces. +
Buffer#writeBuffer(data) +
Append the contents of the 'data' buffer to the end of the buffer.
Buffer#save(fileName)
Write the contents of the buffer to a file. diff --git a/source/tools/murun.c b/source/tools/murun.c index 0adb8bc0..b8a7d991 100644 --- a/source/tools/murun.c +++ b/source/tools/murun.c @@ -1497,6 +1497,17 @@ static void ffi_Buffer_writeLine(js_State *J) rethrow(J); } +static void ffi_Buffer_writeBuffer(js_State *J) +{ + fz_context *ctx = js_getcontext(J); + fz_buffer *buf = js_touserdata(J, 0, "fz_buffer"); + fz_buffer *cat = js_touserdata(J, 1, "fz_buffer"); + fz_try(ctx) + fz_append_buffer(ctx, buf, cat); + fz_catch(ctx) + rethrow(J); +} + static void ffi_Buffer_save(js_State *J) { fz_context *ctx = js_getcontext(J); @@ -3054,6 +3065,7 @@ int murun_main(int argc, char **argv) jsB_propfun(J, "Buffer.writeByte", ffi_Buffer_writeByte, 1); jsB_propfun(J, "Buffer.writeRune", ffi_Buffer_writeRune, 1); jsB_propfun(J, "Buffer.writeLine", ffi_Buffer_writeLine, 1); + jsB_propfun(J, "Buffer.writeBuffer", ffi_Buffer_writeBuffer, 1); jsB_propfun(J, "Buffer.write", ffi_Buffer_write, 1); jsB_propfun(J, "Buffer.save", ffi_Buffer_save, 1); } -- cgit v1.2.3