summaryrefslogtreecommitdiff
path: root/expand.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>1993-06-25 19:20:36 +0000
committerRoland McGrath <roland@redhat.com>1993-06-25 19:20:36 +0000
commitae112a5cb5245b4faa1b43f7a32be6875c142d57 (patch)
tree76d7fae8ac4555c662fc641de57507cd9c78ec3d /expand.c
parent4ac6d662446594a2879b6468444f20e045f13ed1 (diff)
downloadgunmake-ae112a5cb5245b4faa1b43f7a32be6875c142d57.tar.gz
Formerly expand.c.~9~
Diffstat (limited to 'expand.c')
-rw-r--r--expand.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/expand.c b/expand.c
index 5582a97..702152b 100644
--- a/expand.c
+++ b/expand.c
@@ -104,7 +104,28 @@ recursively_expand (v)
return value;
}
-/* Expand a simple reference to variable NAME, which LENGTH chars long. */
+/* Warn that NAME is an undefined variable. */
+
+#ifdef __GNUC__
+__inline
+#endif
+static void
+warn_undefined (name, length)
+ char *name;
+ unsigned int length;
+{
+ if (warn_undefined_variables_flag)
+ {
+ static const char warnmsg[] = "warning: undefined variable `%.*s'";
+ if (reading_filename != 0)
+ makefile_error (reading_filename, *reading_lineno_ptr,
+ warnmsg, length, name);
+ else
+ error (warnmsg, length, name);
+ }
+}
+
+/* Expand a simple reference to variable NAME, which is LENGTH chars long. */
#ifdef __GNUC__
__inline
@@ -117,6 +138,9 @@ reference_variable (o, name, length)
{
register struct variable *v = lookup_variable (name, length);
+ if (v == 0)
+ warn_undefined (name, length);
+
if (v != 0 && *v->value != '\0')
{
char *value = (v->recursive ? recursively_expand (v) : v->value);
@@ -254,6 +278,8 @@ variable_expand (line)
char *subst_beg, *subst_end, *replace_beg, *replace_end;
v = lookup_variable (beg, colon - beg);
+ if (v == 0)
+ warn_undefined (beg, colon - beg);
subst_beg = colon + 1;
count = 0;