[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Changes to m4/src/Attic/builtin.c,v [branch-1_4]
From: |
Eric Blake |
Subject: |
Changes to m4/src/Attic/builtin.c,v [branch-1_4] |
Date: |
Thu, 22 Jun 2006 23:17:23 +0000 |
CVSROOT: /sources/m4
Module name: m4
Branch: branch-1_4
Changes by: Eric Blake <ericb> 06/06/22 23:17:22
Index: src/builtin.c
===================================================================
RCS file: /sources/m4/m4/src/Attic/builtin.c,v
retrieving revision 1.1.1.1.2.12
retrieving revision 1.1.1.1.2.13
diff -u -b -r1.1.1.1.2.12 -r1.1.1.1.2.13
--- src/builtin.c 18 Jun 2006 21:31:56 -0000 1.1.1.1.2.12
+++ src/builtin.c 22 Jun 2006 23:17:22 -0000 1.1.1.1.2.13
@@ -138,6 +138,11 @@
{ "undivert", FALSE, FALSE, FALSE, m4_undivert },
{ 0, FALSE, FALSE, FALSE, 0 },
+
+ /* placeholder is intentionally stuck after the table end delimiter,
+ so that we can easily find it, while not treating it as a real
+ builtin. */
+ { "placeholder", TRUE, FALSE, FALSE, m4_placeholder },
};
static predefined const
@@ -161,12 +166,15 @@
for (bp = &builtin_tab[0]; bp->name != NULL; bp++)
if (bp->func == func)
return bp;
+ if (func == m4_placeholder)
+ return bp + 1;
return NULL;
}
-/*-----------------------------------.
-| Find the builtin, which has NAME. |
-`-----------------------------------*/
+/*----------------------------------------------------------.
+| Find the builtin, which has NAME. On failure, return the |
+| placeholder builtin. |
+`----------------------------------------------------------*/
const builtin *
find_builtin_by_name (const char *name)
@@ -176,7 +184,7 @@
for (bp = &builtin_tab[0]; bp->name != NULL; bp++)
if (strcmp (bp->name, name) == 0)
return bp;
- return NULL;
+ return bp + 1;
}
/*-------------------------------------------------------------------------.
@@ -272,13 +280,13 @@
{
if (!suppress_warnings)
M4ERROR ((warning_status, 0,
- "Warning: Too few arguments to builtin `%s'",
+ "Warning: too few arguments to builtin `%s'",
TOKEN_DATA_TEXT (name)));
isbad = TRUE;
}
else if (max > 0 && argc > max && !suppress_warnings)
M4ERROR ((warning_status, 0,
- "Warning: Excess arguments to builtin `%s' ignored",
+ "Warning: excess arguments to builtin `%s' ignored",
TOKEN_DATA_TEXT (name)));
return isbad;
@@ -298,7 +306,7 @@
if (*arg == 0 || (*valuep = strtol (arg, &endp, 10), *endp != 0))
{
M4ERROR ((warning_status, 0,
- "Non-numeric argument to builtin `%s'",
+ "non-numeric argument to builtin `%s'",
TOKEN_DATA_TEXT (macro)));
return FALSE;
}
@@ -438,7 +446,7 @@
default:
M4ERROR ((warning_status, 0,
- "INTERNAL ERROR: Bad token data type in define_macro ()"));
+ "INTERNAL ERROR: bad token data type in define_macro ()"));
abort ();
}
return;
@@ -608,7 +616,7 @@
dump_symbol (s, &data);
else
M4ERROR ((warning_status, 0,
- "Undefined name %s", TOKEN_DATA_TEXT (argv[i])));
+ "undefined macro `%s'", TOKEN_DATA_TEXT (argv[i])));
}
}
@@ -637,7 +645,7 @@
if (bp == NULL)
{
M4ERROR ((warning_status, 0, "\
-INTERNAL ERROR: Builtin not found in builtin table!"));
+INTERNAL ERROR: builtin not found in builtin table"));
abort ();
}
DEBUG_PRINT1 ("<%s>\n", bp->name);
@@ -645,7 +653,7 @@
default:
M4ERROR ((warning_status, 0,
- "INTERNAL ERROR: Bad token data type in m4_dumpdef ()"));
+ "INTERNAL ERROR: bad token data type in m4_dumpdef ()"));
abort ();
break;
}
@@ -669,9 +677,9 @@
return;
bp = find_builtin_by_name (name);
- if (bp == NULL)
+ if (bp->func == m4_placeholder)
M4ERROR ((warning_status, 0,
- "Undefined name %s", name));
+ "undefined builtin `%s'", name));
else
(*bp->func) (obs, argc - 1, argv + 1);
}
@@ -695,7 +703,7 @@
s = lookup_symbol (name, SYMBOL_LOOKUP);
if (s == NULL || SYMBOL_TYPE (s) == TOKEN_VOID)
M4ERROR ((warning_status, 0,
- "Undefined macro `%s'", name));
+ "undefined macro `%s'", name));
else
call_macro (s, argc - 1, argv + 1, obs);
}
@@ -710,6 +718,7 @@
m4_defn (struct obstack *obs, int argc, token_data **argv)
{
symbol *s;
+ builtin_func *b;
if (bad_argc (argv[0], argc, 2, 2))
return;
@@ -727,7 +736,12 @@
break;
case TOKEN_FUNC:
- push_macro (SYMBOL_FUNC (s));
+ b = SYMBOL_FUNC (s);
+ if (b == m4_placeholder)
+ M4ERROR ((warning_status, 0, "\
+builtin `%s' requested by frozen file is not supported", ARG (1)));
+ else
+ push_macro (b);
break;
case TOKEN_VOID:
@@ -735,7 +749,7 @@
default:
M4ERROR ((warning_status, 0,
- "INTERNAL ERROR: Bad symbol type in m4_defn ()"));
+ "INTERNAL ERROR: bad symbol type in m4_defn ()"));
abort ();
}
}
@@ -777,7 +791,7 @@
if (pin == NULL)
{
M4ERROR ((warning_status, errno,
- "Cannot open pipe to command \"%s\"", ARG (1)));
+ "cannot open pipe to command \"%s\"", ARG (1)));
sysval = 0xffff;
}
else
@@ -816,7 +830,8 @@
if (radix <= 1 || radix > (int) strlen (digits))
{
M4ERROR ((warning_status, 0,
- "Radix in eval out of range (radix = %d)", radix));
+ "radix in builtin `%s' out of range (radix = %d)",
+ ARG (0), radix));
return;
}
@@ -825,7 +840,7 @@
if (min <= 0)
{
M4ERROR ((warning_status, 0,
- "Negative width to eval"));
+ "negative width to builtin `%s'", ARG (0)));
return;
}
@@ -930,7 +945,7 @@
insert_diversion (file);
else if (no_gnu_extensions)
M4ERROR ((warning_status, 0,
- "Non-numeric argument to %s", TOKEN_DATA_TEXT (argv[0])));
+ "non-numeric argument to builtin `%s'", ARG (0)));
else
{
fp = path_search (ARG (i));
@@ -941,7 +956,7 @@
}
else
M4ERROR ((warning_status, errno,
- "Cannot undivert %s", ARG (i)));
+ "cannot undivert `%s'", ARG (i)));
}
}
}
@@ -1047,7 +1062,7 @@
{
if (!silent)
M4ERROR ((warning_status, errno,
- "Cannot open %s", ARG (1)));
+ "cannot open `%s'", ARG (1)));
return;
}
@@ -1090,7 +1105,8 @@
errno = 0;
if ((fd = mkstemp (ARG (1))) < 0)
{
- M4ERROR ((warning_status, errno, "Cannot create tempfile %s", ARG (1)));
+ M4ERROR ((warning_status, errno, "cannot create tempfile `%s'",
+ ARG (1)));
return;
}
close(fd);
@@ -1291,7 +1307,7 @@
debug_set_output (NULL);
else if (!debug_set_output (ARG (1)))
M4ERROR ((warning_status, errno,
- "Cannot set error file: %s", ARG (1)));
+ "cannot set error file: `%s'", ARG (1)));
}
/* This section contains text processing macros: "len", "index",
@@ -1573,7 +1589,7 @@
if (msg != NULL)
{
M4ERROR ((warning_status, 0,
- "Bad regular expression: `%s': %s", regexp, msg));
+ "bad regular expression: `%s': %s", regexp, msg));
return;
}
@@ -1584,7 +1600,7 @@
if (startpos == -2)
{
M4ERROR ((warning_status, 0,
- "Error matching regular expression \"%s\"", regexp));
+ "error matching regular expression \"%s\"", regexp));
return;
}
@@ -1633,7 +1649,7 @@
if (msg != NULL)
{
M4ERROR ((warning_status, 0,
- "Bad regular expression `%s': %s", regexp, msg));
+ "bad regular expression `%s': %s", regexp, msg));
if (buf.buffer != NULL)
xfree (buf.buffer);
return;
@@ -1657,7 +1673,7 @@
if (matchpos == -2)
M4ERROR ((warning_status, 0,
- "Error matching regular expression \"%s\"", regexp));
+ "error matching regular expression \"%s\"", regexp));
else if (offset < length)
obstack_grow (obs, victim + offset, length - offset);
break;
@@ -1686,6 +1702,28 @@
return;
}
+/* Finally, a placeholder builtin. This builtin is not installed by
+ default, but when reading back frozen files, this is associated
+ with any builtin we don't recognize (for example, if the frozen
+ file was created with a changeword capable m4, but is then loaded
+ by a different m4 that does not support changeword). This way, we
+ can keep 'm4 -R' quiet in the common case that the user did not
+ know or care about the builtin when the frozen file was created,
+ while still flagging it as a potential error if an attempt is made
+ to actually use the builtin. */
+
+/*--------------------------------------------------------------------.
+| Issue a warning that this macro is a placeholder for an unsupported |
+| builtin that was requested while reloading a frozen file. |
+`--------------------------------------------------------------------*/
+
+void
+m4_placeholder (struct obstack *obs, int argc, token_data **argv)
+{
+ M4ERROR ((warning_status, 0, "\
+builtin `%s' requested by frozen file is not supported", ARG (0)));
+}
+
/*-------------------------------------------------------------------------.
| This function handles all expansion of user defined and predefined |
| macros. It is called with an obstack OBS, where the macros expansion
|
- Changes to m4/src/Attic/builtin.c,v [branch-1_4], Eric Blake, 2006/06/15
- Changes to m4/src/Attic/builtin.c,v [branch-1_4], Eric Blake, 2006/06/15
- Changes to m4/src/Attic/builtin.c,v [branch-1_4], Eric Blake, 2006/06/18
- Changes to m4/src/Attic/builtin.c,v [branch-1_4],
Eric Blake <=
- Changes to m4/src/Attic/builtin.c,v [branch-1_4], Eric Blake, 2006/06/23
- Changes to m4/src/Attic/builtin.c,v [branch-1_4], Eric Blake, 2006/06/30
- Changes to m4/src/Attic/builtin.c,v [branch-1_4], Eric Blake, 2006/06/30