mirror of
https://github.com/OlafvdSpek/ctemplate.git
synced 2025-09-28 19:05:49 +08:00
Merge e2b72bfa4b
into 4b7e6c52dc
This commit is contained in:
commit
26c2d4c396
|
@ -244,6 +244,19 @@ class FSMGenerateC(FSMGenerateAbstract):
|
||||||
|
|
||||||
return ''.join(out)
|
return ''.join(out)
|
||||||
|
|
||||||
|
def _Repr(self, c):
|
||||||
|
"""Simplified repr() to avoid problems in non-Unicode systems
|
||||||
|
if c == 9:
|
||||||
|
return "'\\t'"
|
||||||
|
elif c == 10:
|
||||||
|
return "'\\n'"
|
||||||
|
elif c == 13:
|
||||||
|
return "'\\r'"
|
||||||
|
elif c >= 0x20 and c < 0x7f:
|
||||||
|
return repr(chr(c))
|
||||||
|
else:
|
||||||
|
return "'\\x%02x'" % c
|
||||||
|
|
||||||
def _CreateTransitionTable(self):
|
def _CreateTransitionTable(self):
|
||||||
"""Print the state transition list.
|
"""Print the state transition list.
|
||||||
|
|
||||||
|
@ -282,7 +295,7 @@ class FSMGenerateC(FSMGenerateAbstract):
|
||||||
for state in self._config.states:
|
for state in self._config.states:
|
||||||
transition_row = []
|
transition_row = []
|
||||||
for c in range(0, 255):
|
for c in range(0, 255):
|
||||||
transition_row.append(' /* %06s */ %s' % (repr(chr(c)),
|
transition_row.append(' /* %06s */ %s' % (self._Repr(c),
|
||||||
state_table[state][c]))
|
state_table[state][c]))
|
||||||
|
|
||||||
out.append(self._CreateStructList('%stransition_row_%s' %
|
out.append(self._CreateStructList('%stransition_row_%s' %
|
||||||
|
|
Loading…
Reference in New Issue
Block a user