backtick commands via PERL5SHELL. See L<perlrun>.
Perl does not depend on the registry, but it can look up certain default
-values if you choose to put them there. On Perl process start Perl checks if
+values if you choose to put them there unless disabled at build time with
+USE_NO_REGISTRY. On Perl process start Perl checks if
C<HKEY_CURRENT_USER\Software\Perl> and C<HKEY_LOCAL_MACHINE\Software\Perl>
exist. If the keys exists, they will be checked for remainder of the Perl
process's run life for certain entries. Entries in
#endif
#ifdef WIN32
typedef unsigned long (*LPEnvOsID)(struct IPerlEnv*);
-typedef char* (*LPEnvLibPath)(struct IPerlEnv*, const char*,
+typedef char* (*LPEnvLibPath)(struct IPerlEnv*, WIN32_NO_REGISTRY_M_(const char*)
STRLEN *const len);
typedef char* (*LPEnvSiteLibPath)(struct IPerlEnv*, const char*,
STRLEN *const len);
#define PerlEnv_os_id() \
(*PL_Env->pEnvOsID)(PL_Env)
#define PerlEnv_lib_path(str, lenp) \
- (*PL_Env->pLibPath)(PL_Env,(str),(lenp))
+ (*PL_Env->pLibPath)(PL_Env,WIN32_NO_REGISTRY_M_(str)(lenp))
#define PerlEnv_sitelib_path(str, lenp) \
(*PL_Env->pSiteLibPath)(PL_Env,(str),(lenp))
#define PerlEnv_vendorlib_path(str, lenp) \
#ifdef WIN32
#define PerlEnv_os_id() win32_os_id()
-#define PerlEnv_lib_path(str, lenp) win32_get_privlib(str, lenp)
+#define PerlEnv_lib_path(str, lenp) win32_get_privlib(WIN32_NO_REGISTRY_M_(str) lenp)
#define PerlEnv_sitelib_path(str, lenp) win32_get_sitelib(str, lenp)
#define PerlEnv_vendorlib_path(str, lenp) win32_get_vendorlib(str, lenp)
#define PerlEnv_get_child_IO(ptr) win32_get_child_IO(ptr)
# ifdef USE_LOCALE_CTYPE
" USE_LOCALE_CTYPE"
# endif
+# ifdef WIN32_NO_REGISTRY
+ " USE_NO_REGISTRY"
+# endif
# ifdef USE_PERL_ATOF
" USE_PERL_ATOF"
# endif
=item *
+A new build option C<USE_NO_REGISTRY> has been added to the makefiles. This
+option is off by default, meaning the default is to do Windows registry lookups.
+This option stops Perl from looking inside the registry for anything. For what
+values are looked up in the registry see L<perlwin32>. Internally, in C, the
+name of this option is C<WIN32_NO_REGISTRY>.
+
+=item *
+
The behavior of Perl using C<HKEY_CURRENT_USER\Software\Perl> and
C<HKEY_LOCAL_MACHINE\Software\Perl> to lookup certain values, including
C<%ENV> vars starting with C<PERL> has changed. Previously, the 2 keys were
#USE_64_BIT_INT = define
#
+# Uncomment this if you want to disable looking up values from
+# HKEY_CURRENT_USER\Software\Perl and HKEY_LOCAL_MACHINE\Software\Perl in
+# the Registry.
+#
+#USE_NO_REGISTRY = define
+
+#
# uncomment exactly one of the following
#
# Visual C++ 6.0 (aka Visual C++ 98)
USE_64_BIT_INT = undef
!ENDIF
+!IF "$(USE_NO_REGISTRY)" == ""
+USE_NO_REGISTRY = undef
+!ENDIF
+
!IF "$(USE_IMP_SYS)$(USE_MULTI)" == "defineundef"
USE_MULTI = define
!ENDIF
BUILDOPT = $(BUILDOPT) -DPERL_IMPLICIT_SYS
!ENDIF
+!IF "$(USE_NO_REGISTRY)" != "undef"
+BUILDOPT = $(BUILDOPT) -DWIN32_NO_REGISTRY
+!ENDIF
+
!IF "$(PROCESSOR_ARCHITECTURE)" == ""
PROCESSOR_ARCHITECTURE = x86
!ENDIF
# All but the free version of VC++ 7.1 can load DLLs on demand. Makes the test
# suite run in about 10% less time.
!IF "$(CCTYPE)" != "MSVC70FREE"
+# If no registry, advapi32 is only used for Perl_pp_getlogin/getlogin/GetUserNameA
+# which is rare to execute
+!IF "$(USE_NO_REGISTRY)" != "undef"
+DELAYLOAD = -DELAYLOAD:ws2_32.dll -DELAYLOAD:advapi32.dll delayimp.lib
+MINIDELAYLOAD =
+!ELSE
DELAYLOAD = -DELAYLOAD:ws2_32.dll delayimp.lib
+#miniperl never does any registry lookups
+MINIDELAYLOAD = -DELAYLOAD:advapi32.dll
+!ENDIF
!ENDIF
# Visual C++ 2005 and 2008 (VC++ 8.0 and 9.0) create manifest files for EXEs and
..\lib\buildcustomize.pl : $(MINIDIR) $(MINI_OBJ) ..\write_buildcustomize.pl
$(LINK32) -out:$(MINIPERL) @<<
- $(BLINK_FLAGS) $(DELAYLOAD) $(LIBFILES) $(MINI_OBJ)
+ $(BLINK_FLAGS) $(DELAYLOAD) $(MINIDELAYLOAD) $(LIBFILES) $(MINI_OBJ)
<<
$(EMBED_EXE_MANI:..\lib\buildcustomize.pl=..\miniperl.exe)
$(MINIPERL) -I..\lib -f ..\write_buildcustomize.pl ..
#USE_LONG_DOUBLE *=define
#
+# Uncomment this if you want to disable looking up values from
+# HKEY_CURRENT_USER\Software\Perl and HKEY_LOCAL_MACHINE\Software\Perl in
+# the Registry.
+#
+#USE_NO_REGISTRY *=define
+
+#
# uncomment exactly one of the following
#
# Visual C++ 6.0 (aka Visual C++ 98)
USE_LARGE_FILES *= undef
USE_64_BIT_INT *= undef
USE_LONG_DOUBLE *= undef
+USE_NO_REGISTRY *= undef
.IF "$(USE_IMP_SYS)" == "define"
PERL_MALLOC = undef
BUILDOPT += -DPERL_IMPLICIT_SYS
.ENDIF
+.IF "$(USE_NO_REGISTRY)" != "undef"
+BUILDOPT += -DWIN32_NO_REGISTRY
+.ENDIF
+
PROCESSOR_ARCHITECTURE *= x86
.IF "$(WIN64)" == "undef"
# All but the free version of VC++ 7.1 can load DLLs on demand. Makes the test
# suite run in about 10% less time.
.IF "$(CCTYPE)" != "MSVC70FREE"
+# If no registry, advapi32 is only used for Perl_pp_getlogin/getlogin/GetUserNameA
+# which is rare to execute
+.IF "$(USE_NO_REGISTRY)" != "undef"
+DELAYLOAD = -DELAYLOAD:ws2_32.dll -DELAYLOAD:advapi32.dll delayimp.lib
+MINIDELAYLOAD =
+.ELSE
DELAYLOAD = -DELAYLOAD:ws2_32.dll delayimp.lib
+#miniperl never does any registry lookups
+MINIDELAYLOAD = -DELAYLOAD:advapi32.dll
+.ENDIF
.ENDIF
# Visual C++ 2005 and 2008 (VC++ 8.0 and 9.0) create manifest files for EXEs and
$(mktmp $(LKPRE) $(MINI_OBJ) $(LIBFILES) $(LKPOST))
.ELSE
$(LINK32) -out:$(MINIPERL) $(BLINK_FLAGS) \
- @$(mktmp $(DELAYLOAD) $(LIBFILES) $(MINI_OBJ))
+ @$(mktmp $(DELAYLOAD) $(MINIDELAYLOAD) $(LIBFILES) $(MINI_OBJ))
$(EMBED_EXE_MANI:s/$@/$(MINIPERL)/)
.ENDIF
$(MINIPERL) -I..\lib -f ..\write_buildcustomize.pl ..
}
char*
-PerlEnvLibPath(struct IPerlEnv* piPerl, const char *pl, STRLEN *const len)
+PerlEnvLibPath(struct IPerlEnv* piPerl, WIN32_NO_REGISTRY_M_(const char *pl) STRLEN *const len)
{
- return win32_get_privlib(pl, len);
+ return win32_get_privlib(WIN32_NO_REGISTRY_M_(pl) len);
}
char*
unsigned int line, uintptr_t pReserved);
#endif
+#ifndef WIN32_NO_REGISTRY
static char* get_regstr_from(HKEY hkey, const char *valuename, SV **svp);
static char* get_regstr(const char *valuename, SV **svp);
+#endif
+
static char* get_emd_part(SV **prev_pathp, STRLEN *const len,
char *trailing, ...);
-static char* win32_get_xlib(const char *pl, const char *xlib,
+static char* win32_get_xlib(const char *pl,
+ WIN32_NO_REGISTRY_M_(const char *xlib)
const char *libname, STRLEN *const len);
+
static BOOL has_shell_metachars(const char *ptr);
static long tokenize(const char *str, char **dest, char ***destv);
static void get_shell(void);
static OSVERSIONINFO g_osver = {0, 0, 0, 0, 0, ""};
+#ifndef WIN32_NO_REGISTRY
/* initialized by Perl_win32_init/PERL_SYS_INIT */
static HKEY HKCU_Perl_hnd;
static HKEY HKLM_Perl_hnd;
+#endif
#ifdef SET_INVALID_PARAMETER_HANDLER
static BOOL silent_invalid_parameter_handler = FALSE;
}
}
+#ifndef WIN32_NO_REGISTRY
/* *svp (if non-NULL) is expected to be POK (valid allocated SvPVX(*svp)) */
static char*
get_regstr_from(HKEY handle, const char *valuename, SV **svp)
}
return str;
}
+#endif /* ifndef WIN32_NO_REGISTRY */
/* *prev_pathp (if non-NULL) is expected to be POK (valid allocated SvPVX(sv)) */
static char *
}
EXTERN_C char *
-win32_get_privlib(const char *pl, STRLEN *const len)
+win32_get_privlib(WIN32_NO_REGISTRY_M_(const char *pl) STRLEN *const len)
{
char *stdlib = "lib";
- char buffer[MAX_PATH+1];
SV *sv = NULL;
+#ifndef WIN32_NO_REGISTRY
+ char buffer[MAX_PATH+1];
/* $stdlib = $HKCU{"lib-$]"} || $HKLM{"lib-$]"} || $HKCU{"lib"} || $HKLM{"lib"} || ""; */
sprintf(buffer, "%s-%s", stdlib, pl);
if (!get_regstr(buffer, &sv))
(void)get_regstr(stdlib, &sv);
+#endif
/* $stdlib .= ";$EMD/../../lib" */
return get_emd_part(&sv, len, stdlib, ARCHNAME, "bin", NULL);
}
static char *
-win32_get_xlib(const char *pl, const char *xlib, const char *libname,
- STRLEN *const len)
+win32_get_xlib(const char *pl, WIN32_NO_REGISTRY_M_(const char *xlib)
+ const char *libname, STRLEN *const len)
{
+#ifndef WIN32_NO_REGISTRY
char regstr[40];
+#endif
char pathstr[MAX_PATH+1];
SV *sv1 = NULL;
SV *sv2 = NULL;
+#ifndef WIN32_NO_REGISTRY
/* $HKCU{"$xlib-$]"} || $HKLM{"$xlib-$]"} . ---; */
sprintf(regstr, "%s-%s", xlib, pl);
(void)get_regstr(regstr, &sv1);
+#endif
/* $xlib .=
* ";$EMD/" . ((-d $EMD/../../../$]) ? "../../.." : "../.."). "/$libname/$]/lib"; */
sprintf(pathstr, "%s/%s/lib", libname, pl);
(void)get_emd_part(&sv1, NULL, pathstr, ARCHNAME, "bin", pl, NULL);
+#ifndef WIN32_NO_REGISTRY
/* $HKCU{$xlib} || $HKLM{$xlib} . ---; */
(void)get_regstr(xlib, &sv2);
+#endif
/* $xlib .=
* ";$EMD/" . ((-d $EMD/../../../$]) ? "../../.." : "../.."). "/$libname/lib"; */
EXTERN_C char *
win32_get_sitelib(const char *pl, STRLEN *const len)
{
- return win32_get_xlib(pl, "sitelib", "site", len);
+ return win32_get_xlib(pl, WIN32_NO_REGISTRY_M_("sitelib") "site", len);
}
#ifndef PERL_VENDORLIB_NAME
EXTERN_C char *
win32_get_vendorlib(const char *pl, STRLEN *const len)
{
- return win32_get_xlib(pl, "vendorlib", PERL_VENDORLIB_NAME, len);
+ return win32_get_xlib(pl, WIN32_NO_REGISTRY_M_("vendorlib") PERL_VENDORLIB_NAME, len);
}
static BOOL
}
FreeEnvironmentStrings(envv);
}
+#ifndef WIN32_NO_REGISTRY
else {
/* last ditch: allow any environment variables that begin with 'PERL'
to be obtained from the registry, if found there */
if (strncmp(name, "PERL", 4) == 0)
(void)get_regstr(name, &curitem);
}
+#endif
}
if (curitem && SvCUR(curitem))
return SvPVX(curitem);
#endif
ansify_path();
+
+#ifndef WIN32_NO_REGISTRY
{
LONG retval;
retval = RegOpenKeyExW(HKEY_CURRENT_USER, L"SOFTWARE\\Perl", 0, KEY_READ, &HKCU_Perl_hnd);
HKLM_Perl_hnd = NULL;
}
}
+#endif
}
void
OP_REFCNT_TERM;
PERLIO_TERM;
MALLOC_TERM;
+#ifndef WIN32_NO_REGISTRY
/* handles might be NULL, RegCloseKey then returns ERROR_INVALID_HANDLE
but no point of checking and we can't die() at this point */
RegCloseKey(HKLM_Perl_hnd);
RegCloseKey(HKCU_Perl_hnd);
/* the handles are in an undefined state until the next PERL_SYS_INIT3 */
+#endif
}
void
/* less I/O calls during each require */
# define PERL_DISABLE_PMC
+/* unnecessery for miniperl to lookup anything from an "installed" perl */
+# define WIN32_NO_REGISTRY
+
/* allow minitest to work */
# define PERL_TEXTMODE_SCRIPTS
#endif
# define PERL_SOCK_SYSWRITE_IS_SEND
#endif
+#ifdef WIN32_NO_REGISTRY
+/* the last _ in WIN32_NO_REGISTRY_M_ is like the _ in aTHX_ */
+# define WIN32_NO_REGISTRY_M_(x)
+#else
+# define WIN32_NO_REGISTRY_M_(x) x,
+#endif
+
#define PERL_NO_FORCE_LINK /* no need for PL_force_link_funcs */
#define ENV_IS_CASELESS
DllExport int win32_async_check(pTHX);
extern int my_fclose(FILE *);
-extern char * win32_get_privlib(const char *pl, STRLEN *const len);
+extern char * win32_get_privlib(WIN32_NO_REGISTRY_M_(const char *pl) STRLEN *const len);
extern char * win32_get_sitelib(const char *pl, STRLEN *const len);
extern char * win32_get_vendorlib(const char *pl, STRLEN *const len);
}
char *
-win32_get_privlib(const char *pl, STRLEN *const len)
+win32_get_privlib(WIN32_NO_REGISTRY_M_(const char *pl) STRLEN *const len)
{
dTHX;
char *stdlib = "lib";