Added fail().
authorRyan C. Gordon <icculus@icculus.org>
Thu, 19 Feb 2009 03:36:49 -0500
changeset 668 983f396a3d71
parent 667 8efc63f4ab9b
child 669 fd14a7278a95
Added fail().
utils/mojoshader-compiler.c
--- a/utils/mojoshader-compiler.c	Thu Feb 19 03:24:03 2009 -0500
+++ b/utils/mojoshader-compiler.c	Thu Feb 19 03:36:49 2009 -0500
@@ -39,6 +39,14 @@
 #define Free NULL
 #endif
 
+
+static void fail(const char *err)
+{
+    printf("%s.\n", err);
+    exit(1);
+} // fail
+
+
 static int open_include(MOJOSHADER_includeType inctype, const char *fname,
                         const char *parent, const char **outdata,
                         unsigned int *outbytes, MOJOSHADER_malloc m,
@@ -164,17 +172,11 @@
         if (strcmp(arg, "-o") == 0)
         {
             if (outfile != NULL)
-            {
-                printf("multiple output files specified.\n");
-                exit(1);
-            } // if
+                fail("multiple output files specified");
 
             arg = argv[++i];
             if (arg == NULL)
-            {
-                printf("no filename after '-o'\n");
-                exit(1);
-            } // if
+                fail("no filename after '-o'");
             outfile = arg;
         } // if
 
@@ -182,10 +184,8 @@
         {
             arg = argv[++i];
             if (arg == NULL)
-            {
-                printf("no path after '-I'\n");
-                exit(1);
-            } // if
+                fail("no path after '-I'");
+
             include_paths = (const char **) realloc(include_paths,
                        (include_path_count+1) * sizeof (char *));
             include_paths[include_path_count] = arg;
@@ -214,19 +214,13 @@
         else
         {
             if (infile != NULL)
-            {
-                printf("multiple input files specified.\n");
-                exit(1);
-            } // if
+                fail("multiple input files specified.");
             infile = arg;
         } // else
     } // for
 
     if (infile == NULL)
-    {
-        printf("no input file specified.\n");
-        exit(1);
-    } // if
+        fail("no input file specified.");
 
     FILE *io = fopen(infile, "rb");
     if (io == NULL)