[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gcl-devel] 2.6.11 windows
From: |
David Billinghurst |
Subject: |
Re: [Gcl-devel] 2.6.11 windows |
Date: |
Thu, 04 Sep 2014 22:17:23 +1000 |
User-agent: |
Mozilla/5.0 (Windows NT 5.1; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 |
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
- [Gcl-devel] 2.6.11 windows, Camm Maguire, 2014/09/02
- Message not available
- Message not available
- Re: [Gcl-devel] 2.6.11 windows,
David Billinghurst <=
- Re: [Gcl-devel] 2.6.11 windows, Camm Maguire, 2014/09/04
- Re: [Gcl-devel] 2.6.11 windows, Camm Maguire, 2014/09/04
- Re: [Gcl-devel] 2.6.11 windows, David Billinghurst, 2014/09/04
- Re: [Gcl-devel] 2.6.11 windows, Camm Maguire, 2014/09/05
- Re: [Gcl-devel] 2.6.11 windows, David Billinghurst, 2014/09/06