[patch, libfortran] PR33253 namelist: reading back a string with apostrophe

Jerry DeLisle jvdelisle@verizon.net
Wed Sep 5 05:32:00 GMT 2007


:ADDPATCH fortran]

Tobias Burnus wrote:
> Hi Jerry,
> 
> Jerry DeLisle wrote:
>> The title of this PR is a bit misleading.  The failure occurs with a
>> string without the apostrophe as well.  The problem here is that when
>> reading a string, we look at the first character and see if it is a
>> delimiter ' or " .  If not we would skip out and not read the rest of
>> the string.
> 
> For me, it does not fully work yet. Using the following program:
> --------------------
> program main
>   implicit none
>   character(len=3) :: a
>   namelist /foo/ a
>   open(10,delim="APOSTROPHE")
>   a = "a'a"
>   write(10,foo)
>   write (*,foo)
>   rewind 10
>   read (10,foo)
> end program main
> --------------------

The attached patch fixes this buglet.  We were not handling the interface to 
write_character quite right to convey the correct delimiting.

Updated the test case to  test the three possible delimiters that can be 
specified to assure the double quotes happen when they should.

Interestingly, the write_character function had all the necessary workings to do 
this. :)

Regression tested on x86-64-gnu-linux.

OK for trunk?

Regards,

Jerry

2007-09-04  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libfortran/33253
	* io/write.c (nml_write_obj): Set the delimiter correctly before calling
	write_character. (namelist_write): Clean up the code a little and add
	comments to clarify what its doing.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: namelist.diff
Type: text/x-patch
Size: 2182 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20070905/930a92cd/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: namelist_38.f90
Type: text/x-fortran
Size: 778 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20070905/930a92cd/attachment-0001.bin>


More information about the Gcc-patches mailing list