diff lwasm/pseudo.c @ 192:bfd0fb0a85c2

Allow exporting multiple symbols on a single directive
author lost
date Sun, 22 Mar 2009 16:28:40 +0000
parents 563adfccb645
children 6ddc861a07d4
line wrap: on
line diff
--- a/lwasm/pseudo.c	Sun Mar 22 16:12:06 2009 +0000
+++ b/lwasm/pseudo.c	Sun Mar 22 16:28:40 2009 +0000
@@ -1039,6 +1039,7 @@
 	lwasm_symbol_ent_t *se;
 	export_list_t *ex;
 	char *sym2, *sym3;
+	int after = 0;
 
 	if (as -> outformat != OUTPUT_OBJ)
 	{
@@ -1049,18 +1050,26 @@
 	if (as -> passnum == 1)
 		return;
 
-	if (!(l -> sym))
+again:
+	if (!(l -> sym) || after == 1)
 	{
+	
+		after = 1;
 		// look for symbol after op
 		if (**p)
 		{
-			for (sym2 = *p; **p && !isspace(**p); (*p)++)
+			for (sym2 = *p; **p && !isspace(**p) && **p != ','; (*p)++)
 				/* do nothing */ ;
+
+			debug_message(2, "export expression: %s", sym2);			
+			if (l -> sym)
+				lwasm_free(l -> sym);
 			sym3 = lwasm_alloc(*p - sym2 + 1);
 			memcpy(sym3, sym2, *p - sym2);
 			sym3[*p - sym2] = '\0';
 			
 			l -> sym = sym3;
+			debug_message(2, "export symbol: '%s'", sym3);
 		}
 	}
 	if (!(l -> sym))
@@ -1116,4 +1125,15 @@
 	se -> sect -> exports = ex;
 	ex -> offset = se -> value;
 	ex -> sym = lwasm_strdup(se -> sym);
+	if (after == 1)
+	{
+		if (**p == ',')
+		{
+			debug_message(2, "Export another symbol: %s", *p);
+			(*p)++;
+			for ( ; **p && isspace(**p); (*p)++)
+				/* do nothing */ ;
+			goto again;
+		}
+	}
 }