gcl-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Gcl-devel] 2.6.11 windows


From: Camm Maguire
Subject: Re: [Gcl-devel] 2.6.11 windows
Date: Thu, 04 Sep 2014 11:30:54 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux)

Greetings!  Just a quick note, the following is better than that which
is committed, as it will catch exponents too.  If you could try
replacing the #ifdef BROKEN_WINDOWS_SSCANF in read.d with

#ifdef BROKEN_WINDOWS_SSCANF
    if (q-s>250) {
      memmove(s+250,q,strlen(q)+1);
      q=s+250;
    }
#endif

placed right *before* the call to sscanf and report the results, that
would be great.  If this works, I'll get the 250 constant from the
configure check and commit this instead.

Take care,

David Billinghurst <address@hidden> writes:

> On 4/09/2014 11:23 AM, Camm Maguire wrote:
>> Greetings!
>>
>> Could you please try commenting out the following line of o/read.d:
>>
>>      if (n!=1||s[m]) return OBJNULL;
> This works and prints 2.718281828459045 on the setq example
>
>> If this works, then try replacing it with
>>
>>     printf("%s %d %d %lf\n",s,n,m,f);fflush(stdout);
>>
>> recompile, and try your setq example again.  Your C library
>> implementation of sscanf cannot correctly process
>>
>>      n=sscanf(s,"%lf%n",&f,&m);
>>
>> and so far is the only such system that I have found.
>
> The sscanf function stops at character 349, so next character is not
> the null terminating the string.
> As shown, the strtod function works, so this may be an option.
>
> mingw uses the microsoft MSVCRT library for I/O. I have done a search
> and can't find mention of this bug.
>
> Here is a self contained test case.
>
> #include <stdio.h>
> #include <stdlib.h>
>
> int main () {
>   char s[]= "\
> 2.718281828459045235360287471352662497757247093699\
> 95957496696762772407663035354759457138217852516642\
> 74274663919320030599218174135966290435729003342952\
> 60595630738132328627943490763233829880753195251019\
> 01157383418793070215408914993488416750924476146066\
> 80822648001684774118537423454424371075390777449920\
> 69551702761838606261331384583000752044933826560297\
> 60673711320070932870912744374704723069697720931014\
> 16928368190255151086574637721112523897844250569536\
> 96770785449969967946864454905987931636889230098793\
> 12773617821542499922957635148220826989519366803318\
> 25288693984964651058209392398294887933203625094431\
> 173012381970684161404";
>   int n, m;
>   double f;
>   char *endptr;
>
>   n=sscanf(s,"%lf%n",&f,&m);
>   printf("s    = %s\n",s);
>   printf("n    = %d\n",n);
>   printf("m    = %d\n",m);
>   printf("f    = %lf\n",f);
>   printf("s[m-2]:s[m] = %c%c%c\n",s[m-2],s[m-1],s[m]);
>
>   /* try strtod
>    *endptr is character that stopped scan */
>   printf("\nWith strtod\n");
>   f = strtod(s,&endptr);
>   printf("f    = %lf\n",f);
>   printf("len  = %d\n",endptr-s);
>   if (! *endptr )
>     printf("Terminating char is null\n");
>   printf("Last char = %c\n",*(endptr-1));
>  }
>
>
> and the output
>
> s    =
> 2.7182818284590452353602874713526624977572470936999595749669676277240766303535475945713821785251664274274663919320030599218174135966290435729003342952605956307381323286279434907632338298807531952510190115738341879307021540891499348841675092447614606680822648001684774118537423454424371075390777449920695517027618386062613313845830007520449338265602976067371132007093287091274437470472306969772093101416928368190255151086574637721112523897844250569536967707854499699679468644549059879316368892300987931277361782154249992295763514822082698951936680331825288693984964651058209392398294887933203625094431173012381970684161404
> n    = 1
> m    = 349
> f    = 2.718282
> s[m-2]:s[m] = 297
>
> With strtod
> f    = 2.718282
> len  = 621
> Terminating char is null
> Last char = 4
>
>
>
>
>
>

-- 
Camm Maguire                                        address@hidden
==========================================================================
"The earth is but one country, and mankind its citizens."  --  Baha'u'llah



reply via email to

[Prev in Thread] Current Thread [Next in Thread]