Removed some harmless compiler warnings and converted some "double" ops to "int" in date.c. (CVS 5997)

FossilOrigin-Name: 5eb648a0b599c83504b892e2a5cefe6a837d6017
This commit is contained in:
shane 2008-12-09 04:59:00 +00:00
parent aa78bec993
commit aef3af54dd
3 changed files with 47 additions and 47 deletions

View File

@ -1,5 +1,5 @@
C Get\srid\sof\smore\ssilly\scompiler\swarnings.\s(CVS\s5996)
D 2008-12-09T03:55:14
C Removed\ssome\sharmless\scompiler\swarnings\sand\sconverted\ssome\s"double"\sops\sto\s"int"\sin\sdate.c.\s(CVS\s5997)
D 2008-12-09T04:59:00
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
F Makefile.in f7e4c81c347b04f7b0f1c1b081a168645d7b8af7
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@ -106,7 +106,7 @@ F src/btreeInt.h 8d21590c97b6a2c00cce1f78ed5dc5756e835108
F src/build.c ce642b06016d94b0dbc34d379bac82b597baf8d5
F src/callback.c e970e5beddbdb23f89a6d05cb1a6419d9f755624
F src/complete.c cb14e06dbe79dee031031f0d9e686ff306afe07c
F src/date.c 88898ae96a0d7f66711caffa40b2cf30e623a387
F src/date.c 80b158ab6d14f07bc81df8415c5ab2c477947d42
F src/delete.c d60885716666e5ea0f177b8db73c22c67ccba2cb
F src/expr.c ee295129a9efa0466ae4ebdb03adc33cd5c2e184
F src/fault.c dc88c821842157460750d2d61a8a8b4197d047ff
@ -664,7 +664,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
P 1522c2c6677b97edfa09dd64b4f9ed139aeb5bec
R 3cf4ecb0531c6feadf1fa1dceb64dc9c
U drh
Z 29140f0489a65f9e7ba95c829363e23e
P 59ae0020683766993c38e2b76a436d78d3e4bd63
R 17936af34c3e654d021393afaa888743
U shane
Z 7b2c61a1e0b4dfcc6d4fa7adb8f20c33

View File

@ -1 +1 @@
59ae0020683766993c38e2b76a436d78d3e4bd63
5eb648a0b599c83504b892e2a5cefe6a837d6017

View File

@ -16,7 +16,7 @@
** sqlite3RegisterDateTimeFunctions() found at the bottom of the file.
** All other code has file scope.
**
** $Id: date.c,v 1.94 2008/11/19 09:05:27 danielk1977 Exp $
** $Id: date.c,v 1.95 2008/12/09 04:59:00 shane Exp $
**
** SQLite processes all times and dates as Julian Day numbers. The
** dates and times are stored as the number of days since noon
@ -80,10 +80,10 @@ struct DateTime {
int h, m; /* Hour and minutes */
int tz; /* Timezone offset in minutes */
double s; /* Seconds */
char validYMD; /* True if Y,M,D are valid */
char validHMS; /* True if h,m,s are valid */
char validJD; /* True if iJD is valid */
char validTZ; /* True if tz is valid */
char validYMD; /* True (1) if Y,M,D are valid */
char validHMS; /* True (1) if h,m,s are valid */
char validJD; /* True (1) if iJD is valid */
char validTZ; /* True (1) if tz is valid */
};
@ -225,7 +225,7 @@ static int parseHhMmSs(const char *zDate, DateTime *p){
p->m = m;
p->s = s + ms;
if( parseTimezone(zDate, p) ) return 1;
p->validTZ = p->tz!=0;
p->validTZ = (p->tz!=0)?1:0;
return 0;
}
@ -254,12 +254,12 @@ static void computeJD(DateTime *p){
}
A = Y/100;
B = 2 - A + (A/4);
X1 = 365.25*(Y+4716);
X2 = 30.6001*(M+1);
p->iJD = (X1 + X2 + D + B - 1524.5)*86400000;
X1 = 36525*(Y+4716)/100;
X2 = 306001*(M+1)/10000;
p->iJD = (sqlite3_int64)((X1 + X2 + D + B - 1524.5 ) * 86400000);
p->validJD = 1;
if( p->validHMS ){
p->iJD += p->h*3600000 + p->m*60000 + p->s*1000;
p->iJD += p->h*3600000 + p->m*60000 + (sqlite3_int64)(p->s*1000);
if( p->validTZ ){
p->iJD -= p->tz*60000;
p->validYMD = 0;
@ -373,14 +373,14 @@ static void computeYMD(DateTime *p){
p->M = 1;
p->D = 1;
}else{
Z = (p->iJD + 43200000)/86400000;
A = (Z - 1867216.25)/36524.25;
Z = (int)((p->iJD + 43200000)/86400000);
A = (int)((Z - 1867216.25)/36524.25);
A = Z + 1 + A - (A/4);
B = A + 1524;
C = (B - 122.1)/365.25;
D = 365.25*C;
E = (B-D)/30.6001;
X1 = 30.6001*E;
C = (int)((B - 122.1)/365.25);
D = (36525*C)/100;
E = (int)((B-D)/30.6001);
X1 = (int)(30.6001*E);
p->D = B - D - X1;
p->M = E<14 ? E-1 : E-13;
p->Y = p->M>2 ? C - 4716 : C - 4715;
@ -395,9 +395,9 @@ static void computeHMS(DateTime *p){
int s;
if( p->validHMS ) return;
computeJD(p);
s = (p->iJD + 43200000) % 86400000;
s = (int)((p->iJD + 43200000) % 86400000);
p->s = s/1000.0;
s = p->s;
s = (int)p->s;
p->s -= s;
p->h = s/3600;
s -= p->h*3600;
@ -429,7 +429,7 @@ static void clearYMD_HMS_TZ(DateTime *p){
** between localtime and UTC (a.k.a. GMT)
** for the time value p where p is in UTC.
*/
static int localtimeOffset(DateTime *p){
static sqlite3_int64 localtimeOffset(DateTime *p){
DateTime x, y;
time_t t;
x = *p;
@ -442,13 +442,13 @@ static int localtimeOffset(DateTime *p){
x.m = 0;
x.s = 0.0;
} else {
int s = x.s + 0.5;
int s = (int)(x.s + 0.5);
x.s = s;
}
x.tz = 0;
x.validJD = 0;
computeJD(&x);
t = x.iJD/1000 - 2440587.5*86400.0;
t = x.iJD/1000 - 210866760000LL;
#ifdef HAVE_LOCALTIME_R
{
struct tm sLocal;
@ -550,13 +550,13 @@ static int parseModifier(const char *zMod, DateTime *p){
** seconds since 1970. Convert to a real julian day number.
*/
if( strcmp(z, "unixepoch")==0 && p->validJD ){
p->iJD = p->iJD/86400.0 + 2440587.5*86400000.0;
p->iJD = p->iJD*10/864000 + 210866760000000LL;
clearYMD_HMS_TZ(p);
rc = 0;
}
#ifndef SQLITE_OMIT_LOCALTIME
else if( strcmp(z, "utc")==0 ){
int c1;
sqlite3_int64 c1;
computeJD(p);
c1 = localtimeOffset(p);
p->iJD -= c1;
@ -576,7 +576,7 @@ static int parseModifier(const char *zMod, DateTime *p){
** date is already on the appropriate weekday, this is a no-op.
*/
if( strncmp(z, "weekday ", 8)==0 && getValue(&z[8],&r)>0
&& (n=r)==r && n>=0 && r<7 ){
&& (n=(int)r)==r && n>=0 && r<7 ){
sqlite3_int64 Z;
computeYMD_HMS(p);
p->validTZ = 0;
@ -657,35 +657,35 @@ static int parseModifier(const char *zMod, DateTime *p){
}
z += n;
while( isspace(*(u8*)z) ) z++;
n = strlen(z);
n = (int)strlen(z);
if( n>10 || n<3 ) break;
if( z[n-1]=='s' ){ z[n-1] = 0; n--; }
computeJD(p);
rc = 0;
if( n==3 && strcmp(z,"day")==0 ){
p->iJD += r*86400000.0 + 0.5;
p->iJD += (sqlite3_int64)(r*86400000.0 + 0.5);
}else if( n==4 && strcmp(z,"hour")==0 ){
p->iJD += r*(86400000.0/24.0) + 0.5;
p->iJD += (sqlite3_int64)(r*(86400000.0/24.0) + 0.5);
}else if( n==6 && strcmp(z,"minute")==0 ){
p->iJD += r*(86400000.0/(24.0*60.0)) + 0.5;
p->iJD += (sqlite3_int64)(r*(86400000.0/(24.0*60.0)) + 0.5);
}else if( n==6 && strcmp(z,"second")==0 ){
p->iJD += r*(86400000.0/(24.0*60.0*60.0)) + 0.5;
p->iJD += (sqlite3_int64)(r*(86400000.0/(24.0*60.0*60.0)) + 0.5);
}else if( n==5 && strcmp(z,"month")==0 ){
int x, y;
computeYMD_HMS(p);
p->M += r;
p->M += (int)r;
x = p->M>0 ? (p->M-1)/12 : (p->M-12)/12;
p->Y += x;
p->M -= x*12;
p->validJD = 0;
computeJD(p);
y = r;
y = (int)r;
if( y!=r ){
p->iJD += (r - y)*30.0*86400000.0 + 0.5;
p->iJD += (sqlite3_int64)((r - y)*30.0*86400000.0 + 0.5);
}
}else if( n==4 && strcmp(z,"year")==0 ){
computeYMD_HMS(p);
p->Y += r;
p->Y += (int)r;
p->validJD = 0;
computeJD(p);
}else{
@ -724,7 +724,7 @@ static int isDate(
setDateTimeToCurrent(context, p);
}else if( (eType = sqlite3_value_type(argv[0]))==SQLITE_FLOAT
|| eType==SQLITE_INTEGER ){
p->iJD = sqlite3_value_double(argv[0])*86400000.0 + 0.5;
p->iJD = (sqlite3_int64)(sqlite3_value_double(argv[0])*86400000.0 + 0.5);
p->validJD = 1;
}else{
z = sqlite3_value_text(argv[0]);
@ -847,7 +847,7 @@ static void strftimeFunc(
){
DateTime x;
u64 n;
int i, j;
size_t i,j;
char *z;
sqlite3 *db;
const char *zFmt = (const char*)sqlite3_value_text(argv[0]);
@ -893,7 +893,7 @@ static void strftimeFunc(
sqlite3_result_error_toobig(context);
return;
}else{
z = sqlite3DbMallocRaw(db, n);
z = sqlite3DbMallocRaw(db, (int)n);
if( z==0 ){
sqlite3_result_error_nomem(context);
return;
@ -924,10 +924,10 @@ static void strftimeFunc(
y.M = 1;
y.D = 1;
computeJD(&y);
nDay = (x.iJD - y.iJD)/86400000.0 + 0.5;
nDay = (int)((x.iJD-y.iJD+43200000)/86400000);
if( zFmt[i]=='W' ){
int wd; /* 0=Monday, 1=Tuesday, ... 6=Sunday */
wd = ((x.iJD+43200000)/86400000) % 7;
wd = (int)(((x.iJD+43200000)/86400000)%7);
sqlite3_snprintf(3, &z[j],"%02d",(nDay+7-wd)/7);
j += 2;
}else{
@ -950,7 +950,7 @@ static void strftimeFunc(
break;
}
case 'S': sqlite3_snprintf(3,&z[j],"%02d",(int)x.s); j+=2; break;
case 'w': z[j++] = (((x.iJD+129600000)/86400000) % 7) + '0'; break;
case 'w': z[j++] = (char)(((x.iJD+129600000)/86400000) % 7) + '0'; break;
case 'Y': sqlite3_snprintf(5,&z[j],"%04d",x.Y); j+=strlen(&z[j]);break;
default: z[j++] = '%'; break;
}