OSDN Git Service

2014-03-15 Jerry DeLisle <jvdelisle@gcc.gnu>
[pf3gnuchains/gcc-fork.git] / libgfortran / io / list_read.c
index d0e83ab..fa34e67 100644 (file)
@@ -1985,8 +1985,6 @@ list_formatted_read (st_parameter_dt *dtp, bt type, void *p, int kind,
 void
 finish_list_read (st_parameter_dt *dtp)
 {
-  int err;
-
   free_saved (dtp);
 
   fbuf_flush (dtp->u.p.current_unit, dtp->u.p.mode);
@@ -1997,9 +1995,22 @@ finish_list_read (st_parameter_dt *dtp)
       return;
     }
 
-  err = eat_line (dtp);
-  if (err == LIBERROR_END)
-    hit_eof (dtp);
+  if (!is_internal_unit (dtp))
+    {
+      int c;
+      c = next_char (dtp);
+      if (c == EOF)
+       {
+         free_line (dtp);
+         hit_eof (dtp);
+         return;
+       }
+      if (c != '\n')
+       eat_line (dtp);
+    }
+
+  free_line (dtp);
+
 }
 
 /*                     NAMELIST INPUT
@@ -2561,17 +2572,17 @@ nml_read_obj (st_parameter_dt *dtp, namelist_info * nl, index_type offset,
               since a single object can have multiple reads.  */
            dtp->u.p.expanded_read = 0;
 
-           /* Now loop over the components. Update the component pointer
-              with the return value from nml_write_obj.  This loop jumps
-              past nested derived types by testing if the potential
-              component name contains '%'.  */
+           /* Now loop over the components.  */
 
            for (cmp = nl->next;
                 cmp &&
-                  !strncmp (cmp->var_name, obj_name, obj_name_len) &&
-                  !strchr (cmp->var_name + obj_name_len, '%');
+                  !strncmp (cmp->var_name, obj_name, obj_name_len);
                 cmp = cmp->next)
              {
+               /* Jump over nested derived type by testing if the potential
+                  component name contains '%'.  */
+               if (strchr (cmp->var_name + obj_name_len, '%'))
+                   continue;
 
                if (nml_read_obj (dtp, cmp, (index_type)(pdata - nl->mem_pos),
                                  pprev_nl, nml_err_msg, nml_err_msg_size,
@@ -2885,7 +2896,8 @@ get_name:
          goto nml_err_ret;
        }
 
-      if (*pprev_nl == NULL || !component_flag)
+      /* Don't move first_nl further in the list if a qualifier was found.  */
+      if ((*pprev_nl == NULL && !qualifier_flag) || !component_flag)
        first_nl = nl;
 
       root_nl = nl;