* [patch, libfortran] PR33039 Read NAMELIST: reads wrong namelist name
@ 2007-08-10 5:36 Jerry DeLisle
2007-08-10 5:42 ` Paul Thomas
2007-08-10 6:07 ` Tobias Burnus
0 siblings, 2 replies; 3+ messages in thread
From: Jerry DeLisle @ 2007-08-10 5:36 UTC (permalink / raw)
To: Fortran List; +Cc: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 593 bytes --]
:ADDPATCH fortran:
Hi,
This patch fixes this by checking for the required space after a namelist name.
I also allow end of line characters, mostly to avoid rewriting a bunch of test
cases. It seems reasonable. The space is a requirement on the user, not the
compiler.
I will commit as obvious. Regression tested on x86-64-Gnu-Linux.
Attached is one test case that requires updating, plus one new test case.
Regards,
Jerry
2007-08-09 Jerry DeLisle <jvdelisle@gcc.gnu.org>
PR libfortran/33039
* io/list_read.c (find_nml_name): Check for a space after a namelist
name match.
[-- Attachment #2: pr33039.diff --]
[-- Type: text/x-patch, Size: 604 bytes --]
Index: list_read.c
===================================================================
--- list_read.c (revision 127265)
+++ list_read.c (working copy)
@@ -2593,6 +2593,14 @@ find_nml_name:
if (dtp->u.p.nml_read_error)
goto find_nml_name;
+ /* A trailing space is required, we give a little lattitude here, 10.9.1. */
+ c = next_char (dtp);
+ if (!(c == ' ' || c == '\r' || c == '\n'))
+ {
+ unget_char (dtp, c);
+ goto find_nml_name;
+ }
+
/* Ready to read namelist objects. If there is an error in input
from stdin, output the error message and continue. */
[-- Attachment #3: namelist_36.f90 --]
[-- Type: text/x-fortran, Size: 1102 bytes --]
! { dg-do run }
! PR33039 Read NAMELIST: reads wrong namelist name
! Test case from PR modified by Jerry DeLisle <jvdelisle@gcc.gnu.org>
PROGRAM namelist
CHARACTER*25 CHAR
NAMELIST /CODE/ CHAR, X
NAMELIST /CODEtwo/ X
OPEN(10, status="scratch")
write(10,'(a)') "File with test NAMELIST inputs"
write(10,'(a)') " &CODVJS char='VJS-Not a proper nml name', X=-0.5/"
write(10,'(a)') " &CODEone char='CODEone input', X=-1.0 /"
write(10,'(a)') " &CODEtwo char='CODEtwo inputs', X=-2.0/"
write(10,'(a)') " &code char='Lower case name',X=-3.0/"
write(10,'(a)') " &CODE char='Desired namelist sel', X=44./"
write(10,'(a)') " &CODEx char='Should not read CODEx nml', X=-5./"
write(10,'(a)') " $CODE char='Second desired nml', X=66.0 /"
write(10,'(a)') " $CODE X=77.0, char='Reordered desired nml'/"
rewind(10)
CHAR = 'Initialize string ***'
X = -777.
READ(10, nml=CODE, END=999)
if (x.ne.-3.0) call abort
READ(10, nml=CODE, END=999)
if (x.ne.44.0) call abort
READ(10, nml=CODE, END=999)
if (x.ne.66.0) call abort
READ(10, nml=CODE, END=999)
999 if (x.ne.77.0) call abort
END PROGRAM namelist
[-- Attachment #4: pr17286.f90 --]
[-- Type: text/x-fortran, Size: 1115 bytes --]
! { dg-do run }
! PR17286
! Namelist read failed when spaces exist between the '=' and the numbers
! This is a libgfortran bug
! Derived from testcase provided by Paul Thomas <paulthomas2@wanadoo.fr>
program bug3
integer num1 , num2 , num3 , num4
data num3 / 42 /
data num4 / 56 /
namelist /mynml1/ num1,num2
namelist /mynml2/ num3,num4
logical dbg
data dbg / .FALSE. /
open(unit=10,status='SCRATCH')
write(10,'(A)') "&mynml1 ,num1= 16,num2=32,&end"
!
! write mynml2
!
write(10,mynml2)
rewind(10)
!
! now read back
!
num1 = -1
num2 = -1
read(10,mynml1)
if (num1.eq.16.and.num2.eq.32) then
if (dbg) write(*,mynml1)
else
if (dbg) print *, 'expected 16 32 got ',num1,num2
call abort
endif
num3 = -1
num4 = -1
read(10,mynml2)
if (num3.eq.42.and.num4.eq.56) then
if (dbg) write(*,mynml2)
else
if (dbg) print *, 'expected 42 56 got ',num3,num4
call abort
endif
close(10)
end
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch, libfortran] PR33039 Read NAMELIST: reads wrong namelist name
2007-08-10 5:36 [patch, libfortran] PR33039 Read NAMELIST: reads wrong namelist name Jerry DeLisle
@ 2007-08-10 5:42 ` Paul Thomas
2007-08-10 6:07 ` Tobias Burnus
1 sibling, 0 replies; 3+ messages in thread
From: Paul Thomas @ 2007-08-10 5:42 UTC (permalink / raw)
To: Jerry DeLisle; +Cc: Fortran List, gcc-patches
:REVIEWMAIL:
Jerry,
This one is obviously OK.
Thanks
Paul
> :ADDPATCH fortran:
>
> Hi,
>
> This patch fixes this by checking for the required space after a
> namelist name. I also allow end of line characters, mostly to avoid
> rewriting a bunch of test cases. It seems reasonable. The space is a
> requirement on the user, not the compiler.
>
> I will commit as obvious. Regression tested on x86-64-Gnu-Linux.
>
> Attached is one test case that requires updating, plus one new test case.
>
> Regards,
>
> Jerry
>
> 2007-08-09 Jerry DeLisle <jvdelisle@gcc.gnu.org>
>
> PR libfortran/33039
> * io/list_read.c (find_nml_name): Check for a space after a namelist
> name match.
> ------------------------------------------------------------------------
>
> Index: list_read.c
> ===================================================================
> --- list_read.c (revision 127265)
> +++ list_read.c (working copy)
> @@ -2593,6 +2593,14 @@ find_nml_name:
> if (dtp->u.p.nml_read_error)
> goto find_nml_name;
>
> + /* A trailing space is required, we give a little lattitude here, 10.9.1. */
> + c = next_char (dtp);
> + if (!(c == ' ' || c == '\r' || c == '\n'))
> + {
> + unget_char (dtp, c);
> + goto find_nml_name;
> + }
> +
> /* Ready to read namelist objects. If there is an error in input
> from stdin, output the error message and continue. */
>
>
> ------------------------------------------------------------------------
>
> ! { dg-do run }
> ! PR33039 Read NAMELIST: reads wrong namelist name
> ! Test case from PR modified by Jerry DeLisle <jvdelisle@gcc.gnu.org>
> PROGRAM namelist
> CHARACTER*25 CHAR
> NAMELIST /CODE/ CHAR, X
> NAMELIST /CODEtwo/ X
>
> OPEN(10, status="scratch")
> write(10,'(a)') "File with test NAMELIST inputs"
> write(10,'(a)') " &CODVJS char='VJS-Not a proper nml name', X=-0.5/"
> write(10,'(a)') " &CODEone char='CODEone input', X=-1.0 /"
> write(10,'(a)') " &CODEtwo char='CODEtwo inputs', X=-2.0/"
> write(10,'(a)') " &code char='Lower case name',X=-3.0/"
> write(10,'(a)') " &CODE char='Desired namelist sel', X=44./"
> write(10,'(a)') " &CODEx char='Should not read CODEx nml', X=-5./"
> write(10,'(a)') " $CODE char='Second desired nml', X=66.0 /"
> write(10,'(a)') " $CODE X=77.0, char='Reordered desired nml'/"
> rewind(10)
> CHAR = 'Initialize string ***'
> X = -777.
> READ(10, nml=CODE, END=999)
> if (x.ne.-3.0) call abort
> READ(10, nml=CODE, END=999)
> if (x.ne.44.0) call abort
> READ(10, nml=CODE, END=999)
> if (x.ne.66.0) call abort
> READ(10, nml=CODE, END=999)
> 999 if (x.ne.77.0) call abort
> END PROGRAM namelist
>
> ------------------------------------------------------------------------
>
> ! { dg-do run }
> ! PR17286
> ! Namelist read failed when spaces exist between the '=' and the numbers
> ! This is a libgfortran bug
> ! Derived from testcase provided by Paul Thomas <paulthomas2@wanadoo.fr>
> program bug3
> integer num1 , num2 , num3 , num4
> data num3 / 42 /
> data num4 / 56 /
> namelist /mynml1/ num1,num2
> namelist /mynml2/ num3,num4
> logical dbg
> data dbg / .FALSE. /
> open(unit=10,status='SCRATCH')
> write(10,'(A)') "&mynml1 ,num1= 16,num2=32,&end"
> !
> ! write mynml2
> !
> write(10,mynml2)
> rewind(10)
> !
> ! now read back
> !
> num1 = -1
> num2 = -1
> read(10,mynml1)
> if (num1.eq.16.and.num2.eq.32) then
> if (dbg) write(*,mynml1)
> else
> if (dbg) print *, 'expected 16 32 got ',num1,num2
> call abort
> endif
> num3 = -1
> num4 = -1
> read(10,mynml2)
> if (num3.eq.42.and.num4.eq.56) then
> if (dbg) write(*,mynml2)
> else
> if (dbg) print *, 'expected 42 56 got ',num3,num4
> call abort
> endif
>
> close(10)
> end
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch, libfortran] PR33039 Read NAMELIST: reads wrong namelist name
2007-08-10 5:36 [patch, libfortran] PR33039 Read NAMELIST: reads wrong namelist name Jerry DeLisle
2007-08-10 5:42 ` Paul Thomas
@ 2007-08-10 6:07 ` Tobias Burnus
1 sibling, 0 replies; 3+ messages in thread
From: Tobias Burnus @ 2007-08-10 6:07 UTC (permalink / raw)
To: Jerry DeLisle; +Cc: Fortran List, gcc-patches
Jerry DeLisle wrote:
> This patch fixes this by checking for the required space after a
> namelist name. I also allow end of line characters, mostly to avoid
> rewriting a bunch of test cases. It seems reasonable. The space is a
> requirement on the user, not the compiler.
I just tried using a tab character and all my compilers accepted it - I
think one could/should allow a '\t' as extension.
Tobias
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-08-10 6:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-10 5:36 [patch, libfortran] PR33039 Read NAMELIST: reads wrong namelist name Jerry DeLisle
2007-08-10 5:42 ` Paul Thomas
2007-08-10 6:07 ` Tobias Burnus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).