--- function.c	2006-04-01 10:36:40.000000000 +0400
+++ function.c.fixed	2008-06-27 14:15:49.000000000 +0400
@@ -28,6 +28,10 @@
 #include "amiga.h"
 #endif
 
+#ifdef WINDOWS32
+#include "pathstuff.h"
+#endif
+
 
 struct function_table_entry
   {
@@ -1883,13 +1887,56 @@
 {
   char *dest;
   const char *start, *end, *apath_limit;
+#ifdef WINDOWS32
+  const int root_offset = 3;
+  char drive_name[3];
+#else
+  const int root_offset = 1;
+#endif
 
   if (name[0] == '\0' || apath == NULL)
     return NULL;
 
   apath_limit = apath + GET_PATH_MAX;
 
-  if (name[0] != '/')
+#ifdef WINDOWS32
+  if (name[0] == '/' || name[1] == ':')
+    {
+      if(name[0] == '/')
+        {
+          /* Case "/foo/bar", so begin abspath with the drive letter of the current disk */
+          if(!starting_directory || starting_directory[0] == '\0' || starting_directory[1] != ':')
+            return NULL;
+          strncpy(apath, starting_directory, 2);
+          apath[2] = 0;
+        }
+      else
+        {
+          strncpy(drive_name, name, 2);
+          drive_name[2] = '\0';
+          if(name[2] == '/' || name[2] == '\\')
+          {
+            /* Case "x:/" or "x:/foo/bar", so begin abspath with the "x:" */
+            strcpy(apath, drive_name);
+          }
+          else
+          {
+            /* Case "x:" or "x:foo/bar", so begin abspath with the current directory on drive x: */
+            strcpy(apath, w32ify(drive_name, 1));
+          }
+          name += 2;
+        }
+      dest = strchr (apath, '\0');
+      *dest++ = '/';
+    }
+#else
+  if (name[0] == '/')
+    {
+      apath[0] = '/';
+      dest = apath + 1;
+    }
+#endif
+  else
     {
       /* It is unlikely we would make it until here but just to make sure. */
       if (!starting_directory)
@@ -1899,22 +1946,25 @@
 
       dest = strchr (apath, '\0');
     }
-  else
-    {
-      apath[0] = '/';
-      dest = apath + 1;
-    }
 
   for (start = end = name; *start != '\0'; start = end)
     {
       unsigned long len;
 
       /* Skip sequence of multiple path-separators.  */
-      while (*start == '/')
+      while (*start == '/'
+#ifdef WINDOWS32
+             || *start == '\\'
+#endif
+      )
 	++start;
 
       /* Find end of path component.  */
-      for (end = start; *end != '\0' && *end != '/'; ++end)
+      for (end = start; *end != '\0' && *end != '/'
+#ifdef WINDOWS32
+                                     && *end != '\\'
+#endif
+                                                   ; ++end)
         ;
 
       len = end - start;
@@ -1926,7 +1976,7 @@
       else if (len == 2 && start[0] == '.' && start[1] == '.')
 	{
 	  /* Back up to previous component, ignore if at root already.  */
-	  if (dest > apath + 1)
+	  if (dest > apath + root_offset)
 	    while ((--dest)[-1] != '/');
 	}
       else
@@ -1944,7 +1994,7 @@
     }
 
   /* Unless it is root strip trailing separator.  */
-  if (dest > apath + 1 && dest[-1] == '/')
+  if (dest > apath + root_offset && dest[-1] == '/')
     --dest;
 
   *dest = '\0';
