improve bf +[,.] handling

This commit is contained in:
Ryan Hitchman 2010-03-23 16:34:58 -06:00
parent 0cfd902b41
commit c478e4f2b4
1 changed files with 8 additions and 4 deletions

View File

@ -76,12 +76,16 @@ def bf(inp):
ip += 1
steps += 1
if steps > MAX_STEPS:
output += "Maximum number of steps exceeded"
if output == '':
output = '(no output)'
output += '[exceeded %d iterations]' % MAX_STEPS
break
output = '/'.join(output.splitlines())
stripped_output = re.sub(r'[\x00-\x1F]', '', output)
if output == '':
if stripped_output == '':
if output != '':
return 'no printable output'
return 'no output'
return unicode(output, 'iso-8859-1')[:430]
return stripped_output[:430].decode('utf8', 'ignore')