From add3346ce9ee7c958bb47adfa91f78d03f1da899 Mon Sep 17 00:00:00 2001 From: dtb Date: Fri, 9 Dec 2022 21:03:06 -0500 Subject: [PATCH] get hello world working again, fix type issues --- src/blang.c | 12 ++++++------ src/blang.h | 16 ++++++++++++++-- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/blang.c b/src/blang.c index db345b6..1edfbed 100644 --- a/src/blang.c +++ b/src/blang.c @@ -1,3 +1,4 @@ +#include #include #include @@ -9,16 +10,15 @@ int main(int argc, char **argv){ int c; void (*op)(struct State *); - s.chart = *argv; + s.chart = *(argv+1); + s.counter = 0; - while((c = getc(stdin)) != EOF){ - /* proper exit is ^* */ + for(s.counter = 0; ; ++s.counter){ if(s.chart == (char *)0) return (int)s.hand; - if((op = Ops_lookup(c)) == NULL) - continue; + if((op = Ops_lookup(s.chart[s.counter])) == NULL) + return 127; else op(&s); } - return 1; } diff --git a/src/blang.h b/src/blang.h index 703e07c..3aba3bb 100644 --- a/src/blang.h +++ b/src/blang.h @@ -1,7 +1,19 @@ #if !defined _BLANG_H # define _BLANG_H +# include +/* This has to be big enough to hold a char * without degradation. + * Adjust to architecture/system/environment/etc. */ +typedef uint64_t hand_t; + +/* Just has to be fairly big. (TODO specify) */ +typedef uint64_t counter_t; + +/* Holds *argv; will not change between environments. */ +typedef char * chart_t; + struct State{ - unsigned char hand; - char *chart; + chart_t chart; + counter_t counter; + hand_t hand; }; #endif