Skip to content

Commit 19e41ab

Browse files
committed
Fix: string.match bracket pattern
1 parent 88be9c4 commit 19e41ab

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/MoonSharp.Interpreter.Tests/EndToEnd/StringLibTests.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,15 @@ public void String_Match_3()
272272
Utils.DynAssert(res, "書籍籍");
273273
}
274274

275+
[Test]
276+
public void String_Match_4()
277+
{
278+
string s = "㍝"; // U+335D
279+
string p = "[Aそ]"; // U+005B, U+0041, U+305D, U+005D
280+
281+
TestMatch(s, p, false);
282+
}
283+
275284
private void TestMatch(string s, string p, bool expected)
276285
{
277286
Script S = new Script(CoreModules.String);

src/MoonSharp.Interpreter/CoreLib/StringLib/KopiLua_StrLib.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,10 @@ private static int matchbracketclass(int c, CharPtr p, CharPtr ec)
203203
else if ((p[1] == '-') && (p + 2 < ec))
204204
{
205205
p += 2;
206-
if ((byte)((p[-2])) <= c && (c <= (byte)p[0]))
206+
if (p[-2] <= c && (c <= p[0]))
207207
return sig;
208208
}
209-
else if ((byte)(p[0]) == c) return sig;
209+
else if (p[0] == c) return sig;
210210
}
211211
return (sig == 0) ? 1 : 0;
212212
}

0 commit comments

Comments
 (0)