]> git.ipfire.org Git - thirdparty/make.git/commitdiff
Formerly expand.c.~9~
authorRoland McGrath <roland@redhat.com>
Fri, 25 Jun 1993 19:20:36 +0000 (19:20 +0000)
committerRoland McGrath <roland@redhat.com>
Fri, 25 Jun 1993 19:20:36 +0000 (19:20 +0000)
expand.c

index 5582a97fbe4519ac3256245c26167785370c05f2..702152bdc185d3da7f54c4a6c1bd9933f1783276 100644 (file)
--- 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;