From 726609a573295054db72ba2465e896ed167dbab1 Mon Sep 17 00:00:00 2001 From: David Schmenk Date: Tue, 19 Jul 2022 18:06:47 -0700 Subject: [PATCH] Make sure 32 significant characters for import/export IDs --- src/toolsrc/codegen.c | 14 +++++++------- src/toolsrc/codegen.pla | 3 +++ src/toolsrc/plasm.pla | 1 + src/vmsrc/apple/a1cmd.pla | 2 +- src/vmsrc/apple/cmd.pla | 2 +- src/vmsrc/apple/cmdjit.pla | 2 +- src/vmsrc/apple/sossys.pla | 2 +- src/vmsrc/apple/sossysjit.pla | 2 +- src/vmsrc/c64/cmd.pla | 4 ++-- 9 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/toolsrc/codegen.c b/src/toolsrc/codegen.c index f8dd98a..42006e9 100755 --- a/src/toolsrc/codegen.c +++ b/src/toolsrc/codegen.c @@ -43,7 +43,7 @@ int id_match(char *name, int len, char *id) { if (len == id[0]) { - if (len > 16) len = 16; + if (len > ID_LEN) len = ID_LEN; while (len--) { if (toupper(name[len]) != id[1 + len]) @@ -99,11 +99,11 @@ int idconst_add(char *name, int len, int value) parse_error("global label already defined\n"); return (0); } + if (len > ID_LEN) len = ID_LEN; name[len] = '\0'; emit_idconst(name, value); name[len] = c; idconst_name[consts][0] = len; - if (len > ID_LEN) len = ID_LEN; while (len--) idconst_name[consts][1 + len] = toupper(name[len]); idconst_value[consts] = value; @@ -128,11 +128,11 @@ int idlocal_add(char *name, int len, int type, int size) parse_error("local label already defined\n"); return (0); } + if (len > ID_LEN) len = ID_LEN; name[len] = '\0'; emit_idlocal(name, localsize); name[len] = c; idlocal_name[locals][0] = len; - if (len > ID_LEN) len = ID_LEN; while (len--) idlocal_name[locals][1 + len] = toupper(name[len]); idlocal_type[locals] = type | LOCAL_TYPE; @@ -159,10 +159,10 @@ int idglobal_add(char *name, int len, int type, int size) parse_error("global label already defined\n"); return (0); } - name[len] = '\0'; - name[len] = c; - idglobal_name[globals][0] = len; if (len > ID_LEN) len = ID_LEN; + //name[len] = '\0'; + //name[len] = c; + idglobal_name[globals][0] = len; while (len--) idglobal_name[globals][1 + len] = toupper(name[len]); idglobal_type[globals] = type; @@ -213,8 +213,8 @@ int idfunc_add(char *name, int len, int type, int tag) printf("Global variable count overflow\n"); return (0); } - idglobal_name[globals][0] = len; if (len > ID_LEN) len = ID_LEN; + idglobal_name[globals][0] = len; while (len--) idglobal_name[globals][1 + len] = toupper(name[len]); idglobal_type[globals] = type; diff --git a/src/toolsrc/codegen.pla b/src/toolsrc/codegen.pla index 002fbe6..f432f66 100644 --- a/src/toolsrc/codegen.pla +++ b/src/toolsrc/codegen.pla @@ -449,6 +449,7 @@ end def idmatch(nameptr, len, idptr, idcnt) byte i + if len > ID_LEN; len = ID_LEN; fin while idcnt if len == idptr->idname i = 1; while i <= len and nameptr->[i - 1] == idptr->idname.[i]; i++; loop @@ -516,6 +517,7 @@ def size_iddata(type, varsize, initsize)#0 end def new_idglobal(nameptr, len, type, value, cparms, cvals)#0 if idmatch(nameptr, len, idglobal_tbl, globals); exit_err(ERR_DUP|ERR_ID); fin + if len > ID_LEN; len = ID_LEN; fin lastglobal=>idval = value lastglobal=>idtype = type lastglobal->funcparms = cparms @@ -588,6 +590,7 @@ def init_idglobal#0 end def new_idlocal(nameptr, len, type, size)#0 if idmatch(nameptr, len, @idlocal_tbl, locals); exit_err(ERR_DUP|ERR_ID); fin + if len > ID_LEN; len = ID_LEN; fin lastlocal=>idval = framesize lastlocal=>idtype = type | LOCAL_TYPE nametostr(nameptr, len, lastlocal + idname) diff --git a/src/toolsrc/plasm.pla b/src/toolsrc/plasm.pla index 979095f..92ecc4e 100755 --- a/src/toolsrc/plasm.pla +++ b/src/toolsrc/plasm.pla @@ -292,6 +292,7 @@ word lineno // // Parser variables // +const ID_LEN = 32 // Significant ID characters const LVALUE = 0 const RVALUE = 1 const LAMBDANUM = 16 diff --git a/src/vmsrc/apple/a1cmd.pla b/src/vmsrc/apple/a1cmd.pla index 6270c32..92bc4cc 100755 --- a/src/vmsrc/apple/a1cmd.pla +++ b/src/vmsrc/apple/a1cmd.pla @@ -911,7 +911,7 @@ end // def lookupextern(esd, index)#1 word sym, addr - byte str[16] + byte str[33] while ^esd sym = esd esd = sym + dcitos(sym, @str) diff --git a/src/vmsrc/apple/cmd.pla b/src/vmsrc/apple/cmd.pla index 0ee93df..d221336 100755 --- a/src/vmsrc/apple/cmd.pla +++ b/src/vmsrc/apple/cmd.pla @@ -946,7 +946,7 @@ end // def lookupextern(esd, index)#1 word sym, addr - byte str[16] + byte str[33] sym = lookupidx(esd, index) if sym addr = lookuptbl(sym, symtbl) diff --git a/src/vmsrc/apple/cmdjit.pla b/src/vmsrc/apple/cmdjit.pla index 9d0056e..f5f1e4d 100755 --- a/src/vmsrc/apple/cmdjit.pla +++ b/src/vmsrc/apple/cmdjit.pla @@ -988,7 +988,7 @@ end // def lookupextern(esd, index)#1 word sym, addr - byte str[16] + byte str[33] sym = lookupidx(esd, index) if sym addr = lookuptbl(sym, symtbl) diff --git a/src/vmsrc/apple/sossys.pla b/src/vmsrc/apple/sossys.pla index e904240..c8f1f49 100755 --- a/src/vmsrc/apple/sossys.pla +++ b/src/vmsrc/apple/sossys.pla @@ -1003,7 +1003,7 @@ end // def lookupextern(esd, index)#1 word sym, addr - byte str[16] + byte str[33] sym = lookupidx(esd, index) if sym addr = lookuptbl(sym, symtbl) diff --git a/src/vmsrc/apple/sossysjit.pla b/src/vmsrc/apple/sossysjit.pla index de13da9..521f710 100755 --- a/src/vmsrc/apple/sossysjit.pla +++ b/src/vmsrc/apple/sossysjit.pla @@ -1014,7 +1014,7 @@ end // def lookupextern(esd, index)#1 word sym, addr - byte str[16] + byte str[33] sym = lookupidx(esd, index) if sym addr = lookuptbl(sym, symtbl) diff --git a/src/vmsrc/c64/cmd.pla b/src/vmsrc/c64/cmd.pla index df22d0f..df158df 100755 --- a/src/vmsrc/c64/cmd.pla +++ b/src/vmsrc/c64/cmd.pla @@ -712,7 +712,7 @@ end asm cout(c)#0 LDA ESTKL,X INX - JMP $FFD2 + JMP $FFD2 end asm cin()#1 DEX @@ -839,7 +839,7 @@ end // def lookupextern(esd, index)#1 word sym, addr - byte str[16] + byte str[33] while ^esd sym = esd esd = sym + dcitos(sym, @str)