cmark

My personal build of CMark ✏️

Commit
2a9409f587eec1acd7a98cbd5dacc31ac3525812
Parent
b018c01fad3b0c6dd9c180b3ba804baee326d9dd
Author
John MacFarlane <jgm@berkeley.edu>
Date

Removed cmark_strbuf_printf and cmark_strbuf_vprintf.

These are no longer needed, and cause complications for MSVC. Also removed HAVE_VA_COPY and HAVE_C99_SNPRINTF feature tests.

Diffstat

4 files changed, 0 insertions, 64 deletions

Status File Name N° Changes Insertions Deletions
Modified src/CMakeLists.txt 5 0 5
Modified src/buffer.c 48 0 48
Modified src/buffer.h 3 0 3
Modified src/config.h.in 8 0 8
diff --git 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
@@ -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
@@ -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
@@ -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