util.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/* util.c
*
* Copyright (c) 1991-2001, Larry Wall
*
* You may distribute under the terms of either the GNU General Public
* License or the Artistic License, as specified in the README file.
*
*/
/*
* "Very useful, no doubt, that was to Saruman; yet it seems that he was
* not content." --Gandalf
*/
#include "EXTERN.h"
#define PERL_IN_UTIL_C
#include "perl.h"
#include <signal.h>
#endif
#ifndef SIG_ERR
#endif
#ifdef I_VFORK
# include <vfork.h>
#endif
/* Put this after #includes because fork and vfork prototypes may
conflict.
*/
#ifndef HAS_VFORK
#endif
#ifdef I_SYS_WAIT
#endif
#ifdef I_LOCALE
# include <locale.h>
#endif
#define FLUSH
#ifdef LEAKTEST
long lastxcount[MAXXCOUNT];
#endif
#endif
/* paranoid version of system's malloc() */
/* NOTE: Do not call the next three routines directly. Use the macros
* in handy.h, so that we can easily redefine everything to do tracking of
* allocated hunks back to the original New to track down any memory leaks.
* XXX This advice seems to be widely ignored :-( --AD August 1996.
*/
{
dTHX;
#ifdef HAS_64K_LIMIT
if (size > 0xffff) {
my_exit(1);
}
#endif /* HAS_64K_LIMIT */
#ifdef DEBUGGING
if ((long)size < 0)
Perl_croak_nocontext("panic: malloc");
#endif
DEBUG_m(PerlIO_printf(Perl_debug_log, "0x%"UVxf": (%05ld) malloc %ld bytes\n",PTR2UV(ptr),(long)PL_an++,(long)size));
return ptr;
else if (PL_nomemok)
return Nullch;
else {
my_exit(1);
return Nullch;
}
/*NOTREACHED*/
}
/* paranoid version of system's realloc() */
{
dTHX;
#endif /* !defined(STANDARD_C) && !defined(HAS_REALLOC_PROTOTYPE) */
#ifdef HAS_64K_LIMIT
if (size > 0xffff) {
my_exit(1);
}
#endif /* HAS_64K_LIMIT */
if (!size) {
return NULL;
}
if (!where)
return safesysmalloc(size);
#ifdef DEBUGGING
if ((long)size < 0)
Perl_croak_nocontext("panic: realloc");
#endif
DEBUG_m(PerlIO_printf(Perl_debug_log, "0x%"UVxf": (%05ld) realloc %ld bytes\n",PTR2UV(ptr),(long)PL_an++,(long)size));
return ptr;
else if (PL_nomemok)
return Nullch;
else {
my_exit(1);
return Nullch;
}
/*NOTREACHED*/
}
/* safe version of system's free() */
{
#ifdef PERL_IMPLICIT_SYS
dTHX;
#endif
if (where) {
/*SUPPRESS 701*/
}
}
/* safe version of system's calloc() */
{
dTHX;
#ifdef HAS_64K_LIMIT
my_exit(1);
}
#endif /* HAS_64K_LIMIT */
#ifdef DEBUGGING
Perl_croak_nocontext("panic: calloc");
#endif
DEBUG_m(PerlIO_printf(Perl_debug_log, "0x%"UVxf": (%05ld) calloc %ld x %ld bytes\n",PTR2UV(ptr),(long)PL_an++,(long)count,(long)size));
return ptr;
}
else if (PL_nomemok)
return Nullch;
else {
my_exit(1);
return Nullch;
}
/*NOTREACHED*/
}
#ifdef LEAKTEST
struct mem_test_strut {
union {
long type;
char c[2];
} u;
long size;
};
# define ALIGN sizeof(struct mem_test_strut)
# define typeof_chunk(ch) \
# define set_typeof_chunk(ch,t) \
(((struct mem_test_strut*) (ch))->u.c[0] = t % 100, ((struct mem_test_strut*) (ch))->u.c[1] = t / 100)
? MAXYCOUNT - 1 \
: ( (size) > 40 \
{
set_typeof_chunk(where, x);
}
{
if (!wh)
return safexmalloc(0,size);
{
}
}
void
{
I32 x;
if (!where)
return;
}
{
set_typeof_chunk(where, x);
}
STATIC void
{
for (j = 0; j < MAXYCOUNT; j++) {
subtot[j] = 0;
}
PerlIO_printf(Perl_debug_log, " Id subtot 4 8 12 16 20 24 28 32 36 40 48 56 64 72 80 80+\n", total);
for (i = 0; i < MAXXCOUNT; i++) {
for (j = 0; j < MAXYCOUNT; j++) {
}
if (flag == 0
? xcount[i] /* Have something */
: (flag == 2
lastxcount[i] = xcount[i];
for (j = 0; j < MAXYCOUNT; j++) {
if ( flag == 0
? xycount[i][j] /* Have something */
: (flag == 2
flag == 2
? xycount[i][j] - lastxycount[i][j]
: xycount[i][j]);
lastxycount[i][j] = xycount[i][j];
} else {
}
}
}
}
if (flag != 2) {
for (j = 0; j < MAXYCOUNT; j++) {
if (subtot[j]) {
} else {
}
}
}
}
#endif /* LEAKTEST */
/* copy a string up to some (non-backslashed) delimiter, if any */
char *
Perl_delimcpy(pTHX_ register char *to, register char *toend, register char *from, register char *fromend, register int delim, I32 *retlen)
{
if (*from == '\\') {
from++;
else {
tolen++;
from++;
}
}
break;
}
*to = '\0';
return from;
}
/* return ptr to little string in big string, NULL if not found */
/* This routine was donated by Corey Satten. */
char *
{
register const char *s, *x;
if (!little)
return (char*)big;
if (!first)
return (char*)big;
while (*big) {
continue;
if (!*x)
return Nullch;
if (*s++ != *x++) {
s--;
break;
}
}
if (!*s)
return (char*)(big-1);
}
return Nullch;
}
/* same as instr but allow embedded nulls */
char *
Perl_ninstr(pTHX_ register const char *big, register const char *bigend, const char *little, const char *lend)
{
register const char *s, *x;
return (char*)big;
return Nullch;
continue;
if (*s++ != *x++) {
s--;
break;
}
}
if (s >= littleend)
return (char*)(big-1);
}
return Nullch;
}
/* reverse of the above--find last substring */
char *
Perl_rninstr(pTHX_ register const char *big, const char *bigend, const char *little, const char *lend)
{
register const char *bigbeg;
register const char *s, *x;
return (char*)bigend;
continue;
if (*s++ != *x++) {
s--;
break;
}
}
if (s >= littleend)
return (char*)(big+1);
}
return Nullch;
}
/*
* Set up for a new ctype locale.
*/
void
{
#ifdef USE_LOCALE_CTYPE
int i;
for (i = 0; i < 256; i++) {
if (isUPPER_LC(i))
PL_fold_locale[i] = toLOWER_LC(i);
else if (isLOWER_LC(i))
PL_fold_locale[i] = toUPPER_LC(i);
else
PL_fold_locale[i] = i;
}
#endif /* USE_LOCALE_CTYPE */
}
/*
* Standardize the locale name from a string returned by 'setlocale'.
*
* The standard return value of setlocale() is either
* (1) "xx_YY" if the first argument of setlocale() is not LC_ALL
* (2) "xa_YY xb_YY ..." if the first argument of setlocale() is LC_ALL
* (the space-separated values represent the various sublocales,
* in some unspecificed order)
*
* In some platforms it has a form like "LC_SOMETHING=Lang_Country.866\n",
* which is harmful for further use of the string in setlocale().
*
*/
STATIC char *
{
char *s;
char *t;
if ((t = strchr(s, '.'))) {
char *u;
if ((u = strchr(t, '\n'))) {
if (u[1] == 0) {
}
}
}
}
if (!okay)
return locs;
}
/*
* Set up for a new collation locale.
*/
void
{
#ifdef USE_LOCALE_COLLATE
if (! newcoll) {
if (PL_collation_name) {
}
PL_collxfrm_base = 0;
PL_collxfrm_mult = 2;
return;
}
{
/* 2: at most so many chars ('a', 'b'). */
/* 50: surely no system expands a char more. */
char xbuf[XFRMBUFSIZE];
if (mult < 1)
}
}
#endif /* USE_LOCALE_COLLATE */
}
void
{
#ifdef USE_LOCALE_NUMERIC
# ifdef HAS_LOCALECONV
lc = localeconv();
PL_numeric_radix_sv = 0;
}
else {
if (PL_numeric_radix_sv)
else
}
}
else
PL_numeric_radix_sv = 0;
# endif /* HAS_LOCALECONV */
#endif /* USE_LOCALE_NUMERIC */
}
/*
* Set up for a new numeric locale.
*/
void
{
#ifdef USE_LOCALE_NUMERIC
if (! newnum) {
if (PL_numeric_name) {
}
return;
}
}
#endif /* USE_LOCALE_NUMERIC */
}
void
{
#ifdef USE_LOCALE_NUMERIC
if (! PL_numeric_standard) {
}
#endif /* USE_LOCALE_NUMERIC */
}
void
{
#ifdef USE_LOCALE_NUMERIC
if (! PL_numeric_local) {
}
#endif /* USE_LOCALE_NUMERIC */
}
/*
* Initialize locale awareness.
*/
int
{
int ok = 1;
/* returns
* 1 = set ok or not applicable,
* 0 = fallback to C locale,
* -1 = fallback to C locale failed
*/
#if defined(USE_LOCALE)
#ifdef USE_LOCALE_CTYPE
#endif /* USE_LOCALE_CTYPE */
#ifdef USE_LOCALE_COLLATE
#endif /* USE_LOCALE_COLLATE */
#ifdef USE_LOCALE_NUMERIC
#endif /* USE_LOCALE_NUMERIC */
#ifdef __GLIBC__
#endif
bool setlocale_failure = FALSE;
#ifdef LOCALE_ENVIRON_REQUIRED
/*
* Ultrix setlocale(..., "") fails if there are no environment
* variables from which to get a locale name.
*/
#ifdef LC_ALL
if (lang) {
else
}
if (!setlocale_failure) {
#ifdef USE_LOCALE_CTYPE
if (! (curctype =
? "" : Nullch)))
else
#endif /* USE_LOCALE_CTYPE */
#ifdef USE_LOCALE_COLLATE
if (! (curcoll =
? "" : Nullch)))
else
#endif /* USE_LOCALE_COLLATE */
#ifdef USE_LOCALE_NUMERIC
if (! (curnum =
? "" : Nullch)))
else
#endif /* USE_LOCALE_NUMERIC */
}
#endif /* LC_ALL */
#endif /* !LOCALE_ENVIRON_REQUIRED */
#ifdef LC_ALL
#endif /* LC_ALL */
if (!setlocale_failure) {
#ifdef USE_LOCALE_CTYPE
else
#endif /* USE_LOCALE_CTYPE */
#ifdef USE_LOCALE_COLLATE
else
#endif /* USE_LOCALE_COLLATE */
#ifdef USE_LOCALE_NUMERIC
else
#endif /* USE_LOCALE_NUMERIC */
}
if (setlocale_failure) {
char *p;
(printwarn &&
if (locwarn) {
#ifdef LC_ALL
"perl: warning: Setting locale failed.\n");
#else /* !LC_ALL */
"perl: warning: Setting locale failed for the categories:\n\t");
#ifdef USE_LOCALE_CTYPE
if (! curctype)
#endif /* USE_LOCALE_CTYPE */
#ifdef USE_LOCALE_COLLATE
if (! curcoll)
#endif /* USE_LOCALE_COLLATE */
#ifdef USE_LOCALE_NUMERIC
if (! curnum)
#endif /* USE_LOCALE_NUMERIC */
#endif /* LC_ALL */
"perl: warning: Please check that your locale settings:\n");
#ifdef __GLIBC__
"\tLANGUAGE = %c%s%c,\n",
#endif
"\tLC_ALL = %c%s%c,\n",
#if defined(USE_ENVIRON_ARRAY)
{
char **e;
for (e = environ; *e; e++) {
&& (p = strchr(*e, '=')))
(int)(p - *e), *e, p + 1);
}
}
#else
"\t(possibly more locale environment variables)\n");
#endif
"\tLANG = %c%s%c\n",
" are supported and installed on your system.\n");
}
#ifdef LC_ALL
if (locwarn)
"perl: warning: Falling back to the standard locale (\"C\").\n");
ok = 0;
}
else {
if (locwarn)
"perl: warning: Failed to fall back to the standard locale (\"C\").\n");
ok = -1;
}
#else /* ! LC_ALL */
if (0
#ifdef USE_LOCALE_CTYPE
#endif /* USE_LOCALE_CTYPE */
#ifdef USE_LOCALE_COLLATE
#endif /* USE_LOCALE_COLLATE */
#ifdef USE_LOCALE_NUMERIC
#endif /* USE_LOCALE_NUMERIC */
)
{
if (locwarn)
"perl: warning: Cannot fall back to the standard locale (\"C\").\n");
ok = -1;
}
#endif /* ! LC_ALL */
#ifdef USE_LOCALE_CTYPE
#endif /* USE_LOCALE_CTYPE */
#ifdef USE_LOCALE_COLLATE
#endif /* USE_LOCALE_COLLATE */
#ifdef USE_LOCALE_NUMERIC
#endif /* USE_LOCALE_NUMERIC */
}
else {
#ifdef USE_LOCALE_CTYPE
#endif /* USE_LOCALE_CTYPE */
#ifdef USE_LOCALE_COLLATE
#endif /* USE_LOCALE_COLLATE */
#ifdef USE_LOCALE_NUMERIC
#endif /* USE_LOCALE_NUMERIC */
}
#endif /* USE_LOCALE */
#ifdef USE_LOCALE_CTYPE
#endif /* USE_LOCALE_CTYPE */
#ifdef USE_LOCALE_COLLATE
#endif /* USE_LOCALE_COLLATE */
#ifdef USE_LOCALE_NUMERIC
#endif /* USE_LOCALE_NUMERIC */
return ok;
}
/* Backwards compatibility. */
int
{
return init_i18nl10n(printwarn);
}
#ifdef USE_LOCALE_COLLATE
/*
* mem_collxfrm() is a bit like strxfrm() but with two important
* differences. First, it handles embedded NULs. Second, it allocates
* a bit more memory than needed for the transformed data itself.
* The real transformed data begins at offset sizeof(collationix).
* Please see sv_collxfrm() to see how this is used.
*/
char *
{
char *xbuf;
/* the first sizeof(collationix) bytes are used by sv_collxfrm(). */
/* the +1 is for the terminating NUL. */
if (! xbuf)
goto bad;
xout = sizeof(PL_collation_ix);
for (;;) {
if (xused == -1)
goto bad;
break;
if (! xbuf)
goto bad;
}
/* Embedded NULs are understood but silently skipped
* because they make no sense in locale collation. */
}
return xbuf;
bad:
*xlen = 0;
return NULL;
}
#endif /* USE_LOCALE_COLLATE */
/* As a space optimization, we do not compile tables for strings of length
0 and 1, and for strings of length 2 unless FBMcf_TAIL. These are
special-cased in fbm_instr().
If FBMcf_TAIL, the table is created as if the string has a trailing \n. */
/*
=for apidoc fbm_compile
Analyses the string in order to make fast searches on it using fbm_instr()
-- the Boyer-Moore algorithm.
=cut
*/
void
{
register U8 *s;
register U32 i;
if (flags & FBMcf_TAIL)
if (len == 0) /* TAIL might be on on a zero-length string. */
return;
if (len > 2) {
unsigned char *sb;
if (len > 255)
mlen = 255;
else
i = 0;
while (s >= sb) {
s--, i++;
}
}
SvVALID_on(sv);
for (i = 0; i < len; i++) {
rarest = i;
}
}
if (flags & FBMcf_TAIL)
}
/* If SvTAIL(littlestr), it has a fake '\n' at end. */
/* If SvTAIL is actually due to \Z or \z, this gives false positives
if multiline */
/*
=for apidoc fbm_instr
Returns the location of the SV in the string delimited by C<str> and
C<strend>. It returns C<Nullch> if the string can't be found. The C<sv>
does not have to be fbm_compiled, but the search will not be as fast
then.
=cut
*/
char *
{
register unsigned char *s;
STRLEN l;
&& (littlelen == 1
return (char*)big;
return Nullch;
}
if (littlelen == 1) {
/* Know that bigend != big. */
return (char *)(bigend - 1);
return (char *) bigend;
}
s = big;
while (s < bigend) {
if (*s == *little)
return (char *)s;
s++;
}
return (char *) bigend;
return Nullch;
}
if (!littlelen)
return (char*)big; /* Cannot be SvTAIL! */
/* littlelen is 2 */
return (char*)bigend - 2;
return (char*)bigend - 1;
return Nullch;
}
{
/* This should be better than FBM if c1 == c2, and almost
as good otherwise: maybe better since we do less indirection.
And we save a lot of memory by caching no table. */
s = big + 1;
bigend--;
while (s <= bigend) {
if (s[0] == c2) {
if (s[-1] == c1)
return (char*)s - 1;
s += 2;
continue;
}
if (s[0] == c1) {
if (s == bigend)
goto check_1char_anchor;
if (s[1] == c2)
return (char*)s;
else {
s++;
goto next_chars;
}
}
else
s += 2;
}
goto check_1char_anchor;
}
/* Now c1 == c2 */
while (s <= bigend) {
if (s[0] == c1) {
if (s[-1] == c1)
return (char*)s - 1;
if (s == bigend)
goto check_1char_anchor;
if (s[1] == c1)
return (char*)s;
s += 3;
}
else
s += 2;
}
}
check_1char_anchor: /* One char and anchor! */
return (char *)bigend; /* bigend is already decremented. */
return Nullch;
}
/* Automatically of length > 2 */
{
return (char*)s; /* how sweet it is */
}
if (s[1] == *little
{
return (char*)s + 1; /* how sweet it is */
}
return Nullch;
}
/* Chop \n from littlestr: */
if (*s == *little
{
return (char*)s;
}
return Nullch;
}
return b;
}
{ /* Do actual FBM. */
register unsigned char *oldlittle;
return Nullch;
--littlelen; /* Last char found by table lookup */
if (s < bigend) {
top2:
/*SUPPRESS 560*/
#ifdef POINTERRIGOR
s += tmp;
goto top2;
}
s += tmp;
#else
goto top2;
#endif
goto check_end;
}
else { /* less expensive than calling strncmp() */
register unsigned char *olds = s;
while (tmp--) {
if (*--s == *--little)
continue;
if (s < bigend) /* fake up continue to outer loop */
goto top2;
goto check_end;
}
return (char *)s;
}
}
return Nullch;
}
}
/* start_shift, end_shift are positive quantities which give offsets
of ends of some substring of bigstr.
If `last' we want the last occurence.
old_posp is the way of communication between consequent calls if
the next call needs to find the .
The initial *old_posp should be -1.
Note that we take into account SvTAIL, so one can get extra
optimizations if _ALL flag is set.
*/
/* If SvTAIL is actually due to \Z or \z, this gives false positives
if PL_multiline. In fact if !PL_multiline the autoritative answer
is not supported yet. */
char *
Perl_screaminstr(pTHX_ SV *bigstr, SV *littlestr, I32 start_shift, I32 end_shift, I32 *old_posp, I32 last)
{
register unsigned char *s, *x;
register unsigned char *big;
register unsigned char *little;
register unsigned char *littleend;
if (*old_posp == -1
goto check_tail;
}
return Nullch;
}
/* The value of pos we can start at: */
/* The value of pos we can stop at: */
goto check_tail;
return Nullch;
}
goto cant_find;
}
#ifdef POINTERRIGOR
do {
continue;
if (*s++ != *x++) {
s--;
break;
}
}
if (s == littleend) {
found = 1;
}
#else /* !POINTERRIGOR */
do {
continue;
if (*s++ != *x++) {
s--;
break;
}
}
if (s == littleend) {
found = 1;
}
#endif /* POINTERRIGOR */
return Nullch;
/* Ignore the trailing "\n". This code is not microoptimized */
if (stop_pos == 0)
return (char*)big;
return (char*)big;
return Nullch;
}
{
while (len--) {
if (*a != *b && *a != PL_fold[*b])
return 1;
a++,b++;
}
return 0;
}
{
while (len--) {
if (*a != *b && *a != PL_fold_locale[*b])
return 1;
a++,b++;
}
return 0;
}
/* copy a string to a safe spot */
/*
=for apidoc savepv
Copy a string to a safe spot. This does not use an SV.
=cut
*/
char *
{
register char *newaddr;
return newaddr;
}
/* same thing but with a known length */
/*
=for apidoc savepvn
Copy a string to a safe spot. The C<len> indicates number of bytes to
copy. This does not use an SV.
=cut
*/
char *
{
register char *newaddr;
return newaddr;
}
/* the SV for Perl_form() and mess() is not kept in an arena */
{
if (!PL_dirty)
if (PL_mess_sv)
return PL_mess_sv;
/* Create as PVMG now, to avoid any upgrading later */
PL_mess_sv = sv;
return sv;
}
#if defined(PERL_IMPLICIT_CONTEXT)
char *
Perl_form_nocontext(const char* pat, ...)
{
dTHX;
char *retval;
return retval;
}
#endif /* PERL_IMPLICIT_CONTEXT */
char *
{
char *retval;
return retval;
}
char *
{
}
#if defined(PERL_IMPLICIT_CONTEXT)
SV *
Perl_mess_nocontext(const char *pat, ...)
{
dTHX;
return retval;
}
#endif /* PERL_IMPLICIT_CONTEXT */
SV *
{
return retval;
}
SV *
{
static char dgd[] = " during global destruction.\n";
}
#ifdef USE_THREADS
#endif
}
return sv;
}
OP *
{
char *message;
int was_in_eval = PL_in_eval;
"%p: die: curstack = %p, mainstack = %p\n",
if (pat) {
}
else
}
else {
msglen = 0;
}
"%p: die: message = %s\ndiehook = %p\n",
if (PL_diehook) {
/* sv_2cv might call Perl_croak() */
PL_diehook = Nullsv;
dSP;
if (message) {
}
else {
}
}
}
"%p: die: restartop = %p, was_in_eval = %d, top_env = %p\n",
JMPENV_JUMP(3);
return PL_restartop;
}
#if defined(PERL_IMPLICIT_CONTEXT)
OP *
Perl_die_nocontext(const char* pat, ...)
{
dTHX;
OP *o;
return o;
}
#endif /* PERL_IMPLICIT_CONTEXT */
OP *
{
OP *o;
return o;
}
void
{
char *message;
if (pat) {
}
else
}
else {
msglen = 0;
}
if (PL_diehook) {
/* sv_2cv might call Perl_croak() */
PL_diehook = Nullsv;
dSP;
if (message) {
}
else {
}
}
}
if (PL_in_eval) {
JMPENV_JUMP(3);
}
else if (!message)
{
#ifdef USE_SFIO
/* SFIO can really mess with your errno */
int e = errno;
#endif
(void)PerlIO_flush(serr);
#ifdef USE_SFIO
errno = e;
#endif
}
}
#if defined(PERL_IMPLICIT_CONTEXT)
void
Perl_croak_nocontext(const char *pat, ...)
{
dTHX;
/* NOTREACHED */
}
#endif /* PERL_IMPLICIT_CONTEXT */
/*
=for apidoc croak
This is the XSUB-writer's interface to Perl's C<die> function.
Normally use this function the same way you use the C C<printf>
function. See C<warn>.
If you want to throw an exception object, assign the object to
C<$@> and then pass C<Nullch> to croak():
errsv = get_sv("@", TRUE);
sv_setsv(errsv, exception_object);
croak(Nullch);
=cut
*/
void
{
/* NOTREACHED */
}
void
{
char *message;
if (PL_warnhook) {
/* sv_2cv might call Perl_warn() */
dSP;
return;
}
}
{
#ifdef LEAKTEST
: 0)
, 0)
: 0);
#endif
(void)PerlIO_flush(serr);
}
}
#if defined(PERL_IMPLICIT_CONTEXT)
void
Perl_warn_nocontext(const char *pat, ...)
{
dTHX;
}
#endif /* PERL_IMPLICIT_CONTEXT */
/*
=for apidoc warn
This is the XSUB-writer's interface to Perl's C<warn> function. Use this
function the same way you use the C C<printf> function. See
C<croak>.
=cut
*/
void
{
}
#if defined(PERL_IMPLICIT_CONTEXT)
void
{
dTHX;
}
#endif /* PERL_IMPLICIT_CONTEXT */
void
{
}
void
{
char *message;
#ifdef USE_THREADS
#endif /* USE_THREADS */
if (PL_diehook) {
/* sv_2cv might call Perl_croak() */
PL_diehook = Nullsv;
dSP;
}
}
if (PL_in_eval) {
JMPENV_JUMP(3);
}
{
(void)PerlIO_flush(serr);
}
}
else {
if (PL_warnhook) {
/* sv_2cv might call Perl_warn() */
dSP;
return;
}
}
{
#ifdef LEAKTEST
: 0)
, 0)
: 0);
#endif
(void)PerlIO_flush(serr);
}
}
}
#ifdef USE_ENVIRON_ARRAY
#if !defined(WIN32)
void
{
#ifndef PERL_USE_SAFE_PUTENV
/* most putenv()s leak, so we manipulate environ directly */
I32 j;
char **tmpenv;
/*SUPPRESS 530*/
for (j=0; j<max; j++) { /* copy environment */
}
}
if (!val) {
safesysfree(environ[i]);
while (environ[i]) {
i++;
}
return;
}
if (!environ[i]) { /* does not exist yet */
}
else
safesysfree(environ[i]);
#else /* PERL_USE_SAFE_PUTENV */
# if defined(__CYGWIN__)
# else
char *new_env;
# endif /* __CYGWIN__ */
#endif /* PERL_USE_SAFE_PUTENV */
}
#else /* WIN32 */
void
{
register char *envstr;
if (!val) {
val = "";
}
(void)PerlEnv_putenv(envstr);
}
#endif /* WIN32 */
{
for (i = 0; environ[i]; i++) {
if (
#ifdef WIN32
#else
#endif
break; /* strnEQ must come first to avoid */
} /* potential SEGV's */
return i;
}
#endif /* !VMS && !EPOC*/
#ifdef UNLINK_ALL_VERSIONS
{
I32 i;
for (i = 0; PerlLIO_unlink(f) >= 0; i++) ;
return i ? 0 : -1;
}
#endif
/* this is a drop-in replacement for bcopy() */
#if !defined(HAS_BCOPY) || !defined(HAS_SAFE_BCOPY)
char *
{
while (len--)
}
else {
while (len--)
}
return retval;
}
#endif
/* this is a drop-in replacement for memset() */
#ifndef HAS_MEMSET
void *
{
while (len--)
return retval;
}
#endif
/* this is a drop-in replacement for bzero() */
#if !defined(HAS_BZERO) && !defined(HAS_MEMSET)
char *
{
while (len--)
*loc++ = 0;
return retval;
}
#endif
/* this is a drop-in replacement for memcmp() */
#if !defined(HAS_MEMCMP) || !defined(HAS_SANE_MEMCMP)
{
while (len--) {
if (tmp = *a++ - *b++)
return tmp;
}
return 0;
}
#endif /* !HAS_MEMCMP || !HAS_SANE_MEMCMP */
#ifndef HAS_VPRINTF
#ifdef USE_CHAR_VSPRINTF
char *
#else
int
#endif
{
#ifndef _IOSTRG
#define _IOSTRG 0
#endif
#ifdef USE_CHAR_VSPRINTF
return(dest);
#else
return 0; /* perl doesn't use return value */
#endif
}
#endif /* HAS_VPRINTF */
#ifdef MYSWAP
#if BYTEORDER != 0x4321
short
Perl_my_swap(pTHX_ short s)
{
#if (BYTEORDER & 1) == 0
short result;
return result;
#else
return s;
#endif
}
long
Perl_my_htonl(pTHX_ long l)
{
union {
long result;
char c[sizeof(long)];
} u;
#if BYTEORDER == 0x1234
u.c[0] = (l >> 24) & 255;
u.c[1] = (l >> 16) & 255;
u.c[2] = (l >> 8) & 255;
u.c[3] = l & 255;
return u.result;
#else
#else
register I32 o;
register I32 s;
u.c[o & 0xf] = (l >> s) & 255;
}
return u.result;
#endif
#endif
}
long
Perl_my_ntohl(pTHX_ long l)
{
union {
long l;
char c[sizeof(long)];
} u;
#if BYTEORDER == 0x1234
u.c[0] = (l >> 24) & 255;
u.c[1] = (l >> 16) & 255;
u.c[2] = (l >> 8) & 255;
u.c[3] = l & 255;
return u.l;
#else
#else
register I32 o;
register I32 s;
u.l = l;
l = 0;
l |= (u.c[o & 0xf] & 255) << s;
}
return l;
#endif
#endif
}
#endif /* BYTEORDER != 0x4321 */
#endif /* MYSWAP */
/*
* Little-endian byte order functions - 'v' for 'VAX', or 'reVerse'.
* If these functions are defined,
* the BYTEORDER is neither 0x1234 nor 0x4321.
* However, this is not assumed.
* -DWS
*/
type \
{ \
union { \
char c[sizeof(type)]; \
} u; \
register I32 i; \
register I32 s; \
for (i = 0, s = 0; i < sizeof(u.c); i++, s += 8) { \
u.c[i] = (n >> s) & 0xFF; \
} \
return u.value; \
}
type \
{ \
union { \
char c[sizeof(type)]; \
} u; \
register I32 i; \
register I32 s; \
u.value = n; \
n = 0; \
for (i = 0, s = 0; i < sizeof(u.c); i++, s += 8) { \
n += (u.c[i] & 0xFF) << s; \
} \
return n; \
}
#endif
#endif
#endif
#endif
/* VMS' my_popen() is in VMS.c, same with OS/2. */
#if (!defined(DOSISH) || defined(HAS_FORK) || defined(AMIGAOS)) && !defined(VMS) && !defined(__OPEN_VM) && !defined(EPOC) && !defined(MACOS_TRADITIONAL)
PerlIO *
{
int p[2];
int pp[2];
#ifdef OS2
if (doexec) {
}
#endif
if (doexec && PL_tainting) {
taint_env();
}
if (PerlProc_pipe(p) < 0)
return Nullfp;
did_pipes = 1;
PerlLIO_close(p[This]);
if (did_pipes) {
PerlLIO_close(pp[0]);
}
if (!doexec)
return Nullfp;
}
sleep(5);
}
if (pid == 0) {
PerlLIO_close(p[THAT]);
if (did_pipes) {
PerlLIO_close(pp[0]);
#endif
}
PerlLIO_close(p[THIS]);
}
#ifndef OS2
if (doexec) {
int fd;
#ifndef NOFILE
#define NOFILE 20
#endif
#endif
PerlProc__exit(1);
}
#endif /* defined OS2 */
/*SUPPRESS 560*/
PL_forkprocess = 0;
return Nullfp;
}
do_execfree(); /* free any memory malloced by child on vfork */
PerlLIO_close(p[that]);
if (did_pipes)
PerlLIO_close(p[This]);
}
int errkid;
int n = 0, n1;
while (n < sizeof(int)) {
(void*)(((char*)&errkid)+n),
(sizeof(int)) - n);
if (n1 <= 0)
break;
n += n1;
}
PerlLIO_close(pp[0]);
did_pipes = 0;
if (n) { /* Error */
PerlLIO_close(p[This]);
if (n != sizeof(int))
do {
return Nullfp;
}
}
if (did_pipes)
PerlLIO_close(pp[0]);
}
#else
PerlIO *
{
/* Needs work for PerlIO ! */
/* used 0 for 2nd parameter to PerlIO-exportFILE; apparently not used */
}
#endif
#endif /* !DOSISH */
#ifdef DUMP_FDS
void
Perl_dump_fds(pTHX_ char *s)
{
int fd;
struct stat tmpstatbuf;
}
}
#endif /* DUMP_FDS */
#ifndef HAS_DUP2
int
{
return oldfd;
#else
#define DUP2_MAX_FDS 256
int fdtmp[DUP2_MAX_FDS];
int fd;
return oldfd;
/* good enough for low fd's... */
if (fdx >= DUP2_MAX_FDS) {
fd = -1;
break;
}
}
while (fdx > 0)
return fd;
#endif
}
#endif
#ifdef HAS_SIGACTION
{
#ifdef SA_RESTART
#endif
#ifdef SA_NOCLDWAIT
#endif
return SIG_ERR;
else
return oact.sa_handler;
}
{
return SIG_ERR;
else
return oact.sa_handler;
}
int
{
#ifdef SA_RESTART
#endif
#ifdef SA_NOCLDWAIT
#endif
}
int
{
}
#else /* !HAS_SIGACTION */
{
}
static int sig_trapped;
static
{
sig_trapped++;
}
{
sig_trapped = 0;
if (sig_trapped)
return oldsig;
}
int
{
}
int
{
}
#endif /* !HAS_SIGACTION */
/* VMS' my_pclose() is in VMS.c; same with OS/2 */
#if (!defined(DOSISH) || defined(HAS_FORK) || defined(AMIGAOS)) && !defined(VMS) && !defined(__OPEN_VM) && !defined(EPOC) && !defined(MACOS_TRADITIONAL)
{
int status;
bool close_failed;
int saved_errno;
#ifdef VMS
int saved_vaxc_errno;
#endif
#ifdef WIN32
int saved_win32_errno;
#endif
SvREFCNT_dec(*svp);
*svp = &PL_sv_undef;
#ifdef OS2
return my_syspclose(ptr);
}
#endif
saved_errno = errno;
#ifdef VMS
#endif
#ifdef WIN32
#endif
}
#ifdef UTS
#endif
do {
if (close_failed) {
return -1;
}
}
#endif /* !DOSISH */
{
char spid[TYPE_CHARS(int)];
if (!pid)
return -1;
if (pid > 0) {
return pid;
}
}
else {
return pid;
}
}
#endif
#ifdef HAS_WAITPID
# ifdef HAS_WAITPID_RUNTIME
if (!HAS_WAITPID_RUNTIME)
goto hard_way;
# endif
#endif
#if !defined(HAS_WAITPID) && defined(HAS_WAIT4)
#endif
{
if (flags)
else {
if (result < 0)
*statusp = -1;
}
return result;
}
#endif
}
#endif /* !DOSISH || OS2 || WIN32 */
void
/*SUPPRESS 590*/
{
char spid[TYPE_CHARS(int)];
return;
}
int pclose();
#ifdef HAS_FORK
int /* Cannot prototype with I32
in os2ish.h. */
#else
#endif
{
/* Needs work for PerlIO ! */
#if defined(DJGPP)
#endif
return result;
}
#endif
void
{
if (len == 1) {
register const char c = *from;
while (count-- > 0)
*to++ = c;
return;
}
while (count-- > 0) {
}
}
}
{
long along;
#if CASTFLAGS & 2
# define BIGDOUBLE 2147483648.0
if (f >= BIGDOUBLE)
#endif
if (f >= 0.0)
return (unsigned long)f;
along = (long)f;
return (unsigned long)along;
}
/* Unfortunately, on some systems the cast_uv() function doesn't
work with the system-supplied definition of ULONG_MAX. The
comparison (f >= ULONG_MAX) always comes out true. It must be a
problem with the compiler constant folding.
In any case, this workaround should be fine on any two's complement
system. If it's not, supply a '-DMY_ULONG_MAX=whatever' in your
ccflags.
--Andy Dougherty <doughera@lafcol.lafayette.edu>
*/
/* Code modified to prefer proper named type ranges, I32, IV, or UV, instead
-- Kenneth Albanowski <kjahds@kjahds.com>
*/
#ifndef MY_UV_MAX
#endif
{
if (f >= I32_MAX)
if (f <= I32_MIN)
return (I32) f;
}
{
if (f >= IV_MAX) {
}
if (f <= IV_MIN)
return (IV) f;
}
{
if (f >= MY_UV_MAX)
if (f < 0) {
if (f < IV_MIN)
}
return (UV) f;
}
#ifndef HAS_RENAME
Perl_same_dirent(pTHX_ char *a, char *b)
{
struct stat tmpstatbuf1;
struct stat tmpstatbuf2;
if (fa)
fa++;
else
fa = a;
if (fb)
fb++;
else
fb = b;
if (strNE(a,b))
return FALSE;
if (fa == a)
else
return FALSE;
if (fb == b)
else
return FALSE;
}
#endif /* !HAS_RENAME */
{
register char *s = start;
register bool overflowed = FALSE;
for (; len-- && *s; s++) {
if (!(*s == '0' || *s == '1')) {
&& (s[1] == '0' || s[1] == '1'))
{
--len;
++s;
}
/* Disallow 0bbb0b0bbb... */
continue;
}
else {
if (ckWARN(WARN_DIGIT))
"Illegal binary digit '%c' ignored", *s);
break;
}
}
if (!overflowed) {
overflowed = TRUE;
if (ckWARN_d(WARN_OVERFLOW))
"Integer overflow in binary number");
}
else
}
if (overflowed) {
rnv *= 2;
/* If an NV has not enough bits in its mantissa to
* represent an UV this summing of small low-order numbers
* is a waste of time (because the NV cannot preserve
* the low-order bits anyway): we could just remember when
* did we overflow and in the end just multiply rnv by the
* right amount. */
rnv += (*s - '0');
}
}
if (!overflowed)
#if UVSIZE > 4
#endif
) {
if (ckWARN(WARN_PORTABLE))
"Binary number > 0b11111111111111111111111111111111 non-portable");
}
return rnv;
}
{
register char *s = start;
register bool overflowed = FALSE;
for (; len-- && *s; s++) {
if (!(*s >= '0' && *s <= '7')) {
&& (s[1] >= '0' && s[1] <= '7'))
{
--len;
++s;
}
else {
/* Allow \octal to work the DWIM way (that is, stop scanning
* as soon as non-octal characters are seen, complain only iff
* someone seems to want to use the digits eight and nine). */
if (*s == '8' || *s == '9') {
if (ckWARN(WARN_DIGIT))
"Illegal octal digit '%c' ignored", *s);
}
break;
}
}
if (!overflowed) {
overflowed = TRUE;
if (ckWARN_d(WARN_OVERFLOW))
"Integer overflow in octal number");
}
else
}
if (overflowed) {
rnv *= 8.0;
/* If an NV has not enough bits in its mantissa to
* represent an UV this summing of small low-order numbers
* is a waste of time (because the NV cannot preserve
* the low-order bits anyway): we could just remember when
* did we overflow and in the end just multiply rnv by the
* right amount of 8-tuples. */
}
}
if (!overflowed)
#if UVSIZE > 4
#endif
) {
if (ckWARN(WARN_PORTABLE))
"Octal number > 037777777777 non-portable");
}
return rnv;
}
{
register char *s = start;
register bool overflowed = FALSE;
char *hexdigit;
for (; len-- && *s; s++) {
if (!hexdigit) {
{
--len;
++s;
}
/* Disallow 0xxx0x0xxx... */
continue;
}
else {
if (ckWARN(WARN_DIGIT))
"Illegal hexadecimal digit '%c' ignored", *s);
break;
}
}
if (!overflowed) {
overflowed = TRUE;
if (ckWARN_d(WARN_OVERFLOW))
"Integer overflow in hexadecimal number");
}
else
}
if (overflowed) {
rnv *= 16.0;
/* If an NV has not enough bits in its mantissa to
* represent an UV this summing of small low-order numbers
* is a waste of time (because the NV cannot preserve
* the low-order bits anyway): we could just remember when
* did we overflow and in the end just multiply rnv by the
* right amount of 16-tuples. */
}
}
if (!overflowed)
#if UVSIZE > 4
#endif
) {
if (ckWARN(WARN_PORTABLE))
"Hexadecimal number > 0xffffffff non-portable");
}
return rnv;
}
char*
{
char tmpbuf[MAXPATHLEN];
register char *s;
int retval;
# define MAX_EXT_LEN 4
#endif
#ifdef OS2
# define MAX_EXT_LEN 4
#endif
#ifdef VMS
# define MAX_EXT_LEN 4
#endif
/* additional extensions to try in each dir if scriptname not found */
#ifdef SEARCH_EXTS
char *exts[] = { SEARCH_EXTS };
int extidx = 0, i = 0;
#else
# define MAX_EXT_LEN 0
#endif
/*
* If dosearch is true and if scriptname does not contain path
* delimiters, search the PATH for scriptname.
*
* If SEARCH_EXTS is also defined, will look for each
* scriptname{SEARCH_EXTS} whenever scriptname is not found
* while searching the PATH.
*
* Assuming SEARCH_EXTS is C<".foo",".bar",NULL>, PATH search
* proceeds as follows:
* If DOSISH or VMSISH:
* + look for ./scriptname{,.foo,.bar}
* + search the PATH for scriptname{,.foo,.bar}
*
* If !DOSISH:
* + look *only* in the PATH for scriptname{,.foo,.bar} (note
* this will not look in '.' if it's not in the PATH)
*/
tmpbuf[0] = '\0';
#ifdef VMS
# ifdef ALWAYS_DEFTYPES
bool seen_dot = 1;
# else
if (dosearch) {
bool seen_dot = 1;
# endif
/* The first time through, just add SEARCH_EXTS to whatever we
* already have, so we can check for default file types. */
while (deftypes ||
{
if (deftypes) {
deftypes = 0;
*tmpbuf = '\0';
}
+ MAX_EXT_LEN) >= sizeof tmpbuf)
continue; /* don't search dir with too-long name */
#else /* !VMS */
#ifdef DOSISH
dosearch = 0;
if (dosearch) { /* Look in '.' first. */
char *cur = scriptname;
#ifdef SEARCH_EXTS
while (ext[i])
break;
}
do {
#endif
"Looking for %s\n",cur));
dosearch = 0;
scriptname = cur;
#ifdef SEARCH_EXTS
break;
#endif
}
#ifdef SEARCH_EXTS
if (cur == scriptname) {
break;
}
#endif
}
#endif
#ifdef MACOS_TRADITIONAL
(s = PerlEnv_getenv("Commands")))
#else
#ifdef DOSISH
#endif
&& (s = PerlEnv_getenv("PATH")))
#endif
{
bool seen_dot = 0;
while (s < PL_bufend) {
#ifdef MACOS_TRADITIONAL
',',
&len);
#else
for (len = 0; *s
# ifdef atarist
&& *s != ','
# endif
&& *s != ';'; len++, s++) {
}
#else /* ! (atarist || DOSISH) */
':',
&len);
#endif /* ! (atarist || DOSISH) */
#endif /* MACOS_TRADITIONAL */
if (s < PL_bufend)
s++;
continue; /* don't search dir with too-long name */
#ifdef MACOS_TRADITIONAL
#else
if (len
#endif
)
seen_dot = 1;
#endif
#endif /* !VMS */
#ifdef SEARCH_EXTS
if (extidx > 0) /* reset after previous loop */
extidx = 0;
do {
#endif
retval = -1;
}
#ifdef SEARCH_EXTS
} while ( retval < 0 /* not there */
);
#endif
if (retval < 0)
continue;
#if !defined(DOSISH) && !defined(MACOS_TRADITIONAL)
#endif
)
{
break;
}
if (!xfailed)
}
#ifndef DOSISH
#endif
if (!xfound) {
}
scriptname = Nullch;
}
if (xfailed)
scriptname = xfound;
}
}
#ifndef PERL_GET_CONTEXT_DEFINED
void *
Perl_get_context(void)
{
#if defined(USE_THREADS) || defined(USE_ITHREADS)
# ifdef OLD_PTHREADS_API
if (pthread_getspecific(PL_thr_key, &t))
Perl_croak_nocontext("panic: pthread_getspecific");
return (void*)t;
# else
# ifdef I_MACH_CTHREADS
return (void*)cthread_data(cthread_self());
# else
return (void*)pthread_getspecific(PL_thr_key);
# endif
# endif
#else
return (void*)NULL;
#endif
}
void
Perl_set_context(void *t)
{
#if defined(USE_THREADS) || defined(USE_ITHREADS)
# ifdef I_MACH_CTHREADS
cthread_set_data(cthread_self(), t);
# else
if (pthread_setspecific(PL_thr_key, t))
Perl_croak_nocontext("panic: pthread_setspecific");
# endif
#endif
}
#endif /* !PERL_GET_CONTEXT_DEFINED */
#ifdef USE_THREADS
#ifdef FAKE_THREADS
/* Very simplistic scheduler for now */
void
schedule(void)
{
}
void
{
*cp = 0;
}
void
{
if (!cond)
return;
/* Insert t in the runnable queue just ahead of us */
thr->i.wait_queue = 0;
/* Remove from the wait queue */
}
void
{
/* Insert t in the runnable queue just ahead of us */
thr->i.wait_queue = 0;
/* Remove from the wait queue */
}
*cp = 0;
}
void
{
/* Remove ourselves from runnable queue */
}
#endif /* FAKE_THREADS */
MAGIC *
{
if (!mg) {
condpair_t *cp;
LOCK_CRED_MUTEX; /* XXX need separate mutex? */
if (mg) {
/* someone else beat us to initialising it */
UNLOCK_CRED_MUTEX; /* XXX need separate mutex? */
}
else {
UNLOCK_CRED_MUTEX; /* XXX need separate mutex? */
}
}
return mg;
}
SV *
{
}
else {
}
return sv;
}
/*
* Make a new perl thread structure using t as a prototype. Some of the
* fields for the new thread are copied from the prototype thread, t,
* so t should not be running in perl at the time this function is
* thread calling new_struct_thread) clearly satisfies this constraint.
*/
struct perl_thread *
{
#if !defined(PERL_IMPLICIT_CONTEXT)
struct perl_thread *thr;
#endif
I32 i;
#ifdef DEBUGGING
PL_markstack = 0;
PL_scopestack = 0;
PL_savestack = 0;
PL_retstack = 0;
PL_dirty = 0;
PL_localizing = 0;
PL_efloatbuf = (char*)NULL;
PL_efloatsize = 0;
#else
#endif
init_stacks();
PL_restartop = 0;
PL_maxscream = -1;
PL_regindent = 0;
PL_reginterp_cnt = 0;
PL_screamfirst = 0;
PL_screamnext = 0;
PL_reg_start_tmp = 0;
PL_reg_start_tmpl = 0;
/* parent thread's data needs to be locked while we make copy */
MUTEX_LOCK(&t->mutex);
#ifdef PERL_FLEXIBLE_EXCEPTIONS
PL_protect = t->Tprotect;
#endif
PL_tainted = t->Ttainted;
PL_chopset = t->Tchopset;
if (t->Tformtarget == t->Ttoptarget)
else
/* Initialise all per-thread SVs that the template thread used */
}
}
PL_nthreads++;
/* done copying parent's state */
MUTEX_UNLOCK(&t->mutex);
#ifdef HAVE_THREAD_INTERN
#endif /* HAVE_THREAD_INTERN */
return thr;
}
#endif /* USE_THREADS */
/*
* This hack is to force load of "huge" support from libm.a
* So it is in perl for (say) POSIX to use.
* Needed for SunOS with Sun's 'acc' for example.
*/
Perl_huge(void)
{
# if defined(USE_LONG_DOUBLE) && defined(HUGE_VALL)
return HUGE_VALL;
# endif
return HUGE_VAL;
}
#endif
#ifdef PERL_GLOBAL_STRUCT
struct perl_vars *
{
return &PL_Vars;
}
#endif
char **
{
return PL_op_name;
}
char **
{
return PL_op_desc;
}
char *
{
return (char*)PL_no_modify;
}
U32 *
{
return PL_opargs;
}
{
return &PL_ppaddr;
}
#ifndef HAS_GETENV_LEN
char *
{
if (env_trans)
return env_trans;
}
#endif
{
switch(vtbl_id) {
case want_vtbl_sv:
result = &PL_vtbl_sv;
break;
case want_vtbl_env:
result = &PL_vtbl_env;
break;
case want_vtbl_envelem:
break;
case want_vtbl_sig:
result = &PL_vtbl_sig;
break;
case want_vtbl_sigelem:
break;
case want_vtbl_pack:
result = &PL_vtbl_pack;
break;
case want_vtbl_packelem:
break;
case want_vtbl_dbline:
result = &PL_vtbl_dbline;
break;
case want_vtbl_isa:
result = &PL_vtbl_isa;
break;
case want_vtbl_isaelem:
break;
case want_vtbl_arylen:
result = &PL_vtbl_arylen;
break;
case want_vtbl_glob:
result = &PL_vtbl_glob;
break;
case want_vtbl_mglob:
result = &PL_vtbl_mglob;
break;
case want_vtbl_nkeys:
result = &PL_vtbl_nkeys;
break;
case want_vtbl_taint:
result = &PL_vtbl_taint;
break;
case want_vtbl_substr:
result = &PL_vtbl_substr;
break;
case want_vtbl_vec:
result = &PL_vtbl_vec;
break;
case want_vtbl_pos:
result = &PL_vtbl_pos;
break;
case want_vtbl_bm:
result = &PL_vtbl_bm;
break;
case want_vtbl_fm:
result = &PL_vtbl_fm;
break;
case want_vtbl_uvar:
result = &PL_vtbl_uvar;
break;
#ifdef USE_THREADS
case want_vtbl_mutex:
result = &PL_vtbl_mutex;
break;
#endif
case want_vtbl_defelem:
break;
case want_vtbl_regexp:
result = &PL_vtbl_regexp;
break;
case want_vtbl_regdata:
break;
case want_vtbl_regdatum:
break;
#ifdef USE_LOCALE_COLLATE
case want_vtbl_collxfrm:
break;
#endif
case want_vtbl_amagic:
result = &PL_vtbl_amagic;
break;
case want_vtbl_amagicelem:
break;
case want_vtbl_backref:
break;
}
return result;
}
#if !defined(FFLUSH_NULL) && defined(HAS__FWALK)
static int
{
}
#endif
{
#if defined(FFLUSH_NULL)
return PerlIO_flush(NULL);
#else
# if defined(HAS__FWALK)
/* undocumented, unprototyped, but very useful BSDism */
return 0;
# else
long open_max = -1;
# if defined(FFLUSH_ALL) && defined(HAS_STDIO_STREAM_ARRAY)
# ifdef PERL_FFLUSH_ALL_FOPEN_MAX
# else
# if defined(HAS_SYSCONF) && defined(_SC_OPEN_MAX)
# else
# ifdef FOPEN_MAX
# else
# ifdef OPEN_MAX
# else
# ifdef _NFILE
# endif
# endif
# endif
# endif
# endif
if (open_max > 0) {
long i;
for (i = 0; i < open_max; i++)
if (STDIO_STREAM_ARRAY[i]._file >= 0 &&
return 0;
}
# endif
return EOF;
# endif
#endif
}
Perl_my_atof(pTHX_ const char* s)
{
NV x = 0.0;
#ifdef USE_LOCALE_NUMERIC
if (PL_numeric_local && IN_LOCALE) {
NV y;
Perl_atof2(s, x);
Perl_atof2(s, y);
if ((y < 0.0 && y < x) || (y > 0.0 && y > x))
return y;
}
else
Perl_atof2(s, x);
#else
Perl_atof2(s, x);
#endif
return x;
}
void
{
char *vile;
char *func =
PL_op_desc[op];
"socket" : "filehandle";
vile = "closed";
}
else {
vile = "unopened";
}
}
"\t(Are you trying to call %s%s on dirhandle %s?)\n",
}
else {
"\t(Are you trying to call %s%s on dirhandle?)\n",
}
}
#ifdef EBCDIC
/* in ASCII order, not that it matters */
static const char controllablechars[] = "?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_";
int
{
if (ch > 'a') {
char *ctlp;
}
if (ctlp == controllablechars)
return('\177'); /* DEL */
else
} else { /* Want uncontrol */
return('?');
else if (ch == '\157')
return('\177');
else if (ch == '\174')
return('\000');
return('\036');
else if (ch == '\155')
return('\037');
else
}
}
#endif