OSDN Git Service

Fix date on last entry.
[pf3gnuchains/gcc-fork.git] / gcc / ABOUT-GCC-NLS
1 Notes on GCC's Native Language Support
2
3 GCC's Native Language Support (NLS) is relatively new and
4 experimental, so NLS is currently disabled by default.  Use
5 configure's --enable-nls option to enable it.  Eventually, NLS will be
6 enabled by default, and you'll need --disable-nls to disable it.  You
7 must enable NLS in order to make a GCC distribution.
8
9 By and large, only diagnostic messages have been internationalized.
10 Some work remains in other areas; for example, GCC does not yet allow
11 non-ASCII letters in identifiers.
12
13 Not all of GCC's diagnostic messages have been internationalized.
14 Programs like `enquire' and `genattr' are not internationalized, as
15 their users are GCC maintainers who typically need to be able to read
16 English anyway; internationalizing them would thus entail needless
17 work for the human translators.  And no one has yet gotten around to
18 internationalizing the messages in the C++ compiler, or in the
19 specialized MIPS-specific programs mips-tdump and mips-tfile.
20
21 The GCC library should not contain any messages that need
22 internationalization, because it operates below the
23 internationalization library.
24
25 Currently, the only language translation supplied is en_UK (British English).
26
27 Unlike some other GNU programs, the GCC sources contain few instances
28 of explicit translation calls like _("string").  Instead, the
29 diagnostic printing routines automatically translate their arguments.
30 For example, GCC source code should not contain calls like `error
31 (_("unterminated comment"))'; it should contain calls like `error
32 ("unterminated comment")' instead, as it is the `error' function's
33 responsibility to translate the message before the user sees it.
34
35 By convention, any function parameter in the GCC sources whose name
36 ends in `msgid' is expected to be a message requiring translation.
37 For example, the `error' function's first parameter is named `msgid'.
38 GCC's exgettext script uses this convention to determine which
39 function parameter strings need to be translated.  The exgettext
40 script also assumes that any occurrence of `%eMSGID}' on a source
41 line, where MSGID does not contain `%' or `}', corresponds to a
42 message MSGID that requires translation; this is needed to identify
43 diagnostics in GCC spec strings.
44
45 If you enable NLS and modify source files, you'll need to use a
46 special version of the GNU gettext package to propagate the
47 modifications to the translation tables.  Apply the following patch
48 (use `patch -p0') to GNU gettext 0.10.35, which you can retrieve from:
49
50 ftp://alpha.gnu.org/gnu/gettext-0.10.35.tar.gz
51
52 This patch has been submitted to the GNU gettext maintainer, so
53 eventually we shouldn't need this special gettext version.
54
55 This patch is free software; you can redistribute it and/or modify
56 it under the terms of the GNU General Public License as published by
57 the Free Software Foundation; either version 2, or (at your option)
58 any later version.
59
60 This patch is distributed in the hope that it will be useful,
61 but WITHOUT ANY WARRANTY; without even the implied warranty of
62 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
63 GNU General Public License for more details.
64
65 You should have received a copy of the GNU General Public License
66 along with this patch; see the file COPYING.  If not, write to
67 the Free Software Foundation, 59 Temple Place - Suite 330,
68 Boston, MA 02111-1307, USA.
69
70 1998-07-26  Paul Eggert  <eggert@twinsun.com>
71
72         * po/Makefile.in.in (maintainer-clean): Remove cat-id-tbl.c and
73         stamp-cat-id.
74
75 1998-07-24  Paul Eggert  <eggert@twinsun.com>
76
77         * po/Makefile.in.in (cat-id-tbl.o): Depend on
78         $(top_srcdir)/intl/libgettext.h, not ../intl/libgettext.h.
79
80 1998-07-20  Paul Eggert  <eggert@twinsun.com>
81
82         * po/Makefile.in.in (.po.pox, all-yes, $(srcdir)/cat-id-tbl.c,
83         $(srcdir)/stamp-cat-id, update-po): Prepend `$(srcdir)/' to
84         files built in the source directory; this is needed for
85         VPATH-based make in Solaris 2.6.
86
87 1998-07-17  Paul Eggert  <eggert@twinsun.com>
88
89         Add support for user-specified argument numbers for keywords.
90         Extract all strings from a keyword arg, not just the first one.
91         Handle parenthesized commas inside keyword args correctly.
92         Warn about nested keywords.
93
94         * doc/gettext.texi: Document --keyword=id:argnum.
95
96         * src/xgettext.c (scan_c_file):
97         Warn about nested keywords, e.g. _(_("xxx")).
98         Warn also about not-yet-implemented but allowed nesting, e.g.
99         dcgettext(..._("xxx")..., "yyy").
100         Get all strings in a keyword arg, not just the first one.
101         Handle parenthesized commas inside keyword args correctly.
102
103         * src/xget-lex.h (enum xgettext_token_type_ty):
104         Replace xgettext_token_type_keyword1 and
105         xgettext_token_type_keyword2 with just plain
106         xgettext_token_type_keyword; it now has argnum value.
107         Add xgettext_token_type_rp.
108         (struct xgettext_token_ty): Add argnum member.
109         line_number and file_name are now also set for
110         xgettext_token_type_keyword.
111         (xgettext_lex_keyword): Arg is const char *.
112
113         * src/xget-lex.c: Include "hash.h".
114         (enum token_type_ty): Add token_type_rp.
115         (keywords): Now a hash table.
116         (phase5_get): Return token_type_rp for ')'.
117         (xgettext_lex, xgettext_lex_keyword): Add support for keyword argnums.
118         (xgettext_lex): Return xgettext_token_type_rp for ')'.
119         Report keyword argnum, line number, and file name back to caller.
120
121 1998-07-09  Paul Eggert  <eggert@twinsun.com>
122
123         * intl/Makefile.in (uninstall):
124         Do nothing unless $(PACKAGE) is gettext.
125
126 ===================================================================
127 RCS file: doc/gettext.texi,v
128 retrieving revision 0.10.35.0
129 retrieving revision 0.10.35.1
130 diff -pu -r0.10.35.0 -r0.10.35.1
131 --- doc/gettext.texi    1998/05/01 05:53:32     0.10.35.0
132 +++ doc/gettext.texi    1998/07/18 00:25:15     0.10.35.1
133 @@ -1854,13 +1854,19 @@ List of directories searched for input f
134  Join messages with existing file.
135  
136  @item -k @var{word}
137 -@itemx --keyword[=@var{word}]
138 -Additonal keyword to be looked for (without @var{word} means not to
139 +@itemx --keyword[=@var{keywordspec}]
140 +Additonal keyword to be looked for (without @var{keywordspec} means not to
141  use default keywords).
142  
143 -The default keywords, which are always looked for if not explicitly
144 -disabled, are @code{gettext}, @code{dgettext}, @code{dcgettext} and
145 -@code{gettext_noop}.
146 +If @var{keywordspec} is a C identifer @var{id}, @code{xgettext} looks
147 +for strings in the first argument of each call to the function or macro
148 +@var{id}.  If @var{keywordspec} is of the form
149 +@samp{@var{id}:@var{argnum}}, @code{xgettext} looks for strings in the
150 +@var{argnum}th argument of the call.
151 +
152 +The default keyword specifications, which are always looked for if not
153 +explicitly disabled, are @code{gettext}, @code{dgettext:2},
154 +@code{dcgettext:2} and @code{gettext_noop}.
155  
156  @item -m [@var{string}]
157  @itemx --msgstr-prefix[=@var{string}]
158 ===================================================================
159 RCS file: intl/Makefile.in,v
160 retrieving revision 0.10.35.0
161 retrieving revision 0.10.35.1
162 diff -pu -r0.10.35.0 -r0.10.35.1
163 --- intl/Makefile.in    1998/04/27 21:53:18     0.10.35.0
164 +++ intl/Makefile.in    1998/07/09 21:39:18     0.10.35.1
165 @@ -143,10 +143,14 @@ install-data: all
166  installcheck:
167  
168  uninstall:
169 -       dists="$(DISTFILES.common)"; \
170 -       for file in $$dists; do \
171 -         rm -f $(gettextsrcdir)/$$file; \
172 -       done
173 +       if test "$(PACKAGE)" = "gettext"; then \
174 +         dists="$(DISTFILES.common)"; \
175 +         for file in $$dists; do \
176 +           rm -f $(gettextsrcdir)/$$file; \
177 +         done
178 +       else \
179 +         : ; \
180 +       fi
181  
182  info dvi:
183  
184 ===================================================================
185 RCS file: src/xget-lex.c,v
186 retrieving revision 0.10.35.0
187 retrieving revision 0.10.35.1
188 diff -pu -r0.10.35.0 -r0.10.35.1
189 --- src/xget-lex.c      1998/07/09 22:49:48     0.10.35.0
190 +++ src/xget-lex.c      1998/07/18 00:25:15     0.10.35.1
191 @@ -33,6 +33,7 @@
192  #include "error.h"
193  #include "system.h"
194  #include "libgettext.h"
195 +#include "hash.h"
196  #include "str-list.h"
197  #include "xget-lex.h"
198  
199 @@ -83,6 +84,7 @@ enum token_type_ty
200    token_type_eoln,
201    token_type_hash,
202    token_type_lp,
203 +  token_type_rp,
204    token_type_comma,
205    token_type_name,
206    token_type_number,
207 @@ -109,7 +111,7 @@ static FILE *fp;
208  static int trigraphs;
209  static int cplusplus_comments;
210  static string_list_ty *comment;
211 -static string_list_ty *keywords;
212 +static hash_table keywords;
213  static int default_keywords = 1;
214  
215  /* These are for tracking whether comments count as immediately before
216 @@ -941,6 +943,10 @@ phase5_get (tp)
217        tp->type = token_type_lp;
218        return;
219  
220 +    case ')':
221 +      tp->type = token_type_rp;
222 +      return;
223 +
224      case ',':
225        tp->type = token_type_comma;
226        return;
227 @@ -1179,6 +1185,7 @@ xgettext_lex (tp)
228    while (1)
229      {
230        token_ty token;
231 +      void *keyword_value;
232  
233        phase8_get (&token);
234        switch (token.type)
235 @@ -1213,17 +1220,20 @@ xgettext_lex (tp)
236           if (default_keywords)
237             {
238               xgettext_lex_keyword ("gettext");
239 -             xgettext_lex_keyword ("dgettext");
240 -             xgettext_lex_keyword ("dcgettext");
241 +             xgettext_lex_keyword ("dgettext:2");
242 +             xgettext_lex_keyword ("dcgettext:2");
243               xgettext_lex_keyword ("gettext_noop");
244               default_keywords = 0;
245             }
246  
247 -         if (string_list_member (keywords, token.string))
248 -           {
249 -             tp->type = (strcmp (token.string, "dgettext") == 0
250 -                         || strcmp (token.string, "dcgettext") == 0)
251 -               ? xgettext_token_type_keyword2 : xgettext_token_type_keyword1;
252 +         if (find_entry (&keywords, token.string, strlen (token.string),
253 +                         &keyword_value)
254 +             == 0)
255 +           {
256 +             tp->type = xgettext_token_type_keyword;
257 +             tp->argnum = (int) keyword_value;
258 +             tp->line_number = token.line_number;
259 +             tp->file_name = logical_file_name;
260             }
261           else
262             tp->type = xgettext_token_type_symbol;
263 @@ -1236,6 +1246,12 @@ xgettext_lex (tp)
264           tp->type = xgettext_token_type_lp;
265           return;
266  
267 +       case token_type_rp:
268 +         last_non_comment_line = newline_count;
269 +
270 +         tp->type = xgettext_token_type_rp;
271 +         return;
272 +
273         case token_type_comma:
274           last_non_comment_line = newline_count;
275  
276 @@ -1263,16 +1279,32 @@ xgettext_lex (tp)
277  
278  void
279  xgettext_lex_keyword (name)
280 -     char *name;
281 +     const char *name;
282  {
283    if (name == NULL)
284      default_keywords = 0;
285    else
286      {
287 -      if (keywords == NULL)
288 -       keywords = string_list_alloc ();
289 +      int argnum;
290 +      size_t len;
291 +      const char *sp;
292 +
293 +      if (keywords.table == NULL)
294 +       init_hash (&keywords, 100);
295 +
296 +      sp = strchr (name, ':');
297 +      if (sp)
298 +       {
299 +         len = sp - name;
300 +         argnum = atoi (sp + 1);
301 +       }
302 +      else
303 +       {
304 +         len = strlen (name);
305 +         argnum = 1;
306 +       }
307  
308 -      string_list_append_unique (keywords, name);
309 +      insert_entry (&keywords, name, len, (void *) argnum);
310      }
311  }
312  
313 ===================================================================
314 RCS file: src/xget-lex.h,v
315 retrieving revision 0.10.35.0
316 retrieving revision 0.10.35.1
317 diff -pu -r0.10.35.0 -r0.10.35.1
318 --- src/xget-lex.h      1998/07/09 22:49:48     0.10.35.0
319 +++ src/xget-lex.h      1998/07/18 00:25:15     0.10.35.1
320 @@ -23,9 +23,9 @@ Foundation, Inc., 59 Temple Place - Suit
321  enum xgettext_token_type_ty
322  {
323    xgettext_token_type_eof,
324 -  xgettext_token_type_keyword1,
325 -  xgettext_token_type_keyword2,
326 +  xgettext_token_type_keyword,
327    xgettext_token_type_lp,
328 +  xgettext_token_type_rp,
329    xgettext_token_type_comma,
330    xgettext_token_type_string_literal,
331    xgettext_token_type_symbol
332 @@ -37,8 +37,14 @@ struct xgettext_token_ty
333  {
334    xgettext_token_type_ty type;
335  
336 -  /* These 3 are only set for xgettext_token_type_string_literal.  */
337 +  /* This 1 is set only for xgettext_token_type_keyword.  */
338 +  int argnum;
339 +
340 +  /* This 1 is set only for xgettext_token_type_string_literal.  */
341    char *string;
342 +
343 +  /* These 2 are set only for xgettext_token_type_keyword and
344 +     xgettext_token_type_string_literal.  */
345    int line_number;
346    char *file_name;
347  };
348 @@ -50,7 +56,7 @@ void xgettext_lex PARAMS ((xgettext_toke
349  const char *xgettext_lex_comment PARAMS ((size_t __n));
350  void xgettext_lex_comment_reset PARAMS ((void));
351  /* void xgettext_lex_filepos PARAMS ((char **, int *)); FIXME needed?  */
352 -void xgettext_lex_keyword PARAMS ((char *__name));
353 +void xgettext_lex_keyword PARAMS ((const char *__name));
354  void xgettext_lex_cplusplus PARAMS ((void));
355  void xgettext_lex_trigraphs PARAMS ((void));
356  
357 ===================================================================
358 RCS file: src/xgettext.c,v
359 retrieving revision 0.10.35.0
360 retrieving revision 0.10.35.1
361 diff -pu -r0.10.35.0 -r0.10.35.1
362 --- src/xgettext.c      1998/07/09 22:49:48     0.10.35.0
363 +++ src/xgettext.c      1998/07/18 00:25:15     0.10.35.1
364 @@ -835,6 +835,8 @@ scan_c_file(filename, mlp, is_cpp_file)
365       int is_cpp_file;
366  {
367    int state;
368 +  int commas_to_skip;  /* defined only when in states 1 and 2 */
369 +  int paren_nesting;   /* defined only when in state 2 */
370  
371    /* Inform scanner whether we have C++ files or not.  */
372    if (is_cpp_file)
373 @@ -854,63 +856,79 @@ scan_c_file(filename, mlp, is_cpp_file)
374     {
375       xgettext_token_ty token;
376  
377 -     /* A simple state machine is used to do the recognising:
378 +     /* A state machine is used to do the recognising:
379          State 0 = waiting for something to happen
380 -        State 1 = seen one of our keywords with string in first parameter
381 -        State 2 = was in state 1 and now saw a left paren
382 -       State 3 = seen one of our keywords with string in second parameter
383 -       State 4 = was in state 3 and now saw a left paren
384 -       State 5 = waiting for comma after being in state 4
385 -       State 6 = saw comma after being in state 5  */
386 +        State 1 = seen one of our keywords
387 +        State 2 = waiting for part of an argument */
388       xgettext_lex (&token);
389       switch (token.type)
390         {
391 -       case xgettext_token_type_keyword1:
392 +       case xgettext_token_type_keyword:
393 +        if (!extract_all && state == 2)
394 +          {
395 +            if (commas_to_skip == 0)
396 +              {
397 +                error (0, 0,
398 +                       _("%s:%d: warning: keyword nested in keyword arg"),
399 +                       token.file_name, token.line_number);
400 +                continue;
401 +              }
402 +
403 +            /* Here we should nest properly, but this would require a
404 +               potentially unbounded stack.  We haven't run across an
405 +               example that needs this functionality yet.  For now,
406 +               we punt and forget the outer keyword.  */
407 +            error (0, 0,
408 +                   _("%s:%d: warning: keyword between outer keyword and its arg"),
409 +                   token.file_name, token.line_number);
410 +          }
411 +        commas_to_skip = token.argnum - 1;
412          state = 1;
413          continue;
414  
415 -       case xgettext_token_type_keyword2:
416 -        state = 3;
417 -        continue;
418 -
419         case xgettext_token_type_lp:
420          switch (state)
421            {
422            case 1:
423 +            paren_nesting = 0;
424              state = 2;
425              break;
426 -          case 3:
427 -            state = 4;
428 +          case 2:
429 +            paren_nesting++;
430              break;
431 -          default:
432 -            state = 0;
433            }
434          continue;
435  
436 +       case xgettext_token_type_rp:
437 +        if (state == 2 && paren_nesting != 0)
438 +          paren_nesting--;
439 +        else
440 +          state = 0;
441 +        continue;
442 +
443         case xgettext_token_type_comma:
444 -        state = state == 5 ? 6 : 0;
445 +        if (state == 2 && commas_to_skip != 0)
446 +          commas_to_skip -= paren_nesting == 0;
447 +        else
448 +          state = 0;
449          continue;
450  
451         case xgettext_token_type_string_literal:
452 -        if (extract_all || state == 2 || state == 6)
453 -          {
454 -            remember_a_message (mlp, &token);
455 -            state = 0;
456 -          }
457 +        if (extract_all || (state == 2 && commas_to_skip == 0))
458 +          remember_a_message (mlp, &token);
459          else
460            {
461              free (token.string);
462 -            state = (state == 4 || state == 5) ? 5 : 0;
463 +            state = state == 2 ? 2 : 0;
464            }
465          continue;
466  
467         case xgettext_token_type_symbol:
468 -        state = (state == 4 || state == 5) ? 5 : 0;
469 +        state = state == 2 ? 2 : 0;
470          continue;
471  
472         default:
473 -        state = 0;
474 -        continue;
475 +        abort ();
476  
477         case xgettext_token_type_eof:
478          break;
479 ===================================================================
480 RCS file: po/Makefile.in.in,v
481 retrieving revision 0.10.35.0
482 retrieving revision 0.10.35.5
483 diff -u -r0.10.35.0 -r0.10.35.5
484 --- po/Makefile.in.in   1998/07/20 20:20:38     0.10.35.0
485 +++ po/Makefile.in.in   1998/07/26 09:07:52     0.10.35.5
486 @@ -62,7 +62,7 @@
487         $(COMPILE) $<
488  
489  .po.pox:
490 -       $(MAKE) $(PACKAGE).pot
491 +       $(MAKE) $(srcdir)/$(PACKAGE).pot
492         $(MSGMERGE) $< $(srcdir)/$(PACKAGE).pot -o $*.pox
493  
494  .po.mo:
495 @@ -79,7 +79,7 @@
496  
497  all: all-@USE_NLS@
498  
499 -all-yes: cat-id-tbl.c $(CATALOGS)
500 +all-yes: $(srcdir)/cat-id-tbl.c $(CATALOGS)
501  all-no:
502  
503  $(srcdir)/$(PACKAGE).pot: $(POTFILES)
504 @@ -90,8 +90,8 @@
505            || ( rm -f $(srcdir)/$(PACKAGE).pot \
506                 && mv $(PACKAGE).po $(srcdir)/$(PACKAGE).pot )
507  
508 -$(srcdir)/cat-id-tbl.c: stamp-cat-id; @:
509 -$(srcdir)/stamp-cat-id: $(PACKAGE).pot
510 +$(srcdir)/cat-id-tbl.c: $(srcdir)/stamp-cat-id; @:
511 +$(srcdir)/stamp-cat-id: $(srcdir)/$(PACKAGE).pot
512         rm -f cat-id-tbl.tmp
513         sed -f ../intl/po2tbl.sed $(srcdir)/$(PACKAGE).pot \
514                 | sed -e "s/@PACKAGE NAME@/$(PACKAGE)/" > cat-id-tbl.tmp
515 @@ -180,7 +180,8 @@
516  
517  check: all
518  
519 -cat-id-tbl.o: ../intl/libgettext.h
520 +cat-id-tbl.o: $(srcdir)/cat-id-tbl.c $(top_srcdir)/intl/libgettext.h
521 +       $(COMPILE) $(srcdir)/cat-id-tbl.c
522  
523  dvi info tags TAGS ID:
524  
525 @@ -196,7 +197,7 @@
526  maintainer-clean: distclean
527         @echo "This command is intended for maintainers to use;"
528         @echo "it deletes files that may require special tools to rebuild."
529 -       rm -f $(GMOFILES)
530 +       rm -f $(GMOFILES) cat-id-tbl.c stamp-cat-id
531  
532  distdir = ../$(PACKAGE)-$(VERSION)/$(subdir)
533  dist distdir: update-po $(DISTFILES)
534 @@ -207,7 +208,7 @@
535         done
536  
537  update-po: Makefile
538 -       $(MAKE) $(PACKAGE).pot
539 +       $(MAKE) $(srcdir)/$(PACKAGE).pot
540         PATH=`pwd`/../src:$$PATH; \
541         cd $(srcdir); \
542         catalogs='$(CATALOGS)'; \