develooper Front page | perl.cvs.parrot | Postings from December 2008

[svn:parrot] r34312 - trunk/compilers/imcc

From:
chromatic
Date:
December 23, 2008 18:01
Subject:
[svn:parrot] r34312 - trunk/compilers/imcc
Message ID:
20081224020134.5F4ADCBA12@x12.develooper.com
Author: chromatic
Date: Tue Dec 23 18:01:33 2008
New Revision: 34312

Modified:
   trunk/compilers/imcc/instructions.c

Log:
[IMCC] Added a check for the return value from a system call.

Modified: trunk/compilers/imcc/instructions.c
==============================================================================
--- trunk/compilers/imcc/instructions.c	(original)
+++ trunk/compilers/imcc/instructions.c	Tue Dec 23 18:01:33 2008
@@ -757,7 +757,7 @@
 
 =item C<static int e_file_open>
 
-Prints a me
+Prints a message to STDOUT.
 
 =cut
 
@@ -768,8 +768,13 @@
 {
     char * const file = (char *) param;
 
-    if (!STREQ(file, "-"))
-        freopen(file, "w", stdout);
+    if (!STREQ(file, "-")) {
+        FILE *newfile = freopen(file, "w", stdout);
+        if (!newfile)
+            Parrot_ex_throw_from_c_args(interp, NULL, EXCEPTION_EXTERNAL_ERROR,
+                "Cannot reopen stdout: %s'\n", strerror(errno));
+    }
+
     output = file;
     Parrot_io_printf(interp, "# IMCC does produce b0rken PASM files\n");
     Parrot_io_printf(interp, "# see http://guest@rt.perl.org/rt3/Ticket/Display.html?id=32392\n");



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About