Index: test/num.test ================================================================== --- test/num.test +++ test/num.test @@ -198,10 +198,30 @@ 5.3 1. {sign:0 approx:0 e:0 m:1} 5.4 1e0 {sign:0 approx:0 e:0 m:1} } { do_test num-9.1.$tn { sqlite4_num_from_text $in } [list {*}$out] } + +#------------------------------------------------------------------------- +# Test ignore-whitespace and prefix-only flags +# +foreach {tn in len flags out} { + 0 {14 } -1 _ true + 1 {14 } -1 w false + 2 { 14 } -1 w false + 3 {14 } 2 _ false + 4 {14 } 3 _ true + 5 {14abc} -1 _ true + 6 {14abc} -1 p false + 7 {+Inf } -1 p false + 8 { 14 z} -1 w true + 9 { 14 z} -1 wp false +} { + do_test num-9.2.$tn { + sqlite4_num_isnan [sqlite4_num_from_text $in $len $flags] + } $out +} foreach {tn in out} { 0 50 50 1 -94 -94 2 {sign:0 approx:0 e:4 m:2} 20000 Index: test/test_num.c ================================================================== --- test/test_num.c +++ test/test_num.c @@ -89,23 +89,31 @@ int argc, /* Number of arguments */ char **argv /* Text of each argument */ ){ sqlite4_num A; int len; - if( argc!=2 && argc!=3 ){ + int flags; + if( argc<2 || argc>4 ){ Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0], - " STRING\" or \"", argv[0], " STRING INTEGER\"", 0); + " STRING\" or \"", argv[0], " STRING INTEGER\" or \"", + argv[0], " STRING INTEGER STRING\"", 0); return TCL_ERROR; } - if( argc==3 ){ + if( argc>=3 ){ if ( Tcl_GetInt(interp, argv[2], &len) ) return TCL_ERROR; }else{ len = -1; } - A = sqlite4_num_from_text(argv[1], len, 0, 0); + flags = 0; + if( argc>=4 ){ + if( strchr(argv[3], 'w') ) flags |= SQLITE4_IGNORE_WHITESPACE; + if( strchr(argv[3], 'p') ) flags |= SQLITE4_PREFIX_ONLY; + } + + A = sqlite4_num_from_text(argv[1], len, flags, 0); append_num_result(interp, A); return TCL_OK; } static int test_num_text_is_real(