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.
[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)
# ----------------------------------------
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])
# ------------------------------------------------------
[[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)
[[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])
# --------------------------------
-
/*.a
/*.bak
/*.o
/xsize.h
/xstrndup.c
/xstrndup.h
-
/c-strcaseeq.h
/fd-hook.c
/fd-hook.h
-
/00gnulib.m4
/alloca.m4
/argmatch.m4
/assert.m4
/calloc.m4
/cloexec.m4
+/close-stream.m4
/close.m4
+/closeout.m4
/codeset.m4
/config-h.m4
/configmake.m4
/fcntl_h.m4
/float_h.m4
/fopen.m4
+/fpending.m4
/fpieee.m4
/fprintf-posix.m4
/frexp.m4
/frexpl.m4
+/fstat.m4
/getdtablesize.m4
/getopt.m4
/gettext.m4
/iswblank.m4
/javacomp.m4
/javaexec.m4
+/largefile.m4
+/ldexp.m4
/ldexpl.m4
/lib-ld.m4
/lib-link.m4
/memchr.m4
/mmap-anon.m4
/mode_t.m4
+/msvc-inval.m4
+/msvc-nothrow.m4
/multiarch.m4
/nls.m4
/nocrash.m4
/open.m4
+/pathmax.m4
/perror.m4
/pipe.m4
/pipe2.m4
/progtest.m4
/quote.m4
/quotearg.m4
+/raise.m4
/rawmemchr.m4
/realloc.m4
/sched_h.m4
/spawn-pipe.m4
/spawn_h.m4
/sprintf-posix.m4
+/ssize_t.m4
/stat.m4
/stdbool.m4
/stddef_h.m4
/strchrnul.m4
/strdup.m4
/strerror.m4
+/strerror_r.m4
/string_h.m4
/strndup.m4
/strnlen.m4
/xalloc.m4
/xsize.m4
/xstrndup.m4
-
-/fstat.m4
-/largefile.m4
-/ldexp.m4
-/msvc-inval.m4
-/msvc-nothrow.m4
-/pathmax.m4
-/raise.m4
-/ssize_t.m4
-/strerror_r.m4
-/close-stream.m4
-/closeout.m4
-/fpending.m4
#include <dirname.h>
#include <get-errno.h>
#include <quote.h>
+#include <quotearg.h>
#include <stdio-safer.h>
#include <xstrndup.h>
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;
}
#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__
#include "files.h"
#include "getargs.h"
#include "muscle-tab.h"
+#include "quote.h"
#include "uniqstr.h"
bool defines_flag;
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));
}
/*----------------------.
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);
}
#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. */
atoi (muscle_find_const (how_name));
if (how_old == MUSCLE_PERCENT_DEFINE_F)
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"));
}
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);
}
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;
}
{
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;
}
{
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
{
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));
}
}
#ifndef MUSCLE_TAB_H_
# define MUSCLE_TAB_H_
+# include <quotearg.h>
+
# include "location.h"
void muscle_init (void);
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"));
}
{
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;
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 = "";
#include <ctype.h>
#include <mbswidth.h>
#include <quote.h>
+#include <streq.h>
#include <src/scan-gram.h>
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);
}
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);
}
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);
}
#include "complain.h"
#include "gram.h"
+#include "quote.h"
#include "symtab.h"
/*-------------------------------------------------------------------.
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
{
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
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],
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],
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
]])
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
# 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])
]])
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]],
]])
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