diff options
author | Erik Andersen | 2000-04-15 16:34:54 +0000 |
---|---|---|
committer | Erik Andersen | 2000-04-15 16:34:54 +0000 |
commit | 5e1189e187f6a7957dadb8eda2c271c4a0777a23 (patch) | |
tree | 140cd30d77342c730afbc1df863bec93c63978a8 /math.c | |
parent | 95c1c1e05f290ccbcc2ff863a62bcee5d57bf5c8 (diff) | |
download | busybox-5e1189e187f6a7957dadb8eda2c271c4a0777a23.zip busybox-5e1189e187f6a7957dadb8eda2c271c4a0777a23.tar.gz |
More documentation updates, and minor fixes to make things sync
up with the docs.
-Erik
Diffstat (limited to 'math.c')
-rw-r--r-- | math.c | 21 |
1 files changed, 13 insertions, 8 deletions
@@ -7,7 +7,10 @@ /* Tiny RPN calculator, because "expr" didn't give me bitwise operations. */ -static const char math_usage[] = "math expression ..."; +static const char math_usage[] = "math expression ...\n\n" + "This is a Tiny RPN calculator that understands the\n" + "following operations: +, -, /, *, and, or, not, eor.\n" + "i.e. 'math 2 2 add' -> 4, and 'math 8 8 \\* 2 2 + /' -> 16\n"; static double stack[100]; static unsigned int pointer; @@ -85,14 +88,14 @@ struct op { }; static const struct op operators[] = { - {"add", add}, + {"+", add}, + {"-", sub}, + {"*", mul}, + {"/", divide}, {"and", and}, - {"div", divide}, - {"eor", eor}, - {"mul", mul}, - {"not", not}, {"or", or}, - {"sub", sub}, + {"not", not}, + {"eor", eor}, {0, 0} }; @@ -127,11 +130,13 @@ static void stack_machine(const char *argument) int math_main(int argc, char **argv) { + if (argc < 1 || *argv[1]=='-') + usage(math_usage); while (argc >= 2) { stack_machine(argv[1]); argv++; argc--; } stack_machine(0); - return 0; + exit( TRUE); } |