From fba23109f7e5b3daf672549cbdbca4b1006812bc Mon Sep 17 00:00:00 2001 From: "Rev. Br. Elijah Schwab, O.Carm" Date: Thu, 15 Dec 2016 12:58:21 -0600 Subject: [PATCH 1/3] Rename gabc files containing non-filename friendly symbols. Addresses #1224 --- tex/gregoriotex.lua | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/tex/gregoriotex.lua b/tex/gregoriotex.lua index df0652d9d..68d389ed4 100644 --- a/tex/gregoriotex.lua +++ b/tex/gregoriotex.lua @@ -729,7 +729,7 @@ local function compile_gabc(gabc_file, gtex_file, glog_file, allow_deprecated) extra_args = extra_args..' -D' end - local cmd = string.format("%s %s -W -o %s -l %s %s", gregorio_exe, extra_args, + local cmd = string.format("%s %s -W -o %s -l %s '%s'", gregorio_exe, extra_args, gtex_file, glog_file, gabc_file) res = os.execute(cmd) if res == nil then @@ -784,21 +784,31 @@ local function compile_gabc(gabc_file, gtex_file, glog_file, allow_deprecated) end local function include_score(input_file, force_gabccompile, allow_deprecated) - local file_root - if string.match(input_file:sub(-5), '%.gtex') then - file_root = input_file:sub(1,-6) - elseif string.match(input_file:sub(-4), '%.tex') then - file_root = input_file:sub(1,-5) - elseif string.match(input_file:sub(-5), '%.gabc') then - file_root = input_file:sub(1,-6) - elseif not file_root then - file_root = input_file - end - local gtex_file = file_root.."-"..internalversion:gsub("%.", "_")..".gtex" - local glog_file = file_root.."-"..internalversion:gsub("%.", "_")..".glog" - local gabc_file = file_root..".gabc" + if string.match(input_file, "[#%%]") then + err("GABC filename contains invalid character(s): # %%\n" + .."Rename the file and retry: %s", input_file) + end + local has_extention = false + local file_dir,input_name + local extensions = {['gabc']=true, ['gtex']=true, ['tex']=true} + if extensions[string.match(input_file, "([^%.\\/]*)$")] then + has_extention = true + end + if has_extention then + file_dir,input_name = string.match(input_file, + "(.-)([^\\/]-)%.?[^%.\\/]*$") + else + file_dir,input_name = string.match(input_file, "(.-)([^\\/]*)$") + end + + local cleaned_filename = input_name:gsub("[%s%+%&%*%?$@:;!\"\'`]", "-") + local gabc_file = string.format("%s%s.gabc", file_dir, input_name) + local gtex_file = string.format("%s%s-%s.gtex", file_dir, cleaned_filename, + internalversion:gsub("%.", "_")) + local glog_file = string.format("%s%s-%s.glog", file_dir, cleaned_filename, + internalversion:gsub("%.", "_")) if not lfs.isfile(gtex_file) then - clean_old_gtex_files(file_root) + clean_old_gtex_files(file_dir..cleaned_filename) log("The file %s does not exist. Searching for a gabc file", gtex_file) if lfs.isfile(gabc_file) then local gabc = io.open(gabc_file, 'r') @@ -831,7 +841,7 @@ local function include_score(input_file, force_gabccompile, allow_deprecated) log("%s has been modified and %s needs to be updated. Recompiling the gabc file.", gabc_file, gtex_file) compile_gabc(gabc_file, gtex_file, glog_file, allow_deprecated) elseif force_gabccompile then - compile_gabc(gabc_file, gtex_file, glog_file) + compile_gabc(gabc_file, gtex_file, glog_file, allow_deprecated) end tex.print(string.format([[\input %s\relax]], gtex_file)) return From 9120e9d0d13490b4434f588a49edff601e2002e8 Mon Sep 17 00:00:00 2001 From: "Rev. Br. Elijah Schwab, O.Carm" Date: Thu, 15 Dec 2016 12:58:21 -0600 Subject: [PATCH 2/3] Rename gabc files containing non-filename friendly symbols. Addresses #1224 --- tex/gregoriotex.lua | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/tex/gregoriotex.lua b/tex/gregoriotex.lua index 237ec7278..f63e95bb2 100644 --- a/tex/gregoriotex.lua +++ b/tex/gregoriotex.lua @@ -740,7 +740,7 @@ local function compile_gabc(gabc_file, gtex_file, glog_file, allow_deprecated) extra_args = extra_args..' -D' end - local cmd = string.format("%s %s -W -o %s -l %s %s", gregorio_exe, extra_args, + local cmd = string.format("%s %s -W -o %s -l %s '%s'", gregorio_exe, extra_args, gtex_file, glog_file, gabc_file) res = os.execute(cmd) if res == nil then @@ -795,21 +795,31 @@ local function compile_gabc(gabc_file, gtex_file, glog_file, allow_deprecated) end local function include_score(input_file, force_gabccompile, allow_deprecated) - local file_root - if string.match(input_file:sub(-5), '%.gtex') then - file_root = input_file:sub(1,-6) - elseif string.match(input_file:sub(-4), '%.tex') then - file_root = input_file:sub(1,-5) - elseif string.match(input_file:sub(-5), '%.gabc') then - file_root = input_file:sub(1,-6) - elseif not file_root then - file_root = input_file - end - local gtex_file = file_root.."-"..internalversion:gsub("%.", "_")..".gtex" - local glog_file = file_root.."-"..internalversion:gsub("%.", "_")..".glog" - local gabc_file = file_root..".gabc" + if string.match(input_file, "[#%%]") then + err("GABC filename contains invalid character(s): # %%\n" + .."Rename the file and retry: %s", input_file) + end + local has_extention = false + local file_dir,input_name + local extensions = {['gabc']=true, ['gtex']=true, ['tex']=true} + if extensions[string.match(input_file, "([^%.\\/]*)$")] then + has_extention = true + end + if has_extention then + file_dir,input_name = string.match(input_file, + "(.-)([^\\/]-)%.?[^%.\\/]*$") + else + file_dir,input_name = string.match(input_file, "(.-)([^\\/]*)$") + end + + local cleaned_filename = input_name:gsub("[%s%+%&%*%?$@:;!\"\'`]", "-") + local gabc_file = string.format("%s%s.gabc", file_dir, input_name) + local gtex_file = string.format("%s%s-%s.gtex", file_dir, cleaned_filename, + internalversion:gsub("%.", "_")) + local glog_file = string.format("%s%s-%s.glog", file_dir, cleaned_filename, + internalversion:gsub("%.", "_")) if not lfs.isfile(gtex_file) then - clean_old_gtex_files(file_root) + clean_old_gtex_files(file_dir..cleaned_filename) log("The file %s does not exist. Searching for a gabc file", gtex_file) if lfs.isfile(gabc_file) then local gabc = io.open(gabc_file, 'r') @@ -842,7 +852,7 @@ local function include_score(input_file, force_gabccompile, allow_deprecated) log("%s has been modified and %s needs to be updated. Recompiling the gabc file.", gabc_file, gtex_file) compile_gabc(gabc_file, gtex_file, glog_file, allow_deprecated) elseif force_gabccompile then - compile_gabc(gabc_file, gtex_file, glog_file) + compile_gabc(gabc_file, gtex_file, glog_file, allow_deprecated) end tex.print(string.format([[\input %s\relax]], gtex_file)) return From 64dc628e0d3e69427049f6dd40c3669740d0b494 Mon Sep 17 00:00:00 2001 From: "Rev. Br. Elijah Schwab, O.Carm" Date: Sat, 1 Apr 2017 15:48:28 -0500 Subject: [PATCH 3/3] Add Changelog entry for fix #1224. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 14d77cb11..5d1d9dc36 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ As of v3.0.0 this project adheres to [Semantic Versioning](http://semver.org/). - The printing of the commentary box is no longer tied to the printing of the inital. As a result it is now possible to have a score which has a commentary but not an initial. See [this thread on the user list](http://www.mail-archive.com/gregorio-users@gna.org/msg03911.html). - Elisions after a vowel centering prefix will no longer cause the center to be placed on the vowel in the prefix. Since prefixes are unvoiced vowels, this makes more sense than the previous behavior. As usual, you may use the manual centering features to force the centering where you want if this does not produce what you want. See [#1320](https://github.com/gregorio-project/gregorio/issues/1320). - Dynmanic line spacing when a clef change occurs at the end of a line is fixed so that the line after the clef change is spaced appropriately. See [#1285](https://github.com/gregorio-project/gregorio/issues/1285). - +- Spaces in the filename of a score no longer cause Gregoriotex to fail. See [#1224](https://github.com/gregorio-project/gregorio/issues/1224). ## [5.0.0-beta2] - 2017-02-24 ### Fixed