summaryrefslogtreecommitdiff
path: root/libgfortran/io/write.c
diff options
context:
space:
mode:
authorjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>2007-09-06 01:20:02 +0000
committerjvdelisle <jvdelisle@138bc75d-0d04-0410-961f-82ee72b054a4>2007-09-06 01:20:02 +0000
commitc53fac2722a5b5512fdc967cf7de1f1375f76053 (patch)
treeb90754cbdf4efd6d1bf2700fbd6908b2619d148e /libgfortran/io/write.c
parentb61df8e4b060200291f3276de29ad15ecc90793b (diff)
downloadgcc-c53fac2722a5b5512fdc967cf7de1f1375f76053.tar.gz
2007-09-05 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@128170 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/io/write.c')
-rw-r--r--libgfortran/io/write.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/libgfortran/io/write.c b/libgfortran/io/write.c
index 72f68b432fc..4792a222b9a 100644
--- a/libgfortran/io/write.c
+++ b/libgfortran/io/write.c
@@ -868,6 +868,7 @@ nml_write_obj (st_parameter_dt *dtp, namelist_info * obj, index_type offset,
size_t base_name_len;
size_t base_var_name_len;
size_t tot_len;
+ unit_delim tmp_delim;
/* Write namelist variable names in upper case. If a derived type,
nothing is output. If a component, base and base_name are set. */
@@ -984,11 +985,13 @@ nml_write_obj (st_parameter_dt *dtp, namelist_info * obj, index_type offset,
break;
case GFC_DTYPE_CHARACTER:
- if (dtp->u.p.nml_delim)
- write_character (dtp, &dtp->u.p.nml_delim, 1);
+ tmp_delim = dtp->u.p.current_unit->flags.delim;
+ if (dtp->u.p.nml_delim == '"')
+ dtp->u.p.current_unit->flags.delim = DELIM_QUOTE;
+ if (dtp->u.p.nml_delim == '\'')
+ dtp->u.p.current_unit->flags.delim = DELIM_APOSTROPHE;
write_character (dtp, p, obj->string_length);
- if (dtp->u.p.nml_delim)
- write_character (dtp, &dtp->u.p.nml_delim, 1);
+ dtp->u.p.current_unit->flags.delim = tmp_delim;
break;
case GFC_DTYPE_REAL:
@@ -1130,7 +1133,6 @@ namelist_write (st_parameter_dt *dtp)
/* Set the delimiter for namelist output. */
tmp_delim = dtp->u.p.current_unit->flags.delim;
- dtp->u.p.current_unit->flags.delim = DELIM_NONE;
switch (tmp_delim)
{
case (DELIM_QUOTE):
@@ -1146,10 +1148,12 @@ namelist_write (st_parameter_dt *dtp)
break;
}
+ /* Temporarily disable namelist delimters. */
+ dtp->u.p.current_unit->flags.delim = DELIM_NONE;
+
write_character (dtp, "&", 1);
/* Write namelist name in upper case - f95 std. */
-
for (i = 0 ;i < dtp->namelist_name_len ;i++ )
{
c = toupper (dtp->namelist_name[i]);
@@ -1165,14 +1169,14 @@ namelist_write (st_parameter_dt *dtp)
t1 = nml_write_obj (dtp, t2, dummy_offset, dummy, dummy_name);
}
}
+
#ifdef HAVE_CRLF
write_character (dtp, " /\r\n", 5);
#else
write_character (dtp, " /\n", 4);
#endif
- /* Recover the original delimiter. */
-
+ /* Restore the original delimiter. */
dtp->u.p.current_unit->flags.delim = tmp_delim;
}