[PATCH] mingw fix

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] mingw fix

Paolo Bonzini-2
Here is the bug that is breaking gst-package on mingw:

st> CSymbols.PathSeparator := $\
$\
st> File computePathFrom: 'C:/a\b\c' to: 'C:\a\e\f'
'/C:/a/e/f'

with the patch, obviously, it returns '..\e\f'.

There was a similar problem in File>>#fullNameFor: but it was already
fixed last June by Freddie Akeroyd.

Paolo

2008-02-13  Paolo Bonzini  <[hidden email]>
   
        * kernel/File.st: Canonicalize names before finding directory
        components.

diff --git a/kernel/File.st b/kernel/File.st
index 09ba2ce..bfa4ff6 100644
--- a/kernel/File.st
+++ b/kernel/File.st
@@ -192,9 +192,18 @@ size and timestamps.'>
 
     File class >> computePathFrom: srcName to: destName [
  <category: 'private'>
- | src dest srcComponent destComponent path |
- src := srcName subStrings: Directory pathSeparator.
- dest := destName subStrings: Directory pathSeparator.
+ | src dest srcCanon destCanon path |
+ "A Windows path may contain both / and \ separators. Clean it up
+ to allow easy parsing"
+ srcCanon := Directory pathSeparator = $/
+    ifTrue: [srcName]
+    ifFalse: [srcName copyReplacing: $/ withObject: Directory pathSeparator].
+ destCanon := Directory pathSeparator = $/
+    ifTrue: [destName]
+    ifFalse: [destName copyReplacing: $/ withObject: Directory pathSeparator].
+
+ src := srcCanon subStrings: Directory pathSeparator.
+ dest := destCanon subStrings: Directory pathSeparator.
  src := src asOrderedCollection.
  src removeLast.
  dest := dest asOrderedCollection.
@@ -208,7 +217,7 @@ size and timestamps.'>
  dest removeFirst].
  src collect: [:each | '..']].
  path addAllLast: dest.
- ^path fold: [:a :b | a , '/' , b]
+ ^path fold: [:a :b | a , Directory pathSeparatorString , b]
     ]
 
     File class >> checkError [

_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] mingw fix

Paolo Bonzini-2
Paul Butcher wrote:
> The remaining question is why libiconv wasn't detected to be present
> when libiconv.a was in the normal /mingw/lib location and
> /mingw/include/iconv.h was also present?

Which begs other questions:

- What does "gcc -print-search-dirs" print?

- does it help if --prefix=/mingw is passed to configure?

- are lib-ld.m4 and lib-link.m4 completely broken? :-(

(No, I don't want you to answer the last...)

Paolo


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk