summaryrefslogtreecommitdiff
path: root/perl.c
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>1997-11-11 23:08:54 +0000
committerGurusamy Sarathy <gsar@cpan.org>1997-11-11 23:08:54 +0000
commite7cd54d7e2bd82a89f30e2f71675be1f5d3be34d (patch)
treef6873b8c4849ed68422779287f972403412a3412 /perl.c
parent1d64a758d60d7ded97c59c753fea85d3365ca0df (diff)
parent004955206412e3e53b76d4dad6bc7ac3032c300a (diff)
downloadperl-e7cd54d7e2bd82a89f30e2f71675be1f5d3be34d.tar.gz
Initial (untested) integration of mainline changes.
p4raw-id: //depot/win32/perl@234
Diffstat (limited to 'perl.c')
-rw-r--r--perl.c185
1 files changed, 80 insertions, 105 deletions
diff --git a/perl.c b/perl.c
index 56ef5faccf..338193d937 100644
--- a/perl.c
+++ b/perl.c
@@ -97,7 +97,7 @@ catch_sigsegv(int signo, struct sigcontext_struct sc)
#endif
PerlInterpreter *
-perl_alloc()
+perl_alloc(void)
{
PerlInterpreter *sv_interp;
@@ -107,8 +107,7 @@ perl_alloc()
}
void
-perl_construct( sv_interp )
-register PerlInterpreter *sv_interp;
+perl_construct(register PerlInterpreter *sv_interp)
{
#ifdef USE_THREADS
int i;
@@ -226,8 +225,7 @@ register PerlInterpreter *sv_interp;
}
void
-perl_destruct(sv_interp)
-register PerlInterpreter *sv_interp;
+perl_destruct(register PerlInterpreter *sv_interp)
{
dTHR;
int destruct_level; /* 0=none, 1=full, 2=full with checks */
@@ -474,8 +472,7 @@ register PerlInterpreter *sv_interp;
envgv = Nullgv;
siggv = Nullgv;
incgv = Nullgv;
- errhv = Nullhv;
- errsv = Nullsv;
+ errgv = Nullgv;
argvgv = Nullgv;
argvoutgv = Nullgv;
stdingv = Nullgv;
@@ -586,8 +583,7 @@ register PerlInterpreter *sv_interp;
}
void
-perl_free(sv_interp)
-PerlInterpreter *sv_interp;
+perl_free(PerlInterpreter *sv_interp)
{
if (!(curinterp = sv_interp))
return;
@@ -595,12 +591,7 @@ PerlInterpreter *sv_interp;
}
int
-perl_parse(sv_interp, xsinit, argc, argv, env)
-PerlInterpreter *sv_interp;
-void (*xsinit)_((void));
-int argc;
-char **argv;
-char **env;
+perl_parse(PerlInterpreter *sv_interp, void (*xsinit) (void), int argc, char **argv, char **env)
{
dTHR;
register SV *sv;
@@ -1001,8 +992,7 @@ print \" \\@INC:\\n @INC\\n\";");
}
int
-perl_run(sv_interp)
-PerlInterpreter *sv_interp;
+perl_run(PerlInterpreter *sv_interp)
{
dTHR;
I32 oldscope;
@@ -1087,20 +1077,26 @@ PerlInterpreter *sv_interp;
}
SV*
-perl_get_sv(name, create)
-char* name;
-I32 create;
+perl_get_sv(char *name, I32 create)
{
- GV* gv = gv_fetchpv(name, create, SVt_PV);
+ GV *gv;
+#ifdef USE_THREADS
+ if (name[1] == '\0' && !isALPHA(name[0])) {
+ PADOFFSET tmp = find_thread_magical(name);
+ if (tmp != NOT_IN_PAD) {
+ dTHR;
+ return *av_fetch(thr->magicals, tmp, FALSE);
+ }
+ }
+#endif /* USE_THREADS */
+ gv = gv_fetchpv(name, create, SVt_PV);
if (gv)
return GvSV(gv);
return Nullsv;
}
AV*
-perl_get_av(name, create)
-char* name;
-I32 create;
+perl_get_av(char *name, I32 create)
{
GV* gv = gv_fetchpv(name, create, SVt_PVAV);
if (create)
@@ -1111,9 +1107,7 @@ I32 create;
}
HV*
-perl_get_hv(name, create)
-char* name;
-I32 create;
+perl_get_hv(char *name, I32 create)
{
GV* gv = gv_fetchpv(name, create, SVt_PVHV);
if (create)
@@ -1124,9 +1118,7 @@ I32 create;
}
CV*
-perl_get_cv(name, create)
-char* name;
-I32 create;
+perl_get_cv(char *name, I32 create)
{
GV* gv = gv_fetchpv(name, create, SVt_PVCV);
if (create && !GvCVu(gv))
@@ -1142,12 +1134,11 @@ I32 create;
/* Be sure to refetch the stack pointer after calling these routines. */
I32
-perl_call_argv(subname, flags, argv)
-char *subname;
-I32 flags; /* See G_* flags in cop.h */
-register char **argv; /* null terminated arg list */
+perl_call_argv(char *subname, I32 flags, register char **argv)
+
+ /* See G_* flags in cop.h */
+ /* null terminated arg list */
{
- dTHR;
dSP;
PUSHMARK(sp);
@@ -1162,19 +1153,18 @@ register char **argv; /* null terminated arg list */
}
I32
-perl_call_pv(subname, flags)
-char *subname; /* name of the subroutine */
-I32 flags; /* See G_* flags in cop.h */
+perl_call_pv(char *subname, I32 flags)
+ /* name of the subroutine */
+ /* See G_* flags in cop.h */
{
return perl_call_sv((SV*)perl_get_cv(subname, TRUE), flags);
}
I32
-perl_call_method(methname, flags)
-char *methname; /* name of the subroutine */
-I32 flags; /* See G_* flags in cop.h */
+perl_call_method(char *methname, I32 flags)
+ /* name of the subroutine */
+ /* See G_* flags in cop.h */
{
- dTHR;
dSP;
OP myop;
if (!op)
@@ -1187,9 +1177,9 @@ I32 flags; /* See G_* flags in cop.h */
/* May be called with any of a CV, a GV, or an SV containing the name. */
I32
-perl_call_sv(sv, flags)
-SV* sv;
-I32 flags; /* See G_* flags in cop.h */
+perl_call_sv(SV *sv, I32 flags)
+
+ /* See G_* flags in cop.h */
{
dTHR;
LOGOP myop; /* fake syntax tree node */
@@ -1251,7 +1241,7 @@ I32 flags; /* See G_* flags in cop.h */
if (flags & G_KEEPERR)
in_eval |= 4;
else
- sv_setpv(errsv,"");
+ sv_setpv(ERRSV,"");
}
markstack_ptr++;
@@ -1296,7 +1286,7 @@ I32 flags; /* See G_* flags in cop.h */
runops();
retval = stack_sp - (stack_base + oldmark);
if ((flags & G_EVAL) && !(flags & G_KEEPERR))
- sv_setpv(errsv,"");
+ sv_setpv(ERRSV,"");
cleanup:
if (flags & G_EVAL) {
@@ -1331,9 +1321,9 @@ I32 flags; /* See G_* flags in cop.h */
/* Eval a string. The G_EVAL flag is always assumed. */
I32
-perl_eval_sv(sv, flags)
-SV* sv;
-I32 flags; /* See G_* flags in cop.h */
+perl_eval_sv(SV *sv, I32 flags)
+
+ /* See G_* flags in cop.h */
{
dTHR;
UNOP myop; /* fake syntax tree node */
@@ -1405,7 +1395,7 @@ I32 flags; /* See G_* flags in cop.h */
runops();
retval = stack_sp - (stack_base + oldmark);
if (!(flags & G_KEEPERR))
- sv_setpv(errsv,"");
+ sv_setpv(ERRSV,"");
cleanup:
JMPENV_POP;
@@ -1420,11 +1410,8 @@ I32 flags; /* See G_* flags in cop.h */
}
SV*
-perl_eval_pv(p, croak_on_error)
-char* p;
-I32 croak_on_error;
+perl_eval_pv(char *p, I32 croak_on_error)
{
- dTHR;
dSP;
SV* sv = newSVpv(p, 0);
@@ -1436,8 +1423,8 @@ I32 croak_on_error;
sv = POPs;
PUTBACK;
- if (croak_on_error && SvTRUE(errsv))
- croak(SvPV(errsv, na));
+ if (croak_on_error && SvTRUE(ERRSV))
+ croak(SvPVx(ERRSV, na));
return sv;
}
@@ -1445,8 +1432,7 @@ I32 croak_on_error;
/* Require a module. */
void
-perl_require_pv(pv)
-char* pv;
+perl_require_pv(char *pv)
{
SV* sv = sv_newmortal();
sv_setpv(sv, "require '");
@@ -1456,10 +1442,7 @@ char* pv;
}
void
-magicname(sym,name,namlen)
-char *sym;
-char *name;
-I32 namlen;
+magicname(char *sym, char *name, I32 namlen)
{
register GV *gv;
@@ -1468,8 +1451,8 @@ I32 namlen;
}
static void
-usage(name) /* XXX move this out into a module ? */
-char *name;
+usage(char *name) /* XXX move this out into a module ? */
+
{
/* This message really ought to be max 23 lines.
* Removed -h because the user already knows that opton. Others? */
@@ -1511,8 +1494,7 @@ NULL
/* This routine handles any switches that can be given during run */
char *
-moreswitches(s)
-char *s;
+moreswitches(char *s)
{
I32 numlen;
U32 rschar;
@@ -1756,7 +1738,7 @@ GNU General Public License, which may be found in the Perl 5.0 source kit.\n\n")
/* unexec() can be found in the Gnu emacs distribution */
void
-my_unexec()
+my_unexec(void)
{
#ifdef UNEXEC
SV* prog;
@@ -1785,7 +1767,7 @@ my_unexec()
}
static void
-init_main_stash()
+init_main_stash(void)
{
dTHR;
GV *gv;
@@ -1808,11 +1790,11 @@ init_main_stash()
incgv = gv_HVadd(gv_AVadd(gv_fetchpv("INC",TRUE, SVt_PVAV)));
GvMULTI_on(incgv);
defgv = gv_fetchpv("_",TRUE, SVt_PVAV);
- errsv = newSVpv("", 0);
- errhv = newHV();
+ errgv = gv_HVadd(gv_fetchpv("@", TRUE, SVt_PV));
+ GvMULTI_on(errgv);
(void)form("%240s",""); /* Preallocate temp - for immediate signals. */
- sv_grow(errsv, 240); /* Preallocate - for immediate signals. */
- sv_setpvn(errsv, "", 0);
+ sv_grow(ERRSV, 240); /* Preallocate - for immediate signals. */
+ sv_setpvn(ERRSV, "", 0);
curstash = defstash;
compiling.cop_stash = defstash;
debstash = GvHV(gv_fetchpv("DB::", GV_ADDMULTI, SVt_PVHV));
@@ -2145,9 +2127,7 @@ sed %s -e \"/^[^#]/b\" \
}
static void
-validate_suid(validarg, scriptname)
-char *validarg;
-char *scriptname;
+validate_suid(char *validarg, char *scriptname)
{
int which;
@@ -2387,7 +2367,7 @@ FIX YOUR KERNEL, PUT A C WRAPPER AROUND THIS SCRIPT, OR USE -u AND UNDUMP!\n");
}
static void
-find_beginning()
+find_beginning(void)
{
register char *s, *s2;
@@ -2416,7 +2396,7 @@ find_beginning()
}
static void
-init_ids()
+init_ids(void)
{
uid = (int)getuid();
euid = (int)geteuid();
@@ -2430,8 +2410,7 @@ init_ids()
}
static void
-forbid_setid(s)
-char *s;
+forbid_setid(char *s)
{
if (euid != uid)
croak("No %s allowed while running setuid", s);
@@ -2440,7 +2419,7 @@ char *s;
}
static void
-init_debugger()
+init_debugger(void)
{
dTHR;
curstash = debstash;
@@ -2459,8 +2438,7 @@ init_debugger()
}
void
-init_stacks(ARGS)
-dARGS
+init_stacks(ARGSproto)
{
curstack = newAV();
mainstack = curstack; /* remember in case we switch stacks */
@@ -2519,7 +2497,7 @@ dARGS
}
static void
-nuke_stacks()
+nuke_stacks(void)
{
dTHR;
Safefree(cxstack);
@@ -2533,7 +2511,7 @@ nuke_stacks()
static PerlIO *tmpfp; /* moved outside init_lexer() because of UNICOS bug */
static void
-init_lexer()
+init_lexer(void)
{
tmpfp = rsfp;
rsfp = Nullfp;
@@ -2543,7 +2521,7 @@ init_lexer()
}
static void
-init_predump_symbols()
+init_predump_symbols(void)
{
dTHR;
GV *tmpgv;
@@ -2584,10 +2562,7 @@ init_predump_symbols()
}
static void
-init_postdump_symbols(argc,argv,env)
-register int argc;
-register char **argv;
-register char **env;
+init_postdump_symbols(register int argc, register char **argv, register char **env)
{
dTHR;
char *s;
@@ -2675,7 +2650,7 @@ register char **env;
}
static void
-init_perllib()
+init_perllib(void)
{
char *s;
if (!tainting) {
@@ -2742,9 +2717,7 @@ init_perllib()
#endif
static void
-incpush(p, addsubdirs)
-char *p;
-int addsubdirs;
+incpush(char *p, int addsubdirs)
{
SV *subdir = Nullsv;
static char *archpat_auto;
@@ -2845,6 +2818,7 @@ init_main_thread()
thr->cvcache = newHV();
thr->magicals = newAV();
thr->specific = newAV();
+ thr->errhv = newHV();
thr->flags = THRf_R_JOINABLE;
MUTEX_INIT(&thr->mutex);
/* Handcraft thrsv similarly to mess_sv */
@@ -2886,14 +2860,13 @@ init_main_thread()
sv_upgrade(bodytarget, SVt_PVFM);
sv_setpvn(bodytarget, "", 0);
formtarget = bodytarget;
+ thr->errsv = newSVpv("", 0);
return thr;
}
#endif /* USE_THREADS */
void
-call_list(oldscope, list)
-I32 oldscope;
-AV* list;
+call_list(I32 oldscope, AV *list)
{
dTHR;
line_t oldline = curcop->cop_line;
@@ -2909,20 +2882,21 @@ AV* list;
JMPENV_PUSH(ret);
switch (ret) {
case 0: {
+ SV* atsv = ERRSV;
PUSHMARK(stack_sp);
perl_call_sv((SV*)cv, G_EVAL|G_DISCARD);
- (void)SvPV(errsv, len);
+ (void)SvPV(atsv, len);
if (len) {
JMPENV_POP;
curcop = &compiling;
curcop->cop_line = oldline;
if (list == beginav)
- sv_catpv(errsv, "BEGIN failed--compilation aborted");
+ sv_catpv(atsv, "BEGIN failed--compilation aborted");
else
- sv_catpv(errsv, "END failed--cleanup aborted");
+ sv_catpv(atsv, "END failed--cleanup aborted");
while (scopestack_ix > oldscope)
LEAVE;
- croak("%s", SvPVX(errsv));
+ croak("%s", SvPVX(atsv));
}
}
break;
@@ -2964,8 +2938,7 @@ AV* list;
}
void
-my_exit(status)
-U32 status;
+my_exit(U32 status)
{
dTHR;
@@ -2988,7 +2961,7 @@ U32 status;
}
void
-my_failure_exit()
+my_failure_exit(void)
{
#ifdef VMS
if (vaxc$errno & 1) {
@@ -3011,7 +2984,7 @@ my_failure_exit()
}
static void
-my_exit_jump()
+my_exit_jump(void)
{
dTHR;
register CONTEXT *cx;
@@ -3037,3 +3010,5 @@ my_exit_jump()
JMPENV_JUMP(2);
}
+
+