#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. */
muscle_syncline_grow (char const *key, location loc)
{
char *extension = NULL;
- obstack_fgrow1 (&muscle_obstack, "]b4_syncline(%d, [[", loc.start.line);
- MUSCLE_OBSTACK_SGROW (&muscle_obstack,
- quotearg_style (c_quoting_style, loc.start.file));
- obstack_sgrow (&muscle_obstack, "]])[");
+ obstack_printf (&muscle_obstack, "]b4_syncline(%d, ", loc.start.line);
+ obstack_quote (&muscle_obstack,
+ quotearg_style (c_quoting_style, loc.start.file));
+ obstack_sgrow (&muscle_obstack, ")[");
obstack_1grow (&muscle_obstack, 0);
extension = obstack_finish (&muscle_obstack);
muscle_grow (key, extension, "");
const char *a1, const char *a2)
{
char *pair;
- obstack_sgrow (&muscle_obstack, "[[[");
- MUSCLE_OBSTACK_SGROW (&muscle_obstack, a1);
- obstack_sgrow (&muscle_obstack, "]], [[");
- MUSCLE_OBSTACK_SGROW (&muscle_obstack, a2);
- obstack_sgrow (&muscle_obstack, "]]]");
+ obstack_sgrow (&muscle_obstack, "[");
+ obstack_quote (&muscle_obstack, a1);
+ obstack_sgrow (&muscle_obstack, ", ");
+ obstack_quote (&muscle_obstack, a2);
+ obstack_sgrow (&muscle_obstack, "]");
obstack_1grow (&muscle_obstack, 0);
pair = obstack_finish (&muscle_obstack);
muscle_grow (muscle, pair, ",\n");
}
-void
+/* In the format `file_name:line.column', append BOUND to MUSCLE. Use
+ digraphs for special characters in the file name. */
+
+static void
muscle_boundary_grow (char const *key, boundary bound)
{
char *extension;
- MUSCLE_OBSTACK_SGROW (&muscle_obstack, bound.file);
- obstack_1grow (&muscle_obstack, ':');
- obstack_fgrow1 (&muscle_obstack, "%d", bound.line);
- obstack_1grow (&muscle_obstack, '.');
- obstack_fgrow1 (&muscle_obstack, "%d", bound.column);
- obstack_1grow (&muscle_obstack, '\0');
+ obstack_sgrow (&muscle_obstack, "[[");
+ obstack_escape (&muscle_obstack, bound.file);
+ obstack_1grow (&muscle_obstack, ':');
+ obstack_printf (&muscle_obstack, "%d", bound.line);
+ obstack_1grow (&muscle_obstack, '.');
+ obstack_printf (&muscle_obstack, "%d", bound.column);
+ obstack_sgrow (&muscle_obstack, "]]");
+ obstack_1grow (&muscle_obstack, '\0');
extension = obstack_finish (&muscle_obstack);
muscle_grow (key, extension, "");
obstack_free (&muscle_obstack, extension);
}
-void
+
+/* In the format `[[file_name:line.column]], [[file_name:line.column]]',
+ append LOC to MUSCLE. Use digraphs for special characters in each
+ file name. */
+
+static void
muscle_location_grow (char const *key, location loc)
{
- muscle_grow (key, "[[", "");
muscle_boundary_grow (key, loc.start);
- muscle_grow (key, "]], [[", "");
+ muscle_grow (key, "", ", ");
muscle_boundary_grow (key, loc.end);
- muscle_grow (key, "]]", "");
}
-#define MUSCLE_COMMON_DECODE(Value) \
- case '$': \
- aver (*++(Value) == ']'); \
- aver (*++(Value) == '['); \
- obstack_sgrow (&muscle_obstack, "$"); \
- break; \
- case '@': \
- switch (*++(Value)) \
- { \
- case '@': obstack_sgrow (&muscle_obstack, "@" ); break; \
- case '{': obstack_sgrow (&muscle_obstack, "[" ); break; \
- case '}': obstack_sgrow (&muscle_obstack, "]" ); break; \
- default: aver (false); break; \
- } \
- break; \
- default: \
- obstack_1grow (&muscle_obstack, *(Value)); \
+#define COMMON_DECODE(Value) \
+ case '$': \
+ aver (*++(Value) == ']'); \
+ aver (*++(Value) == '['); \
+ obstack_sgrow (&muscle_obstack, "$"); \
+ break; \
+ case '@': \
+ switch (*++(Value)) \
+ { \
+ case '@': obstack_sgrow (&muscle_obstack, "@" ); break; \
+ case '{': obstack_sgrow (&muscle_obstack, "[" ); break; \
+ case '}': obstack_sgrow (&muscle_obstack, "]" ); break; \
+ default: aver (false); break; \
+ } \
+ break; \
+ default: \
+ obstack_1grow (&muscle_obstack, *(Value)); \
break;
-/* Reverse of MUSCLE_OBSTACK_SGROW. */
+/* Reverse of obstack_escape. */
static char *
-muscle_string_decode (char const *key)
+string_decode (char const *key)
{
char const *value;
char *value_decoded;
do {
switch (*value)
{
- MUSCLE_COMMON_DECODE (value)
+ COMMON_DECODE (value)
case '[':
case ']':
aver (false);
/* Reverse of muscle_location_grow. */
static location
-muscle_location_decode (char const *key)
+location_decode (char const *key)
{
location loc;
char const *value = muscle_find_const (key);
while (*++value)
switch (*value)
{
- MUSCLE_COMMON_DECODE (value)
+ COMMON_DECODE (value)
case '[':
aver (false);
break;
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"));
}
variable, ")");
muscle_insert (usage_name, "");
- value = muscle_string_decode (name);
+ value = string_decode (name);
if (!value)
value = xstrdup ("");
return value;
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);
- return muscle_location_decode (loc_name);
+ fatal(_("%s: undefined %%define variable %s"),
+ "muscle_percent_define_get_loc", quote (variable));
+ return location_decode (loc_name);
}
char const *
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;
}
name = UNIQSTR_CONCAT ("percent_define(", *variablep, ")");
- value = muscle_string_decode (name);
+ value = string_decode (name);
if (value)
{
for (++values; *values; ++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
{
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));
}
}