From 388f92b607dd96d76bd256b76b40a4a19c3194a0 Mon Sep 17 00:00:00 2001 From: Houtan Bastani Date: Wed, 23 Oct 2019 13:05:58 +0200 Subject: [PATCH] replace `filesep` with `/` On Windows, `filesep` evaluates to `\` and, in a `*printf` statement, this can have unintended consequences (e.g. `\t` evaluates to the tab character Since '/' works on all systems, replace all occurrences of `filesep` with `/` in the codebase --- matlab/reporting/src/@graph/writeGraphFile.m | 10 +++++----- matlab/reporting/src/@page/write.m | 4 ++-- matlab/reporting/src/@report/compile.m | 4 ++-- matlab/reporting/src/@report/write.m | 2 +- matlab/reporting/src/@report_table/writeTableFile.m | 10 +++++----- matlab/reporting/src/initialize_reporting_toolbox.m | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/matlab/reporting/src/@graph/writeGraphFile.m b/matlab/reporting/src/@graph/writeGraphFile.m index 0c0cf3002..c12c6fdbe 100644 --- a/matlab/reporting/src/@graph/writeGraphFile.m +++ b/matlab/reporting/src/@graph/writeGraphFile.m @@ -39,16 +39,16 @@ if ne < 1 return end -if exist([rep_dir filesep o.graphDirName], 'dir') ~= 7 - mkdir([rep_dir filesep o.graphDirName]); +if exist([rep_dir '/' o.graphDirName], 'dir') ~= 7 + mkdir([rep_dir '/' o.graphDirName]); end if isempty(o.graphName) - graphName = sprintf([o.graphDirName filesep 'graph_pg%d_sec%d_row%d_col%d.tex'], pg, sec, row, col); + graphName = sprintf([o.graphDirName '/graph_pg%d_sec%d_row%d_col%d.tex'], pg, sec, row, col); else - graphName = [o.graphDirName filesep o.graphName]; + graphName = [o.graphDirName '/' o.graphName]; end -[fid, msg] = fopen([rep_dir filesep graphName], 'w'); +[fid, msg] = fopen([rep_dir '/' graphName], 'w'); if fid == -1 error(['@graph.writeGraphFile: ' msg]); end diff --git a/matlab/reporting/src/@page/write.m b/matlab/reporting/src/@page/write.m index 51e4a6add..15f27aeda 100644 --- a/matlab/reporting/src/@page/write.m +++ b/matlab/reporting/src/@page/write.m @@ -42,11 +42,11 @@ end fprintf(fid, '\n'); if ~isempty(o.latex) - dir = [rep_dir filesep o.pageDirName]; + dir = [rep_dir '/' o.pageDirName]; if exist(dir, 'dir') ~= 7 mkdir(dir); end - pagename = [dir filesep 'page_' num2str(pg) '.tex']; + pagename = [dir '/page_' num2str(pg) '.tex']; [fidp, msg] = fopen(pagename, 'w'); if fidp == -1 error(['@page.write: ' msg]); diff --git a/matlab/reporting/src/@report/compile.m b/matlab/reporting/src/@report/compile.m index 78dcc6e6c..a2e62a7e6 100644 --- a/matlab/reporting/src/@report/compile.m +++ b/matlab/reporting/src/@report/compile.m @@ -57,7 +57,7 @@ assert(ischar(opts.compiler), '@report.compile: compiler file must be a string') assert(islogical(opts.showReport), '@report.compile: showReport must be either true or false'); assert(islogical(opts.showOutput), '@report.compile: showOutput must be either true or false'); -if exist([o.directory filesep o.fileName], 'file') ~= 2 +if exist([o.directory '/' o.fileName], 'file') ~= 2 o.write(); end @@ -111,7 +111,7 @@ if status ~= 0 ' ' opts.compiler ' returned the error code: ' num2str(status)]); end if o.showOutput || opts.showOutput - fprintf('Done.\n\nYour compiled report is located here:\n %s.pdf\n\n\n', [pwd filesep rfn]) + fprintf('Done.\n\nYour compiled report is located here:\n %s.pdf\n\n\n', [pwd '/' rfn]) end if opts.showReport && ~isoctave open([rfn '.pdf']); diff --git a/matlab/reporting/src/@report/write.m b/matlab/reporting/src/@report/write.m index 0707f9315..a1872f1b6 100644 --- a/matlab/reporting/src/@report/write.m +++ b/matlab/reporting/src/@report/write.m @@ -31,7 +31,7 @@ function o = write(o) if exist(o.directory, 'dir') ~= 7 mkdir(o.directory); end -[fid, msg] = fopen([o.directory filesep o.fileName], 'w'); +[fid, msg] = fopen([o.directory '/' o.fileName], 'w'); if fid == -1 error(['@report.write: ' msg]); end diff --git a/matlab/reporting/src/@report_table/writeTableFile.m b/matlab/reporting/src/@report_table/writeTableFile.m index bfc2a9bce..144f81691 100644 --- a/matlab/reporting/src/@report_table/writeTableFile.m +++ b/matlab/reporting/src/@report_table/writeTableFile.m @@ -40,16 +40,16 @@ if ne == 0 && ~is_data_table return end -if exist([rep_dir filesep o.tableDirName], 'dir') ~= 7 - mkdir([rep_dir filesep o.tableDirName]); +if exist([rep_dir '/' o.tableDirName], 'dir') ~= 7 + mkdir([rep_dir '/' o.tableDirName]); end if isempty(o.tableName) - tableName = sprintf([o.tableDirName filesep 'table_pg%d_sec%d_row%d_col%d.tex'], pg, sec, row, col); + tableName = sprintf([o.tableDirName '/table_pg%d_sec%d_row%d_col%d.tex'], pg, sec, row, col); else - tableName = [o.tableDirName filesep o.tableName]; + tableName = [o.tableDirName '/' o.tableName]; end -[fid, msg] = fopen([rep_dir filesep tableName], 'w'); +[fid, msg] = fopen([rep_dir '/' tableName], 'w'); if fid == -1 error(['@report_table.writeTableFile: ' msg]); end diff --git a/matlab/reporting/src/initialize_reporting_toolbox.m b/matlab/reporting/src/initialize_reporting_toolbox.m index e51c56586..f421b17f7 100644 --- a/matlab/reporting/src/initialize_reporting_toolbox.m +++ b/matlab/reporting/src/initialize_reporting_toolbox.m @@ -24,5 +24,5 @@ function initialize_reporting_toolbox() reporting_src_root = strrep(which('initialize_reporting_toolbox'), 'initialize_reporting_toolbox.m', ''); % Add path to reporting source -addpath([reporting_src_root filesep '..' filesep 'macros']); +addpath([reporting_src_root '/../macros']); end