_expect and other little tweaks
[p5sagit/p5-mst-13.2.git] / pp_ctl.c
index 8b320bf..9e73ca2 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -172,6 +172,7 @@ PP(pp_substcont)
     rxres_restore(&cx->sb_rxres, rx);
 
     if (cx->sb_iters++) {
+       I32 saviters = cx->sb_iters;
        if (cx->sb_iters > cx->sb_maxiters)
            DIE(aTHX_ "Substitution loop");
 
@@ -213,6 +214,7 @@ PP(pp_substcont)
            POPSUBST(cx);
            RETURNOP(pm->op_next);
        }
+       cx->sb_iters = saviters;
     }
     if (RX_MATCH_COPIED(rx) && rx->subbeg != orig) {
        m = s;
@@ -1018,8 +1020,8 @@ PP(pp_sort)
                cx->blk_sub.oldcurpad = PL_curpad;
                cx->blk_sub.argarray = av;
            }
-           qsortsv((myorigmark+1), max,
-                   is_xsub ? sortcv_xsub : hasargs ? sortcv_stacked : sortcv);
+           sortsv((myorigmark+1), max,
+                  is_xsub ? sortcv_xsub : hasargs ? sortcv_stacked : sortcv);
 
            POPBLOCK(cx,PL_curpm);
            PL_stack_sp = newsp;
@@ -1030,8 +1032,8 @@ PP(pp_sort)
     else {
        if (max > 1) {
            MEXTEND(SP, 20);    /* Can't afford stack realloc on signal. */
-           qsortsv(ORIGMARK+1, max,
-                   (PL_op->op_private & OPpSORT_NUMERIC)
+           sortsv(ORIGMARK+1, max,
+                  (PL_op->op_private & OPpSORT_NUMERIC)
                        ? ( (PL_op->op_private & OPpSORT_INTEGER)
                            ? ( overloading ? amagic_i_ncmp : sv_i_ncmp)
                            : ( overloading ? amagic_ncmp : sv_ncmp))
@@ -2591,6 +2593,7 @@ PP(pp_exit)
 #ifdef VMS
         if (anum == 1 && (PL_op->op_private & OPpEXIT_VMSISH))
            anum = 0;
+        VMSISH_HUSHED  = VMSISH_HUSHED || (PL_op->op_private & OPpHUSH_VMSISH);
 #endif
     }
     PL_exit_flags |= PERL_EXIT_EXPECTED;
@@ -3033,6 +3036,8 @@ PP(pp_require)
     SV *filter_state = 0;
     SV *filter_sub = 0;
     SV *hook_sv = 0;
+    SV *encoding;
+    OP *op;
 
     sv = POPs;
     if (SvNIOKp(sv)) {
@@ -3376,7 +3381,17 @@ trylocal: {
     PL_eval_owner = thr;
     MUTEX_UNLOCK(&PL_eval_mutex);
 #endif /* USE_5005THREADS */
-    return DOCATCH(doeval(gimme, NULL));
+
+    /* Store and reset encoding. */
+    encoding = PL_encoding;
+    PL_encoding = Nullsv;
+
+    op = DOCATCH(doeval(gimme, NULL));
+    
+    /* Restore encoding. */
+    PL_encoding = encoding;
+
+    return op;
 }
 
 PP(pp_dofile)
@@ -4036,8 +4051,18 @@ dynprep(pTHX_ gptr *list1, gptr *list2, size_t nmemb, SVCOMPARE_t cmp)
 ** They make convenient temporary pointers in other places.
 */
 
-STATIC void
-S_qsortsv(pTHX_ gptr *list1, size_t nmemb, SVCOMPARE_t cmp)
+/* 
+=for apidoc sortsv
+   
+Sort an array. Here is an example:
+
+    sortsv(AvARRAY(av), av_len(av)+1, Perl_sv_cmp_locale); 
+
+=cut
+*/
+    
+void
+Perl_sortsv(pTHX_ gptr *list1, size_t nmemb, SVCOMPARE_t cmp)
 {
     int i, run;
     int sense;