This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: intl patches (21)


Joseph S. Myers writes:
> The correct solution is to specify both format_arg attributes.  At present
> the last one specified will silently override the previous ones - but once
> I've implemented getting these attributes attached to the function type,
> with multiple attributes allowed, checking against both of them will start
> working, using the support already present in GCC 3 for checking both
> branches of a conditional expression - and this will suppress the warning
> about extra arguments if it occurs in some but not all branches.

That will indeed be the optimal solution. Here is an updated patch.

Bruno


2001-07-22  Bruno Haible  <haible@clisp.cons.org>

	* intl/libintl.h (ngettext, dngettext, dcngettext): Use both msgid1
	and msgid2 for printf format argument checking.

*** glibc-20010626/misc/sys/cdefs.h.bak	Wed Jun  6 14:16:30 2001
--- glibc-20010626/misc/sys/cdefs.h	Tue Jul 24 01:15:31 2001
***************
*** 162,168 ****
  
  /* At some point during the gcc 2.8 development the `format_arg' 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,8)
  # define __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x)))
  #else
--- 162,171 ----
  
  /* At some point during the gcc 2.8 development the `format_arg' attribute
     for functions was introduced.  We don't want to use it unconditionally
!    (although this would be possible) since it generates warnings.
!    If several `format_arg' attributes are given for the same function, in
!    gcc-3.0 and older, all but the last one are ignored.  In newer gccs,
!    all designated arguments are considered.  */
  #if __GNUC_PREREQ (2,8)
  # define __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x)))
  #else
*** glibc-20010626/intl/libintl.h.bak	Sat Oct 21 23:57:05 2000
--- glibc-20010626/intl/libintl.h	Tue Jul 24 01:08:32 2001
***************
*** 53,72 ****
     number N.  */
  extern char *ngettext (__const char *__msgid1, __const char *__msgid2,
  		       unsigned long int __n)
!      __THROW __attribute_format_arg__ (1);
  
  /* Similar to `dgettext' but select the plural form corresponding to the
     number N.  */
  extern char *dngettext (__const char *__domainname, __const char *__msgid1,
  			__const char *__msgid2, unsigned long int __n)
!      __THROW __attribute_format_arg__ (2);
  
  /* Similar to `dcgettext' but select the plural form corresponding to the
     number N.  */
  extern char *dcngettext (__const char *__domainname, __const char *__msgid1,
  			 __const char *__msgid2, unsigned long int __n,
  			 int __category)
!      __THROW __attribute_format_arg__ (2);
  
  
  /* Set the current default message catalog to DOMAINNAME.
--- 53,72 ----
     number N.  */
  extern char *ngettext (__const char *__msgid1, __const char *__msgid2,
  		       unsigned long int __n)
!      __THROW __attribute_format_arg__ (1) __attribute_format_arg__ (2);
  
  /* Similar to `dgettext' but select the plural form corresponding to the
     number N.  */
  extern char *dngettext (__const char *__domainname, __const char *__msgid1,
  			__const char *__msgid2, unsigned long int __n)
!      __THROW __attribute_format_arg__ (2) __attribute_format_arg__ (3);
  
  /* Similar to `dcgettext' but select the plural form corresponding to the
     number N.  */
  extern char *dcngettext (__const char *__domainname, __const char *__msgid1,
  			 __const char *__msgid2, unsigned long int __n,
  			 int __category)
!      __THROW __attribute_format_arg__ (2) __attribute_format_arg__ (3);
  
  
  /* Set the current default message catalog to DOMAINNAME.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]