aboutsummaryrefslogtreecommitdiff
path: root/src/expr.c
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2010-01-12 17:04:07 +0000
committerdrh <drh@noemail.net>2010-01-12 17:04:07 +0000
commit13573c71d8097e81e38d5d1b9c8a5c58e5939851 (patch)
tree9abb36961ebd1a32bdc6b264484a7d053e9ac0fb /src/expr.c
parentab2f1f9560543d73d4ebbf1e1a8b896e83e3d324 (diff)
downloadsqlite-13573c71d8097e81e38d5d1b9c8a5c58e5939851.tar.gz
sqlite-13573c71d8097e81e38d5d1b9c8a5c58e5939851.zip
Use #ifdefs to disable unused code when SQLITE_OMIT_FLOATING_POINT is defined.
FossilOrigin-Name: 66bab8561926963a87f15ad559cba36545c9892c
Diffstat (limited to 'src/expr.c')
-rw-r--r--src/expr.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/expr.c b/src/expr.c
index 34655f97a..88c790a58 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -1882,6 +1882,7 @@ static char *dup8bytes(Vdbe *v, const char *in){
return out;
}
+#ifndef SQLITE_OMIT_FLOATING_POINT
/*
** Generate an instruction that will put the floating point
** value described by z[0..n-1] into register iMem.
@@ -1901,6 +1902,7 @@ static void codeReal(Vdbe *v, const char *z, int negateFlag, int iMem){
sqlite3VdbeAddOp4(v, OP_Real, 0, iMem, 0, zV, P4_REAL);
}
}
+#endif
/*
@@ -1911,7 +1913,8 @@ static void codeReal(Vdbe *v, const char *z, int negateFlag, int iMem){
** z[n] character is guaranteed to be something that does not look
** like the continuation of the number.
*/
-static void codeInteger(Vdbe *v, Expr *pExpr, int negFlag, int iMem){
+static void codeInteger(Parse *pParse, Expr *pExpr, int negFlag, int iMem){
+ Vdbe *v = pParse->pVdbe;
if( pExpr->flags & EP_IntValue ){
int i = pExpr->u.iValue;
if( negFlag ) i = -i;
@@ -1927,7 +1930,11 @@ static void codeInteger(Vdbe *v, Expr *pExpr, int negFlag, int iMem){
zV = dup8bytes(v, (char*)&value);
sqlite3VdbeAddOp4(v, OP_Int64, 0, iMem, 0, zV, P4_INT64);
}else{
+#ifdef SQLITE_OMIT_FLOATING_POINT
+ sqlite3ErrorMsg(pParse, "oversized integer: %s%s", negFlag ? "-" : "", z);
+#else
codeReal(v, z, negFlag, iMem);
+#endif
}
}
}
@@ -2314,14 +2321,16 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){
break;
}
case TK_INTEGER: {
- codeInteger(v, pExpr, 0, target);
+ codeInteger(pParse, pExpr, 0, target);
break;
}
+#ifndef SQLITE_OMIT_FLOATING_POINT
case TK_FLOAT: {
assert( !ExprHasProperty(pExpr, EP_IntValue) );
codeReal(v, pExpr->u.zToken, 0, target);
break;
}
+#endif
case TK_STRING: {
assert( !ExprHasProperty(pExpr, EP_IntValue) );
sqlite3VdbeAddOp4(v, OP_String8, 0, target, 0, pExpr->u.zToken, 0);
@@ -2491,11 +2500,13 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){
case TK_UMINUS: {
Expr *pLeft = pExpr->pLeft;
assert( pLeft );
- if( pLeft->op==TK_FLOAT ){
+ if( pLeft->op==TK_INTEGER ){
+ codeInteger(pParse, pLeft, 1, target);
+#ifndef SQLITE_OMIT_FLOATING_POINT
+ }else if( pLeft->op==TK_FLOAT ){
assert( !ExprHasProperty(pExpr, EP_IntValue) );
codeReal(v, pLeft->u.zToken, 1, target);
- }else if( pLeft->op==TK_INTEGER ){
- codeInteger(v, pLeft, 1, target);
+#endif
}else{
regFree1 = r1 = sqlite3GetTempReg(pParse);
sqlite3VdbeAddOp2(v, OP_Integer, 0, r1);