mirror of
https://github.com/Sei-Lisa/LSL-PyOptimizer
synced 2025-07-01 15:48:21 +00:00
Someone's been misusing Python's re.match... O:)
This commit is contained in:
parent
893bcf177b
commit
ee091c63a6
2 changed files with 18 additions and 18 deletions
|
@ -381,7 +381,7 @@ def InternalTypecast(val, out, InList, f32):
|
|||
if out == Key: return Key(val)
|
||||
if out == float:
|
||||
# Clean up the string for Picky Python
|
||||
match = float_re.match(val)
|
||||
match = float_re.search(val)
|
||||
if match is None:
|
||||
return 0.0
|
||||
if match.group(1):
|
||||
|
@ -394,7 +394,7 @@ def InternalTypecast(val, out, InList, f32):
|
|||
ret = 0.0
|
||||
return ret
|
||||
if out == int:
|
||||
match = int_re.match(val)
|
||||
match = int_re.search(val)
|
||||
if match is None:
|
||||
return 0
|
||||
val = match.group(0)
|
||||
|
@ -412,7 +412,7 @@ def InternalTypecast(val, out, InList, f32):
|
|||
return Z
|
||||
val = val[1:]
|
||||
for _ in range(dim):
|
||||
match = vfloat_re.match(val)
|
||||
match = vfloat_re.search(val)
|
||||
if match is None:
|
||||
return Z
|
||||
if match.group(1):
|
||||
|
@ -752,7 +752,7 @@ def cond(x):
|
|||
if tx == Key:
|
||||
if x == NULL_KEY or len(x) != 36:
|
||||
return False
|
||||
return bool(key_re.match(x))
|
||||
return bool(key_re.search(x))
|
||||
if tx == Vector:
|
||||
return bool(compare(x, ZERO_VECTOR, Eq=False))
|
||||
if tx == Quaternion:
|
||||
|
@ -880,7 +880,7 @@ def llBase64ToInteger(s):
|
|||
assert isstring(s)
|
||||
if len(s) > 8:
|
||||
return 0
|
||||
s = b64_re.match(s).group()
|
||||
s = b64_re.search(s).group()
|
||||
i = len(s)
|
||||
s = b64decode(s + u'='*(-i & 3))
|
||||
if len(s) < 3:
|
||||
|
@ -892,7 +892,7 @@ def llBase64ToInteger(s):
|
|||
|
||||
def llBase64ToString(s):
|
||||
assert isstring(s)
|
||||
s = b64_re.match(s).group(0)
|
||||
s = b64_re.search(s).group(0)
|
||||
return InternalUTF8toString(b64decode(s + u'='*(-len(s)&3)))
|
||||
|
||||
def llCSV2List(s):
|
||||
|
@ -1688,9 +1688,9 @@ def llXorBase64(s, xor):
|
|||
if xor == u'':
|
||||
return s
|
||||
|
||||
s = b64_re.match(s).group(0)
|
||||
s = b64_re.search(s).group(0)
|
||||
L1 = len(s)
|
||||
xor = b64_re.match(xor).group(0)
|
||||
xor = b64_re.search(xor).group(0)
|
||||
L2 = len(xor)
|
||||
|
||||
if L2 == 0:
|
||||
|
@ -1770,9 +1770,9 @@ def llXorBase64StringsCorrect(s, xor):
|
|||
return s
|
||||
|
||||
|
||||
s = b64_re.match(s).group(0)
|
||||
s = b64_re.search(s).group(0)
|
||||
L1 = len(s)
|
||||
xor = b64_re.match(xor).group(0)
|
||||
xor = b64_re.search(xor).group(0)
|
||||
L2 = len(xor)
|
||||
|
||||
if L2 == 0:
|
||||
|
|
|
@ -2494,7 +2494,7 @@ list lazy_list_set(list L, integer i, list v)
|
|||
line = f.readline()
|
||||
if not line: break
|
||||
if line[-1] == '\n': line = line[:-1]
|
||||
match = parse_lin_re.match(line)
|
||||
match = parse_lin_re.search(line)
|
||||
if not match:
|
||||
warning('Syntax error in ' + builtins + ', line ' + line)
|
||||
continue
|
||||
|
@ -2514,12 +2514,12 @@ list lazy_list_set(list L, integer i, list v)
|
|||
arglist = arglist.split(',')
|
||||
bad = False
|
||||
for arg in arglist:
|
||||
argtyp = parse_arg_re.match(arg).group(1)
|
||||
argtyp = parse_arg_re.search(arg).group(1)
|
||||
if argtyp not in self.types:
|
||||
warning('Invalid type in ' + builtins + ', line ' + line + ': ' + argtyp)
|
||||
bad = True
|
||||
break
|
||||
args.append(parse_arg_re.match(arg).group(1))
|
||||
args.append(parse_arg_re.search(arg).group(1))
|
||||
if bad:
|
||||
continue
|
||||
name = match.group(2)
|
||||
|
@ -2555,7 +2555,7 @@ list lazy_list_set(list L, integer i, list v)
|
|||
value = lslfuncs.F32(float(value))
|
||||
elif typ == 'string':
|
||||
value = value.decode('utf8')
|
||||
if parse_str_re.match(value):
|
||||
if parse_str_re.search(value):
|
||||
esc = False
|
||||
tmp = value[1:-1]
|
||||
value = u''
|
||||
|
@ -2586,22 +2586,22 @@ list lazy_list_set(list L, integer i, list v)
|
|||
value = value[1:-1].split(',')
|
||||
if len(value) != (3 if typ == 'vector' else 4):
|
||||
raise ValueError
|
||||
num = parse_num_re.match(value[0])
|
||||
num = parse_num_re.search(value[0])
|
||||
if not num:
|
||||
raise ValueError
|
||||
value[0] = lslfuncs.F32(float(num.group(1)))
|
||||
num = parse_num_re.match(value[1])
|
||||
num = parse_num_re.search(value[1])
|
||||
if not num:
|
||||
raise ValueError
|
||||
value[1] = lslfuncs.F32(float(num.group(1)))
|
||||
num = parse_num_re.match(value[2])
|
||||
num = parse_num_re.search(value[2])
|
||||
if not num:
|
||||
raise ValueError
|
||||
value[2] = lslfuncs.F32(float(num.group(1)))
|
||||
if typ == 'vector':
|
||||
value = Vector(value)
|
||||
else:
|
||||
num = parse_num_re.match(value[3])
|
||||
num = parse_num_re.search(value[3])
|
||||
if not num:
|
||||
raise ValueError
|
||||
value[3] = lslfuncs.F32(float(num.group(1)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue