Skip to content

Instantly share code, notes, and snippets.

@selvanair
Last active May 19, 2021 02:40
Show Gist options
  • Save selvanair/ae78c29869d7c1d15abcb909f04676c6 to your computer and use it in GitHub Desktop.
Save selvanair/ae78c29869d7c1d15abcb909f04676c6 to your computer and use it in GitHub Desktop.
A sed script to convert openvpn-gui resource files to MSVC compliant format
# Make our resource files msvc compliant. Run from folder res as
# for file in *res-??.rc *res-zh-*.rc; do sed -i -r -f res-fix.sed $file; done
# Requires run time replacement of GUI version string in About window
#
# 1. replace version number by a print spec
s/" PACKAGE_VERSION_RESOURCE_STR "/%s/
# add an id to the LTEXT so that we can address it at run time
s/(https:\/\/github.com\/OpenVPN\/openvpn-gui\/",) 0/\1 ID_TXT_VERSION/
#2. hard code copyright years
s/" GUI_COPYRIGHT_YEAR_END "/2021/
s/" CORE_COPYRIGHT_YEAR_END "/2021/
#3. Handle line continuation -- process two lines together using N, P, D pattern
$!N
/AUTORADIOBUTTON/ { # non-text line continuation -- remove them
s/,\s*\\\n/,\n/
}
# match quoted string followed by \ at end of line -- line continuation
/"\s*\\\n/ {
# remove the ending quote
s/("\s*\\\n)/\\\n/
# there are some offending bank lines after a line continuation -- remove them
/\n\s*$/ {
s/\n\s*$/\n/
N
}
# remove the starting quote in continued line
s/(\\\n)(\s*")/\1/
}
s/"\s*\n\s*"/\\\n/ # fix continued lines with missing continuation character
# one LTEXT is too long in most languages (> 256 chars) -- split at info@openvp.net
/\\\n.*info@openvpn.net/ {
s/\\\n/", 0, 8, 70, 240, 64\n LTEXT "/
}
/\\\n.*https:\/\/openvpn.net/ {
s/61/106/
s/70/106/
}
# another LTEXT is too long in many languages -- split at https://github.com
/\\\n.*https:\/\/github.com/ {
s/15/55/
s/\\\n/", ID_TXT_VERSION, 36, 15, 206, 50\n LTEXT "/
}
P
D
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment