help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-smalltalk] Building GNU Smalltalk-2.3.5 with MinGW


From: Paolo Bonzini
Subject: Re: [Help-smalltalk] Building GNU Smalltalk-2.3.5 with MinGW
Date: Fri, 15 Jun 2007 17:27:53 +0200
User-agent: Thunderbird 2.0.0.0 (Macintosh/20070326)

Akeroyd, FA (Freddie) wrote:
> Hi,
>
> I've been playing with compiling GNU Smalltalk-2.3.5 on MinGW and had
> some success.

Great!

> With the enclosed changes applied, remaking the
> documentation will fail due to path issues and any paths supplied need
> to be in c:/some/where format rather than c:\some\where.

The attached patch, on top of 2.3.5, is my take on this. It fixes all path issues, so the only things left should be:

1) modifying _gst_set_file_access_times to use the appropriate Windows API function

2) figuring out what to do with poll

3) figuring out why tests are failing without unix2dos. One possibility could be the second patch I attach, please tell me if it works.

Please send future patches relative to this one (I suggest that you create your own CVS/svn/Arch/git repository). Thanks!

Paolo

2007-06-15  Freddie Akeroyd  <address@hidden>
            Paolo Bonzini  <address@hidden>

        * kernel/Character.st: Add #isPathSeparator.
        * kernel/Directory.st: Use it; add special cases for Win32 systems.
        * kernel/File.st: Use it; add special cases for Win32 systems.
        * kernel/FileDescr.st: Look for :// instead of :/ to distinguish URIs.

        * libgst/cint.c: Remove my_utime.
        * libgst/sysdep.c: Move it here as _gst_set_file_access_times.
        * libgst/sysdep.h: Declare it.
        * libgst/dict.c: Add CSymbols.PathSeparator.


--- orig/Makefile.am
+++ mod/Makefile.am
@@ -107,7 +107,7 @@ DISTCLEANFILES += config.h
 
 # These two lines add a beatiful icon to the Win32 executable
 gsticon.o: gsticon.ico
-       echo ProgramIcon ICON `cygpath -w gsticon.ico` | windres -o gsticon.o
+       echo ProgramIcon ICON `$(CYGPATH_W) gsticon.ico` | windres -o gsticon.o
 
 gst.im: $(bin_PROGRAMS) $(srcdir)/kernel/stamp-classes
        SMALLTALK_KERNEL="`cd $(srcdir)/kernel; pwd`" \


--- orig/configure.ac
+++ mod/configure.ac
@@ -215,7 +215,7 @@ AC_REPLACE_FUNCS(putenv strdup strerror 
        getdtablesize strstr ftruncate floorl ceill sqrtl frexpl ldexpl asinl \
        acosl atanl logl expl tanl sinl cosl truncl lrintl strsep strpbrk)
 AC_CHECK_FUNCS_ONCE(gethostname memcpy memmove sighold uname sbrk usleep lstat 
\
-       grantpt popen getrusage gettimeofday getcwd fork strchr \
+       grantpt popen getrusage gettimeofday getcwd fork strchr utimes \
        sigsetmask alarm select mprotect madvise nl_langinfo waitpid \
        setsid spawnl nanosleep pread pwrite)
 


--- orig/kernel/Character.st
+++ mod/kernel/Character.st
@@ -258,6 +258,12 @@ isPunctuation
     ^(Table at: 1 + codePoint ifAbsent: [ 0 ]) = 4
 !
 
+isPathSeparator
+    "Returns true if self is a path separator ($/ or $\ under Windows,
+     $/ only under Unix systems including Mac OS X).
+    ^self == $/ or: [ self == Directory pathSeparator ]
+!
+
 isVowel
     "Returns true if self is a, e, i, o, or u; case insensitive"
     | char |


--- orig/kernel/Directory.st
+++ mod/kernel/Directory.st
@@ -106,26 +106,33 @@ append: fileName to: directory
     "Answer the name of a file named `fileName' which resides in a directory
      named `directory'."
     directory isEmpty ifTrue: [ ^fileName ].
-    (fileName at: 1) = self pathSeparator
-       ifTrue: [ ^fileName ].
-    (self pathSeparator = $\ and: [ fileName size >= 2 and: [
-       (fileName at: 2) = $: ]]) ifTrue: [ ^fileName ].
-    ^(directory at: directory size) = self pathSeparator
+    self pathSeparator == $\
+       ifFalse: [
+           (fileName at: 1) isPathSeparator ifTrue: [ ^fileName ] ]
+       ifTrue: [
+           (fileName at: 1) isPathSeparator ifTrue: [
+               ^(directory size >= 2 and: [ (directory at: 2) = $: ])
+                   ifTrue: [ '%1:%2' bindWith: directory first with: fileName ]
+                   ifFalse: [ fileName ] ].
+            (fileName size >= 2 and: [ (fileName at: 2) = $: ])
+               ifTrue: [ ^fileName ] ].
+
+    ^(directory at: directory size) isPathSeparator
        ifTrue: [ directory, fileName ]
        ifFalse: [ '%1%2%3'
            bindWith: directory
-           with: self pathSeparatorString
+           with: self pathSeparator
            with: fileName ]
 !
 
 pathSeparator
     "Answer (as a Character) the character used to separate directory names"
-    ^$/
+    ^CSymbols.PathSeparator
 !
 
 pathSeparatorString
     "Answer (in a String) the character used to separate directory names"
-    ^'/'
+    ^String with: self pathSeparator
 ! !
 
 


--- orig/kernel/File.st
+++ mod/kernel/File.st
@@ -132,9 +132,18 @@ fullNameFor: aString
     "Answer the full path to a file called `aString', resolving the `.' and
      `..' directory entries, and answer the result.  `/..' is the same as '/'."
 
-    | path substrings |
+    | path substrings result isAbsolute isWindows |
+
+    isAbsolute := (aString at: 1) isPathSeparator.
+    isWindows := Directory pathSeparator == $\.
+    "Windows paths starting X:/ are absolute"
+    (isWindows and: [
+        aString size >= 3 and: [ 
+       (aString at: 2) = $: and: [
+       (aString at: 3) isPathSeparator ]]]) ifTrue: [ isAbsolute := true ].
+
     path := OrderedCollection new.
-    (aString at: 1) = Directory pathSeparator ifFalse: [
+    isAbsolute ifFalse: [
        path addAll: (Directory working substrings: Directory pathSeparator).
     ].
     substrings := aString substrings: Directory pathSeparator.
@@ -148,9 +157,18 @@ fullNameFor: aString
        ]
     ].
 
-    ^path inject: '/' into: [ :old :each |
-       Directory append: each to: old
-    ]
+    result := path inject: Directory pathSeparatorString into: [ :old :each |
+       Directory append: each to: old
+    ].
+
+    "Remove initial / from /C:/"
+    ^(isWindows and: [
+       result size >= 4 and: [ 
+       (result at: 1) isPathSeparator and: [
+       (result at: 3) = $: and: [
+       (result at: 4) isPathSeparator ]]]])
+           ifTrue: [ result copyFrom: 2 ]
+           ifFalse: [ result ]
 !
 
 pathFrom: srcName to: destName


--- orig/kernel/FileDescr.st
+++ mod/kernel/FileDescr.st
@@ -103,7 +103,7 @@ open: fileName mode: fileMode
      finished with it anyway, using #close. To keep a file open even when
      no references exist anymore, send it #removeToBeFinalized"
 
-    ((fileName indexOfSubCollection: ':/') > 0 and: [
+    ((fileName indexOfSubCollection: '://') > 0 and: [
         fileMode = FileStream read ]) ifTrue: [
            ^NetClients.URIResolver openStreamOn: fileName ].
 


--- orig/libgst/cint.c
+++ mod/libgst/cint.c
@@ -332,22 +332,6 @@ get_errno (void)
 }
 
 int
-my_utime (const char *name,
-         long new_atime,
-         long new_mtime)
-{
-  struct timeval times[2];
-  int result;
-  times[0].tv_sec = new_atime + 86400 * 10957;
-  times[1].tv_sec = new_mtime + 86400 * 10957;
-  times[0].tv_usec = times[1].tv_usec = 0;
-  result = utimes (name, times);
-  if (!result)
-    errno = 0;
-  return (result);
-}
-
-int
 my_stat (const char *name,
         gst_stat * out)
 {
@@ -539,7 +523,7 @@ _gst_init_cfuncs (void)
   _gst_define_cfunc ("strerror", strerror);
   _gst_define_cfunc ("stat", my_stat);
   _gst_define_cfunc ("lstat", my_lstat);
-  _gst_define_cfunc ("utime", my_utime);
+  _gst_define_cfunc ("utime", _gst_set_file_access_times);
 
   _gst_define_cfunc ("opendir", my_opendir);
   _gst_define_cfunc ("closedir", closedir);


--- orig/libgst/dict.c
+++ mod/libgst/dict.c
@@ -1088,6 +1088,14 @@ init_c_symbols ()
 #define NAN (0.0 / 0.0)
 #endif
 
+#if defined WIN32 && !defined __CYGWIN__
+  NAMESPACE_AT_PUT (cSymbolsOOP, _gst_intern_string ("PathSeparator"),
+                   CHAR_OOP_AT ('\\'));
+#else
+  NAMESPACE_AT_PUT (cSymbolsOOP, _gst_intern_string ("PathSeparator"),
+                   CHAR_OOP_AT ('/'));
+#endif
+
   NAMESPACE_AT_PUT (cSymbolsOOP, _gst_intern_string ("CDoubleMin"),
                    floatd_new (DBL_MIN));
   NAMESPACE_AT_PUT (cSymbolsOOP, _gst_intern_string ("CDoubleMax"),


--- orig/libgst/sysdep.c
+++ mod/libgst/sysdep.c
@@ -745,6 +745,21 @@ _gst_get_cur_dir_name (void)
 }
 
 
+int
+_gst_set_file_access_times (const char *name, long new_atime, long new_mtime)
+{
+  struct timeval times[2];
+  int result;
+  times[0].tv_sec = new_atime + 86400 * 10957;
+  times[1].tv_sec = new_mtime + 86400 * 10957;
+  times[0].tv_usec = times[1].tv_usec = 0;
+  result = utimes (name, times);
+  if (!result)
+    errno = 0;
+  return (result);
+}
+
+
 char *
 _gst_get_full_file_name (const char *fileName)
 {


--- orig/libgst/sysdep.h
+++ mod/libgst/sysdep.h
@@ -138,6 +138,12 @@ extern time_t _gst_get_time (void)
 extern time_t _gst_get_file_modify_time (const char *fileName)
   ATTRIBUTE_HIDDEN;
 
+/* Sets the time when FILENAME was last modified.  The times are in
+   seconds, relative to 1 Jan 2000.  */
+extern int _gst_set_file_access_times (const char *name, long new_atime,
+                                      long new_mtime)
+  ATTRIBUTE_HIDDEN;
+
 /* Converts the given time (expressed in seconds since midnight Jan 1,
    1970, and in Universal Coordinated Time) into a local time.  */
 extern time_t _gst_adjust_time_zone (time_t t)



--- orig/tests/testsuite
+++ mod/tests/testsuite
@@ -1224,6 +1224,10 @@ else
   at_diff=diff
 fi
 
+if at_diff2=`diff --strip-trailing-cr "$at_devnull" "$at_devnull" 2>&1` && 
test -z "$at_diff2"
+then
+  at_diff="$at_diff --strip-trailing-cr"
+fi
 
 for at_group in $at_groups
 do

reply via email to

[Prev in Thread] Current Thread [Next in Thread]