This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Patch for strfmon format attributes in glibc
- To: libc-alpha at sources dot redhat dot com
- Subject: Patch for strfmon format attributes in glibc
- From: "Joseph S. Myers" <jsm28 at cam dot ac dot uk>
- Date: Thu, 28 Dec 2000 18:56:49 +0000 (GMT)
I've just added support for checking strfmon formats to GCC. Here's
the corresponding glibc patch.
2000-12-28 Joseph S. Myers <jsm28@cam.ac.uk>
* misc/sys/cdefs.h (__attribute_format_strfmon__): Define.
* stdlib/monetary.h: Add strfmon format attributes.
--- misc/sys/cdefs.h.orig Fri Dec 15 14:27:13 2000
+++ misc/sys/cdefs.h Thu Dec 28 18:46:00 2000
@@ -169,6 +169,16 @@
# define __attribute_format_arg__(x) /* Ignore */
#endif
+/* At some point during the gcc 2.97 development the `strfmon' format
+ attribute for functions was introduced. We don't want to use it
+ unconditionally (although this would be possible) since it
+ generates warnings. */
+#if __GNUC_PREREQ (2,97)
+# define __attribute_format_strfmon__(a,b) __attribute__ ((__format__ (__strfmon__, a, b)))
+#else
+# define __attribute_format_strfmon__(a,b) /* Ignore */
+#endif
+
/* It is possible to compile containing GCC extensions even if GCC is
run in pedantic mode if the uses are carefully marked using the
`__extension__' keyword. But this is not generally available before
--- stdlib/monetary.h.orig Sat Oct 9 21:24:18 1999
+++ stdlib/monetary.h Thu Dec 28 18:47:58 2000
@@ -37,7 +37,8 @@
/* Formatting a monetary value according to the current locale. */
extern ssize_t strfmon (char *__restrict __s, size_t __maxsize,
- __const char *__restrict __format, ...) __THROW;
+ __const char *__restrict __format, ...)
+ __THROW __attribute_format_strfmon__ (3, 4);
#ifdef __USE_GNU
# include <xlocale.h>
@@ -45,7 +46,8 @@
/* Formatting a monetary value according to the current locale. */
extern ssize_t __strfmon_l (char *__restrict __s, size_t __maxsize,
__locale_t loc,
- __const char *__restrict __format, ...) __THROW;
+ __const char *__restrict __format, ...)
+ __THROW __attribute_format_strfmon__ (4, 5);
#endif
__END_DECLS
--
Joseph S. Myers
jsm28@cam.ac.uk