bug fixes
This commit is contained in:
parent
24ef5b3bfc
commit
40897bd709
@ -41,11 +41,16 @@ unsigned int scan_double(const char *in, double *dest) {
|
||||
}
|
||||
while (isdigit(*++c))
|
||||
exp=exp*10+(*c-'0');
|
||||
while (exp) { /* XXX: this introduces rounding errors */
|
||||
d*=10; --exp;
|
||||
}
|
||||
if (neg)
|
||||
while (exp) { /* XXX: this introduces rounding errors */
|
||||
d/=10; --exp;
|
||||
}
|
||||
else
|
||||
while (exp) { /* XXX: this introduces rounding errors */
|
||||
d*=10; --exp;
|
||||
}
|
||||
}
|
||||
done:
|
||||
*dest=d;
|
||||
*dest=(neg?-d:d);
|
||||
return c-in;
|
||||
}
|
||||
|
@ -35,15 +35,25 @@ int socket_sendfile(int out,int in,uint32 offset,uint32 bytes) {
|
||||
|
||||
int socket_sendfile(int out,int in,uint32 offset,uint32 bytes) {
|
||||
char buf[BUFSIZE];
|
||||
int n,m;
|
||||
int sent=0;
|
||||
if (lseek(in,offset,SEEK_SET) == -1)
|
||||
uint32 n,m;
|
||||
uint32 sent=0;
|
||||
if (lseek(in,offset,SEEK_SET) != offset)
|
||||
return -1;
|
||||
if ((n=read(in,buf,(bytes<BUFSIZE)?bytes:BUFSIZE))<0)
|
||||
return (sent?sent:-1);
|
||||
if ((m=write(out,buf,n))<0)
|
||||
return -1;
|
||||
return n;
|
||||
while (bytes>0) {
|
||||
char* tmp=buf;
|
||||
uint32 tobedone;
|
||||
if ((n=read(in,tmp,(bytes<BUFSIZE)?bytes:BUFSIZE))<=0)
|
||||
return (sent?sent:-1);
|
||||
while (n>0) {
|
||||
if ((m=write(out,tmp,n))<0)
|
||||
goto abort;
|
||||
sent+=m;
|
||||
n-=m;
|
||||
tmp+=m;
|
||||
}
|
||||
}
|
||||
abort:
|
||||
return sent;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user