Renamed asprintf to cr_asprintf for compatibility
This commit is contained in:
parent
29860d46be
commit
5247808140
4 changed files with 9 additions and 23 deletions
|
@ -98,6 +98,7 @@ set(SOURCE_FILES
|
|||
src/ordered-set.c
|
||||
src/posix-compat.c
|
||||
src/theories.c
|
||||
src/asprintf.c
|
||||
src/main.c
|
||||
src/entry.c
|
||||
)
|
||||
|
@ -110,12 +111,6 @@ if (PCRE_FOUND)
|
|||
set(HAVE_PCRE 1)
|
||||
endif ()
|
||||
|
||||
if ("${CMAKE_SYSTEM_NAME}" EQUAL "Linux")
|
||||
set (SOURCE_FILES ${SOURCE_FILES}
|
||||
src/asprintf.c
|
||||
)
|
||||
endif ()
|
||||
|
||||
set(INTERFACE_FILES
|
||||
include/criterion/assert.h
|
||||
include/criterion/abort.h
|
||||
|
|
|
@ -24,30 +24,20 @@
|
|||
#ifndef CRITERION_ASPRINTF_COMPAT_H_
|
||||
# define CRITERION_ASPRINTF_COMPAT_H_
|
||||
|
||||
# ifdef __UNIX__
|
||||
# define _GNU_SOURCE 1
|
||||
# endif
|
||||
|
||||
# ifdef __cplusplus
|
||||
# include <cstdarg>
|
||||
# else
|
||||
# include <stdarg.h>
|
||||
# endif
|
||||
|
||||
# ifdef __UNIX__
|
||||
# include <stdio.h>
|
||||
# else
|
||||
|
||||
# include "common.h"
|
||||
# include "common.h"
|
||||
|
||||
CR_BEGIN_C_API
|
||||
|
||||
FORMAT(printf, 2, 3)
|
||||
CR_API int asprintf(char **strp, const char *fmt, ...) CR_NOTHROW;
|
||||
CR_API int vasprintf(char **strp, const char *fmt, va_list ap) CR_NOTHROW;
|
||||
CR_API int cr_asprintf(char **strp, const char *fmt, ...);
|
||||
CR_API int cr_vasprintf(char **strp, const char *fmt, va_list ap);
|
||||
|
||||
CR_END_C_API
|
||||
|
||||
# endif
|
||||
|
||||
#endif /* !CRITERION_ASPRINTF_COMPAT_H_ */
|
||||
|
|
|
@ -67,7 +67,7 @@ struct criterion_assert_args {
|
|||
do { \
|
||||
const char *default_msg = "" CR_VA_HEAD(__VA_ARGS__); \
|
||||
char *formatted_msg = NULL; \
|
||||
int msglen = asprintf(&formatted_msg, "" CR_VA_TAIL(__VA_ARGS__)); \
|
||||
int msglen = cr_asprintf(&formatted_msg, "" CR_VA_TAIL(__VA_ARGS__));\
|
||||
MsgVar = formatted_msg && *formatted_msg ? \
|
||||
formatted_msg : default_msg; \
|
||||
\
|
||||
|
|
|
@ -24,17 +24,18 @@
|
|||
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "criterion/asprintf-compat.h"
|
||||
|
||||
int asprintf(char **strp, const char *fmt, ...) {
|
||||
int cr_asprintf(char **strp, const char *fmt, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
int res = vasprintf(strp, fmt, ap);
|
||||
int res = cr_vasprintf(strp, fmt, ap);
|
||||
va_end(ap);
|
||||
return res;
|
||||
}
|
||||
|
||||
int vasprintf(char **strp, const char *fmt, va_list ap) {
|
||||
int cr_vasprintf(char **strp, const char *fmt, va_list ap) {
|
||||
va_list vl;
|
||||
va_copy(vl, ap);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue