comparison lwasm/symbol.c @ 207:07e1fac76321

Added pragma to allow non case sensitive symbols Added "nosymbolcase" and "symbolnocase" pragmas to cause symbols defined while the pragma is in effect to be treated as case insensitive. Also documented the new pragma.
author William Astle <lost@l-w.ca>
date Sat, 09 Jun 2012 15:47:22 -0600
parents 080bb67d84f2
children 5330ba70836a
comparison
equal deleted inserted replaced
206:080bb67d84f2 207:07e1fac76321
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 ndir = strcmp(sym, se->symbol); 133 if (se -> flags & symbol_flag_nocase)
134 ndir = strcasecmp(sym, se->symbol);
135 else
136 ndir = strcmp(sym, se->symbol);
134 if (!ndir && se -> context != context) 137 if (!ndir && se -> context != context)
135 { 138 {
136 ndir = (context < se -> context) ? -1 : 1; 139 ndir = (context < se -> context) ? -1 : 1;
137 } 140 }
138 if (!ndir) 141 if (!ndir)
172 nse -> version = version; 175 nse -> version = version;
173 nse -> flags = flags; 176 nse -> flags = flags;
174 if (CURPRAGMA(cl, PRAGMA_NOLIST)) 177 if (CURPRAGMA(cl, PRAGMA_NOLIST))
175 { 178 {
176 nse -> flags |= symbol_flag_nolist; 179 nse -> flags |= symbol_flag_nolist;
180 }
181 if (CURPRAGMA(cl, PRAGMA_SYMBOLNOCASE))
182 {
183 nse -> flags |= symbol_flag_nocase;
177 } 184 }
178 nse -> value = lw_expr_copy(val); 185 nse -> value = lw_expr_copy(val);
179 nse -> symbol = lw_strdup(sym); 186 nse -> symbol = lw_strdup(sym);
180 nse -> right = NULL; 187 nse -> right = NULL;
181 nse -> left = NULL; 188 nse -> left = NULL;
249 if (!cl && local) 256 if (!cl && local)
250 return NULL; 257 return NULL;
251 258
252 for (s = as -> symtab.head; s; ) 259 for (s = as -> symtab.head; s; )
253 { 260 {
254 cdir = strcmp(sym, s->symbol); 261 if (s->flags & symbol_flag_nocase)
262 cdir = strcasecmp(sym, s->symbol);
263 else
264 cdir = strcmp(sym, s->symbol);
255 if (!cdir) 265 if (!cdir)
256 { 266 {
257 if (local && s -> context != cl -> context) 267 if (local && s -> context != cl -> context)
258 { 268 {
259 cdir = (cl -> context < s -> context) ? -1 : 1; 269 cdir = (cl -> context < s -> context) ? -1 : 1;