3 # This script is used to generate built-in string tables for dos.library
4 # They use very own format which is impossible to generate with FlexCat.
5 # Sorry for my awful Python knowledge - Sonic
11 while line
.startswith(';'):
14 return line
.rstrip('\n')
16 f
= open(sys
.argv
[1], 'r')
23 if (id_line
== "") or (str_line
== ""):
29 tmp
= tmp
[1].split('(')
30 tmp
= tmp
[1].split('/')
31 numbers
.append(tmp
[0])
33 strings
.append(str_line
)
35 print "/* This file is automatically generated! Do not edit! */"
39 print " * Error codes index table."
40 print " * This table actually consists of pairs of values (begin, end)."
41 print " * One string in the table below corresponds to one error code"
42 print " * from the specified interval."
43 print " * The table is terminated by two zeros."
44 print " * This layout was recreated based on locale.library code brought from MorphOS."
46 print "const ULONG err_Numbers[] ="
51 while (n
< len(numbers
) - 1):
52 prev
= int(numbers
[n
])
54 if (int(numbers
[n
]) == prev
+ 1):
57 print " %s, %s," % (first
, last
)
65 print " * Strings follow each other."
66 print " * Every string is prefixed by length byte in BCPL manner. NULL terminator is counted too."
68 print "const char err_Strings[] ="
70 for str_line
in strings
:
71 print " %d," % (len(str_line
) + 1)