Skip to content

Commit

Permalink
Kill off some GCC warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave Vandervies authored and singpolyma committed Mar 31, 2010
1 parent a5178eb commit ffcd5ea
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions rpnr.l
@@ -1,6 +1,7 @@
%{
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define HANDLE_FATAL(x) do { if(!(x)) { fputs("A fatal error occured.\n", stderr); abort(); } } while (0) /* Simple error handling */
/* Global stack */
size_t stack_size = 0;
Expand All @@ -10,6 +11,13 @@ char **stack = NULL;
void push(const char *);
void do_message(const char *);
%}

/*These (flex-only) avoid GCC warnings in the generated code.
Removing them will not break anything.
*/
%option nounput
%option always-interactive

%%

^#.+$ ; /* ignore comments */
Expand Down Expand Up @@ -45,12 +53,13 @@ char *pop() {

/* Process a "message" by popping top two elements and pushing the result */
void do_message(const char *message) {
char *arg,*obj;
if(stack_length < 2) {
fputs("Syntax error.\n", stderr);
exit(EXIT_FAILURE);
}
char *arg = pop();
char *obj = pop();
arg = pop();
obj = pop();
if(strcmp(message, "=") == 0 || strcmp(message, ":=") == 0) { /* Assignment (special case) */
HANDLE_FATAL(obj = realloc(obj, (strlen(obj)+strlen("=()")+strlen(arg)+1)*sizeof(*obj)));
strcat(obj, "=(");
Expand Down

0 comments on commit ffcd5ea

Please sign in to comment.