From 45b4ec58102b53a056b5a84eb27ab8bc64cb6525 Mon Sep 17 00:00:00 2001 From: jvdelisle Date: Tue, 6 Sep 2016 23:22:26 +0000 Subject: 2016-09-06 Jerry DeLisle PR libgfortran/77393 * io/write_float.def (build_float_string): Recognize when the result will not fit in the user provided, star fill, and exit early. * gfortran.dg/fmt_f0_2.f90: Update test. * gfortran.dg/fmt_f0_3.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@240018 138bc75d-0d04-0410-961f-82ee72b054a4 --- libgfortran/io/write_float.def | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'libgfortran/io/write_float.def') diff --git a/libgfortran/io/write_float.def b/libgfortran/io/write_float.def index 04223c043a3..504482fa170 100644 --- a/libgfortran/io/write_float.def +++ b/libgfortran/io/write_float.def @@ -174,6 +174,13 @@ build_float_string (st_parameter_dt *dtp, const fnode *f, char *buffer, { case FMT_F: nbefore = ndigits - precision; + if ((w > 0) && (nbefore > (int) size)) + { + *len = w; + star_fill (result, w); + result[w] = '\0'; + return; + } /* Make sure the decimal point is a '.'; depending on the locale, this might not be the case otherwise. */ digits[nbefore] = '.'; -- cgit v1.2.1