From d34532e79d136a5e45fa9f9ff162162e80e64781 Mon Sep 17 00:00:00 2001 From: sater Date: Fri, 18 May 1984 13:04:34 +0000 Subject: [PATCH] Incorporated variable length identifiers. Courtesy Johan Stevenson --- util/opt/alloc.c | 9 ++++++--- util/opt/lookup.c | 10 ++++++++-- util/opt/lookup.h | 4 ++-- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/util/opt/alloc.c b/util/opt/alloc.c index 694a0561c..bcb86d0bb 100644 --- a/util/opt/alloc.c +++ b/util/opt/alloc.c @@ -187,9 +187,12 @@ offset *newrom() { return((offset *) newcore(MAXROM*sizeof(offset))); } -sym_p newsym() { - - return((sym_p) newcore(sizeof(sym_t))); +sym_p newsym(len) int len; { + /* + * sym_t includes a 2 character s_name at the end + * extend this structure with len-2 characters + */ + return((sym_p) newcore(sizeof(sym_t) - 2 + len)); } argb_p newargb() { diff --git a/util/opt/lookup.c b/util/opt/lookup.c index f924dc058..d6126e34d 100644 --- a/util/opt/lookup.c +++ b/util/opt/lookup.c @@ -37,6 +37,7 @@ unsigned hash(string) char *string; { sym_p symlookup(name,status,flags) char *name; int status,flags; { register sym_p *spp,sp; + register i; static short genfrag = 32767; spp = &symhash[hash(name)%NSYMHASH]; @@ -58,8 +59,13 @@ sym_p symlookup(name,status,flags) char *name; int status,flags; { * symbol not found, enter in table */ - *spp = sp = newsym(); - strncpy(sp->s_name,name,IDL); + i = strlen(name) + 1; + if (i & 1) + i++; + if (i > IDL) + i = IDL; + *spp = sp = newsym(i); + strncpy(sp->s_name,name,i); sp->s_flags = flags; if (status == DEFINING) sp->s_flags |= SYMDEF; diff --git a/util/opt/lookup.h b/util/opt/lookup.h index 53dc6b660..0d36e3b41 100644 --- a/util/opt/lookup.h +++ b/util/opt/lookup.h @@ -1,14 +1,14 @@ /* $Header$ */ -#define IDL 8 +#define IDL 100 struct sym { sym_p s_next; - char s_name[IDL]; offset *s_rom; short s_flags; short s_frag; offset s_value; + char s_name[2]; /* to be extended up to IDL */ }; /* contents of .s_flags */