# HG changeset patch # User lost@l-w.ca # Date 1312694445 21600 # Node ID 43a3f106802773e11ce26c83eae4748dc699d4bd # Parent 3e9057059a43a30e181110c28ec4b4c0fb841f47 Adjustments for list code diff -r 3e9057059a43 -r 43a3f1068027 lwasm/list.c --- 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); } diff -r 3e9057059a43 -r 43a3f1068027 lwasm/main.c --- 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;