Windows miscellany
authorGurusamy Sarathy <gsar@cpan.org>
Wed, 1 Mar 2000 03:38:03 +0000 (03:38 +0000)
committerGurusamy Sarathy <gsar@cpan.org>
Wed, 1 Mar 2000 03:38:03 +0000 (03:38 +0000)
p4raw-id: //depot/perl@5388

pod/perlguts.pod
win32/perllib.c
win32/win32.c
win32/win32.h

index 2686c39..58bcea3 100644 (file)
@@ -1672,14 +1672,14 @@ Thus, something like:
 in your extesion will translate to this when PERL_IMPLICIT_CONTEXT is
 in effect:
 
-        Perl_sv_setsv(GetPerlInterpreter(), asv, bsv);
+        Perl_sv_setsv(Perl_get_context(), asv, bsv);
 
 or to this otherwise:
 
         Perl_sv_setsv(asv, bsv);
 
 You have to do nothing new in your extension to get this; since
-the Perl library provides GetPerlInterpreter(), it will all just
+the Perl library provides Perl_get_context(), it will all just
 work.
 
 The second, more efficient way is to use the following template for
index 3aed241..2a0cb85 100644 (file)
@@ -334,6 +334,9 @@ RunPerl(int argc, char **argv, char **env)
     return (exitstatus);
 }
 
+EXTERN_C void
+set_w32_module_name(void);
+
 BOOL APIENTRY
 DllMain(HANDLE hModule,                /* DLL module handle */
        DWORD fdwReason,        /* reason called */
@@ -353,6 +356,7 @@ DllMain(HANDLE hModule,             /* DLL module handle */
 #endif
        DisableThreadLibraryCalls((HMODULE)hModule);
        w32_perldll_handle = hModule;
+       set_w32_module_name();
        break;
 
        /* The DLL is detaching from a process due to
index 54f0455..5fb1f46 100644 (file)
@@ -124,6 +124,30 @@ IsWinNT(void)
     return (win32_os_id() == VER_PLATFORM_WIN32_NT);
 }
 
+EXTERN_C void
+set_w32_module_name(void)
+{
+    char* ptr;
+    GetModuleFileName((HMODULE)((w32_perldll_handle == INVALID_HANDLE_VALUE)
+                               ? GetModuleHandle(NULL)
+                               : w32_perldll_handle),
+                     w32_module_name, sizeof(w32_module_name));
+
+    /* try to get full path to binary (which may be mangled when perl is
+     * run from a 16-bit app) */
+    /*PerlIO_printf(Perl_debug_log, "Before %s\n", w32_module_name);*/
+    (void)win32_longpath(w32_module_name);
+    /*PerlIO_printf(Perl_debug_log, "After  %s\n", w32_module_name);*/
+
+    /* normalize to forward slashes */
+    ptr = w32_module_name;
+    while (*ptr) {
+       if (*ptr == '\\')
+           *ptr = '/';
+       ++ptr;
+    }
+}
+
 /* *svp (if non-NULL) is expected to be POK (valid allocated SvPVX(*svp)) */
 static char*
 get_regstr_from(HKEY hkey, const char *valuename, SV **svp)
@@ -186,24 +210,7 @@ get_emd_part(SV **prev_pathp, char *trailing_path, ...)
     baselen = strlen(base);
 
     if (!*w32_module_name) {
-       GetModuleFileName((HMODULE)((w32_perldll_handle == INVALID_HANDLE_VALUE)
-                                   ? GetModuleHandle(NULL)
-                                   : w32_perldll_handle),
-                         w32_module_name, sizeof(w32_module_name));
-
-       /* try to get full path to binary (which may be mangled when perl is
-        * run from a 16-bit app) */
-       /*PerlIO_printf(Perl_debug_log, "Before %s\n", w32_module_name);*/
-       (void)win32_longpath(w32_module_name);
-       /*PerlIO_printf(Perl_debug_log, "After  %s\n", w32_module_name);*/
-
-       /* normalize to forward slashes */
-       ptr = w32_module_name;
-       while (*ptr) {
-           if (*ptr == '\\')
-               *ptr = '/';
-           ++ptr;
-       }
+       set_w32_module_name();
     }
     strcpy(mod_name, w32_module_name);
     ptr = strrchr(mod_name, '/');
index bbf88bb..b0ccd14 100644 (file)
 #  define win32_get_sitelib PerlEnv_sitelib_path
 #endif
 
-#if defined(PERL_IMPLICIT_CONTEXT)
-/* compat */
-#  define GetPerlInterpreter   Perl_get_context
-#  define SetPerlInterpreter   Perl_set_context
-#endif
-
 #ifdef __GNUC__
 #  ifndef __int64              /* some versions seem to #define it already */
 #    define __int64 long long