Avoid setting $! if the sitecustomize script doesn't exist.
Nicholas Clark [Tue, 15 Sep 2009 12:56:31 +0000 (13:56 +0100)]
perl.c

diff --git a/perl.c b/perl.c
index 7876adf..6cf99f1 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -1942,8 +1942,13 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit)
 
 #ifdef USE_SITECUSTOMIZE
     if (!minus_f) {
+       /* SITELIB_EXP is a function call on Win32.
+          The games with local $! are to avoid setting errno if there is no
+          sitecustomize script.  */
+       const char *const sitelib = SITELIB_EXP;
        (void)Perl_av_create_and_unshift_one(aTHX_ &PL_preambleav,
-                                            Perl_newSVpvf(aTHX_ "BEGIN { do '%s/sitecustomize.pl' }", SITELIB_EXP));
+                                            Perl_newSVpvf(aTHX_
+                                                          "BEGIN { do {local $!; -f '%s/sitecustomize.pl'} && do '%s/sitecustomize.pl' }", sitelib, sitelib));
     }
 #endif