Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
f9042ec9
Commit
f9042ec9
authored
Aug 30, 2006
by
Mike McCormack
Committed by
Alexandre Julliard
Sep 07, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
msi: Use a binary search to find sql keywords.
parent
a8ae03f2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
8 deletions
+23
-8
tokenize.c
dlls/msi/tokenize.c
+23
-8
No files found.
dlls/msi/tokenize.c
View file @
f9042ec9
...
...
@@ -39,6 +39,8 @@ struct Keyword {
int
tokenType
;
/* The token value for this keyword */
};
#define MAX_TOKEN_LEN 11
static
const
WCHAR
ABORT_W
[]
=
{
'A'
,
'B'
,
'O'
,
'R'
,
'T'
,
0
};
static
const
WCHAR
AFTER_W
[]
=
{
'A'
,
'F'
,
'T'
,
'E'
,
'R'
,
0
};
static
const
WCHAR
ALTER_W
[]
=
{
'A'
,
'L'
,
'T'
,
'E'
,
'R'
,
0
};
...
...
@@ -264,20 +266,33 @@ static const Keyword aKeywordTable[] = {
#define KEYWORD_COUNT ( sizeof aKeywordTable/sizeof (Keyword) )
/*
** Comparison function for binary search.
*/
static
int
compKeyword
(
const
void
*
m1
,
const
void
*
m2
){
const
Keyword
*
k1
=
m1
,
*
k2
=
m2
;
return
strcmpiW
(
k1
->
zName
,
k2
->
zName
);
}
/*
** 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.
*/
static
int
sqliteKeywordCode
(
const
WCHAR
*
z
,
int
n
){
UINT
i
;
WCHAR
str
[
MAX_TOKEN_LEN
+
1
];
Keyword
key
,
*
r
;
for
(
i
=
0
;
i
<
KEYWORD_COUNT
;
i
++
)
{
if
(
strncmpiW
(
z
,
aKeywordTable
[
i
].
zName
,
n
))
continue
;
if
(
lstrlenW
(
aKeywordTable
[
i
].
zName
)
==
n
)
return
aKeywordTable
[
i
].
tokenType
;
}
if
(
n
>
MAX_TOKEN_LEN
)
return
TK_ID
;
memcpy
(
str
,
z
,
n
*
sizeof
(
WCHAR
)
);
str
[
n
]
=
0
;
key
.
tokenType
=
0
;
key
.
zName
=
str
;
r
=
bsearch
(
&
key
,
aKeywordTable
,
KEYWORD_COUNT
,
sizeof
(
Keyword
),
compKeyword
);
if
(
r
)
return
r
->
tokenType
;
return
TK_ID
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment