Переглянути джерело

Incorporated variable length identifiers.
Courtesy Johan Stevenson

sater 40 роки тому
батько
коміт
d34532e79d
3 змінених файлів з 16 додано та 7 видалено
  1. 6 3
      util/opt/alloc.c
  2. 8 2
      util/opt/lookup.c
  3. 2 2
      util/opt/lookup.h

+ 6 - 3
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() {

+ 8 - 2
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;

+ 2 - 2
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 */