PR 78534, 83704 Handle large formatted I/O
[gcc.git] / libgfortran / io / write_float.def
index 04223c043a345f67e49d6b31fc5d39c41d689a6e..177a568e041d66bf1e302170a16b3d65da6611e6 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007-2016 Free Software Foundation, Inc.
+/* Copyright (C) 2007-2018 Free Software Foundation, Inc.
    Contributed by Andy Vaught
    Write float code factoring to this file by Jerry DeLisle   
    F2003 I/O support contributed by Jerry DeLisle
@@ -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] = '.';