forked from Rust-related/RustPython
fix Opcode::CHARSET
This commit is contained in:
@@ -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'
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user