374a375,386
> /* print output from preprocessor */
> static int tcc_preprocess = 0;
> static int out_linenum = 1;
> 
> #ifdef LIBTCC
> /* buffer for output to memory buffer */
> static CString preprocess_output;
> #define preprocess_out(s) cstr_cat(&preprocess_output, s)
> #else
> #define preprocess_out(s) fputs(s,stdout)
> #endif
> 
1664a1677,1678
>     case TOK_DOTS:
>         return strcpy(p, "...");
2519a2534,2580
> /* print line number and file name */
> void changed_file(void) {
>   char buf[1024];
>   snprintf(buf,sizeof(buf),"\n# %d \"%s\"\n",file->line_num,file->filename);
>   preprocess_out(buf);
>   out_linenum=file->line_num;
> }
> 
> /* print define stack until top reaches 'b' */
> static void print_defines(Sym *b)
> {
>     TokenString str;
>     Sym *nested_list;
>     Sym *top;
>     struct macro_level *ml;
>     int tok;
> 
>     top = define_stack;
>     while (top != b) {
>         tok = top->v;
>         if (tok >= TOK_IDENT && tok < tok_ident) {
> 	  tok_str_new(&str);
> 	  nested_list = NULL;
> 	  ml = NULL;
> 	  if (macro_subst_tok(&str, &nested_list, top, &ml) == 0) {
> 	    preprocess_out("#define ");
> 	    preprocess_out(get_tok_str(tok,NULL));
> 
> 	    tok_str_add(&str, 0);
> 	    int t;
> 	    CValue cval;
> 	    
> 	    int *stri=str.str;
> 	    for (;;) {
> 	      TOK_GET(t, stri, cval);
> 	      if (!t)
> 		break;
> 	      preprocess_out(" ");
> 	      preprocess_out(get_tok_str(t, &cval));
> 	    }
> 	    preprocess_out("\n");
> 	  }
> 	}
>         top = top->prev;
>     }
> }
> 
2940a3002,3004
> 
> 	    if (tcc_preprocess)
> 	      changed_file();
3538a3603,3604
> 		if (tcc_preprocess)
> 		  changed_file();
4343a4410
> 
4392a4460
>     
9204a9273,9275
>     if (tcc_preprocess)
>       changed_file();
>       
9212,9215d9282
<         next();
<         decl(VT_CONST);
<         if (tok != TOK_EOF)
<             expect("declaration");
9217,9218c9284,9302
<         /* end of translation unit info */
<         if (do_debug) {
---
> 	if (tcc_preprocess) {
> 	  for(;;) {
> 	    next();
> 	    while(out_linenum<file->line_num) {
> 	      preprocess_out("\n");
> 	      out_linenum++;
> 	    }
> 	    if (tok==TOK_EOF) break;
> 	    preprocess_out(get_tok_str(tok, &tokc));
> 	    preprocess_out(" ");
> 	  }
> 	} else {
> 	  next();
> 	  decl(VT_CONST);
> 	  if (tok != TOK_EOF)
>             expect("declaration");
> 	  
> 	  /* end of translation unit info */
> 	  if (do_debug) {
9221c9305,9307
<         }
---
> 	  }
> 	}
> 
9224a9311,9317
>     if (tcc_preprocess) {
>       /*
> 	print all defines
>       */
>       print_defines(define_start);
>     }
> 
9229c9322,9324
<     gen_inline_functions();
---
>     if (!tcc_preprocess) {
>       gen_inline_functions();
>     }
9236a9332,9346
> char *tcc_preprocess_string(TCCState *s, const char *buf)
> {
>     cstr_new(&preprocess_output);
>     tcc_preprocess=1;
>     int res=tcc_compile_string(s, buf);
>     tcc_preprocess=0;
>     if (res) {
>       cstr_free(&preprocess_output);
>       return 0;
>     }
>     char *ret=(char *)tcc_realloc(preprocess_output.data, preprocess_output.size+1);
>     ret[preprocess_output.size]=0;
>     return ret;
> }  
> 
10211a10322
>            "  -E          precompile only - output to stdout\n"
10240a10352
>     TCC_OPTION_E,
10273a10386
>     { "E", TCC_OPTION_E, 0 },
10417a10531,10533
>             case TCC_OPTION_E:
> 	        tcc_preprocess = 1;
> 	        break;
10665c10781,10782
<     if (s->output_type == TCC_OUTPUT_MEMORY) {
---
>     if (!tcc_preprocess) {
>       if (s->output_type == TCC_OUTPUT_MEMORY) {
10667c10784
<     } else
---
>       } else
10669,10675c10786,10793
<     if (s->output_type != TCC_OUTPUT_OBJ) {
<         ret = tcc_output_pe(s, outfile);
<     } else
< #endif
<     {
<         tcc_output_file(s, outfile);
<         ret = 0;
---
> 	if (s->output_type != TCC_OUTPUT_OBJ) {
> 	  ret = tcc_output_pe(s, outfile);
> 	} else
> #endif
> 	  {
> 	    tcc_output_file(s, outfile);
> 	    ret = 0;
> 	  }
10677c10795
<  the_end:
---
>     the_end:
