Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Avoid TABs in C files
  • Loading branch information
vstinner committed May 14, 2021
commit 100018d118bd2d30d9e83080b82413c5a4b9ac3c
16 changes: 9 additions & 7 deletions Programs/freeze_test_frozenmain.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
SRC_DIR = os.path.dirname(PROGRAM_DIR)


def writecode(outfp, mod, str):
outfp.write('unsigned char M_%s[] = {' % mod)
for i in range(0, len(str), 16):
outfp.write('\n\t')
for c in bytes(str[i:i+16]):
outfp.write('%d,' % c)
outfp.write('\n};\n')
def writecode(fp, mod, data):
print('unsigned char M_%s[] = {' % mod, file=fp)
indent = ' ' * 4
for i in range(0, len(data), 16):
print(indent, file=fp, end='')
for c in bytes(data[i:i+16]):
print('%d,' % c, file=fp, end='')
print('', file=fp)
print('};', file=fp)


def dump(fp, filename, name):
Expand Down
54 changes: 27 additions & 27 deletions Programs/test_frozenmain.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 9 additions & 11 deletions Tools/freeze/makefreeze.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,12 @@ def makefreeze(base, dict, debug=0, entry_point=None, fail_import=()):
# Write a C initializer for a module containing the frozen python code.
# The array is called M_<mod>.

def writecode(outfp, mod, str):
outfp.write('unsigned char M_%s[] = {' % mod)
for i in range(0, len(str), 16):
outfp.write('\n\t')
for c in bytes(str[i:i+16]):
outfp.write('%d,' % c)
outfp.write('\n};\n')

## def writecode(outfp, mod, str):
## outfp.write('unsigned char M_%s[%d] = "%s";\n' % (mod, len(str),
## '\\"'.join(map(lambda s: repr(s)[1:-1], str.split('"')))))
def writecode(fp, mod, data):
print('unsigned char M_%s[] = {' % mod, file=fp)
indent = ' ' * 4
for i in range(0, len(data), 16):
print(indent, file=fp, end='')
for c in bytes(data[i:i+16]):
print('%d,' % c, file=fp, end='')
print('', file=fp)
print('};', file=fp)