From bd27f10defae57d8ca9f20a3bb135eb8f8928a09 Mon Sep 17 00:00:00 2001 From: burnus Date: Thu, 20 Dec 2007 08:16:48 +0000 Subject: [PATCH] 2007-12-20 Tobias Burnus PR fortran/34530 * io/list_read.c (eat_line): Move up in the file. (eat_separator): In namelist mode, skip over comment lines. 2007-12-20 Tobias Burnus PR fortran/34530 * gfortran.dg/namelist_44.f90: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@131099 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gfortran.dg/namelist_44.f90 | 29 ++++++++++++++++++++++++ libgfortran/ChangeLog | 6 +++++ libgfortran/io/list_read.c | 37 ++++++++++++++++++------------- 4 files changed, 62 insertions(+), 15 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/namelist_44.f90 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 231375b..3c67c45 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,10 @@ 2007-12-20 Tobias Burnus + PR fortran/34530 + * gfortran.dg/namelist_44.f90: New. + +2007-12-20 Tobias Burnus + PR fortran/34482 * gfortran.dg/boz_8.f90: Add error-check check. * gfortran.dg/boz_9.f90: Shorten BOZ where needed, replace diff --git a/gcc/testsuite/gfortran.dg/namelist_44.f90 b/gcc/testsuite/gfortran.dg/namelist_44.f90 new file mode 100644 index 0000000..5922d43 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/namelist_44.f90 @@ -0,0 +1,29 @@ +! { dg-do run } +! +! PR fortran/34530 +! +! Skipping over comment line was not working +! +! Test case contributed by Harald Anlauf. +! +program gfcbug77 + implicit none + + character(len=128) :: file = "" + logical :: default + namelist /BLACKLIST/ file, default + integer, parameter :: nnml = 10 + default = .true. + + open (nnml, file='gfcbug77.nml') + write(nnml,*) "&blacklist " ! The trailing space breaks gfortran + write(nnml,*) " ! This is a comment within the namelist" + write(nnml,*) " file = 'myfile'" + write(nnml,*) " default = F" + write(nnml,*) "/" + rewind(nnml) + read (nnml, nml=BLACKLIST) + close(nnml) + if(file /= "myfile" .or. default) call abort() +! write (*,nml=BLACKLIST) +end program gfcbug77 diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog index 286524b..9d84e1b 100644 --- a/libgfortran/ChangeLog +++ b/libgfortran/ChangeLog @@ -1,3 +1,9 @@ +2007-12-19 Tobias Burnus + + PR fortran/34530 + * io/list_read.c (eat_line): Move up in the file. + (eat_separator): In namelist mode, skip over comment lines. + 2007-12-16 Jerry DeLisle PR fortran/34427 diff --git a/libgfortran/io/list_read.c b/libgfortran/io/list_read.c index df43589..06fd8a1 100644 --- a/libgfortran/io/list_read.c +++ b/libgfortran/io/list_read.c @@ -275,6 +275,20 @@ eat_spaces (st_parameter_dt *dtp) } +/* This function reads characters through to the end of the current line and + just ignores them. */ + +static void +eat_line (st_parameter_dt *dtp) +{ + char c; + if (!is_internal_unit (dtp)) + do + c = next_char (dtp); + while (c != '\n'); +} + + /* Skip over a separator. Technically, we don't always eat the whole separator. This is because if we've processed the last input item, then a separator is unnecessary. Plus the fact that operating @@ -328,7 +342,14 @@ eat_separator (st_parameter_dt *dtp) if (dtp->u.p.namelist_mode) { do - c = next_char (dtp); + { + c = next_char (dtp); + if (c == '!') + { + eat_line (dtp); + c = next_char (dtp); + } + } while (c == '\n' || c == '\r' || c == ' '); unget_char (dtp, c); } @@ -407,20 +428,6 @@ finish_separator (st_parameter_dt *dtp) } -/* This function reads characters through to the end of the current line and - just ignores them. */ - -static void -eat_line (st_parameter_dt *dtp) -{ - char c; - if (!is_internal_unit (dtp)) - do - c = next_char (dtp); - while (c != '\n'); -} - - /* This function is needed to catch bad conversions so that namelist can attempt to see if dtp->u.p.saved_string contains a new object name rather than a bad value. */ -- 2.7.4