aboutsummaryrefslogtreecommitdiff
path: root/src/printf.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/printf.c')
-rw-r--r--src/printf.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/src/printf.c b/src/printf.c
index 6518ddb22..58e575be8 100644
--- a/src/printf.c
+++ b/src/printf.c
@@ -5,7 +5,7 @@
** an historical reference. Most of the "enhancements" have been backed
** out so that the functionality is now the same as standard printf().
**
-** $Id: printf.c,v 1.98 2008/12/10 18:03:46 drh Exp $
+** $Id: printf.c,v 1.99 2008/12/10 19:26:24 drh Exp $
**
**************************************************************************
**
@@ -156,7 +156,7 @@ static const et_info fmtinfo[] = {
** 16 (the number of significant digits in a 64-bit float) '0' is
** always returned.
*/
-static int et_getdigit(LONGDOUBLE_TYPE *val, int *cnt){
+static char et_getdigit(LONGDOUBLE_TYPE *val, int *cnt){
int digit;
LONGDOUBLE_TYPE d;
if( (*cnt)++ >= 16 ) return '0';
@@ -164,7 +164,7 @@ static int et_getdigit(LONGDOUBLE_TYPE *val, int *cnt){
d = digit;
digit += '0';
*val = (*val - d)*10.0;
- return digit;
+ return (char)digit;
}
#endif /* SQLITE_OMIT_FLOATING_POINT */
@@ -413,7 +413,7 @@ void sqlite3VXPrintf(
bufpt = &buf[etBUFSIZE-1];
if( xtype==etORDINAL ){
static const char zOrd[] = "thstndrd";
- int x = longvalue % 10;
+ int x = (int)(longvalue % 10);
if( x>=4 || (longvalue/10)%10==1 ){
x = 0;
}
@@ -431,7 +431,7 @@ void sqlite3VXPrintf(
longvalue = longvalue/base;
}while( longvalue>0 );
}
- length = &buf[etBUFSIZE-1]-bufpt;
+ length = (int)(&buf[etBUFSIZE-1]-bufpt);
for(idx=precision-length; idx>0; idx--){
*(--bufpt) = '0'; /* Zero pad */
}
@@ -442,7 +442,7 @@ void sqlite3VXPrintf(
pre = &aPrefix[infop->prefix];
for(; (x=(*pre))!=0; pre++) *(--bufpt) = x;
}
- length = &buf[etBUFSIZE-1]-bufpt;
+ length = (int)(&buf[etBUFSIZE-1]-bufpt);
break;
case etFLOAT:
case etEXP:
@@ -470,7 +470,7 @@ void sqlite3VXPrintf(
if( xtype==etFLOAT ) realvalue += rounder;
/* Normalize realvalue to within 10.0 > realvalue >= 1.0 */
exp = 0;
- if( sqlite3IsNaN(realvalue) ){
+ if( sqlite3IsNaN((double)realvalue) ){
bufpt = "NaN";
length = 3;
break;
@@ -489,7 +489,7 @@ void sqlite3VXPrintf(
}else{
bufpt = "Inf";
}
- length = strlen(bufpt);
+ length = sqlite3Strlen30(bufpt);
break;
}
}
@@ -520,7 +520,7 @@ void sqlite3VXPrintf(
e2 = exp;
}
nsd = 0;
- flag_dp = (precision>0) | flag_alternateform | flag_altform2;
+ flag_dp = (precision>0 ?1:0) | flag_alternateform | flag_altform2;
/* The sign in front of the number */
if( prefix ){
*(bufpt++) = prefix;
@@ -568,18 +568,18 @@ void sqlite3VXPrintf(
*(bufpt++) = '+';
}
if( exp>=100 ){
- *(bufpt++) = (exp/100)+'0'; /* 100's digit */
+ *(bufpt++) = (char)((exp/100)+'0'); /* 100's digit */
exp %= 100;
}
- *(bufpt++) = exp/10+'0'; /* 10's digit */
- *(bufpt++) = exp%10+'0'; /* 1's digit */
+ *(bufpt++) = (char)(exp/10+'0'); /* 10's digit */
+ *(bufpt++) = (char)(exp%10+'0'); /* 1's digit */
}
*bufpt = 0;
/* The converted number is in buf[] and zero terminated. Output it.
** Note that the number is in the usual order, not reversed as with
** integer conversions. */
- length = bufpt-buf;
+ length = (int)(bufpt-buf);
bufpt = buf;
/* Special case: Add leading zeros if the flag_zeropad flag is
@@ -606,9 +606,10 @@ void sqlite3VXPrintf(
length = 1;
break;
case etCHARX:
- c = buf[0] = va_arg(ap,int);
+ c = va_arg(ap,int);
+ buf[0] = (char)c;
if( precision>=0 ){
- for(idx=1; idx<precision; idx++) buf[idx] = c;
+ for(idx=1; idx<precision; idx++) buf[idx] = (char)c;
length = precision;
}else{
length =1;
@@ -626,14 +627,15 @@ void sqlite3VXPrintf(
if( precision>=0 ){
for(length=0; length<precision && bufpt[length]; length++){}
}else{
- length = strlen(bufpt);
+ length = sqlite3Strlen30(bufpt);
}
break;
case etSQLESCAPE:
case etSQLESCAPE2:
case etSQLESCAPE3: {
- int i, j, n, ch, isnull;
+ int i, j, n, isnull;
int needQuote;
+ char ch;
char q = ((xtype==etSQLESCAPE3)?'"':'\''); /* Quote character */
char *escarg = va_arg(ap,char*);
isnull = escarg==0;
@@ -723,7 +725,7 @@ void sqlite3StrAccumAppend(StrAccum *p, const char *z, int N){
return;
}
if( N<0 ){
- N = strlen(z);
+ N = sqlite3Strlen30(z);
}
if( N==0 || z==0 ){
return;
@@ -744,7 +746,7 @@ void sqlite3StrAccumAppend(StrAccum *p, const char *z, int N){
p->tooBig = 1;
return;
}else{
- p->nAlloc = szNew;
+ p->nAlloc = (int)szNew;
}
zNew = sqlite3DbMallocRaw(p->db, p->nAlloc );
if( zNew ){