# HG changeset patch # User William Astle # Date 1339278442 21600 # Node ID 07e1fac76321ea44ec3af098160e856cd646f3f7 # Parent 080bb67d84f2e6e2d105cb242429b763e0fb2e8f 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. diff -r 080bb67d84f2 -r 07e1fac76321 docs/manual.docbook.sgml --- a/docs/manual.docbook.sgml Thu May 24 17:28:15 2012 -0600 +++ b/docs/manual.docbook.sgml Sat Jun 09 15:47:22 2012 -0600 @@ -1496,11 +1496,12 @@ -Each pragma supported has a positive version and a negative version. +Each pragma supported has a positive version and a negative version. The positive version enables the pragma while the negative version disables -it. The negatitve version is simply the positive version with "no" prefixed -to it. For instance, "pragma" vs. "nopragma". Only the positive version is -listed below. +it. The negatitve version is simply the positive version with "no" prefixed +to it. For instance, "pragma" vs. "nopragma". When only one version is +listed below, its opposite can be obtained by prepending "no" if it is not +present or removing "no" from the beginning if it is present. Pragmas are not case sensitive. @@ -1657,9 +1658,20 @@ assemblers, it is strongly recommended that it be invoked using the PRAGMA directive within the source code rather than on the command line or via the *PRAGMA directive. This way, an error will be raised if someone tries to -* assemble the code under a different assembler. +assemble the code under a different assembler. + + +nosymbolcase +symbolnocase + +Any symbol defined while this pragma is in force will be treated as +case insensitive, regardless whether the pragma is in force when the symbol +is referenced. +It is important to note that this pragma will not work as expected in +all cases when using the object file assembly target. It is intended for +use only when the assembler will be producing the final binary. diff -r 080bb67d84f2 -r 07e1fac76321 lwasm/lwasm.h --- a/lwasm/lwasm.h Thu May 24 17:28:15 2012 -0600 +++ b/lwasm/lwasm.h Sat Jun 09 15:47:22 2012 -0600 @@ -83,7 +83,8 @@ PRAGMA_SHADOW = 0x0040, // allow macros to shadow builtin operations PRAGMA_NOLIST = 0x0080, // don't show line in listing PRAGMA_AUTOBRANCHLENGTH = 0x0100, // automatically select proper length for relative branches - PRAGMA_EXPORT = 0x0200 // export symbols by default, unless local + PRAGMA_EXPORT = 0x0200, // export symbols by default, unless local + PRAGMA_SYMBOLNOCASE = 0x400 // symbols defined under this pragma are matched case insensitively }; @@ -194,6 +195,7 @@ symbol_flag_set = 1, // symbol was used with "set" symbol_flag_nocheck = 2, // do not check symbol characters symbol_flag_nolist = 4, // no not show symbol in symbol table + symbol_flag_nocase = 8, // do not match case of symbol symbol_flag_none = 0 // no flags }; diff -r 080bb67d84f2 -r 07e1fac76321 lwasm/pragma.c --- a/lwasm/pragma.c Thu May 24 17:28:15 2012 -0600 +++ b/lwasm/pragma.c Sat Jun 09 15:47:22 2012 -0600 @@ -57,6 +57,8 @@ { "nolist", "list", PRAGMA_NOLIST }, { "autobranchlength", "noautobranchlength", PRAGMA_AUTOBRANCHLENGTH }, { "export", "noexport", PRAGMA_EXPORT }, + { "symbolnocase", "nosymbolnocase", PRAGMA_SYMBOLNOCASE }, + { "nosymbolcase", "symbolcase", PRAGMA_SYMBOLNOCASE }, { 0, 0, 0} }; diff -r 080bb67d84f2 -r 07e1fac76321 lwasm/symbol.c --- a/lwasm/symbol.c Thu May 24 17:28:15 2012 -0600 +++ b/lwasm/symbol.c Sat Jun 09 15:47:22 2012 -0600 @@ -130,7 +130,10 @@ { int ndir; debug_message(as, 300, "Symbol add lookup: %p", se); - ndir = strcmp(sym, se->symbol); + if (se -> flags & symbol_flag_nocase) + ndir = strcasecmp(sym, se->symbol); + else + ndir = strcmp(sym, se->symbol); if (!ndir && se -> context != context) { ndir = (context < se -> context) ? -1 : 1; @@ -175,6 +178,10 @@ { nse -> flags |= symbol_flag_nolist; } + if (CURPRAGMA(cl, PRAGMA_SYMBOLNOCASE)) + { + nse -> flags |= symbol_flag_nocase; + } nse -> value = lw_expr_copy(val); nse -> symbol = lw_strdup(sym); nse -> right = NULL; @@ -251,7 +258,10 @@ for (s = as -> symtab.head; s; ) { - cdir = strcmp(sym, s->symbol); + if (s->flags & symbol_flag_nocase) + cdir = strcasecmp(sym, s->symbol); + else + cdir = strcmp(sym, s->symbol); if (!cdir) { if (local && s -> context != cl -> context)