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);
39 /* sv_2iv() is now a macro using Perl_sv_2iv_flags();
40 * this function provided for binary compatibility only
44 Perl_sv_2iv(pTHX_ register SV *sv)
46 return sv_2iv_flags(sv, SV_GMAGIC);
49 /* sv_2uv() is now a macro using Perl_sv_2uv_flags();
50 * this function provided for binary compatibility only
54 Perl_sv_2uv(pTHX_ register SV *sv)
56 return sv_2uv_flags(sv, SV_GMAGIC);
59 /* sv_2pv() is now a macro using Perl_sv_2pv_flags();
60 * this function provided for binary compatibility only
64 Perl_sv_2pv(pTHX_ register SV *sv, STRLEN *lp)
66 return sv_2pv_flags(sv, lp, SV_GMAGIC);
70 /* sv_setsv() is now a macro using Perl_sv_setsv_flags();
71 * this function provided for binary compatibility only
75 Perl_sv_setsv(pTHX_ SV *dstr, register SV *sstr)
77 sv_setsv_flags(dstr, sstr, SV_GMAGIC);
80 /* sv_catpvn() is now a macro using Perl_sv_catpvn_flags();
81 * this function provided for binary compatibility only
85 Perl_sv_catpvn(pTHX_ SV *dsv, const char* sstr, STRLEN slen)
87 sv_catpvn_flags(dsv, sstr, slen, SV_GMAGIC);
90 /* sv_catsv() is now a macro using Perl_sv_catsv_flags();
91 * this function provided for binary compatibility only
95 Perl_sv_catsv(pTHX_ SV *dstr, register SV *sstr)
97 sv_catsv_flags(dstr, sstr, SV_GMAGIC);
100 /* sv_pv() is now a macro using SvPV_nolen();
101 * this function provided for binary compatibility only
105 Perl_sv_pv(pTHX_ SV *sv)
110 return sv_2pv(sv, 0);
113 /* sv_pvn_force() is now a macro using Perl_sv_pvn_force_flags();
114 * this function provided for binary compatibility only
118 Perl_sv_pvn_force(pTHX_ SV *sv, STRLEN *lp)
120 return sv_pvn_force_flags(sv, lp, SV_GMAGIC);
123 /* sv_pvbyte () is now a macro using Perl_sv_2pv_flags();
124 * this function provided for binary compatibility only
128 Perl_sv_pvbyte(pTHX_ SV *sv)
130 sv_utf8_downgrade(sv,0);
134 /* sv_pvutf8 () is now a macro using Perl_sv_2pv_flags();
135 * this function provided for binary compatibility only
139 Perl_sv_pvutf8(pTHX_ SV *sv)
146 =for apidoc A|U8 *|uvchr_to_utf8|U8 *d|UV uv
148 Adds the UTF-8 representation of the Native codepoint C<uv> to the end
149 of the string C<d>; C<d> should be have at least C<UTF8_MAXBYTES+1> free
150 bytes available. The return value is the pointer to the byte after the
151 end of the new character. In other words,
153 d = uvchr_to_utf8(d, uv);
155 is the recommended wide native character-aware way of saying
162 /* On ASCII machines this is normally a macro but we want a
163 real function in case XS code wants it
165 #undef Perl_uvchr_to_utf8
167 Perl_uvchr_to_utf8(pTHX_ U8 *d, UV uv)
169 return Perl_uvuni_to_utf8_flags(aTHX_ d, NATIVE_TO_UNI(uv), 0);
174 =for apidoc A|UV|utf8n_to_uvchr|U8 *s|STRLEN curlen|STRLEN *retlen|U32
177 Returns the native character value of the first character in the string
179 which is assumed to be in UTF-8 encoding; C<retlen> will be set to the
180 length, in bytes, of that character.
182 Allows length and flags to be passed to low level routine.
186 /* On ASCII machines this is normally a macro but we want
187 a real function in case XS code wants it
189 #undef Perl_utf8n_to_uvchr
191 Perl_utf8n_to_uvchr(pTHX_ const U8 *s, STRLEN curlen, STRLEN *retlen,
194 const UV uv = Perl_utf8n_to_uvuni(aTHX_ s, curlen, retlen, flags);
195 return UNI_TO_NATIVE(uv);
198 Perl_fprintf_nocontext(PerlIO *stream, const char *format, ...)
202 va_start(arglist, format);
203 return PerlIO_vprintf(stream, format, arglist);
207 Perl_printf_nocontext(const char *format, ...)
211 va_start(arglist, format);
212 return PerlIO_vprintf(PerlIO_stdout(), format, arglist);
215 #if defined(HUGE_VAL) || (defined(USE_LONG_DOUBLE) && defined(HUGE_VALL))
217 * This hack is to force load of "huge" support from libm.a
218 * So it is in perl for (say) POSIX to use.
219 * Needed for SunOS with Sun's 'acc' for example.
224 # if defined(USE_LONG_DOUBLE) && defined(HUGE_VALL)
233 perlsio_binmode(FILE *fp, int iotype, int mode)
236 * This used to be contents of do_binmode in doio.c
239 # if defined(atarist) || defined(__MINT__)
242 ((FILE *) fp)->_flag |= _IOBIN;
244 ((FILE *) fp)->_flag &= ~_IOBIN;
251 if (PerlLIO_setmode(fp, mode) != -1) {
253 if (PerlLIO_setmode(fileno(fp), mode) != -1) {
255 # if defined(WIN32) && defined(__BORLANDC__)
257 * The translation mode of the stream is maintained independent
259 * the translation mode of the fd in the Borland RTL (heavy
260 * digging through their runtime sources reveal). User has to
262 * the mode explicitly for the stream (though they don't
264 * this anywhere). GSAR 97-5-24
270 fp->flags &= ~_F_BIN;
278 # if defined(USEMYBINMODE)
280 if (my_binmode(fp, iotype, mode) != FALSE)
286 PERL_UNUSED_ARG(iotype);
287 PERL_UNUSED_ARG(mode);
294 /* compatibility with versions <= 5.003. */
296 Perl_gv_fullname(pTHX_ SV *sv, const GV *gv)
298 gv_fullname3(sv, gv, sv == (const SV*)gv ? "*" : "");
301 /* compatibility with versions <= 5.003. */
303 Perl_gv_efullname(pTHX_ SV *sv, const GV *gv)
305 gv_efullname3(sv, gv, sv == (const SV*)gv ? "*" : "");
309 Perl_gv_fullname3(pTHX_ SV *sv, const GV *gv, const char *prefix)
311 gv_fullname4(sv, gv, prefix, TRUE);
315 Perl_gv_efullname3(pTHX_ SV *sv, const GV *gv, const char *prefix)
317 gv_efullname4(sv, gv, prefix, TRUE);
321 Perl_av_fake(pTHX_ register I32 size, register SV **strp)
324 register AV * const av = (AV*)NEWSV(9,0);
326 sv_upgrade((SV *)av, SVt_PVAV);
327 Newx(ary,size+1,SV*);
329 Copy(strp,ary,size,SV*);
331 SvPV_set(av, (char*)ary);
332 AvFILLp(av) = size - 1;
333 AvMAX(av) = size - 1;
344 * c-indentation-style: bsd
346 * indent-tabs-mode: t
349 * ex: set ts=8 sts=4 sw=4 noet: