]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR fortran/41075 ([F2008] Implement unlimited format item)
authorJerry DeLisle <jvdelisle@gcc.gnu.org>
Mon, 17 Aug 2009 14:27:29 +0000 (14:27 +0000)
committerJerry DeLisle <jvdelisle@gcc.gnu.org>
Mon, 17 Aug 2009 14:27:29 +0000 (14:27 +0000)
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.

From-SVN: r150844

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

index f441049f0362987aa9ed387d41c061c297f464be..abeac8a9525e64c3e193531adcb29135ab2d4d4a 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 e40adb9b2a103f82c2202dc84f400da7f16319fb..e888a2eba3f4c950060d270e10d9c0280f854181 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 2a077629a6d2aff5a67280b2aa44f5eaaf85b253..9ca6d387480dece0baae80ac6d2ca5f6167f3dc1 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;