]> granicus.if.org Git - php/commitdiff
MFH automatic format checks
authorSascha Schumann <sas@php.net>
Thu, 28 Aug 2003 05:25:26 +0000 (05:25 +0000)
committerSascha Schumann <sas@php.net>
Thu, 28 Aug 2003 05:25:26 +0000 (05:25 +0000)
main/php.h
main/snprintf.h
main/spprintf.h

index e199941915cc02305ab4b3248d1078892d53ae08..e77c9c30bf39eab6559c7f491ee232c217b7f26e 100644 (file)
@@ -220,6 +220,12 @@ char *strerror(int);
 #define LONG_MIN (- LONG_MAX - 1)
 #endif
 
+#ifdef __GNUC__
+# define PHP_ATTRIBUTE_FORMAT(type, idx, first) __attribute__ ((format(type, idx, first)))
+#else
+# define PHP_ATTRIBUTE_FORMAT(type, idx, first)
+#endif
+
 #if !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF) || PHP_BROKEN_SPRINTF || PHP_BROKEN_SNPRINTF || PHP_BROKEN_VSNPRINTF
 #include "snprintf.h"
 #endif
index 4443a6cfc2d4adb4a83a5511f9681c338cd61c2c..ff92a80a6bdf8d11001bf19ecd16dbc2c0d16e1e 100644 (file)
@@ -63,17 +63,17 @@ Example:
 #define SNPRINTF_H
 
 #if !defined(HAVE_SNPRINTF) || PHP_BROKEN_SNPRINTF
-extern int ap_php_snprintf(char *, size_t, const char *, ...);
+int ap_php_snprintf(char *, size_t, const char *, ...) PHP_ATTRIBUTE_FORMAT(printf, 3, 4);
 #define snprintf ap_php_snprintf
 #endif
 
 #if !defined(HAVE_VSNPRINTF) || PHP_BROKEN_VSNPRINTF
-extern int ap_php_vsnprintf(char *, size_t, const char *, va_list ap);
+int ap_php_vsnprintf(char *, size_t, const char *, va_list ap) PHP_ATTRIBUTE_FORMAT(printf, 3, 0);
 #define vsnprintf ap_php_vsnprintf
 #endif
 
 #if PHP_BROKEN_SPRINTF
-int php_sprintf (char* s, const char* format, ...);
+int php_sprintf (char* s, const char* format, ...) PHP_ATTRIBUTE_FORMAT(printf, 2, 3);
 #define sprintf php_sprintf
 #endif
 
index 23ecfddb54409ea293032bcbdc915174d98b19b0..54f2273679ffd1892caa12cfe2828582a27e4a51 100644 (file)
@@ -35,9 +35,9 @@ There is also snprintf: See difference explained in snprintf.h
 #include "snprintf.h"
 
 BEGIN_EXTERN_C()
-PHPAPI extern int spprintf( char **pbuf, size_t max_len, const char *format, ...);
+PHPAPI int spprintf( char **pbuf, size_t max_len, const char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 3, 4);
 
-PHPAPI extern int vspprintf(char **pbuf, size_t max_len, const char *format, va_list ap);
+PHPAPI int vspprintf(char **pbuf, size_t max_len, const char *format, va_list ap) PHP_ATTRIBUTE_FORMAT(printf, 3, 0);
 END_EXTERN_C()
 
 #endif /* SNPRINTF_H */