Better implementation for --use-stdout
[fw/sdcc] / src / SDCCmain.c
index fdadaa08de4b4ef6ca4911643a4aa15577a12d56..6ca55ee3b0d7155c5e962cee0bb4ec8ba6838179 100644 (file)
@@ -22,6 +22,7 @@
    what you give them.   Help stamp out software-hoarding!
 -------------------------------------------------------------------------*/
 
+#include <io.h>
 #include <signal.h>
 #include "common.h"
 #include <ctype.h>
@@ -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;
 }
 
@@ -1478,11 +1480,11 @@ linkEdit (char **envp)
        /* VR 030517 - gplink needs linker options to set the linker script,*/
        buildCmdLine (buffer2, port->linker.cmd, dstFileName, scratchFileName, NULL, linkOptionsSet);
 
-       buildCmdLine2 (buffer, buffer2, sizeof(buffer));
+       buildCmdLine2 (buffer, sizeof(buffer), buffer2);
     }
   else
     {
-      buildCmdLine2 (buffer, port->linker.mcmd, sizeof(buffer));
+      buildCmdLine2 (buffer, sizeof(buffer), port->linker.mcmd);
     }
 
 /*  if (options.verbose)fprintf(stderr, "linker command line: %s\n", buffer); */
@@ -1569,7 +1571,7 @@ assemble (char **envp)
                      options.debug ? port->assembler.debug_opts : port->assembler.plain_opts,
                      asmOptionsSet);
     } else {
-       buildCmdLine2 (buffer, port->assembler.mcmd, sizeof(buffer));
+       buildCmdLine2 (buffer, sizeof(buffer), port->assembler.mcmd);
     }
 
     if (my_system (buffer)) {
@@ -1675,7 +1677,7 @@ preProcess (char **envp)
       if (options.verbose)
        printf ("sdcc: Calling preprocessor...\n");
 
-      buildCmdLine2 (buffer, _preCmd, sizeof(buffer));
+      buildCmdLine2 (buffer, sizeof(buffer), _preCmd);
 
       if (preProcOnly) {
         if (my_system (buffer)) {
@@ -1729,6 +1731,7 @@ setBinPaths(const char *argv0)
 }
 
 /* Set system include path */
+static void
 setIncludePath(void)
 {
   char *p;