3 * Copyright (C) 2005, by Larry Wall and others
5 * You may distribute under the terms of either the GNU General Public
6 * License or the Artistic License, as specified in the README file.
11 * "Anything that Hobbits had no immediate use for, but were unwilling to
12 * throw away, they called a mathom. Their dwellings were apt to become
13 * rather crowded with mathoms, and many of the presents that passed from
14 * hand to hand were of that sort."
18 * This file contains mathoms, various binary artifacts from previous
19 * versions of Perl. For binary or source compatibility reasons, though,
20 * we cannot completely remove them from the core code.
27 #define PERL_IN_MATHOMS_C
30 /* ref() is now a macro using Perl_doref;
31 * this version provided for binary compatibility only.
34 Perl_ref(pTHX_ OP *o, I32 type)
36 return doref(o, type, TRUE);
42 Taint an SV. Use C<SvTAINTED_on> instead.
47 Perl_sv_taint(pTHX_ SV *sv)
49 sv_magic((sv), Nullsv, PERL_MAGIC_taint, Nullch, 0);
52 /* sv_2iv() is now a macro using Perl_sv_2iv_flags();
53 * this function provided for binary compatibility only
57 Perl_sv_2iv(pTHX_ register SV *sv)
59 return sv_2iv_flags(sv, SV_GMAGIC);
62 /* sv_2uv() is now a macro using Perl_sv_2uv_flags();
63 * this function provided for binary compatibility only
67 Perl_sv_2uv(pTHX_ register SV *sv)
69 return sv_2uv_flags(sv, SV_GMAGIC);
72 /* sv_2pv() is now a macro using Perl_sv_2pv_flags();
73 * this function provided for binary compatibility only
77 Perl_sv_2pv(pTHX_ register SV *sv, STRLEN *lp)
79 return sv_2pv_flags(sv, lp, SV_GMAGIC);
83 /* sv_setsv() is now a macro using Perl_sv_setsv_flags();
84 * this function provided for binary compatibility only
88 Perl_sv_setsv(pTHX_ SV *dstr, register SV *sstr)
90 sv_setsv_flags(dstr, sstr, SV_GMAGIC);
93 /* sv_catpvn() is now a macro using Perl_sv_catpvn_flags();
94 * this function provided for binary compatibility only
98 Perl_sv_catpvn(pTHX_ SV *dsv, const char* sstr, STRLEN slen)
100 sv_catpvn_flags(dsv, sstr, slen, SV_GMAGIC);
103 /* sv_catsv() is now a macro using Perl_sv_catsv_flags();
104 * this function provided for binary compatibility only
108 Perl_sv_catsv(pTHX_ SV *dstr, register SV *sstr)
110 sv_catsv_flags(dstr, sstr, SV_GMAGIC);
113 /* sv_pv() is now a macro using SvPV_nolen();
114 * this function provided for binary compatibility only
118 Perl_sv_pv(pTHX_ SV *sv)
123 return sv_2pv(sv, 0);
126 /* sv_pvn_force() is now a macro using Perl_sv_pvn_force_flags();
127 * this function provided for binary compatibility only
131 Perl_sv_pvn_force(pTHX_ SV *sv, STRLEN *lp)
133 return sv_pvn_force_flags(sv, lp, SV_GMAGIC);
136 /* sv_pvbyte () is now a macro using Perl_sv_2pv_flags();
137 * this function provided for binary compatibility only
141 Perl_sv_pvbyte(pTHX_ SV *sv)
143 sv_utf8_downgrade(sv,0);
147 /* sv_pvutf8 () is now a macro using Perl_sv_2pv_flags();
148 * this function provided for binary compatibility only
152 Perl_sv_pvutf8(pTHX_ SV *sv)
159 =for apidoc A|U8 *|uvchr_to_utf8|U8 *d|UV uv
161 Adds the UTF-8 representation of the Native codepoint C<uv> to the end
162 of the string C<d>; C<d> should be have at least C<UTF8_MAXBYTES+1> free
163 bytes available. The return value is the pointer to the byte after the
164 end of the new character. In other words,
166 d = uvchr_to_utf8(d, uv);
168 is the recommended wide native character-aware way of saying
175 /* On ASCII machines this is normally a macro but we want a
176 real function in case XS code wants it
178 #undef Perl_uvchr_to_utf8
180 Perl_uvchr_to_utf8(pTHX_ U8 *d, UV uv)
182 return Perl_uvuni_to_utf8_flags(aTHX_ d, NATIVE_TO_UNI(uv), 0);
187 =for apidoc A|UV|utf8n_to_uvchr|U8 *s|STRLEN curlen|STRLEN *retlen|U32
190 Returns the native character value of the first character in the string
192 which is assumed to be in UTF-8 encoding; C<retlen> will be set to the
193 length, in bytes, of that character.
195 Allows length and flags to be passed to low level routine.
199 /* On ASCII machines this is normally a macro but we want
200 a real function in case XS code wants it
202 #undef Perl_utf8n_to_uvchr
204 Perl_utf8n_to_uvchr(pTHX_ const U8 *s, STRLEN curlen, STRLEN *retlen,
207 const UV uv = Perl_utf8n_to_uvuni(aTHX_ s, curlen, retlen, flags);
208 return UNI_TO_NATIVE(uv);
211 Perl_fprintf_nocontext(PerlIO *stream, const char *format, ...)
215 va_start(arglist, format);
216 return PerlIO_vprintf(stream, format, arglist);
220 Perl_printf_nocontext(const char *format, ...)
224 va_start(arglist, format);
225 return PerlIO_vprintf(PerlIO_stdout(), format, arglist);
228 #if defined(HUGE_VAL) || (defined(USE_LONG_DOUBLE) && defined(HUGE_VALL))
230 * This hack is to force load of "huge" support from libm.a
231 * So it is in perl for (say) POSIX to use.
232 * Needed for SunOS with Sun's 'acc' for example.
237 # if defined(USE_LONG_DOUBLE) && defined(HUGE_VALL)
246 perlsio_binmode(FILE *fp, int iotype, int mode)
249 * This used to be contents of do_binmode in doio.c
252 # if defined(atarist) || defined(__MINT__)
255 ((FILE *) fp)->_flag |= _IOBIN;
257 ((FILE *) fp)->_flag &= ~_IOBIN;
264 if (PerlLIO_setmode(fp, mode) != -1) {
266 if (PerlLIO_setmode(fileno(fp), mode) != -1) {
268 # if defined(WIN32) && defined(__BORLANDC__)
270 * The translation mode of the stream is maintained independent
272 * the translation mode of the fd in the Borland RTL (heavy
273 * digging through their runtime sources reveal). User has to
275 * the mode explicitly for the stream (though they don't
277 * this anywhere). GSAR 97-5-24
283 fp->flags &= ~_F_BIN;
291 # if defined(USEMYBINMODE)
293 if (my_binmode(fp, iotype, mode) != FALSE)
299 PERL_UNUSED_ARG(iotype);
300 PERL_UNUSED_ARG(mode);
307 /* compatibility with versions <= 5.003. */
309 Perl_gv_fullname(pTHX_ SV *sv, const GV *gv)
311 gv_fullname3(sv, gv, sv == (const SV*)gv ? "*" : "");
314 /* compatibility with versions <= 5.003. */
316 Perl_gv_efullname(pTHX_ SV *sv, const GV *gv)
318 gv_efullname3(sv, gv, sv == (const SV*)gv ? "*" : "");
322 Perl_gv_fullname3(pTHX_ SV *sv, const GV *gv, const char *prefix)
324 gv_fullname4(sv, gv, prefix, TRUE);
328 Perl_gv_efullname3(pTHX_ SV *sv, const GV *gv, const char *prefix)
330 gv_efullname4(sv, gv, prefix, TRUE);
334 Perl_av_fake(pTHX_ register I32 size, register SV **strp)
337 register AV * const av = (AV*)NEWSV(9,0);
339 sv_upgrade((SV *)av, SVt_PVAV);
340 Newx(ary,size+1,SV*);
342 Copy(strp,ary,size,SV*);
344 SvPV_set(av, (char*)ary);
345 AvFILLp(av) = size - 1;
346 AvMAX(av) = size - 1;
356 Perl_do_open9(pTHX_ GV *gv, register const char *name, I32 len, int
358 int rawmode, int rawperm, PerlIO *supplied_fp, SV *svs,
361 PERL_UNUSED_ARG(num_svs);
362 return do_openn(gv, name, len, as_raw, rawmode, rawperm,
363 supplied_fp, &svs, 1);
367 Perl_do_binmode(pTHX_ PerlIO *fp, int iotype, int mode)
369 /* The old body of this is now in non-LAYER part of perlio.c
370 * This is a stub for any XS code which might have been calling it.
372 const char *name = ":raw";
373 #ifdef PERLIO_USING_CRLF
374 if (!(mode & O_BINARY))
377 return PerlIO_binmode(aTHX_ fp, iotype, mode, name);
383 * c-indentation-style: bsd
385 * indent-tabs-mode: t
388 * ex: set ts=8 sts=4 sw=4 noet: