aboutsummaryrefslogtreecommitdiff
path: root/backendC/CleanCompilerSources
diff options
context:
space:
mode:
authorjohnvg2011-05-10 13:11:52 +0000
committerjohnvg2011-05-10 13:11:52 +0000
commit13360723314998a282bd73f477e845b301953d09 (patch)
treed747ec94084fadd1e475f1e9ca81049afb46ca10 /backendC/CleanCompilerSources
parentonly allow universal quantifiers at the root of a function argument type, (diff)
don't use freopen to redirect stdout and stderror,
instead use FILE pointer variables std_out_file_p and std_error_file_p, using freopen caused problems on MacOSX with the named pipes that are used by batchbuild to communicate with the compiler(s). git-svn-id: https://svn.cs.ru.nl/repos/clean-compiler/trunk@1937 1f8540f1-abd5-4d5b-9d24-4c5ce8603e2d
Diffstat (limited to 'backendC/CleanCompilerSources')
-rw-r--r--backendC/CleanCompilerSources/backend.c20
-rw-r--r--backendC/CleanCompilerSources/cocl.c110
-rw-r--r--backendC/CleanCompilerSources/sun.h21
-rw-r--r--backendC/CleanCompilerSources/unix_io.c22
4 files changed, 79 insertions, 94 deletions
diff --git a/backendC/CleanCompilerSources/backend.c b/backendC/CleanCompilerSources/backend.c
index 2fd911e..4f149f4 100644
--- a/backendC/CleanCompilerSources/backend.c
+++ b/backendC/CleanCompilerSources/backend.c
@@ -3828,12 +3828,24 @@ BEInit (int argc)
void
BECloseFiles (void)
{
- if (StdErrorReopened)
+ if (StdErrorReopened){
+#ifdef _SUN_
+ fclose (std_error_file_p);
+ std_error_file_p = stderr;
+#else
fclose (StdError);
- StdErrorReopened = False;
- if (StdOutReopened)
+#endif
+ StdErrorReopened = False;
+ }
+ if (StdOutReopened){
+#ifdef _SUN_
+ fclose (std_out_file_p);
+ std_out_file_p = stdout;
+#else
fclose (StdOut);
- StdOutReopened = False;
+#endif
+ StdOutReopened = False;
+ }
} /* BECloseFiles */
void
diff --git a/backendC/CleanCompilerSources/cocl.c b/backendC/CleanCompilerSources/cocl.c
index 3ef308b..c179262 100644
--- a/backendC/CleanCompilerSources/cocl.c
+++ b/backendC/CleanCompilerSources/cocl.c
@@ -8,6 +8,10 @@
#include "MAIN_CLM.d"
+#ifdef _SUN_
+FILE *std_out_file_p,*std_error_file_p;
+#endif
+
static char usage[]=
"Usage: \'cocl [options] [-o file] file\'\n"
"Options: [-v] [-w] [-tc] [-d] [-sl] [-p] [-sa] [-lt] [-lset] [-lat] [-lattr]";
@@ -62,35 +66,7 @@ int use_clean_system_files;
#endif
#ifdef CLEAN2
- int StdOutReopened,StdErrorReopened;
-
- /* Windows:
- static int myfreopen (char *fileName, char *mode, FILE *oldFile)
- {
- FILE *newFile;
-
- newFile=freopen (fileName,mode,oldFile);
- if (newFile == NULL)
- return False;
-
- return True;
- }
-
- static int myfreopen (char *fileName, char *mode, FILE *oldFile)
- {
- FILE *newFile;
- FILE tmpFile;
-
- newFile=fopen (fileName,mode);
- if (newFile == NULL)
- return False;
-
- tmpFile = *oldFile;
- *oldFile = *newFile;
- *newFile = tmpFile;
- }
- # define freopen myfreopen
- */
+int StdOutReopened,StdErrorReopened;
#endif
#if defined (_MAC_) && defined (GNU_C)
@@ -118,11 +94,11 @@ Bool CallCompiler (int argc, char **argv)
{
char *fname,*output_file_name;
int i;
-#ifdef OS2
- extern int window_application;
- window_application=0;
-#endif
+# ifdef _SUN_
+ std_out_file_p = stdout;
+ std_error_file_p = stderr;
+# endif
fname = NULL;
output_file_name=NULL;
@@ -182,11 +158,7 @@ Bool CallCompiler (int argc, char **argv)
else if (strcmp (argv_i, "-c") == 0)
DoCode = False;
else if (strcmp (argv_i, "-p") == 0)
-#ifdef OS2
- window_application=1;
-#else
DoParallel = True;
-#endif
#ifdef _SUN_
else if (strcmp (argv_i, "-csf")==0)
use_clean_system_files=1;
@@ -243,9 +215,17 @@ Bool CallCompiler (int argc, char **argv)
}
} else if (strcmp (argv_i, "-RE") == 0){
if (++i < argc){
+#ifdef _SUN_
+ std_error_file_p = fopen (argv[i],"w");
+ if (std_error_file_p!=NULL)
+ StdErrorReopened = True;
+ else
+ std_error_file_p = stderr;
+#else
freopen (argv[i],"w",StdError);
-#ifdef CLEAN2
+# ifdef CLEAN2
StdErrorReopened = True;
+# endif
#endif
} else {
CmdError ("file name expected after -RE");
@@ -253,9 +233,17 @@ Bool CallCompiler (int argc, char **argv)
}
} else if (strcmp (argv_i, "-RAE") == 0){
if (++i < argc){
+#ifdef _SUN_
+ std_error_file_p = fopen (argv[i],"aw");
+ if (std_error_file_p!=NULL)
+ StdErrorReopened = True;
+ else
+ std_error_file_p = stderr;
+#else
freopen (argv[i],"aw",StdError);
-#ifdef CLEAN2
+# ifdef CLEAN2
StdErrorReopened = True;
+# endif
#endif
} else {
CmdError ("file name expected after -RAE");
@@ -263,9 +251,17 @@ Bool CallCompiler (int argc, char **argv)
}
} else if (strcmp (argv_i, "-RO") == 0){
if (++i < argc){
+#ifdef _SUN_
+ std_out_file_p = fopen (argv[i],"w");
+ if (std_out_file_p!=NULL)
+ StdOutReopened = True;
+ else
+ std_out_file_p = stdout;
+#else
freopen (argv[i],"w",StdOut);
-#ifdef CLEAN2
+# ifdef CLEAN2
StdOutReopened = True;
+# endif
#endif
} else {
CmdError ("file name expected after -RO");
@@ -273,9 +269,17 @@ Bool CallCompiler (int argc, char **argv)
}
} else if (strcmp (argv_i, "-RAO") == 0){
if (++i < argc){
+#ifdef _SUN_
+ std_out_file_p = fopen (argv[i],"aw");
+ if (std_out_file_p!=NULL)
+ StdOutReopened = True;
+ else
+ std_out_file_p = stdout;
+#else
freopen (argv[i],"aw",StdOut);
-#ifdef CLEAN2
+# ifdef CLEAN2
StdOutReopened = True;
+# endif
#endif
} else {
CmdError ("file name expected after -RAO");
@@ -333,27 +337,11 @@ Bool CallCompiler (int argc, char **argv)
#if ! defined (MAIN_CLM)
int main (int argc, char *argv[])
{
-#ifdef OS2
- {
- int length;
- extern char clean_lib_directory[];
+# ifdef _SUN_
+ std_out_file_p = stdout;
+ std_error_file_p = stderr;
+# endif
- length=strlen (argv[0]);
-
- if (length<=128){
- strcpy (clean_lib_directory,argv[0]);
-
- while (length>0){
- --length;
- if (clean_lib_directory[length]=='\\'){
- clean_lib_directory[length]=0;
- break;
- }
- }
- } else
- clean_lib_directory[0]='\0';
- }
-#endif
if (CallCompiler (argc-1, & argv[1]))
return 0;
else
diff --git a/backendC/CleanCompilerSources/sun.h b/backendC/CleanCompilerSources/sun.h
index f1a86d0..8a528c4 100644
--- a/backendC/CleanCompilerSources/sun.h
+++ b/backendC/CleanCompilerSources/sun.h
@@ -23,24 +23,19 @@ typedef float FourBytesReal;
typedef FILE *File;
-#define StdOut stdout
-#define StdError stderr
-#define StdVerboseH stdout
-#define StdVerboseL stdout
-#define StdTrace stdout
-#define StdDebug stdout;
-#define StdListTypes stdout
+extern FILE *std_out_file_p,*std_error_file_p;
+#define StdOut std_out_file_p
+#define StdError std_error_file_p
+#define StdVerboseH std_out_file_p
+#define StdVerboseL std_out_file_p
+#define StdTrace std_out_file_p
+#define StdDebug std_out_file_p
+#define StdListTypes std_out_file_p
#define FGetC(f) fgetc(f)
#define FGetS(s,n,f) fgets(s,n,f)
#define FPutC(c,f) fputc(c,f)
-/* #define System system */
-
int System (char *s);
int abs (int n);
-/* int rand (void); */
-/* int vsprintf (char *s, char *format, va_list arg); */
-
-
diff --git a/backendC/CleanCompilerSources/unix_io.c b/backendC/CleanCompilerSources/unix_io.c
index 199fa84..8849dbf 100644
--- a/backendC/CleanCompilerSources/unix_io.c
+++ b/backendC/CleanCompilerSources/unix_io.c
@@ -440,38 +440,29 @@ FileTime FGetFileTime (char *fname, FileKind kind)
return (FileTime) buf.st_mtime;
} /* FGetFileTime */
-
-
-
-/*******************************************************************************
- * *
- * Error Handling *
- * *
- ******************************************************************************/
+/* Error Handling */
void DoError (char *fmt, ...)
{ va_list args;
va_start (args, fmt);
- (void) vfprintf (stderr, fmt, args);
+ (void) vfprintf (StdError, fmt, args);
va_end (args);
-} /* DoError */
-
+}
void DoFatalError (char *fmt, ...)
{ va_list args;
va_start (args, fmt);
- (void) vfprintf (stderr, fmt, args);
+ (void) vfprintf (StdError, fmt, args);
va_end (args);
exit (0);
-} /* DoFatalError */
-
+}
void CmdError (char *errormsg,...)
{ va_list args;
@@ -483,8 +474,7 @@ void CmdError (char *errormsg,...)
fputc ('\n', stdout);
va_end (args);
-} /* CmdError */
-
+}
/*******************************************************************************
* Interrupt Handling *