This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH, libgfortran] PR24794 namelist input of character array]


:addpatch fortran: Resubmit, the attached diff is against current svn trunk. This is the whole thing with test cases.

2005-11-20 Jerry DeLisle <jvdelisle@gcc.gnu.org>

   PR libgfortran/24794
       * io/list_read.c (read_character): Add auto completion on short
       namelist reads.

Regression testing completed and passed.

OK for Trunk? OK for 4.0-branch?

Regards,

Jerry
Index: list_read.c
===================================================================
--- list_read.c	(revision 107242)
+++ list_read.c	(working copy)
@@ -724,6 +724,11 @@ read_character (int length __attribute__
       goto get_string;
 
     default:
+      if (namelist_mode)
+	{
+	  unget_char (c);
+	  return;
+	}
       push_char (c);
       goto get_string;
     }

c{ dg-do run }
c This program repeats many of the same tests as test_nml_1 but for integer
c instead of real. It also tests repeat nulls, comma delimited character read,
c a triplet qualifier, a range with and assumed start, a quote delimited string,
c a qualifier with an assumed end and a fully explicit range.  It also tests
c that integers and characters are successfully read back by namelist.
c Provided by Paul Thomas - pault@gcc.gnu.org

      program namelist_12

      integer*4 x(10)
      integer*8 xx
      integer ier
      character*10 ch , check
      namelist /mynml/ x, xx, ch
 
c set debug = 0 or 1 in the namelist! (line 33)

      do i = 1 , 10
        x(i) = -1
      end do
      x(6) = 6
      x(10) = 10
      xx = 0
      ch ="zzzzzzzzzz"
      check="abcdefghij"

      open (10,status="scratch", delim="apostrophe")
      write (10, '(a)') "!mynml"
      write (10, '(a)') " "
      write (10, '(a)') "&mynml  x(7) =+99 x=1, 2 ,"
      write (10, '(a)') " 2*3, ,, 2* !comment"
      write (10, '(a)') " 9 ch='qqqdefghqq' , x(8:7:-1) = 8 , 7"
      write (10, '(a)') " ch(:3) =""abc"","
      write (10, '(a)') " ch(9:)='ij' x(4:5)=4 ,5 xx = 42/"
      rewind (10)

      read (10, nml=mynml, IOSTAT=ier)
      if (ier.ne.0) call abort
      rewind (10)

      write (10, nml=mynml, iostat=ier)
      if (ier.ne.0) call abort
      rewind (10)

      read (10, NML=mynml, IOSTAT=ier)
      if (ier.ne.0) call abort
      close (10)

      do i = 1 , 10
        if ( abs( x(i) - i ) .ne. 0 ) call abort ()
        if ( ch(i:i).ne.check(I:I) ) call abort
      end do
      if (xx.ne.42) call abort ()
      end program

Attachment: namelist_13.f90
Description: application/extension-f90

Attachment: namelist_14.f90
Description: application/extension-f90

Attachment: namelist_15.f90
Description: application/extension-f90

Attachment: namelist_21.f90
Description: application/extension-f90

Attachment: namelist_22.f90
Description: application/extension-f90

Attachment: namelist_use.f90
Description: application/extension-f90

Attachment: namelist_use_only.f90
Description: application/extension-f90


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]