diff options
-rw-r--r-- | src/CMakeLists.txt | 5 | ||||
-rw-r--r-- | src/buffer.c | 48 | ||||
-rw-r--r-- | src/buffer.h | 3 | ||||
-rw-r--r-- | src/config.h.in | 8 |
4 files changed, 0 insertions, 64 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b40c1ac..80ecfc2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -139,11 +139,6 @@ CHECK_C_SOURCE_COMPILES(" int f(void) __attribute__ (()); int main() { return 0; } " HAVE___ATTRIBUTE__) -CHECK_C_SOURCE_RUNS(" - #include <stdio.h> - int main() { return snprintf(NULL, 0, \"123\") == 3 ? 0 : 1; } -" HAVE_C99_SNPRINTF) -CHECK_SYMBOL_EXISTS(va_copy stdarg.h HAVE_VA_COPY) CONFIGURE_FILE( ${CMAKE_CURRENT_SOURCE_DIR}/config.h.in diff --git a/src/buffer.c b/src/buffer.c index e07fba6..509eb6c 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -165,54 +165,6 @@ void cmark_strbuf_puts(cmark_strbuf *buf, const char *string) cmark_strbuf_safe_strlen(string)); } -void cmark_strbuf_vprintf(cmark_strbuf *buf, const char *format, va_list ap) -{ - size_t expected_size = strlen(format); - if (expected_size <= SIZE_MAX / 2) - expected_size *= 2; - S_strbuf_grow_by(buf, expected_size); - - while (1) { - va_list args; - va_copy(args, ap); - - int len = vsnprintf( - (char *)buf->ptr + buf->size, - buf->asize - buf->size, - format, args - ); -#ifndef HAVE_C99_SNPRINTF - // Assume we're on Windows. - if (len < 0) { - len = _vscprintf(format, args); - } -#endif - - va_end(args); - - if (len < 0) { - perror("vsnprintf in cmark_strbuf_vprintf"); - abort(); - } - - if ((size_t)len < (size_t)(buf->asize - buf->size)) { - buf->size += len; - break; - } - - S_strbuf_grow_by(buf, len); - } -} - -void cmark_strbuf_printf(cmark_strbuf *buf, const char *format, ...) -{ - va_list ap; - - va_start(ap, format); - cmark_strbuf_vprintf(buf, format, ap); - va_end(ap); -} - void cmark_strbuf_copy_cstr(char *data, bufsize_t datasize, const cmark_strbuf *buf) { bufsize_t copylen; diff --git a/src/buffer.h b/src/buffer.h index babd051..36ae0a1 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -58,9 +58,6 @@ void cmark_strbuf_sets(cmark_strbuf *buf, const char *string); void cmark_strbuf_putc(cmark_strbuf *buf, int c); void cmark_strbuf_put(cmark_strbuf *buf, const unsigned char *data, bufsize_t len); void cmark_strbuf_puts(cmark_strbuf *buf, const char *string); -void cmark_strbuf_printf(cmark_strbuf *buf, const char *format, ...) - CMARK_ATTRIBUTE((format (printf, 2, 3))); -void cmark_strbuf_vprintf(cmark_strbuf *buf, const char *format, va_list ap); void cmark_strbuf_clear(cmark_strbuf *buf); bufsize_t cmark_strbuf_strchr(const cmark_strbuf *buf, int c, bufsize_t pos); diff --git a/src/config.h.in b/src/config.h.in index 5960928..5294bc9 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -15,11 +15,3 @@ #else #define CMARK_ATTRIBUTE(list) #endif - -#cmakedefine HAVE_VA_COPY - -#ifndef HAVE_VA_COPY - #define va_copy(dest, src) ((dest) = (src)) -#endif - -#cmakedefine HAVE_C99_SNPRINTF |