Update functions and variables for the NSIS filetype

And add a script to make this task easier in the future.
master
Enrico Tröger 2019-06-10 14:45:24 +02:00
parent c159d1ae6f
commit 3820a4fb6e
2 changed files with 53 additions and 2 deletions

View File

@ -23,8 +23,8 @@ commentbox=comment
[keywords]
# all items must be in one line and in lowercase
functions=abort addbrandingimage !addincludedir !addincludedirdir !addplugindir addsize addsizesize_to_add_to_section_in_kb allowrootdirinstall allowskipfiles !appendfile autoclosewindow bgfont bggradient brandingtext bringtofront call callinstdll caption captioninstaller_caption !cd changeui checkbitmap clearerrors completedtext componenttext contributors: copyfiles crccheck createdirectory createdirectorydirectory_name createfont createshortcut !define delete deleteinisec deleteinistr deleteregkey deleteregvalue !delfilefile detailprint detailprintmessage detailsbuttontext dirshow dirtext dirvar dirverify dirverifyauto !echo !echomessage !else enablewindow !endif enumregkey enumregvalue !error exch exec execshell !execute execwait expandenvstrings file filebufsize fileclose fileerrortext fileopen fileread filereadbyte fileseek filewrite filewritebyte findclose findfirst findnext findwindow flushini function functionend function_name getcurinsttype getcurrentaddress getcurrentaddressoutput getdlgitem getdllversion getdllversionlocal geterrorlevel getfiletime getfiletimelocal getfullpathname getfunctionaddress getinstdirerror getlabeladdress gettempfilename goto gotolabel hidewindow icon !if ifabort !ifdef iferrors iffileexists !ifmacrodef !ifmacrondef !ifndef ifrebootflag ifsilent !include initpluginsdir !insertmacro installbuttontext installcolors installdir installdirregkey instprogressflags insttype insttypegettext insttypesettext intcmp intcmpu intfmt intop iswindow langstring langstringup licensebkcolor licensedata licenseforceselection licenselangstring licensetext loadlanguagefile lockwindow logset logtext !macro !macroend makensis messagebox miscbuttontext name none nop outfile !packhdr page pagecallbacks pageex pageexend pop portions push pushstring quit readenvstr readinistr readregdword readregstr reboot regdll rename requestexecutionlevel reservefile return rmdir !searchparse searchpath !searchreplace section sectionend sectiongetflags sectiongetinsttypes sectiongetsize sectiongettext sectiongroup sectiongroupend sectionin sectionsetflags sectionsetinsttypes sectionsetsize sectionsettext sendmessage setautoclose setbrandingimage setcompress setcompressionlevel setcompressor setcompressordictsize setctlcolors setcurinsttype setdatablockoptimize setdatesave setdetailsprint setdetailsview seterrorlevel seterrors setfileattributes setfont setoutpath setoverwrite setpluginunload setrebootflag setregview setshellvarcontext setsilent showinstdetails showuninstdetails showwindow silentinstall silentuninstall sleep spacetexts strcmp strcmps strcpy strlen subcaption subsection subsectionend !system !tempfilesymbol !undef uninstallbuttontext uninstallcaption uninstallexename uninstallicon uninstallsubcaption uninstalltext uninstpage unregdll var !verbose viaddversionkey viproductversion !warning windowicon writeinistr writeregbin writeregdword writeregexpandstr writeregstr writeuninstaller xpstyle
variables=$$ $` $' $" $0 $0, $1 $2 $3 $4 $5 $6 $7 $8 $9 $admintools $appdata $cdburn_area $cmdline $commonfiles $cookies $desktop $documents $exedir $favorites $fonts $history $hwndparent $instdir $internet_cache $language $music $nethood ${nsisdir} $outdir $pictures $pluginsdir $printhood $profile $programfiles $quicklaunch $\r $r0 $r1 $r2 $r3 $r4 $r5 $r6 $r7 $r8 $r9 $recent $resources $resources_localized $sendto $smprograms $smstartup $startmenu $sysdir $temp $templates $varname $videos $windir
functions=!addincludedir !addplugindir !appendfile !cd !define !delfile !echo !else !endif !error !execute !finalize !getdllversion !gettlbversion !if !ifdef !ifmacrodef !ifmacrondef !ifndef !include !insertmacro !macro !macroend !macroundef !makensis !packhdr !pragma !searchparse !searchreplace !system !tempfile !undef !verbose !warning abort addbrandingimage addsize allowrootdirinstall allowskipfiles autoclosewindow bgfont bggradient brandingtext bringtofront cpu crccheck call callinstdll caption changeui checkbitmap clearerrors completedtext componenttext copyfiles createdirectory createfont createshortcut delete deleteinisec deleteinistr deleteregkey deleteregvalue detailprint detailsbuttontext dirshow dirtext dirvar dirverify enablewindow enumregkey enumregvalue exch exec execshell execshellwait execwait expandenvstrings file filebufsize fileclose fileerrortext fileopen fileread filereadbyte filereadutf16le filereadword fileseek filewrite filewritebyte filewriteutf16le filewriteword findclose findfirst findnext findwindow flushini function functionend getcurinsttype getcurrentaddress getdllversion getdllversionlocal getdlgitem geterrorlevel getfiletime getfiletimelocal getfullpathname getfunctionaddress getinstdirerror getlabeladdress gettempfilename goto hidewindow icon ifabort iferrors iffileexists ifrebootflag ifsilent initpluginsdir instprogressflags insttype insttypegettext insttypesettext installbuttontext installcolors installdir installdirregkey int64cmp int64cmpu int64fmt intcmp intcmpu intfmt intop intptrcmp intptrcmpu intptrop iswindow langstring langstringup licensebkcolor licensedata licenseforceselection licenselangstring licensetext loadandsetimage loadlanguagefile lockwindow logset logtext manifestdpiaware manifestdpiawareness manifestdisablewindowfiltering manifestgdiscaling manifestmaxversiontested manifestsupportedos messagebox miscbuttontext name nop outfile peaddresource pedllcharacteristics peremoveresource pesubsysver page page pagecallbacks pageex pageexend pop push quit rmdir readenvstr readinistr readregdword readregstr reboot regdll rename requestexecutionlevel reservefile return searchpath section sectionend sectiongetflags sectiongetinsttypes sectiongetsize sectiongettext sectiongroup sectiongroupend sectionin sectionsetflags sectionsetinsttypes sectionsetsize sectionsettext sendmessage setautoclose setbrandingimage setcompress setcompressionlevel setcompressor setcompressordictsize setctlcolors setcurinsttype setdatablockoptimize setdatesave setdetailsprint setdetailsview seterrorlevel seterrors setfileattributes setfont setoutpath setoverwrite setpluginunload setrebootflag setregview setshellvarcontext setsilent showinstdetails showuninstdetails showwindow silentinstall silentuninstall sleep spacetexts strcmp strcmps strcpy strlen subcaption subsection subsectionend target unregdll unicode uninstpage uninstpage uninstallbuttontext uninstallcaption uninstallexename uninstallicon uninstallsubcaption uninstalltext unsafestrcpy viaddversionkey vifileversion viproductversion var windowicon writeinistr writeregbin writeregdword writeregexpandstr writeregmultistr writeregnone writeregstr writeuninstaller xpstyle
variables=${nsisdir} $0 $1 $2 $3 $4 $5 $6 $7 $8 $9 $r0 $r1 $r2 $r3 $r4 $r5 $r6 $r7 $r8 $r9 $\n $\r $\t $$ $admintools $appdata $cdburn_area $cmdline $commonfiles $commonfiles32 $commonfiles64 $cookies $desktop $documents $exedir $exefile $exepath $favorites $fonts $history $hwndparent $instdir $internet_cache $language $localappdata $music $nethood $outdir $pictures $pluginsdir $printhood $profile $programfiles $programfiles32 $programfiles64 $quicklaunch $recent $resources $resources_localized $sendto $smprograms $smstartup $startmenu $sysdir $temp $templates $videos $windir $_click $_outdir
lables=all alt alwaysoff archive auto both bottom bzip2 center colored components control current custom directory dlg_id ext false file_attribute_archive file_attribute_hidden file_attribute_normal file_attribute_offline file_attribute_readonly file_attribute_system file_attribute_temporary filesonly force hidden hide hkcc hkcr hkcu hkdd hkey_classes_root hkey_current_config hkey_current_user hkey_dyn_data hkey_local_machine hkey_performance_data hkey_users hklm hkpd hku idabort idcancel idignore idno idok idretry idyes ifdiff ifnewer instfiles italic lastused leave left license listonly lzma manual mb_abortretryignore mb_defbutton1 mb_defbutton2 mb_defbutton3 mb_defbutton4 mb_iconexclamation mb_iconinformation mb_iconquestion mb_iconstop mb_ok mb_okcancel mb_retrycancel mb_right mb_setforeground mb_topmost mb_yesno mb_yesnocancel nevershow none nonfatal normal of off offline on open print readonly rebootok right shctx shift show silent silentlog smooth strike sw_hide sw_showmaximized sw_showmaximized sw_showminimized sw_showminimized sw_showminnoactive sw_showna sw_shownoactivate sw_shownormal sw_shownormal system temporary textonly top trim true try underline uninstconfirm zlib
userdefined=

View File

@ -0,0 +1,51 @@
#!/bin/bash
#
# Author: Enrico Tröger
# License: GPL v2 or later
#
# Updates the `functions` and `variables` entries in data/filetypes.nsis.
set -e
TOKENS_CPP_FILE="/tmp/nsis_tokens.cpp"
TOKENS_CPP_URL="https://raw.githubusercontent.com/kichik/nsis/master/Source/tokens.cpp"
BUILD_CPP_FILE="/tmp/nsis_build.cpp"
BUILD_CPP_URL="https://raw.githubusercontent.com/kichik/nsis/master/Source/build.cpp"
DATA_FILE=data/filedefs/filetypes.nsis
[ -f "${DATA_FILE}" ]
# download tokens.cpp and build.cpp from NSIS
wget --quiet --output-document="${TOKENS_CPP_FILE}" "${TOKENS_CPP_URL}"
wget --quiet --output-document="${BUILD_CPP_FILE}" "${BUILD_CPP_URL}"
normalize() {
# sort, remove line breaks, convert to lower case and remove leading and trailing whitespace
sort | tr '[:upper:][:space:]' '[:lower:] ' | sed 's/^[[:blank:]]*//;s/[[:blank:]]*$//'
}
# extract function names (then sort the result, conver to lowercase and replace new lines by spaces)
functions=$(
sed --silent --regexp-extended 's/^\{TOK_.*,_T\("(.*)"\),[0-9]+,.*$/\1/p' "${TOKENS_CPP_FILE}" | \
normalize
)
# extract variable names (then sort the result, conver to lowercase and replace new lines by spaces)
variables=$(
sed --silent --regexp-extended \
--expression 's/^[ ]*m_ShellConstants.add\(_T\("(.*)"\),.*,.*\);.*$/\1/p' \
--expression 's/^[ ]*m_UserVarNames.add\(_T\("(.*)"\),.*\);.*$/\1/p' "${BUILD_CPP_FILE}" | \
normalize
)
# hardcode a few more, as found in the documentation ("4.2.2 Other Writable Variables")
variables_extra='{nsisdir} 0 1 2 3 4 5 6 7 8 9 r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 \\n \\r \\t $'
variables="${variables_extra} ${variables}"
# prefix each element with a dollar sign
variables="$(echo "$variables" | sed 's/[^ ]*/$&/g')"
rm "${TOKENS_CPP_FILE}" "${BUILD_CPP_FILE}"
sed --expression "s/^functions=.*$/functions=$functions/" \
--expression "s/^variables=.*$/variables=$variables/" \
--in-place "${DATA_FILE}"