Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Remove unused code and tighten existing code to make the library a little smaller. (CVS 1168) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
34a6b7416c6c9bcdf301f5e7b072a036 |
User & Date: | drh 2004-01-08 02:17:32.000 |
Context
2004-01-12
| ||
00:21 | Make sure the in-memory database can handle malloc failures. (CVS 1169) (check-in: ba92af182c user: drh tags: trunk) | |
2004-01-08
| ||
02:17 | Remove unused code and tighten existing code to make the library a little smaller. (CVS 1168) (check-in: 34a6b7416c user: drh tags: trunk) | |
2004-01-07
| ||
20:37 | Rework the fix to ticket #461 so that we do not have to do redundant tests of WHERE clause terms looking for NULLs. See also check-in (1103). (CVS 1167) (check-in: 5fd581787e user: drh tags: trunk) | |
Changes
Changes to src/date.c.
︙ | ︙ | |||
12 13 14 15 16 17 18 | ** This file contains the C functions that implement date and time ** functions for SQLite. ** ** There is only one exported symbol in this file - the function ** sqliteRegisterDateTimeFunctions() found at the bottom of the file. ** All other code has file scope. ** | | | 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ** This file contains the C functions that implement date and time ** functions for SQLite. ** ** There is only one exported symbol in this file - the function ** sqliteRegisterDateTimeFunctions() found at the bottom of the file. ** All other code has file scope. ** ** $Id: date.c,v 1.8 2004/01/08 02:17:32 drh Exp $ ** ** NOTES: ** ** SQLite processes all times and dates as Julian Day numbers. The ** dates and times are stored as the number of days since noon ** in Greenwich on November 24, 4714 B.C. according to the Gregorian ** calendar system. |
︙ | ︙ | |||
217 218 219 220 221 222 223 | if( p->validJD ) return; if( p->validYMD ){ Y = p->Y; M = p->M; D = p->D; }else{ | | | 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 | if( p->validJD ) return; if( p->validYMD ){ Y = p->Y; M = p->M; D = p->D; }else{ Y = 2000; /* If no YMD specified, assume 2000-Jan-01 */ M = 1; D = 1; } if( M<=2 ){ Y--; M += 12; } |
︙ | ︙ | |||
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 | p->s -= s; p->h = s/3600; s -= p->h*3600; p->m = s/60; p->s += s - p->m*60; p->validHMS = 1; } /* ** Compute the difference (in days) between localtime and UTC (a.k.a. GMT) ** for the time value p where p is in UTC. */ static double localtimeOffset(DateTime *p){ DateTime x, y; time_t t; struct tm *pTm; | > > > > > > > > > > > > > > > > > < < > | 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 | p->s -= s; p->h = s/3600; s -= p->h*3600; p->m = s/60; p->s += s - p->m*60; p->validHMS = 1; } /* ** Compute both YMD and HMS */ static void computeYMD_HMS(DateTime *p){ computeYMD(p); computeHMS(p); } /* ** Clear the YMD and HMS and the TZ */ static void clearYMD_HMS_TZ(DateTime *p){ p->validYMD = 0; p->validHMS = 0; p->validTZ = 0; } /* ** Compute the difference (in days) between localtime and UTC (a.k.a. GMT) ** for the time value p where p is in UTC. */ static double localtimeOffset(DateTime *p){ DateTime x, y; time_t t; struct tm *pTm; x = *p; computeYMD_HMS(&x); if( x.Y<1971 || x.Y>=2038 ){ x.Y = 2000; x.M = 1; x.D = 1; x.h = 0; x.m = 0; x.s = 0.0; |
︙ | ︙ | |||
404 405 406 407 408 409 410 | y.s = pTm->tm_sec; sqliteOsLeaveMutex(); y.validYMD = 1; y.validHMS = 1; y.validJD = 0; y.validTZ = 0; computeJD(&y); | < < < | 420 421 422 423 424 425 426 427 428 429 430 431 432 433 | y.s = pTm->tm_sec; sqliteOsLeaveMutex(); y.validYMD = 1; y.validHMS = 1; y.validJD = 0; y.validTZ = 0; computeJD(&y); return y.rJD - x.rJD; } /* ** Process a modifier to a date-time stamp. The modifiers are ** as follows: ** |
︙ | ︙ | |||
450 451 452 453 454 455 456 | ** ** Assuming the current time value is UTC (a.k.a. GMT), shift it to ** show local time. */ if( strcmp(z, "localtime")==0 ){ computeJD(p); p->rJD += localtimeOffset(p); | | < < | < < | < < < < < | < | < | 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 | ** ** Assuming the current time value is UTC (a.k.a. GMT), shift it to ** show local time. */ if( strcmp(z, "localtime")==0 ){ computeJD(p); p->rJD += localtimeOffset(p); clearYMD_HMS_TZ(p); rc = 0; } break; } case 'u': { /* ** unixepoch ** ** Treat the current value of p->rJD as the number of ** seconds since 1970. Convert to a real julian day number. */ if( strcmp(z, "unixepoch")==0 && p->validJD ){ p->rJD = p->rJD/86400.0 + 2440587.5; clearYMD_HMS_TZ(p); rc = 0; }else if( strcmp(z, "utc")==0 ){ double c1; computeJD(p); c1 = localtimeOffset(p); p->rJD -= c1; clearYMD_HMS_TZ(p); p->rJD += c1 - localtimeOffset(p); rc = 0; } break; } case 'w': { /* ** weekday N ** ** Move the date to the same time on the next occurrance of ** weekday N where 0==Sunday, 1==Monday, and so forth. If the ** 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 ){ int Z; computeYMD_HMS(p); p->validTZ = 0; p->validJD = 0; computeJD(p); Z = p->rJD + 1.5; Z %= 7; if( Z>n ) Z -= 7; p->rJD += n - Z; clearYMD_HMS_TZ(p); rc = 0; } break; } case 's': { /* ** start of TTTTT |
︙ | ︙ | |||
565 566 567 568 569 570 571 | strcpy(z, zMod); if( z[n-1]=='s' ){ z[n-1] = 0; n--; } computeJD(p); rc = 0; if( n==3 && strcmp(z,"day")==0 ){ p->rJD += r; }else if( n==4 && strcmp(z,"hour")==0 ){ | < < < | < | < | < < | 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 | strcpy(z, zMod); if( z[n-1]=='s' ){ z[n-1] = 0; n--; } computeJD(p); rc = 0; if( n==3 && strcmp(z,"day")==0 ){ p->rJD += r; }else if( n==4 && strcmp(z,"hour")==0 ){ p->rJD += r/24.0; }else if( n==6 && strcmp(z,"minute")==0 ){ p->rJD += r/(24.0*60.0); }else if( n==6 && strcmp(z,"second")==0 ){ p->rJD += r/(24.0*60.0*60.0); }else if( n==5 && strcmp(z,"month")==0 ){ int x, y; computeYMD_HMS(p); p->M += 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; if( y!=r ){ p->rJD += (r - y)*30.0; } }else if( n==4 && strcmp(z,"year")==0 ){ computeYMD_HMS(p); p->Y += r; p->validJD = 0; computeJD(p); }else{ rc = 1; } clearYMD_HMS_TZ(p); break; } default: { break; } } return rc; |
︙ | ︙ | |||
652 653 654 655 656 657 658 | ** ** Return YYYY-MM-DD HH:MM:SS */ static void datetimeFunc(sqlite_func *context, int argc, const char **argv){ DateTime x; if( isDate(argc, argv, &x)==0 ){ char zBuf[100]; | | < | 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 | ** ** Return YYYY-MM-DD HH:MM:SS */ static void datetimeFunc(sqlite_func *context, int argc, const char **argv){ DateTime x; if( isDate(argc, argv, &x)==0 ){ char zBuf[100]; computeYMD_HMS(&x); sprintf(zBuf, "%04d-%02d-%02d %02d:%02d:%02d",x.Y, x.M, x.D, x.h, x.m, (int)(x.s)); sqlite_set_result_string(context, zBuf, -1); } } /* |
︙ | ︙ | |||
756 757 758 759 760 761 762 | if( n<sizeof(zBuf) ){ z = zBuf; }else{ z = sqliteMalloc( n ); if( z==0 ) return; } computeJD(&x); | | < | 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 | if( n<sizeof(zBuf) ){ z = zBuf; }else{ z = sqliteMalloc( n ); if( z==0 ) return; } computeJD(&x); computeYMD_HMS(&x); for(i=j=0; zFmt[i]; i++){ if( zFmt[i]!='%' ){ z[j++] = zFmt[i]; }else{ i++; switch( zFmt[i] ){ case 'd': sprintf(&z[j],"%02d",x.D); j+=2; break; |
︙ | ︙ |
Changes to src/hash.c.
︙ | ︙ | |||
8 9 10 11 12 13 14 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This is the implementation of generic hash-tables ** used in SQLite. ** | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This is the implementation of generic hash-tables ** used in SQLite. ** ** $Id: hash.c,v 1.11 2004/01/08 02:17:33 drh Exp $ */ #include "sqliteInt.h" #include <assert.h> /* Turn bulk memory into a hash table object by initializing the ** fields of the Hash structure. ** |
︙ | ︙ | |||
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | static int intHash(const void *pKey, int nKey){ return nKey ^ (nKey<<8) ^ (nKey>>8); } static int intCompare(const void *pKey1, int n1, const void *pKey2, int n2){ return n2 - n1; } /* ** Hash and comparison functions when the mode is SQLITE_HASH_POINTER */ static int ptrHash(const void *pKey, int nKey){ uptr x = Addr(pKey); return x ^ (x<<8) ^ (x>>8); } static int ptrCompare(const void *pKey1, int n1, const void *pKey2, int n2){ if( pKey1==pKey2 ) return 0; if( pKey1<pKey2 ) return -1; return 1; } /* ** Hash and comparison functions when the mode is SQLITE_HASH_STRING */ static int strHash(const void *pKey, int nKey){ return sqliteHashNoCase((const char*)pKey, nKey); } | > > | 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | static int intHash(const void *pKey, int nKey){ return nKey ^ (nKey<<8) ^ (nKey>>8); } static int intCompare(const void *pKey1, int n1, const void *pKey2, int n2){ return n2 - n1; } #if 0 /* NOT USED */ /* ** Hash and comparison functions when the mode is SQLITE_HASH_POINTER */ static int ptrHash(const void *pKey, int nKey){ uptr x = Addr(pKey); return x ^ (x<<8) ^ (x>>8); } static int ptrCompare(const void *pKey1, int n1, const void *pKey2, int n2){ if( pKey1==pKey2 ) return 0; if( pKey1<pKey2 ) return -1; return 1; } #endif /* ** Hash and comparison functions when the mode is SQLITE_HASH_STRING */ static int strHash(const void *pKey, int nKey){ return sqliteHashNoCase((const char*)pKey, nKey); } |
︙ | ︙ | |||
126 127 128 129 130 131 132 | ** is a pointer to another function. Specifically, the return value ** of hashFunction() is a pointer to a function that takes two parameters ** with types "const void*" and "int" and returns an "int". */ static int (*hashFunction(int keyClass))(const void*,int){ switch( keyClass ){ case SQLITE_HASH_INT: return &intHash; | | | | 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | ** is a pointer to another function. Specifically, the return value ** of hashFunction() is a pointer to a function that takes two parameters ** with types "const void*" and "int" and returns an "int". */ static int (*hashFunction(int keyClass))(const void*,int){ switch( keyClass ){ case SQLITE_HASH_INT: return &intHash; /* case SQLITE_HASH_POINTER: return &ptrHash; // NOT USED */ case SQLITE_HASH_STRING: return &strHash; case SQLITE_HASH_BINARY: return &binHash;; default: break; } return 0; } /* ** Return a pointer to the appropriate hash function given the key class. ** ** For help in interpreted the obscure C code in the function definition, ** see the header comment on the previous function. */ static int (*compareFunction(int keyClass))(const void*,int,const void*,int){ switch( keyClass ){ case SQLITE_HASH_INT: return &intCompare; /* case SQLITE_HASH_POINTER: return &ptrCompare; // NOT USED */ case SQLITE_HASH_STRING: return &strCompare; case SQLITE_HASH_BINARY: return &binCompare; default: break; } return 0; } |
︙ | ︙ |
Changes to src/hash.h.
︙ | ︙ | |||
8 9 10 11 12 13 14 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This is the header file for the generic hash-table implemenation ** used in SQLite. ** | | | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ** May you find forgiveness for yourself and forgive others. ** May you share freely, never taking more than you give. ** ************************************************************************* ** This is the header file for the generic hash-table implemenation ** used in SQLite. ** ** $Id: hash.h,v 1.6 2004/01/08 02:17:33 drh Exp $ */ #ifndef _SQLITE_HASH_H_ #define _SQLITE_HASH_H_ /* Forward declarations of structures. */ typedef struct Hash Hash; typedef struct HashElem HashElem; |
︙ | ︙ | |||
67 68 69 70 71 72 73 | ** SQLITE_HASH_BINARY pKey points to binary data nKey bytes long. ** memcmp() is used to compare keys. ** ** A copy of the key is made for SQLITE_HASH_STRING and SQLITE_HASH_BINARY ** if the copyKey parameter to HashInit is 1. */ #define SQLITE_HASH_INT 1 | | | 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | ** SQLITE_HASH_BINARY pKey points to binary data nKey bytes long. ** memcmp() is used to compare keys. ** ** A copy of the key is made for SQLITE_HASH_STRING and SQLITE_HASH_BINARY ** if the copyKey parameter to HashInit is 1. */ #define SQLITE_HASH_INT 1 /* #define SQLITE_HASH_POINTER 2 // NOT USED */ #define SQLITE_HASH_STRING 3 #define SQLITE_HASH_BINARY 4 /* ** Access routines. To delete, insert a NULL pointer. */ void sqliteHashInit(Hash*, int keytype, int copyKey); |
︙ | ︙ |
Changes to src/tokenize.c.
︙ | ︙ | |||
11 12 13 14 15 16 17 | ************************************************************************* ** 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. ** | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < | | | | | | > | | > > > > < < < < < < < < | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | ************************************************************************* ** 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.67 2004/01/08 02:17:33 drh Exp $ */ #include "sqliteInt.h" #include "os.h" #include <ctype.h> #include <stdlib.h> /* ** All the keywords of the SQL language are stored as in a hash ** table composed of instances of the following structure. */ typedef struct Keyword Keyword; struct Keyword { char *zName; /* The keyword name */ u8 tokenType; /* Token value for this keyword */ u8 len; /* Length of this keyword */ u8 iNext; /* Index in aKeywordTable[] of next with same hash */ }; /* ** These are the keywords */ static Keyword aKeywordTable[] = { { "ABORT", TK_ABORT, }, { "AFTER", TK_AFTER, }, { "ALL", TK_ALL, }, { "AND", TK_AND, }, { "AS", TK_AS, }, { "ASC", TK_ASC, }, { "ATTACH", TK_ATTACH, }, { "BEFORE", TK_BEFORE, }, { "BEGIN", TK_BEGIN, }, { "BETWEEN", TK_BETWEEN, }, { "BY", TK_BY, }, { "CASCADE", TK_CASCADE, }, { "CASE", TK_CASE, }, { "CHECK", TK_CHECK, }, { "CLUSTER", TK_CLUSTER, }, { "COLLATE", TK_COLLATE, }, { "COMMIT", TK_COMMIT, }, { "CONFLICT", TK_CONFLICT, }, { "CONSTRAINT", TK_CONSTRAINT, }, { "COPY", TK_COPY, }, { "CREATE", TK_CREATE, }, { "CROSS", TK_JOIN_KW, }, { "DATABASE", TK_DATABASE, }, { "DEFAULT", TK_DEFAULT, }, { "DEFERRED", TK_DEFERRED, }, { "DEFERRABLE", TK_DEFERRABLE, }, { "DELETE", TK_DELETE, }, { "DELIMITERS", TK_DELIMITERS, }, { "DESC", TK_DESC, }, { "DETACH", TK_DETACH, }, { "DISTINCT", TK_DISTINCT, }, { "DROP", TK_DROP, }, { "END", TK_END, }, { "EACH", TK_EACH, }, { "ELSE", TK_ELSE, }, { "EXCEPT", TK_EXCEPT, }, { "EXPLAIN", TK_EXPLAIN, }, { "FAIL", TK_FAIL, }, { "FOR", TK_FOR, }, { "FOREIGN", TK_FOREIGN, }, { "FROM", TK_FROM, }, { "FULL", TK_JOIN_KW, }, { "GLOB", TK_GLOB, }, { "GROUP", TK_GROUP, }, { "HAVING", TK_HAVING, }, { "IGNORE", TK_IGNORE, }, { "IMMEDIATE", TK_IMMEDIATE, }, { "IN", TK_IN, }, { "INDEX", TK_INDEX, }, { "INITIALLY", TK_INITIALLY, }, { "INNER", TK_JOIN_KW, }, { "INSERT", TK_INSERT, }, { "INSTEAD", TK_INSTEAD, }, { "INTERSECT", TK_INTERSECT, }, { "INTO", TK_INTO, }, { "IS", TK_IS, }, { "ISNULL", TK_ISNULL, }, { "JOIN", TK_JOIN, }, { "KEY", TK_KEY, }, { "LEFT", TK_JOIN_KW, }, { "LIKE", TK_LIKE, }, { "LIMIT", TK_LIMIT, }, { "MATCH", TK_MATCH, }, { "NATURAL", TK_JOIN_KW, }, { "NOT", TK_NOT, }, { "NOTNULL", TK_NOTNULL, }, { "NULL", TK_NULL, }, { "OF", TK_OF, }, { "OFFSET", TK_OFFSET, }, { "ON", TK_ON, }, { "OR", TK_OR, }, { "ORDER", TK_ORDER, }, { "OUTER", TK_JOIN_KW, }, { "PRAGMA", TK_PRAGMA, }, { "PRIMARY", TK_PRIMARY, }, { "RAISE", TK_RAISE, }, { "REFERENCES", TK_REFERENCES, }, { "REPLACE", TK_REPLACE, }, { "RESTRICT", TK_RESTRICT, }, { "RIGHT", TK_JOIN_KW, }, { "ROLLBACK", TK_ROLLBACK, }, { "ROW", TK_ROW, }, { "SELECT", TK_SELECT, }, { "SET", TK_SET, }, { "STATEMENT", TK_STATEMENT, }, { "TABLE", TK_TABLE, }, { "TEMP", TK_TEMP, }, { "TEMPORARY", TK_TEMP, }, { "THEN", TK_THEN, }, { "TRANSACTION", TK_TRANSACTION, }, { "TRIGGER", TK_TRIGGER, }, { "UNION", TK_UNION, }, { "UNIQUE", TK_UNIQUE, }, { "UPDATE", TK_UPDATE, }, { "USING", TK_USING, }, { "VACUUM", TK_VACUUM, }, { "VALUES", TK_VALUES, }, { "VIEW", TK_VIEW, }, { "WHEN", TK_WHEN, }, { "WHERE", TK_WHERE, }, }; /* ** This is the hash table */ #define KEY_HASH_SIZE 101 static u8 aiHashTable[KEY_HASH_SIZE]; /* ** This function looks up an identifier to determine if it is a ** keyword. If it is a keyword, the token code of that keyword is ** returned. If the input is not a keyword, TK_ID is returned. */ int sqliteKeywordCode(const char *z, int n){ int h, i; Keyword *p; static char needInit = 1; if( needInit ){ /* Initialize the keyword hash table */ sqliteOsEnterMutex(); if( needInit ){ int nk; nk = sizeof(aKeywordTable)/sizeof(aKeywordTable[0]); for(i=0; i<nk; i++){ aKeywordTable[i].len = strlen(aKeywordTable[i].zName); h = sqliteHashNoCase(aKeywordTable[i].zName, aKeywordTable[i].len); h %= KEY_HASH_SIZE; aKeywordTable[i].iNext = aiHashTable[h]; aiHashTable[h] = i+1; } needInit = 0; } sqliteOsLeaveMutex(); } h = sqliteHashNoCase(z, n) % KEY_HASH_SIZE; for(i=aiHashTable[h]; i; i=p->iNext){ p = &aKeywordTable[i-1]; if( p->len==n && sqliteStrNICmp(p->zName, z, n)==0 ){ return p->tokenType; } } return TK_ID; } /* ** If X is a character that can be used in an identifier and ** X&0x80==0 then isIdChar[X] will be 1. If X&0x80==0x80 then ** X is always an identifier character. (Hence all UTF-8 ** characters can be part of an identifier). isIdChar[X] will ** be 0 for every character in the lower 128 ASCII characters ** that cannot be used as part of an identifier. ** ** In this implementation, an identifier can be a string of ** alphabetic characters, digits, and "_" plus any character ** with the high-order bit set. The latter rule means that ** any sequence of UTF-8 characters or characters taken from ** an extended ISO8859 character set can form an identifier. */ static const char isIdChar[] = { /* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 1x */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 2x */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, /* 3x */ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 4x */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, /* 5x */ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 6x */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, /* 7x */ }; /* ** Return the length of the token that begins at z[0]. ** Store the token type in *tokenType before returning. */ |
︙ | ︙ | |||
376 377 378 379 380 381 382 | return i; } case '?': { *tokenType = TK_VARIABLE; return 1; } default: { | | | | 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 | return i; } case '?': { *tokenType = TK_VARIABLE; return 1; } default: { if( (*z&0x80)==0 && !isIdChar[*z] ){ break; } for(i=1; (z[i]&0x80)!=0 || isIdChar[z[i]]; i++){} *tokenType = sqliteKeywordCode((char*)z, i); return i; } } *tokenType = TK_ILLEGAL; return 1; } |
︙ | ︙ |