Fix #1807329 - When Makefile dependencies are being generated using the -M family of options on Windows, the file paths have been corrected to use single backslashes rather than double backslashes as path separators.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11847 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2010-02-08 23:12:27 +00:00
commit 207ba5ce39
6 changed files with 30 additions and 11 deletions

View file

@ -1,6 +1,11 @@
Version 1.3.41 (in progress) Version 1.3.41 (in progress)
============================ ============================
2010-02-08: wsfulton
Fix #1807329 - When Makefile dependencies are being generated using the -M family of options
on Windows, the file paths have been corrected to use single backslashes rather than double
backslashes as path separators.
2010-02-06: wsfulton 2010-02-06: wsfulton
Fix #2918902 - language specific files not being generated in correct directory on Fix #2918902 - language specific files not being generated in correct directory on
Windows when using forward slashes for -o, for example: Windows when using forward slashes for -o, for example:

View file

@ -1022,7 +1022,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
if (lang_config) { if (lang_config) {
Printf(fs, "\n%%include <%s>\n", lang_config); Printf(fs, "\n%%include <%s>\n", lang_config);
} }
Printf(fs, "%%include(maininput=\"%s\") \"%s\"\n", Swig_filename_escape(input_file), Swig_last_file()); Printf(fs, "%%include(maininput=\"%s\") \"%s\"\n", Swig_filename_escape(input_file), Swig_filename_escape(Swig_last_file()));
for (i = 0; i < Len(libfiles); i++) { for (i = 0; i < Len(libfiles); i++) {
Printf(fs, "\n%%include \"%s\"\n", Getitem(libfiles, i)); Printf(fs, "\n%%include \"%s\"\n", Getitem(libfiles, i));
} }

View file

@ -625,7 +625,7 @@ unterm:
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* DOH *get_filename(DOH *str) * DOH *get_filename(DOH *str)
* *
* Read a filename from str. A filename can be enclose in quotes, angle brackets, * Read a filename from str. A filename can be enclosed in quotes, angle brackets,
* or bare. * or bare.
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */
@ -652,6 +652,7 @@ static String *get_filename(String *str, int *sysfile) {
if (isspace(c)) if (isspace(c))
Ungetc(c, str); Ungetc(c, str);
} }
Swig_filename_unescape(fn);
Swig_filename_correct(fn); Swig_filename_correct(fn);
Seek(fn, 0, SEEK_SET); Seek(fn, 0, SEEK_SET);
return fn; return fn;
@ -1593,9 +1594,9 @@ String *Preprocessor_parse(String *s) {
s1 = cpp_include(fn, sysfile); s1 = cpp_include(fn, sysfile);
if (s1) { if (s1) {
if (include_all) if (include_all)
Printf(ns, "%%includefile \"%s\" [\n", Swig_last_file()); Printf(ns, "%%includefile \"%s\" [\n", Swig_filename_escape(Swig_last_file()));
else if (import_all) { else if (import_all) {
Printf(ns, "%%importfile \"%s\" [\n", Swig_last_file()); Printf(ns, "%%importfile \"%s\" [\n", Swig_filename_escape(Swig_last_file()));
push_imported(); push_imported();
} }
@ -1732,7 +1733,7 @@ String *Preprocessor_parse(String *s) {
char *dirname; char *dirname;
add_chunk(ns, chunk, allow); add_chunk(ns, chunk, allow);
copy_location(s, chunk); copy_location(s, chunk);
Printf(ns, "%sfile%s \"%s\" [\n", decl, opt, Swig_last_file()); Printf(ns, "%sfile%s \"%s\" [\n", decl, opt, Swig_filename_escape(Swig_last_file()));
if (Equal(decl, kpp_dimport)) { if (Equal(decl, kpp_dimport)) {
push_imported(); push_imported();
} }

View file

@ -184,9 +184,8 @@ static FILE *Swig_open_file(const_String_or_char_ptr name, int sysfile, int use_
} }
if (f) { if (f) {
Delete(lastpath); Delete(lastpath);
lastpath = Swig_filename_escape(filename); lastpath = filename;
} }
Delete(filename);
return f; return f;
} }
@ -244,7 +243,7 @@ static String *Swig_include_any(const_String_or_char_ptr name, int sysfile) {
str = Swig_read_file(f); str = Swig_read_file(f);
fclose(f); fclose(f);
Seek(str, 0, SEEK_SET); Seek(str, 0, SEEK_SET);
file = Copy(lastpath); file = Copy(Swig_last_file());
Setfile(str, file); Setfile(str, file);
Delete(file); Delete(file);
Setline(str, 1); Setline(str, 1);

View file

@ -159,12 +159,25 @@ void Swig_filename_correct(String *filename) {
String *Swig_filename_escape(String *filename) { String *Swig_filename_escape(String *filename) {
String *adjusted_filename = Copy(filename); String *adjusted_filename = Copy(filename);
#if defined(_WIN32) /* Note not on Cygwin else filename is displayed with double '/' */ #if defined(_WIN32) /* Note not on Cygwin else filename is displayed with double '/' */
Replaceall(adjusted_filename, "\\\\", "\\"); /* remove double '\' in case any already present */ Replaceall(adjusted_filename, "\\\\", "\\"); /* remove double '\' in case any already present */
Replaceall(adjusted_filename, "\\", "\\\\"); Replaceall(adjusted_filename, "\\", "\\\\");
#endif #endif
return adjusted_filename; return adjusted_filename;
} }
/* -----------------------------------------------------------------------------
* Swig_filename_unescape()
*
* Remove double backslash escaping in filename - for Windows
* ----------------------------------------------------------------------------- */
void Swig_filename_unescape(String *filename) {
(void)filename;
#if defined(_WIN32)
Replaceall(filename, "\\\\", "\\");
#endif
}
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* Swig_string_escape() * Swig_string_escape()
* *

View file

@ -294,8 +294,9 @@ extern int ParmList_is_compactdefargs(ParmList *p);
extern void Swig_banner(File *f); extern void Swig_banner(File *f);
extern void Swig_banner_target_lang(File *f, const_String_or_char_ptr commentchar); extern void Swig_banner_target_lang(File *f, const_String_or_char_ptr commentchar);
extern String *Swig_strip_c_comments(const String *s); extern String *Swig_strip_c_comments(const String *s);
extern String *Swig_filename_escape(String *filename);
extern void Swig_filename_correct(String *filename); extern void Swig_filename_correct(String *filename);
extern String *Swig_filename_escape(String *filename);
extern void Swig_filename_unescape(String *filename);
extern String *Swig_string_escape(String *s); extern String *Swig_string_escape(String *s);
extern String *Swig_string_mangle(const String *s); extern String *Swig_string_mangle(const String *s);
extern void Swig_scopename_split(const String *s, String **prefix, String **last); extern void Swig_scopename_split(const String *s, String **prefix, String **last);