1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# Parse string resources from Windows native resource file
# and pass them to the writestringentry function that
# is responsible for writing the resource id and string
# to a platform specific resource file.
# A script containing this function needs to be specified
# using the -f command line parameter before this script.
BEGIN {
inStringTable = 0;
inBeginEnd = 0;
arrayName = "nativeStringResourceArray_" name;
tableName = "nativeStringResourceTable_" name;
writeheader(arrayName, tableName);
}
{
if ($1 == "STRINGTABLE" && $2 == "DISCARDABLE")
{
inStringTable = 1;
}
else if ($1 == "BEGIN")
{
inBeginEnd = inStringTable;
}
else if (inBeginEnd && $1 == "END")
{
inBeginEnd = 0;
inStringTable = 0;
}
else if (inBeginEnd && $1 != "")
{
# combine all items until the first string and remove them
# from the line
i = 1
expression = ""
# string starts with either a quote or L followed by a quote
while (substr($i, 1, 1) != "\"" && substr($i, 1, 2) != "L\"")
{
# some of the resource IDs contain cast to HRESULT
gsub(/\(HRESULT\)/, "", $i);
# some of the resource IDs have trailing L
gsub(/L/, "", $i);
expression = expression $i;
$i="";
i++;
}
# evaluate the resource ID expression
cmd = "echo $(("expression"))";
cmd | getline var;
close(cmd);
# in case shell returned the result as a string, ensure the var has numeric type
var = var + 0;
# remove the L prefix from strings
gsub(/L"/, "\"", $0);
# join strings "..." "..." into one
gsub(/" +"/, "", $0);
# write the resource entry to the target file
writestringentry(var, $0);
}
}
END {
writefooter(arrayName, tableName);
}
|