diff --git a/BurnOutSharp/External/libmsi/Internal/LibmsiSQLInput.cs b/BurnOutSharp/External/libmsi/Internal/LibmsiSQLInput.cs index 60e471d9..f032f5b3 100644 --- a/BurnOutSharp/External/libmsi/Internal/LibmsiSQLInput.cs +++ b/BurnOutSharp/External/libmsi/Internal/LibmsiSQLInput.cs @@ -717,7 +717,7 @@ namespace LibMSI.Internal /// public LibmsiView View { get; set; } - public LinkedList Mem { get; set; } + public LinkedList Mem { get; set; } = new LinkedList(); #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 yyssa = new List(YYINITDEPTH); + byte[] yyssa = new byte[YYINITDEPTH]; int yyss = 0; // yyssa[0] int yyssp = yyss; // yyssa[0] // The semantic value stack: array, bottom, top. - List yyvsa = new List(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; } diff --git a/BurnOutSharp/External/libmsi/Internal/Tokenize.cs b/BurnOutSharp/External/libmsi/Internal/Tokenize.cs index 50ef4756..6375c362 100644 --- a/BurnOutSharp/External/libmsi/Internal/Tokenize.cs +++ b/BurnOutSharp/External/libmsi/Internal/Tokenize.cs @@ -16,6 +16,7 @@ ** parser for analysis. */ +using System; using System.Linq; namespace LibMSI.Internal @@ -128,24 +129,7 @@ namespace LibMSI.Internal /// /// Comparison function for binary search. /// - 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); /// /// 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;