aboutsummaryrefslogtreecommitdiff
path: root/libgfortran
diff options
context:
space:
mode:
authorJerry DeLisle <jvdelisle@gcc.gnu.org>2008-08-31 00:04:33 +0000
committerJerry DeLisle <jvdelisle@gcc.gnu.org>2008-08-31 00:04:33 +0000
commit8c8627c472ede1c89c7f61f6c0c26b87f2d27681 (patch)
tree7d96658215e45dc279a7c2dcc07fa9a0d13690e0 /libgfortran
parent5779e7133d84c5873249bb643d9852f314022f0b (diff)
downloadgcc-8c8627c472ede1c89c7f61f6c0c26b87f2d27681.zip
gcc-8c8627c472ede1c89c7f61f6c0c26b87f2d27681.tar.gz
gcc-8c8627c472ede1c89c7f61f6c0c26b87f2d27681.tar.bz2
re PR fortran/36895 (Namelist writting to internal files: Control characters wrong?)
2008-08-30 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR libfortran/36895 * io/write.c (namelist_write_newline): New function to correctly mark next records in both external and internal units. (nml_write_obj): Use new function. (namelist_write: Use new function. From-SVN: r139813
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog8
-rw-r--r--libgfortran/io/write.c40
2 files changed, 32 insertions, 16 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index 7b53360..f8083c8 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,11 @@
+2008-08-30 Jerry DeLisle <jvdelisle@gcc.gnu.org>
+
+ PR libfortran/36895
+ * io/write.c (namelist_write_newline): New function to correctly mark
+ next records in both external and internal units.
+ (nml_write_obj): Use new function.
+ (namelist_write: Use new function.
+
2008-08-19 Tobias Burnus <burnus@net-b.de>
PR libfortran/35863
diff --git a/libgfortran/io/write.c b/libgfortran/io/write.c
index 97aed53..65210bc 100644
--- a/libgfortran/io/write.c
+++ b/libgfortran/io/write.c
@@ -1116,6 +1116,22 @@ list_formatted_write (st_parameter_dt *dtp, bt type, void *p, int kind,
#define NML_DIGITS 20
+static void
+namelist_write_newline (st_parameter_dt *dtp)
+{
+ if (!is_internal_unit (dtp))
+ {
+#ifdef HAVE_CRLF
+ write_character (dtp, "\r\n", 1, 2);
+#else
+ write_character (dtp, "\n", 1, 1);
+#endif
+ }
+ else
+ write_character (dtp, " ", 1, 1);
+}
+
+
static namelist_info *
nml_write_obj (st_parameter_dt *dtp, namelist_info * obj, index_type offset,
namelist_info * base, char * base_name)
@@ -1152,11 +1168,9 @@ nml_write_obj (st_parameter_dt *dtp, namelist_info * obj, index_type offset,
if (obj->type != GFC_DTYPE_DERIVED)
{
-#ifdef HAVE_CRLF
- write_character (dtp, "\r\n ", 1, 3);
-#else
- write_character (dtp, "\n ", 1, 2);
-#endif
+ namelist_write_newline (dtp);
+ write_character (dtp, " ", 1, 1);
+
len = 0;
if (base)
{
@@ -1361,11 +1375,8 @@ nml_write_obj (st_parameter_dt *dtp, namelist_info * obj, index_type offset,
if (num > 5)
{
num = 0;
-#ifdef HAVE_CRLF
- write_character (dtp, "\r\n ", 1, 3);
-#else
- write_character (dtp, "\n ", 1, 2);
-#endif
+ namelist_write_newline (dtp);
+ write_character (dtp, " ", 1, 1);
}
rep_ctr = 1;
}
@@ -1392,6 +1403,7 @@ obj_loop:
return retval;
}
+
/* This is the entry function for namelist writes. It outputs the name
of the namelist and iterates through the namelist by calls to
nml_write_obj. The call below has dummys in the arguments used in
@@ -1447,12 +1459,8 @@ namelist_write (st_parameter_dt *dtp)
}
}
-#ifdef HAVE_CRLF
- write_character (dtp, " /\r\n", 1, 5);
-#else
- write_character (dtp, " /\n", 1, 4);
-#endif
-
+ write_character (dtp, " /", 1, 3);
+ namelist_write_newline (dtp);
/* Restore the original delimiter. */
dtp->u.p.delim_status = tmp_delim;
}