agb1 Posted November 22, 2016 Share Posted November 22, 2016 For mods that aren't packaged with iconv, I want to patch them to use the WeiDU HANDLE_CHARSETS macro with iconv_path pointing to a copy of iconv in the "Big World Fixpack" folder, instead of making duplicate copies of iconv for each mod. However, the spaces in the folder name are causing some problems. We could get rid of the spaces in the folder name, but this would necessitate changing a handful of legacy scripts that are scattered around, so I'm looking for alternatives. HANDLE_CHARSETS is defined in src\tph\include\handle_charsets.tpa in the WeiDU source distribution. The macro accepts STR_VAR "iconv_path", appends iconv.exe to it (OUTER_SPRINT iconv ~%iconv_path%/iconv.exe~), then uses FILE_EXISTS to check if the path is valid, and then (if FILE_EXISTS was successful), does an AT_NOW with the full path-to-exe %iconv% variable: AT_NOW ~%iconv% ... Here we have a problem. AT_NOW fails if the path contains spaces unless it is also surrounded by quotes. FILE_EXISTS succeeds if the path contains spaces but fails if the path is also surrounded by quotes. Here is a sample tp2 file demonstrating both cases: BACKUP ~test/backup~ AUTHOR ~agb1 on shsforums.net, gibberlings3.net or forums.beamdog.com~ VERSION ~example~ ALWAYS // test 1 OUTER_SPRINT iconv_path ~Big World Fixpack/_utils/iconv/iconv.exe~ // path with spaces, no quotes PRINT ~%iconv_path%~ ACTION_IF (FILE_EXISTS ~%iconv_path%~) BEGIN // this check succeeds PRINT ~iconv exists~ END ELSE BEGIN PRINT ~iconv not found~ END AT_NOW ~%iconv_path% --help~ // this fails because iconv_path contains spaces (Windows complains 'Big' is not recognized as a command) PRINT ~test 2~ // test 2 OUTER_SPRINT iconv_path ~"Big World Fixpack/_utils/iconv/iconv.exe"~ // path with spaces, surrounded by quotes PRINT ~%iconv_path%~ ACTION_IF (FILE_EXISTS ~%iconv_path%~) BEGIN // this check fails - no match PRINT ~iconv exists~ END ELSE BEGIN PRINT ~iconv not found~ END AT_NOW ~%iconv_path% --help~ // this however works, because the command is passed to Windows with quotation marks FAIL ~end test~ END BEGIN ~do nothing~ Link to comment
Ardanis Posted November 22, 2016 Share Posted November 22, 2016 Mmm, if I understand it right, you need to wrap the path in quotes after FILE_EXISTS but before AT_NOW, i.e. something that can only be done by editing the macro code itself? If so, INCLUDEing the edited macro until Wisp can do something on his end sounds like a proper solution to the issue. I've done it before. Link to comment
Recommended Posts
Archived
This topic is now archived and is closed to further replies.