re PR libfortran/32456 (IO error message should show Unit/Filename)
authorJerry DeLisle <jvdelisle@gcc.gnu.org>
Fri, 29 Jun 2007 19:39:21 +0000 (19:39 +0000)
committerJerry DeLisle <jvdelisle@gcc.gnu.org>
Fri, 29 Jun 2007 19:39:21 +0000 (19:39 +0000)
2007-06-29  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

PR libgfortran/32456
* io/unit.c (filename_from_unit): Don't use find_unit, instead search
for unit directly.

From-SVN: r126119

libgfortran/ChangeLog
libgfortran/io/unit.c

index fc8e1edf2b57593ef89a78164cf3ceffea1fec40..0b5afdecb3c77c4b5d1938a82a95b57c4be8dfce 100644 (file)
@@ -1,3 +1,9 @@
+2007-06-29  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
+
+       PR libgfortran/32456
+       * io/unit.c (filename_from_unit): Don't use find_unit, instead search
+       for unit directly.
+
 2007-06-24  Adam Nemet  <anemet@caviumnetworks.com>
 
        PR libfortran/32495
index 9297af0852138650755542c828e43f96fdf65e58..fac67bdaf7ec494f973836369f1f76f4e11305ba 100644 (file)
@@ -690,11 +690,26 @@ update_position (gfc_unit *u)
    must free memory allocated for the filename string.  */
 
 char *
-filename_from_unit (int unit_number)
+filename_from_unit (int n)
 {
   char *filename;
-  gfc_unit *u = NULL;
-  u = find_unit (unit_number);
+  gfc_unit *u;
+  int c;
+
+  /* Find the unit.  */
+  u = unit_root;
+  while (u != NULL)
+    {
+      c = compare (n, u->unit_number);
+      if (c < 0)
+       u = u->left;
+      if (c > 0)
+       u = u->right;
+      if (c == 0)
+       break;
+    }
+
+  /* Get the filename.  */
   if (u != NULL)
     {
       filename = (char *) get_mem (u->file_len + 1);
@@ -703,4 +718,5 @@ filename_from_unit (int unit_number)
     }
   else
     return (char *) NULL;
-}
\ No newline at end of file
+}
+