Fix bug with tab handling.

Commit 5804a9a introduced a bug where having the foldtabs option disabled (normal) prevented optimizations of functions. Fix it for good (hopefully). While on it, rename the nofoldtabs option to warntabs, making it default, and use it to disable a warning when there are tabs in a string.
This commit is contained in:
Sei Lisa 2016-05-07 03:18:50 +02:00
parent 95bd3209be
commit b7e6e6f7b1
4 changed files with 23 additions and 18 deletions

View file

@ -945,14 +945,14 @@ class foldconst(object):
else:
value = fn(*tuple(arg['value'] for arg in child))
if not self.foldtabs:
if not self.nofoldtabs:
generatesTabs = (
isinstance(value, unicode) and '\t' in value
or type(value) == list and any(isinstance(x, unicode) and '\t' in x for x in value)
)
if generatesTabs:
warning("Can't optimize call to %s because it would generate a tab character (you can force the optimization with the foldtabs option, or disable this warning with the nofoldtabs option)." % node['name'])
return
generatesTabs = (
isinstance(value, unicode) and '\t' in value
or type(value) == list and any(isinstance(x, unicode) and '\t' in x for x in value)
)
if generatesTabs:
if self.warntabs:
warning("Can't optimize call to %s because it would generate a tab character (you can force the optimization with the 'foldtabs' option, or disable this warning by disabling the 'warntabs' option)." % node['name'])
return
parent[index] = {'nt':'CONST', 't':node['t'], 'value':value}
except lslfuncs.ELSLCantCompute:
# Don't transform the tree if function is not computable