changeset 106:43a3f1068027

Adjustments for list code
author lost@l-w.ca
date Sat, 06 Aug 2011 23:20:45 -0600
parents 3e9057059a43
children b3557f8325f7
files lwasm/list.c lwasm/main.c
diffstat 2 files changed, 13 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/lwasm/list.c	Sat Aug 06 23:20:10 2011 -0600
+++ b/lwasm/list.c	Sat Aug 06 23:20:45 2011 -0600
@@ -36,7 +36,7 @@
 void do_list(asmstate_t *as)
 {
 	line_t *cl, *nl, *nl2;
-	FILE *of;
+	FILE *of = NULL;
 	int i;
 	unsigned char *obytes = NULL;
 	int obytelen = 0;
@@ -45,9 +45,16 @@
 		
 	if (!(as -> flags & FLAG_LIST))
 		return;
-
+		
 	if (as -> list_file)
-		of = fopen(as -> list_file, "w");
+	{
+		if (strcmp(as -> list_file, "-") == 0)
+		{
+			of = stdout;
+		}
+		else
+			of = fopen(as -> list_file, "w");
+	}
 	else
 		of = stdout;
 	if (!of)
@@ -55,6 +62,7 @@
 		fprintf(stderr, "Cannot open list file; list not generated\n");
 		return;
 	}
+	
 	for (cl = as -> line_head; cl; cl = nl)
 	{
 		nl = cl -> next;
@@ -211,7 +219,6 @@
 		lw_free(obytes);
 		obytes = NULL;
 	}
-	
 	if (as -> flags & FLAG_SYMBOLS)
 		list_symbols(as, of);
 }
--- a/lwasm/main.c	Sat Aug 06 23:20:10 2011 -0600
+++ b/lwasm/main.c	Sat Aug 06 23:20:45 2011 -0600
@@ -62,7 +62,7 @@
 static int parse_opts(int key, char *arg, void *state)
 {
 	asmstate_t *as = state;
-	
+
 	switch (key)
 	{
 	case 'I':
@@ -107,7 +107,7 @@
 		if (as -> list_file)
 			lw_free(as -> list_file);
 		if (!arg)
-			as -> list_file = NULL;
+			as -> list_file = lw_strdup("-");
 		else
 			as -> list_file = lw_strdup(arg);
 		as -> flags |= FLAG_LIST;