mirror of
https://github.com/sheumann/hush.git
synced 2025-02-20 13:29:08 +00:00
dc: fix "dc p" prinitng bogus data
function old new delta check_under - 20 +20 print_no_pop 27 32 +5 pop 33 24 -9 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/1 up/down: 25/-9) Total: 16 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
b878121e76
commit
c4603fb09a
@ -56,6 +56,12 @@ enum { STACK_SIZE = (COMMON_BUFSIZE - offsetof(struct globals, stack)) / sizeof(
|
|||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
|
static void check_under(void)
|
||||||
|
{
|
||||||
|
if (pointer == 0)
|
||||||
|
bb_error_msg_and_die("stack underflow");
|
||||||
|
}
|
||||||
|
|
||||||
static void push(double a)
|
static void push(double a)
|
||||||
{
|
{
|
||||||
if (pointer >= STACK_SIZE)
|
if (pointer >= STACK_SIZE)
|
||||||
@ -65,8 +71,7 @@ static void push(double a)
|
|||||||
|
|
||||||
static double pop(void)
|
static double pop(void)
|
||||||
{
|
{
|
||||||
if (pointer == 0)
|
check_under();
|
||||||
bb_error_msg_and_die("stack underflow");
|
|
||||||
return stack[--pointer];
|
return stack[--pointer];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,6 +192,7 @@ static void print_stack_no_pop(void)
|
|||||||
|
|
||||||
static void print_no_pop(void)
|
static void print_no_pop(void)
|
||||||
{
|
{
|
||||||
|
check_under();
|
||||||
print_base(stack[pointer-1]);
|
print_base(stack[pointer-1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user