diff options
Diffstat (limited to 'src/nativeresources/processrc.awk')
-rw-r--r-- | src/nativeresources/processrc.awk | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/nativeresources/processrc.awk b/src/nativeresources/processrc.awk new file mode 100644 index 0000000000..1632753956 --- /dev/null +++ b/src/nativeresources/processrc.awk @@ -0,0 +1,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); +} |