baddc

integer-precision dc(1)
git clone git://bvnf.space/baddc.git
Log | Files | Refs | README

commit dd904dca3a854aa350ff7f9ff85d0fa1ba249e87
parent 03316cc81ea9eb5b9d2289f0c7b452628f4bd233
Author: phoebos <ben@bvnf.space>
Date:   Mon, 10 Oct 2022 18:20:18 +0100

add help message

Diffstat:
Mbaddc.c | 8++++++++
1 file changed, 8 insertions(+), 0 deletions(-)

diff --git a/baddc.c b/baddc.c @@ -4,6 +4,7 @@ #include <stdio.h> #include <string.h> #include <stdlib.h> +#include <unistd.h> #define RETURN_IF_FEWER_THAN(n) if (stack_len() < n) { fprintf(stderr, "stack too short!\n"); return; } @@ -194,6 +195,13 @@ struct { #define NUM_OPS ((sizeof(ops)) / (sizeof(*ops))) int main(int argc, char **argv) { + int c; + while ((c = getopt(argc, argv, ":")) != -1) { + fprintf(stderr, "usage: %s [file]\nsupported operations:\n", argv[0]); + for (size_t i = 0; i < NUM_OPS; i++) + fprintf(stderr, "%c\n", ops[i].op); + return 1; + } FILE *fp = NULL; if (argc == 1) { fp = stdin;