diff lwasm/list.c @ 106:43a3f1068027

Adjustments for list code
author lost@l-w.ca
date Sat, 06 Aug 2011 23:20:45 -0600
parents 428068681cbf
children 697bc543368c
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);
 }