From ac17f6e65a89a344955da2ab93a6ad37cceab56a Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Sun, 19 May 2024 02:50:03 -0400 Subject: unprotbas: remove dead code. --- unprotbas.c | 130 ------------------------------------------------------------ 1 file changed, 130 deletions(-) (limited to 'unprotbas.c') diff --git a/unprotbas.c b/unprotbas.c index a367502..de7c441 100644 --- a/unprotbas.c +++ b/unprotbas.c @@ -236,7 +236,6 @@ void move_code(int offset) { The maximum number of variable names is 128. If all 128 vars are in use, the minimum table size is 230 (26 one-letter names, 102 2-letter or letter+number or one-letter string/array names). - */ int vntable_ok(void) { @@ -376,135 +375,6 @@ int fixvars(void) { return 1; } -#if 0 -int old_fixvars(void) { - int vp = vnstart, vv = vvstart; - int strings = 0, arrays = 0, scalars = 0, varname = 0, varnum = 0; - int bad = 0; - - /* See if the variables even need fixing. - - This code is simpler than it should be: it checks that all - characters in the variable name table are valid, but doesn't - check that they're in valid sequences. Example: a variable name - that's just an inverse dollar sign would be considered OK). - Also multiple variables of the same type with the same name - would be OK. - - However, if all the bytes are the same value, even if it's a - valid character, that's correctly detected as invalid. - */ - - if(vntp == vntd) { - fprintf(stderr, "No variables\n"); - return 0; - } - - vp = vnstart + 1; - bad = 1; - while(vp < vvstart - 1) { - if(data[vp] != data[vnstart]) bad = 0; - vp++; - } - - vp = vnstart; - while(vp < vvstart) { - unsigned char c = data[vp]; - /* - fprintf(stderr, "%04x/%04x: %04x\n", vp, vvstart, c); - */ - - /* allow a null byte only at the end of the table! */ - /* if(c == 0 && vp == vvstart - 1) break; */ - /* new rule: treat a null byte as end-of-table, ignore any - junk between it and VNTP. */ - if(c == 0) break; - - vp++; - - /* inverse $ or ( is OK */ - if(c == 0xa4 || c == 0xa8) continue; - - /* numbers and letters are allowed, inverse or normal. */ - c &= 0x7f; - if(c >= 0x30 && c <= 0x39) continue; - if(c >= 0x41 && c <= 0x5a) continue; - - bad++; - break; - } - if(!forcevars && !bad) return 0; - - /* decide whether we have enough room. pretend every new variable name - is 3 bytes (really only true for the 10th and later strings and - arrays, but a little wasted space won't hurt anything). */ - { - int vntblsize = vvstart - vnstart; - int varcount = (codestart - vvstart) / 8; - int neededsize = varcount * 3 + 1; - int move_up_by; - - fprintf(stderr, "%d variables according to value table\n", varcount); - if(neededsize > vntblsize) { - move_up_by = neededsize - vntblsize; - fprintf(stderr, "need %d bytes for vntable, only have %d, moving up by %d to %04x\n", - neededsize, vntblsize, move_up_by, vvtp + move_up_by); - move_code(move_up_by); - } - } - - vp = vnstart; - vv = vvstart; - while(vv < codestart) { - unsigned char sigil = 0; - /* type: scalar = 0, array = 1, string = 2 */ - unsigned char type = data[vv] >> 6; - /* fprintf(stderr, "%04x: %04x, %d\n", vv, data[vv], type); */ - - if(varnum != data[vv+1]) { - fprintf(stderr, "Warning: variable value is corrupt!\n"); - } - varnum++; - - switch(type) { - case 1: varname = arrays++; sigil = 0xa8; break; - case 2: varname = strings++; sigil = 0xa4; break; - default: varname = scalars++; break; - } - - if(varname < 26) { - data[vp] = ('A' + varname); - } else { - varname -= 26; - data[vp++] = 'A' + ((varname - 26) / 9); - data[vp] = ('1' + ((varname - 26) % 9)); - } - - if(sigil) { - vp++; - data[vp++] = sigil; - } else { - data[vp] |= 0x80; - vp++; - } - - vv += 8; - } - - /* there's supposed to be a null byte at the end of the table, unless - all 128 table slots are used. */ - if(varnum < 128) data[vp] = 0; - - /* fixup the VNTD pointer */ - vntd = vntp + (vp - vnstart); - data[4] = vntd & 0xff; - data[5] = vntd >> 8; - - fprintf(stderr, "%d variables, VNTD adjusted to %04x\n", varnum, vntd); - return 1; -} -#endif - void print_help(void) { fprintf(stderr, "Usage: %s [-v] [-f] [-n] [-g] \n", self); fprintf(stderr, "-v: verbose\n"); -- cgit v1.2.3