diff --git a/bfg.c b/bfg.c index 2677b47..6f9fdc4 100644 --- a/bfg.c +++ b/bfg.c @@ -59,8 +59,6 @@ static int32_t add_single_char(char ch, char flags, int32_t *crs_len) { // note that we check for -x .:.:ab but not for -x .:.:ba // int32_t bf_init(char *arg) { - bf_options.rotate = 0; - int32_t i = 0; int32_t crs_len = 0; char flags = 0; @@ -176,7 +174,9 @@ int32_t bf_init(char *arg) { bf_options.crs_len = crs_len; bf_options.current = bf_options.from; - + bf_options.strafe = 0; + bf_options.rotate = 0; + memset((char *) bf_options.state, 0, sizeof(bf_options.state)); if (debug) @@ -202,14 +202,6 @@ uint64_t bf_get_pcount() { return foo; } -int accu(int value) { - int i = 0, a; - for (a = 1; a <= value; ++a) { - i += a; - } - return i; -} - char *bf_next(_Bool rainy) { int32_t i, pos = bf_options.current - 1; @@ -223,16 +215,30 @@ char *bf_next(_Bool rainy) { if(rainy) { - //the first character cannot be taken into account - bf_options.ptr[0] = bf_options.crs[bf_options.state[0]]; - for(i=1; i 2) { + if(bf_options.current % 2) { + bf_options.ptr[0] = bf_options.crs[bf_options.state[0]]; + bf_options.ptr[1] = bf_options.crs[bf_options.state[1]]; + bf_options.ptr[2] = bf_options.crs[bf_options.state[2]]; + + for(i=3; i