SQLite

Check-in [a715e70012]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Allow floating point literals to being or end with a decimal point. Ticket #1371. (CVS 2616)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a715e7001247e84e0982335570593f0802774635
User & Date: drh 2005-08-23 11:31:26.000
Context
2005-08-24
03:52
After calling realloc() on an array to resize it, be sure not to use pointers into the old array. Ticket #1376. (CVS 2617) (check-in: 9f9a257123 user: drh tags: trunk)
2005-08-23
11:31
Allow floating point literals to being or end with a decimal point. Ticket #1371. (CVS 2616) (check-in: a715e70012 user: drh tags: trunk)
11:17
Handle empty blob constants correctly. Ticket #1373. (CVS 2615) (check-in: 5cada745ac user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/tokenize.c.
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
*************************************************************************
** An tokenizer for SQL
**
** This file contains C code that splits an SQL input string up into
** individual tokens and sends those tokens one-by-one over to the
** parser for analysis.
**
** $Id: tokenize.c,v 1.106 2005/08/14 17:53:21 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
#include <ctype.h>
#include <stdlib.h>

/*







|







11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
*************************************************************************
** An tokenizer for SQL
**
** This file contains C code that splits an SQL input string up into
** individual tokens and sends those tokens one-by-one over to the
** parser for analysis.
**
** $Id: tokenize.c,v 1.107 2005/08/23 11:31:26 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
#include <ctype.h>
#include <stdlib.h>

/*
197
198
199
200
201
202
203




204
205



206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
        }
      }
      if( c ) i++;
      *tokenType = TK_STRING;
      return i;
    }
    case '.': {




      *tokenType = TK_DOT;
      return 1;



    }
    case '0': case '1': case '2': case '3': case '4':
    case '5': case '6': case '7': case '8': case '9': {
      *tokenType = TK_INTEGER;
      for(i=1; isdigit(z[i]); i++){}
#ifndef SQLITE_OMIT_FLOATING_POINT
      if( z[i]=='.' && isdigit(z[i+1]) ){
        i += 2;
        while( isdigit(z[i]) ){ i++; }
        *tokenType = TK_FLOAT;
      }
      if( (z[i]=='e' || z[i]=='E') &&
           ( isdigit(z[i+1]) 
            || ((z[i+1]=='+' || z[i+1]=='-') && isdigit(z[i+2]))
           )







>
>
>
>
|
|
>
>
>




|

|
|







197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
        }
      }
      if( c ) i++;
      *tokenType = TK_STRING;
      return i;
    }
    case '.': {
#ifndef SQLITE_OMIT_FLOATING_POINT
      if( !isdigit(z[1]) )
#endif
      {
        *tokenType = TK_DOT;
        return 1;
      }
      /* If the next character is a digit, this is a floating point
      ** number that begins with ".".  Fall thru into the next case */
    }
    case '0': case '1': case '2': case '3': case '4':
    case '5': case '6': case '7': case '8': case '9': {
      *tokenType = TK_INTEGER;
      for(i=0; isdigit(z[i]); i++){}
#ifndef SQLITE_OMIT_FLOATING_POINT
      if( z[i]=='.' ){
        i++;
        while( isdigit(z[i]) ){ i++; }
        *tokenType = TK_FLOAT;
      }
      if( (z[i]=='e' || z[i]=='E') &&
           ( isdigit(z[i+1]) 
            || ((z[i+1]=='+' || z[i+1]=='-') && isdigit(z[i+2]))
           )
Changes to test/misc5.test.
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# This file implements tests for miscellanous features that were
# left out of other test files.
#
# $Id: misc5.test,v 1.4 2005/08/21 16:54:25 drh Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# Build records using the MakeRecord opcode such that the size of the 
# header is at the transition point in the size of a varint.
#







|







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#
#***********************************************************************
# This file implements regression tests for SQLite library.
#
# This file implements tests for miscellanous features that were
# left out of other test files.
#
# $Id: misc5.test,v 1.5 2005/08/23 11:31:26 drh Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# Build records using the MakeRecord opcode such that the size of the 
# header is at the transition point in the size of a varint.
#
483
484
485
486
487
488
489














490
491
492
  close $fd
  sqlite3 db test.db
  catchsql {
    CREATE TABLE t1(a,b,c);
  }
} {1 {file is encrypted or is not a database}}

















finish_test







>
>
>
>
>
>
>
>
>
>
>
>
>
>



483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
  close $fd
  sqlite3 db test.db
  catchsql {
    CREATE TABLE t1(a,b,c);
  }
} {1 {file is encrypted or is not a database}}

# Ticket #1371.  Allow floating point numbers of the form .N  or N.
#
do_test misc5-5.1 {
  execsql {SELECT .1 }
} 0.1
do_test misc5-5.2 {
  execsql {SELECT 2. }
} 2.0
do_test misc5-5.3 {
  execsql {SELECT 3.e0 }
} 3.0
do_test misc5-5.4 {
  execsql {SELECT .4e+1}
} 4.0


finish_test