mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-20 08:53:51 +00:00
GUI: Add too long string literal warning code to theme generation tool.
This has the same effect as clang's -Woverlength-strings warning of string literals longer than C++ compilers are specified to work with.
This commit is contained in:
parent
0c8f8898ff
commit
49ea7cd1fd
@ -37,6 +37,7 @@ def parseSTX(theme_file, def_file):
|
|||||||
comm = re.compile("<!--(.*?)-->", re.DOTALL)
|
comm = re.compile("<!--(.*?)-->", re.DOTALL)
|
||||||
head = re.compile("<\?(.*?)\?>")
|
head = re.compile("<\?(.*?)\?>")
|
||||||
|
|
||||||
|
strlitcount = 0
|
||||||
output = ""
|
output = ""
|
||||||
for line in theme_file:
|
for line in theme_file:
|
||||||
output += line.rstrip("\r\n\t ").lstrip() + " \n"
|
output += line.rstrip("\r\n\t ").lstrip() + " \n"
|
||||||
@ -48,7 +49,9 @@ def parseSTX(theme_file, def_file):
|
|||||||
|
|
||||||
for line in output.splitlines():
|
for line in output.splitlines():
|
||||||
if line and not line.isspace():
|
if line and not line.isspace():
|
||||||
|
strlitcount += len(line)
|
||||||
def_file.write("\"" + line + "\"\n")
|
def_file.write("\"" + line + "\"\n")
|
||||||
|
return strlitcount
|
||||||
|
|
||||||
def buildDefTheme(themeName):
|
def buildDefTheme(themeName):
|
||||||
def_file = open("default.inc", "w")
|
def_file = open("default.inc", "w")
|
||||||
@ -57,16 +60,23 @@ def buildDefTheme(themeName):
|
|||||||
print ("Cannot open default theme dir.")
|
print ("Cannot open default theme dir.")
|
||||||
|
|
||||||
def_file.write(""" "<?xml version = '1.0'?>"\n""")
|
def_file.write(""" "<?xml version = '1.0'?>"\n""")
|
||||||
|
strlitcount = 24
|
||||||
|
|
||||||
for filename in os.listdir(themeName):
|
for filename in os.listdir(themeName):
|
||||||
filename = os.path.join(themeName, filename)
|
filename = os.path.join(themeName, filename)
|
||||||
if os.path.isfile(filename) and filename.endswith(".stx"):
|
if os.path.isfile(filename) and filename.endswith(".stx"):
|
||||||
theme_file = open(filename, "r")
|
theme_file = open(filename, "r")
|
||||||
parseSTX(theme_file, def_file)
|
strlitcount += parseSTX(theme_file, def_file)
|
||||||
theme_file.close()
|
theme_file.close()
|
||||||
|
|
||||||
def_file.close()
|
def_file.close()
|
||||||
|
|
||||||
|
if strlitcount > 65535:
|
||||||
|
print("WARNING: default.inc string literal is of length %d which exceeds the" % strlitcount)
|
||||||
|
print(" maximum length of 65536 that C++ compilers are required to support.")
|
||||||
|
print(" It is likely that bugs will occur dependent on compiler behaviour.")
|
||||||
|
print(" To avoid this, reduce the size of the theme.")
|
||||||
|
|
||||||
def printUsage():
|
def printUsage():
|
||||||
print ("===============================")
|
print ("===============================")
|
||||||
print ("ScummVM Theme Generation Script")
|
print ("ScummVM Theme Generation Script")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user