gcc/collect2.c, gcc/collect2.h: Use ngettext() when needed
Marco Poletti
poletti.marco@gmail.com
Fri Jan 8 07:10:00 GMT 2010
In the file collect2.c, there were translatable strings like "%d
constructor(s) found\n" that are hard to translate.
Instead, it should use the ngettext() function to allow more flexible
translations.
I have added the function header to collect2.h, don't know if this is
considered good/bad practice in GCC.
NOTE: This is my first code commit to an OSS project, so I could have
done many mistakes :-)
Critics are very appreciated.
* gcc/collect2.c, gcc/collect2.h: Use ngettext() when needed
Index: gcc/collect2.c
===================================================================
--- gcc/collect2.c (revisione 155698)
+++ gcc/collect2.c (copia locale)
@@ -430,6 +430,17 @@ notice (const char *cmsgid, ...)
va_end (ap);
}
+/* Notify user of a non-error, without translating the format string. */
+void
+notice_dont_translate (const char *cmsgid, ...)
+{
+ va_list ap;
+
+ va_start (ap, cmsgid);
+ vfprintf (stderr, cmsgid, ap);
+ va_end (ap);
+}
+
/* Die when sys call fails. */
void
@@ -1806,9 +1817,12 @@ main (int argc, char **argv)
if (debug)
{
- notice ("%d constructor(s) found\n", constructors.number);
- notice ("%d destructor(s) found\n", destructors.number);
- notice ("%d frame table(s) found\n", frame_tables.number);
+ notice_dont_translate (ngettext("%d constructor found\n",
+ "%d constructors found\n", constructors.number), constructors.number);
+ notice_dont_translate (ngettext("%d destructor found\n",
+ "%d destructors found\n", destructors.number), destructors.number);
+ notice_dont_translate (ngettext("%d frame table found\n",
+ "%d frame tables found\n", frame_tables.number), frame_tables.number);
}
/* If the scan exposed nothing of special interest, there's no need to
Index: gcc/collect2.h
===================================================================
--- gcc/collect2.h (revisione 155698)
+++ gcc/collect2.h (copia locale)
@@ -41,6 +41,7 @@ extern char *temporary_firstobj;
extern int vflag, debug;
extern void error (const char *, ...) ATTRIBUTE_PRINTF_1;
+extern void notice_dont_translate (const char *, ...) ATTRIBUTE_PRINTF_1;
extern void notice (const char *, ...) ATTRIBUTE_PRINTF_1;
extern void fatal (const char *, ...) ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN;
extern void fatal_perror (const char *, ...)
More information about the Gcc-patches
mailing list