Ran code maid against this code.

This commit is contained in:
Lars Brubaker 2015-04-08 15:20:10 -07:00
parent 1445945d9c
commit 591528ee91
309 changed files with 139399 additions and 140129 deletions

View file

@ -1,74 +1,72 @@
using System.Diagnostics;
namespace Community.CsharpSqlite
{
using u8 = System.Byte;
using u8 = System.Byte;
public partial class Sqlite3
{
/*
** 2001 September 15
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
**
** May you do good and not evil.
** May you find forgiveness for yourself and forgive others.
** May you share freely, never taking more than you give.
**
*************************************************************************
** An tokenizer for SQL
**
** This file contains C code that implements the sqlite3_complete() API.
** This code used to be part of the tokenizer.c source file. But by
** separating it out, the code will be automatically omitted from
** static links that do not use it.
*************************************************************************
** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart
** C#-SQLite is an independent reimplementation of the SQLite software library
**
** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3
**
*************************************************************************
*/
//#include "sqliteInt.h"
public partial class Sqlite3
{
/*
** 2001 September 15
**
** The author disclaims copyright to this source code. In place of
** a legal notice, here is a blessing:
**
** May you do good and not evil.
** May you find forgiveness for yourself and forgive others.
** May you share freely, never taking more than you give.
**
*************************************************************************
** An tokenizer for SQL
**
** This file contains C code that implements the sqlite3_complete() API.
** This code used to be part of the tokenizer.c source file. But by
** separating it out, the code will be automatically omitted from
** static links that do not use it.
*************************************************************************
** Included in SQLite3 port to C#-SQLite; 2008 Noah B Hart
** C#-SQLite is an independent reimplementation of the SQLite software library
**
** SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3
**
*************************************************************************
*/
//#include "sqliteInt.h"
#if !SQLITE_OMIT_COMPLETE
/*
/*
** This is defined in tokenize.c. We just have to import the definition.
*/
#if !SQLITE_AMALGAMATION
#if SQLITE_ASCII
//#define IdChar(C) ((sqlite3CtypeMap[(unsigned char)C]&0x46)!=0)
static bool IdChar( u8 C )
{
return ( sqlite3CtypeMap[(char)C] & 0x46 ) != 0;
}
//#define IdChar(C) ((sqlite3CtypeMap[(unsigned char)C]&0x46)!=0)
private static bool IdChar(u8 C)
{
return (sqlite3CtypeMap[(char)C] & 0x46) != 0;
}
#endif
//#if SQLITE_EBCDIC
//extern const char sqlite3IsEbcdicIdChar[];
//#define IdChar(C) (((c=C)>=0x42 && sqlite3IsEbcdicIdChar[c-0x40]))
//#endif
//#if SQLITE_EBCDIC
//extern const char sqlite3IsEbcdicIdChar[];
//#define IdChar(C) (((c=C)>=0x42 && sqlite3IsEbcdicIdChar[c-0x40]))
//#endif
#endif // * SQLITE_AMALGAMATION */
/*
/*
** Token types used by the sqlite3_complete() routine. See the header
** comments on that procedure for additional information.
*/
const int tkSEMI = 0;
const int tkWS = 1;
const int tkOTHER = 2;
private const int tkSEMI = 0;
private const int tkWS = 1;
private const int tkOTHER = 2;
#if !SQLITE_OMIT_TRIGGER
const int tkEXPLAIN = 3;
const int tkCREATE = 4;
const int tkTEMP = 5;
const int tkTRIGGER = 6;
const int tkEND = 7;
private const int tkEXPLAIN = 3;
private const int tkCREATE = 4;
private const int tkTEMP = 5;
private const int tkTRIGGER = 6;
private const int tkEND = 7;
#endif
/*
/*
** Return TRUE if the given SQL string ends in a semicolon.
**
** Special handling is require for CREATE TRIGGER statements.
@ -86,7 +84,7 @@ namespace Community.CsharpSqlite
** (2) NORMAL We are in the middle of statement which ends with a single
** semicolon.
**
** (3) EXPLAIN The keyword EXPLAIN has been seen at the beginning of
** (3) EXPLAIN The keyword EXPLAIN has been seen at the beginning of
** a statement.
**
** (4) CREATE The keyword CREATE has been seen at the beginning of a
@ -122,16 +120,16 @@ namespace Community.CsharpSqlite
** is look for a semicolon that is not part of an string or comment.
*/
static public int sqlite3_complete( string zSql )
{
int state = 0; /* Current state, using numbers defined in header comment */
int token; /* Value of the next token */
static public int sqlite3_complete(string zSql)
{
int state = 0; /* Current state, using numbers defined in header comment */
int token; /* Value of the next token */
#if !SQLITE_OMIT_TRIGGER
/* A complex statement machine used to detect the end of a CREATE TRIGGER
/* A complex statement machine used to detect the end of a CREATE TRIGGER
** statement. This is the normal case.
*/
u8[][] trans = new u8[][] {
u8[][] trans = new u8[][] {
/* Token: */
/* State: ** SEMI WS OTHER EXPLAIN CREATE TEMP TRIGGER END */
/* 0 INVALID: */ new u8[]{ 1, 0, 2, 3, 4, 2, 2, 2, },
@ -156,179 +154,179 @@ namespace Community.CsharpSqlite
};
#endif // * SQLITE_OMIT_TRIGGER */
int zIdx = 0;
while ( zIdx < zSql.Length )
{
switch ( zSql[zIdx] )
{
case ';':
{ /* A semicolon */
token = tkSEMI;
break;
}
case ' ':
case '\r':
case '\t':
case '\n':
case '\f':
{ /* White space is ignored */
token = tkWS;
break;
}
case '/':
{ /* C-style comments */
if ( zSql[zIdx + 1] != '*' )
{
token = tkOTHER;
break;
}
zIdx += 2;
while ( zIdx < zSql.Length && zSql[zIdx] != '*' || zIdx < zSql.Length - 1 && zSql[zIdx + 1] != '/' )
{
zIdx++;
}
if ( zIdx == zSql.Length )
return 0;
zIdx++;
token = tkWS;
break;
}
case '-':
{ /* SQL-style comments from "--" to end of line */
if ( zSql[zIdx + 1] != '-' )
{
token = tkOTHER;
break;
}
while ( zIdx < zSql.Length && zSql[zIdx] != '\n' )
{
zIdx++;
}
if ( zIdx == zSql.Length )
return state == 1 ? 1 : 0;//if( *zSql==0 ) return state==1;
token = tkWS;
break;
}
case '[':
{ /* Microsoft-style identifiers in [...] */
zIdx++;
while ( zIdx < zSql.Length && zSql[zIdx] != ']' )
{
zIdx++;
}
if ( zIdx == zSql.Length )
return 0;
token = tkOTHER;
break;
}
case '`': /* Grave-accent quoted symbols used by MySQL */
case '"': /* single- and double-quoted strings */
case '\'':
{
int c = zSql[zIdx];
zIdx++;
while ( zIdx < zSql.Length && zSql[zIdx] != c )
{
zIdx++;
}
if ( zIdx == zSql.Length )
return 0;
token = tkOTHER;
break;
}
default:
{
//#if SQLITE_EBCDIC
// unsigned char c;
//#endif
if ( IdChar( (u8)zSql[zIdx] ) )
{
/* Keywords and unquoted identifiers */
int nId;
for ( nId = 1; ( zIdx + nId ) < zSql.Length && IdChar( (u8)zSql[zIdx + nId] ); nId++ )
{
}
int zIdx = 0;
while (zIdx < zSql.Length)
{
switch (zSql[zIdx])
{
case ';':
{ /* A semicolon */
token = tkSEMI;
break;
}
case ' ':
case '\r':
case '\t':
case '\n':
case '\f':
{ /* White space is ignored */
token = tkWS;
break;
}
case '/':
{ /* C-style comments */
if (zSql[zIdx + 1] != '*')
{
token = tkOTHER;
break;
}
zIdx += 2;
while (zIdx < zSql.Length && zSql[zIdx] != '*' || zIdx < zSql.Length - 1 && zSql[zIdx + 1] != '/')
{
zIdx++;
}
if (zIdx == zSql.Length)
return 0;
zIdx++;
token = tkWS;
break;
}
case '-':
{ /* SQL-style comments from "--" to end of line */
if (zSql[zIdx + 1] != '-')
{
token = tkOTHER;
break;
}
while (zIdx < zSql.Length && zSql[zIdx] != '\n')
{
zIdx++;
}
if (zIdx == zSql.Length)
return state == 1 ? 1 : 0;//if( *zSql==0 ) return state==1;
token = tkWS;
break;
}
case '[':
{ /* Microsoft-style identifiers in [...] */
zIdx++;
while (zIdx < zSql.Length && zSql[zIdx] != ']')
{
zIdx++;
}
if (zIdx == zSql.Length)
return 0;
token = tkOTHER;
break;
}
case '`': /* Grave-accent quoted symbols used by MySQL */
case '"': /* single- and double-quoted strings */
case '\'':
{
int c = zSql[zIdx];
zIdx++;
while (zIdx < zSql.Length && zSql[zIdx] != c)
{
zIdx++;
}
if (zIdx == zSql.Length)
return 0;
token = tkOTHER;
break;
}
default:
{
//#if SQLITE_EBCDIC
// unsigned char c;
//#endif
if (IdChar((u8)zSql[zIdx]))
{
/* Keywords and unquoted identifiers */
int nId;
for (nId = 1; (zIdx + nId) < zSql.Length && IdChar((u8)zSql[zIdx + nId]); nId++)
{
}
#if SQLITE_OMIT_TRIGGER
token = tkOTHER;
#else
switch ( zSql[zIdx] )
{
case 'c':
case 'C':
{
if ( nId == 6 && sqlite3StrNICmp( zSql, zIdx, "create", 6 ) == 0 )
{
token = tkCREATE;
}
else
{
token = tkOTHER;
}
break;
}
case 't':
case 'T':
{
if ( nId == 7 && sqlite3StrNICmp( zSql, zIdx, "trigger", 7 ) == 0 )
{
token = tkTRIGGER;
}
else if ( nId == 4 && sqlite3StrNICmp( zSql, zIdx, "temp", 4 ) == 0 )
{
token = tkTEMP;
}
else if ( nId == 9 && sqlite3StrNICmp( zSql, zIdx, "temporary", 9 ) == 0 )
{
token = tkTEMP;
}
else
{
token = tkOTHER;
}
break;
}
case 'e':
case 'E':
{
if ( nId == 3 && sqlite3StrNICmp( zSql, zIdx, "end", 3 ) == 0 )
{
token = tkEND;
}
else
switch (zSql[zIdx])
{
case 'c':
case 'C':
{
if (nId == 6 && sqlite3StrNICmp(zSql, zIdx, "create", 6) == 0)
{
token = tkCREATE;
}
else
{
token = tkOTHER;
}
break;
}
case 't':
case 'T':
{
if (nId == 7 && sqlite3StrNICmp(zSql, zIdx, "trigger", 7) == 0)
{
token = tkTRIGGER;
}
else if (nId == 4 && sqlite3StrNICmp(zSql, zIdx, "temp", 4) == 0)
{
token = tkTEMP;
}
else if (nId == 9 && sqlite3StrNICmp(zSql, zIdx, "temporary", 9) == 0)
{
token = tkTEMP;
}
else
{
token = tkOTHER;
}
break;
}
case 'e':
case 'E':
{
if (nId == 3 && sqlite3StrNICmp(zSql, zIdx, "end", 3) == 0)
{
token = tkEND;
}
else
#if !SQLITE_OMIT_EXPLAIN
if ( nId == 7 && sqlite3StrNICmp( zSql, zIdx, "explain", 7 ) == 0 )
{
token = tkEXPLAIN;
}
else
if (nId == 7 && sqlite3StrNICmp(zSql, zIdx, "explain", 7) == 0)
{
token = tkEXPLAIN;
}
else
#endif
{
token = tkOTHER;
}
break;
}
default:
{
token = tkOTHER;
break;
}
}
{
token = tkOTHER;
}
break;
}
default:
{
token = tkOTHER;
break;
}
}
#endif // * SQLITE_OMIT_TRIGGER */
zIdx += nId - 1;
}
else
{
/* Operators and special symbols */
token = tkOTHER;
}
break;
}
}
state = trans[state][token];
zIdx++;
}
return ( state == 1 ) ? 1 : 0;//return state==1;
}
zIdx += nId - 1;
}
else
{
/* Operators and special symbols */
token = tkOTHER;
}
break;
}
}
state = trans[state][token];
zIdx++;
}
return (state == 1) ? 1 : 0;//return state==1;
}
#if !SQLITE_OMIT_UTF16
/*
@ -358,5 +356,5 @@ return sqlite3ApiExit(0, rc);
}
#endif // * SQLITE_OMIT_UTF16 */
#endif // * SQLITE_OMIT_COMPLETE */
}
}
}
}