[swig] Bacport fix for preprocessor regression (#691513).

Adam Tkac atkac at fedoraproject.org
Tue Mar 29 10:46:09 UTC 2011


commit 6673f8a3f38fc2cbd8029d32b02bd40ca6e15a35
Author: Adam Tkac <atkac at redhat.com>
Date:   Tue Mar 29 12:45:54 2011 +0200

    Bacport fix for preprocessor regression (#691513).
    
    Signed-off-by: Adam Tkac <atkac at redhat.com>

 swig.spec              |    7 ++-
 swig202-rh691513.patch |  212 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 218 insertions(+), 1 deletions(-)
---
diff --git a/swig.spec b/swig.spec
index 3d0fe96..11d55d1 100644
--- a/swig.spec
+++ b/swig.spec
@@ -4,7 +4,7 @@
 Summary: Connects C/C++/Objective C to some high-level programming languages
 Name: swig
 Version: 2.0.2
-Release: 1%{?dist}
+Release: 2%{?dist}
 License: GPLv3+ and BSD
 Group: Development/Tools
 URL: http://swig.sourceforge.net/
@@ -12,6 +12,7 @@ Source: http://downloads.sourceforge.net/project/swig/swig/swig-%{version}/swig-
 Patch1: swig-1.3.23-pylib.patch
 Patch2: swig200-rh623854.patch
 Patch3: swig200-rh666429.patch
+Patch4: swig202-rh691513.patch
 
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildRequires: perl, python-devel, pcre-devel
@@ -46,6 +47,7 @@ This package contains documentation for SWIG and useful examples
 %patch1 -p1 -b .pylib
 %patch2 -p1 -b .rh623854
 %patch3 -p1 -b .rh666429
+%patch4 -p1 -b .rh691513
 
 # as written on https://fedoraproject.org/wiki/Packaging_talk:Perl, section 2
 # (specific req/prov filtering). Before you remove this hack make sure you don't
@@ -117,6 +119,9 @@ rm -rf %{buildroot}
 %doc Doc Examples LICENSE LICENSE-GPL LICENSE-UNIVERSITIES COPYRIGHT
 
 %changelog
+* Tue Mar 29 2011 Adam Tkac <atkac redhat com> 2.0.2-2
+- bacport fix for preprocessor regression (#691513)
+
 * Mon Feb 21 2011 Adam Tkac <atkac redhat com> 2.0.2-1
 - update to 2.0.2
 
diff --git a/swig202-rh691513.patch b/swig202-rh691513.patch
new file mode 100644
index 0000000..4b97f21
--- /dev/null
+++ b/swig202-rh691513.patch
@@ -0,0 +1,212 @@
+From 8f0beedbee985a73dc01e2f430311a69c8cebbd0 Mon Sep 17 00:00:00 2001
+From: wsfulton <wsfulton at 626c5289-ae23-0410-ae9c-e8d60b6d4f22>
+Date: Thu, 17 Mar 2011 07:33:05 +0000
+Subject: [PATCH] Fix regression introduced in swig-2.0.2 where filenames with spaces were not found when used with %include and %import
+
+git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12546 626c5289-ae23-0410-ae9c-e8d60b6d4f22
+
+Signed-off-by: Adam Tkac <atkac at redhat.com>
+---
+ CHANGES.current                                    |    4 ++
+ Examples/test-suite/preproc_include.i              |   19 +++++++++
+ Examples/test-suite/preproc_include_d withspace.h  |    3 +
+ Examples/test-suite/preproc_include_e withspace.h  |    3 +
+ Examples/test-suite/preproc_include_f withspace.h  |    3 +
+ Examples/test-suite/preproc_include_g.h            |    3 +
+ .../test-suite/python/preproc_include_runme.py     |   12 ++++++
+ Source/Preprocessor/cpp.c                          |   41 ++++++++++---------
+ 8 files changed, 69 insertions(+), 19 deletions(-)
+ create mode 100644 Examples/test-suite/preproc_include_d withspace.h
+ create mode 100644 Examples/test-suite/preproc_include_e withspace.h
+ create mode 100644 Examples/test-suite/preproc_include_f withspace.h
+ create mode 100644 Examples/test-suite/preproc_include_g.h
+
+diff --git a/Examples/test-suite/preproc_include.i b/Examples/test-suite/preproc_include.i
+index c6b08b5..86c5f71 100644
+--- a/Examples/test-suite/preproc_include.i
++++ b/Examples/test-suite/preproc_include.i
+@@ -6,6 +6,8 @@
+ int multiply10(int a) { return a*10; }
+ int multiply20(int a) { return a*20; }
+ int multiply30(int a) { return a*30; }
++int multiply40(int a) { return a*40; }
++int multiply50(int a) { return a*50; }
+ %}
+ 
+ #define INCLUDE_B preproc_include_b.h
+@@ -16,3 +18,20 @@ int multiply30(int a) { return a*30; }
+ // Note that this test uses -includeall, so including preproc_include_b.h also includes preproc_include_c.h
+ %include INCLUDE_B
+ 
++%include"preproc_include_d withspace.h"
++
++#define INCLUDE_E "preproc_include_e withspace.h"
++
++%include INCLUDE_E
++
++%inline %{
++#define INCLUDE_F /*comments*/ "preproc_include_f withspace.h"/*testing*/
++#include INCLUDE_F
++#include /*oooo*/"preproc_include_g.h"/*ahhh*/
++%}
++
++%{
++int multiply60(int a) { return a*60; }
++int multiply70(int a) { return a*70; }
++%}
++
+diff --git a/Examples/test-suite/preproc_include_d withspace.h b/Examples/test-suite/preproc_include_d withspace.h
+new file mode 100644
+index 0000000..142ddd5
+--- /dev/null
++++ b/Examples/test-suite/preproc_include_d withspace.h	
+@@ -0,0 +1,3 @@
++
++int multiply40(int a);
++
+diff --git a/Examples/test-suite/preproc_include_e withspace.h b/Examples/test-suite/preproc_include_e withspace.h
+new file mode 100644
+index 0000000..d749765
+--- /dev/null
++++ b/Examples/test-suite/preproc_include_e withspace.h	
+@@ -0,0 +1,3 @@
++
++int multiply50(int a);
++
+diff --git a/Examples/test-suite/preproc_include_f withspace.h b/Examples/test-suite/preproc_include_f withspace.h
+new file mode 100644
+index 0000000..8a39a34
+--- /dev/null
++++ b/Examples/test-suite/preproc_include_f withspace.h	
+@@ -0,0 +1,3 @@
++
++int multiply60(int a);
++
+diff --git a/Examples/test-suite/preproc_include_g.h b/Examples/test-suite/preproc_include_g.h
+new file mode 100644
+index 0000000..db4f914
+--- /dev/null
++++ b/Examples/test-suite/preproc_include_g.h
+@@ -0,0 +1,3 @@
++
++int multiply70(int a);
++
+diff --git a/Examples/test-suite/python/preproc_include_runme.py b/Examples/test-suite/python/preproc_include_runme.py
+index e156065..778de3c 100644
+--- a/Examples/test-suite/python/preproc_include_runme.py
++++ b/Examples/test-suite/python/preproc_include_runme.py
+@@ -9,3 +9,15 @@ if preproc_include.multiply20(10) != 200:
+ if preproc_include.multiply30(10) != 300:
+   raise RuntimeError
+ 
++if preproc_include.multiply40(10) != 400:
++  raise RuntimeError
++
++if preproc_include.multiply50(10) != 500:
++  raise RuntimeError
++
++if preproc_include.multiply60(10) != 600:
++  raise RuntimeError
++
++if preproc_include.multiply70(10) != 700:
++  raise RuntimeError
++
+diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c
+index 752c95e..8d2346c 100644
+--- a/Source/Preprocessor/cpp.c
++++ b/Source/Preprocessor/cpp.c
+@@ -93,8 +93,6 @@ static String *cpp_include(const_String_or_char_ptr fn, int sysfile) {
+     Setattr(included_files, file, file);
+   }
+   if (!s) {
+-    /* XXX(bhy) may not need the seek */
+-    /* Seek(fn, 0, SEEK_SET); */
+     if (ignore_missing) {
+       Swig_warning(WARN_PP_MISSING_FILE, Getfile(fn), Getline(fn), "Unable to find '%s'\n", fn);
+     } else {
+@@ -665,11 +663,30 @@ static String *get_filename(String *str, int *sysfile) {
+     while (((c = Getc(str)) != EOF) && (c != '>'))
+       Putc(c, fn);
+   } else {
++    String *preprocessed_str;
+     Putc(c, fn);
+     while (((c = Getc(str)) != EOF) && (!isspace(c)))
+       Putc(c, fn);
+     if (isspace(c))
+       Ungetc(c, str);
++    preprocessed_str = Preprocessor_replace(fn);
++    Seek(preprocessed_str, 0, SEEK_SET);
++    Delete(fn);
++
++    fn = NewStringEmpty();
++    copy_location(preprocessed_str, fn);
++    c = Getc(preprocessed_str);
++    if (c == '\"') {
++      while (((c = Getc(preprocessed_str)) != EOF) && (c != '\"'))
++	Putc(c, fn);
++    } else if (c == '<') {
++      *sysfile = 1;
++      while (((c = Getc(preprocessed_str)) != EOF) && (c != '>'))
++	Putc(c, fn);
++    } else {
++      fn = Copy(preprocessed_str);
++    }
++    Delete(preprocessed_str);
+   }
+   Swig_filename_unescape(fn);
+   Swig_filename_correct(fn);
+@@ -1689,14 +1706,12 @@ String *Preprocessor_parse(String *s) {
+ 	  String *s1, *s2, *fn;
+ 	  char *dirname;
+ 	  int sysfile = 0;
+-	  String *filename_processed;
+ 	  if (include_all && import_all) {
+ 	    Swig_warning(WARN_PP_INCLUDEALL_IMPORTALL, Getfile(s), Getline(id), "Both includeall and importall are defined: using includeall.\n");
+ 	    import_all = 0;
+ 	  }
+-	  filename_processed = Preprocessor_replace(value);
+-	  Seek(filename_processed, 0, SEEK_SET);
+-	  fn = get_filename(filename_processed, &sysfile);
++	  Seek(value, 0, SEEK_SET);
++	  fn = get_filename(value, &sysfile);
+ 	  s1 = cpp_include(fn, sysfile);
+ 	  if (s1) {
+ 	    if (include_all)
+@@ -1827,8 +1842,6 @@ String *Preprocessor_parse(String *s) {
+ 	    DOH *s1, *s2, *fn, *opt;
+ 	    String *options_whitespace = NewStringEmpty();
+ 	    String *filename_whitespace = NewStringEmpty();
+-	    String *filename_unprocessed = NewStringEmpty();
+-	    String *filename_processed;
+ 	    int sysfile = 0;
+ 
+ 	    if (Equal(decl, kpp_dextern)) {
+@@ -1840,15 +1853,7 @@ String *Preprocessor_parse(String *s) {
+ 	    opt = get_options(s);
+ 
+ 	    skip_whitespace(s, filename_whitespace);
+-	    copy_location(s, filename_unprocessed);
+-	    while (((c = Getc(s)) != EOF) && (!isspace(c)))
+-	      Putc(c, filename_unprocessed);
+-	    if (isspace(c))
+-	      Ungetc(c, s);
+-	    filename_processed = Preprocessor_replace(filename_unprocessed);
+-	    Seek(filename_processed, 0, SEEK_SET);
+-
+-	    fn = get_filename(filename_processed, &sysfile);
++	    fn = get_filename(s, &sysfile);
+ 	    s1 = cpp_include(fn, sysfile);
+ 	    if (s1) {
+ 	      char *dirname;
+@@ -1878,8 +1883,6 @@ String *Preprocessor_parse(String *s) {
+ 	      Delete(s1);
+ 	    }
+ 	    Delete(fn);
+-	    Delete(filename_processed);
+-	    Delete(filename_unprocessed);
+ 	    Delete(filename_whitespace);
+ 	    Delete(options_whitespace);
+ 	  }
+-- 
+1.7.4.2
+


More information about the scm-commits mailing list