fix Opcode::CHARSET

This commit is contained in:
Kangzhi Shi
2021-01-01 13:10:19 +02:00
parent 080b417f1f
commit 994ab4efb3
2 changed files with 6 additions and 4 deletions

View File

@@ -22,14 +22,15 @@ p = re.compile('ab')
idpattern = r'([_a-z][_a-z0-9]*)'
mo = re.search(idpattern, '7382 _boe0+2')
print(mo)
# TODO:
# assert mo.group(0) == '_boe0'
assert mo.group(0) == '_boe0'
# tes op range
assert re.compile('[a-z]').match('a').span() == (0, 1)
assert re.compile('[a-z]').fullmatch('z').span() == (0, 1)
# test op charset
assert re.compile('[_a-z0-9]*').match('_09az').group() == '_09az'
# test op repeat one
assert re.compile('a*').match('aaa').span() == (0, 3)
assert re.compile('abcd*').match('abcdddd').group() == 'abcdddd'

View File

@@ -741,7 +741,8 @@ fn charset(set: &[u32], c: char) -> bool {
}
SreOpcode::CHARSET => {
/* <CHARSET> <bitmap> */
if ch < 256 && (set[(ch / 32) as usize] & (1 << (32 - 1))) != 0 {
let set = &set[1..];
if ch < 256 && ((set[(ch >> 5) as usize] & (1u32 << (ch & 31))) != 0) {
return ok;
}
i += 8;