[patch@31988] Revised Module::Build fixes for VMS.
[p5sagit/p5-mst-13.2.git] / win32 / perlhost.h
index 3860507..9974fd8 100644 (file)
@@ -989,7 +989,14 @@ PerlLIOFileStat(struct IPerlLIO* piPerl, int handle, Stat_t *buffer)
 int
 PerlLIOIOCtl(struct IPerlLIO* piPerl, int i, unsigned int u, char *data)
 {
-    return win32_ioctlsocket((SOCKET)i, (long)u, (u_long*)data);
+    u_long u_long_arg;
+    int retval;
+
+    /* mauke says using memcpy avoids alignment issues */
+    memcpy(&u_long_arg, data, sizeof u_long_arg); 
+    retval = win32_ioctlsocket((SOCKET)i, (long)u, &u_long_arg);
+    memcpy(data, &u_long_arg, sizeof u_long_arg);
+    return retval;
 }
 
 int
@@ -2238,32 +2245,6 @@ CPerlHost::FreeLocalEnvironmentStrings(LPSTR lpStr)
     Safefree(lpStr);
 }
 
-static char *
-get_valid_filename(pTHX_ WCHAR *widename)
-{
-    char *name;
-    BOOL use_default = FALSE;
-    size_t widelen = wcslen(widename)+1;
-    int len = WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, widename, widelen,
-                                  NULL, 0, NULL, NULL);
-    Newx(name, len, char);
-    WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, widename, widelen,
-                        name, len, NULL, &use_default);
-    if (use_default) {
-        WCHAR *shortname;
-        DWORD shortlen = GetShortPathNameW(widename, NULL, 0);
-        Newx(shortname, shortlen, WCHAR);
-        shortlen = GetShortPathNameW(widename, shortname, shortlen)+1;
-        len = WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, shortname, shortlen,
-                                  NULL, 0, NULL, NULL);
-        Renew(name, len, char);
-        WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, shortname, shortlen,
-                            name, len, NULL, NULL);
-        Safefree(shortname);
-    }
-    return name;
-}
-
 char*
 CPerlHost::GetChildDir(void)
 {
@@ -2271,15 +2252,8 @@ CPerlHost::GetChildDir(void)
     char* ptr;
     size_t length;
 
-    if (IsWin95()) {
-        Newx(ptr, MAX_PATH+1, char);
-        m_pvDir->GetCurrentDirectoryA(MAX_PATH+1, ptr);
-    }
-    else {
-        WCHAR path[MAX_PATH+1];
-        m_pvDir->GetCurrentDirectoryW(MAX_PATH+1, path);
-        ptr = get_valid_filename(aTHX_ path);
-    }
+    Newx(ptr, MAX_PATH+1, char);
+    m_pvDir->GetCurrentDirectoryA(MAX_PATH+1, ptr);
     length = strlen(ptr);
     if (length > 3) {
         if ((ptr[length-1] == '\\') || (ptr[length-1] == '/'))