[Initng-svn] r2337 - initng/tools

svn at initng.thinktux.net svn at initng.thinktux.net
Mon Dec 5 22:46:39 CET 2005


Author: jimmy
Date: Mon Dec  5 22:46:38 2005
New Revision: 2337

Modified:
   initng/tools/install_service.c
Log:
Writen by Aidan Thornton makomk at lycos.co.uk

This patch makes install_service more strict. In particular, it will now reject
nested blocks and files with missing #endd, whereas before it would silently
ignore them (leading to strange results).


Modified: initng/tools/install_service.c
==============================================================================
--- initng/tools/install_service.c	(original)
+++ initng/tools/install_service.c	Mon Dec  5 22:46:38 2005
@@ -973,18 +973,22 @@
                 }
                 continue;
             }
+
+            else if (MATCH("#elsed", line) ||
+                     MATCH("#endd", line) || MATCH("#endexec", line))
+            {
+                fprintf(stderr,
+                        "ERROR: trailing #elsed, #end, or #endexec\n");
+                fclose(out);
+                if (outfile)
+                    unlink(outfile);
+                exit(1);
+            }
             else
             {
                 /* line started with a '#', but we are not in_block, and the line was neither 
                  * #ifd nor #exec. so it's a comment.
                  */
-                if (MATCH("#elsed", line) ||
-                    MATCH("#endd", line) || MATCH("#endexec", line))
-                {
-                    fprintf(stderr,
-                            "WARNING: found #elsed, #end or #endexec, but not in BLOCK!\n");
-                    /* exit here ??? */
-                }
                 /* this is a comment so print it */
                 print_it(out, line);
                 continue;                   /* read next line */
@@ -993,6 +997,22 @@
         /* ok, we are in a block */
         if (in_block == IF_BLOCK)
         {
+            if (MATCH("#exec", line) || MATCH("#ifd", line))
+            {
+                fprintf(stderr, "ERROR: nested blocks not supported\n");
+                fclose(out);
+                if (outfile)
+                    unlink(outfile);
+                exit(1);
+            }
+            if (MATCH("#endexec", line))
+            {
+                fprintf(stderr, "ERROR: #endexec without #exec\n");
+                fclose(out);
+                if (outfile)
+                    unlink(outfile);
+                exit(1);
+            }
             if (if_block_print_out)
             {
                 /*if the block should be printed up to now */
@@ -1082,6 +1102,18 @@
         }
     }
 
+    if (in_block)
+    {
+        if (in_block == EXEC_BLOCK)
+            fprintf(stderr, "ERROR: missing #endexec\n");
+        else
+            fprintf(stderr, "ERROR: missing #endd\n");
+        fclose(out);
+        if (outfile)
+            unlink(outfile);
+        exit(1);
+    }
+
     /* free the overlay table */
     for (i = 0; i < 1000 && overlay[i].opt; i++)
     {


More information about the Initng-svn mailing list