Skip to content

Commit 2e846e5

Browse files
committed
Merge branch 'escape-filepaths'
* escape-filepaths: escape phony targets as well escape target name escape path of generated file escape filepaths
2 parents ba0154d + cf7802c commit 2e846e5

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

Source/Modules/main.cxx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,9 +1141,9 @@ int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) {
11411141
} else
11421142
f_dependencies_file = stdout;
11431143
if (dependencies_target) {
1144-
Printf(f_dependencies_file, "%s: ", dependencies_target);
1144+
Printf(f_dependencies_file, "%s: ", Swig_filename_escape_space(dependencies_target));
11451145
} else {
1146-
Printf(f_dependencies_file, "%s: ", outfile);
1146+
Printf(f_dependencies_file, "%s: ", Swig_filename_escape_space(outfile));
11471147
}
11481148
List *files = Preprocessor_depend();
11491149
List *phony_targets = NewList();
@@ -1154,15 +1154,15 @@ int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm) {
11541154
use_file = 0;
11551155
}
11561156
if (use_file) {
1157-
Printf(f_dependencies_file, "\\\n %s ", Getitem(files, i));
1157+
Printf(f_dependencies_file, "\\\n %s ", Swig_filename_escape_space(Getitem(files, i)));
11581158
if (depend_phony)
11591159
Append(phony_targets, Getitem(files, i));
11601160
}
11611161
}
11621162
Printf(f_dependencies_file, "\n");
11631163
if (depend_phony) {
11641164
for (int i = 0; i < Len(phony_targets); i++) {
1165-
Printf(f_dependencies_file, "\n%s:\n", Getitem(phony_targets, i));
1165+
Printf(f_dependencies_file, "\n%s:\n", Swig_filename_escape_space(Getitem(phony_targets, i)));
11661166
}
11671167
}
11681168

Source/Swig/misc.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,19 @@ String *Swig_filename_escape(String *filename) {
249249
return adjusted_filename;
250250
}
251251

252+
/* -----------------------------------------------------------------------------
253+
* Swig_filename_escape()
254+
*
255+
* Escapes spaces in filename - for Makefiles
256+
* ----------------------------------------------------------------------------- */
257+
258+
String *Swig_filename_escape_space(String *filename) {
259+
String *adjusted_filename = Copy(filename);
260+
Swig_filename_correct(adjusted_filename);
261+
Replaceall(adjusted_filename, " ", "\\ ");
262+
return adjusted_filename;
263+
}
264+
252265
/* -----------------------------------------------------------------------------
253266
* Swig_filename_unescape()
254267
*

Source/Swig/swig.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ extern int ParmList_is_compactdefargs(ParmList *p);
315315
extern String *Swig_new_subdirectory(String *basedirectory, String *subdirectory);
316316
extern void Swig_filename_correct(String *filename);
317317
extern String *Swig_filename_escape(String *filename);
318+
extern String *Swig_filename_escape_space(String *filename);
318319
extern void Swig_filename_unescape(String *filename);
319320
extern int Swig_storage_isextern(Node *n);
320321
extern int Swig_storage_isexternc(Node *n);

0 commit comments

Comments
 (0)