gcc on Sparc Solaris 8

Jonathan Wakely jwakely.gcc@gmail.com
Mon Sep 30 13:39:00 GMT 2019


On Mon, 30 Sep 2019 at 14:33, rolf perau via gcc-help
<gcc-help@gcc.gnu.org> wrote:
>
> Hi Dennis,
> int scan_assign_double(ScanFILE *psf, double *pd, void *userdata, ScanFLAG flags){
>         char temp[100];
>
>         if (scan_nonblank(psf) == '=') fgetc(psf->fp);
>         if (scan_word(psf, temp, sizeof(temp)-1)) return -1;
>
> fprintf( stderr, "Reading the String : %s\n", temp);
>
>         if (sscanf(temp, " %lf ", pd) != 1) {
>                 error_out(err_scan_expect_double, temp, psf->filename, psf->linum);
>                 return -1;
>         }
>
> fprintf( stderr, "%s %lf\n\n", "After sscanf %lf :" , *pd);
>
>         if (scan_nonblank(psf) == ';') fgetc(psf->fp);
>         return 0;
> }
>
> Resulting in :
>
> Reading the String : 0.7
> After sscanf %lf : 0,000000
>
> Reading the String : 5257.872067
> After sscanf %lf : 5257,000000
>
> Reading the String : 152.498875
> After sscanf %lf : 152,000000
>
> Reading the String : 12.0
> After sscanf %lf : 12,000000
>
> Reading the String : 0.7
> After sscanf %lf : 0,000000


This looks pretty obviously related to locales. Your locale expects
',' as a decimal point, but the numbers you are trying to read have
'.' for decimal points. That means sscanf stops reading the number at
the '.' character, because that's the end of the string that matches
the expected format for a number.

In any case, sscanf is not part of GCC, it comes from the Solaris C
library, so this is not a GCC problem.



More information about the Gcc-help mailing list