Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Don't report false error when writing a zero-byte file.
 Fixes unit tests:
   preprocessor/output/empty-file
   preprocessor/output/just-a-comment
  • Loading branch information
icculus committed Apr 9, 2009
1 parent d4cf9db commit 363eac9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions utils/mojoshader-compiler.c
Expand Up @@ -136,7 +136,8 @@ static int preprocess(const char *fname, const char *buf, int len,
{
if (pd->output != NULL)
{
if (fwrite(pd->output, pd->output_len, 1, io) != 1)
const int len = pd->output_len;
if ((len) && (fwrite(pd->output, len, 1, io) != 1))
printf(" ... fwrite('%s') failed.\n", outfile);
else if ((outfile != NULL) && (fclose(io) == EOF))
printf(" ... fclose('%s') failed.\n", outfile);
Expand Down Expand Up @@ -177,7 +178,8 @@ static int assemble(const char *fname, const char *buf, int len,
{
if (pd->output != NULL)
{
if (fwrite(pd->output, pd->output_len, 1, io) != 1)
const int len = pd->output_len;
if ((len) && (fwrite(pd->output, len, 1, io) != 1))
printf(" ... fwrite('%s') failed.\n", outfile);
else if ((outfile != NULL) && (fclose(io) == EOF))
printf(" ... fclose('%s') failed.\n", outfile);
Expand Down

0 comments on commit 363eac9

Please sign in to comment.