This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Non-Configure code required to implement a strict by default option
authorTodd Rinaldo <toddr@cpan.org>
Sun, 13 Sep 2020 18:05:29 +0000 (13:05 -0500)
committerSawyer X <xsawyerx@cpan.org>
Tue, 15 Sep 2020 14:37:44 +0000 (17:37 +0300)
perl.c
perl.h
pp_ctl.c

diff --git a/perl.c b/perl.c
index f54dc60..992cbc3 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -2085,6 +2085,7 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit)
     char c;
     bool doextract = FALSE;
     const char *cddir = NULL;
+    bool minus_e = FALSE; /* both -e and -E */
 #ifdef USE_SITECUSTOMIZE
     bool minus_f = FALSE;
 #endif
@@ -2167,6 +2168,7 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit)
            /* FALLTHROUGH */
        case 'e':
            forbid_setid('e', FALSE);
+        minus_e = TRUE;
            if (!PL_e_script) {
                PL_e_script = newSVpvs("");
                add_read_e_script = TRUE;
@@ -2548,6 +2550,8 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit)
        filter_add(read_e_script, NULL);
 
     /* now parse the script */
+    if (minus_e == FALSE)
+        PL_hints |= HINTS_DEFAULT; /* after init_main_stash ; need to be after init_predump_symbols */
 
     SETERRNO(0,SS_NORMAL);
     if (yyparse(GRAMPROG) || PL_parser->error_count) {
diff --git a/perl.h b/perl.h
index ef8ada7..5a48146 100644 (file)
--- a/perl.h
+++ b/perl.h
@@ -5346,6 +5346,16 @@ typedef enum {
 #define HINT_SORT_STABLE       0x00000100 /* sort styles */
 #define HINT_SORT_UNSTABLE     0x00000200
 
+#define HINT_ALL_STRICT       HINT_STRICT_REFS \
+                            | HINT_STRICT_SUBS \
+                            | HINT_STRICT_VARS
+
+#ifdef USE_STRICT_BY_DEFAULT
+#define HINTS_DEFAULT            HINT_ALL_STRICT
+#else
+#define HINTS_DEFAULT            0
+#endif
+
 /* flags for PL_sawampersand */
 
 #define SAWAMPERSAND_LEFT       1   /* saw $` */
index 6fcaaef..d05dec3 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -3485,7 +3485,7 @@ S_doeval_compile(pTHX_ U8 gimme, CV* outside, U32 seq, HV *hh)
 
     SAVEHINTS();
     if (clear_hints) {
-       PL_hints = 0;
+       PL_hints = HINTS_DEFAULT;
        hv_clear(GvHV(PL_hintgv));
         CLEARFEATUREBITS();
     }