summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkim Demaille <demaille@gostai.com>2012-02-08 10:28:58 +0100
committerAkim Demaille <demaille@gostai.com>2012-02-08 11:32:36 +0100
commit4a9cd8f24abba232b4a07ccdda4c6f109d27acac (patch)
treed418ca00f576cc3027bc2d3f98ca9293362d7d37
parent62a87154b3bb1af77ee153603972090a600bafce (diff)
downloadbison-4a9cd8f24abba232b4a07ccdda4c6f109d27acac.tar.gz
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.
-rw-r--r--data/bison.m48
-rw-r--r--lib/.gitignore2
-rw-r--r--m4/.gitignore26
-rw-r--r--src/files.c4
-rw-r--r--src/getargs.c10
-rw-r--r--src/muscle-tab.c35
-rw-r--r--src/muscle-tab.h2
-rw-r--r--src/reader.c4
-rw-r--r--src/scan-code.l12
-rw-r--r--src/scan-gram.l9
-rw-r--r--src/symtab.c5
-rw-r--r--tests/input.at16
-rw-r--r--tests/regression.at4
-rw-r--r--tests/skeletons.at4
14 files changed, 73 insertions, 68 deletions
diff --git a/data/bison.m4 b/data/bison.m4
index 7dfb1a72..37bc012f 100644
--- a/data/bison.m4
+++ b/data/bison.m4
@@ -598,7 +598,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)
# ----------------------------------------
@@ -615,7 +615,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])
# ------------------------------------------------------
@@ -659,7 +659,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)
@@ -731,7 +731,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])
# --------------------------------
diff --git a/lib/.gitignore b/lib/.gitignore
index 365b84d0..5b14836b 100644
--- a/lib/.gitignore
+++ b/lib/.gitignore
@@ -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
diff --git a/m4/.gitignore b/m4/.gitignore
index 901724d0..01e5f645 100644
--- a/m4/.gitignore
+++ b/m4/.gitignore
@@ -1,4 +1,3 @@
-
/00gnulib.m4
/alloca.m4
/argmatch.m4
@@ -6,7 +5,9 @@
/assert.m4
/calloc.m4
/cloexec.m4
+/close-stream.m4
/close.m4
+/closeout.m4
/codeset.m4
/config-h.m4
/configmake.m4
@@ -28,10 +29,12 @@
/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
@@ -57,6 +60,8 @@
/iswblank.m4
/javacomp.m4
/javaexec.m4
+/largefile.m4
+/ldexp.m4
/ldexpl.m4
/lib-ld.m4
/lib-link.m4
@@ -78,10 +83,13 @@
/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
@@ -95,6 +103,7 @@
/progtest.m4
/quote.m4
/quotearg.m4
+/raise.m4
/rawmemchr.m4
/realloc.m4
/sched_h.m4
@@ -112,6 +121,7 @@
/spawn-pipe.m4
/spawn_h.m4
/sprintf-posix.m4
+/ssize_t.m4
/stat.m4
/stdbool.m4
/stddef_h.m4
@@ -124,6 +134,7 @@
/strchrnul.m4
/strdup.m4
/strerror.m4
+/strerror_r.m4
/string_h.m4
/strndup.m4
/strnlen.m4
@@ -156,16 +167,3 @@
/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
diff --git a/src/files.c b/src/files.c
index 66d92185..d80b718d 100644
--- a/src/files.c
+++ b/src/files.c
@@ -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;
}
diff --git a/src/getargs.c b/src/getargs.c
index 5fa3c452..e5d1faa3 100644
--- a/src/getargs.c
+++ b/src/getargs.c
@@ -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 defines_flag;
@@ -421,14 +421,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);
}
diff --git a/src/muscle-tab.c b/src/muscle-tab.c
index e366d33b..bc1aa1fc 100644
--- a/src/muscle-tab.c
+++ b/src/muscle-tab.c
@@ -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. */
@@ -439,8 +439,8 @@ muscle_percent_define_insert (char const *variable, location variable_loc,
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"));
}
@@ -503,8 +503,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);
}
@@ -517,8 +517,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;
}
@@ -563,14 +563,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;
}
@@ -621,10 +621,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
{
@@ -634,9 +634,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));
}
}
diff --git a/src/muscle-tab.h b/src/muscle-tab.h
index 4bf8d66d..5f701ae4 100644
--- a/src/muscle-tab.h
+++ b/src/muscle-tab.h
@@ -20,6 +20,8 @@
#ifndef MUSCLE_TAB_H_
# define MUSCLE_TAB_H_
+# include <quotearg.h>
+
# include "location.h"
void muscle_init (void);
diff --git a/src/reader.c b/src/reader.c
index 60fe7bd0..107fe901 100644
--- a/src/reader.c
+++ b/src/reader.c
@@ -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"));
}
diff --git a/src/scan-code.l b/src/scan-code.l
index ba6adb1f..b8c0c1b0 100644
--- a/src/scan-code.l
+++ b/src/scan-code.l
@@ -755,13 +755,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;
@@ -782,8 +782,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 = "";
diff --git a/src/scan-gram.l b/src/scan-gram.l
index 449fbea9..e2e08f9a 100644
--- a/src/scan-gram.l
+++ b/src/scan-gram.l
@@ -39,6 +39,7 @@
#include <ctype.h>
#include <mbswidth.h>
#include <quote.h>
+#include <streq.h>
#include <src/scan-gram.h>
@@ -965,6 +966,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);
}
@@ -977,7 +982,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);
}
@@ -988,7 +993,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);
}
diff --git a/src/symtab.c b/src/symtab.c
index 07d5efb0..5a595648 100644
--- a/src/symtab.c
+++ b/src/symtab.c
@@ -26,6 +26,7 @@
#include "complain.h"
#include "gram.h"
+#include "quote.h"
#include "symtab.h"
/*-------------------------------------------------------------------.
@@ -444,10 +445,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
{
diff --git a/tests/input.at b/tests/input.at
index 6a2bcdcc..84ae0ffe 100644
--- a/tests/input.at
+++ b/tests/input.at
@@ -745,8 +745,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
@@ -1206,9 +1206,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],
@@ -1221,9 +1221,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],
@@ -1236,9 +1236,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
diff --git a/tests/regression.at b/tests/regression.at
index 5affe4d9..9aaedde0 100644
--- a/tests/regression.at
+++ b/tests/regression.at
@@ -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])
diff --git a/tests/skeletons.at b/tests/skeletons.at
index eee57b0c..1a9933fe 100644
--- a/tests/skeletons.at
+++ b/tests/skeletons.at
@@ -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