diff options
author | Daniel <steew0x8@protonmail.com> | 2021-11-06 18:19:38 +0100 |
---|---|---|
committer | Daniel <steew0x8@protonmail.com> | 2021-11-06 18:19:38 +0100 |
commit | 2dba790a5b0d1e61acee6da4b85a486b036446ba (patch) | |
tree | 419c3c27793c26b31d205259ac5dce223b90e208 /main.c | |
parent | fe6314692dbdbf69db8b3e8a3979c1f1d21d621c (diff) | |
download | rpncalc-2dba790a5b0d1e61acee6da4b85a486b036446ba.tar.gz |
added some functions
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/main.c b/main.c index e81d50b..cb5dada 100644 --- a/main.c +++ b/main.c @@ -40,7 +40,6 @@ int main() { if (interpreted == (double)0 && endptr == buf) { /* strtod returned the char it could not read */ TYPE t = discriminate(buf); if (t == OPERATOR ) { - printf("func\n"); if (s.stk.count <= 1) { fprintf(s.defout, "not enough arguments\n"); continue; @@ -64,13 +63,18 @@ int main() { s.last_op = '/'; } else; } else if (t == FUNCTION) { + /* check for special commands, else pass to exec() */ if (strcmp(buf, "quit") == 0) { fprintf(s.defout, "quitting, bye!\n"); exit(0); + } else if (strcmp(buf, "list") == 0) { + for (int i = 0; s.sorted[i].name != 0; i++) { + fprintf(s.defout, "[%s]\t->\t%s\n", s.sorted[i].name, s.sorted[i].description); + continue; + } } else exec(buf, &s); } } else { /* we found a number */ - printf("number\n"); s.stk.val[s.stk.count++] = interpreted; } |