m4-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Changes to m4/src/freeze.c,v [branch-1_4]


From: Eric Blake
Subject: Changes to m4/src/freeze.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/freeze.c
===================================================================
RCS file: /sources/m4/m4/src/freeze.c,v
retrieving revision 1.1.1.1.2.5
retrieving revision 1.1.1.1.2.6
diff -u -b -r1.1.1.1.2.5 -r1.1.1.1.2.6
--- src/freeze.c        15 Jun 2006 21:29:16 -0000      1.1.1.1.2.5
+++ src/freeze.c        22 Jun 2006 23:17:22 -0000      1.1.1.1.2.6
@@ -211,6 +211,22 @@
     }                                                          \
   while (0)
 
+  /* Skip comments (`#' at beginning of line) and blank lines, setting
+     character to the next directive or to EOF.  */
+
+#define GET_DIRECTIVE \
+  do                                                            \
+    {                                                           \
+      GET_CHARACTER;                                            \
+      if (character == '#')                                     \
+        {                                                       \
+          while (character != EOF && character != '\n')         \
+            GET_CHARACTER;                                      \
+          VALIDATE ('\n');                                      \
+        }                                                       \
+    }                                                           \
+  while (character == '\n')
+
   file = path_search (name);
   if (file == NULL)
     M4ERROR ((EXIT_FAILURE, errno, "Cannot open %s", name));
@@ -220,28 +236,22 @@
   allocated[1] = 100;
   string[1] = xmalloc ((size_t) allocated[1]);
 
-  while (GET_CHARACTER, character != EOF)
+  /* Validate format version.  Only `1' is acceptable for now.  */
+  GET_DIRECTIVE;
+  VALIDATE ('V');
+  GET_CHARACTER;
+  VALIDATE ('1');
+  GET_CHARACTER;
+  VALIDATE ('\n');
+
+  GET_DIRECTIVE;
+  while (character != EOF)
+    {
     switch (character)
       {
       default:
        M4ERROR ((EXIT_FAILURE, 0, "Ill-formed frozen file"));
 
-      case '\n':
-
-       /* Skip empty lines.  */
-
-       break;
-
-      case '#':
-
-       /* Comments are introduced by `#' at beginning of line, and are
-          ignored.  */
-
-       while (character != EOF && character != '\n')
-         GET_CHARACTER;
-       VALIDATE ('\n');
-       break;
-
       case 'C':
       case 'D':
       case 'F':
@@ -326,12 +336,7 @@
            /* Enter a macro having a builtin function as a definition.  */
 
            bp = find_builtin_by_name (string[1]);
-           if (bp)
              define_builtin (string[0], bp, SYMBOL_PUSHDEF);
-           else
-             M4ERROR ((warning_status, 0, "\
-`%s' from frozen file not found in builtin table!",
-                       string[0]));
            break;
 
          case 'T':
@@ -356,16 +361,8 @@
          }
        break;
 
-      case 'V':
-
-       /* Validate format version.  Only `1' is acceptable for now.  */
-
-       GET_CHARACTER;
-       VALIDATE ('1');
-       GET_CHARACTER;
-       VALIDATE ('\n');
-       break;
-
+        }
+      GET_DIRECTIVE;
       }
 
   free (string[0]);
@@ -373,6 +370,7 @@
   fclose (file);
 
 #undef GET_CHARACTER
+#undef GET_DIRECTIVE
 #undef GET_NUMBER
 #undef VALIDATE
 }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]