summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2017-03-12 11:19:09 -0500
committerTor Andersson <tor.andersson@artifex.com>2017-03-22 12:07:26 +0100
commitcfb66cd25bbf31857b471735e5ff0f7c2aea4d3c (patch)
tree8d8d06c9e2c880611a3c8cc025d8c35fe38d59ba
parent3832d0c7ab87aa1f2b3a3dbebe43a37e4055d121 (diff)
downloadmupdf-cfb66cd25bbf31857b471735e5ff0f7c2aea4d3c.tar.xz
Rename fz_putc/puts/printf to fz_write_*.
Rename fz_write to fz_write_data. Rename fz_write_buffer_* and fz_buffer_printf to fz_append_*. Be consistent in naming: fz_write_* calls write to fz_output. fz_append_* calls append to fz_buffer. Update documentation.
-rw-r--r--include/mupdf/fitz/buffer.h73
-rw-r--r--include/mupdf/fitz/output.h60
-rw-r--r--include/mupdf/pdf/parse.h4
-rw-r--r--platform/java/mupdf_native.c42
-rw-r--r--platform/x11/pdfapp.c2
-rw-r--r--source/fitz/bitmap.c10
-rw-r--r--source/fitz/buffer.c67
-rw-r--r--source/fitz/draw-device.c2
-rw-r--r--source/fitz/font.c12
-rw-r--r--source/fitz/hash.c10
-rw-r--r--source/fitz/image.c2
-rw-r--r--source/fitz/load-gif.c2
-rw-r--r--source/fitz/outline.c12
-rw-r--r--source/fitz/output-pcl.c114
-rw-r--r--source/fitz/output-png.c6
-rw-r--r--source/fitz/output-pnm.c44
-rw-r--r--source/fitz/output-ps.c28
-rw-r--r--source/fitz/output-pwg.c30
-rw-r--r--source/fitz/output-tga.c44
-rw-r--r--source/fitz/output.c10
-rw-r--r--source/fitz/path.c26
-rw-r--r--source/fitz/shade.c26
-rw-r--r--source/fitz/stext-output.c148
-rw-r--r--source/fitz/stext-search.c4
-rw-r--r--source/fitz/store.c12
-rw-r--r--source/fitz/svg-device.c264
-rw-r--r--source/fitz/trace-device.c158
-rw-r--r--source/fitz/util.c6
-rw-r--r--source/fitz/zip.c44
-rw-r--r--source/gprf/gprf-skeleton.c6
-rw-r--r--source/pdf/pdf-appearance.c160
-rw-r--r--source/pdf/pdf-crypt.c24
-rw-r--r--source/pdf/pdf-device.c96
-rw-r--r--source/pdf/pdf-font.c78
-rw-r--r--source/pdf/pdf-function.c78
-rw-r--r--source/pdf/pdf-lex.c26
-rw-r--r--source/pdf/pdf-object.c4
-rw-r--r--source/pdf/pdf-op-buffer.c274
-rw-r--r--source/pdf/pdf-pkcs7.c10
-rw-r--r--source/pdf/pdf-store.c2
-rw-r--r--source/pdf/pdf-write.c144
-rw-r--r--source/tools/mudraw.c38
-rw-r--r--source/tools/muraster.c6
-rw-r--r--source/tools/murun.c10
-rw-r--r--source/tools/pdfcreate.c4
-rw-r--r--source/tools/pdfextract.c4
-rw-r--r--source/tools/pdfinfo.c68
-rw-r--r--source/tools/pdfpages.c12
-rw-r--r--source/tools/pdfshow.c36
49 files changed, 1163 insertions, 1179 deletions
diff --git a/include/mupdf/fitz/buffer.h b/include/mupdf/fitz/buffer.h
index df3f216a..96fcc185 100644
--- a/include/mupdf/fitz/buffer.h
+++ b/include/mupdf/fitz/buffer.h
@@ -15,34 +15,27 @@ typedef struct fz_buffer_s fz_buffer;
/*
fz_keep_buffer: Increment the reference count for a buffer.
- buf: The buffer to increment the reference count for.
-
- Returns a pointer to the buffer. Does not throw exceptions.
+ Returns a pointer to the buffer.
*/
fz_buffer *fz_keep_buffer(fz_context *ctx, fz_buffer *buf);
/*
fz_drop_buffer: Decrement the reference count for a buffer.
-
- buf: The buffer to decrement the reference count for.
*/
void fz_drop_buffer(fz_context *ctx, fz_buffer *buf);
/*
- fz_buffer_storage: Retrieve information on the storage currently used
- by a buffer.
+ fz_buffer_storage: Retrieve internal memory of buffer.
- data: Pointer to place to retrieve data pointer.
+ datap: Output parameter that will be pointed to the data.
- Returns length of stream.
+ Returns the current size of the data in bytes.
*/
-size_t fz_buffer_storage(fz_context *ctx, fz_buffer *buf, unsigned char **data);
+size_t fz_buffer_storage(fz_context *ctx, fz_buffer *buf, unsigned char **datap);
/*
fz_string_from_buffer: Ensure that a buffer's data ends in a
0 byte, and return a pointer to it.
-
- Returns pointer to data.
*/
const char *fz_string_from_buffer(fz_context *ctx, fz_buffer *buf);
@@ -51,8 +44,7 @@ const char *fz_string_from_buffer(fz_context *ctx, fz_buffer *buf);
capacity: Initial capacity.
- Returns pointer to new buffer. Throws exception on allocation
- failure.
+ Returns pointer to new buffer.
*/
fz_buffer *fz_new_buffer(fz_context *ctx, size_t capacity);
@@ -85,60 +77,47 @@ fz_buffer *fz_new_buffer_from_base64(fz_context *ctx, const char *data, size_t s
fz_resize_buffer: Ensure that a buffer has a given capacity,
truncating data if required.
- buf: The buffer to alter.
-
capacity: The desired capacity for the buffer. If the current size
of the buffer contents is smaller than capacity, it is truncated.
-
*/
void fz_resize_buffer(fz_context *ctx, fz_buffer *buf, size_t capacity);
/*
fz_grow_buffer: Make some space within a buffer (i.e. ensure that
capacity > size).
-
- buf: The buffer to grow.
-
- May throw exception on failure to allocate.
*/
void fz_grow_buffer(fz_context *ctx, fz_buffer *buf);
/*
- fz_trim_buffer: Trim wasted capacity from a buffer.
-
- buf: The buffer to trim.
+ fz_trim_buffer: Trim wasted capacity from a buffer by resizing internal memory.
*/
void fz_trim_buffer(fz_context *ctx, fz_buffer *buf);
/*
- fz_append_buffer: Concatenate buffers
-
- buf: first to concatenate and the holder of the result
- extra: second to concatenate
-
- May throw exception on failure to allocate.
+ fz_append_buffer: Append the contents of source buffer to destination buffer.
*/
-void fz_append_buffer(fz_context *ctx, fz_buffer *buf, fz_buffer *extra);
+void fz_append_buffer(fz_context *ctx, fz_buffer *destination, fz_buffer *source);
/*
- fz_write_buffer*: write to a buffer.
- fz_buffer_printf: print formatted to a buffer.
- fz_buffer_print_pdfstring: Print a string using PDF syntax and escapes.
- The buffer will grow as required.
+ fz_append_*: Append data to a buffer.
+ fz_append_printf: Format and append data to buffer using printf-like formatting (see fz_vsnprintf).
+ fz_append_pdf_string: Append a string with PDF syntax quotes and escapes.
+ The buffer will automatically grow as required.
*/
-void fz_write_buffer(fz_context *ctx, fz_buffer *buf, const void *data, size_t len);
-void fz_write_buffer_byte(fz_context *ctx, fz_buffer *buf, int val);
-void fz_write_buffer_rune(fz_context *ctx, fz_buffer *buf, int val);
-void fz_write_buffer_int32_le(fz_context *ctx, fz_buffer *buf, int x);
-void fz_write_buffer_int16_le(fz_context *ctx, fz_buffer *buf, int x);
-void fz_write_buffer_bits(fz_context *ctx, fz_buffer *buf, int val, int bits);
-void fz_write_buffer_pad(fz_context *ctx, fz_buffer *buf);
-size_t fz_buffer_printf(fz_context *ctx, fz_buffer *buffer, const char *fmt, ...);
-size_t fz_buffer_vprintf(fz_context *ctx, fz_buffer *buffer, const char *fmt, va_list args);
-void fz_buffer_print_pdf_string(fz_context *ctx, fz_buffer *buffer, const char *text);
+void fz_append_data(fz_context *ctx, fz_buffer *buf, const void *data, size_t len);
+void fz_append_string(fz_context *ctx, fz_buffer *buf, const char *data);
+void fz_append_byte(fz_context *ctx, fz_buffer *buf, int c);
+void fz_append_rune(fz_context *ctx, fz_buffer *buf, int c);
+void fz_append_int32_le(fz_context *ctx, fz_buffer *buf, int x);
+void fz_append_int16_le(fz_context *ctx, fz_buffer *buf, int x);
+void fz_append_bits(fz_context *ctx, fz_buffer *buf, int value, int count);
+void fz_append_bits_pad(fz_context *ctx, fz_buffer *buf);
+size_t fz_append_printf(fz_context *ctx, fz_buffer *buffer, const char *fmt, ...);
+size_t fz_append_vprintf(fz_context *ctx, fz_buffer *buffer, const char *fmt, va_list args);
+void fz_append_pdf_string(fz_context *ctx, fz_buffer *buffer, const char *text);
/*
- fz_terminate_buffer: zero-terminate buffer in order to use as a C string.
+ fz_terminate_buffer: Zero-terminate buffer in order to use as a C string.
This byte is invisible and does not affect the length of the buffer as returned by fz_buffer_storage.
The zero byte is written *after* the data, and subsequent writes will overwrite the terminating byte.
@@ -146,7 +125,7 @@ void fz_buffer_print_pdf_string(fz_context *ctx, fz_buffer *buffer, const char *
void fz_terminate_buffer(fz_context *ctx, fz_buffer *buf);
/*
- fz_md5_buffer: create MD5 digest of buffer contents.
+ fz_md5_buffer: Create MD5 digest of buffer contents.
*/
void fz_md5_buffer(fz_context *ctx, fz_buffer *buffer, unsigned char digest[16]);
diff --git a/include/mupdf/fitz/output.h b/include/mupdf/fitz/output.h
index fd57736a..d1282352 100644
--- a/include/mupdf/fitz/output.h
+++ b/include/mupdf/fitz/output.h
@@ -140,41 +140,28 @@ void fz_set_stdout(fz_context *ctx, fz_output *out);
void fz_set_stderr(fz_context *ctx, fz_output *err);
/*
- fz_printf: fprintf equivalent for output streams. See fz_snprintf.
+ fz_write_printf: Format and write data to an output stream.
+ See fz_vsnprintf for formatting details.
*/
-void fz_printf(fz_context *ctx, fz_output *out, const char *fmt, ...);
+void fz_write_printf(fz_context *ctx, fz_output *out, const char *fmt, ...);
/*
- fz_vprintf: vfprintf equivalent for output streams. See fz_vsnprintf.
+ fz_write_vprintf: va_list version of fz_write_printf.
*/
-void fz_vprintf(fz_context *ctx, fz_output *out, const char *fmt, va_list ap);
+void fz_write_vprintf(fz_context *ctx, fz_output *out, const char *fmt, va_list ap);
/*
- fz_putc: fputc equivalent for output streams.
-*/
-#define fz_putc(C,O,B) fz_write_byte(C, O, B)
-
-/*
- fz_puts: fputs equivalent for output streams.
-*/
-#define fz_puts(C,O,S) fz_write(C, O, (S), strlen(S))
-
-/*
- fz_putrune: fz_putc equivalent for utf-8 output.
-*/
-#define fz_putrune(C,O,R) fz_write_rune(C, O, R)
-
-/*
- fz_seek_output: Seek to the specified file position. See fseek
- for arguments.
+ fz_seek_output: Seek to the specified file position.
+ See fseek for arguments.
Throw an error on unseekable outputs.
*/
void fz_seek_output(fz_context *ctx, fz_output *out, fz_off_t off, int whence);
/*
- fz_tell_output: Return the current file position. Throw an error
- on untellable outputs.
+ fz_tell_output: Return the current file position.
+
+ Throw an error on untellable outputs.
*/
fz_off_t fz_tell_output(fz_context *ctx, fz_output *out);
@@ -184,22 +171,27 @@ fz_off_t fz_tell_output(fz_context *ctx, fz_output *out);
void fz_drop_output(fz_context *, fz_output *);
/*
- fz_write: Write data to output. Designed to parallel
- fwrite.
-
- out: Output stream to write to.
+ fz_write_data: Write data to output.
data: Pointer to data to write.
-
- size: Length of data to write.
+ size: Size of data to write in bytes.
*/
-static inline void fz_write(fz_context *ctx, fz_output *out, const void *data, size_t size)
+static inline void fz_write_data(fz_context *ctx, fz_output *out, const void *data, size_t size)
{
if (out)
out->write(ctx, out->state, data, size);
}
/*
+ fz_write_string: Write a string. Does not write zero terminator.
+*/
+static inline void fz_write_string(fz_context *ctx, fz_output *out, const char *s)
+{
+ if (out)
+ out->write(ctx, out->state, s, strlen(s));
+}
+
+/*
fz_write_int32_be: Write a big-endian 32-bit binary integer.
*/
static inline void fz_write_int32_be(fz_context *ctx, fz_output *out, int x)
@@ -261,10 +253,6 @@ static inline void fz_write_int16_le(fz_context *ctx, fz_output *out, int x)
/*
fz_write_byte: Write a single byte.
-
- out: stream to write to.
-
- x: value to write
*/
static inline void fz_write_byte(fz_context *ctx, fz_output *out, unsigned char x)
{
@@ -274,10 +262,6 @@ static inline void fz_write_byte(fz_context *ctx, fz_output *out, unsigned char
/*
fz_write_rune: Write a UTF-8 encoded unicode character.
-
- out: stream to write to.
-
- x: value to write
*/
static inline void fz_write_rune(fz_context *ctx, fz_output *out, int rune)
{
diff --git a/include/mupdf/pdf/parse.h b/include/mupdf/pdf/parse.h
index ea715326..dc706f40 100644
--- a/include/mupdf/pdf/parse.h
+++ b/include/mupdf/pdf/parse.h
@@ -32,8 +32,8 @@ pdf_obj *pdf_parse_stm_obj(fz_context *ctx, pdf_document *doc, fz_stream *f, pdf
pdf_obj *pdf_parse_ind_obj(fz_context *ctx, pdf_document *doc, fz_stream *f, pdf_lexbuf *buf, int *num, int *gen, fz_off_t *stm_ofs, int *try_repair);
/*
- pdf_print_token: print a lexed token to a buffer, growing if necessary
+ pdf_append_token: print a lexed token to a buffer, growing if necessary
*/
-void pdf_print_token(fz_context *ctx, fz_buffer *buf, int tok, pdf_lexbuf *lex);
+void pdf_append_token(fz_context *ctx, fz_buffer *buf, int tok, pdf_lexbuf *lex);
#endif
diff --git a/platform/java/mupdf_native.c b/platform/java/mupdf_native.c
index 4b6ca33a..311560fd 100644
--- a/platform/java/mupdf_native.c
+++ b/platform/java/mupdf_native.c
@@ -4864,22 +4864,22 @@ FUN(Page_textAsHtml)(JNIEnv *env, jobject self)
buf = fz_new_buffer(ctx, 256);
out = fz_new_output_with_buffer(ctx, buf);
- fz_printf(ctx, out, "<html>\n");
- fz_printf(ctx, out, "<style>\n");
- fz_printf(ctx, out, "body{margin:0;}\n");
- fz_printf(ctx, out, "div.page{background-color:white;}\n");
- fz_printf(ctx, out, "div.block{margin:0pt;padding:0pt;}\n");
- fz_printf(ctx, out, "div.metaline{display:table;width:100%%}\n");
- fz_printf(ctx, out, "div.line{display:table-row;}\n");
- fz_printf(ctx, out, "div.cell{display:table-cell;padding-left:0.25em;padding-right:0.25em}\n");
- //fz_printf(ctx, out, "p{margin:0;padding:0;}\n");
- fz_printf(ctx, out, "</style>\n");
- fz_printf(ctx, out, "<body style=\"margin:0\"><div style=\"padding:10px\" id=\"content\">");
+ fz_write_printf(ctx, out, "<html>\n");
+ fz_write_printf(ctx, out, "<style>\n");
+ fz_write_printf(ctx, out, "body{margin:0;}\n");
+ fz_write_printf(ctx, out, "div.page{background-color:white;}\n");
+ fz_write_printf(ctx, out, "div.block{margin:0pt;padding:0pt;}\n");
+ fz_write_printf(ctx, out, "div.metaline{display:table;width:100%%}\n");
+ fz_write_printf(ctx, out, "div.line{display:table-row;}\n");
+ fz_write_printf(ctx, out, "div.cell{display:table-cell;padding-left:0.25em;padding-right:0.25em}\n");
+ //fz_write_printf(ctx, out, "p{margin:0;padding:0;}\n");
+ fz_write_printf(ctx, out, "</style>\n");
+ fz_write_printf(ctx, out, "<body style=\"margin:0\"><div style=\"padding:10px\" id=\"content\">");
fz_print_stext_page_html(ctx, out, text);
- fz_printf(ctx, out, "</div></body>\n");
- fz_printf(ctx, out, "<style>\n");
+ fz_write_printf(ctx, out, "</div></body>\n");
+ fz_write_printf(ctx, out, "<style>\n");
fz_print_stext_sheet(ctx, out, sheet);
- fz_printf(ctx, out, "</style>\n</html>\n");
+ fz_write_printf(ctx, out, "</style>\n</html>\n");
}
fz_always(ctx)
{
@@ -5244,7 +5244,7 @@ FUN(Buffer_writeByte)(JNIEnv *env, jobject self, jbyte b)
if (!ctx || !buf) return;
fz_try(ctx)
- fz_write_buffer_byte(ctx, buf, b);
+ fz_append_byte(ctx, buf, b);
fz_catch(ctx)
jni_rethrow(env, ctx);
}
@@ -5265,7 +5265,7 @@ FUN(Buffer_writeBytes)(JNIEnv *env, jobject self, jobject jbs)
if (!bs) { jni_throw_io(env, "cannot get bytes to write"); return; }
fz_try(ctx)
- fz_write_buffer(ctx, buf, bs, len);
+ fz_append_data(ctx, buf, bs, len);
fz_always(ctx)
(*env)->ReleaseByteArrayElements(env, jbs, bs, JNI_ABORT);
fz_catch(ctx)
@@ -5306,7 +5306,7 @@ FUN(Buffer_writeBytesFrom)(JNIEnv *env, jobject self, jobject jbs, jint joff, ji
if (!bs) { jni_throw_io(env, "cannot get bytes to write"); return; }
fz_try(ctx)
- fz_write_buffer(ctx, buf, &bs[off], len);
+ fz_append_data(ctx, buf, &bs[off], len);
fz_always(ctx)
(*env)->ReleaseByteArrayElements(env, jbs, bs, JNI_ABORT);
fz_catch(ctx)
@@ -5358,8 +5358,8 @@ FUN(Buffer_writeLine)(JNIEnv *env, jobject self, jstring jline)
fz_try(ctx)
{
- fz_write_buffer(ctx, buf, line, strlen(line));
- fz_write_buffer_byte(ctx, buf, '\n');
+ fz_append_string(ctx, buf, line);
+ fz_append_byte(ctx, buf, '\n');
}
fz_always(ctx)
(*env)->ReleaseStringUTFChars(env, jline, line);
@@ -5395,8 +5395,8 @@ FUN(Buffer_writeLines)(JNIEnv *env, jobject self, jobject jlines)
fz_try(ctx)
{
- fz_write_buffer(ctx, buf, line, strlen(line));
- fz_write_buffer_byte(ctx, buf, '\n');
+ fz_append_string(ctx, buf, line);
+ fz_append_byte(ctx, buf, '\n');
}
fz_always(ctx)
(*env)->ReleaseStringUTFChars(env, jline, line);
diff --git a/platform/x11/pdfapp.c b/platform/x11/pdfapp.c
index 2c4c8b78..be7c0ac0 100644
--- a/platform/x11/pdfapp.c
+++ b/platform/x11/pdfapp.c
@@ -247,7 +247,7 @@ static int make_fake_doc(pdfapp_t *app)
contents = fz_new_buffer(ctx, 100);
- fz_buffer_printf(ctx, contents, "1 0 0 RG %f w 0 0 m %f %f l 0 %f m %f 0 l s\n",
+ fz_append_printf(ctx, contents, "1 0 0 RG %f w 0 0 m %f %f l 0 %f m %f 0 l s\n",
fz_min(mediabox.x1, mediabox.y1) / 20,
mediabox.x1, mediabox.y1,
mediabox.y1, mediabox.x1);
diff --git a/source/fitz/bitmap.c b/source/fitz/bitmap.c
index 2a7a9142..9db6a1df 100644
--- a/source/fitz/bitmap.c
+++ b/source/fitz/bitmap.c
@@ -310,7 +310,7 @@ pbm_write_header(fz_context *ctx, fz_band_writer *writer)
int w = writer->w;
int h = writer->h;
- fz_printf(ctx, out, "P4\n%d %d\n", w, h);
+ fz_write_printf(ctx, out, "P4\n%d %d\n", w, h);
}
static void
@@ -320,7 +320,7 @@ pkm_write_header(fz_context *ctx, fz_band_writer *writer)
int w = writer->w;
int h = writer->h;
- fz_printf(ctx, out, "P7\nWIDTH %d\nHEIGHT %d\nDEPTH 4\nMAXVAL 255\nTUPLTYPE CMYK\nENDHDR\n", w, h);
+ fz_write_printf(ctx, out, "P7\nWIDTH %d\nHEIGHT %d\nDEPTH 4\nMAXVAL 255\nTUPLTYPE CMYK\nENDHDR\n", w, h);
}
void
@@ -363,7 +363,7 @@ pbm_write_band(fz_context *ctx, fz_band_writer *writer, int stride, int band_sta
bytestride = (w + 7) >> 3;
while (end--)
{
- fz_write(ctx, out, p, bytestride);
+ fz_write_data(ctx, out, p, bytestride);
p += stride;
}
}
@@ -391,11 +391,11 @@ pkm_write_band(fz_context *ctx, fz_band_writer *writer, int stride, int band_sta
int ww = w-1;
while (ww > 0)
{
- fz_write(ctx, out, &pkm[8 * *p++], 8);
+ fz_write_data(ctx, out, &pkm[8 * *p++], 8);
ww -= 2;
}
if (ww == 0)
- fz_write(ctx, out, &pkm[8 * *p], 4);
+ fz_write_data(ctx, out, &pkm[8 * *p], 4);
p += bytestride;
}
}
diff --git a/source/fitz/buffer.c b/source/fitz/buffer.c
index a2880659..ab814728 100644
--- a/source/fitz/buffer.c
+++ b/source/fitz/buffer.c
@@ -76,15 +76,15 @@ fz_new_buffer_from_base64(fz_context *ctx, const char *data, size_t size)
{
int c = *s++;
if (c >= 'A' && c <= 'Z')
- fz_write_buffer_bits(ctx, buf, c - 'A', 6);
+ fz_append_bits(ctx, buf, c - 'A', 6);
else if (c >= 'a' && c <= 'z')
- fz_write_buffer_bits(ctx, buf, c - 'a' + 26, 6);
+ fz_append_bits(ctx, buf, c - 'a' + 26, 6);
else if (c >= '0' && c <= '9')
- fz_write_buffer_bits(ctx, buf, c - '0' + 52, 6);
+ fz_append_bits(ctx, buf, c - '0' + 52, 6);
else if (c == '+')
- fz_write_buffer_bits(ctx, buf, 62, 6);
+ fz_append_bits(ctx, buf, 62, 6);
else if (c == '/')
- fz_write_buffer_bits(ctx, buf, 63, 6);
+ fz_append_bits(ctx, buf, 63, 6);
}
}
fz_catch(ctx)
@@ -205,7 +205,8 @@ fz_append_buffer(fz_context *ctx, fz_buffer *buf, fz_buffer *extra)
buf->len += extra->len;
}
-void fz_write_buffer(fz_context *ctx, fz_buffer *buf, const void *data, size_t len)
+void
+fz_append_data(fz_context *ctx, fz_buffer *buf, const void *data, size_t len)
{
if (buf->len + len > buf->cap)
fz_ensure_buffer(ctx, buf, buf->len + len);
@@ -214,7 +215,19 @@ void fz_write_buffer(fz_context *ctx, fz_buffer *buf, const void *data, size_t l
buf->unused_bits = 0;
}
-void fz_write_buffer_byte(fz_context *ctx, fz_buffer *buf, int val)
+void
+fz_append_string(fz_context *ctx, fz_buffer *buf, const char *data)
+{
+ size_t len = strlen(data);
+ if (buf->len + len > buf->cap)
+ fz_ensure_buffer(ctx, buf, buf->len + len);
+ memcpy(buf->data + buf->len, data, len);
+ buf->len += len;
+ buf->unused_bits = 0;
+}
+
+void
+fz_append_byte(fz_context *ctx, fz_buffer *buf, int val)
{
if (buf->len + 1 > buf->cap)
fz_grow_buffer(ctx, buf);
@@ -222,7 +235,8 @@ void fz_write_buffer_byte(fz_context *ctx, fz_buffer *buf, int val)
buf->unused_bits = 0;
}
-void fz_write_buffer_rune(fz_context *ctx, fz_buffer *buf, int c)
+void
+fz_append_rune(fz_context *ctx, fz_buffer *buf, int c)
{
char data[10];
int len = fz_runetochar(data, c);
@@ -233,21 +247,24 @@ void fz_write_buffer_rune(fz_context *ctx, fz_buffer *buf, int c)
buf->unused_bits = 0;
}
-void fz_write_buffer_int32_le(fz_context *ctx, fz_buffer *buf, int x)
+void
+fz_append_int32_le(fz_context *ctx, fz_buffer *buf, int x)
{
- fz_write_buffer_byte(ctx, buf, (x)&0xFF);
- fz_write_buffer_byte(ctx, buf, (x>>8)&0xFF);
- fz_write_buffer_byte(ctx, buf, (x>>16)&0xFF);
- fz_write_buffer_byte(ctx, buf, (x>>24)&0xFF);
+ fz_append_byte(ctx, buf, (x)&0xFF);
+ fz_append_byte(ctx, buf, (x>>8)&0xFF);
+ fz_append_byte(ctx, buf, (x>>16)&0xFF);
+ fz_append_byte(ctx, buf, (x>>24)&0xFF);
}
-void fz_write_buffer_int16_le(fz_context *ctx, fz_buffer *buf, int x)
+void
+fz_append_int16_le(fz_context *ctx, fz_buffer *buf, int x)
{
- fz_write_buffer_byte(ctx, buf, (x)&0xFF);
- fz_write_buffer_byte(ctx, buf, (x>>8)&0xFF);
+ fz_append_byte(ctx, buf, (x)&0xFF);
+ fz_append_byte(ctx, buf, (x>>8)&0xFF);
}
-void fz_write_buffer_bits(fz_context *ctx, fz_buffer *buf, int val, int bits)
+void
+fz_append_bits(fz_context *ctx, fz_buffer *buf, int val, int bits)
{
int shift;
@@ -308,24 +325,25 @@ void fz_write_buffer_bits(fz_context *ctx, fz_buffer *buf, int val, int bits)
buf->unused_bits = bits;
}
-void fz_write_buffer_pad(fz_context *ctx, fz_buffer *buf)
+void
+fz_append_bits_pad(fz_context *ctx, fz_buffer *buf)
{
buf->unused_bits = 0;
}
size_t
-fz_buffer_printf(fz_context *ctx, fz_buffer *buffer, const char *fmt, ...)
+fz_append_printf(fz_context *ctx, fz_buffer *buffer, const char *fmt, ...)
{
size_t ret;
va_list args;
va_start(args, fmt);
- ret = fz_buffer_vprintf(ctx, buffer, fmt, args);
+ ret = fz_append_vprintf(ctx, buffer, fmt, args);
va_end(args);
return ret;
}
size_t
-fz_buffer_vprintf(fz_context *ctx, fz_buffer *buffer, const char *fmt, va_list old_args)
+fz_append_vprintf(fz_context *ctx, fz_buffer *buffer, const char *fmt, va_list old_args)
{
size_t slack;
size_t len;
@@ -355,7 +373,7 @@ fz_buffer_vprintf(fz_context *ctx, fz_buffer *buffer, const char *fmt, va_list o
}
void
-fz_buffer_print_pdf_string(fz_context *ctx, fz_buffer *buffer, const char *text)
+fz_append_pdf_string(fz_context *ctx, fz_buffer *buffer, const char *text)
{
size_t len = 2;
const char *s = text;
@@ -430,7 +448,8 @@ fz_buffer_print_pdf_string(fz_context *ctx, fz_buffer *buffer, const char *text)
buffer->len += len;
}
-void fz_md5_buffer(fz_context *ctx, fz_buffer *buffer, unsigned char digest[16])
+void
+fz_md5_buffer(fz_context *ctx, fz_buffer *buffer, unsigned char digest[16])
{
fz_md5 state;
fz_md5_init(&state);
@@ -469,7 +488,7 @@ fz_test_buffer_write(fz_context *ctx)
k = (rand() & 31)+1;
if (k > j)
k = j;
- fz_write_buffer_bits(ctx, copy, fz_read_bits(ctx, stm, k), k);
+ fz_append_bits(ctx, copy, fz_read_bits(ctx, stm, k), k);
j -= k;
}
while (j);
diff --git a/source/fitz/draw-device.c b/source/fitz/draw-device.c
index 230e3a8e..9d7a19af 100644
--- a/source/fitz/draw-device.c
+++ b/source/fitz/draw-device.c
@@ -1950,7 +1950,7 @@ static void
fz_print_tile(fz_context *ctx, fz_output *out, void *key_)
{
tile_key *key = (tile_key *)key_;
- fz_printf(ctx, out, "(tile id=%x, ctm=%g %g %g %g) ", key->id, key->ctm[0], key->ctm[1], key->ctm[2], key->ctm[3]);
+ fz_write_printf(ctx, out, "(tile id=%x, ctm=%g %g %g %g) ", key->id, key->ctm[0], key->ctm[1], key->ctm[2], key->ctm[3]);
}
static fz_store_type fz_tile_store_type =
diff --git a/source/fitz/font.c b/source/fitz/font.c
index 31877d67..3927eb17 100644
--- a/source/fitz/font.c
+++ b/source/fitz/font.c
@@ -1356,27 +1356,27 @@ fz_render_t3_glyph_direct(fz_context *ctx, fz_device *dev, fz_font *font, int gi
void
fz_print_font(fz_context *ctx, fz_output *out, fz_font *font)
{
- fz_printf(ctx, out, "font '%s' {\n", font->name);
+ fz_write_printf(ctx, out, "font '%s' {\n", font->name);
if (font->ft_face)
{
- fz_printf(ctx, out, "\tfreetype face %p\n", font->ft_face);
+ fz_write_printf(ctx, out, "\tfreetype face %p\n", font->ft_face);
if (font->flags.ft_substitute)
- fz_printf(ctx, out, "\tsubstitute font\n");
+ fz_write_printf(ctx, out, "\tsubstitute font\n");
}
if (font->t3procs)
{
- fz_printf(ctx, out, "\ttype3 matrix [%g %g %g %g]\n",
+ fz_write_printf(ctx, out, "\ttype3 matrix [%g %g %g %g]\n",
font->t3matrix.a, font->t3matrix.b,
font->t3matrix.c, font->t3matrix.d);
- fz_printf(ctx, out, "\ttype3 bbox [%g %g %g %g]\n",
+ fz_write_printf(ctx, out, "\ttype3 bbox [%g %g %g %g]\n",
font->bbox.x0, font->bbox.y0,
font->bbox.x1, font->bbox.y1);
}
- fz_printf(ctx, out, "}\n");
+ fz_write_printf(ctx, out, "}\n");
}
fz_rect *
diff --git a/source/fitz/hash.c b/source/fitz/hash.c
index fe6ae6f8..9ebb0b31 100644
--- a/source/fitz/hash.c
+++ b/source/fitz/hash.c
@@ -290,21 +290,21 @@ fz_print_hash_details(fz_context *ctx, fz_output *out, fz_hash_table *table, voi
{
int i, k;
- fz_printf(ctx, out, "cache load %d / %d\n", table->load, table->size);
+ fz_write_printf(ctx, out, "cache load %d / %d\n", table->load, table->size);
for (i = 0; i < table->size; i++)
{
if (!table->ents[i].val && !compact)
- fz_printf(ctx, out, "table %04d: empty\n", i);
+ fz_write_printf(ctx, out, "table %04d: empty\n", i);
else if (table->ents[i].val)
{
- fz_printf(ctx, out, "table %04d: key=", i);
+ fz_write_printf(ctx, out, "table %04d: key=", i);
for (k = 0; k < MAX_KEY_LEN; k++)
- fz_printf(ctx, out, "%02x", ((unsigned char*)table->ents[i].key)[k]);
+ fz_write_printf(ctx, out, "%02x", ((unsigned char*)table->ents[i].key)[k]);
if (details)
details(ctx, out, table->ents[i].val);
else
- fz_printf(ctx, out, " val=$%p\n", table->ents[i].val);
+ fz_write_printf(ctx, out, " val=$%p\n", table->ents[i].val);
}
}
}
diff --git a/source/fitz/image.c b/source/fitz/image.c
index 261c9f09..a1d392d9 100644
--- a/source/fitz/image.c
+++ b/source/fitz/image.c
@@ -85,7 +85,7 @@ static void
fz_print_image_key(fz_context *ctx, fz_output *out, void *key_)
{
fz_image_key *key = (fz_image_key *)key_;
- fz_printf(ctx, out, "(image %d x %d sf=%d) ", key->image->w, key->image->h, key->l2factor);
+ fz_write_printf(ctx, out, "(image %d x %d sf=%d) ", key->image->w, key->image->h, key->l2factor);
}
static int
diff --git a/source/fitz/load-gif.c b/source/fitz/load-gif.c
index 49e7cc06..c8835774 100644
--- a/source/fitz/load-gif.c
+++ b/source/fitz/load-gif.c
@@ -110,7 +110,7 @@ gif_read_subblocks(fz_context *ctx, struct info *info, unsigned char *p, unsigne
if (end - p < len)
fz_throw(ctx, FZ_ERROR_GENERIC, "premature end in data subblock in gif image");
if (buf)
- fz_write_buffer(ctx, buf, p, len);
+ fz_append_data(ctx, buf, p, len);
p += len;
}
} while (len > 0);
diff --git a/source/fitz/outline.c b/source/fitz/outline.c
index 888212bc..4948110c 100644
--- a/source/fitz/outline.c
+++ b/source/fitz/outline.c
@@ -33,16 +33,16 @@ fz_debug_outline_xml_imp(fz_context *ctx, fz_output *out, fz_outline *outline, i
{
while (outline)
{
- fz_printf(ctx, out, "<outline title=%q uri=\"%s\"", outline->title, outline->uri);
+ fz_write_printf(ctx, out, "<outline title=%q uri=\"%s\"", outline->title, outline->uri);
if (outline->down)
{
- fz_printf(ctx, out, ">\n");
+ fz_write_printf(ctx, out, ">\n");
fz_debug_outline_xml_imp(ctx, out, outline->down, level + 1);
- fz_printf(ctx, out, "</outline>\n");
+ fz_write_printf(ctx, out, "</outline>\n");
}
else
{
- fz_printf(ctx, out, " />\n");
+ fz_write_printf(ctx, out, " />\n");
}
outline = outline->next;
}
@@ -61,8 +61,8 @@ fz_print_outline_imp(fz_context *ctx, fz_output *out, fz_outline *outline, int l
while (outline)
{
for (i = 0; i < level; i++)
- fz_printf(ctx, out, "\t");
- fz_printf(ctx, out, "%s\t%s\n", outline->title, outline->uri);
+ fz_write_printf(ctx, out, "\t");
+ fz_write_printf(ctx, out, "%s\t%s\n", outline->title, outline->uri);
if (outline->down)
fz_print_outline_imp(ctx, out, outline->down, level + 1);
outline = outline->next;
diff --git a/source/fitz/output-pcl.c b/source/fitz/output-pcl.c
index 4bc36fd8..ab95f6aa 100644
--- a/source/fitz/output-pcl.c
+++ b/source/fitz/output-pcl.c
@@ -371,12 +371,12 @@ pcl_header(fz_context *ctx, fz_output *out, fz_pcl_options *pcl, int num_copies,
if (pcl->page_count == 0)
{
if (pcl->features & HACK__IS_A_LJET4PJL)
- fz_puts(ctx, out, "\033%-12345X@PJL\r\n@PJL ENTER LANGUAGE = PCL\r\n");
- fz_puts(ctx, out, "\033E"); /* reset printer */
+ fz_write_string(ctx, out, "\033%-12345X@PJL\r\n@PJL ENTER LANGUAGE = PCL\r\n");
+ fz_write_string(ctx, out, "\033E"); /* reset printer */
/* If the printer supports it, set orientation */
if (pcl->features & PCL_HAS_ORIENTATION)
{
- fz_printf(ctx, out, "\033&l%dO", pcl->orientation);
+ fz_write_printf(ctx, out, "\033&l%dO", pcl->orientation);
}
/* If the printer supports it, set the paper size */
/* based on the actual requested size. */
@@ -387,10 +387,10 @@ pcl_header(fz_context *ctx, fz_output *out, fz_pcl_options *pcl, int num_copies,
int decipointw = (w * 720 + (xres>>1)) / xres;
int decipointh = (h * 720 + (yres>>1)) / yres;
- fz_printf(ctx, out, "\033&f%dI", decipointw);
- fz_printf(ctx, out, "\033&f%dJ", decipointh);
+ fz_write_printf(ctx, out, "\033&f%dI", decipointw);
+ fz_write_printf(ctx, out, "\033&f%dJ", decipointh);
}
- fz_printf(ctx, out, "\033&l%dA", pcl->paper_size);
+ fz_write_printf(ctx, out, "\033&l%dA", pcl->paper_size);
}
/* If printer can duplex, set duplex mode appropriately. */
if (pcl->features & PCL_HAS_DUPLEX)
@@ -400,17 +400,17 @@ pcl_header(fz_context *ctx, fz_output *out, fz_pcl_options *pcl, int num_copies,
if (pcl->duplex)
{
if (!pcl->tumble)
- fz_puts(ctx, out, "\033&l1S");
+ fz_write_string(ctx, out, "\033&l1S");
else
- fz_puts(ctx, out, "\033&l2S");
+ fz_write_string(ctx, out, "\033&l2S");
}
else
- fz_puts(ctx, out, "\033&l0S");
+ fz_write_string(ctx, out, "\033&l0S");
}
else
{
/* default to duplex for this printer */
- fz_puts(ctx, out, "\033&l1S");
+ fz_write_string(ctx, out, "\033&l1S");
}
}
}
@@ -433,39 +433,39 @@ pcl_header(fz_context *ctx, fz_output *out, fz_pcl_options *pcl, int num_copies,
{
if (pcl->page_count != 0 && (pcl->features & PCL_CAN_SET_PAPER_SIZE))
{
- fz_printf(ctx, out, "\033&l%dA", pcl->paper_size);
+ fz_write_printf(ctx, out, "\033&l%dA", pcl->paper_size);
}
- fz_puts(ctx, out, "\033&l0o0l0E");
- fz_puts(ctx, out, pcl->odd_page_init);
+ fz_write_string(ctx, out, "\033&l0o0l0E");
+ fz_write_string(ctx, out, pcl->odd_page_init);
}
else
- fz_puts(ctx, out, pcl->even_page_init);
+ fz_write_string(ctx, out, pcl->even_page_init);
}
else
{
if (pcl->features & PCL_CAN_SET_PAPER_SIZE)
{
- fz_printf(ctx, out, "\033&l%dA", pcl->paper_size);
+ fz_write_printf(ctx, out, "\033&l%dA", pcl->paper_size);
}
- fz_puts(ctx, out, "\033&l0o0l0E");
- fz_puts(ctx, out, pcl->odd_page_init);
+ fz_write_string(ctx, out, "\033&l0o0l0E");
+ fz_write_string(ctx, out, pcl->odd_page_init);
}
- fz_printf(ctx, out, "\033&l%dX", num_copies); /* # of copies */
+ fz_write_printf(ctx, out, "\033&l%dX", num_copies); /* # of copies */
/* End raster graphics, position cursor at top. */
- fz_puts(ctx, out, "\033*rB\033*p0x0Y");
+ fz_write_string(ctx, out, "\033*rB\033*p0x0Y");
/* The DeskJet and DeskJet Plus reset everything upon */
/* receiving \033*rB, so we must reinitialize graphics mode. */
if (pcl->features & PCL_END_GRAPHICS_DOES_RESET)
{
- fz_puts(ctx, out, pcl->odd_page_init); /* Assume this does the right thing */
- fz_printf(ctx, out, "\033&l%dX", num_copies); /* # of copies */
+ fz_write_string(ctx, out, pcl->odd_page_init); /* Assume this does the right thing */
+ fz_write_printf(ctx, out, "\033&l%dX", num_copies); /* # of copies */
}
/* Set resolution. */
- fz_printf(ctx, out, "\033*t%dR", xres);
+ fz_write_printf(ctx, out, "\033*t%dR", xres);
pcl->page_count++;
}
@@ -736,10 +736,10 @@ color_pcl_write_header(fz_context *ctx, fz_band_writer *writer_)
/* Raster presentation */
/* Print in orientation of the logical page */
- fz_printf(ctx, out, "\033&r0F");
+ fz_write_printf(ctx, out, "\033&r0F");
/* Set color mode */
- fz_write(ctx, out, "\033*v6W"
+ fz_write_data(ctx, out, "\033*v6W"
"\000" /* Colorspace 0 = Device RGB */
"\003" /* Pixel encoding mode: 3 = Direct by Pixel*/
"\000" /* Bits per index: 0 = no palette */
@@ -752,21 +752,21 @@ color_pcl_write_header(fz_context *ctx, fz_band_writer *writer_)
/* Raster resolution */
/* Supposed to be strictly 75, 100, 150, 200, 300, 600 */
/* FIXME: xres vs yres */
- fz_printf(ctx, out, "\033*t%dR", xres);
+ fz_write_printf(ctx, out, "\033*t%dR", xres);
/* Raster height */
- fz_printf(ctx, out, "\033*r%dT", h);
+ fz_write_printf(ctx, out, "\033*r%dT", h);
/* Raster width */
- fz_printf(ctx, out, "\033*r%dS", w);
+ fz_write_printf(ctx, out, "\033*r%dS", w);
/* start raster graphics */
/* 0 = start at default left graphics margin */
- fz_printf(ctx, out, "\033*r0A");
+ fz_write_printf(ctx, out, "\033*r0A");
/* Now output the actual bitmap */
/* Adaptive Compression */
- fz_printf(ctx, out, "\033*b5M");
+ fz_write_printf(ctx, out, "\033*b5M");
}
static void
@@ -816,8 +816,8 @@ color_pcl_write_band(fz_context *ctx, fz_band_writer *writer_, int stride, int b
if (fill + 3 >= 32767)
{
/* Can't fit into the block, so flush */
- fz_printf(ctx, out, "\033*b%dW", fill);
- fz_write(ctx, out, comp, fill);
+ fz_write_printf(ctx, out, "\033*b%dW", fill);
+ fz_write_data(ctx, out, comp, fill);
fill = 0;
}
comp[fill++] = 4; /* Empty row */
@@ -860,8 +860,8 @@ color_pcl_write_band(fz_context *ctx, fz_band_writer *writer_, int stride, int b
if (fill + len + 3 > 32767)
{
/* Can't fit this into the block, so flush and send uncompressed */
- fz_printf(ctx, out, "\033*b%dW", fill);
- fz_write(ctx, out, comp, fill);
+ fz_write_printf(ctx, out, "\033*b%dW", fill);
+ fz_write_data(ctx, out, comp, fill);
fill = 0;
len = 0;
}
@@ -879,8 +879,8 @@ color_pcl_write_band(fz_context *ctx, fz_band_writer *writer_, int stride, int b
if (fill + ds + 3 > 32767)
{
/* Can't fit a line uncompressed, so flush */
- fz_printf(ctx, out, "\033*b%dW", fill);
- fz_write(ctx, out, comp, fill);
+ fz_write_printf(ctx, out, "\033*b%dW", fill);
+ fz_write_data(ctx, out, comp, fill);
fill = 0;
}
@@ -916,12 +916,12 @@ color_pcl_write_trailer(fz_context *ctx, fz_band_writer *writer_)
if (writer->fill)
{
- fz_printf(ctx, out, "\033*b%dW", writer->fill);
- fz_write(ctx, out, writer->compbuf, writer->fill);
+ fz_write_printf(ctx, out, "\033*b%dW", writer->fill);
+ fz_write_data(ctx, out, writer->compbuf, writer->fill);
}
/* End Raster Graphics */
- fz_printf(ctx, out, "\033*rC");
+ fz_write_printf(ctx, out, "\033*rC");
}
static void
@@ -1126,7 +1126,7 @@ mono_pcl_write_header(fz_context *ctx, fz_band_writer *writer_)
if (writer->options.features & HACK__IS_A_OCE9050)
{
/* Enter HPGL/2 mode, begin plot, Initialise (start plot), Enter PCL mode */
- fz_puts(ctx, out, "\033%1BBPIN;\033%1A");
+ fz_write_string(ctx, out, "\033%1BBPIN;\033%1A");
}
pcl_header(ctx, out, &writer->options, 1, xres, yres, w, h);
@@ -1188,23 +1188,23 @@ mono_pcl_write_band(fz_context *ctx, fz_band_writer *writer_, int ss, int band_s
if (pcl->features & PCL_ANY_SPACING)
{
if (num_blank_lines > 0)
- fz_printf(ctx, out, "\033*p+%dY", num_blank_lines);
+ fz_write_printf(ctx, out, "\033*p+%dY", num_blank_lines);
/* Start raster graphics. */
- fz_puts(ctx, out, "\033*r1A");
+ fz_write_string(ctx, out, "\033*r1A");
}
else if (pcl->features & PCL_MODE_3_COMPRESSION)
{
/* Start raster graphics. */
- fz_puts(ctx, out, "\033*r1A");
+ fz_write_string(ctx, out, "\033*r1A");
for (; num_blank_lines; num_blank_lines--)
- fz_puts(ctx, out, "\033*b0W");
+ fz_write_string(ctx, out, "\033*b0W");
}
else
{
/* Start raster graphics. */
- fz_puts(ctx, out, "\033*r1A");
+ fz_write_string(ctx, out, "\033*r1A");
for (; num_blank_lines; num_blank_lines--)
- fz_puts(ctx, out, "\033*bW");
+ fz_write_string(ctx, out, "\033*bW");
}
}
@@ -1226,30 +1226,30 @@ mono_pcl_write_band(fz_context *ctx, fz_band_writer *writer_, int ss, int band_s
if (mode_3ns && compression != 2)
{
/* Switch to mode 2 */
- fz_puts(ctx, out, from3to2);
+ fz_write_string(ctx, out, from3to2);
compression = 2;
}
if (pcl->features & PCL_MODE_3_COMPRESSION)
{
/* Must clear the seed row. */
- fz_puts(ctx, out, "\033*b1Y");
+ fz_write_string(ctx, out, "\033*b1Y");
num_blank_lines--;
}
if (mode_3ns)
{
for (; num_blank_lines; num_blank_lines--)
- fz_puts(ctx, out, "\033*b0W");
+ fz_write_string(ctx, out, "\033*b0W");
}
else
{
for (; num_blank_lines; num_blank_lines--)
- fz_puts(ctx, out, "\033*bW");
+ fz_write_string(ctx, out, "\033*bW");
}
}
else if (pcl->features & PCL3_SPACING)
- fz_printf(ctx, out, "\033*p+%dY", num_blank_lines * yres);
+ fz_write_printf(ctx, out, "\033*p+%dY", num_blank_lines * yres);
else
- fz_printf(ctx, out, "\033*b%dY", num_blank_lines);
+ fz_write_printf(ctx, out, "\033*b%dY", num_blank_lines);
/* Clear the seed row (only matters for mode 3 compression). */
memset(prev, 0, line_size);
}
@@ -1269,7 +1269,7 @@ mono_pcl_write_band(fz_context *ctx, fz_band_writer *writer_, int ss, int band_s
if (count3 + penalty3 < count2 + penalty2)
{
if (compression != 3)
- fz_puts(ctx, out, from2to3);
+ fz_write_string(ctx, out, from2to3);
compression = 3;
out_data = (unsigned char *)mode3buf;
out_count = count3;
@@ -1277,7 +1277,7 @@ mono_pcl_write_band(fz_context *ctx, fz_band_writer *writer_, int ss, int band_s
else
{
if (compression != 2)
- fz_puts(ctx, out, from3to2);
+ fz_write_string(ctx, out, from3to2);
compression = 2;
out_data = (unsigned char *)mode2buf;
out_count = count2;
@@ -1295,8 +1295,8 @@ mono_pcl_write_band(fz_context *ctx, fz_band_writer *writer_, int ss, int band_s
}
/* Transfer the data */
- fz_printf(ctx, out, "\033*b%dW", out_count);
- fz_write(ctx, out, out_data, out_count);
+ fz_write_printf(ctx, out, "\033*b%dW", out_count);
+ fz_write_data(ctx, out, out_data, out_count);
}
writer->num_blank_lines = num_blank_lines;
@@ -1309,12 +1309,12 @@ mono_pcl_write_trailer(fz_context *ctx, fz_band_writer *writer_)
fz_output *out = writer->super.out;
/* end raster graphics and eject page */
- fz_puts(ctx, out, "\033*rB\f");
+ fz_write_string(ctx, out, "\033*rB\f");
if (writer->options.features & HACK__IS_A_OCE9050)
{
/* Pen up, pen select, advance full page, reset */
- fz_puts(ctx, out, "\033%1BPUSP0PG;\033E");
+ fz_write_string(ctx, out, "\033%1BPUSP0PG;\033E");
}
}
diff --git a/source/fitz/output-png.c b/source/fitz/output-png.c
index 62be417b..de5500c9 100644
--- a/source/fitz/output-png.c
+++ b/source/fitz/output-png.c
@@ -14,8 +14,8 @@ static void putchunk(fz_context *ctx, fz_output *out, char *tag, unsigned char *
{
unsigned int sum;
fz_write_int32_be(ctx, out, size);
- fz_write(ctx, out, tag, 4);
- fz_write(ctx, out, data, size);
+ fz_write_data(ctx, out, tag, 4);
+ fz_write_data(ctx, out, data, size);
sum = crc32(0, NULL, 0);
sum = crc32(sum, (unsigned char*)tag, 4);
sum = crc32(sum, data, size);
@@ -114,7 +114,7 @@ png_write_header(fz_context *ctx, fz_band_writer *writer_)
head[11] = 0; /* filter */
head[12] = 0; /* interlace */
- fz_write(ctx, out, pngsig, 8);
+ fz_write_data(ctx, out, pngsig, 8);
putchunk(ctx, out, "IHDR", head, 13);
}
diff --git a/source/fitz/output-pnm.c b/source/fitz/output-pnm.c
index 299c9e47..dbc521b7 100644
--- a/source/fitz/output-pnm.c
+++ b/source/fitz/output-pnm.c
@@ -17,11 +17,11 @@ pnm_write_header(fz_context *ctx, fz_band_writer *writer)
fz_throw(ctx, FZ_ERROR_GENERIC, "pixmap must be grayscale or rgb to write as pnm");
if (n == 1)
- fz_printf(ctx, out, "P5\n");
+ fz_write_printf(ctx, out, "P5\n");
if (n == 3)
- fz_printf(ctx, out, "P6\n");
- fz_printf(ctx, out, "%d %d\n", w, h);
- fz_printf(ctx, out, "255\n");
+ fz_write_printf(ctx, out, "P6\n");
+ fz_write_printf(ctx, out, "%d %d\n", w, h);
+ fz_write_printf(ctx, out, "255\n");
}
static void
@@ -61,7 +61,7 @@ pnm_write_band(fz_context *ctx, fz_band_writer *writer, int stride, int band_sta
{
case 1:
/* No collation required */
- fz_write(ctx, out, p, num_written);
+ fz_write_data(ctx, out, p, num_written);
p += num_written;
break;
case 2:
@@ -77,11 +77,11 @@ pnm_write_band(fz_context *ctx, fz_band_writer *writer, int stride, int band_sta
*o++ = *p;
p += 2;
}
- fz_write(ctx, out, buffer, num_written);
+ fz_write_data(ctx, out, buffer, num_written);
break;
}
case 3:
- fz_write(ctx, out, p, num_written*3);
+ fz_write_data(ctx, out, p, num_written*3);
p += num_written*3;
break;
case 4:
@@ -99,7 +99,7 @@ pnm_write_band(fz_context *ctx, fz_band_writer *writer, int stride, int band_sta
*o++ = p[2];
p += n;
}
- fz_write(ctx, out, buffer, num_written * 3);
+ fz_write_data(ctx, out, buffer, num_written * 3);
break;
}
}
@@ -164,22 +164,22 @@ pam_write_header(fz_context *ctx, fz_band_writer *writer)
int n = writer->n;
int alpha = writer->alpha;
- fz_printf(ctx, out, "P7\n");
- fz_printf(ctx, out, "WIDTH %d\n", w);
- fz_printf(ctx, out, "HEIGHT %d\n", h);
- fz_printf(ctx, out, "DEPTH %d\n", n);
- fz_printf(ctx, out, "MAXVAL 255\n");
+ fz_write_printf(ctx, out, "P7\n");
+ fz_write_printf(ctx, out, "WIDTH %d\n", w);
+ fz_write_printf(ctx, out, "HEIGHT %d\n", h);
+ fz_write_printf(ctx, out, "DEPTH %d\n", n);
+ fz_write_printf(ctx, out, "MAXVAL 255\n");
n -= alpha;
- if (n == 0 && alpha) fz_printf(ctx, out, "TUPLTYPE GRAYSCALE\n");
- else if (n == 1 && !alpha) fz_printf(ctx, out, "TUPLTYPE GRAYSCALE\n");
- else if (n == 1 && alpha) fz_printf(ctx, out, "TUPLTYPE GRAYSCALE_ALPHA\n");
- else if (n == 3 && !alpha) fz_printf(ctx, out, "TUPLTYPE RGB\n");
- else if (n == 3 && alpha) fz_printf(ctx, out, "TUPLTYPE RGB_ALPHA\n");
- else if (n == 4 && !alpha) fz_printf(ctx, out, "TUPLTYPE CMYK\n");
- else if (n == 5) fz_printf(ctx, out, "TUPLTYPE CMYK_ALPHA\n");
- fz_printf(ctx, out, "ENDHDR\n");
+ if (n == 0 && alpha) fz_write_printf(ctx, out, "TUPLTYPE GRAYSCALE\n");
+ else if (n == 1 && !alpha) fz_write_printf(ctx, out, "TUPLTYPE GRAYSCALE\n");
+ else if (n == 1 && alpha) fz_write_printf(ctx, out, "TUPLTYPE GRAYSCALE_ALPHA\n");
+ else if (n == 3 && !alpha) fz_write_printf(ctx, out, "TUPLTYPE RGB\n");
+ else if (n == 3 && alpha) fz_write_printf(ctx, out, "TUPLTYPE RGB_ALPHA\n");
+ else if (n == 4 && !alpha) fz_write_printf(ctx, out, "TUPLTYPE CMYK\n");
+ else if (n == 5) fz_write_printf(ctx, out, "TUPLTYPE CMYK_ALPHA\n");
+ fz_write_printf(ctx, out, "ENDHDR\n");
}
static void
@@ -201,7 +201,7 @@ pam_write_band(fz_context *ctx, fz_band_writer *writer, int stride, int band_sta
for (y = 0; y < end; y++)
{
- fz_write(ctx, out, sp, w * n);
+ fz_write_data(ctx, out, sp, w * n);
sp += stride;
}
}
diff --git a/source/fitz/output-ps.c b/source/fitz/output-ps.c
index 915dc222..9b6aeb06 100644
--- a/source/fitz/output-ps.c
+++ b/source/fitz/output-ps.c
@@ -15,7 +15,7 @@ typedef struct ps_band_writer_s
void
fz_write_ps_file_header(fz_context *ctx, fz_output *out)
{
- fz_printf(ctx, out,
+ fz_write_printf(ctx, out,
"%%!PS-Adobe-3.0\n"
//"%%%%BoundingBox: 0 0 612 792\n"
//"%%%%HiResBoundingBox: 0 0 612 792\n"
@@ -37,7 +37,7 @@ fz_write_ps_file_header(fz_context *ctx, fz_output *out)
void fz_write_ps_file_trailer(fz_context *ctx, fz_output *out, int pages)
{
- fz_printf(ctx, out, "%%%%Trailer\n%%%%Pages: %d\n%%%%EOF\n", pages);
+ fz_write_printf(ctx, out, "%%%%Trailer\n%%%%Pages: %d\n%%%%EOF\n", pages);
}
static void
@@ -72,27 +72,27 @@ ps_write_header(fz_context *ctx, fz_band_writer *writer_)
fz_throw(ctx, FZ_ERROR_GENERIC, "compression error %d", err);
}
- fz_printf(ctx, out, "%%%%Page: %d %d\n", pagenum, pagenum);
- fz_printf(ctx, out, "%%%%PageBoundingBox: 0 0 %d %d\n", w_points, h_points);
- fz_printf(ctx, out, "%%%%BeginPageSetup\n");
- fz_printf(ctx, out, "<</PageSize [%d %d]>> setpagedevice\n", w_points, h_points);
- fz_printf(ctx, out, "%%%%EndPageSetup\n\n");
- fz_printf(ctx, out, "/DataFile currentfile /FlateDecode filter def\n\n");
+ fz_write_printf(ctx, out, "%%%%Page: %d %d\n", pagenum, pagenum);
+ fz_write_printf(ctx, out, "%%%%PageBoundingBox: 0 0 %d %d\n", w_points, h_points);
+ fz_write_printf(ctx, out, "%%%%BeginPageSetup\n");
+ fz_write_printf(ctx, out, "<</PageSize [%d %d]>> setpagedevice\n", w_points, h_points);
+ fz_write_printf(ctx, out, "%%%%EndPageSetup\n\n");
+ fz_write_printf(ctx, out, "/DataFile currentfile /FlateDecode filter def\n\n");
switch(n)
{
case 1:
- fz_printf(ctx, out, "/DeviceGray setcolorspace\n");
+ fz_write_printf(ctx, out, "/DeviceGray setcolorspace\n");
break;
case 3:
- fz_printf(ctx, out, "/DeviceRGB setcolorspace\n");
+ fz_write_printf(ctx, out, "/DeviceRGB setcolorspace\n");
break;
case 4:
- fz_printf(ctx, out, "/DeviceCMYK setcolorspace\n");
+ fz_write_printf(ctx, out, "/DeviceCMYK setcolorspace\n");
break;
default:
fz_throw(ctx, FZ_ERROR_GENERIC, "Unexpected colorspace for ps output");
}
- fz_printf(ctx, out,
+ fz_write_printf(ctx, out,
"<<\n"
"/ImageType 1\n"
"/Width %d\n"
@@ -125,7 +125,7 @@ ps_write_trailer(fz_context *ctx, fz_band_writer *writer_)
fz_throw(ctx, FZ_ERROR_GENERIC, "compression error %d", err);
fz_write(ctx, out, writer->output, writer->output_size - writer->stream.avail_out);
- fz_printf(ctx, out, "\nshowpage\n%%%%PageTrailer\n%%%%EndPageTrailer\n\n");
+ fz_write_printf(ctx, out, "\nshowpage\n%%%%PageTrailer\n%%%%EndPageTrailer\n\n");
}
static void
@@ -231,7 +231,7 @@ ps_write_band(fz_context *ctx, fz_band_writer *writer_, int stride, int band_sta
if (err != Z_OK)
fz_throw(ctx, FZ_ERROR_GENERIC, "compression error %d", err);
- fz_write(ctx, out, writer->output, writer->output_size - writer->stream.avail_out);
+ fz_write_data(ctx, out, writer->output, writer->output_size - writer->stream.avail_out);
}
fz_band_writer *fz_new_ps_band_writer(fz_context *ctx, fz_output *out)
diff --git a/source/fitz/output-pwg.c b/source/fitz/output-pwg.c
index ea6e7add..9d31f2a5 100644
--- a/source/fitz/output-pwg.c
+++ b/source/fitz/output-pwg.c
@@ -11,7 +11,7 @@ fz_write_pwg_file_header(fz_context *ctx, fz_output *out)
static const unsigned char pwgsig[4] = { 'R', 'a', 'S', '2' };
/* Sync word */
- fz_write(ctx, out, pwgsig, 4);
+ fz_write_data(ctx, out, pwgsig, 4);
}
static void
@@ -22,10 +22,10 @@ pwg_page_header(fz_context *ctx, fz_output *out, const fz_pwg_options *pwg,
int i;
/* Page Header: */
- fz_write(ctx, out, pwg ? pwg->media_class : zero, 64);
- fz_write(ctx, out, pwg ? pwg->media_color : zero, 64);
- fz_write(ctx, out, pwg ? pwg->media_type : zero, 64);
- fz_write(ctx, out, pwg ? pwg->output_type : zero, 64);
+ fz_write_data(ctx, out, pwg ? pwg->media_class : zero, 64);
+ fz_write_data(ctx, out, pwg ? pwg->media_color : zero, 64);
+ fz_write_data(ctx, out, pwg ? pwg->media_type : zero, 64);
+ fz_write_data(ctx, out, pwg ? pwg->output_type : zero, 64);
fz_write_int32_be(ctx, out, pwg ? pwg->advance_distance : 0);
fz_write_int32_be(ctx, out, pwg ? pwg->advance_media : 0);
fz_write_int32_be(ctx, out, pwg ? pwg->collate : 0);
@@ -36,14 +36,14 @@ pwg_page_header(fz_context *ctx, fz_output *out, const fz_pwg_options *pwg,
/* CUPS format says that 284->300 are supposed to be the bbox of the
* page in points. PWG says 'Reserved'. */
for (i=284; i < 300; i += 4)
- fz_write(ctx, out, zero, 4);
+ fz_write_data(ctx, out, zero, 4);
fz_write_int32_be(ctx, out, pwg ? pwg->insert_sheet : 0);
fz_write_int32_be(ctx, out, pwg ? pwg->jog : 0);
fz_write_int32_be(ctx, out, pwg ? pwg->leading_edge : 0);
/* CUPS format says that 312->320 are supposed to be the margins of
* the lower left hand edge of page in points. PWG says 'Reserved'. */
for (i=312; i < 320; i += 4)
- fz_write(ctx, out, zero, 4);
+ fz_write_data(ctx, out, zero, 4);
fz_write_int32_be(ctx, out, pwg ? pwg->manual_feed : 0);
fz_write_int32_be(ctx, out, pwg ? pwg->media_position : 0);
fz_write_int32_be(ctx, out, pwg ? pwg->media_weight : 0);
@@ -78,7 +78,7 @@ pwg_page_header(fz_context *ctx, fz_output *out, const fz_pwg_options *pwg,
fz_write_int32_be(ctx, out, pwg ? pwg->row_step : 0);
fz_write_int32_be(ctx, out, bpp <= 8 ? 1 : (bpp>>8)); /* Num Colors */
for (i=424; i < 452; i += 4)
- fz_write(ctx, out, zero, 4);
+ fz_write_data(ctx, out, zero, 4);
fz_write_int32_be(ctx, out, 1); /* TotalPageCount */
fz_write_int32_be(ctx, out, 1); /* CrossFeedTransform */
fz_write_int32_be(ctx, out, 1); /* FeedTransform */
@@ -87,9 +87,9 @@ pwg_page_header(fz_context *ctx, fz_output *out, const fz_pwg_options *pwg,
fz_write_int32_be(ctx, out, w); /* ImageBoxRight */
fz_write_int32_be(ctx, out, h); /* ImageBoxBottom */
for (i=480; i < 1668; i += 4)
- fz_write(ctx, out, zero, 4);
- fz_write(ctx, out, pwg ? pwg->rendering_intent : zero, 64);
- fz_write(ctx, out, pwg ? pwg->page_size_name : zero, 64);
+ fz_write_data(ctx, out, zero, 4);
+ fz_write_data(ctx, out, pwg ? pwg->rendering_intent : zero, 64);
+ fz_write_data(ctx, out, pwg ? pwg->page_size_name : zero, 64);
}
void
@@ -235,14 +235,14 @@ pwg_write_mono_band(fz_context *ctx, fz_band_writer *writer_, int stride, int ba
break;
}
fz_write_byte(ctx, out, xrep-1);
- fz_write(ctx, out, sp, 1);
+ fz_write_data(ctx, out, sp, 1);
sp += xrep;
x += xrep;
}
else
{
fz_write_byte(ctx, out, 257-d);
- fz_write(ctx, out, sp, d);
+ fz_write_data(ctx, out, sp, d);
sp += d;
x += d;
}
@@ -338,7 +338,7 @@ pwg_write_band(fz_context *ctx, fz_band_writer *writer_, int stride, int band_st
break;
}
fz_write_byte(ctx, out, xrep-1);
- fz_write(ctx, out, sp, n);
+ fz_write_data(ctx, out, sp, n);
sp += n*xrep;
x += xrep;
}
@@ -348,7 +348,7 @@ pwg_write_band(fz_context *ctx, fz_band_writer *writer_, int stride, int band_st
x += d;
while (d > 0)
{
- fz_write(ctx, out, sp, n);
+ fz_write_data(ctx, out, sp, n);
sp += n;
d--;
}
diff --git a/source/fitz/output-tga.c b/source/fitz/output-tga.c
index 0e3cf3c5..e6e9a4a5 100644
--- a/source/fitz/output-tga.c
+++ b/source/fitz/output-tga.c
@@ -15,35 +15,35 @@ static inline void tga_put_pixel(fz_context *ctx, fz_output *out, const unsigned
{
case 4: /* RGBA or BGRA */
if (!is_bgr) {
- fz_putc(ctx, out, data[2]);
- fz_putc(ctx, out, data[1]);
- fz_putc(ctx, out, data[0]);
+ fz_write_byte(ctx, out, data[2]);
+ fz_write_byte(ctx, out, data[1]);
+ fz_write_byte(ctx, out, data[0]);
} else {
- fz_putc(ctx, out, data[0]);
- fz_putc(ctx, out, data[1]);
- fz_putc(ctx, out, data[2]);
+ fz_write_byte(ctx, out, data[0]);
+ fz_write_byte(ctx, out, data[1]);
+ fz_write_byte(ctx, out, data[2]);
}
- fz_putc(ctx, out, data[3]);
+ fz_write_byte(ctx, out, data[3]);
break;
case 3: /* RGB or BGR */
if (!is_bgr) {
- fz_putc(ctx, out, data[2]);
- fz_putc(ctx, out, data[1]);
- fz_putc(ctx, out, data[0]);
+ fz_write_byte(ctx, out, data[2]);
+ fz_write_byte(ctx, out, data[1]);
+ fz_write_byte(ctx, out, data[0]);
} else {
- fz_putc(ctx, out, data[0]);
- fz_putc(ctx, out, data[1]);
- fz_putc(ctx, out, data[2]);
+ fz_write_byte(ctx, out, data[0]);
+ fz_write_byte(ctx, out, data[1]);
+ fz_write_byte(ctx, out, data[2]);
}
break;
case 2: /* GA */
- fz_putc(ctx, out, data[0]);
- fz_putc(ctx, out, data[0]);
- fz_putc(ctx, out, data[0]);
- fz_putc(ctx, out, data[1]);
+ fz_write_byte(ctx, out, data[0]);
+ fz_write_byte(ctx, out, data[0]);
+ fz_write_byte(ctx, out, data[0]);
+ fz_write_byte(ctx, out, data[1]);
break;
case 1: /* G */
- fz_putc(ctx, out, data[0]);
+ fz_write_byte(ctx, out, data[0]);
break;
}
}
@@ -97,7 +97,7 @@ tga_write_header(fz_context *ctx, fz_band_writer *writer_)
head[16] = d * 8; /* BPP */
head[17] = alpha && n > 1 ? 8 : 0; /* Alpha bpp */
- fz_write(ctx, out, head, sizeof(head));
+ fz_write_data(ctx, out, head, sizeof(head));
}
static void
@@ -121,7 +121,7 @@ tga_write_band(fz_context *ctx, fz_band_writer *writer_, int stride, int band_st
for (; i + j < w && j < 128 && !memcmp(line + i * n, line + (i + j) * n, d); j++);
if (j > 1)
{
- fz_putc(ctx, out, j - 1 + 128);
+ fz_write_byte(ctx, out, j - 1 + 128);
tga_put_pixel(ctx, out, line + i * n, n, is_bgr);
}
else
@@ -129,7 +129,7 @@ tga_write_band(fz_context *ctx, fz_band_writer *writer_, int stride, int band_st
for (; i + j < w && j <= 128 && memcmp(line + (i + j - 1) * n, line + (i + j) * n, d) != 0; j++);
if (i + j < w || j > 128)
j--;
- fz_putc(ctx, out, j - 1);
+ fz_write_byte(ctx, out, j - 1);
for (; j > 0; j--, i++)
tga_put_pixel(ctx, out, line + i * n, n, is_bgr);
}
@@ -142,7 +142,7 @@ tga_write_trailer(fz_context *ctx, fz_band_writer *writer)
{
fz_output *out = writer->out;
- fz_write(ctx, out, "\0\0\0\0\0\0\0\0TRUEVISION-XFILE.\0", 26);
+ fz_write_data(ctx, out, "\0\0\0\0\0\0\0\0TRUEVISION-XFILE.\0", 26);
}
fz_band_writer *fz_new_tga_band_writer(fz_context *ctx, fz_output *out, int is_bgr)
diff --git a/source/fitz/output.c b/source/fitz/output.c
index 7ca6fa4e..bd4dba66 100644
--- a/source/fitz/output.c
+++ b/source/fitz/output.c
@@ -206,7 +206,7 @@ static void
buffer_write(fz_context *ctx, void *opaque, const void *data, size_t len)
{
fz_buffer *buffer = opaque;
- fz_write_buffer(ctx, buffer, data, len);
+ fz_append_data(ctx, buffer, data, len);
}
static void
@@ -267,7 +267,7 @@ fz_tell_output(fz_context *ctx, fz_output *out)
}
void
-fz_vprintf(fz_context *ctx, fz_output *out, const char *fmt, va_list old_args)
+fz_write_vprintf(fz_context *ctx, fz_output *out, const char *fmt, va_list old_args)
{
char buffer[256], *p = buffer;
size_t len;
@@ -299,12 +299,12 @@ fz_vprintf(fz_context *ctx, fz_output *out, const char *fmt, va_list old_args)
}
void
-fz_printf(fz_context *ctx, fz_output *out, const char *fmt, ...)
+fz_write_printf(fz_context *ctx, fz_output *out, const char *fmt, ...)
{
va_list args;
if (!out) return;
va_start(args, fmt);
- fz_vprintf(ctx, out, fmt, args);
+ fz_write_vprintf(ctx, out, fmt, args);
va_end(args);
}
@@ -313,7 +313,7 @@ fz_save_buffer(fz_context *ctx, fz_buffer *buf, const char *filename)
{
fz_output *out = fz_new_output_with_path(ctx, filename, 0);
fz_try(ctx)
- fz_write(ctx, out, buf->data, buf->len);
+ fz_write_data(ctx, out, buf->data, buf->len);
fz_always(ctx)
fz_drop_output(ctx, out);
fz_catch(ctx)
diff --git a/source/fitz/path.c b/source/fitz/path.c
index 8fef2a32..120d2e9e 100644
--- a/source/fitz/path.c
+++ b/source/fitz/path.c
@@ -1354,46 +1354,46 @@ fz_print_path(fz_context *ctx, fz_output *out, fz_path *path, int indent)
uint8_t cmd = path->cmds[i++];
for (n = 0; n < indent; n++)
- fz_putc(ctx, out, ' ');
+ fz_write_byte(ctx, out, ' ');
switch (cmd)
{
case FZ_MOVETO:
case FZ_MOVETOCLOSE:
x = path->coords[k++];
y = path->coords[k++];
- fz_printf(ctx, out, "%g %g m%s\n", x, y, cmd == FZ_MOVETOCLOSE ? " z" : "");
+ fz_write_printf(ctx, out, "%g %g m%s\n", x, y, cmd == FZ_MOVETOCLOSE ? " z" : "");
break;
case FZ_LINETO:
case FZ_LINETOCLOSE:
x = path->coords[k++];
y = path->coords[k++];
- fz_printf(ctx, out, "%g %g l%s\n", x, y, cmd == FZ_LINETOCLOSE ? " z" : "");
+ fz_write_printf(ctx, out, "%g %g l%s\n", x, y, cmd == FZ_LINETOCLOSE ? " z" : "");
break;
case FZ_DEGENLINETO:
case FZ_DEGENLINETOCLOSE:
- fz_printf(ctx, out, "d%s\n", cmd == FZ_DEGENLINETOCLOSE ? " z" : "");
+ fz_write_printf(ctx, out, "d%s\n", cmd == FZ_DEGENLINETOCLOSE ? " z" : "");
break;
case FZ_HORIZTO:
case FZ_HORIZTOCLOSE:
x = path->coords[k++];
- fz_printf(ctx, out, "%g h%s\n", x, cmd == FZ_HORIZTOCLOSE ? " z" : "");
+ fz_write_printf(ctx, out, "%g h%s\n", x, cmd == FZ_HORIZTOCLOSE ? " z" : "");
break;
case FZ_VERTTOCLOSE:
case FZ_VERTTO:
y = path->coords[k++];
- fz_printf(ctx, out, "%g i%s\n", y, cmd == FZ_VERTTOCLOSE ? " z" : "");
+ fz_write_printf(ctx, out, "%g i%s\n", y, cmd == FZ_VERTTOCLOSE ? " z" : "");
break;
case FZ_CURVETOCLOSE:
case FZ_CURVETO:
x = path->coords[k++];
y = path->coords[k++];
- fz_printf(ctx, out, "%g %g ", x, y);
+ fz_write_printf(ctx, out, "%g %g ", x, y);
x = path->coords[k++];
y = path->coords[k++];
- fz_printf(ctx, out, "%g %g ", x, y);
+ fz_write_printf(ctx, out, "%g %g ", x, y);
x = path->coords[k++];
y = path->coords[k++];
- fz_printf(ctx, out, "%g %g c%s\n", x, y, cmd == FZ_CURVETOCLOSE ? " z" : "");
+ fz_write_printf(ctx, out, "%g %g c%s\n", x, y, cmd == FZ_CURVETOCLOSE ? " z" : "");
break;
case FZ_CURVETOVCLOSE:
case FZ_CURVETOV:
@@ -1401,18 +1401,18 @@ fz_print_path(fz_context *ctx, fz_output *out, fz_path *path, int indent)
case FZ_CURVETOY:
x = path->coords[k++];
y = path->coords[k++];
- fz_printf(ctx, out, "%g %g ", x, y);
+ fz_write_printf(ctx, out, "%g %g ", x, y);
x = path->coords[k++];
y = path->coords[k++];
- fz_printf(ctx, out, "%g %g %c%s\n", x, y, (cmd == FZ_CURVETOVCLOSE || cmd == FZ_CURVETOV ? 'v' : 'y'), (cmd == FZ_CURVETOVCLOSE || cmd == FZ_CURVETOYCLOSE) ? " z" : "");
+ fz_write_printf(ctx, out, "%g %g %c%s\n", x, y, (cmd == FZ_CURVETOVCLOSE || cmd == FZ_CURVETOV ? 'v' : 'y'), (cmd == FZ_CURVETOVCLOSE || cmd == FZ_CURVETOYCLOSE) ? " z" : "");
break;
case FZ_RECTTO:
x = path->coords[k++];
y = path->coords[k++];
- fz_printf(ctx, out, "%g %g ", x, y);
+ fz_write_printf(ctx, out, "%g %g ", x, y);
x = path->coords[k++];
y = path->coords[k++];
- fz_printf(ctx, out, "%g %g r\n", x, y);
+ fz_write_printf(ctx, out, "%g %g r\n", x, y);
break;
}
}
diff --git a/source/fitz/shade.c b/source/fitz/shade.c
index 274d40f3..4e5b9a19 100644
--- a/source/fitz/shade.c
+++ b/source/fitz/shade.c
@@ -1090,39 +1090,39 @@ fz_print_shade(fz_context *ctx, fz_output *out, fz_shade *shade)
{
int i;
- fz_printf(ctx, out, "shading {\n");
+ fz_write_printf(ctx, out, "shading {\n");
switch (shade->type)
{
- case FZ_FUNCTION_BASED: fz_printf(ctx, out, "\ttype function_based\n"); break;
- case FZ_LINEAR: fz_printf(ctx, out, "\ttype linear\n"); break;
- case FZ_RADIAL: fz_printf(ctx, out, "\ttype radial\n"); break;
- default: /* MESH */ fz_printf(ctx, out, "\ttype mesh\n"); break;
+ case FZ_FUNCTION_BASED: fz_write_printf(ctx, out, "\ttype function_based\n"); break;
+ case FZ_LINEAR: fz_write_printf(ctx, out, "\ttype linear\n"); break;
+ case FZ_RADIAL: fz_write_printf(ctx, out, "\ttype radial\n"); break;
+ default: /* MESH */ fz_write_printf(ctx, out, "\ttype mesh\n"); break;
}
- fz_printf(ctx, out, "\tbbox [%g %g %g %g]\n",
+ fz_write_printf(ctx, out, "\tbbox [%g %g %g %g]\n",
shade->bbox.x0, shade->bbox.y0,
shade->bbox.x1, shade->bbox.y1);
- fz_printf(ctx, out, "\tcolorspace %s\n", fz_colorspace_name(ctx, shade->colorspace));
+ fz_write_printf(ctx, out, "\tcolorspace %s\n", fz_colorspace_name(ctx, shade->colorspace));
- fz_printf(ctx, out, "\tmatrix [%g %g %g %g %g %g]\n",
+ fz_write_printf(ctx, out, "\tmatrix [%g %g %g %g %g %g]\n",
shade->matrix.a, shade->matrix.b, shade->matrix.c,
shade->matrix.d, shade->matrix.e, shade->matrix.f);
if (shade->use_background)
{
int n = fz_colorspace_n(ctx, shade->colorspace);
- fz_printf(ctx, out, "\tbackground [");
+ fz_write_printf(ctx, out, "\tbackground [");
for (i = 0; i < n; i++)
- fz_printf(ctx, out, "%s%g", i == 0 ? "" : " ", shade->background[i]);
- fz_printf(ctx, out, "]\n");
+ fz_write_printf(ctx, out, "%s%g", i == 0 ? "" : " ", shade->background[i]);
+ fz_write_printf(ctx, out, "]\n");
}
if (shade->use_function)
{
- fz_printf(ctx, out, "\tfunction\n");
+ fz_write_printf(ctx, out, "\tfunction\n");
}
- fz_printf(ctx, out, "}\n");
+ fz_write_printf(ctx, out, "}\n");
}
diff --git a/source/fitz/stext-output.c b/source/fitz/stext-output.c
index 09b18db8..49ef2ea5 100644
--- a/source/fitz/stext-output.c
+++ b/source/fitz/stext-output.c
@@ -12,11 +12,11 @@ static void
fz_print_style_begin(fz_context *ctx, fz_output *out, fz_stext_style *style)
{
int script = style->script;
- fz_printf(ctx, out, "<span class=\"s%d\">", style->id);
+ fz_write_printf(ctx, out, "<span class=\"s%d\">", style->id);
while (script-- > 0)
- fz_printf(ctx, out, "<sup>");
+ fz_write_printf(ctx, out, "<sup>");
while (++script < 0)
- fz_printf(ctx, out, "<sub>");
+ fz_write_printf(ctx, out, "<sub>");
}
static void
@@ -24,10 +24,10 @@ fz_print_style_end(fz_context *ctx, fz_output *out, fz_stext_style *style)
{
int script = style->script;
while (script-- > 0)
- fz_printf(ctx, out, "</sup>");
+ fz_write_printf(ctx, out, "</sup>");
while (++script < 0)
- fz_printf(ctx, out, "</sub>");
- fz_printf(ctx, out, "</span>");
+ fz_write_printf(ctx, out, "</sub>");
+ fz_write_printf(ctx, out, "</span>");
}
static void
@@ -36,13 +36,13 @@ fz_print_style(fz_context *ctx, fz_output *out, fz_stext_style *style)
const char *name = fz_font_name(ctx, style->font);
const char *s = strchr(name, '+');
s = s ? s + 1 : name;
- fz_printf(ctx, out, "span.s%d{font-family:\"%s\";font-size:%gpt;",
+ fz_write_printf(ctx, out, "span.s%d{font-family:\"%s\";font-size:%gpt;",
style->id, s, style->size);
if (fz_font_is_italic(ctx, style->font))
- fz_printf(ctx, out, "font-style:italic;");
+ fz_write_printf(ctx, out, "font-style:italic;");
if (fz_font_is_bold(ctx, style->font))
- fz_printf(ctx, out, "font-weight:bold;");
- fz_printf(ctx, out, "}\n");
+ fz_write_printf(ctx, out, "font-weight:bold;");
+ fz_write_printf(ctx, out, "}\n");
}
void
@@ -66,8 +66,8 @@ send_data_base64_stext(fz_context *ctx, fz_output *out, fz_buffer *buffer)
int d = buffer->data[3*i+1];
int e = buffer->data[3*i+2];
if ((i & 15) == 0)
- fz_printf(ctx, out, "\n");
- fz_printf(ctx, out, "%c%c%c%c", set[c>>2], set[((c&3)<<4)|(d>>4)], set[((d&15)<<2)|(e>>6)], set[e & 63]);
+ fz_write_printf(ctx, out, "\n");
+ fz_write_printf(ctx, out, "%c%c%c%c", set[c>>2], set[((c&3)<<4)|(d>>4)], set[((d&15)<<2)|(e>>6)], set[e & 63]);
}
i *= 3;
switch (buffer->len-i)
@@ -76,13 +76,13 @@ send_data_base64_stext(fz_context *ctx, fz_output *out, fz_buffer *buffer)
{
int c = buffer->data[i];
int d = buffer->data[i+1];
- fz_printf(ctx, out, "%c%c%c=", set[c>>2], set[((c&3)<<4)|(d>>4)], set[((d&15)<<2)]);
+ fz_write_printf(ctx, out, "%c%c%c=", set[c>>2], set[((c&3)<<4)|(d>>4)], set[((d&15)<<2)]);
break;
}
case 1:
{
int c = buffer->data[i];
- fz_printf(ctx, out, "%c%c==", set[c>>2], set[(c&3)<<4]);
+ fz_write_printf(ctx, out, "%c%c==", set[c>>2], set[(c&3)<<4]);
break;
}
default:
@@ -100,7 +100,7 @@ fz_print_stext_page_html(fz_context *ctx, fz_output *out, fz_stext_page *page)
fz_stext_span *span;
void *last_region = NULL;
- fz_printf(ctx, out, "<div class=\"page\">\n");
+ fz_write_printf(ctx, out, "<div class=\"page\">\n");
for (block_n = 0; block_n < page->len; block_n++)
{
@@ -109,7 +109,7 @@ fz_print_stext_page_html(fz_context *ctx, fz_output *out, fz_stext_page *page)
case FZ_PAGE_BLOCK_TEXT:
{
fz_stext_block * block = page->blocks[block_n].u.text;
- fz_printf(ctx, out, "<div class=\"block\"><p>\n");
+ fz_write_printf(ctx, out, "<div class=\"block\"><p>\n");
for (line_n = 0; line_n < block->len; line_n++)
{
int lastcol=-1;
@@ -119,16 +119,16 @@ fz_print_stext_page_html(fz_context *ctx, fz_output *out, fz_stext_page *page)
if (line->region != last_region)
{
if (last_region)
- fz_printf(ctx, out, "</div>");
- fz_printf(ctx, out, "<div class=\"metaline\">");
+ fz_write_printf(ctx, out, "</div>");
+ fz_write_printf(ctx, out, "<div class=\"metaline\">");
last_region = line->region;
}
- fz_printf(ctx, out, "<div class=\"line\"");
+ fz_write_printf(ctx, out, "<div class=\"line\"");
#ifdef DEBUG_INTERNALS
if (line->region)
- fz_printf(ctx, out, " region=\"%x\"", line->region);
+ fz_write_printf(ctx, out, " region=\"%x\"", line->region);
#endif
- fz_printf(ctx, out, ">");
+ fz_write_printf(ctx, out, ">");
for (span = line->first_span; span; span = span->next)
{
float size = fz_matrix_expansion(&span->transform);
@@ -138,17 +138,17 @@ fz_print_stext_page_html(fz_context *ctx, fz_output *out, fz_stext_page *page)
{
if (lastcol >= 0)
{
- fz_printf(ctx, out, "</div>");
+ fz_write_printf(ctx, out, "</div>");
}
/* If we skipped any columns then output some spacer spans */
while (lastcol < span->column-1)
{
- fz_printf(ctx, out, "<div class=\"cell\"></div>");
+ fz_write_printf(ctx, out, "<div class=\"cell\"></div>");
lastcol++;
}
lastcol++;
/* Now output the span to contain this entire column */
- fz_printf(ctx, out, "<div class=\"cell\" style=\"");
+ fz_write_printf(ctx, out, "<div class=\"cell\" style=\"");
{
fz_stext_span *sn;
for (sn = span->next; sn; sn = sn->next)
@@ -156,26 +156,26 @@ fz_print_stext_page_html(fz_context *ctx, fz_output *out, fz_stext_page *page)
if (sn->column != lastcol)
break;
}
- fz_printf(ctx, out, "width:%g%%;align:%s", span->column_width, (span->align == 0 ? "left" : (span->align == 1 ? "center" : "right")));
+ fz_write_printf(ctx, out, "width:%g%%;align:%s", span->column_width, (span->align == 0 ? "left" : (span->align == 1 ? "center" : "right")));
}
if (span->indent > 1)
- fz_printf(ctx, out, ";padding-left:1em;text-indent:-1em");
+ fz_write_printf(ctx, out, ";padding-left:1em;text-indent:-1em");
if (span->indent < -1)
- fz_printf(ctx, out, ";text-indent:1em");
- fz_printf(ctx, out, "\">");
+ fz_write_printf(ctx, out, ";text-indent:1em");
+ fz_write_printf(ctx, out, "\">");
}
#ifdef DEBUG_INTERNALS
- fz_printf(ctx, out, "<span class=\"internal_span\"");
+ fz_write_printf(ctx, out, "<span class=\"internal_span\"");
if (span->column)
- fz_printf(ctx, out, " col=\"%x\"", span->column);
- fz_printf(ctx, out, ">");
+ fz_write_printf(ctx, out, " col=\"%x\"", span->column);
+ fz_write_printf(ctx, out, ">");
#endif
if (span->spacing >= 1)
- fz_printf(ctx, out, " ");
+ fz_write_printf(ctx, out, " ");
if (base_offset > SUBSCRIPT_OFFSET)
- fz_printf(ctx, out, "<sub>");
+ fz_write_printf(ctx, out, "<sub>");
else if (base_offset < SUPERSCRIPT_OFFSET)
- fz_printf(ctx, out, "<sup>");
+ fz_write_printf(ctx, out, "<sup>");
for (ch_n = 0; ch_n < span->len; ch_n++)
{
fz_stext_char *ch = &span->text[ch_n];
@@ -188,15 +188,15 @@ fz_print_stext_page_html(fz_context *ctx, fz_output *out, fz_stext_page *page)
}
if (ch->c == '<')
- fz_printf(ctx, out, "&lt;");
+ fz_write_printf(ctx, out, "&lt;");
else if (ch->c == '>')
- fz_printf(ctx, out, "&gt;");
+ fz_write_printf(ctx, out, "&gt;");
else if (ch->c == '&')
- fz_printf(ctx, out, "&amp;");
+ fz_write_printf(ctx, out, "&amp;");
else if (ch->c >= 32 && ch->c <= 127)
- fz_printf(ctx, out, "%c", ch->c);
+ fz_write_printf(ctx, out, "%c", ch->c);
else
- fz_printf(ctx, out, "&#x%x;", ch->c);
+ fz_write_printf(ctx, out, "&#x%x;", ch->c);
}
if (style)
{
@@ -204,56 +204,56 @@ fz_print_stext_page_html(fz_context *ctx, fz_output *out, fz_stext_page *page)
style = NULL;
}
if (base_offset > SUBSCRIPT_OFFSET)
- fz_printf(ctx, out, "</sub>");
+ fz_write_printf(ctx, out, "</sub>");
else if (base_offset < SUPERSCRIPT_OFFSET)
- fz_printf(ctx, out, "</sup>");
+ fz_write_printf(ctx, out, "</sup>");
#ifdef DEBUG_INTERNALS
- fz_printf(ctx, out, "</span>");
+ fz_write_printf(ctx, out, "</span>");
#endif
}
/* Close our floating span */
- fz_printf(ctx, out, "</div>");
+ fz_write_printf(ctx, out, "</div>");
/* Close the line */
- fz_printf(ctx, out, "</div>");
- fz_printf(ctx, out, "\n");
+ fz_write_printf(ctx, out, "</div>");
+ fz_write_printf(ctx, out, "\n");
}
/* Close the metaline */
- fz_printf(ctx, out, "</div>");
+ fz_write_printf(ctx, out, "</div>");
last_region = NULL;
- fz_printf(ctx, out, "</p></div>\n");
+ fz_write_printf(ctx, out, "</p></div>\n");
break;
}
case FZ_PAGE_BLOCK_IMAGE:
{
fz_image_block *image = page->blocks[block_n].u.image;
fz_compressed_buffer *buffer = fz_compressed_image_buffer(ctx, image->image);
- fz_printf(ctx, out, "<img width=%d height=%d src=\"data:", image->image->w, image->image->h);
+ fz_write_printf(ctx, out, "<img width=%d height=%d src=\"data:", image->image->w, image->image->h);
switch (buffer == NULL ? FZ_IMAGE_JPX : buffer->params.type)
{
case FZ_IMAGE_JPEG:
- fz_printf(ctx, out, "image/jpeg;base64,");
+ fz_write_printf(ctx, out, "image/jpeg;base64,");
send_data_base64_stext(ctx, out, buffer->buffer);
break;
case FZ_IMAGE_PNG:
- fz_printf(ctx, out, "image/png;base64,");
+ fz_write_printf(ctx, out, "image/png;base64,");
send_data_base64_stext(ctx, out, buffer->buffer);
break;
default:
{
fz_buffer *buf = fz_new_buffer_from_image_as_png(ctx, image->image);
- fz_printf(ctx, out, "image/png;base64,");
+ fz_write_printf(ctx, out, "image/png;base64,");
send_data_base64_stext(ctx, out, buf);
fz_drop_buffer(ctx, buf);
break;
}
}
- fz_printf(ctx, out, "\">\n");
+ fz_write_printf(ctx, out, "\">\n");
break;
}
}
}
- fz_printf(ctx, out, "</div>\n");
+ fz_write_printf(ctx, out, "</div>\n");
}
void
@@ -261,7 +261,7 @@ fz_print_stext_page_xml(fz_context *ctx, fz_output *out, fz_stext_page *page)
{
int block_n;
- fz_printf(ctx, out, "<page width=\"%g\" height=\"%g\">\n",
+ fz_write_printf(ctx, out, "<page width=\"%g\" height=\"%g\">\n",
page->mediabox.x1 - page->mediabox.x0,
page->mediabox.y1 - page->mediabox.y0);
@@ -275,12 +275,12 @@ fz_print_stext_page_xml(fz_context *ctx, fz_output *out, fz_stext_page *page)
fz_stext_line *line;
const char *s;
- fz_printf(ctx, out, "<block bbox=\"%g %g %g %g\">\n",
+ fz_write_printf(ctx, out, "<block bbox=\"%g %g %g %g\">\n",
block->bbox.x0, block->bbox.y0, block->bbox.x1, block->bbox.y1);
for (line = block->lines; line < block->lines + block->len; line++)
{
fz_stext_span *span;
- fz_printf(ctx, out, "<line bbox=\"%g %g %g %g\">\n",
+ fz_write_printf(ctx, out, "<line bbox=\"%g %g %g %g\">\n",
line->bbox.x0, line->bbox.y0, line->bbox.x1, line->bbox.y1);
for (span = line->first_span; span; span = span->next)
{
@@ -294,44 +294,44 @@ fz_print_stext_page_xml(fz_context *ctx, fz_output *out, fz_stext_page *page)
{
if (style)
{
- fz_printf(ctx, out, "</span>\n");
+ fz_write_printf(ctx, out, "</span>\n");
}
style = ch->style;
name = fz_font_name(ctx, style->font);
s = strchr(name, '+');
s = s ? s + 1 : name;
- fz_printf(ctx, out, "<span bbox=\"%g %g %g %g\" font=\"%s\" size=\"%g\">\n",
+ fz_write_printf(ctx, out, "<span bbox=\"%g %g %g %g\" font=\"%s\" size=\"%g\">\n",
span->bbox.x0, span->bbox.y0, span->bbox.x1, span->bbox.y1,
s, style->size);
}
{
fz_rect rect;
fz_stext_char_bbox(ctx, &rect, span, char_num);
- fz_printf(ctx, out, "<char bbox=\"%g %g %g %g\" x=\"%g\" y=\"%g\" c=\"",
+ fz_write_printf(ctx, out, "<char bbox=\"%g %g %g %g\" x=\"%g\" y=\"%g\" c=\"",
rect.x0, rect.y0, rect.x1, rect.y1, ch->p.x, ch->p.y);
}
switch (ch->c)
{
- case '<': fz_printf(ctx, out, "&lt;"); break;
- case '>': fz_printf(ctx, out, "&gt;"); break;
- case '&': fz_printf(ctx, out, "&amp;"); break;
- case '"': fz_printf(ctx, out, "&quot;"); break;
- case '\'': fz_printf(ctx, out, "&apos;"); break;
+ case '<': fz_write_printf(ctx, out, "&lt;"); break;
+ case '>': fz_write_printf(ctx, out, "&gt;"); break;
+ case '&': fz_write_printf(ctx, out, "&amp;"); break;
+ case '"': fz_write_printf(ctx, out, "&quot;"); break;
+ case '\'': fz_write_printf(ctx, out, "&apos;"); break;
default:
if (ch->c >= 32 && ch->c <= 127)
- fz_printf(ctx, out, "%c", ch->c);
+ fz_write_printf(ctx, out, "%c", ch->c);
else
- fz_printf(ctx, out, "&#x%x;", ch->c);
+ fz_write_printf(ctx, out, "&#x%x;", ch->c);
break;
}
- fz_printf(ctx, out, "\"/>\n");
+ fz_write_printf(ctx, out, "\"/>\n");
}
if (style)
- fz_printf(ctx, out, "</span>\n");
+ fz_write_printf(ctx, out, "</span>\n");
}
- fz_printf(ctx, out, "</line>\n");
+ fz_write_printf(ctx, out, "</line>\n");
}
- fz_printf(ctx, out, "</block>\n");
+ fz_write_printf(ctx, out, "</block>\n");
break;
}
case FZ_PAGE_BLOCK_IMAGE:
@@ -340,7 +340,7 @@ fz_print_stext_page_xml(fz_context *ctx, fz_output *out, fz_stext_page *page)
}
}
}
- fz_printf(ctx, out, "</page>\n");
+ fz_write_printf(ctx, out, "</page>\n");
}
void
@@ -369,12 +369,12 @@ fz_print_stext_page(fz_context *ctx, fz_output *out, fz_stext_page *page)
{
n = fz_runetochar(utf, ch->c);
for (i = 0; i < n; i++)
- fz_printf(ctx, out, "%c", utf[i]);
+ fz_write_printf(ctx, out, "%c", utf[i]);
}
}
- fz_printf(ctx, out, "\n");
+ fz_write_printf(ctx, out, "\n");
}
- fz_printf(ctx, out, "\n");
+ fz_write_printf(ctx, out, "\n");
break;
}
case FZ_PAGE_BLOCK_IMAGE:
diff --git a/source/fitz/stext-search.c b/source/fitz/stext-search.c
index 99584581..6a3ea526 100644
--- a/source/fitz/stext-search.c
+++ b/source/fitz/stext-search.c
@@ -255,7 +255,7 @@ fz_copy_selection(fz_context *ctx, fz_stext_page *page, fz_rect rect)
{
if (seen)
{
- fz_write_buffer_byte(ctx, buffer, '\n');
+ fz_append_byte(ctx, buffer, '\n');
}
seen = 0;
@@ -268,7 +268,7 @@ fz_copy_selection(fz_context *ctx, fz_stext_page *page, fz_rect rect)
c = 0xFFFD;
if (hitbox.x1 >= x0 && hitbox.x0 <= x1 && hitbox.y1 >= y0 && hitbox.y0 <= y1)
{
- fz_write_buffer_rune(ctx, buffer, c);
+ fz_append_rune(ctx, buffer, c);
seen = 1;
}
}
diff --git a/source/fitz/store.c b/source/fitz/store.c
index 620bf0ea..70f25029 100644
--- a/source/fitz/store.c
+++ b/source/fitz/store.c
@@ -677,7 +677,7 @@ static void
print_item(fz_context *ctx, fz_output *out, void *item_)
{
fz_item *item = (fz_item *)item_;
- fz_printf(ctx, out, " val=%p item=%p\n", item->val, item);
+ fz_write_printf(ctx, out, " val=%p item=%p\n", item->val, item);
}
void
@@ -686,24 +686,24 @@ fz_print_store_locked(fz_context *ctx, fz_output *out)
fz_item *item, *next;
fz_store *store = ctx->store;
- fz_printf(ctx, out, "-- resource store contents --\n");
+ fz_write_printf(ctx, out, "-- resource store contents --\n");
for (item = store->head; item; item = next)
{
next = item->next;
if (next)
next->val->refs++;
- fz_printf(ctx, out, "store[*][refs=%d][size=%d] ", item->val->refs, item->size);
+ fz_write_printf(ctx, out, "store[*][refs=%d][size=%d] ", item->val->refs, item->size);
fz_unlock(ctx, FZ_LOCK_ALLOC);
item->type->print(ctx, out, item->key);
- fz_printf(ctx, out, " = %p\n", item->val);
+ fz_write_printf(ctx, out, " = %p\n", item->val);
fz_lock(ctx, FZ_LOCK_ALLOC);
if (next)
next->val->refs--;
}
- fz_printf(ctx, out, "-- resource store hash contents --\n");
+ fz_write_printf(ctx, out, "-- resource store hash contents --\n");
fz_print_hash_details(ctx, out, store->hash, print_item, 1);
- fz_printf(ctx, out, "-- end --\n");
+ fz_write_printf(ctx, out, "-- end --\n");
}
void
diff --git a/source/fitz/svg-device.c b/source/fitz/svg-device.c
index eb056c13..e80682fd 100644
--- a/source/fitz/svg-device.c
+++ b/source/fitz/svg-device.c
@@ -94,7 +94,7 @@ end_def(fz_context *ctx, svg_device *sdev)
sdev->out = sdev->out_store;
if (sdev->def_count == 0 && sdev->defs_buffer != NULL)
{
- fz_write(ctx, sdev->out, sdev->defs_buffer->data, sdev->defs_buffer->len);
+ fz_write_data(ctx, sdev->out, sdev->defs_buffer->data, sdev->defs_buffer->len);
sdev->defs_buffer->len = 0;
}
return sdev->out;
@@ -107,7 +107,7 @@ svg_path_moveto(fz_context *ctx, void *arg, float x, float y)
{
fz_output *out = (fz_output *)arg;
- fz_printf(ctx, out, "M %g %g ", x, y);
+ fz_write_printf(ctx, out, "M %g %g ", x, y);
}
static void
@@ -115,7 +115,7 @@ svg_path_lineto(fz_context *ctx, void *arg, float x, float y)
{
fz_output *out = (fz_output *)arg;
- fz_printf(ctx, out, "L %g %g ", x, y);
+ fz_write_printf(ctx, out, "L %g %g ", x, y);
}
static void
@@ -123,7 +123,7 @@ svg_path_curveto(fz_context *ctx, void *arg, float x1, float y1, float x2, float
{
fz_output *out = (fz_output *)arg;
- fz_printf(ctx, out, "C %g %g %g %g %g %g ", x1, y1, x2, y2, x3, y3);
+ fz_write_printf(ctx, out, "C %g %g %g %g %g %g ", x1, y1, x2, y2, x3, y3);
}
static void
@@ -131,7 +131,7 @@ svg_path_close(fz_context *ctx, void *arg)
{
fz_output *out = (fz_output *)arg;
- fz_printf(ctx, out, "Z ");
+ fz_write_printf(ctx, out, "Z ");
}
static const fz_path_walker svg_path_walker =
@@ -145,9 +145,9 @@ static const fz_path_walker svg_path_walker =
static void
svg_dev_path(fz_context *ctx, svg_device *sdev, const fz_path *path)
{
- fz_printf(ctx, sdev->out, " d=\"");
+ fz_write_printf(ctx, sdev->out, " d=\"");
fz_walk_path(ctx, path, &svg_path_walker, sdev->out);
- fz_printf(ctx, sdev->out, "\"");
+ fz_write_printf(ctx, sdev->out, "\"");
}
static void
@@ -157,7 +157,7 @@ svg_dev_ctm(fz_context *ctx, svg_device *sdev, const fz_matrix *ctm)
if (ctm->a != 1.0 || ctm->b != 0 || ctm->c != 0 || ctm->d != 1.0 || ctm->e != 0 || ctm->f != 0)
{
- fz_printf(ctx, out, " transform=\"matrix(%g,%g,%g,%g,%g,%g)\"",
+ fz_write_printf(ctx, out, " transform=\"matrix(%g,%g,%g,%g,%g,%g)\"",
ctm->a, ctm->b, ctm->c, ctm->d, ctm->e, ctm->f);
}
}
@@ -175,23 +175,23 @@ svg_dev_stroke_state(fz_context *ctx, svg_device *sdev, const fz_stroke_state *s
if (exp < 1)
exp = 1;
- fz_printf(ctx, out, " stroke-width=\"%g\"", exp);
- fz_printf(ctx, out, " stroke-linecap=\"%s\"",
+ fz_write_printf(ctx, out, " stroke-width=\"%g\"", exp);
+ fz_write_printf(ctx, out, " stroke-linecap=\"%s\"",
(stroke_state->start_cap == FZ_LINECAP_SQUARE ? "square" :
(stroke_state->start_cap == FZ_LINECAP_ROUND ? "round" : "butt")));
if (stroke_state->dash_len != 0)
{
int i;
- fz_printf(ctx, out, " stroke-dasharray=");
+ fz_write_printf(ctx, out, " stroke-dasharray=");
for (i = 0; i < stroke_state->dash_len; i++)
- fz_printf(ctx, out, "%c%g", (i == 0 ? '\"' : ','), stroke_state->dash_list[i]);
- fz_printf(ctx, out, "\"");
+ fz_write_printf(ctx, out, "%c%g", (i == 0 ? '\"' : ','), stroke_state->dash_list[i]);
+ fz_write_printf(ctx, out, "\"");
if (stroke_state->dash_phase != 0)
- fz_printf(ctx, out, " stroke-dashoffset=\"%g\"", stroke_state->dash_phase);
+ fz_write_printf(ctx, out, " stroke-dashoffset=\"%g\"", stroke_state->dash_phase);
}
if (stroke_state->linejoin == FZ_LINEJOIN_MITER || stroke_state->linejoin == FZ_LINEJOIN_MITER_XPS)
- fz_printf(ctx, out, " stroke-miterlimit=\"%g\"", stroke_state->miterlimit);
- fz_printf(ctx, out, " stroke-linejoin=\"%s\"",
+ fz_write_printf(ctx, out, " stroke-miterlimit=\"%g\"", stroke_state->miterlimit);
+ fz_write_printf(ctx, out, " stroke-linejoin=\"%s\"",
(stroke_state->linejoin == FZ_LINEJOIN_BEVEL ? "bevel" :
(stroke_state->linejoin == FZ_LINEJOIN_ROUND ? "round" : "miter")));
}
@@ -223,12 +223,12 @@ svg_dev_fill_color(fz_context *ctx, svg_device *sdev, fz_colorspace *colorspace,
{
int rgb = svg_hex_color(ctx, colorspace, color);
if (rgb != 0) /* black is the default value */
- fz_printf(ctx, out, " fill=\"#%06x\"", rgb);
+ fz_write_printf(ctx, out, " fill=\"#%06x\"", rgb);
}
else
- fz_printf(ctx, out, " fill=\"none\"");
+ fz_write_printf(ctx, out, " fill=\"none\"");
if (alpha != 1)
- fz_printf(ctx, out, " fill-opacity=\"%g\"", alpha);
+ fz_write_printf(ctx, out, " fill-opacity=\"%g\"", alpha);
}
static void
@@ -236,11 +236,11 @@ svg_dev_stroke_color(fz_context *ctx, svg_device *sdev, fz_colorspace *colorspac
{
fz_output *out = sdev->out;
if (colorspace)
- fz_printf(ctx, out, " fill=\"none\" stroke=\"#%06x\"", svg_hex_color(ctx, colorspace, color));
+ fz_write_printf(ctx, out, " fill=\"none\" stroke=\"#%06x\"", svg_hex_color(ctx, colorspace, color));
else
- fz_printf(ctx, out, " fill=\"none\" stroke=\"none\"");
+ fz_write_printf(ctx, out, " fill=\"none\" stroke=\"none\"");
if (alpha != 1)
- fz_printf(ctx, out, " stroke-opacity=\"%g\"", alpha);
+ fz_write_printf(ctx, out, " stroke-opacity=\"%g\"", alpha);
}
static void
@@ -322,7 +322,7 @@ svg_dev_text_span(fz_context *ctx, svg_device *sdev, const fz_matrix *ctm, const
if (span->len == 0)
{
- fz_printf(ctx, out, "/>\n");
+ fz_write_printf(ctx, out, "/>\n");
return;
}
@@ -344,15 +344,15 @@ svg_dev_text_span(fz_context *ctx, svg_device *sdev, const fz_matrix *ctm, const
is_bold = fz_font_is_bold(ctx, span->font);
is_italic = fz_font_is_italic(ctx, span->font);
- fz_printf(ctx, out, " xml:space=\"preserve\"");
- fz_printf(ctx, out, " transform=\"matrix(%M)\"", &final_tm);
- fz_printf(ctx, out, " font-size=\"%g\"", font_size);
- fz_printf(ctx, out, " font-family=\"%s\"", font_family);
- if (is_bold) fz_printf(ctx, out, " font-weight=\"bold\"");
- if (is_italic) fz_printf(ctx, out, " font-style=\"italic\"");
- if (span->wmode != 0) fz_printf(ctx, out, " writing-mode=\"tb\"");
+ fz_write_printf(ctx, out, " xml:space=\"preserve\"");
+ fz_write_printf(ctx, out, " transform=\"matrix(%M)\"", &final_tm);
+ fz_write_printf(ctx, out, " font-size=\"%g\"", font_size);
+ fz_write_printf(ctx, out, " font-family=\"%s\"", font_family);
+ if (is_bold) fz_write_printf(ctx, out, " font-weight=\"bold\"");
+ if (is_italic) fz_write_printf(ctx, out, " font-style=\"italic\"");
+ if (span->wmode != 0) fz_write_printf(ctx, out, " writing-mode=\"tb\"");
- fz_putc(ctx, out, '>');
+ fz_write_byte(ctx, out, '>');
start = find_first_char(ctx, span, 0);
while (start < span->len)
@@ -365,9 +365,9 @@ svg_dev_text_span(fz_context *ctx, svg_device *sdev, const fz_matrix *ctm, const
if (span->items[start].gid >= 0)
cluster_advance = svg_cluster_advance(ctx, span, start, end);
if (span->wmode == 0)
- fz_printf(ctx, out, "<tspan y=\"%g\" x=\"%g", p.y, p.x);
+ fz_write_printf(ctx, out, "<tspan y=\"%g\" x=\"%g", p.y, p.x);
else
- fz_printf(ctx, out, "<tspan x=\"%g\" y=\"%g", p.x, p.y);
+ fz_write_printf(ctx, out, "<tspan x=\"%g\" y=\"%g", p.x, p.y);
for (i = start + 1; i < end; ++i)
{
it = &span->items[i];
@@ -389,10 +389,10 @@ svg_dev_text_span(fz_context *ctx, svg_device *sdev, const fz_matrix *ctm, const
else
p.y += font_size * cluster_advance;
}
- fz_printf(ctx, out, " %g", span->wmode == 0 ? p.x : p.y);
+ fz_write_printf(ctx, out, " %g", span->wmode == 0 ? p.x : p.y);
}
}
- fz_printf(ctx, out, "\">");
+ fz_write_printf(ctx, out, "\">");
for (i = start; i < end; ++i)
{
it = &span->items[i];
@@ -400,17 +400,17 @@ svg_dev_text_span(fz_context *ctx, svg_device *sdev, const fz_matrix *ctm, const
{
int c = it->ucs;
if (c >= 32 && c <= 127 && c != '<' && c != '&' && c != '>')
- fz_putc(ctx, out, c);
+ fz_write_byte(ctx, out, c);
else
- fz_printf(ctx, out, "&#x%04x;", c);
+ fz_write_printf(ctx, out, "&#x%04x;", c);
}
}
- fz_printf(ctx, out, "</tspan>");
+ fz_write_printf(ctx, out, "</tspan>");
start = find_first_char(ctx, span, end);
}
- fz_printf(ctx, out, "</text>\n");
+ fz_write_printf(ctx, out, "</text>\n");
}
static font *
@@ -476,10 +476,10 @@ svg_dev_text_span_as_paths_defs(fz_context *ctx, fz_device *dev, fz_text_span *s
shift.f = -rect.y0;
fz_transform_path(ctx, path, &shift);
out = start_def(ctx, sdev);
- fz_printf(ctx, out, "<symbol id=\"font_%x_%x\">\n", fnt->id, gid);
- fz_printf(ctx, out, "<path");
+ fz_write_printf(ctx, out, "<symbol id=\"font_%x_%x\">\n", fnt->id, gid);
+ fz_write_printf(ctx, out, "<path");
svg_dev_path(ctx, sdev, path);
- fz_printf(ctx, out, "/>\n");
+ fz_write_printf(ctx, out, "/>\n");
fz_drop_path(ctx, path);
}
else
@@ -488,10 +488,10 @@ svg_dev_text_span_as_paths_defs(fz_context *ctx, fz_device *dev, fz_text_span *s
shift.e = -rect.x0;
shift.f = -rect.y0;
out = start_def(ctx, sdev);
- fz_printf(ctx, out, "<symbol id=\"font_%x_%x\">\n", fnt->id, gid);
+ fz_write_printf(ctx, out, "<symbol id=\"font_%x_%x\">\n", fnt->id, gid);
fz_run_t3_glyph(ctx, span->font, gid, &shift, dev);
}
- fz_printf(ctx, out, "</symbol>\n");
+ fz_write_printf(ctx, out, "</symbol>\n");
out = end_def(ctx, sdev);
fnt->sentlist[gid].x_off = rect.x0;
fnt->sentlist[gid].y_off = rect.y0;
@@ -533,10 +533,10 @@ svg_dev_text_span_as_paths_fill(fz_context *ctx, fz_device *dev, const fz_text_s
local_trm.f = it->y;
fz_concat(&local_trm2, &local_trm, ctm);
fz_concat(&local_trm2, &shift, &local_trm2);
- fz_printf(ctx, out, "<use xlink:href=\"#font_%x_%x\"", fnt->id, gid);
+ fz_write_printf(ctx, out, "<use xlink:href=\"#font_%x_%x\"", fnt->id, gid);
svg_dev_ctm(ctx, sdev, &local_trm2);
svg_dev_fill_color(ctx, sdev, colorspace, color, alpha);
- fz_printf(ctx, out, "/>\n");
+ fz_write_printf(ctx, out, "/>\n");
}
}
@@ -573,11 +573,11 @@ svg_dev_text_span_as_paths_stroke(fz_context *ctx, fz_device *dev, const fz_text
local_trm.f = it->y;
fz_concat(&local_trm2, &local_trm, ctm);
fz_concat(&local_trm2, &shift, &local_trm2);
- fz_printf(ctx, out, "<use xlink:href=\"#font_%x_%x\"", fnt->id, gid);
+ fz_write_printf(ctx, out, "<use xlink:href=\"#font_%x_%x\"", fnt->id, gid);
svg_dev_stroke_state(ctx, sdev, stroke, &local_trm2);
svg_dev_ctm(ctx, sdev, &local_trm2);
svg_dev_stroke_color(ctx, sdev, colorspace, color, alpha);
- fz_printf(ctx, out, "/>\n");
+ fz_write_printf(ctx, out, "/>\n");
}
}
@@ -590,13 +590,13 @@ svg_dev_fill_path(fz_context *ctx, fz_device *dev, const fz_path *path, int even
svg_device *sdev = (svg_device*)dev;
fz_output *out = sdev->out;
- fz_printf(ctx, out, "<path");
+ fz_write_printf(ctx, out, "<path");
svg_dev_ctm(ctx, sdev, ctm);
svg_dev_path(ctx, sdev, path);
svg_dev_fill_color(ctx, sdev, colorspace, color, alpha);
if (even_odd)
- fz_printf(ctx, out, " fill-rule=\"evenodd\"");
- fz_printf(ctx, out, "/>\n");
+ fz_write_printf(ctx, out, " fill-rule=\"evenodd\"");
+ fz_write_printf(ctx, out, "/>\n");
}
static void
@@ -606,12 +606,12 @@ svg_dev_stroke_path(fz_context *ctx, fz_device *dev, const fz_path *path, const
svg_device *sdev = (svg_device*)dev;
fz_output *out = sdev->out;
- fz_printf(ctx, out, "<path");
+ fz_write_printf(ctx, out, "<path");
svg_dev_ctm(ctx, sdev, ctm);
svg_dev_stroke_state(ctx, sdev, stroke, &fz_identity);
svg_dev_stroke_color(ctx, sdev, colorspace, color, alpha);
svg_dev_path(ctx, sdev, path);
- fz_printf(ctx, out, "/>\n");
+ fz_write_printf(ctx, out, "/>\n");
}
static void
@@ -623,15 +623,15 @@ svg_dev_clip_path(fz_context *ctx, fz_device *dev, const fz_path *path, int even
int num = sdev->id++;
out = start_def(ctx, sdev);
- fz_printf(ctx, out, "<clipPath id=\"cp%d\">\n", num);
- fz_printf(ctx, out, "<path");
+ fz_write_printf(ctx, out, "<clipPath id=\"cp%d\">\n", num);
+ fz_write_printf(ctx, out, "<path");
svg_dev_ctm(ctx, sdev, ctm);
svg_dev_path(ctx, sdev, path);
if (even_odd)
- fz_printf(ctx, out, " fill-rule=\"evenodd\"");
- fz_printf(ctx, out, "/>\n</clipPath>\n");
+ fz_write_printf(ctx, out, " fill-rule=\"evenodd\"");
+ fz_write_printf(ctx, out, "/>\n</clipPath>\n");
out = end_def(ctx, sdev);
- fz_printf(ctx, out, "<g clip-path=\"url(#cp%d)\">\n", num);
+ fz_write_printf(ctx, out, "<g clip-path=\"url(#cp%d)\">\n", num);
}
static void
@@ -647,16 +647,16 @@ svg_dev_clip_stroke_path(fz_context *ctx, fz_device *dev, const fz_path *path, c
fz_bound_path(ctx, path, stroke, ctm, &bounds);
out = start_def(ctx, sdev);
- fz_printf(ctx, out, "<mask id=\"ma%d\" x=\"%g\" y=\"%g\" width=\"%g\" height=\"%g\" maskUnits=\"userSpaceOnUse\" maskContentUnits=\"userSpaceOnUse\">\n",
+ fz_write_printf(ctx, out, "<mask id=\"ma%d\" x=\"%g\" y=\"%g\" width=\"%g\" height=\"%g\" maskUnits=\"userSpaceOnUse\" maskContentUnits=\"userSpaceOnUse\">\n",
num, bounds.x0, bounds.y0, bounds.x1 - bounds.x0, bounds.y1 - bounds.y0);
- fz_printf(ctx, out, "<path");
+ fz_write_printf(ctx, out, "<path");
svg_dev_ctm(ctx, sdev, ctm);
svg_dev_stroke_state(ctx, sdev, stroke, &fz_identity);
svg_dev_stroke_color(ctx, sdev, fz_device_rgb(ctx), white, 1);
svg_dev_path(ctx, sdev, path);
- fz_printf(ctx, out, "/>\n</mask>\n");
+ fz_write_printf(ctx, out, "/>\n</mask>\n");
out = end_def(ctx, sdev);
- fz_printf(ctx, out, "<g mask=\"url(#ma%d)\">\n", num);
+ fz_write_printf(ctx, out, "<g mask=\"url(#ma%d)\">\n", num);
}
static void
@@ -672,7 +672,7 @@ svg_dev_fill_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz
{
for (span = text->head; span; span = span->next)
{
- fz_printf(ctx, out, "<text");
+ fz_write_printf(ctx, out, "<text");
svg_dev_fill_color(ctx, sdev, colorspace, color, alpha);
svg_dev_text_span(ctx, sdev, ctm, span);
}
@@ -700,7 +700,7 @@ svg_dev_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text, const
{
for (span = text->head; span; span = span->next)
{
- fz_printf(ctx, out, "<text");
+ fz_write_printf(ctx, out, "<text");
svg_dev_fill_color(ctx, sdev, colorspace, color, alpha);
svg_dev_text_span(ctx, sdev, ctm, span);
}
@@ -730,14 +730,14 @@ svg_dev_clip_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz
fz_bound_text(ctx, text, NULL, ctm, &bounds);
out = start_def(ctx, sdev);
- fz_printf(ctx, out, "<mask id=\"ma%d\" x=\"%g\" y=\"%g\" width=\"%g\" height=\"%g\"",
+ fz_write_printf(ctx, out, "<mask id=\"ma%d\" x=\"%g\" y=\"%g\" width=\"%g\" height=\"%g\"",
num, bounds.x0, bounds.y0, bounds.x1 - bounds.x0, bounds.y1 - bounds.y0);
- fz_printf(ctx, out, " maskUnits=\"userSpaceOnUse\" maskContentUnits=\"userSpaceOnUse\">\n");
+ fz_write_printf(ctx, out, " maskUnits=\"userSpaceOnUse\" maskContentUnits=\"userSpaceOnUse\">\n");
if (sdev->text_as_text)
{
for (span = text->head; span; span = span->next)
{
- fz_printf(ctx, out, "<text");
+ fz_write_printf(ctx, out, "<text");
svg_dev_fill_color(ctx, sdev, fz_device_rgb(ctx), white, 1);
svg_dev_text_span(ctx, sdev, ctm, span);
}
@@ -750,9 +750,9 @@ svg_dev_clip_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz
svg_dev_text_span_as_paths_fill(ctx, dev, span, ctm, fz_device_rgb(ctx), white, 1.0f, fnt);
}
}
- fz_printf(ctx, out, "</mask>\n");
+ fz_write_printf(ctx, out, "</mask>\n");
out = end_def(ctx, sdev);
- fz_printf(ctx, out, "<g mask=\"url(#ma%d)\">\n", num);
+ fz_write_printf(ctx, out, "<g mask=\"url(#ma%d)\">\n", num);
}
static void
@@ -770,14 +770,14 @@ svg_dev_clip_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text, c
fz_bound_text(ctx, text, NULL, ctm, &bounds);
out = start_def(ctx, sdev);
- fz_printf(ctx, out, "<mask id=\"ma%d\" x=\"%g\" y=\"%g\" width=\"%g\" height=\"%g\"",
+ fz_write_printf(ctx, out, "<mask id=\"ma%d\" x=\"%g\" y=\"%g\" width=\"%g\" height=\"%g\"",
num, bounds.x0, bounds.y0, bounds.x1 - bounds.x0, bounds.y1 - bounds.y0);
- fz_printf(ctx, out, " maskUnits=\"userSpaceOnUse\" maskContentUnits=\"userSpaceOnUse\">\n");
+ fz_write_printf(ctx, out, " maskUnits=\"userSpaceOnUse\" maskContentUnits=\"userSpaceOnUse\">\n");
if (sdev->text_as_text)
{
for (span = text->head; span; span = span->next)
{
- fz_printf(ctx, out, "<text");
+ fz_write_printf(ctx, out, "<text");
svg_dev_stroke_state(ctx, sdev, stroke, &fz_identity);
svg_dev_stroke_color(ctx, sdev, fz_device_rgb(ctx), white, 1);
svg_dev_text_span(ctx, sdev, ctm, span);
@@ -791,9 +791,9 @@ svg_dev_clip_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text, c
svg_dev_text_span_as_paths_stroke(ctx, dev, span, stroke, ctm, fz_device_rgb(ctx), white, 1.0f, fnt);
}
}
- fz_printf(ctx, out, "</mask>\n");
+ fz_write_printf(ctx, out, "</mask>\n");
out = end_def(ctx, sdev);
- fz_printf(ctx, out, "<g mask=\"url(#ma%d)\">\n", num);
+ fz_write_printf(ctx, out, "<g mask=\"url(#ma%d)\">\n", num);
}
static void
@@ -809,7 +809,7 @@ svg_dev_ignore_text(fz_context *ctx, fz_device *dev, const fz_text *text, const
{
for (span = text->head; span; span = span->next)
{
- fz_printf(ctx, out, "<text");
+ fz_write_printf(ctx, out, "<text");
svg_dev_fill_color(ctx, sdev, fz_device_rgb(ctx), black, 0.0f);
svg_dev_text_span(ctx, sdev, ctm, span);
}
@@ -829,8 +829,8 @@ send_data_base64(fz_context *ctx, fz_output *out, fz_buffer *buffer)
int d = buffer->data[3*i+1];
int e = buffer->data[3*i+2];
if ((i & 15) == 0)
- fz_printf(ctx, out, "\n");
- fz_printf(ctx, out, "%c%c%c%c", set[c>>2], set[((c&3)<<4)|(d>>4)], set[((d&15)<<2)|(e>>6)], set[e & 63]);
+ fz_write_printf(ctx, out, "\n");
+ fz_write_printf(ctx, out, "%c%c%c%c", set[c>>2], set[((c&3)<<4)|(d>>4)], set[((d&15)<<2)|(e>>6)], set[e & 63]);
}
i *= 3;
switch (buffer->len-i)
@@ -839,13 +839,13 @@ send_data_base64(fz_context *ctx, fz_output *out, fz_buffer *buffer)
{
int c = buffer->data[i];
int d = buffer->data[i+1];
- fz_printf(ctx, out, "%c%c%c=", set[c>>2], set[((c&3)<<4)|(d>>4)], set[((d&15)<<2)]);
+ fz_write_printf(ctx, out, "%c%c%c=", set[c>>2], set[((c&3)<<4)|(d>>4)], set[((d&15)<<2)]);
break;
}
case 1:
{
int c = buffer->data[i];
- fz_printf(ctx, out, "%c%c==", set[c>>2], set[(c&3)<<4]);
+ fz_write_printf(ctx, out, "%c%c==", set[c>>2], set[(c&3)<<4]);
break;
}
default:
@@ -874,7 +874,7 @@ svg_send_image(fz_context *ctx, svg_device *sdev, fz_image *img)
break;
if (i >= 0)
{
- fz_printf(ctx, out, "<use xlink:href=\"#im%d\" x=\"0\" y=\"0\" width=\"%d\" height=\"%d\"/>\n",
+ fz_write_printf(ctx, out, "<use xlink:href=\"#im%d\" x=\"0\" y=\"0\" width=\"%d\" height=\"%d\"/>\n",
sdev->images[i].id, img->w, img->h);
return;
}
@@ -891,23 +891,23 @@ svg_send_image(fz_context *ctx, svg_device *sdev, fz_image *img)
id = sdev->id++;
out = start_def(ctx, sdev);
- fz_printf(ctx, out, "<symbol id=\"im%d\" viewBox=\"0 0 %d %d\">\n", id, img->w, img->h);
+ fz_write_printf(ctx, out, "<symbol id=\"im%d\" viewBox=\"0 0 %d %d\">\n", id, img->w, img->h);
}
- fz_printf(ctx, out, "<image");
+ fz_write_printf(ctx, out, "<image");
buffer = fz_compressed_image_buffer(ctx, img);
- fz_printf(ctx, out, " width=\"%d\" height=\"%d\" xlink:href=\"data:", img->w, img->h);
+ fz_write_printf(ctx, out, " width=\"%d\" height=\"%d\" xlink:href=\"data:", img->w, img->h);
switch (buffer == NULL ? FZ_IMAGE_JPX : buffer->params.type)
{
case FZ_IMAGE_PNG:
- fz_printf(ctx, out, "image/png;base64,");
+ fz_write_printf(ctx, out, "image/png;base64,");
send_data_base64(ctx, out, buffer->buffer);
break;
case FZ_IMAGE_JPEG:
/* SVG cannot cope with CMYK images */
if (img->colorspace != fz_device_cmyk(ctx))
{
- fz_printf(ctx, out, "image/jpeg;base64,");
+ fz_write_printf(ctx, out, "image/jpeg;base64,");
send_data_base64(ctx, out, buffer->buffer);
break;
}
@@ -915,24 +915,24 @@ svg_send_image(fz_context *ctx, svg_device *sdev, fz_image *img)
default:
{
fz_buffer *buf = fz_new_buffer_from_image_as_png(ctx, img);
- fz_printf(ctx, out, "image/png;base64,");
+ fz_write_printf(ctx, out, "image/png;base64,");
send_data_base64(ctx, out, buf);
fz_drop_buffer(ctx, buf);
break;
}
}
- fz_printf(ctx, out, "\"/>\n");
+ fz_write_printf(ctx, out, "\"/>\n");
if (sdev->reuse_images)
{
- fz_printf(ctx, out, "</symbol>\n");
+ fz_write_printf(ctx, out, "</symbol>\n");
out = end_def(ctx, sdev);
sdev->images[sdev->num_images].id = id;
sdev->images[sdev->num_images].image = fz_keep_image(ctx, img);
sdev->num_images++;
- fz_printf(ctx, out, "<use xlink:href=\"#im%d\" x=\"0\" y=\"0\" width=\"%d\" height=\"%d\"/>\n",
+ fz_write_printf(ctx, out, "<use xlink:href=\"#im%d\" x=\"0\" y=\"0\" width=\"%d\" height=\"%d\"/>\n",
id, img->w, img->h);
}
}
@@ -950,13 +950,13 @@ svg_dev_fill_image(fz_context *ctx, fz_device *dev, fz_image *image, const fz_ma
scale.d = 1.0f / image->h;
fz_concat(&local_ctm, &scale, ctm);
- fz_printf(ctx, out, "<g");
+ fz_write_printf(ctx, out, "<g");
if (alpha != 1.0f)
- fz_printf(ctx, out, " opacity=\"%g\"", alpha);
+ fz_write_printf(ctx, out, " opacity=\"%g\"", alpha);
svg_dev_ctm(ctx, sdev, &local_ctm);
- fz_printf(ctx, out, ">\n");
+ fz_write_printf(ctx, out, ">\n");
svg_send_image(ctx, sdev, image);
- fz_printf(ctx, out, "</g>\n");
+ fz_write_printf(ctx, out, "</g>\n");
}
static void
@@ -985,12 +985,12 @@ svg_dev_fill_shade(fz_context *ctx, fz_device *dev, fz_shade *shade, const fz_ma
fz_paint_shade(ctx, shade, ctm, pix, &bbox);
buf = fz_new_buffer_from_pixmap_as_png(ctx, pix);
if (alpha != 1.0f)
- fz_printf(ctx, out, "<g opacity=\"%g\">\n", alpha);
- fz_printf(ctx, out, "<image x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" xlink:href=\"data:image/png;base64,", pix->x, pix->y, pix->w, pix->h);
+ fz_write_printf(ctx, out, "<g opacity=\"%g\">\n", alpha);
+ fz_write_printf(ctx, out, "<image x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" xlink:href=\"data:image/png;base64,", pix->x, pix->y, pix->w, pix->h);
send_data_base64(ctx, out, buf);
- fz_printf(ctx, out, "\"/>\n");
+ fz_write_printf(ctx, out, "\"/>\n");
if (alpha != 1.0f)
- fz_printf(ctx, out, "</g>\n");
+ fz_write_printf(ctx, out, "</g>\n");
}
fz_always(ctx)
{
@@ -1018,14 +1018,14 @@ svg_dev_fill_image_mask(fz_context *ctx, fz_device *dev, fz_image *image, const
fz_concat(&local_ctm, &scale, ctm);
out = start_def(ctx, sdev);
- fz_printf(ctx, out, "<mask id=\"ma%d\">\n", mask);
+ fz_write_printf(ctx, out, "<mask id=\"ma%d\">\n", mask);
svg_send_image(ctx, sdev, image);
- fz_printf(ctx, out, "</mask>\n");
+ fz_write_printf(ctx, out, "</mask>\n");
out = end_def(ctx, sdev);
- fz_printf(ctx, out, "<rect x=\"0\" y=\"0\" width=\"%d\" height=\"%d\"", image->w, image->h);
+ fz_write_printf(ctx, out, "<rect x=\"0\" y=\"0\" width=\"%d\" height=\"%d\"", image->w, image->h);
svg_dev_fill_color(ctx, sdev, colorspace, color, alpha);
svg_dev_ctm(ctx, sdev, &local_ctm);
- fz_printf(ctx, out, " mask=\"url(#ma%d)\"/>\n", mask);
+ fz_write_printf(ctx, out, " mask=\"url(#ma%d)\"/>\n", mask);
}
static void
@@ -1042,13 +1042,13 @@ svg_dev_clip_image_mask(fz_context *ctx, fz_device *dev, fz_image *image, const
fz_concat(&local_ctm, &scale, ctm);
out = start_def(ctx, sdev);
- fz_printf(ctx, out, "<mask id=\"ma%d\">\n<g", mask);
+ fz_write_printf(ctx, out, "<mask id=\"ma%d\">\n<g", mask);
svg_dev_ctm(ctx, sdev, &local_ctm);
- fz_printf(ctx, out, ">\n");
+ fz_write_printf(ctx, out, ">\n");
svg_send_image(ctx, sdev, image);
- fz_printf(ctx, out, "</g>\n</mask>\n");
+ fz_write_printf(ctx, out, "</g>\n</mask>\n");
out = end_def(ctx, sdev);
- fz_printf(ctx, out, "<g mask=\"url(#ma%d)\">\n", mask);
+ fz_write_printf(ctx, out, "<g mask=\"url(#ma%d)\">\n", mask);
}
static void
@@ -1058,7 +1058,7 @@ svg_dev_pop_clip(fz_context *ctx, fz_device *dev)
fz_output *out = sdev->out;
/* FIXME */
- fz_printf(ctx, out, "</g>\n");
+ fz_write_printf(ctx, out, "</g>\n");
}
static void
@@ -1069,7 +1069,7 @@ svg_dev_begin_mask(fz_context *ctx, fz_device *dev, const fz_rect *bbox, int lum
int mask = sdev->id++;
out = start_def(ctx, sdev);
- fz_printf(ctx, out, "<mask id=\"ma%d\">\n", mask);
+ fz_write_printf(ctx, out, "<mask id=\"ma%d\">\n", mask);
if (dev->container_len > 0)
dev->container[dev->container_len-1].user = mask;
@@ -1085,9 +1085,9 @@ svg_dev_end_mask(fz_context *ctx, fz_device *dev)
if (dev->container_len > 0)
mask = (int)dev->container[dev->container_len-1].user;
- fz_printf(ctx, out, "\"/>\n</mask>\n");
+ fz_write_printf(ctx, out, "\"/>\n</mask>\n");
out = end_def(ctx, sdev);
- fz_printf(ctx, out, "<g mask=\"url(#ma%d)\">\n", mask);
+ fz_write_printf(ctx, out, "<g mask=\"url(#ma%d)\">\n", mask);
}
static void
@@ -1098,9 +1098,9 @@ svg_dev_begin_group(fz_context *ctx, fz_device *dev, const fz_rect *bbox, int is
/* SVG 1.1 doesn't support adequate blendmodes/knockout etc, so just ignore it for now */
if (alpha == 1)
- fz_printf(ctx, out, "<g>\n");
+ fz_write_printf(ctx, out, "<g>\n");
else
- fz_printf(ctx, out, "<g opacity=\"%g\">\n", alpha);
+ fz_write_printf(ctx, out, "<g opacity=\"%g\">\n", alpha);
}
static void
@@ -1109,7 +1109,7 @@ svg_dev_end_group(fz_context *ctx, fz_device *dev)
svg_device *sdev = (svg_device*)dev;
fz_output *out = sdev->out;
- fz_printf(ctx, out, "</g>\n");
+ fz_write_printf(ctx, out, "</g>\n");
}
static int
@@ -1148,7 +1148,7 @@ svg_dev_begin_tile(fz_context *ctx, fz_device *dev, const fz_rect *area, const f
/* The first thing we do is to capture the contents of the pattern
* as a symbol we can reuse. */
out = start_def(ctx, sdev);
- fz_printf(ctx, out, "<symbol id=\"pac%d\">\n", t->pattern);
+ fz_write_printf(ctx, out, "<symbol id=\"pac%d\">\n", t->pattern);
return 0;
}
@@ -1168,7 +1168,7 @@ svg_dev_end_tile(fz_context *ctx, fz_device *dev)
num = --sdev->num_tiles;
t = &sdev->tiles[num];
- fz_printf(ctx, out, "</symbol>\n");
+ fz_write_printf(ctx, out, "</symbol>\n");
/* In svg, the reference tile is taken from (x,y) to (x+width,y+height)
* and is repeated at (x+n*width,y+m*height) for all integer n and m.
@@ -1178,48 +1178,48 @@ svg_dev_end_tile(fz_context *ctx, fz_device *dev)
* pattern tile, we need to render the pattern contents several times
* to ensure that the pattern tile contains everything. */
- fz_printf(ctx, out, "<pattern id=\"pa%d\" patternUnits=\"userSpaceOnUse\" patternContentUnits=\"userSpaceOnUse\"",
+ fz_write_printf(ctx, out, "<pattern id=\"pa%d\" patternUnits=\"userSpaceOnUse\" patternContentUnits=\"userSpaceOnUse\"",
t->pattern);
- fz_printf(ctx, out, " x=\"0\" y=\"0\" width=\"%g\" height=\"%g\">\n",
+ fz_write_printf(ctx, out, " x=\"0\" y=\"0\" width=\"%g\" height=\"%g\">\n",
t->step.x, t->step.y);
if (t->view.x0 > 0 || t->step.x < t->view.x1 || t->view.y0 > 0 || t->step.y < t->view.y1)
{
cp = sdev->id++;
- fz_printf(ctx, out, "<clipPath id=\"cp%d\">\n", cp);
- fz_printf(ctx, out, "<path d=\"M %g %g L %g %g L %g %g L %g %g Z\"/>\n",
+ fz_write_printf(ctx, out, "<clipPath id=\"cp%d\">\n", cp);
+ fz_write_printf(ctx, out, "<path d=\"M %g %g L %g %g L %g %g L %g %g Z\"/>\n",
t->view.x0, t->view.y0,
t->view.x1, t->view.y0,
t->view.x1, t->view.y1,
t->view.x0, t->view.y1);
- fz_printf(ctx, out, "</clipPath>\n");
- fz_printf(ctx, out, "<g clip-path=\"url(#cp%d)\">\n", cp);
+ fz_write_printf(ctx, out, "</clipPath>\n");
+ fz_write_printf(ctx, out, "<g clip-path=\"url(#cp%d)\">\n", cp);
}
/* All the pattern contents will have their own ctm applied. Let's
* undo the current one to allow for this */
fz_invert_matrix(&inverse, &t->ctm);
- fz_printf(ctx, out, "<g");
+ fz_write_printf(ctx, out, "<g");
svg_dev_ctm(ctx, sdev, &inverse);
- fz_printf(ctx, out, ">\n");
+ fz_write_printf(ctx, out, ">\n");
w = t->view.x1 - t->view.x0;
h = t->view.y1 - t->view.y0;
for (x = 0; x > -w; x -= t->step.x)
for (y = 0; y > -h; y -= t->step.y)
- fz_printf(ctx, out, "<use x=\"%g\" y=\"%g\" xlink:href=\"#pac%d\"/>\n", x, y, t->pattern);
+ fz_write_printf(ctx, out, "<use x=\"%g\" y=\"%g\" xlink:href=\"#pac%d\"/>\n", x, y, t->pattern);
- fz_printf(ctx, out, "</g>\n");
+ fz_write_printf(ctx, out, "</g>\n");
if (cp != -1)
- fz_printf(ctx, out, "</g>\n");
- fz_printf(ctx, out, "</pattern>\n");
+ fz_write_printf(ctx, out, "</g>\n");
+ fz_write_printf(ctx, out, "</pattern>\n");
out = end_def(ctx, sdev);
/* Finally, fill a rectangle with the pattern. */
- fz_printf(ctx, out, "<rect");
+ fz_write_printf(ctx, out, "<rect");
svg_dev_ctm(ctx, sdev, &t->ctm);
- fz_printf(ctx, out, " fill=\"url(#pa%d)\" x=\"%g\" y=\"%g\" width=\"%g\" height=\"%g\"/>\n",
+ fz_write_printf(ctx, out, " fill=\"url(#pa%d)\" x=\"%g\" y=\"%g\" width=\"%g\" height=\"%g\"/>\n",
t->pattern, t->area.x0, t->area.y0, t->area.x1 - t->area.x0, t->area.y1 - t->area.y0);
}
@@ -1228,7 +1228,7 @@ svg_dev_close_device(fz_context *ctx, fz_device *dev)
{
svg_device *sdev = (svg_device*)dev;
fz_output *out = sdev->out;
- fz_printf(ctx, out, "</svg>\n");
+ fz_write_printf(ctx, out, "</svg>\n");
}
static void
@@ -1294,9 +1294,9 @@ fz_device *fz_new_svg_device(fz_context *ctx, fz_output *out, float page_width,
dev->text_as_text = (text_format == FZ_SVG_TEXT_AS_TEXT);
dev->reuse_images = reuse_images;
- fz_printf(ctx, out, "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n");
- fz_printf(ctx, out, "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n");
- fz_printf(ctx, out, "<svg xmlns=\"http://www.w3.org/2000/svg\" "
+ fz_write_printf(ctx, out, "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n");
+ fz_write_printf(ctx, out, "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n");
+ fz_write_printf(ctx, out, "<svg xmlns=\"http://www.w3.org/2000/svg\" "
"xmlns:xlink=\"http://www.w3.org/1999/xlink\" version=\"1.1\" "
"width=\"%gpt\" height=\"%gpt\" viewBox=\"0 0 %g %g\">\n",
page_width, page_height, page_width, page_height);
diff --git a/source/fitz/trace-device.c b/source/fitz/trace-device.c
index 881d7567..d306297f 100644
--- a/source/fitz/trace-device.c
+++ b/source/fitz/trace-device.c
@@ -9,7 +9,7 @@ typedef struct fz_trace_device_s
static void
fz_trace_matrix(fz_context *ctx, fz_output *out, const fz_matrix *ctm)
{
- fz_printf(ctx, out, " matrix=\"%g %g %g %g %g %g\"",
+ fz_write_printf(ctx, out, " matrix=\"%g %g %g %g %g %g\"",
ctm->a, ctm->b, ctm->c, ctm->d, ctm->e, ctm->f);
}
@@ -20,13 +20,13 @@ fz_trace_color(fz_context *ctx, fz_output *out, fz_colorspace *colorspace, const
if (colorspace)
{
n = fz_colorspace_n(ctx, colorspace);
- fz_printf(ctx, out, " colorspace=\"%s\" color=\"", fz_colorspace_name(ctx, colorspace));
+ fz_write_printf(ctx, out, " colorspace=\"%s\" color=\"", fz_colorspace_name(ctx, colorspace));
for (i = 0; i < n; i++)
- fz_printf(ctx, out, "%s%g", i == 0 ? "" : " ", color[i]);
- fz_printf(ctx, out, "\"");
+ fz_write_printf(ctx, out, "%s%g", i == 0 ? "" : " ", color[i]);
+ fz_write_printf(ctx, out, "\"");
}
if (alpha < 1)
- fz_printf(ctx, out, " alpha=\"%g\"", alpha);
+ fz_write_printf(ctx, out, " alpha=\"%g\"", alpha);
}
static int
@@ -39,30 +39,30 @@ static void
fz_trace_text_span(fz_context *ctx, fz_output *out, fz_text_span *span)
{
int i;
- fz_printf(ctx, out, "<span font=\"%s\" wmode=\"%d\"", fz_font_name(ctx, span->font), span->wmode);
- fz_printf(ctx, out, " trm=\"%g %g %g %g\">\n", span->trm.a, span->trm.b, span->trm.c, span->trm.d);
+ fz_write_printf(ctx, out, "<span font=\"%s\" wmode=\"%d\"", fz_font_name(ctx, span->font), span->wmode);
+ fz_write_printf(ctx, out, " trm=\"%g %g %g %g\">\n", span->trm.a, span->trm.b, span->trm.c, span->trm.d);
for (i = 0; i < span->len; i++)
{
char name[32];
if (span->items[i].ucs == -1)
- fz_printf(ctx, out, "<g unicode=\"-1\"");
+ fz_write_printf(ctx, out, "<g unicode=\"-1\"");
else if (!isxmlmeta(span->items[i].ucs))
- fz_printf(ctx, out, "<g unicode=\"%c\"", span->items[i].ucs);
+ fz_write_printf(ctx, out, "<g unicode=\"%c\"", span->items[i].ucs);
else
- fz_printf(ctx, out, "<g unicode=\"U+%04x\"", span->items[i].ucs);
+ fz_write_printf(ctx, out, "<g unicode=\"U+%04x\"", span->items[i].ucs);
if (span->items[i].gid >= 0)
{
fz_get_glyph_name(ctx, span->font, span->items[i].gid, name, sizeof name);
- fz_printf(ctx, out, " glyph=\"%s\"", name);
+ fz_write_printf(ctx, out, " glyph=\"%s\"", name);
}
else
- fz_printf(ctx, out, " glyph=\"-1\"");
+ fz_write_printf(ctx, out, " glyph=\"-1\"");
- fz_printf(ctx, out, " x=\"%g\" y=\"%g\" />\n", span->items[i].x, span->items[i].y);
+ fz_write_printf(ctx, out, " x=\"%g\" y=\"%g\" />\n", span->items[i].x, span->items[i].y);
}
- fz_printf(ctx, out, "</span>\n");
+ fz_write_printf(ctx, out, "</span>\n");
}
static void
@@ -77,28 +77,28 @@ static void
trace_moveto(fz_context *ctx, void *arg, float x, float y)
{
fz_output *out = arg;
- fz_printf(ctx, out, "<moveto x=\"%g\" y=\"%g\"/>\n", x, y);
+ fz_write_printf(ctx, out, "<moveto x=\"%g\" y=\"%g\"/>\n", x, y);
}
static void
trace_lineto(fz_context *ctx, void *arg, float x, float y)
{
fz_output *out = arg;
- fz_printf(ctx, out, "<lineto x=\"%g\" y=\"%g\"/>\n", x, y);
+ fz_write_printf(ctx, out, "<lineto x=\"%g\" y=\"%g\"/>\n", x, y);
}
static void
trace_curveto(fz_context *ctx, void *arg, float x1, float y1, float x2, float y2, float x3, float y3)
{
fz_output *out = arg;
- fz_printf(ctx, out, "<curveto x1=\"%g\" y1=\"%g\" x2=\"%g\" y2=\"%g\" x3=\"%g\" y3=\"%g\"/>\n", x1, y1, x2, y2, x3, y3);
+ fz_write_printf(ctx, out, "<curveto x1=\"%g\" y1=\"%g\" x2=\"%g\" y2=\"%g\" x3=\"%g\" y3=\"%g\"/>\n", x1, y1, x2, y2, x3, y3);
}
static void
trace_close(fz_context *ctx, void *arg)
{
fz_output *out = arg;
- fz_printf(ctx, out, "<closepath/>\n");
+ fz_write_printf(ctx, out, "<closepath/>\n");
}
static const fz_path_walker trace_path_walker =
@@ -120,16 +120,16 @@ fz_trace_fill_path(fz_context *ctx, fz_device *dev, const fz_path *path, int eve
fz_colorspace *colorspace, const float *color, float alpha)
{
fz_output *out = ((fz_trace_device*)dev)->out;
- fz_printf(ctx, out, "<fill_path");
+ fz_write_printf(ctx, out, "<fill_path");
if (even_odd)
- fz_printf(ctx, out, " winding=\"eofill\"");
+ fz_write_printf(ctx, out, " winding=\"eofill\"");
else
- fz_printf(ctx, out, " winding=\"nonzero\"");
+ fz_write_printf(ctx, out, " winding=\"nonzero\"");
fz_trace_color(ctx, out, colorspace, color, alpha);
fz_trace_matrix(ctx, out, ctm);
- fz_printf(ctx, out, ">\n");
+ fz_write_printf(ctx, out, ">\n");
fz_trace_path(ctx, out, path);
- fz_printf(ctx, out, "</fill_path>\n");
+ fz_write_printf(ctx, out, "</fill_path>\n");
}
static void
@@ -139,53 +139,53 @@ fz_trace_stroke_path(fz_context *ctx, fz_device *dev, const fz_path *path, const
fz_output *out = ((fz_trace_device*)dev)->out;
int i;
- fz_printf(ctx, out, "<stroke_path");
- fz_printf(ctx, out, " linewidth=\"%g\"", stroke->linewidth);
- fz_printf(ctx, out, " miterlimit=\"%g\"", stroke->miterlimit);
- fz_printf(ctx, out, " linecap=\"%d,%d,%d\"", stroke->start_cap, stroke->dash_cap, stroke->end_cap);
- fz_printf(ctx, out, " linejoin=\"%d\"", stroke->linejoin);
+ fz_write_printf(ctx, out, "<stroke_path");
+ fz_write_printf(ctx, out, " linewidth=\"%g\"", stroke->linewidth);
+ fz_write_printf(ctx, out, " miterlimit=\"%g\"", stroke->miterlimit);
+ fz_write_printf(ctx, out, " linecap=\"%d,%d,%d\"", stroke->start_cap, stroke->dash_cap, stroke->end_cap);
+ fz_write_printf(ctx, out, " linejoin=\"%d\"", stroke->linejoin);
if (stroke->dash_len)
{
- fz_printf(ctx, out, " dash_phase=\"%g\" dash=\"", stroke->dash_phase);
+ fz_write_printf(ctx, out, " dash_phase=\"%g\" dash=\"", stroke->dash_phase);
for (i = 0; i < stroke->dash_len; i++)
- fz_printf(ctx, out, "%s%g", i > 0 ? " " : "", stroke->dash_list[i]);
- fz_printf(ctx, out, "\"");
+ fz_write_printf(ctx, out, "%s%g", i > 0 ? " " : "", stroke->dash_list[i]);
+ fz_write_printf(ctx, out, "\"");
}
fz_trace_color(ctx, out, colorspace, color, alpha);
fz_trace_matrix(ctx, out, ctm);
- fz_printf(ctx, out, ">\n");
+ fz_write_printf(ctx, out, ">\n");
fz_trace_path(ctx, out, path);
- fz_printf(ctx, out, "</stroke_path>\n");
+ fz_write_printf(ctx, out, "</stroke_path>\n");
}
static void
fz_trace_clip_path(fz_context *ctx, fz_device *dev, const fz_path *path, int even_odd, const fz_matrix *ctm, const fz_rect *scissor)
{
fz_output *out = ((fz_trace_device*)dev)->out;
- fz_printf(ctx, out, "<clip_path");
+ fz_write_printf(ctx, out, "<clip_path");
if (even_odd)
- fz_printf(ctx, out, " winding=\"eofill\"");
+ fz_write_printf(ctx, out, " winding=\"eofill\"");
else
- fz_printf(ctx, out, " winding=\"nonzero\"");
+ fz_write_printf(ctx, out, " winding=\"nonzero\"");
fz_trace_matrix(ctx, out, ctm);
- fz_printf(ctx, out, ">\n");
+ fz_write_printf(ctx, out, ">\n");
fz_trace_path(ctx, out, path);
- fz_printf(ctx, out, "</clip_path>\n");
+ fz_write_printf(ctx, out, "</clip_path>\n");
}
static void
fz_trace_clip_stroke_path(fz_context *ctx, fz_device *dev, const fz_path *path, const fz_stroke_state *stroke, const fz_matrix *ctm, const fz_rect *scissor)
{
fz_output *out = ((fz_trace_device*)dev)->out;
- fz_printf(ctx, out, "<clip_stroke_path");
+ fz_write_printf(ctx, out, "<clip_stroke_path");
fz_trace_matrix(ctx, out, ctm);
- fz_printf(ctx, out, ">\n");
+ fz_write_printf(ctx, out, ">\n");
fz_trace_path(ctx, out, path);
- fz_printf(ctx, out, "</clip_stroke_path>\n");
+ fz_write_printf(ctx, out, "</clip_stroke_path>\n");
}
static void
@@ -193,12 +193,12 @@ fz_trace_fill_text(fz_context *ctx, fz_device *dev, const fz_text *text, const f
fz_colorspace *colorspace, const float *color, float alpha)
{
fz_output *out = ((fz_trace_device*)dev)->out;
- fz_printf(ctx, out, "<fill_text");
+ fz_write_printf(ctx, out, "<fill_text");
fz_trace_color(ctx, out, colorspace, color, alpha);
fz_trace_matrix(ctx, out, ctm);
- fz_printf(ctx, out, ">\n");
+ fz_write_printf(ctx, out, ">\n");
fz_trace_text(ctx, out, text);
- fz_printf(ctx, out, "</fill_text>\n");
+ fz_write_printf(ctx, out, "</fill_text>\n");
}
static void
@@ -206,64 +206,64 @@ fz_trace_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text, const
fz_colorspace *colorspace, const float *color, float alpha)
{
fz_output *out = ((fz_trace_device*)dev)->out;
- fz_printf(ctx, out, "<stroke_text");
+ fz_write_printf(ctx, out, "<stroke_text");
fz_trace_color(ctx, out, colorspace, color, alpha);
fz_trace_matrix(ctx, out, ctm);
- fz_printf(ctx, out, ">\n");
+ fz_write_printf(ctx, out, ">\n");
fz_trace_text(ctx, out, text);
- fz_printf(ctx, out, "</stroke_text>\n");
+ fz_write_printf(ctx, out, "</stroke_text>\n");
}
static void
fz_trace_clip_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_matrix *ctm, const fz_rect *scissor)
{
fz_output *out = ((fz_trace_device*)dev)->out;
- fz_printf(ctx, out, "<clip_text");
+ fz_write_printf(ctx, out, "<clip_text");
fz_trace_matrix(ctx, out, ctm);
- fz_printf(ctx, out, ">\n");
+ fz_write_printf(ctx, out, ">\n");
fz_trace_text(ctx, out, text);
- fz_printf(ctx, out, "</clip_text>\n");
+ fz_write_printf(ctx, out, "</clip_text>\n");
}
static void
fz_trace_clip_stroke_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_stroke_state *stroke, const fz_matrix *ctm, const fz_rect *scissor)
{
fz_output *out = ((fz_trace_device*)dev)->out;
- fz_printf(ctx, out, "<clip_stroke_text");
+ fz_write_printf(ctx, out, "<clip_stroke_text");
fz_trace_matrix(ctx, out, ctm);
- fz_printf(ctx, out, ">\n");
+ fz_write_printf(ctx, out, ">\n");
fz_trace_text(ctx, out, text);
- fz_printf(ctx, out, "</clip_stroke_text>\n");
+ fz_write_printf(ctx, out, "</clip_stroke_text>\n");
}
static void
fz_trace_ignore_text(fz_context *ctx, fz_device *dev, const fz_text *text, const fz_matrix *ctm)
{
fz_output *out = ((fz_trace_device*)dev)->out;
- fz_printf(ctx, out, "<ignore_text");
+ fz_write_printf(ctx, out, "<ignore_text");
fz_trace_matrix(ctx, out, ctm);
- fz_printf(ctx, out, ">\n");
+ fz_write_printf(ctx, out, ">\n");
fz_trace_text(ctx, out, text);
- fz_printf(ctx, out, "</ignore_text>\n");
+ fz_write_printf(ctx, out, "</ignore_text>\n");
}
static void
fz_trace_fill_image(fz_context *ctx, fz_device *dev, fz_image *image, const fz_matrix *ctm, float alpha)
{
fz_output *out = ((fz_trace_device*)dev)->out;
- fz_printf(ctx, out, "<fill_image alpha=\"%g\"", alpha);
+ fz_write_printf(ctx, out, "<fill_image alpha=\"%g\"", alpha);
fz_trace_matrix(ctx, out, ctm);
- fz_printf(ctx, out, " width=\"%d\" height=\"%d\"", image->w, image->h);
- fz_printf(ctx, out, "/>\n");
+ fz_write_printf(ctx, out, " width=\"%d\" height=\"%d\"", image->w, image->h);
+ fz_write_printf(ctx, out, "/>\n");
}
static void
fz_trace_fill_shade(fz_context *ctx, fz_device *dev, fz_shade *shade, const fz_matrix *ctm, float alpha)
{
fz_output *out = ((fz_trace_device*)dev)->out;
- fz_printf(ctx, out, "<fill_shade alpha=\"%g\"", alpha);
+ fz_write_printf(ctx, out, "<fill_shade alpha=\"%g\"", alpha);
fz_trace_matrix(ctx, out, ctm);
- fz_printf(ctx, out, "/>\n");
+ fz_write_printf(ctx, out, "/>\n");
}
static void
@@ -271,52 +271,52 @@ fz_trace_fill_image_mask(fz_context *ctx, fz_device *dev, fz_image *image, const
fz_colorspace *colorspace, const float *color, float alpha)
{
fz_output *out = ((fz_trace_device*)dev)->out;
- fz_printf(ctx, out, "<fill_image_mask");
+ fz_write_printf(ctx, out, "<fill_image_mask");
fz_trace_matrix(ctx, out, ctm);
fz_trace_color(ctx, out, colorspace, color, alpha);
- fz_printf(ctx, out, " width=\"%d\" height=\"%d\"", image->w, image->h);
- fz_printf(ctx, out, "/>\n");
+ fz_write_printf(ctx, out, " width=\"%d\" height=\"%d\"", image->w, image->h);
+ fz_write_printf(ctx, out, "/>\n");
}
static void
fz_trace_clip_image_mask(fz_context *ctx, fz_device *dev, fz_image *image, const fz_matrix *ctm, const fz_rect *scissor)
{
fz_output *out = ((fz_trace_device*)dev)->out;
- fz_printf(ctx, out, "<clip_image_mask");
+ fz_write_printf(ctx, out, "<clip_image_mask");
fz_trace_matrix(ctx, out, ctm);
- fz_printf(ctx, out, " width=\"%d\" height=\"%d\"", image->w, image->h);
- fz_printf(ctx, out, "/>\n");
+ fz_write_printf(ctx, out, " width=\"%d\" height=\"%d\"", image->w, image->h);
+ fz_write_printf(ctx, out, "/>\n");
}
static void
fz_trace_pop_clip(fz_context *ctx, fz_device *dev)
{
fz_output *out = ((fz_trace_device*)dev)->out;
- fz_printf(ctx, out, "<pop_clip/>\n");
+ fz_write_printf(ctx, out, "<pop_clip/>\n");
}
static void
fz_trace_begin_mask(fz_context *ctx, fz_device *dev, const fz_rect *bbox, int luminosity, fz_colorspace *colorspace, const float *color)
{
fz_output *out = ((fz_trace_device*)dev)->out;
- fz_printf(ctx, out, "<mask bbox=\"%g %g %g %g\" s=\"%s\"",
+ fz_write_printf(ctx, out, "<mask bbox=\"%g %g %g %g\" s=\"%s\"",
bbox->x0, bbox->y0, bbox->x1, bbox->y1,
luminosity ? "luminosity" : "alpha");
- fz_printf(ctx, out, ">\n");
+ fz_write_printf(ctx, out, ">\n");
}
static void
fz_trace_end_mask(fz_context *ctx, fz_device *dev)
{
fz_output *out = ((fz_trace_device*)dev)->out;
- fz_printf(ctx, out, "</mask>\n");
+ fz_write_printf(ctx, out, "</mask>\n");
}
static void
fz_trace_begin_group(fz_context *ctx, fz_device *dev, const fz_rect *bbox, int isolated, int knockout, int blendmode, float alpha)
{
fz_output *out = ((fz_trace_device*)dev)->out;
- fz_printf(ctx, out, "<group bbox=\"%g %g %g %g\" isolated=\"%d\" knockout=\"%d\" blendmode=\"%s\" alpha=\"%g\">\n",
+ fz_write_printf(ctx, out, "<group bbox=\"%g %g %g %g\" isolated=\"%d\" knockout=\"%d\" blendmode=\"%s\" alpha=\"%g\">\n",
bbox->x0, bbox->y0, bbox->x1, bbox->y1,
isolated, knockout, fz_blendmode_name(blendmode), alpha);
}
@@ -325,19 +325,19 @@ static void
fz_trace_end_group(fz_context *ctx, fz_device *dev)
{
fz_output *out = ((fz_trace_device*)dev)->out;
- fz_printf(ctx, out, "</group>\n");
+ fz_write_printf(ctx, out, "</group>\n");
}
static int
fz_trace_begin_tile(fz_context *ctx, fz_device *dev, const fz_rect *area, const fz_rect *view, float xstep, float ystep, const fz_matrix *ctm, int id)
{
fz_output *out = ((fz_trace_device*)dev)->out;
- fz_printf(ctx, out, "<tile");
- fz_printf(ctx, out, " area=\"%g %g %g %g\"", area->x0, area->y0, area->x1, area->y1);
- fz_printf(ctx, out, " view=\"%g %g %g %g\"", view->x0, view->y0, view->x1, view->y1);
- fz_printf(ctx, out, " xstep=\"%g\" ystep=\"%g\"", xstep, ystep);
+ fz_write_printf(ctx, out, "<tile");
+ fz_write_printf(ctx, out, " area=\"%g %g %g %g\"", area->x0, area->y0, area->x1, area->y1);
+ fz_write_printf(ctx, out, " view=\"%g %g %g %g\"", view->x0, view->y0, view->x1, view->y1);
+ fz_write_printf(ctx, out, " xstep=\"%g\" ystep=\"%g\"", xstep, ystep);
fz_trace_matrix(ctx, out, ctm);
- fz_printf(ctx, out, ">\n");
+ fz_write_printf(ctx, out, ">\n");
return 0;
}
@@ -345,7 +345,7 @@ static void
fz_trace_end_tile(fz_context *ctx, fz_device *dev)
{
fz_output *out = ((fz_trace_device*)dev)->out;
- fz_printf(ctx, out, "</tile>\n");
+ fz_write_printf(ctx, out, "</tile>\n");
}
fz_device *fz_new_trace_device(fz_context *ctx, fz_output *out)
diff --git a/source/fitz/util.c b/source/fitz/util.c
index 8d32346e..346ebaeb 100644
--- a/source/fitz/util.c
+++ b/source/fitz/util.c
@@ -464,11 +464,11 @@ fz_new_buffer_from_stext_page(fz_context *ctx, fz_stext_page *text, const fz_rec
if (need_newline)
{
if (crlf)
- fz_write_buffer_rune(ctx, buf, '\r');
- fz_write_buffer_rune(ctx, buf, '\n');
+ fz_append_byte(ctx, buf, '\r');
+ fz_append_byte(ctx, buf, '\n');
need_newline = 0;
}
- fz_write_buffer_rune(ctx, buf, c);
+ fz_append_rune(ctx, buf, c);
}
}
}
diff --git a/source/fitz/zip.c b/source/fitz/zip.c
index cb51fd6d..6b7dca34 100644
--- a/source/fitz/zip.c
+++ b/source/fitz/zip.c
@@ -27,24 +27,24 @@ fz_write_zip_entry(fz_context *ctx, fz_zip_writer *zip, const char *name, fz_buf
sum = crc32(0, NULL, 0);
sum = crc32(sum, buf->data, (uInt)buf->len);
- fz_write_buffer_int32_le(ctx, zip->central, ZIP_CENTRAL_DIRECTORY_SIG);
- fz_write_buffer_int16_le(ctx, zip->central, 0); /* version made by: MS-DOS */
- fz_write_buffer_int16_le(ctx, zip->central, 20); /* version to extract: 2.0 */
- fz_write_buffer_int16_le(ctx, zip->central, 0); /* general purpose bit flag */
- fz_write_buffer_int16_le(ctx, zip->central, 0); /* compression method: store */
- fz_write_buffer_int16_le(ctx, zip->central, 0); /* TODO: last mod file time */
- fz_write_buffer_int16_le(ctx, zip->central, 0); /* TODO: last mod file date */
- fz_write_buffer_int32_le(ctx, zip->central, sum); /* crc-32 */
- fz_write_buffer_int32_le(ctx, zip->central, (int)buf->len); /* csize */
- fz_write_buffer_int32_le(ctx, zip->central, (int)buf->len); /* usize */
- fz_write_buffer_int16_le(ctx, zip->central, (int)strlen(name)); /* file name length */
- fz_write_buffer_int16_le(ctx, zip->central, 0); /* extra field length */
- fz_write_buffer_int16_le(ctx, zip->central, 0); /* file comment length */
- fz_write_buffer_int16_le(ctx, zip->central, 0); /* disk number start */
- fz_write_buffer_int16_le(ctx, zip->central, 0); /* internal file attributes */
- fz_write_buffer_int32_le(ctx, zip->central, 0); /* external file attributes */
- fz_write_buffer_int32_le(ctx, zip->central, offset); /* relative offset of local header */
- fz_write_buffer(ctx, zip->central, name, strlen(name));
+ fz_append_int32_le(ctx, zip->central, ZIP_CENTRAL_DIRECTORY_SIG);
+ fz_append_int16_le(ctx, zip->central, 0); /* version made by: MS-DOS */
+ fz_append_int16_le(ctx, zip->central, 20); /* version to extract: 2.0 */
+ fz_append_int16_le(ctx, zip->central, 0); /* general purpose bit flag */
+ fz_append_int16_le(ctx, zip->central, 0); /* compression method: store */
+ fz_append_int16_le(ctx, zip->central, 0); /* TODO: last mod file time */
+ fz_append_int16_le(ctx, zip->central, 0); /* TODO: last mod file date */
+ fz_append_int32_le(ctx, zip->central, sum); /* crc-32 */
+ fz_append_int32_le(ctx, zip->central, (int)buf->len); /* csize */
+ fz_append_int32_le(ctx, zip->central, (int)buf->len); /* usize */
+ fz_append_int16_le(ctx, zip->central, (int)strlen(name)); /* file name length */
+ fz_append_int16_le(ctx, zip->central, 0); /* extra field length */
+ fz_append_int16_le(ctx, zip->central, 0); /* file comment length */
+ fz_append_int16_le(ctx, zip->central, 0); /* disk number start */
+ fz_append_int16_le(ctx, zip->central, 0); /* internal file attributes */
+ fz_append_int32_le(ctx, zip->central, 0); /* external file attributes */
+ fz_append_int32_le(ctx, zip->central, offset); /* relative offset of local header */
+ fz_append_string(ctx, zip->central, name);
fz_write_int32_le(ctx, zip->output, ZIP_LOCAL_FILE_SIG);
fz_write_int16_le(ctx, zip->output, 20); /* version to extract: 2.0 */
@@ -57,8 +57,8 @@ fz_write_zip_entry(fz_context *ctx, fz_zip_writer *zip, const char *name, fz_buf
fz_write_int32_le(ctx, zip->output, (int)buf->len); /* usize */
fz_write_int16_le(ctx, zip->output, (int)strlen(name)); /* file name length */
fz_write_int16_le(ctx, zip->output, 0); /* extra field length */
- fz_write(ctx, zip->output, name, strlen(name));
- fz_write(ctx, zip->output, buf->data, buf->len);
+ fz_write_data(ctx, zip->output, name, strlen(name));
+ fz_write_data(ctx, zip->output, buf->data, buf->len);
++zip->count;
}
@@ -68,7 +68,7 @@ fz_close_zip_writer(fz_context *ctx, fz_zip_writer *zip)
{
fz_off_t offset = fz_tell_output(ctx, zip->output);
- fz_write(ctx, zip->output, zip->central->data, zip->central->len);
+ fz_write_data(ctx, zip->output, zip->central->data, zip->central->len);
fz_write_int32_le(ctx, zip->output, ZIP_END_OF_CENTRAL_DIRECTORY_SIG);
fz_write_int16_le(ctx, zip->output, 0); /* number of this disk */
@@ -79,7 +79,7 @@ fz_close_zip_writer(fz_context *ctx, fz_zip_writer *zip)
fz_write_int32_le(ctx, zip->output, (int)offset); /* offset of the central directory */
fz_write_int16_le(ctx, zip->output, 5); /* zip file comment length */
- fz_write(ctx, zip->output, "MuPDF", 5);
+ fz_write_data(ctx, zip->output, "MuPDF", 5);
zip->closed = 1;
}
diff --git a/source/gprf/gprf-skeleton.c b/source/gprf/gprf-skeleton.c
index 23a50fbe..e990e55a 100644
--- a/source/gprf/gprf-skeleton.c
+++ b/source/gprf/gprf-skeleton.c
@@ -49,9 +49,9 @@ fz_save_gproof(fz_context *ctx, const char *pdf_file, fz_document *doc, const ch
}
/* Filenames */
- fz_write(ctx, out, pdf_file, strlen(pdf_file)+1);
- fz_write(ctx, out, print_profile, strlen(print_profile) + 1);
- fz_write(ctx, out, display_profile, strlen(display_profile) + 1);
+ fz_write_data(ctx, out, pdf_file, strlen(pdf_file)+1);
+ fz_write_data(ctx, out, print_profile, strlen(print_profile) + 1);
+ fz_write_data(ctx, out, display_profile, strlen(display_profile) + 1);
}
fz_always(ctx)
{
diff --git a/source/pdf/pdf-appearance.c b/source/pdf/pdf-appearance.c
index c5193ea4..e011fdc9 100644
--- a/source/pdf/pdf-appearance.c
+++ b/source/pdf/pdf-appearance.c
@@ -203,24 +203,24 @@ static void get_text_widget_info(fz_context *ctx, pdf_document *doc, pdf_obj *wi
void pdf_fzbuf_print_da(fz_context *ctx, fz_buffer *fzbuf, pdf_da_info *di)
{
if (di->font_name != NULL && di->font_size != 0)
- fz_buffer_printf(ctx, fzbuf, "/%s %d Tf", di->font_name, di->font_size);
+ fz_append_printf(ctx, fzbuf, "/%s %d Tf", di->font_name, di->font_size);
switch (di->col_size)
{
case 1:
- fz_buffer_printf(ctx, fzbuf, " %f g", di->col[0]);
+ fz_append_printf(ctx, fzbuf, " %f g", di->col[0]);
break;
case 3:
- fz_buffer_printf(ctx, fzbuf, " %f %f %f rg", di->col[0], di->col[1], di->col[2]);
+ fz_append_printf(ctx, fzbuf, " %f %f %f rg", di->col[0], di->col[1], di->col[2]);
break;
case 4:
- fz_buffer_printf(ctx, fzbuf, " %f %f %f %f k", di->col[0], di->col[1], di->col[2], di->col[3]);
+ fz_append_printf(ctx, fzbuf, " %f %f %f %f k", di->col[0], di->col[1], di->col[2], di->col[3]);
break;
default:
- fz_buffer_printf(ctx, fzbuf, " 0 g");
+ fz_append_string(ctx, fzbuf, " 0 g");
break;
}
}
@@ -242,17 +242,17 @@ static void fzbuf_print_color(fz_context *ctx, fz_buffer *fzbuf, pdf_obj *arr, i
switch (pdf_array_len(ctx, arr))
{
case 1:
- fz_buffer_printf(ctx, fzbuf, stroke?"%f G\n":"%f g\n",
+ fz_append_printf(ctx, fzbuf, stroke?"%f G\n":"%f g\n",
pdf_to_real(ctx, pdf_array_get(ctx, arr, 0)) + adj);
break;
case 3:
- fz_buffer_printf(ctx, fzbuf, stroke?"%f %f %f RG\n":"%f %f %f rg\n",
+ fz_append_printf(ctx, fzbuf, stroke?"%f %f %f RG\n":"%f %f %f rg\n",
pdf_to_real(ctx, pdf_array_get(ctx, arr, 0)) + adj,
pdf_to_real(ctx, pdf_array_get(ctx, arr, 1)) + adj,
pdf_to_real(ctx, pdf_array_get(ctx, arr, 2)) + adj);
break;
case 4:
- fz_buffer_printf(ctx, fzbuf, stroke?"%f %f %f %f K\n":"%f %f %f %f k\n",
+ fz_append_printf(ctx, fzbuf, stroke?"%f %f %f %f K\n":"%f %f %f %f k\n",
pdf_to_real(ctx, pdf_array_get(ctx, arr, 0)),
pdf_to_real(ctx, pdf_array_get(ctx, arr, 1)),
pdf_to_real(ctx, pdf_array_get(ctx, arr, 2)),
@@ -266,63 +266,63 @@ static void fzbuf_print_rect_fill(fz_context *ctx, fz_buffer *fzbuf, const fz_re
{
if (clip)
{
- fz_buffer_printf(ctx, fzbuf, fmt_re, clip->x0, clip->y0, clip->x1 - clip->x0, clip->y1 - clip->y0);
- fz_buffer_printf(ctx, fzbuf, fmt_W);
+ fz_append_printf(ctx, fzbuf, fmt_re, clip->x0, clip->y0, clip->x1 - clip->x0, clip->y1 - clip->y0);
+ fz_append_printf(ctx, fzbuf, fmt_W);
}
if (col_size > 0)
{
switch (col_size)
{
case 1:
- fz_buffer_printf(ctx, fzbuf, "%f g\n", col[0]);
+ fz_append_printf(ctx, fzbuf, "%f g\n", col[0]);
break;
case 3:
- fz_buffer_printf(ctx, fzbuf, "%f %f %f rg\n", col[0], col[1], col[2]);
+ fz_append_printf(ctx, fzbuf, "%f %f %f rg\n", col[0], col[1], col[2]);
break;
case 4:
- fz_buffer_printf(ctx, fzbuf, "%f %f %f %f k\n", col[0], col[1], col[2], col[3]);
+ fz_append_printf(ctx, fzbuf, "%f %f %f %f k\n", col[0], col[1], col[2], col[3]);
break;
default:
break;
}
}
if (tm)
- fz_buffer_printf(ctx, fzbuf, fmt_Tm, tm->a, tm->b, tm->c, tm->d, tm->e, tm->f);
+ fz_append_printf(ctx, fzbuf, fmt_Tm, tm->a, tm->b, tm->c, tm->d, tm->e, tm->f);
- fz_buffer_printf(ctx, fzbuf, fmt_re, rect->x0, rect->y0, rect->x1 - rect->x0, rect->y1 - rect->y0);
- fz_buffer_printf(ctx, fzbuf, fmt_f);
+ fz_append_printf(ctx, fzbuf, fmt_re, rect->x0, rect->y0, rect->x1 - rect->x0, rect->y1 - rect->y0);
+ fz_append_printf(ctx, fzbuf, fmt_f);
}
static void fzbuf_print_text(fz_context *ctx, fz_buffer *fzbuf, const fz_rect *clip, pdf_obj *col, font_info *font_rec, const fz_matrix *tm, char *text)
{
- fz_buffer_printf(ctx, fzbuf, fmt_q);
+ fz_append_printf(ctx, fzbuf, fmt_q);
if (clip)
{
- fz_buffer_printf(ctx, fzbuf, fmt_re, clip->x0, clip->y0, clip->x1 - clip->x0, clip->y1 - clip->y0);
- fz_buffer_printf(ctx, fzbuf, fmt_W);
+ fz_append_printf(ctx, fzbuf, fmt_re, clip->x0, clip->y0, clip->x1 - clip->x0, clip->y1 - clip->y0);
+ fz_append_printf(ctx, fzbuf, fmt_W);
if (col)
{
fzbuf_print_color(ctx, fzbuf, col, 0, 0.0);
- fz_buffer_printf(ctx, fzbuf, fmt_f);
+ fz_append_printf(ctx, fzbuf, fmt_f);
}
else
{
- fz_buffer_printf(ctx, fzbuf, fmt_n);
+ fz_append_printf(ctx, fzbuf, fmt_n);
}
}
- fz_buffer_printf(ctx, fzbuf, fmt_BT);
+ fz_append_printf(ctx, fzbuf, fmt_BT);
pdf_fzbuf_print_da(ctx, fzbuf, &font_rec->da_rec);
- fz_buffer_printf(ctx, fzbuf, "\n");
+ fz_append_printf(ctx, fzbuf, "\n");
if (tm)
- fz_buffer_printf(ctx, fzbuf, fmt_Tm, tm->a, tm->b, tm->c, tm->d, tm->e, tm->f);
+ fz_append_printf(ctx, fzbuf, fmt_Tm, tm->a, tm->b, tm->c, tm->d, tm->e, tm->f);
- fz_buffer_print_pdf_string(ctx, fzbuf, text);
- fz_buffer_printf(ctx, fzbuf, fmt_Tj);
- fz_buffer_printf(ctx, fzbuf, fmt_ET);
- fz_buffer_printf(ctx, fzbuf, fmt_Q);
+ fz_append_pdf_string(ctx, fzbuf, text);
+ fz_append_printf(ctx, fzbuf, fmt_Tj);
+ fz_append_printf(ctx, fzbuf, fmt_ET);
+ fz_append_printf(ctx, fzbuf, fmt_Q);
}
static fz_buffer *create_text_buffer(fz_context *ctx, const fz_rect *clip, text_widget_info *info, const fz_matrix *tm, char *text)
@@ -331,9 +331,9 @@ static fz_buffer *create_text_buffer(fz_context *ctx, const fz_rect *clip, text_
fz_try(ctx)
{
- fz_buffer_printf(ctx, fzbuf, fmt_Tx_BMC);
+ fz_append_printf(ctx, fzbuf, fmt_Tx_BMC);
fzbuf_print_text(ctx, fzbuf, clip, info->col, &info->font_rec, tm, text);
- fz_buffer_printf(ctx, fzbuf, fmt_EMC);
+ fz_append_printf(ctx, fzbuf, fmt_EMC);
}
fz_catch(ctx)
{
@@ -558,53 +558,53 @@ static void text_splitter_retry(text_splitter *splitter)
static void fzbuf_print_text_start1(fz_context *ctx, fz_buffer *fzbuf, const fz_rect *clip, pdf_obj *col)
{
- fz_buffer_printf(ctx, fzbuf, fmt_Tx_BMC);
- fz_buffer_printf(ctx, fzbuf, fmt_q);
+ fz_append_printf(ctx, fzbuf, fmt_Tx_BMC);
+ fz_append_printf(ctx, fzbuf, fmt_q);
if (clip)
{
- fz_buffer_printf(ctx, fzbuf, fmt_re, clip->x0, clip->y0, clip->x1 - clip->x0, clip->y1 - clip->y0);
- fz_buffer_printf(ctx, fzbuf, fmt_W);
+ fz_append_printf(ctx, fzbuf, fmt_re, clip->x0, clip->y0, clip->x1 - clip->x0, clip->y1 - clip->y0);
+ fz_append_printf(ctx, fzbuf, fmt_W);
if (col)
{
fzbuf_print_color(ctx, fzbuf, col, 0, 0.0);
- fz_buffer_printf(ctx, fzbuf, fmt_f);
+ fz_append_printf(ctx, fzbuf, fmt_f);
}
else
{
- fz_buffer_printf(ctx, fzbuf, fmt_n);
+ fz_append_printf(ctx, fzbuf, fmt_n);
}
}
}
static void fzbuf_print_text_start2(fz_context *ctx, fz_buffer *fzbuf, font_info *font, const fz_matrix *tm)
{
- fz_buffer_printf(ctx, fzbuf, fmt_BT);
+ fz_append_printf(ctx, fzbuf, fmt_BT);
pdf_fzbuf_print_da(ctx, fzbuf, &font->da_rec);
- fz_buffer_printf(ctx, fzbuf, "\n");
+ fz_append_printf(ctx, fzbuf, "\n");
- fz_buffer_printf(ctx, fzbuf, fmt_Tm, tm->a, tm->b, tm->c, tm->d, tm->e, tm->f);
+ fz_append_printf(ctx, fzbuf, fmt_Tm, tm->a, tm->b, tm->c, tm->d, tm->e, tm->f);
}
static void fzbuf_print_text_end(fz_context *ctx, fz_buffer *fzbuf)
{
- fz_buffer_printf(ctx, fzbuf, fmt_ET);
- fz_buffer_printf(ctx, fzbuf, fmt_Q);
- fz_buffer_printf(ctx, fzbuf, fmt_EMC);
+ fz_append_printf(ctx, fzbuf, fmt_ET);
+ fz_append_printf(ctx, fzbuf, fmt_Q);
+ fz_append_printf(ctx, fzbuf, fmt_EMC);
}
static void fzbuf_print_text_word(fz_context *ctx, fz_buffer *fzbuf, float x, float y, char *text, size_t count)
{
size_t i;
- fz_buffer_printf(ctx, fzbuf, fmt_Td, x, y);
- fz_buffer_printf(ctx, fzbuf, "(");
+ fz_append_printf(ctx, fzbuf, fmt_Td, x, y);
+ fz_append_printf(ctx, fzbuf, "(");
for (i = 0; i < count; i++)
- fz_buffer_printf(ctx, fzbuf, "%c", text[i]);
+ fz_append_printf(ctx, fzbuf, "%c", text[i]);
- fz_buffer_printf(ctx, fzbuf, ") Tj\n");
+ fz_append_printf(ctx, fzbuf, ") Tj\n");
}
static fz_buffer *create_text_appearance(fz_context *ctx, pdf_document *doc, const fz_rect *bbox, const fz_matrix *oldtm, text_widget_info *info, char *text)
@@ -1051,9 +1051,9 @@ static void update_marked_content(fz_context *ctx, pdf_document *doc, pdf_xobjec
if (first)
first = 0;
else
- fz_buffer_printf(ctx, newbuf, " ");
+ fz_append_printf(ctx, newbuf, " ");
- pdf_print_token(ctx, newbuf, tok, &lbuf);
+ pdf_append_token(ctx, newbuf, tok, &lbuf);
if (tok == PDF_TOK_KEYWORD && !strcmp(lbuf.scratch, "BMC"))
break;
}
@@ -1070,8 +1070,8 @@ static void update_marked_content(fz_context *ctx, pdf_document *doc, pdf_xobjec
/* Copy the replacement appearance stream to newbuf */
for (tok = pdf_lex(ctx, str_inner, &lbuf); tok != PDF_TOK_EOF; tok = pdf_lex(ctx, str_inner, &lbuf))
{
- fz_buffer_printf(ctx, newbuf, " ");
- pdf_print_token(ctx, newbuf, tok, &lbuf);
+ fz_append_printf(ctx, newbuf, " ");
+ pdf_append_token(ctx, newbuf, tok, &lbuf);
}
if (bmc_found)
@@ -1086,8 +1086,8 @@ static void update_marked_content(fz_context *ctx, pdf_document *doc, pdf_xobjec
/* Copy the rest of the existing appearance stream to newbuf */
for (tok = pdf_lex(ctx, str_outer, &lbuf); tok != PDF_TOK_EOF; tok = pdf_lex(ctx, str_outer, &lbuf))
{
- fz_buffer_printf(ctx, newbuf, " ");
- pdf_print_token(ctx, newbuf, tok, &lbuf);
+ fz_append_printf(ctx, newbuf, " ");
+ pdf_append_token(ctx, newbuf, tok, &lbuf);
}
}
@@ -1445,9 +1445,9 @@ void pdf_update_pushbutton_appearance(fz_context *ctx, pdf_document *doc, pdf_ob
if (pdf_is_array(ctx, tobj))
{
fzbuf_print_color(ctx, fzbuf, tobj, 0, 0.0);
- fz_buffer_printf(ctx, fzbuf, fmt_re,
+ fz_append_printf(ctx, fzbuf, fmt_re,
rect.x0, rect.y0, rect.x1, rect.y1);
- fz_buffer_printf(ctx, fzbuf, fmt_f);
+ fz_append_printf(ctx, fzbuf, fmt_f);
}
bstyle = get_border_style(ctx, obj);
bwidth = get_border_width(ctx, obj);
@@ -1457,38 +1457,38 @@ void pdf_update_pushbutton_appearance(fz_context *ctx, pdf_document *doc, pdf_ob
btotal += bwidth;
if (bstyle == BS_Beveled)
- fz_buffer_printf(ctx, fzbuf, fmt_g, 1.0);
+ fz_append_printf(ctx, fzbuf, fmt_g, 1.0);
else
- fz_buffer_printf(ctx, fzbuf, fmt_g, 0.33);
- fz_buffer_printf(ctx, fzbuf, fmt_m, bwidth, bwidth);
- fz_buffer_printf(ctx, fzbuf, fmt_l, bwidth, rect.y1 - bwidth);
- fz_buffer_printf(ctx, fzbuf, fmt_l, rect.x1 - bwidth, rect.y1 - bwidth);
- fz_buffer_printf(ctx, fzbuf, fmt_l, rect.x1 - 2 * bwidth, rect.y1 - 2 * bwidth);
- fz_buffer_printf(ctx, fzbuf, fmt_l, 2 * bwidth, rect.y1 - 2 * bwidth);
- fz_buffer_printf(ctx, fzbuf, fmt_l, 2 * bwidth, 2 * bwidth);
- fz_buffer_printf(ctx, fzbuf, fmt_f);
+ fz_append_printf(ctx, fzbuf, fmt_g, 0.33);
+ fz_append_printf(ctx, fzbuf, fmt_m, bwidth, bwidth);
+ fz_append_printf(ctx, fzbuf, fmt_l, bwidth, rect.y1 - bwidth);
+ fz_append_printf(ctx, fzbuf, fmt_l, rect.x1 - bwidth, rect.y1 - bwidth);
+ fz_append_printf(ctx, fzbuf, fmt_l, rect.x1 - 2 * bwidth, rect.y1 - 2 * bwidth);
+ fz_append_printf(ctx, fzbuf, fmt_l, 2 * bwidth, rect.y1 - 2 * bwidth);
+ fz_append_printf(ctx, fzbuf, fmt_l, 2 * bwidth, 2 * bwidth);
+ fz_append_printf(ctx, fzbuf, fmt_f);
if (bstyle == BS_Beveled)
fzbuf_print_color(ctx, fzbuf, tobj, 0, -0.25);
else
- fz_buffer_printf(ctx, fzbuf, fmt_g, 0.66);
- fz_buffer_printf(ctx, fzbuf, fmt_m, rect.x1 - bwidth, rect.y1 - bwidth);
- fz_buffer_printf(ctx, fzbuf, fmt_l, rect.x1 - bwidth, bwidth);
- fz_buffer_printf(ctx, fzbuf, fmt_l, bwidth, bwidth);
- fz_buffer_printf(ctx, fzbuf, fmt_l, 2 * bwidth, 2 * bwidth);
- fz_buffer_printf(ctx, fzbuf, fmt_l, rect.x1 - 2 * bwidth, 2 * bwidth);
- fz_buffer_printf(ctx, fzbuf, fmt_l, rect.x1 - 2 * bwidth, rect.y1 - 2 * bwidth);
- fz_buffer_printf(ctx, fzbuf, fmt_f);
+ fz_append_printf(ctx, fzbuf, fmt_g, 0.66);
+ fz_append_printf(ctx, fzbuf, fmt_m, rect.x1 - bwidth, rect.y1 - bwidth);
+ fz_append_printf(ctx, fzbuf, fmt_l, rect.x1 - bwidth, bwidth);
+ fz_append_printf(ctx, fzbuf, fmt_l, bwidth, bwidth);
+ fz_append_printf(ctx, fzbuf, fmt_l, 2 * bwidth, 2 * bwidth);
+ fz_append_printf(ctx, fzbuf, fmt_l, rect.x1 - 2 * bwidth, 2 * bwidth);
+ fz_append_printf(ctx, fzbuf, fmt_l, rect.x1 - 2 * bwidth, rect.y1 - 2 * bwidth);
+ fz_append_printf(ctx, fzbuf, fmt_f);
}
tobj = pdf_dict_getl(ctx, obj, PDF_NAME_MK, PDF_NAME_BC, NULL);
if (tobj)
{
fzbuf_print_color(ctx, fzbuf, tobj, 1, 0.0);
- fz_buffer_printf(ctx, fzbuf, fmt_w, bwidth);
- fz_buffer_printf(ctx, fzbuf, fmt_re,
+ fz_append_printf(ctx, fzbuf, fmt_w, bwidth);
+ fz_append_printf(ctx, fzbuf, fmt_re,
bwidth/2, bwidth/2,
rect.x1 -bwidth/2, rect.y1 - bwidth/2);
- fz_buffer_printf(ctx, fzbuf, fmt_s);
+ fz_append_printf(ctx, fzbuf, fmt_s);
}
tobj = pdf_dict_getl(ctx, obj, PDF_NAME_MK, PDF_NAME_CA, NULL);
@@ -2305,7 +2305,7 @@ static void insert_signature_appearance_layers(fz_context *ctx, pdf_document *do
pdf_dict_putl(ctx, main_ap, frm, PDF_NAME_Resources, PDF_NAME_XObject, PDF_NAME_FRM, NULL);
fzbuf = fz_new_buffer(ctx, 8);
- fz_buffer_printf(ctx, fzbuf, "/FRM Do");
+ fz_append_printf(ctx, fzbuf, "/FRM Do");
pdf_update_stream(ctx, doc, main_ap, fzbuf, 0);
fz_drop_buffer(ctx, fzbuf);
fzbuf = NULL;
@@ -2313,13 +2313,13 @@ static void insert_signature_appearance_layers(fz_context *ctx, pdf_document *do
pdf_dict_putl(ctx, frm, n0, PDF_NAME_Resources, PDF_NAME_XObject, PDF_NAME_n0, NULL);
pdf_dict_putl(ctx, frm, ap, PDF_NAME_Resources, PDF_NAME_XObject, PDF_NAME_n2, NULL);
fzbuf = fz_new_buffer(ctx, 8);
- fz_buffer_printf(ctx, fzbuf, "q 1 0 0 1 0 0 cm /n0 Do Q q 1 0 0 1 0 0 cm /n2 Do Q");
+ fz_append_printf(ctx, fzbuf, "q 1 0 0 1 0 0 cm /n0 Do Q q 1 0 0 1 0 0 cm /n2 Do Q");
pdf_update_stream(ctx, doc, frm, fzbuf, 0);
fz_drop_buffer(ctx, fzbuf);
fzbuf = NULL;
fzbuf = fz_new_buffer(ctx, 8);
- fz_buffer_printf(ctx, fzbuf, "%% DSBlank");
+ fz_append_printf(ctx, fzbuf, "%% DSBlank");
pdf_update_stream(ctx, doc, n0, fzbuf, 0);
fz_drop_buffer(ctx, fzbuf);
fzbuf = NULL;
@@ -2410,10 +2410,10 @@ void pdf_set_signature_appearance(fz_context *ctx, pdf_document *doc, pdf_annot
/* Display the distinguished name in the right-hand half */
fzbuf = fz_new_buffer(ctx, 256);
- fz_buffer_printf(ctx, fzbuf, "Digitally signed by %s", name);
- fz_buffer_printf(ctx, fzbuf, "\nDN: %s", dn);
+ fz_append_printf(ctx, fzbuf, "Digitally signed by %s", name);
+ fz_append_printf(ctx, fzbuf, "\nDN: %s", dn);
if (date)
- fz_buffer_printf(ctx, fzbuf, "\nDate: %s", date);
+ fz_append_printf(ctx, fzbuf, "\nDate: %s", date);
rect = annot_rect;
rect.x0 = (rect.x0 + rect.x1)/2.0f;
text = fit_text(ctx, &font_rec, fz_string_from_buffer(ctx, fzbuf), &rect);
diff --git a/source/pdf/pdf-crypt.c b/source/pdf/pdf-crypt.c
index aad7324e..8dfeb9ad 100644
--- a/source/pdf/pdf-crypt.c
+++ b/source/pdf/pdf-crypt.c
@@ -1035,22 +1035,22 @@ pdf_print_crypt(fz_context *ctx, fz_output *out, pdf_crypt *crypt)
{
int i;
- fz_printf(ctx, out, "crypt {\n");
+ fz_write_printf(ctx, out, "crypt {\n");
- fz_printf(ctx, out, "\tv=%d length=%d\n", crypt->v, crypt->length);
- fz_printf(ctx, out, "\tstmf method=%d length=%d\n", crypt->stmf.method, crypt->stmf.length);
- fz_printf(ctx, out, "\tstrf method=%d length=%d\n", crypt->strf.method, crypt->strf.length);
- fz_printf(ctx, out, "\tr=%d\n", crypt->r);
+ fz_write_printf(ctx, out, "\tv=%d length=%d\n", crypt->v, crypt->length);
+ fz_write_printf(ctx, out, "\tstmf method=%d length=%d\n", crypt->stmf.method, crypt->stmf.length);
+ fz_write_printf(ctx, out, "\tstrf method=%d length=%d\n", crypt->strf.method, crypt->strf.length);
+ fz_write_printf(ctx, out, "\tr=%d\n", crypt->r);
- fz_printf(ctx, out, "\to=<");
+ fz_write_printf(ctx, out, "\to=<");
for (i = 0; i < 32; i++)
- fz_printf(ctx, out, "%02X", crypt->o[i]);
- fz_printf(ctx, out, ">\n");
+ fz_write_printf(ctx, out, "%02X", crypt->o[i]);
+ fz_write_printf(ctx, out, ">\n");
- fz_printf(ctx, out, "\tu=<");
+ fz_write_printf(ctx, out, "\tu=<");
for (i = 0; i < 32; i++)
- fz_printf(ctx, out, "%02X", crypt->u[i]);
- fz_printf(ctx, out, ">\n");
+ fz_write_printf(ctx, out, "%02X", crypt->u[i]);
+ fz_write_printf(ctx, out, ">\n");
- fz_printf(ctx, out, "}\n");
+ fz_write_printf(ctx, out, "}\n");
}
diff --git a/source/pdf/pdf-device.c b/source/pdf/pdf-device.c
index 702cee83..1857cc4c 100644
--- a/source/pdf/pdf-device.c
+++ b/source/pdf/pdf-device.c
@@ -107,7 +107,7 @@ pdf_dev_stroke_state(fz_context *ctx, pdf_device *pdev, const fz_stroke_state *s
return;
if (!gs->stroke_state || gs->stroke_state->linewidth != stroke_state->linewidth)
{
- fz_buffer_printf(ctx, gs->buf, "%f w\n", stroke_state->linewidth);
+ fz_append_printf(ctx, gs->buf, "%f w\n", stroke_state->linewidth);
}
if (!gs->stroke_state || gs->stroke_state->start_cap != stroke_state->start_cap)
{
@@ -115,18 +115,18 @@ pdf_dev_stroke_state(fz_context *ctx, pdf_device *pdev, const fz_stroke_state *s
/* FIXME: Triangle caps aren't supported in pdf */
if (cap == FZ_LINECAP_TRIANGLE)
cap = FZ_LINECAP_BUTT;
- fz_buffer_printf(ctx, gs->buf, "%d J\n", cap);
+ fz_append_printf(ctx, gs->buf, "%d J\n", cap);
}
if (!gs->stroke_state || gs->stroke_state->linejoin != stroke_state->linejoin)
{
int join = stroke_state->linejoin;
if (join == FZ_LINEJOIN_MITER_XPS)
join = FZ_LINEJOIN_MITER;
- fz_buffer_printf(ctx, gs->buf, "%d j\n", join);
+ fz_append_printf(ctx, gs->buf, "%d j\n", join);
}
if (!gs->stroke_state || gs->stroke_state->miterlimit != stroke_state->miterlimit)
{
- fz_buffer_printf(ctx, gs->buf, "%f M\n", stroke_state->miterlimit);
+ fz_append_printf(ctx, gs->buf, "%f M\n", stroke_state->miterlimit);
}
if (gs->stroke_state == NULL && stroke_state->dash_len == 0)
{}
@@ -135,10 +135,14 @@ pdf_dev_stroke_state(fz_context *ctx, pdf_device *pdev, const fz_stroke_state *s
{
int i;
if (stroke_state->dash_len == 0)
- fz_buffer_printf(ctx, gs->buf, "[");
+ fz_append_byte(ctx, gs->buf, '[');
for (i = 0; i < stroke_state->dash_len; i++)
- fz_buffer_printf(ctx, gs->buf, "%c%f", (i == 0 ? '[' : ' '), stroke_state->dash_list[i]);
- fz_buffer_printf(ctx, gs->buf, "]%f d\n", stroke_state->dash_phase);
+ {
+ if (i > 0)
+ fz_append_byte(ctx, gs->buf, ' ');
+ fz_append_printf(ctx, gs->buf, "%f", stroke_state->dash_list[i]);
+ }
+ fz_append_printf(ctx, gs->buf, "]%f d\n", stroke_state->dash_phase);
}
fz_drop_stroke_state(ctx, gs->stroke_state);
gs->stroke_state = fz_keep_stroke_state(ctx, stroke_state);
@@ -154,32 +158,28 @@ static void
pdf_dev_path_moveto(fz_context *ctx, void *arg, float x, float y)
{
fz_buffer *buf = (fz_buffer *)arg;
-
- fz_buffer_printf(ctx, buf, "%f %f m\n", x, y);
+ fz_append_printf(ctx, buf, "%f %f m\n", x, y);
}
static void
pdf_dev_path_lineto(fz_context *ctx, void *arg, float x, float y)
{
fz_buffer *buf = (fz_buffer *)arg;
-
- fz_buffer_printf(ctx, buf, "%f %f l\n", x, y);
+ fz_append_printf(ctx, buf, "%f %f l\n", x, y);
}
static void
pdf_dev_path_curveto(fz_context *ctx, void *arg, float x1, float y1, float x2, float y2, float x3, float y3)
{
fz_buffer *buf = (fz_buffer *)arg;
-
- fz_buffer_printf(ctx, buf, "%f %f %f %f %f %f c\n", x1, y1, x2, y2, x3, y3);
+ fz_append_printf(ctx, buf, "%f %f %f %f %f %f c\n", x1, y1, x2, y2, x3, y3);
}
static void
pdf_dev_path_close(fz_context *ctx, void *arg)
{
fz_buffer *buf = (fz_buffer *)arg;
-
- fz_buffer_printf(ctx, buf, "h\n");
+ fz_append_printf(ctx, buf, "h\n");
}
static const fz_path_walker pdf_dev_path_proc =
@@ -209,7 +209,7 @@ pdf_dev_ctm(fz_context *ctx, pdf_device *pdev, const fz_matrix *ctm)
fz_invert_matrix(&inverse, &gs->ctm);
fz_concat(&inverse, ctm, &inverse);
gs->ctm = *ctm;
- fz_buffer_printf(ctx, gs->buf, "%M cm\n", &inverse);
+ fz_append_printf(ctx, gs->buf, "%M cm\n", &inverse);
}
static void
@@ -256,22 +256,22 @@ pdf_dev_color(fz_context *ctx, pdf_device *pdev, fz_colorspace *colorspace, cons
switch (cspace + stroke*8)
{
case 1:
- fz_buffer_printf(ctx, gs->buf, "%f g\n", color[0]);
+ fz_append_printf(ctx, gs->buf, "%f g\n", color[0]);
break;
case 3:
- fz_buffer_printf(ctx, gs->buf, "%f %f %f rg\n", color[0], color[1], color[2]);
+ fz_append_printf(ctx, gs->buf, "%f %f %f rg\n", color[0], color[1], color[2]);
break;
case 4:
- fz_buffer_printf(ctx, gs->buf, "%f %f %f %f k\n", color[0], color[1], color[2], color[3]);
+ fz_append_printf(ctx, gs->buf, "%f %f %f %f k\n", color[0], color[1], color[2], color[3]);
break;
case 1+8:
- fz_buffer_printf(ctx, gs->buf, "%f G\n", color[0]);
+ fz_append_printf(ctx, gs->buf, "%f G\n", color[0]);
break;
case 3+8:
- fz_buffer_printf(ctx, gs->buf, "%f %f %f RG\n", color[0], color[1], color[2]);
+ fz_append_printf(ctx, gs->buf, "%f %f %f RG\n", color[0], color[1], color[2]);
break;
case 4+8:
- fz_buffer_printf(ctx, gs->buf, "%f %f %f %f K\n", color[0], color[1], color[2], color[3]);
+ fz_append_printf(ctx, gs->buf, "%f %f %f %f K\n", color[0], color[1], color[2], color[3]);
break;
}
}
@@ -331,7 +331,7 @@ pdf_dev_alpha(fz_context *ctx, pdf_device *pdev, float alpha, int stroke)
}
pdev->num_alphas++;
}
- fz_buffer_printf(ctx, gs->buf, "/Alp%d gs\n", i);
+ fz_append_printf(ctx, gs->buf, "/Alp%d gs\n", i);
}
static int
@@ -386,7 +386,7 @@ pdf_dev_font(fz_context *ctx, pdf_device *pdev, fz_font *font)
gs->font = pdf_dev_add_font_res(ctx, pdev, font);
- fz_buffer_printf(ctx, gs->buf, "/F%d 1 Tf\n", gs->font);
+ fz_append_printf(ctx, gs->buf, "/F%d 1 Tf\n", gs->font);
}
static void
@@ -407,7 +407,7 @@ pdf_dev_push_new_buf(fz_context *ctx, pdf_device *pdev, fz_buffer *buf, void (*o
fz_keep_buffer(ctx, pdev->gstates[pdev->num_gstates].buf);
pdev->gstates[pdev->num_gstates].on_pop = on_pop;
pdev->gstates[pdev->num_gstates].on_pop_arg = on_pop_arg;
- fz_buffer_printf(ctx, pdev->gstates[pdev->num_gstates].buf, "q\n");
+ fz_append_string(ctx, pdev->gstates[pdev->num_gstates].buf, "q\n");
pdev->num_gstates++;
}
@@ -423,7 +423,7 @@ pdf_dev_pop(fz_context *ctx, pdf_device *pdev)
gstate *gs = CURRENT_GSTATE(pdev);
void *arg = gs->on_pop_arg;
- fz_buffer_printf(ctx, gs->buf, "Q\n");
+ fz_append_string(ctx, gs->buf, "Q\n");
if (gs->on_pop)
gs->on_pop(ctx, pdev, arg);
pdev->num_gstates--;
@@ -451,7 +451,7 @@ pdf_dev_text_span(fz_context *ctx, pdf_device *pdev, fz_text_span *span)
fz_invert_matrix(&inv_tm, &tm);
- fz_buffer_printf(ctx, gs->buf, "%M Tm\n[<", &tm);
+ fz_append_printf(ctx, gs->buf, "%M Tm\n[<", &tm);
for (i = 0; i < span->len; ++i)
{
@@ -472,17 +472,17 @@ pdf_dev_text_span(fz_context *ctx, pdf_device *pdev, fz_text_span *span)
if (dx != 0 || dy != 0)
{
if (span->wmode == 0 && dy == 0)
- fz_buffer_printf(ctx, gs->buf, ">%d<", -dx);
+ fz_append_printf(ctx, gs->buf, ">%d<", -dx);
else if (span->wmode == 1 && dx == 0)
- fz_buffer_printf(ctx, gs->buf, ">%d<", -dy);
+ fz_append_printf(ctx, gs->buf, ">%d<", -dy);
else
- fz_buffer_printf(ctx, gs->buf, ">]TJ\n%M Tm\n[<", &tm);
+ fz_append_printf(ctx, gs->buf, ">]TJ\n%M Tm\n[<", &tm);
}
if (fz_font_t3_procs(ctx, span->font))
- fz_buffer_printf(ctx, gs->buf, "%02x", it->gid);
+ fz_append_printf(ctx, gs->buf, "%02x", it->gid);
else
- fz_buffer_printf(ctx, gs->buf, "%04x", it->gid);
+ fz_append_printf(ctx, gs->buf, "%04x", it->gid);
adv = fz_advance_glyph(ctx, span->font, it->gid, span->wmode);
if (span->wmode == 0)
@@ -491,7 +491,7 @@ pdf_dev_text_span(fz_context *ctx, pdf_device *pdev, fz_text_span *span)
fz_pre_translate(&tm, 0, adv);
}
- fz_buffer_printf(ctx, gs->buf, ">]TJ\n");
+ fz_append_string(ctx, gs->buf, ">]TJ\n");
}
static void
@@ -502,7 +502,7 @@ pdf_dev_trm(fz_context *ctx, pdf_device *pdev, int trm)
if (gs->text_rendering_mode == trm)
return;
gs->text_rendering_mode = trm;
- fz_buffer_printf(ctx, gs->buf, "%d Tr\n", trm);
+ fz_append_printf(ctx, gs->buf, "%d Tr\n", trm);
}
static void
@@ -512,7 +512,7 @@ pdf_dev_begin_text(fz_context *ctx, pdf_device *pdev, const fz_matrix *tm, int t
if (!pdev->in_text)
{
gstate *gs = CURRENT_GSTATE(pdev);
- fz_buffer_printf(ctx, gs->buf, "BT\n");
+ fz_append_string(ctx, gs->buf, "BT\n");
pdev->in_text = 1;
}
}
@@ -525,7 +525,7 @@ pdf_dev_end_text(fz_context *ctx, pdf_device *pdev)
if (!pdev->in_text)
return;
pdev->in_text = 0;
- fz_buffer_printf(ctx, gs->buf, "ET\n");
+ fz_append_string(ctx, gs->buf, "ET\n");
}
static int
@@ -640,7 +640,7 @@ pdf_dev_fill_path(fz_context *ctx, fz_device *dev, const fz_path *path, int even
pdf_dev_color(ctx, pdev, colorspace, color, 0);
pdf_dev_ctm(ctx, pdev, ctm);
pdf_dev_path(ctx, pdev, path);
- fz_buffer_printf(ctx, gs->buf, (even_odd ? "f*\n" : "f\n"));
+ fz_append_string(ctx, gs->buf, (even_odd ? "f*\n" : "f\n"));
}
static void
@@ -656,7 +656,7 @@ pdf_dev_stroke_path(fz_context *ctx, fz_device *dev, const fz_path *path, const
pdf_dev_ctm(ctx, pdev, ctm);
pdf_dev_stroke_state(ctx, pdev, stroke);
pdf_dev_path(ctx, pdev, path);
- fz_buffer_printf(ctx, gs->buf, "S\n");
+ fz_append_string(ctx, gs->buf, "S\n");
}
static void
@@ -670,7 +670,7 @@ pdf_dev_clip_path(fz_context *ctx, fz_device *dev, const fz_path *path, int even
pdf_dev_ctm(ctx, pdev, ctm);
pdf_dev_path(ctx, pdev, path);
gs = CURRENT_GSTATE(pdev);
- fz_buffer_printf(ctx, gs->buf, (even_odd ? "W* n\n" : "W n\n"));
+ fz_append_string(ctx, gs->buf, (even_odd ? "W* n\n" : "W n\n"));
}
static void
@@ -688,7 +688,7 @@ pdf_dev_clip_stroke_path(fz_context *ctx, fz_device *dev, const fz_path *path, c
pdf_dev_ctm(ctx, pdev, ctm);
pdf_dev_path(ctx, pdev, path);
gs = CURRENT_GSTATE(pdev);
- fz_buffer_printf(ctx, gs->buf, "W n\n");
+ fz_append_string(ctx, gs->buf, "W n\n");
}
static void
@@ -823,7 +823,7 @@ pdf_dev_fill_image(fz_context *ctx, fz_device *dev, fz_image *image, const fz_ma
fz_pre_scale(&local_ctm, 1, -1);
fz_pre_translate(&local_ctm, 0, -1);
pdf_dev_ctm(ctx, pdev, &local_ctm);
- fz_buffer_printf(ctx, gs->buf, "/Img%d Do\n", pdf_to_num(ctx, im_res));
+ fz_append_printf(ctx, gs->buf, "/Img%d Do\n", pdf_to_num(ctx, im_res));
/* Possibly add to page resources */
pdf_dev_add_image_res(ctx, dev, im_res);
@@ -855,7 +855,7 @@ pdf_dev_fill_image_mask(fz_context *ctx, fz_device *dev, fz_image *image, const
fz_warn(ctx, "pdf_add_image: problem adding image resource");
return;
}
- fz_buffer_printf(ctx, gs->buf, "q\n");
+ fz_append_string(ctx, gs->buf, "q\n");
pdf_dev_alpha(ctx, pdev, alpha, 0);
pdf_dev_color(ctx, pdev, colorspace, color, 0);
@@ -863,7 +863,7 @@ pdf_dev_fill_image_mask(fz_context *ctx, fz_device *dev, fz_image *image, const
fz_pre_scale(&local_ctm, 1, -1);
fz_pre_translate(&local_ctm, 0, -1);
pdf_dev_ctm(ctx, pdev, &local_ctm);
- fz_buffer_printf(ctx, gs->buf, "/Img%d Do Q\n", pdf_to_num(ctx, im_res));
+ fz_append_printf(ctx, gs->buf, "/Img%d Do Q\n", pdf_to_num(ctx, im_res));
/* Possibly add to page resources */
pdf_dev_add_image_res(ctx, dev, im_res);
@@ -937,7 +937,7 @@ pdf_dev_begin_mask(fz_context *ctx, fz_device *dev, const fz_rect *bbox, int lum
pdf_drop_obj(ctx, egs_ref);
}
gs = CURRENT_GSTATE(pdev);
- fz_buffer_printf(ctx, gs->buf, "/SM%d gs\n", pdev->num_smasks-1);
+ fz_append_printf(ctx, gs->buf, "/SM%d gs\n", pdev->num_smasks-1);
}
fz_always(ctx)
{
@@ -966,13 +966,13 @@ pdf_dev_end_mask(fz_context *ctx, fz_device *dev)
/* Here we do part of the pop, but not all of it. */
pdf_dev_end_text(ctx, pdev);
- fz_buffer_printf(ctx, buf, "Q\n");
+ fz_append_string(ctx, buf, "Q\n");
pdf_update_stream(ctx, doc, form_ref, buf, 0);
fz_drop_buffer(ctx, buf);
gs->buf = fz_keep_buffer(ctx, gs[-1].buf);
gs->on_pop_arg = NULL;
pdf_drop_obj(ctx, form_ref);
- fz_buffer_printf(ctx, gs->buf, "q\n");
+ fz_append_string(ctx, gs->buf, "q\n");
}
static void
@@ -1006,7 +1006,7 @@ pdf_dev_begin_group(fz_context *ctx, fz_device *dev, const fz_rect *bbox, int is
/* Add the call to this group */
gs = CURRENT_GSTATE(pdev);
- fz_buffer_printf(ctx, gs->buf, "/BlendMode%d gs /Fm%d Do\n", blendmode, num);
+ fz_append_printf(ctx, gs->buf, "/BlendMode%d gs /Fm%d Do\n", blendmode, num);
/* Now, everything we get until the end of group needs to go into a
* new buffer, which will be the stream contents for the form. */
@@ -1133,7 +1133,7 @@ fz_device *pdf_new_pdf_device(fz_context *ctx, pdf_document *doc, const fz_matri
dev->max_gstates = 1;
if (topctm != &fz_identity)
- fz_buffer_printf(ctx, buf, "%M cm\n", topctm);
+ fz_append_printf(ctx, buf, "%M cm\n", topctm);
}
fz_catch(ctx)
{
diff --git a/source/pdf/pdf-font.c b/source/pdf/pdf-font.c
index e3be140a..3cced0d8 100644
--- a/source/pdf/pdf-font.c
+++ b/source/pdf/pdf-font.c
@@ -960,7 +960,7 @@ hail_mary_cmp_key(fz_context *ctx, void *k0, void *k1)
static void
hail_mary_print_key(fz_context *ctx, fz_output *out, void *key_)
{
- fz_printf(ctx, out, "hail mary ");
+ fz_write_printf(ctx, out, "hail mary ");
}
static fz_store_type hail_mary_store_type =
@@ -1436,30 +1436,30 @@ pdf_print_font(fz_context *ctx, fz_output *out, pdf_font_desc *fontdesc)
{
int i;
- fz_printf(ctx, out, "fontdesc {\n");
+ fz_write_printf(ctx, out, "fontdesc {\n");
if (fontdesc->font->ft_face)
- fz_printf(ctx, out, "\tfreetype font\n");
+ fz_write_printf(ctx, out, "\tfreetype font\n");
if (fontdesc->font->t3procs)
- fz_printf(ctx, out, "\ttype3 font\n");
+ fz_write_printf(ctx, out, "\ttype3 font\n");
- fz_printf(ctx, out, "\twmode %d\n", fontdesc->wmode);
- fz_printf(ctx, out, "\tDW %d\n", fontdesc->dhmtx.w);
+ fz_write_printf(ctx, out, "\twmode %d\n", fontdesc->wmode);
+ fz_write_printf(ctx, out, "\tDW %d\n", fontdesc->dhmtx.w);
- fz_printf(ctx, out, "\tW {\n");
+ fz_write_printf(ctx, out, "\tW {\n");
for (i = 0; i < fontdesc->hmtx_len; i++)
- fz_printf(ctx, out, "\t\t<%04x> <%04x> %d\n",
+ fz_write_printf(ctx, out, "\t\t<%04x> <%04x> %d\n",
fontdesc->hmtx[i].lo, fontdesc->hmtx[i].hi, fontdesc->hmtx[i].w);
- fz_printf(ctx, out, "\t}\n");
+ fz_write_printf(ctx, out, "\t}\n");
if (fontdesc->wmode)
{
- fz_printf(ctx, out, "\tDW2 [%d %d]\n", fontdesc->dvmtx.y, fontdesc->dvmtx.w);
- fz_printf(ctx, out, "\tW2 {\n");
+ fz_write_printf(ctx, out, "\tDW2 [%d %d]\n", fontdesc->dvmtx.y, fontdesc->dvmtx.w);
+ fz_write_printf(ctx, out, "\tW2 {\n");
for (i = 0; i < fontdesc->vmtx_len; i++)
- fz_printf(ctx, out, "\t\t<%04x> <%04x> %d %d %d\n", fontdesc->vmtx[i].lo, fontdesc->vmtx[i].hi,
+ fz_write_printf(ctx, out, "\t\t<%04x> <%04x> %d %d %d\n", fontdesc->vmtx[i].lo, fontdesc->vmtx[i].hi,
fontdesc->vmtx[i].x, fontdesc->vmtx[i].y, fontdesc->vmtx[i].w);
- fz_printf(ctx, out, "\t}\n");
+ fz_write_printf(ctx, out, "\t}\n");
}
}
@@ -1935,15 +1935,15 @@ pdf_add_to_unicode(fz_context *ctx, pdf_document *doc, fz_font *font)
fz_try(ctx)
{
/* Header boiler plate */
- fz_buffer_printf(ctx, buf, "/CIDInit /ProcSet findresource begin\n");
- fz_buffer_printf(ctx, buf, "12 dict begin\n");
- fz_buffer_printf(ctx, buf, "begincmap\n");
- fz_buffer_printf(ctx, buf, "/CIDSystemInfo <</Registry(Adobe)/Ordering(UCS)/Supplement 0>> def\n");
- fz_buffer_printf(ctx, buf, "/CMapName /Adobe-Identity-UCS def\n");
- fz_buffer_printf(ctx, buf, "/CMapType 2 def\n");
- fz_buffer_printf(ctx, buf, "1 begincodespacerange\n");
- fz_buffer_printf(ctx, buf, "<0000> <FFFF>\n");
- fz_buffer_printf(ctx, buf, "endcodespacerange\n");
+ fz_append_string(ctx, buf, "/CIDInit /ProcSet findresource begin\n");
+ fz_append_string(ctx, buf, "12 dict begin\n");
+ fz_append_string(ctx, buf, "begincmap\n");
+ fz_append_string(ctx, buf, "/CIDSystemInfo <</Registry(Adobe)/Ordering(UCS)/Supplement 0>> def\n");
+ fz_append_string(ctx, buf, "/CMapName /Adobe-Identity-UCS def\n");
+ fz_append_string(ctx, buf, "/CMapType 2 def\n");
+ fz_append_string(ctx, buf, "1 begincodespacerange\n");
+ fz_append_string(ctx, buf, "<0000> <FFFF>\n");
+ fz_append_string(ctx, buf, "endcodespacerange\n");
/* Note to have a valid CMap, the number of entries in table set can
* not exceed 100, so we have to break into multiple tables. Also, note
@@ -1957,11 +1957,11 @@ pdf_add_to_unicode(fz_context *ctx, pdf_document *doc, fz_font *font)
int count = 0;
if (num_seq > 100)
{
- fz_buffer_printf(ctx, buf, "100 beginbfrange\n");
+ fz_append_string(ctx, buf, "100 beginbfrange\n");
num_seq -= 100;
}
else
- fz_buffer_printf(ctx, buf, "%d beginbfrange\n", num_seq);
+ fz_append_printf(ctx, buf, "%d beginbfrange\n", num_seq);
for (k = 0; k < face->num_glyphs; k += n)
{
n = next_range(table, face->num_glyphs, k);
@@ -1969,21 +1969,21 @@ pdf_add_to_unicode(fz_context *ctx, pdf_document *doc, fz_font *font)
{
if (count == 100)
{
- fz_buffer_printf(ctx, buf, "endbfrange\n");
+ fz_append_string(ctx, buf, "endbfrange\n");
if (num_seq > 100)
{
- fz_buffer_printf(ctx, buf, "100 beginbfrange\n");
+ fz_append_string(ctx, buf, "100 beginbfrange\n");
num_seq -= 100;
}
else
- fz_buffer_printf(ctx, buf, "%d beginbfrange\n", num_seq);
+ fz_append_printf(ctx, buf, "%d beginbfrange\n", num_seq);
count = 0;
}
- fz_buffer_printf(ctx, buf, "<%04x> <%04x> <%04x>\n", k, k+n-1, table[k]);
+ fz_append_printf(ctx, buf, "<%04x> <%04x> <%04x>\n", k, k+n-1, table[k]);
++count;
}
}
- fz_buffer_printf(ctx, buf, "endbfrange\n");
+ fz_append_string(ctx, buf, "endbfrange\n");
}
/* Then the singles */
@@ -1992,11 +1992,11 @@ pdf_add_to_unicode(fz_context *ctx, pdf_document *doc, fz_font *font)
int count = 0;
if (num_chr > 100)
{
- fz_buffer_printf(ctx, buf, "100 beginbfchar\n");
+ fz_append_string(ctx, buf, "100 beginbfchar\n");
num_chr -= 100;
}
else
- fz_buffer_printf(ctx, buf, "%d beginbfchar\n", num_chr);
+ fz_append_printf(ctx, buf, "%d beginbfchar\n", num_chr);
for (k = 0; k < face->num_glyphs; k += n)
{
n = next_range(table, face->num_glyphs, k);
@@ -2004,27 +2004,27 @@ pdf_add_to_unicode(fz_context *ctx, pdf_document *doc, fz_font *font)
{
if (count == 100)
{
- fz_buffer_printf(ctx, buf, "endbfchar\n");
+ fz_append_string(ctx, buf, "endbfchar\n");
if (num_chr > 100)
{
- fz_buffer_printf(ctx, buf, "100 beginbfchar\n");
+ fz_append_string(ctx, buf, "100 beginbfchar\n");
num_chr -= 100;
}
else
- fz_buffer_printf(ctx, buf, "%d beginbfchar\n", num_chr);
+ fz_append_printf(ctx, buf, "%d beginbfchar\n", num_chr);
count = 0;
}
- fz_buffer_printf(ctx, buf, "<%04x> <%04x>\n", k, table[k]);
+ fz_append_printf(ctx, buf, "<%04x> <%04x>\n", k, table[k]);
++count;
}
}
- fz_buffer_printf(ctx, buf, "endbfchar\n");
+ fz_append_string(ctx, buf, "endbfchar\n");
}
/* Trailer boiler plate */
- fz_buffer_printf(ctx, buf, "endcmap\n");
- fz_buffer_printf(ctx, buf, "CMapName currentdict /CMap defineresource pop\n");
- fz_buffer_printf(ctx, buf, "end\nend\n");
+ fz_append_string(ctx, buf, "endcmap\n");
+ fz_append_string(ctx, buf, "CMapName currentdict /CMap defineresource pop\n");
+ fz_append_string(ctx, buf, "end\nend\n");
fobj = pdf_new_dict(ctx, doc, 3);
fref = pdf_add_object(ctx, doc, fobj);
diff --git a/source/pdf/pdf-function.c b/source/pdf/pdf-function.c
index db76ba4b..8dda0cb2 100644
--- a/source/pdf/pdf-function.c
+++ b/source/pdf/pdf-function.c
@@ -114,7 +114,7 @@ pdf_print_ps_stack(fz_context *ctx, fz_output *out, ps_stack *st)
{
int i;
- fz_printf(ctx, out, "stack:");
+ fz_write_printf(ctx, out, "stack:");
for (i = 0; i < st->sp; i++)
{
@@ -122,22 +122,22 @@ pdf_print_ps_stack(fz_context *ctx, fz_output *out, ps_stack *st)
{
case PS_BOOL:
if (st->stack[i].u.b)
- fz_printf(ctx, out, " true");
+ fz_write_printf(ctx, out, " true");
else
- fz_printf(ctx, out, " false");
+ fz_write_printf(ctx, out, " false");
break;
case PS_INT:
- fz_printf(ctx, out, " %d", st->stack[i].u.i);
+ fz_write_printf(ctx, out, " %d", st->stack[i].u.i);
break;
case PS_REAL:
- fz_printf(ctx, out, " %g", st->stack[i].u.f);
+ fz_write_printf(ctx, out, " %g", st->stack[i].u.f);
break;
}
}
- fz_printf(ctx, out, "\n");
+ fz_write_printf(ctx, out, "\n");
}
static void
@@ -1390,12 +1390,12 @@ pdf_debug_indent(fz_context *ctx, fz_output *out, char *prefix, int level, char
{
int i;
- fz_puts(ctx, out, prefix);
+ fz_write_string(ctx, out, prefix);
for (i = 0; i < level; i++)
- fz_putc(ctx, out, '\t');
+ fz_write_byte(ctx, out, '\t');
- fz_puts(ctx, out, suffix);
+ fz_write_string(ctx, out, suffix);
}
static void
@@ -1510,78 +1510,78 @@ pdf_debug_function_imp(fz_context *ctx, fz_output *out, fz_function *func_, int
}
pdf_debug_indent(ctx, out, "\n", level, "");
- fz_printf(ctx, out, "%d input -> %d output\n", func->base.m, func->base.n);
+ fz_write_printf(ctx, out, "%d input -> %d output\n", func->base.m, func->base.n);
pdf_debug_indent(ctx, out, "", level, "domain ");
for (i = 0; i < func->base.m; i++)
- fz_printf(ctx, out, "%g %g ", func->domain[i][0], func->domain[i][1]);
- fz_printf(ctx, out, "\n");
+ fz_write_printf(ctx, out, "%g %g ", func->domain[i][0], func->domain[i][1]);
+ fz_write_printf(ctx, out, "\n");
if (func->has_range)
{
pdf_debug_indent(ctx, out, "", level, "range ");
for (i = 0; i < func->base.n; i++)
- fz_printf(ctx, out, "%g %g ", func->range[i][0], func->range[i][1]);
- fz_printf(ctx, out, "\n");
+ fz_write_printf(ctx, out, "%g %g ", func->range[i][0], func->range[i][1]);
+ fz_write_printf(ctx, out, "\n");
}
switch (func->type)
{
case SAMPLE:
pdf_debug_indent(ctx, out, "", level, "");
- fz_printf(ctx, out, "bps: %d\n", func->u.sa.bps);
+ fz_write_printf(ctx, out, "bps: %d\n", func->u.sa.bps);
pdf_debug_indent(ctx, out, "", level, "");
- fz_printf(ctx, out, "size: [ ");
+ fz_write_printf(ctx, out, "size: [ ");
for (i = 0; i < func->base.m; i++)
- fz_printf(ctx, out, "%d ", func->u.sa.size[i]);
- fz_printf(ctx, out, "]\n");
+ fz_write_printf(ctx, out, "%d ", func->u.sa.size[i]);
+ fz_write_printf(ctx, out, "]\n");
pdf_debug_indent(ctx, out, "", level, "");
- fz_printf(ctx, out, "encode: [ ");
+ fz_write_printf(ctx, out, "encode: [ ");
for (i = 0; i < func->base.m; i++)
- fz_printf(ctx, out, "%g %g ", func->u.sa.encode[i][0], func->u.sa.encode[i][1]);
- fz_printf(ctx, out, "]\n");
+ fz_write_printf(ctx, out, "%g %g ", func->u.sa.encode[i][0], func->u.sa.encode[i][1]);
+ fz_write_printf(ctx, out, "]\n");
pdf_debug_indent(ctx, out, "", level, "");
- fz_printf(ctx, out, "decode: [ ");
+ fz_write_printf(ctx, out, "decode: [ ");
for (i = 0; i < func->base.m; i++)
- fz_printf(ctx, out, "%g %g ", func->u.sa.decode[i][0], func->u.sa.decode[i][1]);
- fz_printf(ctx, out, "]\n");
+ fz_write_printf(ctx, out, "%g %g ", func->u.sa.decode[i][0], func->u.sa.decode[i][1]);
+ fz_write_printf(ctx, out, "]\n");
break;
case EXPONENTIAL:
pdf_debug_indent(ctx, out, "", level, "");
- fz_printf(ctx, out, "n: %g\n", func->u.e.n);
+ fz_write_printf(ctx, out, "n: %g\n", func->u.e.n);
pdf_debug_indent(ctx, out, "", level, "");
- fz_printf(ctx, out, "c0: [ ");
+ fz_write_printf(ctx, out, "c0: [ ");
for (i = 0; i < func->base.n; i++)
- fz_printf(ctx, out, "%g ", func->u.e.c0[i]);
- fz_printf(ctx, out, "]\n");
+ fz_write_printf(ctx, out, "%g ", func->u.e.c0[i]);
+ fz_write_printf(ctx, out, "]\n");
pdf_debug_indent(ctx, out, "", level, "");
- fz_printf(ctx, out, "c1: [ ");
+ fz_write_printf(ctx, out, "c1: [ ");
for (i = 0; i < func->base.n; i++)
- fz_printf(ctx, out, "%g ", func->u.e.c1[i]);
- fz_printf(ctx, out, "]\n");
+ fz_write_printf(ctx, out, "%g ", func->u.e.c1[i]);
+ fz_write_printf(ctx, out, "]\n");
break;
case STITCHING:
pdf_debug_indent(ctx, out, "", level, "");
- fz_printf(ctx, out, "%d functions\n", func->u.st.k);
+ fz_write_printf(ctx, out, "%d functions\n", func->u.st.k);
pdf_debug_indent(ctx, out, "", level, "");
- fz_printf(ctx, out, "bounds: [ ");
+ fz_write_printf(ctx, out, "bounds: [ ");
for (i = 0; i < func->u.st.k - 1; i++)
- fz_printf(ctx, out, "%g ", func->u.st.bounds[i]);
- fz_printf(ctx, out, "]\n");
+ fz_write_printf(ctx, out, "%g ", func->u.st.bounds[i]);
+ fz_write_printf(ctx, out, "]\n");
pdf_debug_indent(ctx, out, "", level, "");
- fz_printf(ctx, out, "encode: [ ");
+ fz_write_printf(ctx, out, "encode: [ ");
for (i = 0; i < func->u.st.k * 2; i++)
- fz_printf(ctx, out, "%g ", func->u.st.encode[i]);
- fz_printf(ctx, out, "]\n");
+ fz_write_printf(ctx, out, "%g ", func->u.st.encode[i]);
+ fz_write_printf(ctx, out, "]\n");
for (i = 0; i < func->u.st.k; i++)
pdf_debug_function_imp(ctx, out, func->u.st.funcs[i], level);
@@ -1589,7 +1589,7 @@ pdf_debug_function_imp(fz_context *ctx, fz_output *out, fz_function *func_, int
case POSTSCRIPT:
pdf_debug_ps_func_code(ctx, out, func->u.p.code, func->u.p.code, level);
- fz_printf(ctx, out, "\n");
+ fz_write_printf(ctx, out, "\n");
break;
}
diff --git a/source/pdf/pdf-lex.c b/source/pdf/pdf-lex.c
index ec66f56e..6a9ca906 100644
--- a/source/pdf/pdf-lex.c
+++ b/source/pdf/pdf-lex.c
@@ -615,47 +615,45 @@ pdf_lex_no_string(fz_context *ctx, fz_stream *f, pdf_lexbuf *buf)
}
}
-void pdf_print_token(fz_context *ctx, fz_buffer *fzbuf, int tok, pdf_lexbuf *buf)
+void pdf_append_token(fz_context *ctx, fz_buffer *fzbuf, int tok, pdf_lexbuf *buf)
{
switch (tok)
{
case PDF_TOK_NAME:
- fz_buffer_printf(ctx, fzbuf, "/%s", buf->scratch);
+ fz_append_printf(ctx, fzbuf, "/%s", buf->scratch);
break;
case PDF_TOK_STRING:
if (buf->len >= buf->size)
pdf_lexbuf_grow(ctx, buf);
buf->scratch[buf->len] = 0;
- fz_buffer_print_pdf_string(ctx, fzbuf, buf->scratch);
+ fz_append_pdf_string(ctx, fzbuf, buf->scratch);
break;
case PDF_TOK_OPEN_DICT:
- fz_buffer_printf(ctx, fzbuf, "<<");
+ fz_append_string(ctx, fzbuf, "<<");
break;
case PDF_TOK_CLOSE_DICT:
- fz_buffer_printf(ctx, fzbuf, ">>");
+ fz_append_string(ctx, fzbuf, ">>");
break;
case PDF_TOK_OPEN_ARRAY:
- fz_buffer_printf(ctx, fzbuf, "[");
+ fz_append_byte(ctx, fzbuf, '[');
break;
case PDF_TOK_CLOSE_ARRAY:
- fz_buffer_printf(ctx, fzbuf, "]");
+ fz_append_byte(ctx, fzbuf, ']');
break;
case PDF_TOK_OPEN_BRACE:
- fz_buffer_printf(ctx, fzbuf, "{");
+ fz_append_byte(ctx, fzbuf, '{');
break;
case PDF_TOK_CLOSE_BRACE:
- fz_buffer_printf(ctx, fzbuf, "}");
+ fz_append_byte(ctx, fzbuf, '}');
break;
case PDF_TOK_INT:
- fz_buffer_printf(ctx, fzbuf, "%d", buf->i);
+ fz_append_printf(ctx, fzbuf, "%d", buf->i);
break;
case PDF_TOK_REAL:
- {
- fz_buffer_printf(ctx, fzbuf, "%g", buf->f);
- }
+ fz_append_printf(ctx, fzbuf, "%g", buf->f);
break;
default:
- fz_buffer_printf(ctx, fzbuf, "%s", buf->scratch);
+ fz_append_data(ctx, fzbuf, buf->scratch, buf->len);
break;
}
}
diff --git a/source/pdf/pdf-object.c b/source/pdf/pdf-object.c
index 736fe88b..86a204a6 100644
--- a/source/pdf/pdf-object.c
+++ b/source/pdf/pdf-object.c
@@ -2132,13 +2132,13 @@ int pdf_print_obj(fz_context *ctx, fz_output *out, pdf_obj *obj, int tight)
if ((n + 1) < sizeof buf)
{
pdf_sprint_obj(ctx, buf, sizeof buf, obj, tight);
- fz_write(ctx, out, buf, n);
+ fz_write_data(ctx, out, buf, n);
}
else
{
ptr = fz_malloc(ctx, n + 1);
pdf_sprint_obj(ctx, ptr, n + 1, obj, tight);
- fz_write(ctx, out, ptr, n);
+ fz_write_data(ctx, out, ptr, n);
fz_free(ctx, ptr);
}
return n;
diff --git a/source/pdf/pdf-op-buffer.c b/source/pdf/pdf-op-buffer.c
index 1bfe982a..b916ea3f 100644
--- a/source/pdf/pdf-op-buffer.c
+++ b/source/pdf/pdf-op-buffer.c
@@ -17,7 +17,7 @@ pdf_out_w(fz_context *ctx, pdf_processor *proc, float linewidth)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
if (!((pdf_output_processor*)proc)->extgstate)
- fz_printf(ctx, out, "%f w\n", linewidth);
+ fz_write_printf(ctx, out, "%f w\n", linewidth);
}
static void
@@ -25,7 +25,7 @@ pdf_out_j(fz_context *ctx, pdf_processor *proc, int linejoin)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
if (!((pdf_output_processor*)proc)->extgstate)
- fz_printf(ctx, out, "%d j\n", linejoin);
+ fz_write_printf(ctx, out, "%d j\n", linejoin);
}
static void
@@ -33,7 +33,7 @@ pdf_out_J(fz_context *ctx, pdf_processor *proc, int linecap)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
if (!((pdf_output_processor*)proc)->extgstate)
- fz_printf(ctx, out, "%d J\n", linecap);
+ fz_write_printf(ctx, out, "%d J\n", linecap);
}
static void
@@ -41,7 +41,7 @@ pdf_out_M(fz_context *ctx, pdf_processor *proc, float a)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
if (!((pdf_output_processor*)proc)->extgstate)
- fz_printf(ctx, out, "%f M\n", a);
+ fz_write_printf(ctx, out, "%f M\n", a);
}
static void
@@ -51,7 +51,7 @@ pdf_out_d(fz_context *ctx, pdf_processor *proc, pdf_obj *array, float phase)
if (!((pdf_output_processor*)proc)->extgstate)
{
pdf_print_obj(ctx, out, array, 1);
- fz_printf(ctx, out, " %f d\n", phase);
+ fz_write_printf(ctx, out, " %f d\n", phase);
}
}
@@ -60,7 +60,7 @@ pdf_out_ri(fz_context *ctx, pdf_processor *proc, const char *intent)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
if (!((pdf_output_processor*)proc)->extgstate)
- fz_printf(ctx, out, "/%s ri\n", intent);
+ fz_write_printf(ctx, out, "/%s ri\n", intent);
}
static void
@@ -68,7 +68,7 @@ pdf_out_i(fz_context *ctx, pdf_processor *proc, float flatness)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
if (!((pdf_output_processor*)proc)->extgstate)
- fz_printf(ctx, out, "%f i\n", flatness);
+ fz_write_printf(ctx, out, "%f i\n", flatness);
}
static void
@@ -76,7 +76,7 @@ pdf_out_gs_begin(fz_context *ctx, pdf_processor *proc, const char *name, pdf_obj
{
fz_output *out = ((pdf_output_processor*)proc)->out;
((pdf_output_processor*)proc)->extgstate = 1;
- fz_printf(ctx, out, "/%s gs\n", name);
+ fz_write_printf(ctx, out, "/%s gs\n", name);
}
static void
@@ -91,21 +91,21 @@ static void
pdf_out_q(fz_context *ctx, pdf_processor *proc)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "q\n");
+ fz_write_printf(ctx, out, "q\n");
}
static void
pdf_out_Q(fz_context *ctx, pdf_processor *proc)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "Q\n");
+ fz_write_printf(ctx, out, "Q\n");
}
static void
pdf_out_cm(fz_context *ctx, pdf_processor *proc, float a, float b, float c, float d, float e, float f)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "%f %f %f %f %f %f cm\n", a, b, c, d, e, f);
+ fz_write_printf(ctx, out, "%f %f %f %f %f %f cm\n", a, b, c, d, e, f);
}
/* path construction */
@@ -114,49 +114,49 @@ static void
pdf_out_m(fz_context *ctx, pdf_processor *proc, float x, float y)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "%f %f m\n", x, y);
+ fz_write_printf(ctx, out, "%f %f m\n", x, y);
}
static void
pdf_out_l(fz_context *ctx, pdf_processor *proc, float x, float y)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "%f %f l\n", x, y);
+ fz_write_printf(ctx, out, "%f %f l\n", x, y);
}
static void
pdf_out_c(fz_context *ctx, pdf_processor *proc, float x1, float y1, float x2, float y2, float x3, float y3)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "%f %f %f %f %f %f c\n", x1, y1, x2, y2, x3, y3);
+ fz_write_printf(ctx, out, "%f %f %f %f %f %f c\n", x1, y1, x2, y2, x3, y3);
}
static void
pdf_out_v(fz_context *ctx, pdf_processor *proc, float x2, float y2, float x3, float y3)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "%f %f %f %f v\n", x2, y2, x3, y3);
+ fz_write_printf(ctx, out, "%f %f %f %f v\n", x2, y2, x3, y3);
}
static void
pdf_out_y(fz_context *ctx, pdf_processor *proc, float x1, float y1, float x3, float y3)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "%f %f %f %f y\n", x1, y1, x3, y3);
+ fz_write_printf(ctx, out, "%f %f %f %f y\n", x1, y1, x3, y3);
}
static void
pdf_out_h(fz_context *ctx, pdf_processor *proc)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "h\n");
+ fz_write_printf(ctx, out, "h\n");
}
static void
pdf_out_re(fz_context *ctx, pdf_processor *proc, float x, float y, float w, float h)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "%f %f %f %f re\n", x, y, w, h);
+ fz_write_printf(ctx, out, "%f %f %f %f re\n", x, y, w, h);
}
/* path painting */
@@ -165,70 +165,70 @@ static void
pdf_out_S(fz_context *ctx, pdf_processor *proc)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "S\n");
+ fz_write_printf(ctx, out, "S\n");
}
static void
pdf_out_s(fz_context *ctx, pdf_processor *proc)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "s\n");
+ fz_write_printf(ctx, out, "s\n");
}
static void
pdf_out_F(fz_context *ctx, pdf_processor *proc)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "F\n");
+ fz_write_printf(ctx, out, "F\n");
}
static void
pdf_out_f(fz_context *ctx, pdf_processor *proc)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "f\n");
+ fz_write_printf(ctx, out, "f\n");
}
static void
pdf_out_fstar(fz_context *ctx, pdf_processor *proc)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "f*\n");
+ fz_write_printf(ctx, out, "f*\n");
}
static void
pdf_out_B(fz_context *ctx, pdf_processor *proc)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "B\n");
+ fz_write_printf(ctx, out, "B\n");
}
static void
pdf_out_Bstar(fz_context *ctx, pdf_processor *proc)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "B*\n");
+ fz_write_printf(ctx, out, "B*\n");
}
static void
pdf_out_b(fz_context *ctx, pdf_processor *proc)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "b\n");
+ fz_write_printf(ctx, out, "b\n");
}
static void
pdf_out_bstar(fz_context *ctx, pdf_processor *proc)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "b*\n");
+ fz_write_printf(ctx, out, "b*\n");
}
static void
pdf_out_n(fz_context *ctx, pdf_processor *proc)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "n\n");
+ fz_write_printf(ctx, out, "n\n");
}
/* clipping paths */
@@ -237,14 +237,14 @@ static void
pdf_out_W(fz_context *ctx, pdf_processor *proc)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "W\n");
+ fz_write_printf(ctx, out, "W\n");
}
static void
pdf_out_Wstar(fz_context *ctx, pdf_processor *proc)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "W*\n");
+ fz_write_printf(ctx, out, "W*\n");
}
/* text objects */
@@ -253,14 +253,14 @@ static void
pdf_out_BT(fz_context *ctx, pdf_processor *proc)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "BT\n");
+ fz_write_printf(ctx, out, "BT\n");
}
static void
pdf_out_ET(fz_context *ctx, pdf_processor *proc)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "ET\n");
+ fz_write_printf(ctx, out, "ET\n");
}
/* text state */
@@ -269,28 +269,28 @@ static void
pdf_out_Tc(fz_context *ctx, pdf_processor *proc, float charspace)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "%f Tc\n", charspace);
+ fz_write_printf(ctx, out, "%f Tc\n", charspace);
}
static void
pdf_out_Tw(fz_context *ctx, pdf_processor *proc, float wordspace)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "%f Tw\n", wordspace);
+ fz_write_printf(ctx, out, "%f Tw\n", wordspace);
}
static void
pdf_out_Tz(fz_context *ctx, pdf_processor *proc, float scale)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "%f Tz\n", scale);
+ fz_write_printf(ctx, out, "%f Tz\n", scale);
}
static void
pdf_out_TL(fz_context *ctx, pdf_processor *proc, float leading)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "%f TL\n", leading);
+ fz_write_printf(ctx, out, "%f TL\n", leading);
}
static void
@@ -298,21 +298,21 @@ pdf_out_Tf(fz_context *ctx, pdf_processor *proc, const char *name, pdf_font_desc
{
fz_output *out = ((pdf_output_processor*)proc)->out;
if (!((pdf_output_processor*)proc)->extgstate)
- fz_printf(ctx, out, "/%s %f Tf\n", name, size);
+ fz_write_printf(ctx, out, "/%s %f Tf\n", name, size);
}
static void
pdf_out_Tr(fz_context *ctx, pdf_processor *proc, int render)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "%d Tr\n", render);
+ fz_write_printf(ctx, out, "%d Tr\n", render);
}
static void
pdf_out_Ts(fz_context *ctx, pdf_processor *proc, float rise)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "%f Ts\n", rise);
+ fz_write_printf(ctx, out, "%f Ts\n", rise);
}
/* text positioning */
@@ -321,28 +321,28 @@ static void
pdf_out_Td(fz_context *ctx, pdf_processor *proc, float tx, float ty)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "%f %f Td\n", tx, ty);
+ fz_write_printf(ctx, out, "%f %f Td\n", tx, ty);
}
static void
pdf_out_TD(fz_context *ctx, pdf_processor *proc, float tx, float ty)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "%f %f TD\n", tx, ty);
+ fz_write_printf(ctx, out, "%f %f TD\n", tx, ty);
}
static void
pdf_out_Tm(fz_context *ctx, pdf_processor *proc, float a, float b, float c, float d, float e, float f)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "%f %f %f %f %f %f Tm\n", a, b, c, d, e, f);
+ fz_write_printf(ctx, out, "%f %f %f %f %f %f Tm\n", a, b, c, d, e, f);
}
static void
pdf_out_Tstar(fz_context *ctx, pdf_processor *proc)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "T*\n");
+ fz_write_printf(ctx, out, "T*\n");
}
/* text showing */
@@ -358,22 +358,22 @@ put_string(fz_context *ctx, fz_output *out, const unsigned char *str, int len)
if (i < len)
{
- fz_printf(ctx, out, "<");
+ fz_write_printf(ctx, out, "<");
for (i = 0; i < len; ++i)
- fz_printf(ctx, out, "%02x", str[i]);
- fz_printf(ctx, out, ">");
+ fz_write_printf(ctx, out, "%02x", str[i]);
+ fz_write_printf(ctx, out, ">");
}
else
{
- fz_printf(ctx, out, "(");
+ fz_write_printf(ctx, out, "(");
for (i = 0; i < len; ++i)
{
unsigned char c = str[i];
if (c == '(' || c == ')' || c == '\\')
- fz_putc(ctx, out, '\\');
- fz_putc(ctx, out, c);
+ fz_write_byte(ctx, out, '\\');
+ fz_write_byte(ctx, out, c);
}
- fz_printf(ctx, out, ")");
+ fz_write_printf(ctx, out, ")");
}
}
@@ -382,7 +382,7 @@ pdf_out_TJ(fz_context *ctx, pdf_processor *proc, pdf_obj *array)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
pdf_print_obj(ctx, out, array, 1);
- fz_printf(ctx, out, " TJ\n");
+ fz_write_printf(ctx, out, " TJ\n");
}
static void
@@ -390,7 +390,7 @@ pdf_out_Tj(fz_context *ctx, pdf_processor *proc, char *str, int len)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
put_string(ctx, out, (const unsigned char *)str, len);
- fz_printf(ctx, out, " Tj\n");
+ fz_write_printf(ctx, out, " Tj\n");
}
static void
@@ -398,16 +398,16 @@ pdf_out_squote(fz_context *ctx, pdf_processor *proc, char *str, int len)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
put_string(ctx, out, (const unsigned char *)str, len);
- fz_printf(ctx, out, " '\n");
+ fz_write_printf(ctx, out, " '\n");
}
static void
pdf_out_dquote(fz_context *ctx, pdf_processor *proc, float aw, float ac, char *str, int len)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "%f %f ", aw, ac);
+ fz_write_printf(ctx, out, "%f %f ", aw, ac);
put_string(ctx, out, (const unsigned char *)str, len);
- fz_printf(ctx, out, " \"\n");
+ fz_write_printf(ctx, out, " \"\n");
}
/* type 3 fonts */
@@ -416,14 +416,14 @@ static void
pdf_out_d0(fz_context *ctx, pdf_processor *proc, float wx, float wy)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "%f %f d0\n", wx, wy);
+ fz_write_printf(ctx, out, "%f %f d0\n", wx, wy);
}
static void
pdf_out_d1(fz_context *ctx, pdf_processor *proc, float wx, float wy, float llx, float lly, float urx, float ury)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "%f %f %f %f %f %f d1\n", wx, wy, llx, lly, urx, ury);
+ fz_write_printf(ctx, out, "%f %f %f %f %f %f d1\n", wx, wy, llx, lly, urx, ury);
}
/* color */
@@ -432,14 +432,14 @@ static void
pdf_out_CS(fz_context *ctx, pdf_processor *proc, const char *name, fz_colorspace *cs)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "/%s CS\n", name);
+ fz_write_printf(ctx, out, "/%s CS\n", name);
}
static void
pdf_out_cs(fz_context *ctx, pdf_processor *proc, const char *name, fz_colorspace *cs)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "/%s cs\n", name);
+ fz_write_printf(ctx, out, "/%s cs\n", name);
}
static void
@@ -448,8 +448,8 @@ pdf_out_SC_pattern(fz_context *ctx, pdf_processor *proc, const char *name, pdf_p
fz_output *out = ((pdf_output_processor*)proc)->out;
int i;
for (i = 0; i < n; ++i)
- fz_printf(ctx, out, "%f ", color[i]);
- fz_printf(ctx, out, "/%s SCN\n", name);
+ fz_write_printf(ctx, out, "%f ", color[i]);
+ fz_write_printf(ctx, out, "/%s SCN\n", name);
}
static void
@@ -458,22 +458,22 @@ pdf_out_sc_pattern(fz_context *ctx, pdf_processor *proc, const char *name, pdf_p
fz_output *out = ((pdf_output_processor*)proc)->out;
int i;
for (i = 0; i < n; ++i)
- fz_printf(ctx, out, "%f ", color[i]);
- fz_printf(ctx, out, "/%s scn\n", name);
+ fz_write_printf(ctx, out, "%f ", color[i]);
+ fz_write_printf(ctx, out, "/%s scn\n", name);
}
static void
pdf_out_SC_shade(fz_context *ctx, pdf_processor *proc, const char *name, fz_shade *shade)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "/%s SCN\n", name);
+ fz_write_printf(ctx, out, "/%s SCN\n", name);
}
static void
pdf_out_sc_shade(fz_context *ctx, pdf_processor *proc, const char *name, fz_shade *shade)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "/%s scn\n", name);
+ fz_write_printf(ctx, out, "/%s scn\n", name);
}
static void
@@ -482,8 +482,8 @@ pdf_out_SC_color(fz_context *ctx, pdf_processor *proc, int n, float *color)
fz_output *out = ((pdf_output_processor*)proc)->out;
int i;
for (i = 0; i < n; ++i)
- fz_printf(ctx, out, "%f ", color[i]);
- fz_printf(ctx, out, "SCN\n");
+ fz_write_printf(ctx, out, "%f ", color[i]);
+ fz_write_printf(ctx, out, "SCN\n");
}
static void
@@ -492,50 +492,50 @@ pdf_out_sc_color(fz_context *ctx, pdf_processor *proc, int n, float *color)
fz_output *out = ((pdf_output_processor*)proc)->out;
int i;
for (i = 0; i < n; ++i)
- fz_printf(ctx, out, "%f ", color[i]);
- fz_printf(ctx, out, "scn\n");
+ fz_write_printf(ctx, out, "%f ", color[i]);
+ fz_write_printf(ctx, out, "scn\n");
}
static void
pdf_out_G(fz_context *ctx, pdf_processor *proc, float g)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "%f G\n", g);
+ fz_write_printf(ctx, out, "%f G\n", g);
}
static void
pdf_out_g(fz_context *ctx, pdf_processor *proc, float g)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "%f g\n", g);
+ fz_write_printf(ctx, out, "%f g\n", g);
}
static void
pdf_out_RG(fz_context *ctx, pdf_processor *proc, float r, float g, float b)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "%f %f %f RG\n", r, g, b);
+ fz_write_printf(ctx, out, "%f %f %f RG\n", r, g, b);
}
static void
pdf_out_rg(fz_context *ctx, pdf_processor *proc, float r, float g, float b)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "%f %f %f rg\n", r, g, b);
+ fz_write_printf(ctx, out, "%f %f %f rg\n", r, g, b);
}
static void
pdf_out_K(fz_context *ctx, pdf_processor *proc, float c, float m, float y, float k)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "%f %f %f %f K\n", c, m, y, k);
+ fz_write_printf(ctx, out, "%f %f %f %f K\n", c, m, y, k);
}
static void
pdf_out_k(fz_context *ctx, pdf_processor *proc, float c, float m, float y, float k)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "%f %f %f %f k\n", c, m, y, k);
+ fz_write_printf(ctx, out, "%f %f %f %f k\n", c, m, y, k);
}
/* shadings, images, xobjects */
@@ -560,30 +560,30 @@ pdf_out_BI(fz_context *ctx, pdf_processor *proc, fz_image *img)
if (buf == NULL)
return;
- fz_printf(ctx, out, "BI\n");
- fz_printf(ctx, out, "/W %d\n", img->w);
- fz_printf(ctx, out, "/H %d\n", img->h);
- fz_printf(ctx, out, "/BPC %d\n", img->bpc);
+ fz_write_printf(ctx, out, "BI\n");
+ fz_write_printf(ctx, out, "/W %d\n", img->w);
+ fz_write_printf(ctx, out, "/H %d\n", img->h);
+ fz_write_printf(ctx, out, "/BPC %d\n", img->bpc);
if (img->imagemask)
- fz_printf(ctx, out, "/IM true\n");
+ fz_write_printf(ctx, out, "/IM true\n");
else if (img->colorspace == fz_device_gray(ctx))
- fz_printf(ctx, out, "/CS/G\n");
+ fz_write_printf(ctx, out, "/CS/G\n");
else if (img->colorspace == fz_device_rgb(ctx))
- fz_printf(ctx, out, "/CS/RGB\n");
+ fz_write_printf(ctx, out, "/CS/RGB\n");
else if (img->colorspace == fz_device_cmyk(ctx))
- fz_printf(ctx, out, "/CS/CMYK\n");
+ fz_write_printf(ctx, out, "/CS/CMYK\n");
else if (fz_colorspace_is_indexed(ctx, img->colorspace))
- fz_printf(ctx, out, "/CS/I\n");
+ fz_write_printf(ctx, out, "/CS/I\n");
if (img->interpolate)
- fz_printf(ctx, out, "/I true\n");
- fz_printf(ctx, out, "/D[");
+ fz_write_printf(ctx, out, "/I true\n");
+ fz_write_printf(ctx, out, "/D[");
for (i = 0; i < img->n * 2; ++i)
{
if (i > 0)
- fz_putc(ctx, out, ' ');
- fz_printf(ctx, out, "%g", img->decode[i]);
+ fz_write_byte(ctx, out, ' ');
+ fz_write_printf(ctx, out, "%g", img->decode[i]);
}
- fz_printf(ctx, out, "]\n");
+ fz_write_printf(ctx, out, "]\n");
switch (cbuf->params.type)
{
@@ -592,78 +592,78 @@ pdf_out_BI(fz_context *ctx, pdf_processor *proc, fz_image *img)
break;
case FZ_IMAGE_JPEG:
- fz_printf(ctx, out, ahx ? "/F[/AHx/DCT]\n" : "/F/DCT\n");
+ fz_write_printf(ctx, out, ahx ? "/F[/AHx/DCT]\n" : "/F/DCT\n");
if (cbuf->params.u.jpeg.color_transform != -1)
- fz_printf(ctx, out, "/DP<</ColorTransform %d>>\n",
+ fz_write_printf(ctx, out, "/DP<</ColorTransform %d>>\n",
cbuf->params.u.jpeg.color_transform);
break;
case FZ_IMAGE_FAX:
- fz_printf(ctx, out, ahx ? "/F[/AHx/CCF]\n/DP[null<<\n" : "/F/CCF\n/DP<<\n");
- fz_printf(ctx, out, "/K %d\n", cbuf->params.u.fax.k);
+ fz_write_printf(ctx, out, ahx ? "/F[/AHx/CCF]\n/DP[null<<\n" : "/F/CCF\n/DP<<\n");
+ fz_write_printf(ctx, out, "/K %d\n", cbuf->params.u.fax.k);
if (cbuf->params.u.fax.columns != 1728)
- fz_printf(ctx, out, "/Columns %d\n", cbuf->params.u.fax.columns);
+ fz_write_printf(ctx, out, "/Columns %d\n", cbuf->params.u.fax.columns);
if (cbuf->params.u.fax.rows > 0)
- fz_printf(ctx, out, "/Rows %d\n", cbuf->params.u.fax.rows);
+ fz_write_printf(ctx, out, "/Rows %d\n", cbuf->params.u.fax.rows);
if (cbuf->params.u.fax.end_of_line)
- fz_printf(ctx, out, "/EndOfLine true\n");
+ fz_write_printf(ctx, out, "/EndOfLine true\n");
if (cbuf->params.u.fax.encoded_byte_align)
- fz_printf(ctx, out, "/EncodedByteAlign true\n");
+ fz_write_printf(ctx, out, "/EncodedByteAlign true\n");
if (!cbuf->params.u.fax.end_of_block)
- fz_printf(ctx, out, "/EndOfBlock false\n");
+ fz_write_printf(ctx, out, "/EndOfBlock false\n");
if (cbuf->params.u.fax.black_is_1)
- fz_printf(ctx, out, "/BlackIs1 true\n");
+ fz_write_printf(ctx, out, "/BlackIs1 true\n");
if (cbuf->params.u.fax.damaged_rows_before_error > 0)
- fz_printf(ctx, out, "/DamagedRowsBeforeError %d\n",
+ fz_write_printf(ctx, out, "/DamagedRowsBeforeError %d\n",
cbuf->params.u.fax.damaged_rows_before_error);
- fz_printf(ctx, out, ahx ? ">>]\n" : ">>\n");
+ fz_write_printf(ctx, out, ahx ? ">>]\n" : ">>\n");
break;
case FZ_IMAGE_RAW:
if (ahx)
- fz_printf(ctx, out, "/F/AHx\n");
+ fz_write_printf(ctx, out, "/F/AHx\n");
break;
case FZ_IMAGE_RLD:
- fz_printf(ctx, out, ahx ? "/F[/AHx/RL]\n" : "/F/RL\n");
+ fz_write_printf(ctx, out, ahx ? "/F[/AHx/RL]\n" : "/F/RL\n");
break;
case FZ_IMAGE_FLATE:
- fz_printf(ctx, out, ahx ? "/F[/AHx/Fl]\n" : "/F/Fl\n");
+ fz_write_printf(ctx, out, ahx ? "/F[/AHx/Fl]\n" : "/F/Fl\n");
if (cbuf->params.u.flate.predictor > 1)
{
- fz_printf(ctx, out, ahx ? "/DP[null<<\n" : "/DP<<\n");
- fz_printf(ctx, out, "/Predictor %d\n", cbuf->params.u.flate.predictor);
+ fz_write_printf(ctx, out, ahx ? "/DP[null<<\n" : "/DP<<\n");
+ fz_write_printf(ctx, out, "/Predictor %d\n", cbuf->params.u.flate.predictor);
if (cbuf->params.u.flate.columns != 1)
- fz_printf(ctx, out, "/Columns %d\n", cbuf->params.u.flate.columns);
+ fz_write_printf(ctx, out, "/Columns %d\n", cbuf->params.u.flate.columns);
if (cbuf->params.u.flate.colors != 1)
- fz_printf(ctx, out, "/Colors %d\n", cbuf->params.u.flate.colors);
+ fz_write_printf(ctx, out, "/Colors %d\n", cbuf->params.u.flate.colors);
if (cbuf->params.u.flate.bpc != 8)
- fz_printf(ctx, out, "/BitsPerComponent %d\n", cbuf->params.u.flate.bpc);
- fz_printf(ctx, out, ahx ? ">>]\n" : ">>\n");
+ fz_write_printf(ctx, out, "/BitsPerComponent %d\n", cbuf->params.u.flate.bpc);
+ fz_write_printf(ctx, out, ahx ? ">>]\n" : ">>\n");
}
break;
case FZ_IMAGE_LZW:
- fz_printf(ctx, out, ahx ? "/F[/AHx/LZW]\n" : "/F/LZW\n");
+ fz_write_printf(ctx, out, ahx ? "/F[/AHx/LZW]\n" : "/F/LZW\n");
if (cbuf->params.u.lzw.predictor > 1)
{
- fz_printf(ctx, out, ahx ? "/DP[<<null\n" : "/DP<<\n");
- fz_printf(ctx, out, "/Predictor %d\n", cbuf->params.u.lzw.predictor);
+ fz_write_printf(ctx, out, ahx ? "/DP[<<null\n" : "/DP<<\n");
+ fz_write_printf(ctx, out, "/Predictor %d\n", cbuf->params.u.lzw.predictor);
if (cbuf->params.u.lzw.columns != 1)
- fz_printf(ctx, out, "/Columns %d\n", cbuf->params.u.lzw.columns);
+ fz_write_printf(ctx, out, "/Columns %d\n", cbuf->params.u.lzw.columns);
if (cbuf->params.u.lzw.colors != 1)
- fz_printf(ctx, out, "/Colors %d\n", cbuf->params.u.lzw.colors);
+ fz_write_printf(ctx, out, "/Colors %d\n", cbuf->params.u.lzw.colors);
if (cbuf->params.u.lzw.bpc != 8)
- fz_printf(ctx, out, "/BitsPerComponent %d\n", cbuf->params.u.lzw.bpc);
+ fz_write_printf(ctx, out, "/BitsPerComponent %d\n", cbuf->params.u.lzw.bpc);
if (cbuf->params.u.lzw.early_change != 1)
- fz_printf(ctx, out, "/EarlyChange %d\n", cbuf->params.u.lzw.early_change);
- fz_printf(ctx, out, ahx ? ">>]\n" : ">>\n");
+ fz_write_printf(ctx, out, "/EarlyChange %d\n", cbuf->params.u.lzw.early_change);
+ fz_write_printf(ctx, out, ahx ? ">>]\n" : ">>\n");
}
break;
}
- fz_printf(ctx, out, "ID\n");
+ fz_write_printf(ctx, out, "ID\n");
len = fz_buffer_storage(ctx, buf, &data);
if (ahx)
{
@@ -671,39 +671,39 @@ pdf_out_BI(fz_context *ctx, pdf_processor *proc, fz_image *img)
for (z = 0; z < len; ++z)
{
int c = data[z];
- fz_putc(ctx, out, "0123456789abcdef"[(c >> 4) & 0xf]);
- fz_putc(ctx, out, "0123456789abcdef"[c & 0xf]);
+ fz_write_byte(ctx, out, "0123456789abcdef"[(c >> 4) & 0xf]);
+ fz_write_byte(ctx, out, "0123456789abcdef"[c & 0xf]);
if ((z & 31) == 31)
- fz_putc(ctx, out, '\n');
+ fz_write_byte(ctx, out, '\n');
}
- fz_putc(ctx, out, '>');
+ fz_write_byte(ctx, out, '>');
}
else
{
- fz_write(ctx, out, data, len);
+ fz_write_data(ctx, out, data, len);
}
- fz_printf(ctx, out, "\nEI\n");
+ fz_write_printf(ctx, out, "\nEI\n");
}
static void
pdf_out_sh(fz_context *ctx, pdf_processor *proc, const char *name, fz_shade *shade)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "/%s sh\n", name);
+ fz_write_printf(ctx, out, "/%s sh\n", name);
}
static void
pdf_out_Do_image(fz_context *ctx, pdf_processor *proc, const char *name, fz_image *image)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "/%s Do\n", name);
+ fz_write_printf(ctx, out, "/%s Do\n", name);
}
static void
pdf_out_Do_form(fz_context *ctx, pdf_processor *proc, const char *name, pdf_xobject *xobj, pdf_obj *page_resources)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "/%s Do\n", name);
+ fz_write_printf(ctx, out, "/%s Do\n", name);
}
/* marked content */
@@ -712,39 +712,39 @@ static void
pdf_out_MP(fz_context *ctx, pdf_processor *proc, const char *tag)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "/%s MP\n", tag);
+ fz_write_printf(ctx, out, "/%s MP\n", tag);
}
static void
pdf_out_DP(fz_context *ctx, pdf_processor *proc, const char *tag, pdf_obj *raw, pdf_obj *cooked)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "/%s ", tag);
+ fz_write_printf(ctx, out, "/%s ", tag);
pdf_print_obj(ctx, out, raw, 1);
- fz_printf(ctx, out, " DP\n");
+ fz_write_printf(ctx, out, " DP\n");
}
static void
pdf_out_BMC(fz_context *ctx, pdf_processor *proc, const char *tag)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "/%s BMC\n", tag);
+ fz_write_printf(ctx, out, "/%s BMC\n", tag);
}
static void
pdf_out_BDC(fz_context *ctx, pdf_processor *proc, const char *tag, pdf_obj *raw, pdf_obj *cooked)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "/%s ", tag);
+ fz_write_printf(ctx, out, "/%s ", tag);
pdf_print_obj(ctx, out, raw, 1);
- fz_printf(ctx, out, " BDC\n");
+ fz_write_printf(ctx, out, " BDC\n");
}
static void
pdf_out_EMC(fz_context *ctx, pdf_processor *proc)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "EMC\n");
+ fz_write_printf(ctx, out, "EMC\n");
}
/* compatibility */
@@ -753,14 +753,14 @@ static void
pdf_out_BX(fz_context *ctx, pdf_processor *proc)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "BX\n");
+ fz_write_printf(ctx, out, "BX\n");
}
static void
pdf_out_EX(fz_context *ctx, pdf_processor *proc)
{
fz_output *out = ((pdf_output_processor*)proc)->out;
- fz_printf(ctx, out, "EX\n");
+ fz_write_printf(ctx, out, "EX\n");
}
static void
diff --git a/source/pdf/pdf-pkcs7.c b/source/pdf/pdf-pkcs7.c
index ae5b75fa..dd106034 100644
--- a/source/pdf/pdf-pkcs7.c
+++ b/source/pdf/pdf-pkcs7.c
@@ -731,19 +731,19 @@ void pdf_sign_signature(fz_context *ctx, pdf_document *doc, pdf_widget *widget,
if (!dn->cn)
fz_throw(ctx, FZ_ERROR_GENERIC, "Certificate has no common name");
- fz_buffer_printf(ctx, fzbuf, "cn=%s", dn->cn);
+ fz_append_printf(ctx, fzbuf, "cn=%s", dn->cn);
if (dn->o)
- fz_buffer_printf(ctx, fzbuf, ", o=%s", dn->o);
+ fz_append_printf(ctx, fzbuf, ", o=%s", dn->o);
if (dn->ou)
- fz_buffer_printf(ctx, fzbuf, ", ou=%s", dn->ou);
+ fz_append_printf(ctx, fzbuf, ", ou=%s", dn->ou);
if (dn->email)
- fz_buffer_printf(ctx, fzbuf, ", email=%s", dn->email);
+ fz_append_printf(ctx, fzbuf, ", email=%s", dn->email);
if (dn->c)
- fz_buffer_printf(ctx, fzbuf, ", c=%s", dn->c);
+ fz_append_printf(ctx, fzbuf, ", c=%s", dn->c);
dn_str = fz_string_from_buffer(ctx, fzbuf);
pdf_set_signature_appearance(ctx, doc, (pdf_annot *)widget, dn->cn, dn_str, NULL);
diff --git a/source/pdf/pdf-store.c b/source/pdf/pdf-store.c
index 33d34ab9..e29e7ccb 100644
--- a/source/pdf/pdf-store.c
+++ b/source/pdf/pdf-store.c
@@ -36,7 +36,7 @@ pdf_print_key(fz_context *ctx, fz_output *out, void *key_)
pdf_obj *key = (pdf_obj *)key_;
if (pdf_is_indirect(ctx, key))
- fz_printf(ctx, out, "(%d 0 R) ", pdf_to_num(ctx, key));
+ fz_write_printf(ctx, out, "(%d 0 R) ", pdf_to_num(ctx, key));
else
pdf_print_obj(ctx, out, key, 0);
}
diff --git a/source/pdf/pdf-write.c b/source/pdf/pdf-write.c
index 7602e0c9..d0ff2f76 100644
--- a/source/pdf/pdf-write.c
+++ b/source/pdf/pdf-write.c
@@ -1674,13 +1674,13 @@ static void copystream(fz_context *ctx, pdf_document *doc, pdf_write_state *opts
pdf_dict_put(ctx, obj, PDF_NAME_Length, newlen);
pdf_drop_obj(ctx, newlen);
- fz_printf(ctx, opts->out, "%d %d obj\n", num, gen);
+ fz_write_printf(ctx, opts->out, "%d %d obj\n", num, gen);
pdf_print_obj(ctx, opts->out, obj, opts->do_tight);
- fz_puts(ctx, opts->out, "\nstream\n");
- fz_write(ctx, opts->out, data, len);
+ fz_write_string(ctx, opts->out, "\nstream\n");
+ fz_write_data(ctx, opts->out, data, len);
if (len > 0 && data[len-1] != '\n')
- fz_putc(ctx, opts->out, '\n');
- fz_puts(ctx, opts->out, "endstream\nendobj\n\n");
+ fz_write_byte(ctx, opts->out, '\n');
+ fz_write_string(ctx, opts->out, "endstream\nendobj\n\n");
fz_drop_buffer(ctx, buf);
pdf_drop_obj(ctx, obj);
@@ -1739,13 +1739,13 @@ static void expandstream(fz_context *ctx, pdf_document *doc, pdf_write_state *op
pdf_dict_put(ctx, obj, PDF_NAME_Length, newlen);
pdf_drop_obj(ctx, newlen);
- fz_printf(ctx, opts->out, "%d %d obj\n", num, gen);
+ fz_write_printf(ctx, opts->out, "%d %d obj\n", num, gen);
pdf_print_obj(ctx, opts->out, obj, opts->do_tight);
- fz_puts(ctx, opts->out, "\nstream\n");
- fz_write(ctx, opts->out, data, len);
+ fz_write_string(ctx, opts->out, "\nstream\n");
+ fz_write_data(ctx, opts->out, data, len);
if (len > 0 && data[len-1] != '\n')
- fz_putc(ctx, opts->out, '\n');
- fz_puts(ctx, opts->out, "endstream\nendobj\n\n");
+ fz_write_byte(ctx, opts->out, '\n');
+ fz_write_string(ctx, opts->out, "endstream\nendobj\n\n");
fz_drop_buffer(ctx, buf);
pdf_drop_obj(ctx, obj);
@@ -1827,7 +1827,7 @@ static void writeobject(fz_context *ctx, pdf_document *doc, pdf_write_state *opt
fz_rethrow_if(ctx, FZ_ERROR_TRYLATER);
if (opts->continue_on_error)
{
- fz_printf(ctx, opts->out, "%d %d obj\nnull\nendobj\n", num, gen);
+ fz_write_printf(ctx, opts->out, "%d %d obj\nnull\nendobj\n", num, gen);
if (opts->errors)
(*opts->errors)++;
fz_warn(ctx, "%s", fz_caught_message(ctx));
@@ -1858,15 +1858,15 @@ static void writeobject(fz_context *ctx, pdf_document *doc, pdf_write_state *opt
entry = pdf_get_xref_entry(ctx, doc, num);
if (!pdf_obj_num_is_stream(ctx, doc, num))
{
- fz_printf(ctx, opts->out, "%d %d obj\n", num, gen);
+ fz_write_printf(ctx, opts->out, "%d %d obj\n", num, gen);
pdf_print_obj(ctx, opts->out, obj, opts->do_tight);
- fz_puts(ctx, opts->out, "\nendobj\n\n");
+ fz_write_string(ctx, opts->out, "\nendobj\n\n");
}
else if (entry->stm_ofs < 0 && entry->stm_buf == NULL)
{
- fz_printf(ctx, opts->out, "%d %d obj\n", num, gen);
+ fz_write_printf(ctx, opts->out, "%d %d obj\n", num, gen);
pdf_print_obj(ctx, opts->out, obj, opts->do_tight);
- fz_puts(ctx, opts->out, "\nstream\nendstream\nendobj\n\n");
+ fz_write_string(ctx, opts->out, "\nstream\nendstream\nendobj\n\n");
}
else
{
@@ -1888,7 +1888,7 @@ static void writeobject(fz_context *ctx, pdf_document *doc, pdf_write_state *opt
fz_rethrow_if(ctx, FZ_ERROR_TRYLATER);
if (opts->continue_on_error)
{
- fz_printf(ctx, opts->out, "%d %d obj\nnull\nendobj\n", num, gen);
+ fz_write_printf(ctx, opts->out, "%d %d obj\nnull\nendobj\n", num, gen);
if (opts->errors)
(*opts->errors)++;
fz_warn(ctx, "%s", fz_caught_message(ctx));
@@ -1908,13 +1908,13 @@ static void writexrefsubsect(fz_context *ctx, pdf_write_state *opts, int from, i
{
int num;
- fz_printf(ctx, opts->out, "%d %d\n", from, to - from);
+ fz_write_printf(ctx, opts->out, "%d %d\n", from, to - from);
for (num = from; num < to; num++)
{
if (opts->use_list[num])
- fz_printf(ctx, opts->out, "%010Zd %05d n \n", opts->ofs_list[num], opts->gen_list[num]);
+ fz_write_printf(ctx, opts->out, "%010Zd %05d n \n", opts->ofs_list[num], opts->gen_list[num]);
else
- fz_printf(ctx, opts->out, "%010Zd %05d f \n", opts->ofs_list[num], opts->gen_list[num]);
+ fz_write_printf(ctx, opts->out, "%010Zd %05d f \n", opts->ofs_list[num], opts->gen_list[num]);
}
}
@@ -1924,7 +1924,7 @@ static void writexref(fz_context *ctx, pdf_document *doc, pdf_write_state *opts,
pdf_obj *obj;
pdf_obj *nobj = NULL;
- fz_puts(ctx, opts->out, "xref\n");
+ fz_write_string(ctx, opts->out, "xref\n");
opts->first_xref_entry_offset = fz_tell_output(ctx, opts->out);
if (opts->do_incremental)
@@ -1952,7 +1952,7 @@ static void writexref(fz_context *ctx, pdf_document *doc, pdf_write_state *opts,
writexrefsubsect(ctx, opts, from, to);
}
- fz_puts(ctx, opts->out, "\n");
+ fz_write_string(ctx, opts->out, "\n");
fz_var(trailer);
fz_var(nobj);
@@ -2007,13 +2007,13 @@ static void writexref(fz_context *ctx, pdf_document *doc, pdf_write_state *opts,
fz_rethrow(ctx);
}
- fz_puts(ctx, opts->out, "trailer\n");
+ fz_write_string(ctx, opts->out, "trailer\n");
pdf_print_obj(ctx, opts->out, trailer, opts->do_tight);
- fz_puts(ctx, opts->out, "\n");
+ fz_write_string(ctx, opts->out, "\n");
pdf_drop_obj(ctx, trailer);
- fz_printf(ctx, opts->out, "startxref\n%d\n%%%%EOF\n", startxref);
+ fz_write_printf(ctx, opts->out, "startxref\n%d\n%%%%EOF\n", startxref);
doc->has_xref_streams = 0;
}
@@ -2026,12 +2026,12 @@ static void writexrefstreamsubsect(fz_context *ctx, pdf_document *doc, pdf_write
pdf_array_push_drop(ctx, index, pdf_new_int(ctx, doc, to - from));
for (num = from; num < to; num++)
{
- fz_write_buffer_byte(ctx, fzbuf, opts->use_list[num] ? 1 : 0);
- fz_write_buffer_byte(ctx, fzbuf, opts->ofs_list[num]>>24);
- fz_write_buffer_byte(ctx, fzbuf, opts->ofs_list[num]>>16);
- fz_write_buffer_byte(ctx, fzbuf, opts->ofs_list[num]>>8);
- fz_write_buffer_byte(ctx, fzbuf, opts->ofs_list[num]);
- fz_write_buffer_byte(ctx, fzbuf, opts->gen_list[num]);
+ fz_append_byte(ctx, fzbuf, opts->use_list[num] ? 1 : 0);
+ fz_append_byte(ctx, fzbuf, opts->ofs_list[num]>>24);
+ fz_append_byte(ctx, fzbuf, opts->ofs_list[num]>>16);
+ fz_append_byte(ctx, fzbuf, opts->ofs_list[num]>>8);
+ fz_append_byte(ctx, fzbuf, opts->ofs_list[num]);
+ fz_append_byte(ctx, fzbuf, opts->gen_list[num]);
}
}
@@ -2137,7 +2137,7 @@ static void writexrefstream(fz_context *ctx, pdf_document *doc, pdf_write_state
pdf_update_stream(ctx, doc, dict, fzbuf, 0);
writeobject(ctx, doc, opts, num, 0, 0);
- fz_printf(ctx, opts->out, "startxref\n%Zd\n%%%%EOF\n", startxref);
+ fz_write_printf(ctx, opts->out, "startxref\n%Zd\n%%%%EOF\n", startxref);
}
fz_always(ctx)
{
@@ -2159,7 +2159,7 @@ padto(fz_context *ctx, fz_output *out, fz_off_t target)
assert(pos <= target);
while (pos < target)
{
- fz_putc(ctx, out, '\n');
+ fz_write_byte(ctx, out, '\n');
pos++;
}
}
@@ -2208,8 +2208,8 @@ writeobjects(fz_context *ctx, pdf_document *doc, pdf_write_state *opts, int pass
if (!opts->do_incremental)
{
- fz_printf(ctx, opts->out, "%%PDF-%d.%d\n", doc->version / 10, doc->version % 10);
- fz_puts(ctx, opts->out, "%%\316\274\341\277\246\n\n");
+ fz_write_printf(ctx, opts->out, "%%PDF-%d.%d\n", doc->version / 10, doc->version % 10);
+ fz_write_string(ctx, opts->out, "%%\316\274\341\277\246\n\n");
}
dowriteobject(ctx, doc, opts, opts->start, pass);
@@ -2362,69 +2362,69 @@ make_page_offset_hints(fz_context *ctx, pdf_document *doc, pdf_write_state *opts
/* Table F.3 - Header */
/* Header Item 1: Least number of objects in a page */
- fz_write_buffer_bits(ctx, buf, min_objs_per_page, 32);
+ fz_append_bits(ctx, buf, min_objs_per_page, 32);
/* Header Item 2: Location of first pages page object */
- fz_write_buffer_bits(ctx, buf, opts->ofs_list[pop[0]->page_object_number], 32);
+ fz_append_bits(ctx, buf, opts->ofs_list[pop[0]->page_object_number], 32);
/* Header Item 3: Number of bits required to represent the difference
* between the greatest and least number of objects in a page. */
objs_per_page_bits = my_log2(max_objs_per_page - min_objs_per_page);
- fz_write_buffer_bits(ctx, buf, objs_per_page_bits, 16);
+ fz_append_bits(ctx, buf, objs_per_page_bits, 16);
/* Header Item 4: Least length of a page. */
- fz_write_buffer_bits(ctx, buf, min_page_length, 32);
+ fz_append_bits(ctx, buf, min_page_length, 32);
/* Header Item 5: Number of bits needed to represent the difference
* between the greatest and least length of a page. */
page_len_bits = my_log2(max_page_length - min_page_length);
- fz_write_buffer_bits(ctx, buf, page_len_bits, 16);
+ fz_append_bits(ctx, buf, page_len_bits, 16);
/* Header Item 6: Least offset to start of content stream (Acrobat
* sets this to always be 0) */
- fz_write_buffer_bits(ctx, buf, 0, 32);
+ fz_append_bits(ctx, buf, 0, 32);
/* Header Item 7: Number of bits needed to represent the difference
* between the greatest and least offset to content stream (Acrobat
* sets this to always be 0) */
- fz_write_buffer_bits(ctx, buf, 0, 16);
+ fz_append_bits(ctx, buf, 0, 16);
/* Header Item 8: Least content stream length. (Acrobat
* sets this to always be 0) */
- fz_write_buffer_bits(ctx, buf, 0, 32);
+ fz_append_bits(ctx, buf, 0, 32);
/* Header Item 9: Number of bits needed to represent the difference
* between the greatest and least content stream length (Acrobat
* sets this to always be the same as item 5) */
- fz_write_buffer_bits(ctx, buf, page_len_bits, 16);
+ fz_append_bits(ctx, buf, page_len_bits, 16);
/* Header Item 10: Number of bits needed to represent the greatest
* number of shared object references. */
shared_object_bits = my_log2(max_shared_object_refs);
- fz_write_buffer_bits(ctx, buf, shared_object_bits, 16);
+ fz_append_bits(ctx, buf, shared_object_bits, 16);
/* Header Item 11: Number of bits needed to represent the greatest
* shared object identifier. */
shared_object_id_bits = my_log2(max_shared_object - min_shared_object + pop[0]->num_shared);
- fz_write_buffer_bits(ctx, buf, shared_object_id_bits, 16);
+ fz_append_bits(ctx, buf, shared_object_id_bits, 16);
/* Header Item 12: Number of bits needed to represent the numerator
* of the fractions. We always send 0. */
- fz_write_buffer_bits(ctx, buf, 0, 16);
+ fz_append_bits(ctx, buf, 0, 16);
/* Header Item 13: Number of bits needed to represent the denominator
* of the fractions. We always send 0. */
- fz_write_buffer_bits(ctx, buf, 0, 16);
+ fz_append_bits(ctx, buf, 0, 16);
/* Table F.4 - Page offset hint table (per page) */
/* Item 1: A number that, when added to the least number of objects
* on a page, gives the number of objects in the page. */
for (i = 0; i < opts->page_count; i++)
{
- fz_write_buffer_bits(ctx, buf, pop[i]->num_objects - min_objs_per_page, objs_per_page_bits);
+ fz_append_bits(ctx, buf, pop[i]->num_objects - min_objs_per_page, objs_per_page_bits);
}
- fz_write_buffer_pad(ctx, buf);
+ fz_append_bits_pad(ctx, buf);
/* Item 2: A number that, when added to the least page length, gives
* the length of the page in bytes. */
for (i = 0; i < opts->page_count; i++)
{
- fz_write_buffer_bits(ctx, buf, pop[i]->max_ofs - pop[i]->min_ofs - min_page_length, page_len_bits);
+ fz_append_bits(ctx, buf, pop[i]->max_ofs - pop[i]->min_ofs - min_page_length, page_len_bits);
}
- fz_write_buffer_pad(ctx, buf);
+ fz_append_bits_pad(ctx, buf);
/* Item 3: The number of shared objects referenced from the page. */
for (i = 0; i < opts->page_count; i++)
{
- fz_write_buffer_bits(ctx, buf, pop[i]->num_shared, shared_object_bits);
+ fz_append_bits(ctx, buf, pop[i]->num_shared, shared_object_bits);
}
- fz_write_buffer_pad(ctx, buf);
+ fz_append_bits_pad(ctx, buf);
/* Item 4: Shared object id for each shared object ref in every page.
* Spec says "not for page 1", but acrobat does send page 1's - all
* as zeros. */
@@ -2434,12 +2434,12 @@ make_page_offset_hints(fz_context *ctx, pdf_document *doc, pdf_write_state *opts
{
int o = pop[i]->object[j];
if (i == 0 && opts->use_list[o] & USE_PAGE1)
- fz_write_buffer_bits(ctx, buf, 0 /* o - pop[0]->page_object_number */, shared_object_id_bits);
+ fz_append_bits(ctx, buf, 0 /* o - pop[0]->page_object_number */, shared_object_id_bits);
if (i != 0 && opts->use_list[o] & USE_SHARED)
- fz_write_buffer_bits(ctx, buf, o - min_shared_object + pop[0]->num_shared, shared_object_id_bits);
+ fz_append_bits(ctx, buf, o - min_shared_object + pop[0]->num_shared, shared_object_id_bits);
}
}
- fz_write_buffer_pad(ctx, buf);
+ fz_append_bits_pad(ctx, buf);
/* Item 5: Numerator of fractional position for each shared object reference. */
/* We always send 0 in 0 bits */
/* Item 6: A number that, when added to the least offset to the start
@@ -2453,36 +2453,36 @@ make_page_offset_hints(fz_context *ctx, pdf_document *doc, pdf_write_state *opts
*/
for (i = 0; i < opts->page_count; i++)
{
- fz_write_buffer_bits(ctx, buf, pop[i]->max_ofs - pop[i]->min_ofs - min_page_length, page_len_bits);
+ fz_append_bits(ctx, buf, pop[i]->max_ofs - pop[i]->min_ofs - min_page_length, page_len_bits);
}
/* Pad, and then do shared object hint table */
- fz_write_buffer_pad(ctx, buf);
+ fz_append_bits_pad(ctx, buf);
opts->hints_shared_offset = (int)fz_buffer_storage(ctx, buf, NULL);
/* Table F.5: */
/* Header Item 1: Object number of the first object in the shared
* objects section. */
- fz_write_buffer_bits(ctx, buf, min_shared_object, 32);
+ fz_append_bits(ctx, buf, min_shared_object, 32);
/* Header Item 2: Location of first object in the shared objects
* section. */
- fz_write_buffer_bits(ctx, buf, opts->ofs_list[min_shared_object], 32);
+ fz_append_bits(ctx, buf, opts->ofs_list[min_shared_object], 32);
/* Header Item 3: The number of shared object entries for the first
* page. */
- fz_write_buffer_bits(ctx, buf, pop[0]->num_shared, 32);
+ fz_append_bits(ctx, buf, pop[0]->num_shared, 32);
/* Header Item 4: The number of shared object entries for the shared
* objects section + first page. */
- fz_write_buffer_bits(ctx, buf, max_shared_object - min_shared_object + pop[0]->num_shared, 32);
+ fz_append_bits(ctx, buf, max_shared_object - min_shared_object + pop[0]->num_shared, 32);
/* Header Item 5: The number of bits needed to represent the greatest
* number of objects in a shared object group (Always 0). */
- fz_write_buffer_bits(ctx, buf, 0, 16);
+ fz_append_bits(ctx, buf, 0, 16);
/* Header Item 6: The least length of a shared object group in bytes. */
- fz_write_buffer_bits(ctx, buf, min_shared_length, 32);
+ fz_append_bits(ctx, buf, min_shared_length, 32);
/* Header Item 7: The number of bits required to represent the
* difference between the greatest and least length of a shared object
* group. */
shared_length_bits = my_log2(max_shared_length - min_shared_length);
- fz_write_buffer_bits(ctx, buf, shared_length_bits, 16);
+ fz_append_bits(ctx, buf, shared_length_bits, 16);
/* Table F.6 */
/* Item 1: Shared object group length (page 1 objects) */
@@ -2498,7 +2498,7 @@ make_page_offset_hints(fz_context *ctx, pdf_document *doc, pdf_write_state *opts
else
max = opts->ofs_list[1];
if (opts->use_list[o] & USE_PAGE1)
- fz_write_buffer_bits(ctx, buf, max - min - min_shared_length, shared_length_bits);
+ fz_append_bits(ctx, buf, max - min - min_shared_length, shared_length_bits);
}
/* Item 1: Shared object group length (shared objects) */
for (i = min_shared_object; i <= max_shared_object; i++)
@@ -2511,18 +2511,18 @@ make_page_offset_hints(fz_context *ctx, pdf_document *doc, pdf_write_state *opts
max = opts->ofs_list[i+1];
else
max = opts->ofs_list[1];
- fz_write_buffer_bits(ctx, buf, max - min - min_shared_length, shared_length_bits);
+ fz_append_bits(ctx, buf, max - min - min_shared_length, shared_length_bits);
}
- fz_write_buffer_pad(ctx, buf);
+ fz_append_bits_pad(ctx, buf);
/* Item 2: MD5 presence flags */
for (i = max_shared_object - min_shared_object + pop[0]->num_shared; i > 0; i--)
{
- fz_write_buffer_bits(ctx, buf, 0, 1);
+ fz_append_bits(ctx, buf, 0, 1);
}
- fz_write_buffer_pad(ctx, buf);
+ fz_append_bits_pad(ctx, buf);
/* Item 3: MD5 sums (not present) */
- fz_write_buffer_pad(ctx, buf);
+ fz_append_bits_pad(ctx, buf);
/* Item 4: Number of objects in the group (not present) */
}
@@ -2860,7 +2860,7 @@ do_pdf_save_document(fz_context *ctx, pdf_document *doc, pdf_write_state *opts,
if (opts->out)
{
fz_seek_output(ctx, opts->out, 0, SEEK_END);
- fz_puts(ctx, opts->out, "\n");
+ fz_write_string(ctx, opts->out, "\n");
}
}
diff --git a/source/tools/mudraw.c b/source/tools/mudraw.c
index 785bcaa2..77f400a4 100644
--- a/source/tools/mudraw.c
+++ b/source/tools/mudraw.c
@@ -352,27 +352,27 @@ static void
file_level_headers(fz_context *ctx)
{
if (output_format == OUT_STEXT || output_format == OUT_TRACE)
- fz_printf(ctx, out, "<?xml version=\"1.0\"?>\n");
+ fz_write_printf(ctx, out, "<?xml version=\"1.0\"?>\n");
if (output_format == OUT_TEXT || output_format == OUT_HTML || output_format == OUT_STEXT)
sheet = fz_new_stext_sheet(ctx);
if (output_format == OUT_HTML)
{
- fz_printf(ctx, out, "<style>\n");
- fz_printf(ctx, out, "body{background-color:gray;margin:12pt;}\n");
- fz_printf(ctx, out, "div.page{background-color:white;margin:6pt;padding:6pt;}\n");
- fz_printf(ctx, out, "div.block{border:1px solid gray;margin:6pt;padding:6pt;}\n");
- fz_printf(ctx, out, "div.metaline{display:table;width:100%%}\n");
- fz_printf(ctx, out, "div.line{display:table-row;padding:6pt}\n");
- fz_printf(ctx, out, "div.cell{display:table-cell;padding-left:6pt;padding-right:6pt}\n");
- fz_printf(ctx, out, "p{margin:0pt;padding:0pt;}\n");
- fz_printf(ctx, out, "</style>\n");
- fz_printf(ctx, out, "<body>\n");
+ fz_write_printf(ctx, out, "<style>\n");
+ fz_write_printf(ctx, out, "body{background-color:gray;margin:12pt;}\n");
+ fz_write_printf(ctx, out, "div.page{background-color:white;margin:6pt;padding:6pt;}\n");
+ fz_write_printf(ctx, out, "div.block{border:1px solid gray;margin:6pt;padding:6pt;}\n");
+ fz_write_printf(ctx, out, "div.metaline{display:table;width:100%%}\n");
+ fz_write_printf(ctx, out, "div.line{display:table-row;padding:6pt}\n");
+ fz_write_printf(ctx, out, "div.cell{display:table-cell;padding-left:6pt;padding-right:6pt}\n");
+ fz_write_printf(ctx, out, "p{margin:0pt;padding:0pt;}\n");
+ fz_write_printf(ctx, out, "</style>\n");
+ fz_write_printf(ctx, out, "<body>\n");
}
if (output_format == OUT_STEXT || output_format == OUT_TRACE)
- fz_printf(ctx, out, "<document name=\"%s\">\n", filename);
+ fz_write_printf(ctx, out, "<document name=\"%s\">\n", filename);
if (output_format == OUT_PS)
fz_write_ps_file_header(ctx, out);
@@ -385,14 +385,14 @@ static void
file_level_trailers(fz_context *ctx)
{
if (output_format == OUT_STEXT || output_format == OUT_TRACE)
- fz_printf(ctx, out, "</document>\n");
+ fz_write_printf(ctx, out, "</document>\n");
if (output_format == OUT_HTML)
{
- fz_printf(ctx, out, "</body>\n");
- fz_printf(ctx, out, "<style>\n");
+ fz_write_printf(ctx, out, "</body>\n");
+ fz_write_printf(ctx, out, "<style>\n");
fz_print_stext_sheet(ctx, out, sheet);
- fz_printf(ctx, out, "</style>\n");
+ fz_write_printf(ctx, out, "</style>\n");
}
if (output_format == OUT_PS)
@@ -456,7 +456,7 @@ static void dodrawpage(fz_context *ctx, fz_page *page, fz_display_list *list, in
{
fz_try(ctx)
{
- fz_printf(ctx, out, "<page mediabox=\"%g %g %g %g\">\n",
+ fz_write_printf(ctx, out, "<page mediabox=\"%g %g %g %g\">\n",
mediabox.x0, mediabox.y0, mediabox.x1, mediabox.y1);
dev = fz_new_trace_device(ctx, out);
if (lowmemory)
@@ -465,7 +465,7 @@ static void dodrawpage(fz_context *ctx, fz_page *page, fz_display_list *list, in
fz_run_display_list(ctx, list, dev, &fz_identity, &fz_infinite_rect, cookie);
else
fz_run_page(ctx, page, dev, &fz_identity, cookie);
- fz_printf(ctx, out, "</page>\n");
+ fz_write_printf(ctx, out, "</page>\n");
fz_close_device(ctx, dev);
}
fz_always(ctx)
@@ -519,7 +519,7 @@ static void dodrawpage(fz_context *ctx, fz_page *page, fz_display_list *list, in
else if (output_format == OUT_TEXT)
{
fz_print_stext_page(ctx, out, text);
- fz_printf(ctx, out, "\f\n");
+ fz_write_printf(ctx, out, "\f\n");
}
}
fz_always(ctx)
diff --git a/source/tools/muraster.c b/source/tools/muraster.c
index 468bb212..78fd18fa 100644
--- a/source/tools/muraster.c
+++ b/source/tools/muraster.c
@@ -253,6 +253,8 @@ static const suffix_t suffix_table[] =
#endif
};
+#ifndef DISABLE_MUTHREADS
+
static mu_mutex mutexes[FZ_LOCK_MAX];
static void muraster_lock(void *user, int lock)
@@ -295,6 +297,8 @@ static fz_locks_context *init_muraster_locks(void)
return &muraster_locks;
}
+#endif
+
#ifdef MURASTER_CONFIG_RENDER_THREADS
#define NUM_RENDER_THREADS MURASTER_CONFIG_RENDER_THREADS
#elif defined(DISABLE_MUTHREADS)
@@ -1384,7 +1388,7 @@ int main(int argc, char **argv)
{
char *password = "";
fz_document *doc = NULL;
- int i, c;
+ int c;
fz_context *ctx;
fz_alloc_context alloc_ctx = { NULL, trace_malloc, trace_realloc, trace_free };
fz_locks_context *locks = NULL;
diff --git a/source/tools/murun.c b/source/tools/murun.c
index 25fd0d39..75f5d19f 100644
--- a/source/tools/murun.c
+++ b/source/tools/murun.c
@@ -1416,7 +1416,7 @@ static void ffi_Buffer_writeByte(js_State *J)
fz_buffer *buf = js_touserdata(J, 0, "fz_buffer");
unsigned char val = js_tonumber(J, 1);
fz_try(ctx)
- fz_write_buffer_byte(ctx, buf, val);
+ fz_append_byte(ctx, buf, val);
fz_catch(ctx)
rethrow(J);
}
@@ -1427,7 +1427,7 @@ static void ffi_Buffer_writeRune(js_State *J)
fz_buffer *buf = js_touserdata(J, 0, "fz_buffer");
int val = js_tonumber(J, 1);
fz_try(ctx)
- fz_write_buffer_rune(ctx, buf, val);
+ fz_append_rune(ctx, buf, val);
fz_catch(ctx)
rethrow(J);
}
@@ -1442,8 +1442,8 @@ static void ffi_Buffer_write(js_State *J)
const char *s = js_tostring(J, i);
fz_try(ctx) {
if (i > 1)
- fz_write_buffer_byte(ctx, buf, ' ');
- fz_write_buffer(ctx, buf, s, strlen(s));
+ fz_append_byte(ctx, buf, ' ');
+ fz_append_string(ctx, buf, s);
} fz_catch(ctx)
rethrow(J);
}
@@ -1455,7 +1455,7 @@ static void ffi_Buffer_writeLine(js_State *J)
fz_buffer *buf = js_touserdata(J, 0, "fz_buffer");
ffi_Buffer_write(J);
fz_try(ctx)
- fz_write_buffer_byte(ctx, buf, '\n');
+ fz_append_byte(ctx, buf, '\n');
fz_catch(ctx)
rethrow(J);
}
diff --git a/source/tools/pdfcreate.c b/source/tools/pdfcreate.c
index 79f4a29d..b7b580db 100644
--- a/source/tools/pdfcreate.c
+++ b/source/tools/pdfcreate.c
@@ -129,8 +129,8 @@ static void create_page(char *input)
}
else
{
- fz_write_buffer(ctx, contents, line, strlen(line));
- fz_write_buffer_byte(ctx, contents, '\n');
+ fz_append_string(ctx, contents, line);
+ fz_append_byte(ctx, contents, '\n');
}
}
fz_drop_stream(ctx, stm);
diff --git a/source/tools/pdfextract.c b/source/tools/pdfextract.c
index 4104cc20..c7390392 100644
--- a/source/tools/pdfextract.c
+++ b/source/tools/pdfextract.c
@@ -71,7 +71,7 @@ writejpeg(fz_context *ctx, const unsigned char *data, size_t len, const char *fi
fz_try(ctx)
{
out = fz_new_output_with_path(ctx, buf, 0);
- fz_write(ctx, out, data, len);
+ fz_write_data(ctx, out, data, len);
}
fz_always(ctx)
{
@@ -195,7 +195,7 @@ static void savefont(pdf_obj *dict, int num)
printf("extracting font %s\n", namebuf);
out = fz_new_output_with_path(ctx, namebuf, 0);
fz_try(ctx)
- fz_write(ctx, out, data, len);
+ fz_write_data(ctx, out, data, len);
fz_always(ctx)
fz_drop_output(ctx, out);
fz_catch(ctx)
diff --git a/source/tools/pdfinfo.c b/source/tools/pdfinfo.c
index e6b37709..8fac93f6 100644
--- a/source/tools/pdfinfo.c
+++ b/source/tools/pdfinfo.c
@@ -178,23 +178,23 @@ showglobalinfo(fz_context *ctx, globals *glo)
fz_output *out = glo->out;
pdf_document *doc = glo->doc;
- fz_printf(ctx, out, "\nPDF-%d.%d\n", doc->version / 10, doc->version % 10);
+ fz_write_printf(ctx, out, "\nPDF-%d.%d\n", doc->version / 10, doc->version % 10);
obj = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME_Info);
if (obj)
{
- fz_printf(ctx, out, "Info object (%d 0 R):\n", pdf_to_num(ctx, obj));
+ fz_write_printf(ctx, out, "Info object (%d 0 R):\n", pdf_to_num(ctx, obj));
pdf_print_obj(ctx, out, pdf_resolve_indirect(ctx, obj), 1);
}
obj = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME_Encrypt);
if (obj)
{
- fz_printf(ctx, out, "\nEncryption object (%d 0 R):\n", pdf_to_num(ctx, obj));
+ fz_write_printf(ctx, out, "\nEncryption object (%d 0 R):\n", pdf_to_num(ctx, obj));
pdf_print_obj(ctx, out, pdf_resolve_indirect(ctx, obj), 1);
}
- fz_printf(ctx, out, "\nPages: %d\n\n", glo->pagecount);
+ fz_write_printf(ctx, out, "\nPages: %d\n\n", glo->pagecount);
}
static void
@@ -680,10 +680,10 @@ printinfo(fz_context *ctx, globals *glo, char *filename, int show, int page)
if (show & DIMENSIONS && glo->dims > 0)
{
- fz_printf(ctx, out, "Mediaboxes (%d):\n", glo->dims);
+ fz_write_printf(ctx, out, "Mediaboxes (%d):\n", glo->dims);
for (i = 0; i < glo->dims; i++)
{
- fz_printf(ctx, out, PAGE_FMT_zu "[ %g %g %g %g ]\n",
+ fz_write_printf(ctx, out, PAGE_FMT_zu "[ %g %g %g %g ]\n",
glo->dim[i].page,
pdf_to_num(ctx, glo->dim[i].pageref),
glo->dim[i].u.dim.bbox->x0,
@@ -691,15 +691,15 @@ printinfo(fz_context *ctx, globals *glo, char *filename, int show, int page)
glo->dim[i].u.dim.bbox->x1,
glo->dim[i].u.dim.bbox->y1);
}
- fz_printf(ctx, out, "\n");
+ fz_write_printf(ctx, out, "\n");
}
if (show & FONTS && glo->fonts > 0)
{
- fz_printf(ctx, out, "Fonts (%d):\n", glo->fonts);
+ fz_write_printf(ctx, out, "Fonts (%d):\n", glo->fonts);
for (i = 0; i < glo->fonts; i++)
{
- fz_printf(ctx, out, PAGE_FMT_zu "%s '%s' %s%s(%d 0 R)\n",
+ fz_write_printf(ctx, out, PAGE_FMT_zu "%s '%s' %s%s(%d 0 R)\n",
glo->font[i].page,
pdf_to_num(ctx, glo->font[i].pageref),
pdf_to_name(ctx, glo->font[i].u.font.subtype),
@@ -708,18 +708,18 @@ printinfo(fz_context *ctx, globals *glo, char *filename, int show, int page)
glo->font[i].u.font.encoding ? " " : "",
pdf_to_num(ctx, glo->font[i].u.font.obj));
}
- fz_printf(ctx, out, "\n");
+ fz_write_printf(ctx, out, "\n");
}
if (show & IMAGES && glo->images > 0)
{
- fz_printf(ctx, out, "Images (%d):\n", glo->images);
+ fz_write_printf(ctx, out, "Images (%d):\n", glo->images);
for (i = 0; i < glo->images; i++)
{
char *cs = NULL;
char *altcs = NULL;
- fz_printf(ctx, out, PAGE_FMT_zu "[ ",
+ fz_write_printf(ctx, out, PAGE_FMT_zu "[ ",
glo->image[i].page,
pdf_to_num(ctx, glo->image[i].pageref));
@@ -734,7 +734,7 @@ printinfo(fz_context *ctx, globals *glo, char *filename, int show, int page)
if (strstr(filter, "Decode"))
*(strstr(filter, "Decode")) = '\0';
- fz_printf(ctx, out, "%s%s",
+ fz_write_printf(ctx, out, "%s%s",
filter,
j == pdf_array_len(ctx, glo->image[i].u.image.filter) - 1 ? "" : " ");
fz_free(ctx, filter);
@@ -748,11 +748,11 @@ printinfo(fz_context *ctx, globals *glo, char *filename, int show, int page)
if (strstr(filter, "Decode"))
*(strstr(filter, "Decode")) = '\0';
- fz_printf(ctx, out, "%s", filter);
+ fz_write_printf(ctx, out, "%s", filter);
fz_free(ctx, filter);
}
else
- fz_printf(ctx, out, "Raw");
+ fz_write_printf(ctx, out, "Raw");
if (glo->image[i].u.image.cs)
{
@@ -793,7 +793,7 @@ printinfo(fz_context *ctx, globals *glo, char *filename, int show, int page)
fz_strlcpy(altcs, "Sep", 4);
}
- fz_printf(ctx, out, " ] %dx%d %dbpc %s%s%s (%d 0 R)\n",
+ fz_write_printf(ctx, out, " ] %dx%d %dbpc %s%s%s (%d 0 R)\n",
pdf_to_int(ctx, glo->image[i].u.image.width),
pdf_to_int(ctx, glo->image[i].u.image.height),
glo->image[i].u.image.bpc ? pdf_to_int(ctx, glo->image[i].u.image.bpc) : 1,
@@ -805,12 +805,12 @@ printinfo(fz_context *ctx, globals *glo, char *filename, int show, int page)
fz_free(ctx, cs);
fz_free(ctx, altcs);
}
- fz_printf(ctx, out, "\n");
+ fz_write_printf(ctx, out, "\n");
}
if (show & SHADINGS && glo->shadings > 0)
{
- fz_printf(ctx, out, "Shading patterns (%d):\n", glo->shadings);
+ fz_write_printf(ctx, out, "Shading patterns (%d):\n", glo->shadings);
for (i = 0; i < glo->shadings; i++)
{
char *shadingtype[] =
@@ -825,18 +825,18 @@ printinfo(fz_context *ctx, globals *glo, char *filename, int show, int page)
"Tensor patch",
};
- fz_printf(ctx, out, PAGE_FMT_zu "%s (%d 0 R)\n",
+ fz_write_printf(ctx, out, PAGE_FMT_zu "%s (%d 0 R)\n",
glo->shading[i].page,
pdf_to_num(ctx, glo->shading[i].pageref),
shadingtype[pdf_to_int(ctx, glo->shading[i].u.shading.type)],
pdf_to_num(ctx, glo->shading[i].u.shading.obj));
}
- fz_printf(ctx, out, "\n");
+ fz_write_printf(ctx, out, "\n");
}
if (show & PATTERNS && glo->patterns > 0)
{
- fz_printf(ctx, out, "Patterns (%d):\n", glo->patterns);
+ fz_write_printf(ctx, out, "Patterns (%d):\n", glo->patterns);
for (i = 0; i < glo->patterns; i++)
{
if (pdf_to_int(ctx, glo->pattern[i].u.pattern.type) == 1)
@@ -855,7 +855,7 @@ printinfo(fz_context *ctx, globals *glo, char *filename, int show, int page)
"Constant/fast tiling",
};
- fz_printf(ctx, out, PAGE_FMT_zu "Tiling %s %s (%d 0 R)\n",
+ fz_write_printf(ctx, out, PAGE_FMT_zu "Tiling %s %s (%d 0 R)\n",
glo->pattern[i].page,
pdf_to_num(ctx, glo->pattern[i].pageref),
painttype[pdf_to_int(ctx, glo->pattern[i].u.pattern.paint)],
@@ -864,22 +864,22 @@ printinfo(fz_context *ctx, globals *glo, char *filename, int show, int page)
}
else
{
- fz_printf(ctx, out, PAGE_FMT_zu "Shading %d 0 R (%d 0 R)\n",
+ fz_write_printf(ctx, out, PAGE_FMT_zu "Shading %d 0 R (%d 0 R)\n",
glo->pattern[i].page,
pdf_to_num(ctx, glo->pattern[i].pageref),
pdf_to_num(ctx, glo->pattern[i].u.pattern.shading),
pdf_to_num(ctx, glo->pattern[i].u.pattern.obj));
}
}
- fz_printf(ctx, out, "\n");
+ fz_write_printf(ctx, out, "\n");
}
if (show & XOBJS && glo->forms > 0)
{
- fz_printf(ctx, out, "Form xobjects (%d):\n", glo->forms);
+ fz_write_printf(ctx, out, "Form xobjects (%d):\n", glo->forms);
for (i = 0; i < glo->forms; i++)
{
- fz_printf(ctx, out, PAGE_FMT_zu "Form%s%s%s%s (%d 0 R)\n",
+ fz_write_printf(ctx, out, PAGE_FMT_zu "Form%s%s%s%s (%d 0 R)\n",
glo->form[i].page,
pdf_to_num(ctx, glo->form[i].pageref),
glo->form[i].u.form.groupsubtype ? " " : "",
@@ -888,20 +888,20 @@ printinfo(fz_context *ctx, globals *glo, char *filename, int show, int page)
glo->form[i].u.form.reference ? " Reference" : "",
pdf_to_num(ctx, glo->form[i].u.form.obj));
}
- fz_printf(ctx, out, "\n");
+ fz_write_printf(ctx, out, "\n");
}
if (show & XOBJS && glo->psobjs > 0)
{
- fz_printf(ctx, out, "Postscript xobjects (%d):\n", glo->psobjs);
+ fz_write_printf(ctx, out, "Postscript xobjects (%d):\n", glo->psobjs);
for (i = 0; i < glo->psobjs; i++)
{
- fz_printf(ctx, out, PAGE_FMT_zu "(%d 0 R)\n",
+ fz_write_printf(ctx, out, PAGE_FMT_zu "(%d 0 R)\n",
glo->psobj[i].page,
pdf_to_num(ctx, glo->psobj[i].pageref),
pdf_to_num(ctx, glo->psobj[i].u.form.obj));
}
- fz_printf(ctx, out, "\n");
+ fz_write_printf(ctx, out, "\n");
}
}
@@ -923,15 +923,15 @@ showinfo(fz_context *ctx, globals *glo, char *filename, int show, const char *pa
while ((pagelist = fz_parse_page_range(ctx, pagelist, &spage, &epage, pagecount)))
{
if (allpages)
- fz_printf(ctx, out, "Retrieving info from pages %d-%d...\n", spage, epage);
+ fz_write_printf(ctx, out, "Retrieving info from pages %d-%d...\n", spage, epage);
for (page = spage; page <= epage; page++)
{
gatherpageinfo(ctx, glo, page, show);
if (!allpages)
{
- fz_printf(ctx, out, "Page %d:\n", page);
+ fz_write_printf(ctx, out, "Page %d:\n", page);
printinfo(ctx, glo, filename, show, page);
- fz_printf(ctx, out, "\n");
+ fz_write_printf(ctx, out, "\n");
clearinfo(ctx, glo);
}
}
@@ -967,7 +967,7 @@ pdfinfo_info(fz_context *ctx, fz_output *out, char *filename, char *password, in
closexref(ctx, &glo);
filename = argv[argidx];
- fz_printf(ctx, out, "%s:\n", filename);
+ fz_write_printf(ctx, out, "%s:\n", filename);
glo.doc = pdf_open_document(glo.ctx, filename);
if (pdf_needs_password(ctx, glo.doc))
if (!pdf_authenticate_password(ctx, glo.doc, password))
diff --git a/source/tools/pdfpages.c b/source/tools/pdfpages.c
index cb6a6a2d..598f7594 100644
--- a/source/tools/pdfpages.c
+++ b/source/tools/pdfpages.c
@@ -31,7 +31,7 @@ showbox(fz_context *ctx, fz_output *out, pdf_obj *page, char *text, pdf_obj *nam
pdf_to_rect(ctx, obj, &bbox);
- fz_printf(ctx, out, "<%s l=\"%g\" b=\"%g\" r=\"%g\" t=\"%g\" />\n", text, bbox.x0, bbox.y0, bbox.x1, bbox.y1);
+ fz_write_printf(ctx, out, "<%s l=\"%g\" b=\"%g\" r=\"%g\" t=\"%g\" />\n", text, bbox.x0, bbox.y0, bbox.x1, bbox.y1);
}
fz_catch(ctx)
{
@@ -53,7 +53,7 @@ shownum(fz_context *ctx, fz_output *out, pdf_obj *page, char *text, pdf_obj *nam
if (!pdf_is_number(ctx, obj))
break;
- fz_printf(ctx, out, "<%s v=\"%g\" />\n", text, pdf_to_real(ctx, obj));
+ fz_write_printf(ctx, out, "<%s v=\"%g\" />\n", text, pdf_to_real(ctx, obj));
}
fz_catch(ctx)
{
@@ -69,7 +69,7 @@ showpage(fz_context *ctx, pdf_document *doc, fz_output *out, int page)
pdf_obj *pageref;
int failed = 0;
- fz_printf(ctx, out, "<page pagenum=\"%d\">\n", page);
+ fz_write_printf(ctx, out, "<page pagenum=\"%d\">\n", page);
fz_try(ctx)
{
pageref = pdf_lookup_page_obj(ctx, doc, page-1);
@@ -78,7 +78,7 @@ showpage(fz_context *ctx, pdf_document *doc, fz_output *out, int page)
}
fz_catch(ctx)
{
- fz_printf(ctx, out, "Failed to gather information for page %d\n", page);
+ fz_write_printf(ctx, out, "Failed to gather information for page %d\n", page);
failed = 1;
}
@@ -93,7 +93,7 @@ showpage(fz_context *ctx, pdf_document *doc, fz_output *out, int page)
failed |= shownum(ctx, out, pageref, "UserUnit", PDF_NAME_UserUnit);
}
- fz_printf(ctx, out, "</page>\n");
+ fz_write_printf(ctx, out, "</page>\n");
return failed;
}
@@ -141,7 +141,7 @@ pdfpages_pages(fz_context *ctx, fz_output *out, char *filename, char *password,
pdf_drop_document(ctx, doc);
filename = argv[argidx];
- fz_printf(ctx, out, "%s:\n", filename);
+ fz_write_printf(ctx, out, "%s:\n", filename);
doc = pdf_open_document(ctx, filename);
if (pdf_needs_password(ctx, doc))
if (!pdf_authenticate_password(ctx, doc, password))
diff --git a/source/tools/pdfshow.c b/source/tools/pdfshow.c
index a6f897ca..03c93da8 100644
--- a/source/tools/pdfshow.c
+++ b/source/tools/pdfshow.c
@@ -25,9 +25,9 @@ static void showtrailer(void)
{
if (!doc)
fz_throw(ctx, FZ_ERROR_GENERIC, "no file specified");
- fz_printf(ctx, out, "trailer\n");
+ fz_write_printf(ctx, out, "trailer\n");
pdf_print_obj(ctx, out, pdf_trailer(ctx, doc), 0);
- fz_printf(ctx, out, "\n");
+ fz_write_printf(ctx, out, "\n");
}
static void showencrypt(void)
@@ -39,9 +39,9 @@ static void showencrypt(void)
encrypt = pdf_dict_get(ctx, pdf_trailer(ctx, doc), PDF_NAME_Encrypt);
if (!encrypt)
fz_throw(ctx, FZ_ERROR_GENERIC, "document not encrypted");
- fz_printf(ctx, out, "encryption dictionary\n");
+ fz_write_printf(ctx, out, "encryption dictionary\n");
pdf_print_obj(ctx, out, pdf_resolve_indirect(ctx, encrypt), 0);
- fz_printf(ctx, out, "\n");
+ fz_write_printf(ctx, out, "\n");
}
static void showxref(void)
@@ -49,7 +49,7 @@ static void showxref(void)
if (!doc)
fz_throw(ctx, FZ_ERROR_GENERIC, "no file specified");
pdf_print_xref(ctx, doc);
- fz_printf(ctx, out, "\n");
+ fz_write_printf(ctx, out, "\n");
}
static void showpagetree(void)
@@ -65,9 +65,9 @@ static void showpagetree(void)
for (i = 0; i < count; i++)
{
ref = pdf_lookup_page_obj(ctx, doc, i);
- fz_printf(ctx, out, "page %d = %d 0 R\n", i + 1, pdf_to_num(ctx, ref));
+ fz_write_printf(ctx, out, "page %d = %d 0 R\n", i + 1, pdf_to_num(ctx, ref));
}
- fz_printf(ctx, out, "\n");
+ fz_write_printf(ctx, out, "\n");
}
static void showsafe(unsigned char *buf, size_t n)
@@ -112,7 +112,7 @@ static void showstream(int num)
if (n == 0)
break;
if (showbinary)
- fz_write(ctx, out, buf, n);
+ fz_write_data(ctx, out, buf, n);
else
showsafe(buf, n);
}
@@ -137,19 +137,19 @@ static void showobject(int num)
}
else
{
- fz_printf(ctx, out, "%d 0 obj\n", num);
+ fz_write_printf(ctx, out, "%d 0 obj\n", num);
pdf_print_obj(ctx, out, obj, 0);
- fz_printf(ctx, out, "\nstream\n");
+ fz_write_printf(ctx, out, "\nstream\n");
showstream(num);
- fz_printf(ctx, out, "endstream\n");
- fz_printf(ctx, out, "endobj\n\n");
+ fz_write_printf(ctx, out, "endstream\n");
+ fz_write_printf(ctx, out, "endobj\n\n");
}
}
else
{
- fz_printf(ctx, out, "%d 0 obj\n", num);
+ fz_write_printf(ctx, out, "%d 0 obj\n", num);
pdf_print_obj(ctx, out, obj, 0);
- fz_printf(ctx, out, "\nendobj\n\n");
+ fz_write_printf(ctx, out, "\nendobj\n\n");
}
pdf_drop_obj(ctx, obj);
@@ -178,17 +178,17 @@ static void showgrep(char *filename)
pdf_sort_dict(ctx, obj);
- fz_printf(ctx, out, "%s:%d: ", filename, i);
+ fz_write_printf(ctx, out, "%s:%d: ", filename, i);
pdf_print_obj(ctx, out, obj, 1);
- fz_printf(ctx, out, "\n");
+ fz_write_printf(ctx, out, "\n");
pdf_drop_obj(ctx, obj);
}
}
- fz_printf(ctx, out, "%s:trailer: ", filename);
+ fz_write_printf(ctx, out, "%s:trailer: ", filename);
pdf_print_obj(ctx, out, pdf_trailer(ctx, doc), 1);
- fz_printf(ctx, out, "\n");
+ fz_write_printf(ctx, out, "\n");
}
static void showoutline(void)