Cleaned up strtoarr.py

This commit is contained in:
A.M. Rowsell 2019-04-15 23:40:34 -04:00
commit 54ec66b345
Signed by: amr
GPG key ID: 0B6E2D8375CF79A9

View file

@ -3,7 +3,7 @@
# This Source Code Form is subject to the terms of the Mozilla Public # This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this # License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
#!/usr/bin/python3
## ##
# @file # @file
# @brief File to create string arrays # @brief File to create string arrays
@ -19,7 +19,7 @@
import sys import sys
import os import os
inString = str(sys.argv[1]); inString = str(sys.argv[1])
print("static const char {0}[{1}] = {{ ".format(sys.argv[2], len(inString)), end='') print("static const char {0}[{1}] = {{ ".format(sys.argv[2], len(inString)), end='')
for letter in inString[:-1]: for letter in inString[:-1]:
@ -27,6 +27,5 @@ for letter in inString[:-1]:
print("{0:#x}, ".format(p), end='') print("{0:#x}, ".format(p), end='')
p = ord(inString[-1]) p = ord(inString[-1])
print("{0:#x} ".format(int(p)), end='') print("{0:#x} ".format(int(p)) + "}; // " + inString)
print("}; // " + inString) print("static const uint8_t {0}_len = {1};".format(sys.argv[2], len(inString)))
print("static const uint8_t {0}_len = {1};".format(sys.argv[2], len(inString)))