summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjvoisin2023-10-01 22:06:17 +0200
committerjvoisin2023-10-01 22:06:17 +0200
commit32b21b7d85383df49030b18240c1409e73001066 (patch)
tree461982e80c5dc2f1c99f11fe94efa2c8557a73fa
parent6a801d8a749da3889ec57030cee09d1d60b4663e (diff)
Add vfprintf`
-rw-r--r--include/stdio.h16
-rw-r--r--tests/Makefile1
-rw-r--r--tests/test_fprintf.c7
-rw-r--r--tests/test_vfprintf.c16
4 files changed, 40 insertions, 0 deletions
diff --git a/include/stdio.h b/include/stdio.h
index 3bbee38..491de27 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -183,7 +183,23 @@ _FORTIFY_FN(vsprintf) int vsprintf(char * _FORTIFY_POS0 __s, const char *__f,
183} 183}
184 184
185#ifndef __clang__ /* FIXME */ 185#ifndef __clang__ /* FIXME */
186#undef vfprintf
186#undef vprintf 187#undef vprintf
188
189__access(read_only, 2)
190__format(printf, 2, 0)
191#if __has_builtin(__builtin_vfprintf)
192__diagnose_as_builtin(__builtin_vfprintf, 2, 3)
193#endif
194_FORTIFY_FN(vfprintf) int vfprintf(FILE * __s, const char *__f, __builtin_va_list __v)
195{
196#if __has_builtin(__builtin___vfprintf_chk) && USE_NATIVE_CHK
197 return __builtin___vfprintf_chk(__s, _FORTIFY_SOURCE, __f, __v);
198#else
199 return __orig_vfprintf(__s, __f, __v);
200#endif
201}
202
187__access(read_only, 1) 203__access(read_only, 1)
188__format(printf, 1, 0) 204__format(printf, 1, 0)
189#if __has_builtin(__builtin_vprintf) 205#if __has_builtin(__builtin_vprintf)
diff --git a/tests/Makefile b/tests/Makefile
index 445ac9c..5f70069 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -114,6 +114,7 @@ RUNTIME_TARGETS= \
114 test_vsnprintf_dynamic \ 114 test_vsnprintf_dynamic \
115 test_vsnprintf_static \ 115 test_vsnprintf_static \
116 test_vsprintf \ 116 test_vsprintf \
117 test_vfprintf \
117 test_vprintf \ 118 test_vprintf \
118 test_wcscat_static_write \ 119 test_wcscat_static_write \
119 test_wcscpy_static_write \ 120 test_wcscpy_static_write \
diff --git a/tests/test_fprintf.c b/tests/test_fprintf.c
new file mode 100644
index 0000000..ab83f11
--- /dev/null
+++ b/tests/test_fprintf.c
@@ -0,0 +1,7 @@
1#include "common.h"
2
3#include <stdio.h>
4
5int main(int argc, char** argv) {
6 fprintf(stdout, "%s", "1234567");
7}
diff --git a/tests/test_vfprintf.c b/tests/test_vfprintf.c
new file mode 100644
index 0000000..8ccf994
--- /dev/null
+++ b/tests/test_vfprintf.c
@@ -0,0 +1,16 @@
1#include "common.h"
2
3#include <stdarg.h>
4#include <stdio.h>
5
6void wrap(char *format, ...) {
7 va_list args;
8 va_start(args, format);
9 vfprintf(stdout, format, args);
10 va_end(args);
11}
12
13
14int main(int argc, char** argv) {
15 wrap("%s", "1234567");
16}