summarylogtreecommitdiffstats
path: root/0051-use-gnu_printf-in-format.patch
blob: d73adaa667d8e19d6cdd594b364350f8ae0dd54a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
From c25ea3b8769fa270074f16ead5f119260219d127 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9?=
 <alexey.pawlow@gmail.com>
Date: Thu, 17 Jun 2021 18:52:03 +0530
Subject: [PATCH 051/N] use gnu_printf in format
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Алексей <alexey.pawlow@gmail.com>
---
 Include/bytesobject.h | 4 ++--
 Include/pyerrors.h    | 4 ++--
 Include/pyport.h      | 6 ++++++
 Include/sysmodule.h   | 4 ++--
 4 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/Include/bytesobject.h b/Include/bytesobject.h
index 5062d8d..627e8b2 100644
--- a/Include/bytesobject.h
+++ b/Include/bytesobject.h
@@ -38,9 +38,9 @@ PyAPI_FUNC(PyObject *) PyBytes_FromStringAndSize(const char *, Py_ssize_t);
 PyAPI_FUNC(PyObject *) PyBytes_FromString(const char *);
 PyAPI_FUNC(PyObject *) PyBytes_FromObject(PyObject *);
 PyAPI_FUNC(PyObject *) PyBytes_FromFormatV(const char*, va_list)
-                                Py_GCC_ATTRIBUTE((format(printf, 1, 0)));
+                                Py_PRINTF(1, 0);
 PyAPI_FUNC(PyObject *) PyBytes_FromFormat(const char*, ...)
-                                Py_GCC_ATTRIBUTE((format(printf, 1, 2)));
+                                Py_PRINTF(1, 2);
 PyAPI_FUNC(Py_ssize_t) PyBytes_Size(PyObject *);
 PyAPI_FUNC(char *) PyBytes_AsString(PyObject *);
 PyAPI_FUNC(PyObject *) PyBytes_Repr(PyObject *, int);
diff --git a/Include/pyerrors.h b/Include/pyerrors.h
index 979a26b..28cfb0f 100644
--- a/Include/pyerrors.h
+++ b/Include/pyerrors.h
@@ -310,9 +310,9 @@ PyAPI_FUNC(int) PyUnicodeTranslateError_SetReason(
     );
 
 PyAPI_FUNC(int) PyOS_snprintf(char *str, size_t size, const char  *format, ...)
-                        Py_GCC_ATTRIBUTE((format(printf, 3, 4)));
+                        Py_PRINTF(3, 4);
 PyAPI_FUNC(int) PyOS_vsnprintf(char *str, size_t size, const char  *format, va_list va)
-                        Py_GCC_ATTRIBUTE((format(printf, 3, 0)));
+                        Py_PRINTF(3, 0);
 
 #ifndef Py_LIMITED_API
 #  define Py_CPYTHON_ERRORS_H
diff --git a/Include/pyport.h b/Include/pyport.h
index a05fa3a..0972630 100644
--- a/Include/pyport.h
+++ b/Include/pyport.h
@@ -798,6 +798,12 @@ extern char * _getpty(int *, int, mode_t, int);
 
 #define Py_VA_COPY va_copy
 
+#if defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__>= 4) || __GNUC__ > 4)
+#  define Py_PRINTF(X,Y) Py_GCC_ATTRIBUTE((format(gnu_printf,X,Y)))
+#else
+#  define Py_PRINTF(X,Y) Py_GCC_ATTRIBUTE((format(printf,X,Y))) 
+#endif
+
 /*
  * Convenient macros to deal with endianness of the platform. WORDS_BIGENDIAN is
  * detected by configure and defined in pyconfig.h. The code in pyconfig.h
diff --git a/Include/sysmodule.h b/Include/sysmodule.h
index 670e5d2..d582963 100644
--- a/Include/sysmodule.h
+++ b/Include/sysmodule.h
@@ -15,9 +15,9 @@ PyAPI_FUNC(void) PySys_SetArgvEx(int, wchar_t **, int);
 PyAPI_FUNC(void) PySys_SetPath(const wchar_t *);
 
 PyAPI_FUNC(void) PySys_WriteStdout(const char *format, ...)
-                 Py_GCC_ATTRIBUTE((format(printf, 1, 2)));
+                 Py_PRINTF(1, 2);
 PyAPI_FUNC(void) PySys_WriteStderr(const char *format, ...)
-                 Py_GCC_ATTRIBUTE((format(printf, 1, 2)));
+                 Py_PRINTF(1, 2);
 PyAPI_FUNC(void) PySys_FormatStdout(const char *format, ...);
 PyAPI_FUNC(void) PySys_FormatStderr(const char *format, ...);
 
-- 
2.33.0