Skip to content
Browse files

Kill off some GCC warnings

  • Loading branch information...
1 parent a5178eb commit ffcd5eac49368f8e88ee5ae64f1150254eb56066 @dj3vande dj3vande committed with Mar 29, 2010
Showing with 11 additions and 2 deletions.
  1. +11 −2 rpnr.l
View
13 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;
@@ -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 */
@@ -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, "=(");

0 comments on commit ffcd5ea

Please sign in to comment.
Something went wrong with that request. Please try again.