diff options
author | wlestes <wlestes> | 2012-02-03 22:32:35 +0000 |
---|---|---|
committer | wlestes <wlestes> | 2012-02-03 22:32:35 +0000 |
commit | 0ece5566df239cfc380d927efd0a94fc71dd9f3e (patch) | |
tree | 66177f978d35a2e8e4da78933af8f315e8f18b09 /misc.c | |
parent | 48658c017179243b859cc3ddb01a9e0d58f8e451 (diff) | |
download | flex-0ece5566df239cfc380d927efd0a94fc71dd9f3e.tar.gz |
more better error messages; more better memory handling
Diffstat (limited to 'misc.c')
-rw-r--r-- | misc.c | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -61,6 +61,8 @@ static void sko_push(bool dc) if(!sko_stack){ sko_sz = 1; sko_stack = (struct sko_state*)flex_alloc(sizeof(struct sko_state)*sko_sz); + if (!sko_stack) + flexfatal(_("allocation of sko_stack failed")); sko_len = 0; } if(sko_len >= sko_sz){ @@ -454,15 +456,29 @@ void lerrif (msg, arg) /* lerrsf - report an error message formatted with one string argument */ void lerrsf (msg, arg) - const char *msg, arg[]; + const char *msg, arg[]; { char errmsg[MAXLINE]; - snprintf (errmsg, sizeof(errmsg), msg, arg); + snprintf (errmsg, sizeof(errmsg)-1, msg, arg); + errmsg[sizeof(errmsg)-1] = 0; /* ensure NULL termination */ flexerror (errmsg); } +/* lerrsf_fatal - as lerrsf, but call flexfatal */ + +void lerrsf_fatal (msg, arg) + const char *msg, arg[]; +{ + char errmsg[MAXLINE]; + + snprintf (errmsg, sizeof(errmsg)-1, msg, arg); + errmsg[sizeof(errmsg)-1] = 0; /* ensure NULL termination */ + flexfatal (errmsg); +} + + /* line_directive_out - spit out a "#line" statement */ void line_directive_out (output_file, do_infile) |