OSDN Git Service

2009-08-17 Jerry DeLisle <jvdelisle@gcc.gnu.org>
authorjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 17 Aug 2009 14:27:29 +0000 (14:27 +0000)
committerjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 17 Aug 2009 14:27:29 +0000 (14:27 +0000)
PR fortran/41075
* io/io.h (enum format_token): Add FMT_STAR.
* io/format.c (format_lex): Add case for FMT_STAR.
(parse_format_list): Parse FMT_STAR and check for left paren
after. (next_format0): Modify helper function to check for
unimited format and return the repeated format node.  Update
comments to clarify.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@150844 138bc75d-0d04-0410-961f-82ee72b054a4

libgfortran/ChangeLog
libgfortran/io/format.c
libgfortran/io/io.h

index f441049..abeac8a 100644 (file)
@@ -1,3 +1,13 @@
+2009-08-17  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
+
+       PR fortran/41075
+       * io/io.h (enum format_token): Add FMT_STAR.
+       * io/format.c (format_lex): Add case for FMT_STAR.
+       (parse_format_list): Parse FMT_STAR and check for left paren
+       after. (next_format0): Modify helper function to check for
+       unimited format and return the repeated format node.  Update
+       comments to clarify.
+       
 2009-08-15  Kai Tietz  <kai.tietz@onevision.com>
 
        * intrinsics/string_intrinsics_inc.c (string_len_trim): Use
index e40adb9..e888a2e 100644 (file)
@@ -313,6 +313,10 @@ format_lex (format_data *fmt)
 
   switch (c)
     {
+    case '*':
+       token = FMT_STAR;
+       break;
+
     case '(':
       token = FMT_LPAREN;
       break;
@@ -595,6 +599,21 @@ parse_format_list (st_parameter_dt *dtp, bool *save_ok)
  format_item_1:
   switch (t)
     {
+    case FMT_STAR:
+      t = format_lex (fmt);
+      if (t != FMT_LPAREN)
+       {
+         fmt->error = "Left parenthesis required after '*'";
+         goto finished;
+       }
+      get_fnode (fmt, &head, &tail, FMT_LPAREN);
+      tail->repeat = -2;  /* Signifies unlimited format.  */
+      tail->u.child = parse_format_list (dtp, &saveit);
+      if (fmt->error != NULL)
+       goto finished;
+
+      goto between_desc;
+
     case FMT_POSINT:
       repeat = fmt->value;
 
@@ -1252,8 +1271,23 @@ next_format0 (fnode * f)
       return NULL;
     }
 
-  /* Deal with a parenthesis node */
+  /* Deal with a parenthesis node with unlimited format.  */
+
+  if (f->repeat == -2)  /* -2 signifies unlimited.  */
+  for (;;)
+    {
+      if (f->current == NULL)
+       f->current = f->u.child;
+
+      for (; f->current != NULL; f->current = f->current->next)
+       {
+         r = next_format0 (f->current);
+         if (r != NULL)
+           return r;
+       }
+    }
 
+  /* Deal with a parenthesis node with specific repeat count.  */
   for (; f->count < f->repeat; f->count++)
     {
       if (f->current == NULL)
index 2a07762..9ca6d38 100644 (file)
@@ -654,7 +654,7 @@ typedef enum
   FMT_LPAREN, FMT_RPAREN, FMT_X, FMT_S, FMT_SS, FMT_SP, FMT_STRING,
   FMT_BADSTRING, FMT_P, FMT_I, FMT_B, FMT_BN, FMT_BZ, FMT_O, FMT_Z, FMT_F,
   FMT_E, FMT_EN, FMT_ES, FMT_G, FMT_L, FMT_A, FMT_D, FMT_H, FMT_END, FMT_DC,
-  FMT_DP
+  FMT_DP, FMT_STAR
 }
 format_token;