index 6a89c565a06df76df8c26c012017795ce258939f..ba56df58d1b637591d5dfaa30def7465b8617837 100644 (file)
+2008年02月18日 Eric Blake <ebb9@byu.net>
+
+ Avoid some magic numbers.
+ * m4/m4private.h (CHAR_EOF, CHAR_BUILTIN, CHAR_QUOTE, CHAR_ARGV)
+ (CHAR_RETRY): Define in terms of UCHAR_MAX.
+ * m4/syntax.c (m4_syntax_create, set_syntax_set)
+ (reset_syntax_set, check_is_single_quotes)
+ (check_is_single_comments, check_is_macro_escaped)
+ (m4_set_quotes, m4_set_comment): Likewise.
+ * modules/gnu.c (regexp_compile): Likewise.
+ * modules/m4.c (translit): Likewise.
+ * src/freeze.c (produce_syntax_dump): Likewise.
+ Reported by Ralf Wildenhues.
+
2008年02月16日 Eric Blake <ebb9@byu.net>
Add regression test for multi-character quote recursion.
index a2b78b8fee4c71b64910d155d2539c97c9b84d62..220170338dc0bac29c84494b16501d666690024e 100644 (file)
@@ -349,7 +349,7 @@ extern void m4__push_arg_quote (m4 *, m4_obstack *, m4_macro_args *,
VALUE_MACRO_ARGS_BIT))
# define m4_set_symbol_value_text(V, T, L, A) \
- ((V)->type = M4_SYMBOL_TEXT, (V)->u.u_t.text = (T), \
+ ((V)->type = M4_SYMBOL_TEXT, (V)->u.u_t.text = (T), \
(V)->u.u_t.len = (L), (V)->u.u_t.quote_age = (A))
# define m4_set_symbol_value_builtin(V, B) \
((V)->type = M4_SYMBOL_FUNC, (V)->u.builtin = (B))
@@ -395,11 +395,11 @@ extern void m4__symtab_remove_module_references (m4_symbol_table*,
/* CHAR_RETRY must be last, because we size the syntax table to hold
all other characters and sentinels. */
-#define CHAR_EOF 256 /* Character return on EOF. */
-#define CHAR_BUILTIN 257 /* Character return for BUILTIN token. */
-#define CHAR_QUOTE 258 /* Character return for quoted string. */
-#define CHAR_ARGV 259 /* Character return for $@ reference. */
-#define CHAR_RETRY 260 /* Character return for end of input block. */
+#define CHAR_EOF (UCHAR_MAX + 1) /* Return on EOF. */
+#define CHAR_BUILTIN (UCHAR_MAX + 2) /* Return for BUILTIN token. */
+#define CHAR_QUOTE (UCHAR_MAX + 3) /* Return for quoted string. */
+#define CHAR_ARGV (UCHAR_MAX + 4) /* Return for $@ reference. */
+#define CHAR_RETRY (UCHAR_MAX + 5) /* Return for end of input block. */
#define DEF_LQUOTE "`" /* Default left quote delimiter. */
#define DEF_RQUOTE "\'" /* Default right quote delimiter. */
index 8a7b0d1893c85af7200ed96ee2090318f5fc2956..115884ee5cb2a406329b08d9398bda3a554eb8ed 100644 (file)
int ch;
/* Set up default table. This table never changes during operation. */
- for (ch = 256; --ch >= 0;)
+ for (ch = UCHAR_MAX + 1; --ch >= 0; )
switch (ch)
{
case '(':
@@ -309,7 +309,7 @@ set_syntax_set (m4_syntax_table *syntax, const char *chars, int code)
/* Explicit set of characters to install with this category; all
other characters that used to have the category get reset to
OTHER. */
- for (ch = 256; --ch >= 0; )
+ for (ch = UCHAR_MAX + 1; --ch >= 0; )
{
if (code == M4_SYNTAX_RQUOTE || code == M4_SYNTAX_ECOMM)
remove_syntax_attribute (syntax, ch, code);
reset_syntax_set (m4_syntax_table *syntax, int code)
{
int ch;
- for (ch = 256; --ch >= 0; )
+ for (ch = UCHAR_MAX + 1; --ch >= 0; )
{
/* Reset the category back to its default state. All other
characters that used to have this category get reset to
@@ -443,7 +443,7 @@ check_is_single_quotes (m4_syntax_table *syntax)
on the syntax table, then update lquote/rquote accordingly.
Otherwise, keep lquote/rquote, but we no longer have single
quotes. */
- for (ch = 256; --ch >= 0; )
+ for (ch = UCHAR_MAX + 1; --ch >= 0; )
{
if (m4_has_syntax (syntax, ch, M4_SYNTAX_LQUOTE))
{
@@ -496,7 +496,7 @@ check_is_single_comments (m4_syntax_table *syntax)
on the syntax table, then update bcomm/ecomm accordingly.
Otherwise, keep bcomm/ecomm, but we no longer have single
comments. */
- for (ch = 256; --ch >= 0; )
+ for (ch = UCHAR_MAX + 1; --ch >= 0; )
{
if (m4_has_syntax (syntax, ch, M4_SYNTAX_BCOMM))
{
@@ -535,7 +535,7 @@ check_is_macro_escaped (m4_syntax_table *syntax)
int ch;
syntax->is_macro_escaped = false;
- for (ch = 256; --ch >= 0; )
+ for (ch = UCHAR_MAX + 1; --ch >= 0; )
if (m4_has_syntax (syntax, ch, M4_SYNTAX_ESCAPE))
{
syntax->is_macro_escaped = true;
@@ -593,7 +593,7 @@ m4_set_quotes (m4_syntax_table *syntax, const char *lq, const char *rq)
(M4_SYNTAX_IGNORE | M4_SYNTAX_ESCAPE
| M4_SYNTAX_ALPHA | M4_SYNTAX_NUM)));
- for (ch = 256; --ch >= 0;)
+ for (ch = UCHAR_MAX + 1; --ch >= 0; )
{
if (m4_has_syntax (syntax, ch, M4_SYNTAX_LQUOTE))
add_syntax_attribute (syntax, ch,
@@ -656,7 +656,7 @@ m4_set_comment (m4_syntax_table *syntax, const char *bc, const char *ec)
| M4_SYNTAX_ALPHA | M4_SYNTAX_NUM
| M4_SYNTAX_LQUOTE)));
- for (ch = 256; --ch >= 0;)
+ for (ch = UCHAR_MAX + 1; --ch >= 0; )
{
if (m4_has_syntax (syntax, ch, M4_SYNTAX_BCOMM))
add_syntax_attribute (syntax, ch,
@@ -744,10 +744,10 @@ set_quote_age (m4_syntax_table *syntax, bool reset, bool change)
| M4_SYNTAX_SPACE))
&& *syntax->quote.str1 != *syntax->quote.str2
&& (!syntax->comm.len1
- || (*syntax->comm.str1 != *syntax->quote.str2
- && !m4_has_syntax (syntax, *syntax->comm.str1,
- (M4_SYNTAX_OPEN | M4_SYNTAX_COMMA
- | M4_SYNTAX_CLOSE))))
+ || (*syntax->comm.str1 != *syntax->quote.str2
+ && !m4_has_syntax (syntax, *syntax->comm.str1,
+ (M4_SYNTAX_OPEN | M4_SYNTAX_COMMA
+ | M4_SYNTAX_CLOSE))))
&& m4_has_syntax (syntax, ',', M4_SYNTAX_COMMA))
{
syntax->quote_age = ((local_syntax_age << 16)