diff --git a/lslopt/lslfoldconst.py b/lslopt/lslfoldconst.py index 12da7ef..834ce1f 100644 --- a/lslopt/lslfoldconst.py +++ b/lslopt/lslfoldconst.py @@ -945,16 +945,13 @@ class foldconst(object): else: value = fn(*tuple(arg['value'] for arg in child)) if not self.foldtabs: - 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)." % node['name']) + 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 parent[index] = {'nt':'CONST', 't':node['t'], 'value':value} except lslfuncs.ELSLCantCompute: diff --git a/lslopt/lsloptimizer.py b/lslopt/lsloptimizer.py index 6fd2883..d47efe8 100644 --- a/lslopt/lsloptimizer.py +++ b/lslopt/lsloptimizer.py @@ -68,6 +68,7 @@ class optimizer(foldconst, renamer, deadcode): self.addstrings = 'addstrings' in options self.foldtabs = 'foldtabs' in options + self.nofoldtabs = 'nofoldtabs' in options self.shrinknames = 'shrinknames' in options diff --git a/main.py b/main.py index 076039f..c1ba024 100755 --- a/main.py +++ b/main.py @@ -277,6 +277,8 @@ Optimizer options (+ means active by default, - means inactive by default): expansion of functions that produce strings with tabs. The resulting source isn't guaranteed to be copy-paste-able to the viewer. + nofoldtabs - Suppress warning when a function can't be optimized + because it generates a string or list with a tab. skippreproc + Skip preprocessor directives in the source as if they were comments. Not useful unless the script is itself the output of a preprocessor like GNU cpp, which inserts