1 # Parse string resources from Windows native resource file
2 # and pass them to the writestringentry function that
3 # is responsible for writing the resource id and string
4 # to a platform specific resource file.
5 # A script containing this function needs to be specified
6 # using the -f command line parameter before this script.
11 arrayName = "nativeStringResourceArray_" name;
12 tableName = "nativeStringResourceTable_" name;
13 writeheader(arrayName, tableName);
16 if ($1 == "STRINGTABLE" && $2 == "DISCARDABLE")
20 else if ($1 == "BEGIN")
22 inBeginEnd = inStringTable;
24 else if (inBeginEnd && $1 == "END")
29 else if (inBeginEnd && $1 != "")
31 # combine all items until the first string and remove them
35 # string starts with either a quote or L followed by a quote
36 while (substr($i, 1, 1) != "\"" && substr($i, 1, 2) != "L\"")
38 # some of the resource IDs contain cast to HRESULT
39 gsub(/\(HRESULT\)/, "", $i);
40 # some of the resource IDs have trailing L
42 expression = expression $i;
46 # evaluate the resource ID expression
47 cmd = "echo $(("expression"))";
50 # in case shell returned the result as a string, ensure the var has numeric type
53 # Extract string content starting with either " or L"
54 idx = match($0, /L?\"/);
55 content = substr($0, idx);
57 # remove the L prefix from strings
58 gsub(/L"/, "\"", content);
59 # join strings "..." "..." into one
60 gsub(/" +"/, "", content);
62 # write the resource entry to the target file
63 writestringentry(var, content);
67 writefooter(arrayName, tableName);