mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-07-09 02:16:46 +00:00
Fix SQL parsing
This commit is contained in:
@@ -717,7 +717,7 @@ namespace LibMSI.Internal
|
||||
/// </summary>
|
||||
public LibmsiView View { get; set; }
|
||||
|
||||
public LinkedList<object> Mem { get; set; }
|
||||
public LinkedList<object> Mem { get; set; } = new LinkedList<object>();
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -786,16 +786,16 @@ namespace LibMSI.Internal
|
||||
// to reallocate them elsewhere.
|
||||
|
||||
// Their size.
|
||||
int yystacksize = YYINITDEPTH;
|
||||
long yystacksize = YYINITDEPTH;
|
||||
|
||||
// The state stack: array, bottom, top.
|
||||
List<byte> yyssa = new List<byte>(YYINITDEPTH);
|
||||
byte[] yyssa = new byte[YYINITDEPTH];
|
||||
int yyss = 0; // yyssa[0]
|
||||
int yyssp = yyss; // yyssa[0]
|
||||
|
||||
// The semantic value stack: array, bottom, top.
|
||||
List<SQL_STYPE> yyvsa = new List<SQL_STYPE>(YYINITDEPTH);
|
||||
int yyvs = 0; // yyvsa[0]
|
||||
SQL_STYPE[] yyvsa = new SQL_STYPE[YYINITDEPTH];
|
||||
int yyvs = 0; // yyvsa[0]
|
||||
int yyvsp = 0; // yyvsa[0]
|
||||
|
||||
int yyn;
|
||||
@@ -833,7 +833,7 @@ namespace LibMSI.Internal
|
||||
yysetstate:
|
||||
//YYDPRINTF ((stderr, "Entering state %d\n", yystate));
|
||||
//YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
|
||||
yyssp = (byte)yystate;
|
||||
yyssa[yyssp] = (byte)yystate;
|
||||
|
||||
if (yyss + yystacksize - 1 <= yyssp)
|
||||
{
|
||||
@@ -902,6 +902,7 @@ namespace LibMSI.Internal
|
||||
else
|
||||
{
|
||||
yytoken = YYTRANSLATE(yychar);
|
||||
//YY_SYMBOL_PRINT("Next token is", yytoken, &yylval, &yylloc);
|
||||
}
|
||||
|
||||
// If the proper action on seeing token YYTOKEN is to reduce or to
|
||||
@@ -1847,7 +1848,7 @@ namespace LibMSI.Internal
|
||||
len -= 2;
|
||||
}
|
||||
|
||||
str = strdata.Data.Substring(p, len) + '\0';
|
||||
str = strdata.Data.Substring(p, len);
|
||||
Mem.AddLast(str);
|
||||
return LibmsiResult.LIBMSI_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
** parser for analysis.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace LibMSI.Internal
|
||||
@@ -128,24 +129,7 @@ namespace LibMSI.Internal
|
||||
/// <summary>
|
||||
/// Comparison function for binary search.
|
||||
/// </summary>
|
||||
public static int CompareKeyword(string m1, Keyword m2)
|
||||
{
|
||||
int p = 0, q = 0;
|
||||
for (; p < m1.Length && m1[p] != '\0'; p++, q++)
|
||||
{
|
||||
if ((ushort)m1[p] > 127)
|
||||
return 1;
|
||||
|
||||
char c = m1[p];
|
||||
if (c >= 'a' && c <= 'z')
|
||||
c ^= (char)('A' ^ 'a');
|
||||
|
||||
if (c != m2.Name[q])
|
||||
return (int)c - (int)m2.Name[q];
|
||||
}
|
||||
|
||||
return (int)m1[p] - (int)m2.Name[q];
|
||||
}
|
||||
public static int CompareKeyword(string m1, Keyword m2) => string.Compare(m1, m2.Name, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
/// <summary>
|
||||
/// This function looks up an identifier to determine if it is a
|
||||
@@ -157,7 +141,7 @@ namespace LibMSI.Internal
|
||||
if (n > MAX_TOKEN_LEN)
|
||||
return sql_tokentype.TK_ID;
|
||||
|
||||
string str = z.Substring(n) + '\0';
|
||||
string str = z.Substring(0, n);
|
||||
Keyword r = KeywordTable.FirstOrDefault(k => CompareKeyword(str, k) == 0);
|
||||
if (r != default)
|
||||
return r.TokenType;
|
||||
|
||||
Reference in New Issue
Block a user