This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB 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: [commit] mark some of printf_(un)filtered


> Date: Fri, 11 Feb 2005 19:39:45 -0500
> From: Andrew Cagney <ac131313@redhat.com>
> 
> Only some, where in doubt I tried to skip (sometimes entire files). 
> Where fairly certain that there shouldn't be a translation, I marked it 
> as (("string")).

Thanks.

These patches have many such (("string")) ``translations''.  IMHO, it
certainly should have never been committed without discussions.

Anyway, those strings which we decide not to translate should have
comments explaining why, lest someone in the future will decide that
it's an omission.

> committed,

Sigh... yet another commit without an RFA.  Am I the only one who is
astonished to see commits of massive patches whose author says that he
is uncertain what would be the best way of making the very changes he
just committed??

> @@ -3091,7 +3091,7 @@ user_select_syms (struct ada_symbol_info
>            else if (is_enumeral
>                     && TYPE_NAME (SYMBOL_TYPE (syms[i].sym)) != NULL)
>              {
> -              printf_unfiltered ("[%d] ", i + first_choice);
> +              printf_unfiltered (("[%d] "), i + first_choice);

This should be translated, as some languages have rules for numerals.

> @@ -3151,7 +3151,7 @@ get_selections (int *choices, int n_choi
>    if (prompt == NULL)
>      prompt = ">";
>  
> -  printf_unfiltered ("%s ", prompt);
> +  printf_unfiltered (("%s "), prompt);

The prompt shouldn't be translated, I think.

>  print_value_flags (struct type *t)
>  {
>    if (can_dereference (t))
> -    printf_filtered ("*");
> +    printf_filtered (("*"));
>    else
> -    printf_filtered ("-");
> +    printf_filtered (("-"));

No translations needed here, I think.

> @@ -58,7 +58,7 @@ breakpoints_changed (void)
>    if (annotation_level > 1)
>      {
>        target_terminal_ours ();
> -      printf_unfiltered ("\n\032\032breakpoints-invalid\n");
> +      printf_unfiltered (("\n\032\032breakpoints-invalid\n"));

Annotations should never be translated, since front ends depend on
their literal text.

> @@ -2162,25 +2161,22 @@ print_it_typical (bpstat bs)
>  	  (CURRENT_EXCEPTION_KIND == EX_EVENT_CATCH))
>  	{
>  	  annotate_catchpoint (bs->breakpoint_at->number);
> -	  printf_filtered ("\nCatchpoint %d (exception caught), ", 
> +	  printf_filtered (_("\nCatchpoint %d (exception caught), "), 
>  			   bs->breakpoint_at->number);
> -	  printf_filtered ("throw location ");
>  	  if (CURRENT_EXCEPTION_THROW_PC && CURRENT_EXCEPTION_THROW_LINE)
> -	    printf_filtered ("%s:%d",
> +	    printf_filtered (_("throw location %s:%d, "),
>  			     CURRENT_EXCEPTION_THROW_FILE,
>  			     CURRENT_EXCEPTION_THROW_LINE);
>  	  else
> -	    printf_filtered ("unknown");
> +	    printf_filtered (_("throw location unknown, "));
>  
> -	  printf_filtered (", catch location ");
>  	  if (CURRENT_EXCEPTION_CATCH_PC && CURRENT_EXCEPTION_CATCH_LINE)
> -	    printf_filtered ("%s:%d",
> +	    printf_filtered (_("catch location %s:%d\n"),
>  			     CURRENT_EXCEPTION_CATCH_FILE,
>  			     CURRENT_EXCEPTION_CATCH_LINE);
>  	  else
> -	    printf_filtered ("unknown");
> +	    printf_filtered (_("catch location unknown\n"));
>  
> -	  printf_filtered ("\n");
>  	  /* don't bother to print location frame info */
>  	  return PRINT_SRC_ONLY;
>  	}

This code fragment assembles a sentence from several parts.  While the
refactoring of individual parts is well done (thanks, Andrew), the
overall result will be less than perfect for right-to-left languages.
Therefore, I suggest to rewrite this as a single call to
printf_filtered that has the entire output line as its argument.

> @@ -2196,25 +2192,22 @@ print_it_typical (bpstat bs)
>  	  (CURRENT_EXCEPTION_KIND == EX_EVENT_THROW))
>  	{
>  	  annotate_catchpoint (bs->breakpoint_at->number);
> -	  printf_filtered ("\nCatchpoint %d (exception thrown), ",
> +	  printf_filtered (_("\nCatchpoint %d (exception thrown), "),
>  			   bs->breakpoint_at->number);
> -	  printf_filtered ("throw location ");
>  	  if (CURRENT_EXCEPTION_THROW_PC && CURRENT_EXCEPTION_THROW_LINE)
> -	    printf_filtered ("%s:%d",
> +	    printf_filtered (_("throw location %s:%d, "),
>  			     CURRENT_EXCEPTION_THROW_FILE,
>  			     CURRENT_EXCEPTION_THROW_LINE);
>  	  else
> -	    printf_filtered ("unknown");
> +	    printf_filtered (_("throw location unknown, "));
>  
> -	  printf_filtered (", catch location ");
>  	  if (CURRENT_EXCEPTION_CATCH_PC && CURRENT_EXCEPTION_CATCH_LINE)
> -	    printf_filtered ("%s:%d",
> +	    printf_filtered (_("catch location %s:%d\n"),
>  			     CURRENT_EXCEPTION_CATCH_FILE,
>  			     CURRENT_EXCEPTION_CATCH_LINE);
>  	  else
> -	    printf_filtered ("unknown");
> +	    printf_filtered (_("catch location unknown\n"));
>  
> -	  printf_filtered ("\n");
>  	  /* don't bother to print location frame info */
>  	  return PRINT_SRC_ONLY; 
>  	}

Same here.

> -	printf_filtered ("Catchpoint %d (%s %s)",
> +	printf_filtered (_("Catchpoint %d (%s %s)"),
>  			 b->number,
>  			 (b->type == bp_catch_load) ? "load" : "unload",
>  			 (b->dll_pathname != NULL) ? 

The "load" and "unload" parts should not be separate strings, but part
of a full translatable string.

>  	  for (j = 0; j < LINE_SIZE; j++)
>  	    printf_filtered ("%02x", p->data[j] & 0xFF);
> -	  printf_filtered ("\n");
> +	  printf_filtered (("\n"));

No need to translate the newline, obviously.

> @@ -2315,7 +2315,7 @@ dwarf2_psymtab_to_symtab (struct partial
>  	{
>  	  if (info_verbose)
>  	    {
> -	      printf_filtered ("Reading in symbols for %s...", pst->filename);
> +	      printf_filtered (_("Reading in symbols for %s..."), pst->filename);
>  	      gdb_flush (gdb_stdout);
>  	    }
>  
> @@ -2327,7 +2327,7 @@ dwarf2_psymtab_to_symtab (struct partial
>  
>  	  /* Finish up the debug error message.  */
>  	  if (info_verbose)
> -	    printf_filtered ("done.\n");
> +	    printf_filtered (_("done.\n"));

This "done" part should have an i18n comment telling translators that
it's the end of the "Reading in symbols for %s...done" sentence.

> @@ -2415,7 +2417,7 @@ dwarf_psymtab_to_symtab (struct partial_
>  	         disconcerting pauses.  */
>  	      if (info_verbose)
>  		{
> -		  printf_filtered ("Reading in symbols for %s...",
> +		  printf_filtered (_("Reading in symbols for %s..."),
>  				   pst->filename);
>  		  gdb_flush (gdb_stdout);
>  		}
> @@ -2434,7 +2436,7 @@ dwarf_psymtab_to_symtab (struct partial_
>  	      /* Finish up the verbose info message.  */
>  	      if (info_verbose)
>  		{
> -		  printf_filtered ("done.\n");
> +		  printf_filtered (_("done.\n"));

Same here.

> @@ -527,10 +527,10 @@ print_section_info (struct target_ops *t
>  
>    printf_filtered ("\t`%s', ", bfd_get_filename (abfd));
>    wrap_here ("        ");
> -  printf_filtered ("file type %s.\n", bfd_get_target (abfd));
> +  printf_filtered (_("file type %s.\n"), bfd_get_target (abfd));

This should be made a single sentence, I think.

> @@ -2694,13 +2694,9 @@ print_bit_vector (B_TYPE *bits, int nbit
>  	  puts_filtered (" ");
>  	}
>        if (B_TST (bits, bitno))
> -	{
> -	  printf_filtered ("1");
> -	}
> +	printf_filtered (("1"));
>        else
> -	{
> -	  printf_filtered ("0");
> -	}
> +	printf_filtered (("0"));

Don't think these need translation.

>    if (pipe (inf_ttrace_pfd1) == -1)
> -    perror_with_name ("pipe");
> +    perror_with_name (("pipe"));

Names of functions and system calls should not be translated.

>  inf_ttrace_files_info (struct target_ops *ignore)
>  {
> -  printf_unfiltered ("\tUsing the running image of %s %s.\n",
> +  printf_unfiltered (_("\tUsing the running image of %s %s.\n"),
>  		     attach_flag ? "attached" : "child",
>  		     target_pid_to_str (inferior_ptid));

This needs top be rewritten so as to make "attached" and "child" parts
of a single translatable string.

>    if (from_tty)
>      {
> -      printf_filtered ("Continuing at ");
> +      printf_filtered (_("Continuing at "));
>        print_address_numeric (addr, 1, gdb_stdout);
>        printf_filtered (".\n");

Can we make this a single string with a format specifier?

> @@ -3145,8 +3145,8 @@ signal_pass_update (int signo, int state
>  static void
>  sig_print_header (void)
>  {
> -  printf_filtered ("\
> -Signal        Stop\tPrint\tPass to program\tDescription\n");
> +  printf_filtered (_("\
> +Signal        Stop\tPrint\tPass to program\tDescription\n"));
>  }

This is okay, but the related "Yes" and "No" strings in sig_print_info
should be marked up for translation as well, and the code there
rewritten to use a single string, not fragments.

>  child_files_info (struct target_ops *ignore)
>  {
> -  printf_unfiltered ("\tUsing the running image of %s %s.\n",
> +  printf_unfiltered (_("\tUsing the running image of %s %s.\n"),
>        attach_flag ? "attached" : "child", target_pid_to_str (inferior_ptid));
>  }

"attached" and "child" should be part of the full string.

> @@ -311,7 +311,7 @@ mdebug_psymtab_to_symtab (struct partial
>  
>    if (info_verbose)
>      {
> -      printf_filtered ("Reading in symbols for %s...", pst->filename);
> +      printf_filtered (_("Reading in symbols for %s..."), pst->filename);
>        gdb_flush (gdb_stdout);
>      }
>  
> @@ -324,7 +324,7 @@ mdebug_psymtab_to_symtab (struct partial
>    scan_file_globals (pst->objfile);
>  
>    if (info_verbose)
> -    printf_filtered ("done.\n");
> +    printf_filtered (_("done.\n"));

We need a comment here about "Reading in symbols for %s..." and "done"
being part of the same sentence.

> @@ -4109,7 +4109,7 @@ psymtab_to_symtab_1 (struct partial_symt
>           from a shared library, so tell the user only if verbose is on.  */
>        if (info_verbose && n_undef_symbols)
>  	{
> -	  printf_filtered ("File %s contains %d unresolved references:",
> +	  printf_filtered (_("File %s contains %d unresolved references:"),
>  			   st->filename, n_undef_symbols);
>  	  printf_filtered ("\n\t%4d variables\n\t%4d procedures\n\t%4d labels\n",
>  			   n_undef_vars, n_undef_procs, n_undef_labels);

I think the "\n\t%4d variables\n\t%4d procedures\n\t%4d labels\n"
part should be marked up for translation.

> --- printcmd.c	11 Feb 2005 18:13:52 -0000	1.87
> +++ printcmd.c	12 Feb 2005 00:38:05 -0000
> @@ -1021,16 +1021,16 @@ sym_info (char *arg, int from_tty)
>  	  printf_filtered ("%s in ",
>  			   SYMBOL_PRINT_NAME (msymbol));
>  	if (pc_in_unmapped_range (addr, sect))
> -	  printf_filtered ("load address range of ");
> +	  printf_filtered (_("load address range of "));
>  	if (section_is_overlay (sect))
> -	  printf_filtered ("%s overlay ",
> +	  printf_filtered (_("%s overlay "),
>  			   section_is_mapped (sect) ? "mapped" : "unmapped");
> -	printf_filtered ("section %s", sect->name);
> +	printf_filtered (_("section %s"), sect->name);
>  	printf_filtered ("\n");
>        }

This should be produced as a single sentence, and "mapped"/"unmapped"
parts should be part of it.

>        if (section_is_overlay (section))
>  	{
>  	  load_addr = overlay_unmapped_address (load_addr, section);
> -	  printf_filtered (",\n -- loaded at ");
> +	  printf_filtered (_(",\n -- loaded at "));
>  	  print_address_numeric (load_addr, 1, gdb_stdout);
> -	  printf_filtered (" in overlay section %s", section->name);
> +	  printf_filtered (_(" in overlay section %s"), section->name);

Can we use some format specifier instead of print_address_numeric?  If
we can, then this should be a single translatable string.

>        if (section_is_overlay (section))
>  	{
>  	  load_addr = overlay_unmapped_address (load_addr, section);
> -	  printf_filtered (",\n -- loaded at ");
> +	  printf_filtered (_(",\n -- loaded at "));
>  	  print_address_numeric (load_addr, 1, gdb_stdout);
> -	  printf_filtered (" in overlay section %s", section->name);
> +	  printf_filtered (_(" in overlay section %s"), section->name);
>  	}

Same here.

>        if (section_is_overlay (section))
>  	{
>  	  load_addr = overlay_unmapped_address (load_addr, section);
> -	  printf_filtered (",\n -- loaded at ");
> +	  printf_filtered (_(",\n -- loaded at "));
>  	  print_address_numeric (load_addr, 1, gdb_stdout);
> -	  printf_filtered (" in overlay section %s", section->name);
> +	  printf_filtered (_(" in overlay section %s"), section->name);
>  	}

And here.

> @@ -1222,15 +1222,15 @@ address_info (char *exp, int from_tty)
>  	else
>  	  {
>  	    section = SYMBOL_BFD_SECTION (msym);
> -	    printf_filtered ("static storage at address ");
> +	    printf_filtered (_("static storage at address "));
>  	    print_address_numeric (load_addr = SYMBOL_VALUE_ADDRESS (msym),
>  				   1, gdb_stdout);
>  	    if (section_is_overlay (section))
>  	      {
>  		load_addr = overlay_unmapped_address (load_addr, section);
> -		printf_filtered (",\n -- loaded at ");
> +		printf_filtered (_(",\n -- loaded at "));
>  		print_address_numeric (load_addr, 1, gdb_stdout);
> -		printf_filtered (" in overlay section %s", section->name);
> +		printf_filtered (_(" in overlay section %s"), section->name);
>  	      }

And here (two counts).

> @@ -4230,7 +4230,7 @@ wait_again:
>  		default:	 /* FIXME: use si_signo if possible for fault */
>  		  retval = pid_to_ptid (-1);
>  		  printf_filtered ("procfs:%d -- ", __LINE__);
> -		  printf_filtered ("child stopped for unknown reason:\n");
> +		  printf_filtered (_("child stopped for unknown reason:\n"));

The "procfs:%d -- " part that prints the value of __LINE__ should be
made part of the translatable string.

> @@ -4238,7 +4238,7 @@ wait_again:
>  		break;	/* case PR_FAULTED: */
>  	      default:	/* switch (why) unmatched */
>  		printf_filtered ("procfs:%d -- ", __LINE__);
> -		printf_filtered ("child stopped for unknown reason:\n");
> +		printf_filtered (_("child stopped for unknown reason:\n"));

Same here.

>  procfs_files_info (struct target_ops *ignore)
>  {
> -  printf_filtered ("\tUsing the running image of %s %s via /proc.\n",
> +  printf_filtered (_("\tUsing the running image of %s %s via /proc.\n"),
>  		   attach_flag? "attached": "child",
>  		   target_pid_to_str (inferior_ptid));

The "attached" and "child" parts should be part of the translatable
string.

> @@ -5770,7 +5770,7 @@ info_proc_mappings (procinfo *pi, int su
>    if (summary)
>      return;	/* No output for summary mode. */
>  
> -  printf_filtered ("Mapped address spaces:\n\n");
> +  printf_filtered (_("Mapped address spaces:\n\n"));
>    printf_filtered (header_fmt_string,
>  		   "Start Addr",
>  		   "  End Addr",

I think "Start Addr" and "End Addr" should be translatable.

> @@ -490,12 +490,12 @@ set_memory_packet_size (char *args, stru
>  static void
>  show_memory_packet_size (struct memory_packet_config *config)
>  {
> -  printf_filtered ("The %s is %ld. ", config->name, config->size);
> +  printf_filtered (_("The %s is %ld. "), config->name, config->size);
>    if (config->fixed_p)
> -    printf_filtered ("Packets are fixed at %ld bytes.\n",
> +    printf_filtered (_("Packets are fixed at %ld bytes.\n"),
>  		     get_memory_packet_size (config));
>    else
> -    printf_filtered ("Packets are limited to %ld bytes.\n",
> +    printf_filtered (_("Packets are limited to %ld bytes.\n"),
>  		     get_memory_packet_size (config));

This should be produced as a single sentence, not as 2 parts.

> +  printf_filtered (_("%s preprocessor macro info.\n"),
>                     s->macro_table ? "Includes" : "Does not include");

This should be rewritten as 2 calls to printf_filtered with either
"Includes" or "Does not include" as part of the full translatable
format string.

> @@ -939,14 +939,14 @@ frame_info (char *addr_exp, int from_tty
>  
>    if (selected_frame_p && frame_relative_level (fi) >= 0)
>      {
> -      printf_filtered ("Stack level %d, frame at ",
> +      printf_filtered (_("Stack level %d, frame at "),
>  		       frame_relative_level (fi));
>        print_address_numeric (get_frame_base (fi), 1, gdb_stdout);
>        printf_filtered (":\n");
>      }
>    else
>      {
> -      printf_filtered ("Stack frame at ");
> +      printf_filtered (_("Stack frame at "));
>        print_address_numeric (get_frame_base (fi), 1, gdb_stdout);
>        printf_filtered (":\n");
>      }

If we can replace print_address_numeric with a format specifier, these
two fragments should each be replaced with a single call to
printf_filtered.

> @@ -887,7 +887,7 @@ symbol_file_add_with_addrs_or_offsets (b
>    if (!have_partial_symbols () && !have_full_symbols ())
>      {
>        wrap_here ("");
> -      printf_filtered ("(no debugging symbols found)");
> +      printf_filtered (_("(no debugging symbols found)"));
>        if (from_tty || info_verbose)
>          printf_filtered ("...");
>        else
> @@ -901,7 +901,7 @@ symbol_file_add_with_addrs_or_offsets (b
>  	deprecated_post_add_symbol_hook ();
>        else
>  	{
> -	  printf_unfiltered ("done.\n");
> +	  printf_unfiltered (_("done.\n"));
>  	}

This seems to produce a sentence in chunks, so either rewrite as a
single sentence or add i18n comments that make this clear.

> @@ -1401,7 +1401,7 @@ target_info (char *args, int from_tty)
>        if ((int) (t->to_stratum) <= (int) dummy_stratum)
>  	continue;
>        if (has_all_mem)
> -	printf_unfiltered ("\tWhile running this, GDB does not access memory from...\n");
> +	printf_unfiltered (_("\tWhile running this, GDB does not access memory from...\n"));
>        printf_unfiltered ("%s:\n", t->to_longname);

I think these two calls to printf_unfiltered should be replaced with a
single call.

> @@ -1130,15 +1130,15 @@ query (const char *ctlstr, ...)
>        gdb_flush (gdb_stdout);
>  
>        if (annotation_level > 1)
> -	printf_filtered ("\n\032\032pre-query\n");
> +	printf_filtered (("\n\032\032pre-query\n"));
>  
>        va_start (args, ctlstr);
>        vfprintf_filtered (gdb_stdout, ctlstr, args);
>        va_end (args);
> -      printf_filtered ("(y or n) ");
> +      printf_filtered (_("(y or n) "));

This string's translation should be consistent with the translations
of the 'Y' and 'N' characters we expect as responses, so that the
result is guaranteed to be correct.  E.g., there should not be two or
more places in the function that translate "Y" and "N": the "(y or n)"
string should actually use the translations of "Y" and "N".

Also, the simple-minded up-casing code, viz.

      if (answer >= 'a')
      	 answer -= 040;

should be replaced with a call to `toupper', or perhaps even with a
series of calls to `toupper', in case the translation of "Y" or "N" is
not a single character.

> -      printf_filtered ("Please answer y or n.\n");
> +      printf_filtered (_("Please answer y or n.\n"));

This string should also use the translation of "Y" and "N" instead of
literal characters.

> @@ -1232,13 +1232,13 @@ defaulted_query (const char *ctlstr, con
>        gdb_flush (gdb_stdout);
>  
>        if (annotation_level > 1)
> -	printf_filtered ("\n\032\032pre-query\n");
> +	printf_filtered (("\n\032\032pre-query\n"));
>  
>        vfprintf_filtered (gdb_stdout, ctlstr, args);
> -      printf_filtered ("(%s or %s) ", y_string, n_string);
> +      printf_filtered (_("(%s or %s) "), y_string, n_string);
>  
>        if (annotation_level > 1)
> -	printf_filtered ("\n\032\032query\n");
> +	printf_filtered (("\n\032\032query\n"));
>  
>        wrap_here ("");
>        gdb_flush (gdb_stdout);
> @@ -1277,12 +1277,12 @@ defaulted_query (const char *ctlstr, con
>  	  break;
>  	}
>        /* Invalid entries are not defaulted and require another selection.  */
> -      printf_filtered ("Please answer %s or %s.\n",
> +      printf_filtered (_("Please answer %s or %s.\n"),
>  		       y_string, n_string);
>      }

`defaulted_query' needs much more work than this: 'y' and 'n' should
be made translatable strings, as well as y_string and n_string.  Also,
the comment about up-casing in `query' applies here as well.

`yquery' and `nquery' should be modified to pass strings, not single
characters, to `defaulted_query'.

> @@ -682,9 +682,9 @@ show_values (char *num_exp, int from_tty
>    for (i = num; i < num + 10 && i <= value_history_count; i++)
>      {
>        val = access_value_history (i);
> -      printf_filtered ("$%d = ", i);
> +      printf_filtered (("$%d = "), i);

This should probably be translatable.

>        value_print (val, gdb_stdout, 0, Val_pretty_default);
> -      printf_filtered ("\n");
> +      printf_filtered (("\n"));

Obviously, no need to translate a newline.

> @@ -819,14 +819,15 @@ show_convenience (char *ignore, int from
>  	{
>  	  varseen = 1;
>  	}
> -      printf_filtered ("$%s = ", var->name);
> +      printf_filtered (("$%s = "), var->name);
>        value_print (var->value, gdb_stdout, 0, Val_pretty_default);
> -      printf_filtered ("\n");
> +      printf_filtered (("\n"));

Same here.

> @@ -88,7 +88,7 @@ tui_query_hook (const char * msg, va_lis
>        gdb_flush (gdb_stdout);
>  
>        vfprintf_filtered (gdb_stdout, msg, argp);
> -      printf_filtered ("(y or n) ");
> +      printf_filtered (_("(y or n) "));
>  
>        wrap_here ("");
>        gdb_flush (gdb_stdout);
> @@ -121,7 +121,7 @@ tui_query_hook (const char * msg, va_lis
>  	  retval = 0;
>  	  break;
>  	}
> -      printf_filtered ("Please answer y or n.\n");
> +      printf_filtered (_("Please answer y or n.\n"));
>      }

`tui_query_hook' needs the same work as `query' and `defaulted_query',
to make it i18n-clean.


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