get hello world working again, fix type issues
This commit is contained in:
parent
da0ec7de01
commit
add3346ce9
12
src/blang.c
12
src/blang.c
@ -1,3 +1,4 @@
|
|||||||
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
@ -9,16 +10,15 @@ int main(int argc, char **argv){
|
|||||||
int c;
|
int c;
|
||||||
void (*op)(struct State *);
|
void (*op)(struct State *);
|
||||||
|
|
||||||
s.chart = *argv;
|
s.chart = *(argv+1);
|
||||||
|
s.counter = 0;
|
||||||
|
|
||||||
while((c = getc(stdin)) != EOF){
|
for(s.counter = 0; ; ++s.counter){
|
||||||
/* proper exit is ^* */
|
|
||||||
if(s.chart == (char *)0)
|
if(s.chart == (char *)0)
|
||||||
return (int)s.hand;
|
return (int)s.hand;
|
||||||
if((op = Ops_lookup(c)) == NULL)
|
if((op = Ops_lookup(s.chart[s.counter])) == NULL)
|
||||||
continue;
|
return 127;
|
||||||
else
|
else
|
||||||
op(&s);
|
op(&s);
|
||||||
}
|
}
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
16
src/blang.h
16
src/blang.h
@ -1,7 +1,19 @@
|
|||||||
#if !defined _BLANG_H
|
#if !defined _BLANG_H
|
||||||
# define _BLANG_H
|
# define _BLANG_H
|
||||||
|
# include <stdint.h>
|
||||||
|
/* 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{
|
struct State{
|
||||||
unsigned char hand;
|
chart_t chart;
|
||||||
char *chart;
|
counter_t counter;
|
||||||
|
hand_t hand;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user