Search
lxdream.org :: lxdream/src/tools/actparse.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/tools/actparse.c
changeset 1169:23a9613aceb1
prev981:79fcace1ab43
next1296:30ecee61f811
author nkeynes
date Sat Mar 03 15:52:59 2012 +1000 (12 years ago)
permissions -rw-r--r--
last change Swap between run + pause icons when pressed
file annotate diff log raw
1.1 --- a/src/tools/actparse.c Sun Feb 08 23:38:41 2009 +0000
1.2 +++ b/src/tools/actparse.c Sat Mar 03 15:52:59 2012 +1000
1.3 @@ -16,6 +16,7 @@
1.4 * GNU General Public License for more details.
1.5 */
1.6
1.7 +#include <errno.h>
1.8 #include <stdlib.h>
1.9 #include <stdio.h>
1.10 #include <string.h>
1.11 @@ -105,7 +106,12 @@
1.12 af->filename = filename;
1.13 af->length = st.st_size+1;
1.14 af->text = malloc( st.st_size+1 );
1.15 - fread( af->text, st.st_size, 1, f );
1.16 + if( fread( af->text, st.st_size, 1, f ) != 1 ) {
1.17 + fprintf( stderr, "Error: unable to read from file '%s' (%s)\n", filename, strerror(errno));
1.18 + free(af);
1.19 + fclose(f);
1.20 + return NULL;
1.21 + }
1.22 af->text[st.st_size] = '\0';
1.23 af->yyline = 1;
1.24 af->yyposn = 0;
1.25 @@ -113,7 +119,6 @@
1.26 af->token.symbol = NONE;
1.27 af->token.lineno = 1;
1.28 af->token.filename = filename;
1.29 -
1.30 return af;
1.31 }
1.32
.