[BusyBox-cvs] busybox/miscutils dc.c,1.16,1.17
Erik Andersen
andersen at busybox.net
Wed Oct 22 11:24:44 UTC 2003
Update of /var/cvs/busybox/miscutils
In directory winder:/tmp/cvs-serv13190/miscutils
Modified Files:
dc.c
Log Message:
Goetz Bock writes:
Dear list,
during my quest do pack busybox into an RPM, I've fixed a small bug
(missing \n) in dc's usage. And added two additional operations: mod and
exp/power.
Feel free to drop them.
Index: dc.c
===================================================================
RCS file: /var/cvs/busybox/miscutils/dc.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- dc.c 28 Aug 2003 22:12:53 -0000 1.16
+++ dc.c 22 Oct 2003 11:24:39 -0000 1.17
@@ -44,6 +44,13 @@
push(pop() * pop());
}
+static void power(void)
+{
+ double topower = pop();
+
+ push(pow(pop(), topower));
+}
+
static void divide(void)
{
double divisor = pop();
@@ -51,6 +58,13 @@
push(pop() / divisor);
}
+static void mod(void)
+{
+ unsigned int d = pop();
+
+ push((unsigned int) pop() % d);
+}
+
static void and(void)
{
push((unsigned int) pop() & (unsigned int) pop());
@@ -119,10 +133,16 @@
{"mul", mul},
{"/", divide},
{"div", divide},
+ {"**", power},
+ {"exp", power},
+ {"pow", power},
+ {"%", mod},
+ {"mod", mod},
{"and", and},
{"or", or},
{"not", not},
{"eor", eor},
+ {"xor", eor},
{"p", print_no_pop},
{"f", print_stack_no_pop},
{"o", set_output_base},
More information about the busybox-cvs
mailing list