This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gcc/collect2.c, gcc/collect2.h: Use ngettext() when needed


[...]
>> First note that once the points below have been addressed I think the
>> change will be over the threshold for needing a copyright assignment, so
>> you should start the process for that now. ?See
>> <http://gcc.gnu.org/wiki/CopyrightAssignment>. ?(I see you already have
>> translation disclaimers on file at the FSF, but they don't cover changes
>> to the code itself.)
>>
>
> I have sent the required e-mail.
> I will reply again to this mail when the copyright assignment process
> is complete.

I have now completed the copyright assignment procedure.
I post the updated patch, tested with "make bootstrap" and "make
bootstrap --disable-nls".
Critics are appreciated, this will be my first commit.

Changelog:
       * intl.c (fake_ngettext): New function.
       * intl.h (fake_ngettext): Declare.
       (ngettext): Define macro.
       * collect2.c (notice_translated): New function.
       (main): Use notice_translated and ngettext.
       * collect2.h (notice_translated): Declare.

Actual patch:

Index: gcc/intl.c
===================================================================
--- gcc/intl.c	(revisione 156750)
+++ gcc/intl.c	(copia locale)
@@ -121,6 +121,19 @@ gcc_gettext_width (const char *msgstr)

 #endif /* ENABLE_NLS */

+#ifndef ENABLE_NLS
+
+const char *
+fake_ngettext (const char *singular, const char *plural, unsigned long n)
+{
+  if (n == 1UL)
+    return singular;
+
+  return plural;
+}
+
+#endif
+
 /* Return the indent for successive lines, using the width of
    the STR.  STR must have been translated already.  The string
    must be freed by the caller.  */
Index: gcc/intl.h
===================================================================
--- gcc/intl.h	(revisione 156750)
+++ gcc/intl.h	(copia locale)
@@ -38,8 +38,13 @@ extern size_t gcc_gettext_width (const c
 # define bindtextdomain(domain, directory) (domain)
 # undef gettext
 # define gettext(msgid) (msgid)
+# define ngettext(singular,plural,n) fake_ngettext(singular,plural,n)
 # define gcc_init_libintl()	/* nothing */
 # define gcc_gettext_width(s) strlen(s)
+
+extern const char *fake_ngettext(const char *singular,const char *plural,
+                                 unsigned long int n);
+
 #endif

 #ifndef _
Index: gcc/collect2.c
===================================================================
--- gcc/collect2.c	(revisione 156750)
+++ 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_translated (const char *cmsgid, ...)
+{
+  va_list ap;
+
+  va_start (ap, cmsgid);
+  vfprintf (stderr, cmsgid, ap);
+  va_end (ap);
+}
+
 /* Die when sys call fails.  */

 void
@@ -1809,9 +1820,18 @@ 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_translated (ngettext ("%d constructor found\n",
+                                   "%d constructors found\n",
+                                   constructors.number),
+                         constructors.number);
+      notice_translated (ngettext ("%d destructor found\n",
+                                   "%d destructors found\n",
+                                   destructors.number),
+                         destructors.number);
+      notice_translated (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 156750)
+++ 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_translated (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 *, ...)


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