From 96b3ee1c504a6507154bbbfcf081a8f969fb8671 Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Sun, 22 Apr 2012 19:28:34 +0200 Subject: [PATCH] re PR libfortran/53051 (I/O: Support reading floating-point numbers which use "Q" for the exponent) 2012-04-22 Tobias Burnus PR fortran/53051 * io/list_read.c (parse_real): Support "q" for the exponential. * io/read.c (read_f): Ditto. 2012-04-22 Tobias Burnus PR fortran/53051 * gfortran.dg/read_float_4.f90: New. From-SVN: r186675 --- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/read_float_4.f90 | 18 ++++++++++++++++++ libgfortran/ChangeLog | 7 +++++++ libgfortran/io/list_read.c | 6 ++++++ libgfortran/io/read.c | 2 ++ 5 files changed, 38 insertions(+) create mode 100644 gcc/testsuite/gfortran.dg/read_float_4.f90 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5f4f4b62dc6..d2877e72304 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2012-04-22 Tobias Burnus + + PR fortran/53051 + * gfortran.dg/read_float_4.f90: New. + 2012-04-21 Manuel López-Ibáñez PR 35441 diff --git a/gcc/testsuite/gfortran.dg/read_float_4.f90 b/gcc/testsuite/gfortran.dg/read_float_4.f90 new file mode 100644 index 00000000000..01a0de8c04f --- /dev/null +++ b/gcc/testsuite/gfortran.dg/read_float_4.f90 @@ -0,0 +1,18 @@ +! { dg-do run } +! +! PR libgfortran/53051 +! +! Check that reading "4.0q0" works, i.e. floating-point +! numbers which use "q" to indicate the exponential. +! (Which is a vendor extension.) +! + character(len=20) :: str + real :: r + integer :: i + + r = 0 + str = '1.0q0' + read(str, *, iostat=i) r + if (r /= 1.0 .or. i /= 0) call abort() + !print *, r + end diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 7f1a082a264..ec662841ee2 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,10 @@ +2012-04-22 Tobias Burnus + + PR fortran/53051 + * io/list_read.c (parse_real): Support "q" for the + exponential. + * io/read.c (read_f): Ditto. + 2012-04-17 Tobias Burnus PR libfortran/38199 diff --git a/libgfortran/io/list_read.c b/libgfortran/io/list_read.c index 2024fcd9b6c..4d2ce794120 100644 --- a/libgfortran/io/list_read.c +++ b/libgfortran/io/list_read.c @@ -1136,6 +1136,8 @@ parse_real (st_parameter_dt *dtp, void *buffer, int length) case 'E': case 'd': case 'D': + case 'q': + case 'Q': push_char (dtp, 'e'); goto exp1; @@ -1449,6 +1451,8 @@ read_real (st_parameter_dt *dtp, void * dest, int length) case 'e': case 'D': case 'd': + case 'Q': + case 'q': goto exp1; case '+': @@ -1546,6 +1550,8 @@ read_real (st_parameter_dt *dtp, void * dest, int length) case 'e': case 'D': case 'd': + case 'Q': + case 'q': goto exp1; case '+': diff --git a/libgfortran/io/read.c b/libgfortran/io/read.c index aa41bc7b9d2..32c8b3250f8 100644 --- a/libgfortran/io/read.c +++ b/libgfortran/io/read.c @@ -1026,6 +1026,8 @@ found_digit: case 'E': case 'd': case 'D': + case 'q': + case 'Q': ++p; --w; goto exponent;