comparison lwasm/symbol.c @ 215:5330ba70836a

Fix undefined symbol error with pragma nosymbolcase Made symbol tree lookup handle case sensitivity correctly. It is not sufficient to switch which of strcmp and strcasecmp is used to do the lookups. Instead, one must use strcasecmp all the way until a match and then use additional sorting once a match is achieved, if relevant. In this case, a simple linked list of symbols that differ only in case since this is not expected to be a common case.
author William Astle <lost@l-w.ca>
date Sun, 10 Jun 2012 13:29:23 -0600
parents 07e1fac76321
children 0c4b3e8b4d0b
comparison
equal deleted inserted replaced
214:ff024e572ff2 215:5330ba70836a
128 cdir = 0; 128 cdir = 0;
129 for (se = as -> symtab.head, sprev = NULL; se; ) 129 for (se = as -> symtab.head, sprev = NULL; se; )
130 { 130 {
131 int ndir; 131 int ndir;
132 debug_message(as, 300, "Symbol add lookup: %p", se); 132 debug_message(as, 300, "Symbol add lookup: %p", se);
133 if (se -> flags & symbol_flag_nocase) 133 ndir = strcasecmp(sym, se -> symbol);
134 ndir = strcasecmp(sym, se->symbol); 134 // if (!ndir && !CURPRAGMA(cl, PRAGMA_SYMBOLNOCASE) && !(se -> flags & symbol_flag_set))
135 else 135 if (!ndir && !(se -> flags & symbol_flag_set))
136 ndir = strcmp(sym, se->symbol); 136 {
137 if (strcmp(sym, se -> symbol))
138 ndir = 1;
139 }
137 if (!ndir && se -> context != context) 140 if (!ndir && se -> context != context)
138 { 141 {
139 ndir = (context < se -> context) ? -1 : 1; 142 ndir = (context < se -> context) ? -1 : 1;
140 } 143 }
141 if (!ndir) 144 if (!ndir)
256 if (!cl && local) 259 if (!cl && local)
257 return NULL; 260 return NULL;
258 261
259 for (s = as -> symtab.head; s; ) 262 for (s = as -> symtab.head; s; )
260 { 263 {
261 if (s->flags & symbol_flag_nocase) 264 cdir = strcasecmp(sym, s -> symbol);
262 cdir = strcasecmp(sym, s->symbol); 265 if (!cdir && !(s->flags & symbol_flag_nocase))
263 else 266 {
264 cdir = strcmp(sym, s->symbol); 267 if (strcmp(sym, s -> symbol))
268 cdir = 1;
269 }
265 if (!cdir) 270 if (!cdir)
266 { 271 {
267 if (local && s -> context != cl -> context) 272 if (local && s -> context != cl -> context)
268 { 273 {
269 cdir = (cl -> context < s -> context) ? -1 : 1; 274 cdir = (cl -> context < s -> context) ? -1 : 1;