diff options
Diffstat (limited to 'dc.c')
-rw-r--r-- | dc.c | 19 |
1 files changed, 7 insertions, 12 deletions
@@ -13,19 +13,15 @@ static unsigned int pointer; | |||
13 | 13 | ||
14 | static void push(double a) | 14 | static void push(double a) |
15 | { | 15 | { |
16 | if (pointer >= (sizeof(stack) / sizeof(*stack))) { | 16 | if (pointer >= (sizeof(stack) / sizeof(*stack))) |
17 | errorMsg("stack overflow\n"); | 17 | fatalError("stack overflow\n"); |
18 | exit(-1); | 18 | stack[pointer++] = a; |
19 | } else | ||
20 | stack[pointer++] = a; | ||
21 | } | 19 | } |
22 | 20 | ||
23 | static double pop() | 21 | static double pop() |
24 | { | 22 | { |
25 | if (pointer == 0) { | 23 | if (pointer == 0) |
26 | errorMsg("stack underflow\n"); | 24 | fatalError("stack underflow\n"); |
27 | exit(-1); | ||
28 | } | ||
29 | return stack[--pointer]; | 25 | return stack[--pointer]; |
30 | } | 26 | } |
31 | 27 | ||
@@ -124,8 +120,7 @@ static void stack_machine(const char *argument) | |||
124 | } | 120 | } |
125 | o++; | 121 | o++; |
126 | } | 122 | } |
127 | errorMsg("%s: syntax error.\n", argument); | 123 | fatalError("%s: syntax error.\n", argument); |
128 | exit(-1); | ||
129 | } | 124 | } |
130 | 125 | ||
131 | /* return pointer to next token in buffer and set *buffer to one char | 126 | /* return pointer to next token in buffer and set *buffer to one char |
@@ -182,5 +177,5 @@ int dc_main(int argc, char **argv) | |||
182 | } | 177 | } |
183 | } | 178 | } |
184 | stack_machine(0); | 179 | stack_machine(0); |
185 | return( TRUE); | 180 | return EXIT_SUCCESS; |
186 | } | 181 | } |