diff options
Diffstat (limited to 'base/spprint.c')
-rw-r--r-- | base/spprint.c | 72 |
1 files changed, 68 insertions, 4 deletions
diff --git a/base/spprint.c b/base/spprint.c index cc12d397..a72a0c30 100644 --- a/base/spprint.c +++ b/base/spprint.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2001-2019 Artifex Software, Inc. +/* Copyright (C) 2001-2020 Artifex Software, Inc. All Rights Reserved. This software is provided AS-IS with no warranty, either express or @@ -156,7 +156,7 @@ pprintg6(stream * s, const char *format, double v1, double v2, double v3, /* Print a long value using a format. */ const char * -pprintld1(stream * s, const char *format, long v) +pprintld1(stream *s, const char *format, long v) { const char *fp = pprintf_scan(s, format); char str[25]; @@ -170,16 +170,80 @@ pprintld1(stream * s, const char *format, long v) return pprintf_scan(s, fp + 3); } const char * -pprintld2(stream * s, const char *format, long v1, long v2) +pprintld2(stream *s, const char *format, long v1, long v2) { return pprintld1(s, pprintld1(s, format, v1), v2); } const char * -pprintld3(stream * s, const char *format, long v1, long v2, long v3) +pprintld3(stream *s, const char *format, long v1, long v2, long v3) { return pprintld2(s, pprintld1(s, format, v1), v2, v3); } +/* Print a size_t value using a format. */ +const char * +pprintzd1(stream *s, const char *format, size_t v) +{ + const char *fp = pprintf_scan(s, format); + char str[25]; + const size_t z = strlen("%"PRIdSIZE); + +#ifdef DEBUG + size_t i; + + for (i = 0; i < z; i++) + if (fp[i] != ("%"PRIdSIZE)[i]) + break; + if (i != z) + lprintf1("Bad format in pprintzd: %s\n", format); +#endif + gs_sprintf(str, "%"PRIdSIZE, v); + pputs_short(s, str); + return pprintf_scan(s, fp + z); +} +const char * +pprintzd2(stream *s, const char *format, size_t v1, size_t v2) +{ + return pprintzd1(s, pprintzd1(s, format, v1), v2); +} +const char * +pprintzd3(stream *s, const char *format, size_t v1, size_t v2, size_t v3) +{ + return pprintzd2(s, pprintzd1(s, format, v1), v2, v3); +} + +/* Print an int64_t value using a format. */ +const char * +pprinti64d1(stream *s, const char *format, int64_t v) +{ + const char *fp = pprintf_scan(s, format); + char str[25]; + const size_t z = strlen("%"PRId64); + +#ifdef DEBUG + size_t i; + + for (i = 0; i < z; i++) + if (fp[i] != ("%"PRId64)[i]) + break; + if (i != z) + lprintf1("Bad format in pprinti64d: %s\n", format); +#endif + gs_sprintf(str, "%"PRId64, v); + pputs_short(s, str); + return pprintf_scan(s, fp + z); +} +const char * +pprinti64d2(stream *s, const char *format, int64_t v1, int64_t v2) +{ + return pprinti64d1(s, pprinti64d1(s, format, v1), v2); +} +const char * +pprinti64d3(stream *s, const char *format, int64_t v1, int64_t v2, int64_t v3) +{ + return pprinti64d2(s, pprinti64d1(s, format, v1), v2, v3); +} + /* Print (a) string(s) using a format. */ const char * pprints1(stream * s, const char *format, const char *str) |