From 15c68e222fab78b3228a5b79d2387817f6f2672b Mon Sep 17 00:00:00 2001
From: kargl <kargl@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Sat, 21 Oct 2006 22:38:56 +0000
Subject: [PATCH] 2006-10-21  Steven G. Kargl  <kargl@gcc.gnu.org>

        * runtime/error.c: Add errno.h
        (generate_error): Set iostat to errno on OS error.
        * libgfortran.h: Set ERROR_OS to 5000



git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@117939 138bc75d-0d04-0410-961f-82ee72b054a4
---
 libgfortran/ChangeLog       | 6 ++++++
 libgfortran/libgfortran.h   | 2 +-
 libgfortran/runtime/error.c | 3 ++-
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index 19c2a92a3f67..a9e70825f802 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,9 @@
+2006-10-21  Steven G. Kargl  <kargl@gcc.gnu.org>
+
+	* runtime/error.c: Add errno.h
+	(generate_error): Set iostat to errno on OS error.
+	* libgfortran.h: Set ERROR_OS to 5000
+
 2006-10-20  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
 
 	* generated/minval_r8.c: Regenerate.
diff --git a/libgfortran/libgfortran.h b/libgfortran/libgfortran.h
index cdbde51f0af7..e023f0ea26e9 100644
--- a/libgfortran/libgfortran.h
+++ b/libgfortran/libgfortran.h
@@ -397,7 +397,7 @@ typedef enum
   ERROR_EOR = -2,
   ERROR_END = -1,
   ERROR_OK = 0,			/* Indicates success, must be zero.  */
-  ERROR_OS,			/* Operating system error, more info in errno.  */
+  ERROR_OS = 5000,		/* Operating system error, more info in errno.  */
   ERROR_OPTION_CONFLICT,
   ERROR_BAD_OPTION,
   ERROR_MISSING_OPTION,
diff --git a/libgfortran/runtime/error.c b/libgfortran/runtime/error.c
index 9960733f16a0..f8f76d3d26fc 100644
--- a/libgfortran/runtime/error.c
+++ b/libgfortran/runtime/error.c
@@ -34,6 +34,7 @@ Boston, MA 02110-1301, USA.  */
 #include <stdarg.h>
 #include <string.h>
 #include <float.h>
+#include <errno.h>
 
 #include "libgfortran.h"
 #include "../io/io.h"
@@ -457,7 +458,7 @@ generate_error (st_parameter_common *cmp, int family, const char *message)
 {
   /* Set the error status.  */
   if ((cmp->flags & IOPARM_HAS_IOSTAT))
-    *cmp->iostat = family;
+    *cmp->iostat = (family == ERROR_OS) ? errno : family;
 
   if (message == NULL)
     message =
-- 
GitLab