use a more consistent quoting style.

See <http://lists.gnu.org/archive/html/bug-bison/2012-01/msg00120.html>.
Use quotearg as often as possible instead of leaving the choice of
the quotes to the translators.  Use shorter messages.  Factor similar
messages to a single format, to make localization easier.

	* src/files.c, src/getargs.c, src/muscle-tab.c, src/reader.c
	* src/scan-code.l, src/scan-gram.l, src/symtab.c:
	Use quote() or quotearg_colon() on printf arguments instead of
	quotes in the format string.
	* data/bison.m4: Keep sync with the changes in muscle-tab.c.

	* tests/skeletons.at, tests/input.at, tests/regression.at: Adjust
	expected messages.
(cherry picked from commit 4a9cd8f24a)

Conflicts:

	src/muscle-tab.c
This commit is contained in:
Akim Demaille
2012-02-08 10:28:58 +01:00
parent 270ff8be14
commit 4c787a31df
13 changed files with 61 additions and 54 deletions

View File

@@ -25,6 +25,7 @@
#include <dirname.h>
#include <get-errno.h>
#include <quote.h>
#include <quotearg.h>
#include <stdio-safer.h>
#include <xstrndup.h>
@@ -109,7 +110,8 @@ xfopen (const char *name, const char *mode)
ptr = fopen_safer (name, mode);
if (!ptr)
error (EXIT_FAILURE, get_errno (), _("cannot open file '%s'"), name);
error (EXIT_FAILURE, get_errno (),
_("%s: cannot open"), quotearg_colon (name));
return ptr;
}

View File

@@ -26,7 +26,6 @@
#include <c-strcase.h>
#include <configmake.h>
#include <error.h>
#include <quotearg.h>
/* Hack to get <getopt.h> to declare getopt with a prototype. */
#if lint && ! defined __GNU_LIBRARY__
@@ -45,6 +44,7 @@
#include "files.h"
#include "getargs.h"
#include "muscle-tab.h"
#include "quote.h"
#include "uniqstr.h"
bool debug_flag;
@@ -424,14 +424,14 @@ language_argmatch (char const *arg, int prio, location loc)
language = &valid_languages[i];
return;
}
msg = _("invalid language '%s'");
msg = _("%s: invalid language");
}
else if (language_prio == prio)
msg = _("multiple language declarations are invalid");
else
return;
complain_at (loc, msg, arg);
complain_at (loc, msg, quotearg_colon (arg));
}
/*----------------------.
@@ -679,9 +679,9 @@ getargs (int argc, char *argv[])
if (argc - optind != 1)
{
if (argc - optind < 1)
error (0, 0, _("missing operand after '%s'"), argv[argc - 1]);
error (0, 0, _("%s: missing operand"), quotearg_colon (argv[argc - 1]));
else
error (0, 0, _("extra operand '%s'"), argv[optind + 1]);
error (0, 0, _("extra operand %s"), quote (argv[optind + 1]));
usage (EXIT_FAILURE);
}

View File

@@ -21,12 +21,12 @@
#include "system.h"
#include <hash.h>
#include <quotearg.h>
#include "complain.h"
#include "files.h"
#include "muscle-tab.h"
#include "getargs.h"
#include "muscle-tab.h"
#include "quote.h"
/* A key-value pair, along with storage that can be reclaimed when
this pair is no longer needed. */
@@ -425,8 +425,8 @@ muscle_percent_define_insert (char const *variable, location variable_loc,
free (variable_tr);
return;
}
complain_at (variable_loc, _("%%define variable '%s' redefined"),
variable);
complain_at (variable_loc, _("%%define variable %s redefined"),
quote (variable));
complain_at (muscle_percent_define_get_loc (variable),
_("previous definition"));
}
@@ -467,8 +467,8 @@ muscle_percent_define_get_loc (char const *variable)
char const *loc_name;
loc_name = UNIQSTR_CONCAT ("percent_define_loc(", variable, ")");
if (!muscle_find_const (loc_name))
fatal(_("undefined %%define variable '%s' passed to"
" muscle_percent_define_get_loc"), variable);
fatal(_("%s: undefined %%define variable %s"),
"muscle_percent_define_get_loc", quote (variable));
return muscle_location_decode (loc_name);
}
@@ -481,8 +481,8 @@ muscle_percent_define_get_syncline (char const *variable)
UNIQSTR_CONCAT ("percent_define_syncline(", variable, ")");
syncline = muscle_find_const (syncline_name);
if (!syncline)
fatal(_("undefined %%define variable '%s' passed to"
" muscle_percent_define_get_syncline"), variable);
fatal(_("%s: undefined %%define variable %s"),
"muscle_percent_define_get_syncline", quote (variable));
return syncline;
}
@@ -527,14 +527,14 @@ muscle_percent_define_flag_if (char const *variable)
{
muscle_insert (invalid_boolean_name, "");
complain_at(muscle_percent_define_get_loc (variable),
_("invalid value for %%define Boolean variable '%s'"),
variable);
_("invalid value for %%define Boolean variable %s"),
quote (variable));
}
free (value);
}
else
fatal(_("undefined %%define variable '%s' passed to muscle_percent_define_flag_if"),
variable);
fatal(_("%s: undefined %%define variable %s"),
"muscle_percent_define_flag", quote (variable));
return result;
}
@@ -585,10 +585,10 @@ muscle_percent_define_check_values (char const * const *values)
{
location loc = muscle_percent_define_get_loc (*variablep);
complain_at(loc,
_("invalid value for %%define variable '%s': '%s'"),
*variablep, value);
_("invalid value for %%define variable %s: %s"),
quote (*variablep), quote_n (1, value));
for (values = variablep + 1; *values; ++values)
complain_at (loc, _("accepted value: '%s'"), *values);
complain_at (loc, _("accepted value: %s"), quote (*values));
}
else
{
@@ -598,9 +598,8 @@ muscle_percent_define_check_values (char const * const *values)
free (value);
}
else
fatal(_("undefined %%define variable '%s' passed to"
" muscle_percent_define_check_values"),
*variablep);
fatal (_("%s: undefined %%define variable %s"),
"muscle_percent_define_check_values", quote (*variablep));
}
}

View File

@@ -21,6 +21,8 @@
#ifndef MUSCLE_TAB_H_
# define MUSCLE_TAB_H_
# include <quotearg.h>
# include "location.h"
void muscle_init (void);

View File

@@ -130,8 +130,8 @@ record_merge_function_type (int merger, uniqstr type, location declaration_loc)
if (merge_function->type != NULL && !UNIQSTR_EQ (merge_function->type, type))
{
complain_at (declaration_loc,
_("result type clash on merge function '%s': <%s> != <%s>"),
merge_function->name, type, merge_function->type);
_("result type clash on merge function %s: <%s> != <%s>"),
quote (merge_function->name), type, merge_function->type);
complain_at (merge_function->type_declaration_location,
_("previous declaration"));
}

View File

@@ -754,13 +754,13 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
{
if (rule->midrule_parent_rule)
complain_at (dollar_loc,
_("$$ for the midrule at $%d of '%s'"
_("$$ for the midrule at $%d of %s"
" has no declared type"),
rule->midrule_parent_rhs_index,
effective_rule->content.sym->tag);
quote (effective_rule->content.sym->tag));
else
complain_at (dollar_loc, _("$$ of '%s' has no declared type"),
rule->content.sym->tag);
complain_at (dollar_loc, _("$$ of %s has no declared type"),
quote (rule->content.sym->tag));
}
else
untyped_var_seen = true;
@@ -781,8 +781,8 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
if (!type_name)
{
if (union_seen | tag_seen)
complain_at (dollar_loc, _("$%s of '%s' has no declared type"),
cp, effective_rule->content.sym->tag);
complain_at (dollar_loc, _("$%s of %s has no declared type"),
cp, quote (effective_rule->content.sym->tag));
else
untyped_var_seen = true;
type_name = "";

View File

@@ -39,6 +39,7 @@
#include <ctype.h>
#include <mbswidth.h>
#include <quote.h>
#include <streq.h>
#include "scan-gram.h"
@@ -872,6 +873,10 @@ unexpected_end (boundary start, char const *msgid, char const *token_end)
location loc;
loc.start = start;
loc.end = scanner_cursor;
token_end = quote (token_end);
// Instead of '\'', display "'".
if (STREQ (token_end, "'\\''", '\'', '\\', '\'', '\'', 0,0,0,0,0))
token_end = "\"'\"";
complain_at (loc, _(msgid), token_end);
}
@@ -884,7 +889,7 @@ unexpected_end (boundary start, char const *msgid, char const *token_end)
static void
unexpected_eof (boundary start, char const *token_end)
{
unexpected_end (start, N_("missing '%s' at end of file"), token_end);
unexpected_end (start, N_("missing %s at end of file"), token_end);
}
@@ -895,7 +900,7 @@ unexpected_eof (boundary start, char const *token_end)
static void
unexpected_newline (boundary start, char const *token_end)
{
unexpected_end (start, N_("missing '%s' at end of line"), token_end);
unexpected_end (start, N_("missing %s at end of line"), token_end);
}

View File

@@ -26,6 +26,7 @@
#include "complain.h"
#include "gram.h"
#include "quote.h"
#include "symtab.h"
/*-------------------------------------------------------------------.
@@ -409,10 +410,10 @@ void
symbol_make_alias (symbol *sym, symbol *str, location loc)
{
if (str->alias)
warn_at (loc, _("symbol '%s' used more than once as a literal string"),
warn_at (loc, _("symbol %s used more than once as a literal string"),
str->tag);
else if (sym->alias)
warn_at (loc, _("symbol '%s' given more than one literal string"),
warn_at (loc, _("symbol %s given more than one literal string"),
sym->tag);
else
{