From 18e53454def2c2efb40a1596feed2506c39745ce Mon Sep 17 00:00:00 2001 From: Kia <kia@special-circumstanc.es> Date: Sat, 4 Sep 2021 15:53:51 -0600 Subject: [PATCH] char range seems to work --- gen_intrange.c | 56 ++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 6 deletions(-) diff --git a/gen_intrange.c b/gen_intrange.c index 1286e92..b5a9d50 100644 --- a/gen_intrange.c +++ b/gen_intrange.c @@ -1,18 +1,59 @@ #include <string.h> #include <stdlib.h> +#include <assert.h> +#include <stdio.h> + + + +struct charset { + uint8_t bitmap[32]; // 32 * 8 = 256 +}; + + +void charset_set(struct charset *cs, uint8_t char_idx, uint8_t indicator) { + + int arr_idx = char_idx / 8; + int bit_idx = char_idx % 8; + + uint8_t newbit = 1; + if(indicator == 1) { + cs->bitmap[arr_idx] = cs->bitmap[arr_idx] | (newbit << bit_idx); + } else { + cs->bitmap[arr_idx] = cs->bitmap[arr_idx] & ~(newbit << bit_idx); + } +} int main(int argc, char *argv[]) { - assert(argc == 3); - int16_t low = atoi(argv[1]); - int16_t high = atoi(argv[2]); + assert(argc == 4); + uint8_t bytes = atoi(argv[1]); + uint64_t low = atoi(argv[2]); + uint64_t high = atoi(argv[3]); printf("LOW = %d\nHIGH=%d\n", low, high); + struct charset *cs = (struct charset *) calloc(sizeof(struct charset), 1); + for (int i=0; i<256; i++) + { + charset_set(cs, i, 1); + } + + charset_set(cs, 255, 1); + charset_set(cs, 254, 0); + + for (int i = 0; i<32; i++) + { + printf("bitmapism %d = %hhu\n",i, cs->bitmap[i]); +} } +/* bitmap-ism */ + + -void gen_int_range(HAllocator *mm__, HCFStack *stk__, uint64_t low, uint64_t high, uint8_t bytes) { - /* Possible FIXME: TallerThanMe */ +/* + +void gen_int_range(uint64_t low, uint64_t high, uint8_t bytes) { + /* Possible FIXME: TallerThanMe * / if (1 == bytes) { HCharset cs = new_charset(mm__); for (uint64_t i=low; i<=high; ++i) { @@ -59,4 +100,7 @@ void gen_int_range(HAllocator *mm__, HCFStack *stk__, uint64_t low, uint64_t hig } HCFS_END_CHOICE(); } } -} \ No newline at end of file +} + + +*/ \ No newline at end of file -- GitLab