From f4a5503b5883e61757ef31f025878c964e364af6 Mon Sep 17 00:00:00 2001 From: jesusc Date: Fri, 20 Jun 2003 02:43:06 +0000 Subject: [PATCH] Better implementation for --use-stdout git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@2711 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/SDCC.lex | 4 ++-- src/SDCCglobl.h | 11 +++++++++++ src/SDCCmain.c | 4 +++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/SDCC.lex b/src/SDCC.lex index 93593591..cc78678f 100644 --- a/src/SDCC.lex +++ b/src/SDCC.lex @@ -671,11 +671,11 @@ int yyerror(char *s) if (mylineno && filename) { if(options.vc_err_style) - fprintf(stdout,"\n%s(%d) : %s: token -> '%s' ; column %d\n", + fprintf(stderr,"\n%s(%d) : %s: token -> '%s' ; column %d\n", filename,mylineno, s,yytext,column); else - fprintf(stdout,"\n%s:%d: %s: token -> '%s' ; column %d\n", + fprintf(stderr,"\n%s:%d: %s: token -> '%s' ; column %d\n", filename,mylineno, s,yytext,column); fatalError++; diff --git a/src/SDCCglobl.h b/src/SDCCglobl.h index 0b6d6f8e..711aa74d 100644 --- a/src/SDCCglobl.h +++ b/src/SDCCglobl.h @@ -338,4 +338,15 @@ extern struct _dumpFiles dumpFiles[]; */ extern char scratchFileName[PATH_MAX]; +/* Define well known filenos if the system does not define them. */ +#ifndef STDIN_FILENO +# define STDIN_FILENO 0 +#endif +#ifndef STDOUT_FILENO +# define STDOUT_FILENO 1 +#endif +#ifndef STDERR_FILENO +# define STDERR_FILENO 2 +#endif + #endif diff --git a/src/SDCCmain.c b/src/SDCCmain.c index 9f86359a..6ca55ee3 100644 --- a/src/SDCCmain.c +++ b/src/SDCCmain.c @@ -22,6 +22,7 @@ what you give them. Help stamp out software-hoarding! -------------------------------------------------------------------------*/ +#include #include #include "common.h" #include @@ -1271,7 +1272,8 @@ parseCmdLine (int argc, char **argv) werror (E_FILE_OPEN_ERR, scratchFileName); } MSVC_style(options.vc_err_style); - if(options.use_stdout) SetErrorOut(stdout); + if(options.use_stdout) dup2(STDOUT_FILENO, STDERR_FILENO); + return 0; } -- 2.47.2