https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61847

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |burnus at gcc dot gnu.org

--- Comment #21 from Tobias Burnus <burnus at gcc dot gnu.org> ---
(In reply to Jerry DeLisle from comment #20)
> Created attachment 33858 [details]
> Proposed patch

  /* If the current locale is expecting a comma rather than a decimal
     point, convert it now.  */
  if (dtp->u.p.current_unit->decimal_locale == ',')
    *strchr (buffer, '.') = ',';

In principle, there are more options than just "," and "."; for instance, in
Britain, one often uses a centered dot (·) but that's not in the locale.

Looking at the output of all my locales, I found:
  ps_AF.utf8:     0٫400000
as the only locale which doesn't use either a '.' or a ','. Still, using a code
like the following looks more robust.

/* During _gfortran_st_read/write.  */
const char *curr_locale = setlocale(LC_ALL, NULL);
setlocale(LC_ALL, "C");

...

/* During _gfortran_st_read_done/write_done.  */
setlocale(LC_ALL, curr_locale);


* * *

Side remarks:

* Per PR36857 comment 8, it has to be "C" and not "POSIX" for MinGW.
* The fix for PR 36857 also assumes that there is only "," and "."; thus, when
going the setlocale route, it should be fixed as well.
* See also PR 47007; see also the variant using __strtold_l/strtold_l and
newlocale for READ (cf. PR 47007 comment 20 to 22).

Reply via email to