comparison 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
comparison
equal deleted inserted replaced
105:3e9057059a43 106:43a3f1068027
34 Do listing 34 Do listing
35 */ 35 */
36 void do_list(asmstate_t *as) 36 void do_list(asmstate_t *as)
37 { 37 {
38 line_t *cl, *nl, *nl2; 38 line_t *cl, *nl, *nl2;
39 FILE *of; 39 FILE *of = NULL;
40 int i; 40 int i;
41 unsigned char *obytes = NULL; 41 unsigned char *obytes = NULL;
42 int obytelen = 0; 42 int obytelen = 0;
43 43
44 char *tc; 44 char *tc;
45 45
46 if (!(as -> flags & FLAG_LIST)) 46 if (!(as -> flags & FLAG_LIST))
47 return; 47 return;
48 48
49 if (as -> list_file) 49 if (as -> list_file)
50 of = fopen(as -> list_file, "w"); 50 {
51 if (strcmp(as -> list_file, "-") == 0)
52 {
53 of = stdout;
54 }
55 else
56 of = fopen(as -> list_file, "w");
57 }
51 else 58 else
52 of = stdout; 59 of = stdout;
53 if (!of) 60 if (!of)
54 { 61 {
55 fprintf(stderr, "Cannot open list file; list not generated\n"); 62 fprintf(stderr, "Cannot open list file; list not generated\n");
56 return; 63 return;
57 } 64 }
65
58 for (cl = as -> line_head; cl; cl = nl) 66 for (cl = as -> line_head; cl; cl = nl)
59 { 67 {
60 nl = cl -> next; 68 nl = cl -> next;
61 if (CURPRAGMA(cl, PRAGMA_NOLIST)) 69 if (CURPRAGMA(cl, PRAGMA_NOLIST))
62 { 70 {
209 fprintf(of, "\n"); 217 fprintf(of, "\n");
210 } 218 }
211 lw_free(obytes); 219 lw_free(obytes);
212 obytes = NULL; 220 obytes = NULL;
213 } 221 }
214
215 if (as -> flags & FLAG_SYMBOLS) 222 if (as -> flags & FLAG_SYMBOLS)
216 list_symbols(as, of); 223 list_symbols(as, of);
217 } 224 }