Skip to content

Commit

Permalink
Added fail().
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Feb 19, 2009
1 parent 41f856a commit 1ddbb54
Showing 1 changed file with 14 additions and 20 deletions.
34 changes: 14 additions & 20 deletions utils/mojoshader-compiler.c
Expand Up @@ -39,6 +39,14 @@ static void Free(void *_ptr)
#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,
Expand Down Expand Up @@ -164,28 +172,20 @@ int main(int argc, char **argv)
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

else if (strcmp(arg, "-I") == 0)
{
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;
Expand Down Expand Up @@ -214,19 +214,13 @@ int main(int argc, char **argv)
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)
Expand Down

0 comments on commit 1ddbb54

Please sign in to comment.