summaryrefslogtreecommitdiff
path: root/perl.c
diff options
context:
space:
mode:
authorPerl 5 Porters <perl5-porters@africa.nicoh.com>1997-04-25 00:00:00 +1200
committerChip Salzenberg <chip@atlantic.net>1997-04-25 00:00:00 +1200
commitfc36a67e8855d031b2a6921819d899eb149eee2d (patch)
tree7e927725470a83d271eae7d78123f60cb86e60df /perl.c
parent74a7701791a30556a92328b89e5a00414a4ce4a3 (diff)
downloadperl-fc36a67e8855d031b2a6921819d899eb149eee2d.tar.gz
[inseparable changes from match from perl-5.003_97h to perl-5.003_97i]
CORE PORTABILITY Subject: Provide memset() if it's missing From: Chip Salzenberg <chip@perl.com> Files: global.sym perl.h proto.h util.c Subject: Don't tell GCC that warn(), croak(), and die() are printf-lik From: Chip Salzenberg <chip@perl.com> Files: proto.h DOCUMENTATION Subject: FAQ udpate (24-apr-97) Date: Thu, 24 Apr 1997 16:47:23 -0600 (MDT) From: Nathan Torkington <gnat@prometheus.frii.com> Files: pod/perlfaq*.pod private-msgid: 199704242247.QAA07010@prometheus.frii.com OTHER CORE CHANGES Subject: Misc. sv_vcatpvfn() fixes From: Hugo van der Sanden <hv@crypt.compulink.co.uk> Files: gv.c mg.c op.c perl.c pp.c pp_ctl.c sv.c toke.c util.c Subject: Enforce order of sprintf() elements From: Chip Salzenberg <chip@perl.com> Files: sv.c Subject: Guard against long numbers, <<LONG_DELIM, and <long glob> From: Chip Salzenberg <chip@perl.com> Files: global.sym mg.c perl.c pod/perldiag.pod proto.h toke.c util.c Subject: Guard against C<goto> to deeply nested label From: Chip Salzenberg <chip@perl.com> Files: pod/perldiag.pod pp_ctl.c Subject: Guard against overflow in dup2() emulation From: Chip Salzenberg <chip@perl.com> Files: util.c Subject: Win32: Guard against long function names From: Chip Salzenberg <chip@perl.com> Files: win32/win32sck.c Subject: Make mess() always work, by using a non-arena SV From: Chip Salzenberg <chip@perl.com> Files: perl.c util.c Subject: When copying a format line, take only its string value From: Chip Salzenberg <chip@perl.com> Files: sv.c Subject: Fix LEAKTEST numbers From: Chip Salzenberg <chip@perl.com> Files: ext/DynaLoader/dl_vms.xs handy.h os2/os2.c util.c vms/vms.c win32/win32.c win32/win32sck.c
Diffstat (limited to 'perl.c')
-rw-r--r--perl.c93
1 files changed, 58 insertions, 35 deletions
diff --git a/perl.c b/perl.c
index b4d69cb80c..8af7172d16 100644
--- a/perl.c
+++ b/perl.c
@@ -377,11 +377,6 @@ register PerlInterpreter *sv_interp;
(long)cxstack_ix + 1);
}
-
- /* Without SVs, messages must be primitive. */
- SvREFCNT_dec(mess_sv);
- mess_sv = &sv_undef;
-
/* Now absolutely destruct everything, somehow or other, loops or no. */
last_sv_count = 0;
SvFLAGS(strtab) |= SVTYPEMASK; /* don't clean out strtab now */
@@ -433,9 +428,20 @@ register PerlInterpreter *sv_interp;
if (origfilename)
Safefree(origfilename);
nuke_stacks();
- hints = 0; /* Reset hints. Should hints be per-interpreter ? */
+ hints = 0; /* Reset hints. Should hints be per-interpreter ? */
DEBUG_P(debprofdump());
+
+ /* As the absolutely last thing, free the non-arena SV for mess() */
+
+ if (mess_sv) {
+ /* we know that type >= SVt_PV */
+ SvOOK_off(mess_sv);
+ Safefree(SvPVX(mess_sv));
+ Safefree(SvANY(mess_sv));
+ Safefree(mess_sv);
+ mess_sv = Nullsv;
+ }
}
void
@@ -1614,15 +1620,19 @@ SV *sv;
I32 len;
int retval;
#if defined(DOSISH) && !defined(OS2) && !defined(atarist)
-#define SEARCH_EXTS ".bat", ".cmd", NULL
+# define SEARCH_EXTS ".bat", ".cmd", NULL
+# define MAX_EXT_LEN 4
#endif
#ifdef VMS
# define SEARCH_EXTS ".pl", ".com", NULL
+# define MAX_EXT_LEN 4
#endif
/* additional extensions to try in each dir if scriptname not found */
#ifdef SEARCH_EXTS
char *ext[] = { SEARCH_EXTS };
int extidx = (strchr(scriptname,'.')) ? -1 : 0; /* has ext already */
+#else
+# define MAX_EXT_LEN 0
#endif
#ifdef VMS
@@ -1632,38 +1642,51 @@ SV *sv;
hasdir = (strpbrk(scriptname,":[</") != Nullch) ;
/* The first time through, just add SEARCH_EXTS to whatever we
* already have, so we can check for default file types. */
- while (deftypes || (!hasdir && my_trnlnm("DCL$PATH",tokenbuf,idx++)) ) {
- if (deftypes) { deftypes = 0; *tokenbuf = '\0'; }
- strcat(tokenbuf,scriptname);
+ while (deftypes ||
+ (!hasdir && my_trnlnm("DCL$PATH",tokenbuf,idx++)) )
+ {
+ if (deftypes) {
+ deftypes = 0;
+ *tokenbuf = '\0';
+ }
+ if ((strlen(tokenbuf) + strlen(scriptname)
+ + MAX_EXT_LEN) >= sizeof tokenbuf)
+ continue; /* don't search dir with too-long name */
+ strcat(tokenbuf, scriptname);
#else /* !VMS */
if (dosearch && !strchr(scriptname, '/') && (s = getenv("PATH"))) {
-
bufend = s + strlen(s);
- while (*s) {
-#ifndef DOSISH
- s = cpytill(tokenbuf,s,bufend,':',&len);
+ while (s < bufend) {
+#ifndef atarist
+ s = delimcpy(tokenbuf, tokenbuf + sizeof tokenbuf, s, bufend,
+#ifdef DOSISH
+ ';',
#else
-#ifdef atarist
- for (len = 0; *s && *s != ',' && *s != ';'; tokenbuf[len++] = *s++);
- tokenbuf[len] = '\0';
-#else
- for (len = 0; *s && *s != ';'; tokenbuf[len++] = *s++);
- tokenbuf[len] = '\0';
-#endif
+ ':',
#endif
- if (*s)
+ &len);
+#else /* atarist */
+ for (len = 0; *s && *s != ',' && *s != ';'; len++, s++) {
+ if (len < sizeof tokenbuf)
+ tokenbuf[len] = *s;
+ }
+ if (len < sizeof tokenbuf)
+ tokenbuf[len] = '\0';
+#endif /* atarist */
+ if (s < bufend)
s++;
-#ifndef DOSISH
- if (len && tokenbuf[len-1] != '/')
-#else
-#ifdef atarist
- if (len && ((tokenbuf[len-1] != '\\') && (tokenbuf[len-1] != '/')))
-#else
- if (len && tokenbuf[len-1] != '\\')
-#endif
-#endif
- (void)strcat(tokenbuf+len,"/");
- (void)strcat(tokenbuf+len,scriptname);
+ if (len + 1 + strlen(scriptname) + MAX_EXT_LEN >= sizeof tokenbuf)
+ continue; /* don't search dir with too-long name */
+ if (len
+#if defined(atarist) && !defined(DOSISH)
+ && tokenbuf[len - 1] != '/'
+#endif
+#if defined(atarist) || defined(DOSISH)
+ && tokenbuf[len - 1] != '\\'
+#endif
+ )
+ tokenbuf[len++] = '/';
+ (void)strcpy(tokenbuf + len, scriptname);
#endif /* !VMS */
#ifdef SEARCH_EXTS
@@ -1743,7 +1766,7 @@ sed %s -e \"/^[^#]/b\" \
-e \"/^#[ ]*undef[ ]/b\" \
-e \"/^#[ ]*endif/b\" \
-e \"s/^#.*//\" \
- %s | %S -C %S %s",
+ %s | %_ -C %_ %s",
(doextract ? "-e \"1,/^#/d\n\"" : ""),
#else
sv_setpvf(cmd, "\
@@ -1758,7 +1781,7 @@ sed %s -e \"/^[^#]/b\" \
-e '/^#[ ]*undef[ ]/b' \
-e '/^#[ ]*endif/b' \
-e 's/^[ ]*#.*//' \
- %s | %S -C %S %s",
+ %s | %_ -C %_ %s",
#ifdef LOC_SED
LOC_SED,
#else