This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Correct spaces in MANIFEST.
[perl5.git] / mathoms.c
index 082a2ff..626bbb3 100644 (file)
--- a/mathoms.c
+++ b/mathoms.c
@@ -1,6 +1,6 @@
 /*    mathoms.c
  *
- *    Copyright (C) 2005, 2006, 2007, 2007, by Larry Wall and others
+ *    Copyright (C) 2005, 2006, 2007, 2008 by Larry Wall and others
  *
  *    You may distribute under the terms of either the GNU General Public
  *    License or the Artistic License, as specified in the README file.
@@ -8,13 +8,15 @@
  */
 
 /*
- * "Anything that Hobbits had no immediate use for, but were unwilling to 
- * throw away, they called a mathom. Their dwellings were apt to become
- * rather crowded with mathoms, and many of the presents that passed from
- * hand to hand were of that sort." 
+ *  Anything that Hobbits had no immediate use for, but were unwilling to
+ *  throw away, they called a mathom.  Their dwellings were apt to become
+ *  rather crowded with mathoms, and many of the presents that passed from
+ *  hand to hand were of that sort.
+ *
+ *     [p.5 of _The Lord of the Rings_: "Prologue"]
  */
 
-#ifndef NO_MATHOMS
+
 
 /* 
  * This file contains mathoms, various binary artifacts from previous
 #define PERL_IN_MATHOMS_C
 #include "perl.h"
 
+#ifdef NO_MATHOMS
+/* ..." warning: ISO C forbids an empty source file"
+   So make sure we have something in here by processing the headers anyway.
+ */
+#else
+
 PERL_CALLCONV OP * Perl_ref(pTHX_ OP *o, I32 type);
 PERL_CALLCONV void Perl_sv_unref(pTHX_ SV *sv);
 PERL_CALLCONV void Perl_sv_taint(pTHX_ SV *sv);
@@ -68,6 +76,7 @@ PERL_CALLCONV int Perl_printf_nocontext(const char *format, ...);
 PERL_CALLCONV int Perl_magic_setglob(pTHX_ SV* sv, MAGIC* mg);
 PERL_CALLCONV AV * Perl_newAV(pTHX);
 PERL_CALLCONV HV * Perl_newHV(pTHX);
+PERL_CALLCONV IO * Perl_newIO(pTHX);
 
 /* ref() is now a macro using Perl_doref;
  * this version provided for binary compatibility only.
@@ -602,30 +611,7 @@ Perl_hv_magic(pTHX_ HV *hv, GV *gv, int how)
 {
     PERL_ARGS_ASSERT_HV_MAGIC;
 
-    sv_magic((SV*)hv, (SV*)gv, how, NULL, 0);
-}
-
-AV *
-Perl_av_fake(pTHX_ register I32 size, register SV **strp)
-{
-    register SV** ary;
-    register AV * const av = (AV*)newSV_type(SVt_PVAV);
-
-    PERL_ARGS_ASSERT_AV_FAKE;
-
-    Newx(ary,size+1,SV*);
-    AvALLOC(av) = ary;
-    Copy(strp,ary,size,SV*);
-    AvREIFY_only(av);
-    AvARRAY(av) = ary;
-    AvFILLp(av) = size - 1;
-    AvMAX(av) = size - 1;
-    while (size--) {
-        assert (*strp);
-        SvTEMP_off(*strp);
-        strp++;
-    }
-    return av;
+    sv_magic(MUTABLE_SV(hv), MUTABLE_SV(gv), how, NULL, 0);
 }
 
 bool
@@ -695,25 +681,16 @@ Perl_init_i18nl14n(pTHX_ int printwarn)
     return init_i18nl10n(printwarn);
 }
 
-OP *
-Perl_oopsCV(pTHX_ OP *o)
-{
-    PERL_ARGS_ASSERT_OOPSCV;
-
-    Perl_croak(aTHX_ "NOT IMPL LINE %d",__LINE__);
-    /* STUB */
-    PERL_UNUSED_ARG(o);
-    NORETURN_FUNCTION_END;
-}
-
 PP(pp_padany)
 {
     DIE(aTHX_ "NOT IMPL LINE %d",__LINE__);
+    return NORMAL;
 }
 
 PP(pp_mapstart)
 {
     DIE(aTHX_ "panic: mapstart");      /* uses grepstart */
+    return NORMAL;
 }
 
 /* These ops all have the same body as pp_null.  */
@@ -1274,14 +1251,6 @@ Perl_sv_usepvn(pTHX_ SV *sv, char *ptr, STRLEN len)
     sv_usepvn_flags(sv,ptr,len, 0);
 }
 
-void
-Perl_cv_ckproto(pTHX_ const CV *cv, const GV *gv, const char *p)
-{
-    PERL_ARGS_ASSERT_CV_CKPROTO;
-
-    cv_ckproto_len(cv, gv, p, p ? strlen(p) : 0);
-}
-
 /*
 =for apidoc unpack_str
 
@@ -1353,8 +1322,8 @@ Perl_hv_delete_ent(pTHX_ HV *hv, SV *keysv, I32 flags, U32 hash)
 {
     PERL_ARGS_ASSERT_HV_DELETE_ENT;
 
-    return (SV *) hv_common(hv, keysv, NULL, 0, 0, flags | HV_DELETE, NULL,
-                           hash);
+    return MUTABLE_SV(hv_common(hv, keysv, NULL, 0, 0, flags | HV_DELETE, NULL,
+                               hash));
 }
 
 SV**
@@ -1436,8 +1405,8 @@ Perl_hv_delete(pTHX_ HV *hv, const char *key, I32 klen_i32, I32 flags)
        klen = klen_i32;
        k_flags = 0;
     }
-    return (SV *) hv_common(hv, NULL, key, klen, k_flags, flags | HV_DELETE,
-                           NULL, 0);
+    return MUTABLE_SV(hv_common(hv, NULL, key, klen, k_flags, flags | HV_DELETE,
+                               NULL, 0));
 }
 
 /* Functions after here were made mathoms post 5.10.0 but pre 5.8.9 */
@@ -1445,7 +1414,7 @@ Perl_hv_delete(pTHX_ HV *hv, const char *key, I32 klen_i32, I32 flags)
 AV *
 Perl_newAV(pTHX)
 {
-    return (AV*)newSV_type(SVt_PVAV);
+    return MUTABLE_AV(newSV_type(SVt_PVAV));
     /* sv_upgrade does AvREAL_only():
     AvALLOC(av) = 0;
     AvARRAY(av) = NULL;
@@ -1455,7 +1424,7 @@ Perl_newAV(pTHX)
 HV *
 Perl_newHV(pTHX)
 {
-    HV * const hv = (HV*)newSV_type(SVt_PVHV);
+    HV * const hv = MUTABLE_HV(newSV_type(SVt_PVHV));
     assert(!SvOK(hv));
 
     return hv;
@@ -1469,6 +1438,76 @@ Perl_sv_insert(pTHX_ SV *const bigstr, const STRLEN offset, const STRLEN len,
     sv_insert_flags(bigstr, offset, len, little, littlelen, SV_GMAGIC);
 }
 
+void
+Perl_save_freesv(pTHX_ SV *sv)
+{
+    dVAR;
+    save_freesv(sv);
+}
+
+void
+Perl_save_mortalizesv(pTHX_ SV *sv)
+{
+    dVAR;
+
+    PERL_ARGS_ASSERT_SAVE_MORTALIZESV;
+
+    save_mortalizesv(sv);
+}
+
+void
+Perl_save_freeop(pTHX_ OP *o)
+{
+    dVAR;
+    save_freeop(o);
+}
+
+void
+Perl_save_freepv(pTHX_ char *pv)
+{
+    dVAR;
+    save_freepv(pv);
+}
+
+void
+Perl_save_op(pTHX)
+{
+    dVAR;
+    save_op();
+}
+
+#ifdef PERL_DONT_CREATE_GVSV
+GV *
+Perl_gv_SVadd(pTHX_ GV *gv)
+{
+    return gv_SVadd(gv);
+}
+#endif
+
+GV *
+Perl_gv_AVadd(pTHX_ GV *gv)
+{
+    return gv_AVadd(gv);
+}
+
+GV *
+Perl_gv_HVadd(pTHX_ register GV *gv)
+{
+    return gv_HVadd(gv);
+}
+
+GV *
+Perl_gv_IOadd(pTHX_ register GV *gv)
+{
+    return gv_IOadd(gv);
+}
+
+IO *
+Perl_newIO(pTHX)
+{
+    return MUTABLE_IO(newSV_type(SVt_PVIO));
+}
+
 #endif /* NO_MATHOMS */
 
 /*