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

@@ -412,7 +412,7 @@ m4_define([b4_percent_define_get_loc],
[m4_pushdef([b4_loc], m4_indir([b4_percent_define_loc(]$1[)]))dnl
b4_loc[]dnl
m4_popdef([b4_loc])],
[b4_fatal([[undefined %%define variable '%s' passed to b4_percent_define_get_loc]], [$1])])])
[b4_fatal([[b4_percent_define_get_loc: undefined %%define variable '%s']], [$1])])])
# b4_percent_define_get_syncline(VARIABLE)
# ----------------------------------------
@@ -429,7 +429,7 @@ m4_popdef([b4_loc])],
m4_define([b4_percent_define_get_syncline],
[m4_ifdef([b4_percent_define_syncline(]$1[)],
[m4_indir([b4_percent_define_syncline(]$1[)])],
[b4_fatal([[undefined %%define variable '%s' passed to b4_percent_define_get_syncline]], [$1])])])
[b4_fatal([[b4_percent_define_get_syncline: undefined %%define variable '%s']], [$1])])])
# b4_percent_define_ifdef(VARIABLE, IF-TRUE, [IF-FALSE])
# ------------------------------------------------------
@@ -467,7 +467,7 @@ m4_define([b4_percent_define_flag_if],
[[invalid value for %%define Boolean variable '%s']],
[$1])],
[[b4_percent_define_flag_if($1)]])])],
[b4_fatal([[undefined %%define variable '%s' passed to b4_percent_define_flag_if]], [$1])])])
[b4_fatal([[b4_percent_define_flag_if: undefined %%define variable '%s']], [$1])])])
# b4_percent_define_default(VARIABLE, DEFAULT)
# --------------------------------------------
@@ -524,7 +524,7 @@ m4_define([_b4_percent_define_check_values],
[[accepted value: '%s']],
m4_dquote(b4_value))])])dnl
m4_popdef([b4_good_value])],
[b4_fatal([[undefined %%define variable '%s' passed to b4_percent_define_check_values]], [$1])])])
[b4_fatal([[b4_percent_define_check_values: undefined %%define variable '%s']], [$1])])])
# b4_percent_code_get([QUALIFIER])
# --------------------------------

2
lib/.gitignore vendored
View File

@@ -1,4 +1,3 @@
/*.a
/*.bak
/*.o
@@ -242,7 +241,6 @@
/xsize.h
/xstrndup.c
/xstrndup.h
/c-strcaseeq.h
/fd-hook.c
/fd-hook.h

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
{

View File

@@ -750,8 +750,8 @@ start: ;
AT_BISON_CHECK([-o input.c input.y], 1, [],
[[input.y:1.10-2.0: missing '"' at end of line
input.y:4.10-5.0: missing ''' at end of line
input.y:14.11-15.0: missing ''' at end of line
input.y:4.10-5.0: missing "'" at end of line
input.y:14.11-15.0: missing "'" at end of line
input.y:16.11-17.0: missing '"' at end of line
input.y:19.13-20.0: missing '}' at end of file
input.y:20.1: syntax error, unexpected end of file
@@ -1200,9 +1200,9 @@ AT_CHECK([[perl -e "print 'start: \'';" >> empty.y || exit 77]])
AT_BISON_CHECK([empty.y], [1], [],
[[empty.y:2.8-9: warning: empty character literal
empty.y:3.8-4.0: warning: empty character literal
empty.y:3.8-4.0: missing ''' at end of line
empty.y:3.8-4.0: missing "'" at end of line
empty.y:4.8: warning: empty character literal
empty.y:4.8: missing ''' at end of file
empty.y:4.8: missing "'" at end of file
]])
AT_DATA([two.y],
@@ -1215,9 +1215,9 @@ AT_CHECK([[perl -e "print 'start: \'ab';" >> two.y || exit 77]])
AT_BISON_CHECK([two.y], [1], [],
[[two.y:2.8-11: warning: extra characters in character literal
two.y:3.8-4.0: warning: extra characters in character literal
two.y:3.8-4.0: missing ''' at end of line
two.y:3.8-4.0: missing "'" at end of line
two.y:4.8-10: warning: extra characters in character literal
two.y:4.8-10: missing ''' at end of file
two.y:4.8-10: missing "'" at end of file
]])
AT_DATA([three.y],
@@ -1230,9 +1230,9 @@ AT_CHECK([[perl -e "print 'start: \'abc';" >> three.y || exit 77]])
AT_BISON_CHECK([three.y], [1], [],
[[three.y:2.8-12: warning: extra characters in character literal
three.y:3.8-4.0: warning: extra characters in character literal
three.y:3.8-4.0: missing ''' at end of line
three.y:3.8-4.0: missing "'" at end of line
three.y:4.8-11: warning: extra characters in character literal
three.y:4.8-11: missing ''' at end of file
three.y:4.8-11: missing "'" at end of file
]])
AT_CLEANUP

View File

@@ -197,7 +197,7 @@ exp: '(' exp ')' | NUM ;
]])
AT_BISON_CHECK([-v -o input.c input.y], 0, [],
[[input.y:6.8-14: warning: symbol '"<="' used more than once as a literal string
[[input.y:6.8-14: warning: symbol "<=" used more than once as a literal string
]])
AT_CLEANUP
@@ -475,7 +475,7 @@ main (void)
# the user specification is eliminated.
AT_BISON_CHECK([-o input.c input.y], [[0]], [[]],
[[input.y:22.8-14: warning: symbol SPECIAL redeclared
input.y:22.8-63: warning: symbol '"\\'?\"\a\b\f\n\r\t\v\001\201\001\201??!"' used more than once as a literal string
input.y:22.8-63: warning: symbol "\\'?\"\a\b\f\n\r\t\v\001\201\001\201??!" used more than once as a literal string
]])
AT_COMPILE([input])

View File

@@ -228,7 +228,7 @@ start: ;
]])
AT_BISON_CHECK([[input3.y]], [[1]], [[]],
[[input3.y: fatal error: undefined %define variable 'bogus' passed to b4_percent_define_get_loc
[[input3.y: fatal error: b4_percent_define_get_loc: undefined %define variable 'bogus'
]])
AT_DATA([[skel4.c]],
@@ -242,7 +242,7 @@ start: ;
]])
AT_BISON_CHECK([[input4.y]], [[1]], [[]],
[[input4.y: fatal error: undefined %define variable 'bogus' passed to b4_percent_define_get_syncline
[[input4.y: fatal error: b4_percent_define_get_syncline: undefined %define variable 'bogus'
]])
AT_CLEANUP