changeset 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 ff024e572ff2
children 398773d7e504
files lwasm/instab.c lwasm/symbol.c
diffstat 2 files changed, 14 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/lwasm/instab.c	Sat Jun 09 23:36:24 2012 -0600
+++ b/lwasm/instab.c	Sun Jun 10 13:29:23 2012 -0600
@@ -600,6 +600,7 @@
 	{ "rmq", 		{	-1, 	-1, 	-1, 	-1 },	pseudo_parse_rmq,		pseudo_resolve_rmq,				pseudo_emit_rmq,			lwasm_insn_struct | lwasm_insn_setdata},
 
 	{ "zmb", 		{	-1, 	-1, 	-1, 	-1 },	pseudo_parse_zmb,		pseudo_resolve_zmb,				pseudo_emit_zmb,			lwasm_insn_normal},
+	{ "fzb", 		{	-1, 	-1, 	-1, 	-1 },	pseudo_parse_zmb,		pseudo_resolve_zmb,				pseudo_emit_zmb,			lwasm_insn_normal},
 	{ "zmd", 		{	-1, 	-1, 	-1, 	-1 },	pseudo_parse_zmd,		pseudo_resolve_zmd,				pseudo_emit_zmd,			lwasm_insn_normal},
 	{ "zmq", 		{	-1, 	-1, 	-1, 	-1 },	pseudo_parse_zmq,		pseudo_resolve_zmq,				pseudo_emit_zmq,			lwasm_insn_normal},
 
--- a/lwasm/symbol.c	Sat Jun 09 23:36:24 2012 -0600
+++ b/lwasm/symbol.c	Sun Jun 10 13:29:23 2012 -0600
@@ -130,10 +130,13 @@
 	{
 		int ndir;
 		debug_message(as, 300, "Symbol add lookup: %p", se);
-		if (se -> flags & symbol_flag_nocase)
-			ndir = strcasecmp(sym, se->symbol);
-		else
-			ndir = strcmp(sym, se->symbol);
+		ndir = strcasecmp(sym, se -> symbol);
+//		if (!ndir && !CURPRAGMA(cl, PRAGMA_SYMBOLNOCASE) && !(se -> flags & symbol_flag_set))
+		if (!ndir && !(se -> flags & symbol_flag_set))
+		{
+			if (strcmp(sym, se -> symbol))
+				ndir = 1;
+		}
 		if (!ndir && se -> context != context)
 		{
 			ndir = (context < se -> context) ? -1 : 1;
@@ -258,10 +261,12 @@
 	
 	for (s = as -> symtab.head; s; )
 	{
-		if (s->flags & symbol_flag_nocase)
-			cdir = strcasecmp(sym, s->symbol);
-		else
-			cdir = strcmp(sym, s->symbol);
+		cdir = strcasecmp(sym, s -> symbol);
+		if (!cdir && !(s->flags & symbol_flag_nocase))
+		{
+			if (strcmp(sym, s -> symbol))
+				cdir = 1;
+		}
 		if (!cdir)
 		{
 			if (local && s -> context != cl -> context)