This is a live mirror of the Perl 5 development currently hosted at
https://github.com/perl/perl5
https://perl5.git.perl.org
/
perl5.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
dquote_static.c: Clarify comment
[perl5.git]
/
doio.c
diff --git
a/doio.c
b/doio.c
index
022b499
..
fed1a49
100644
(file)
--- a/
doio.c
+++ b/
doio.c
@@
-126,8
+126,9
@@
Perl_do_openn(pTHX_ GV *gv, register const char *oname, I32 len, int as_raw,
if (result == EOF && fd > PL_maxsysfd) {
/* Why is this not Perl_warn*() call ? */
PerlIO_printf(Perl_error_log,
if (result == EOF && fd > PL_maxsysfd) {
/* Why is this not Perl_warn*() call ? */
PerlIO_printf(Perl_error_log,
- "Warning: unable to close filehandle %s properly.\n",
- GvENAME(gv));
+ "Warning: unable to close filehandle %"HEKf" properly.\n",
+ HEKfARG(GvENAME_HEK(gv))
+ );
}
IoOFP(io) = IoIFP(io) = NULL;
}
}
IoOFP(io) = IoIFP(io) = NULL;
}
@@
-148,7
+149,8
@@
Perl_do_openn(pTHX_ GV *gv, register const char *oname, I32 len, int as_raw,
int ismodifying;
if (num_svs != 0) {
int ismodifying;
if (num_svs != 0) {
- Perl_croak(aTHX_ "panic: sysopen with multiple args");
+ Perl_croak(aTHX_ "panic: sysopen with multiple args, num_svs=%ld",
+ (long) num_svs);
}
/* It's not always
}
/* It's not always
@@
-318,7
+320,10
@@
Perl_do_openn(pTHX_ GV *gv, register const char *oname, I32 len, int as_raw,
}
while (isSPACE(*type))
type++;
}
while (isSPACE(*type))
type++;
- if (num_svs && (SvIOK(*svp) || (SvPOK(*svp) && looks_like_number(*svp)))) {
+ if (num_svs && (
+ SvIOK(*svp)
+ || (SvPOKp(*svp) && looks_like_number(*svp))
+ )) {
fd = SvUV(*svp);
num_svs = 0;
}
fd = SvUV(*svp);
num_svs = 0;
}
@@
-541,14
+546,16
@@
Perl_do_openn(pTHX_ GV *gv, register const char *oname, I32 len, int as_raw,
if ((IoTYPE(io) == IoTYPE_RDONLY) &&
(fp == PerlIO_stdout() || fp == PerlIO_stderr())) {
Perl_warner(aTHX_ packWARN(WARN_IO),
if ((IoTYPE(io) == IoTYPE_RDONLY) &&
(fp == PerlIO_stdout() || fp == PerlIO_stderr())) {
Perl_warner(aTHX_ packWARN(WARN_IO),
- "Filehandle STD%s reopened as %s only for input",
+ "Filehandle STD%s reopened as %"HEKf
+ " only for input",
((fp == PerlIO_stdout()) ? "OUT" : "ERR"),
((fp == PerlIO_stdout()) ? "OUT" : "ERR"),
-
GvENAME(gv
));
+
HEKfARG(GvENAME_HEK(gv)
));
}
else if ((IoTYPE(io) == IoTYPE_WRONLY) && fp == PerlIO_stdin()) {
Perl_warner(aTHX_ packWARN(WARN_IO),
}
else if ((IoTYPE(io) == IoTYPE_WRONLY) && fp == PerlIO_stdin()) {
Perl_warner(aTHX_ packWARN(WARN_IO),
- "Filehandle STDIN reopened as %s only for output",
- GvENAME(gv));
+ "Filehandle STDIN reopened as %"HEKf" only for output",
+ HEKfARG(GvENAME_HEK(gv))
+ );
}
}
}
}
@@
-1215,26
+1222,31
@@
Perl_do_print(pTHX_ register SV *sv, PerlIO *fp)
U8 *tmpbuf = NULL;
bool happy = TRUE;
U8 *tmpbuf = NULL;
bool happy = TRUE;
- if (PerlIO_isutf8(fp)) {
- if (!SvUTF8(sv)) {
+ if (PerlIO_isutf8(fp)) {
/* If the stream is utf8 ... */
+ if (!SvUTF8(sv)) {
/* Convert to utf8 if necessary */
/* We don't modify the original scalar. */
tmpbuf = bytes_to_utf8((const U8*) tmps, &len);
tmps = (char *) tmpbuf;
}
/* We don't modify the original scalar. */
tmpbuf = bytes_to_utf8((const U8*) tmps, &len);
tmps = (char *) tmpbuf;
}
- else if (ckWARN
_d(WARN_UTF8
)) {
+ else if (ckWARN
4_d(WARN_UTF8, WARN_SURROGATE, WARN_NON_UNICODE, WARN_NONCHAR
)) {
(void) check_utf8_print((const U8*) tmps, len);
}
(void) check_utf8_print((const U8*) tmps, len);
}
- }
- else if (DO_UTF8(sv)) {
+ } /* else stream isn't utf8 */
+ else if (DO_UTF8(sv)) { /* But if is utf8 internally, attempt to
+ convert to bytes */
STRLEN tmplen = len;
bool utf8 = TRUE;
U8 * const result = bytes_from_utf8((const U8*) tmps, &tmplen, &utf8);
if (!utf8) {
STRLEN tmplen = len;
bool utf8 = TRUE;
U8 * const result = bytes_from_utf8((const U8*) tmps, &tmplen, &utf8);
if (!utf8) {
+
+ /* Here, succeeded in downgrading from utf8. Set up to below
+ * output the converted value */
tmpbuf = result;
tmps = (char *) tmpbuf;
len = tmplen;
}
tmpbuf = result;
tmps = (char *) tmpbuf;
len = tmplen;
}
- else {
+ else { /* Non-utf8 output stream, but string only representable in
+ utf8 */
assert((char *)result == tmps);
Perl_ck_warner_d(aTHX_ packWARN(WARN_UTF8),
"Wide character in %s",
assert((char *)result == tmps);
Perl_ck_warner_d(aTHX_ packWARN(WARN_UTF8),
"Wide character in %s",
@@
-1267,7
+1279,6
@@
Perl_my_stat_flags(pTHX_ const U32 flags)
GV* gv;
if (PL_op->op_flags & OPf_REF) {
GV* gv;
if (PL_op->op_flags & OPf_REF) {
- EXTEND(SP,1);
gv = cGVOP_gv;
do_fstat:
if (gv == PL_defgv)
gv = cGVOP_gv;
do_fstat:
if (gv == PL_defgv)
@@
-1275,30
+1286,26
@@
Perl_my_stat_flags(pTHX_ const U32 flags)
io = GvIO(gv);
do_fstat_have_io:
PL_laststype = OP_STAT;
io = GvIO(gv);
do_fstat_have_io:
PL_laststype = OP_STAT;
- PL_statgv = gv;
+ PL_statgv = gv
? gv : (GV *)io
;
sv_setpvs(PL_statname, "");
if(io) {
if (IoIFP(io)) {
return (PL_laststatval = PerlLIO_fstat(PerlIO_fileno(IoIFP(io)), &PL_statcache));
} else if (IoDIRP(io)) {
return (PL_laststatval = PerlLIO_fstat(my_dirfd(IoDIRP(io)), &PL_statcache));
sv_setpvs(PL_statname, "");
if(io) {
if (IoIFP(io)) {
return (PL_laststatval = PerlLIO_fstat(PerlIO_fileno(IoIFP(io)), &PL_statcache));
} else if (IoDIRP(io)) {
return (PL_laststatval = PerlLIO_fstat(my_dirfd(IoDIRP(io)), &PL_statcache));
- } else {
- report_evil_fh(gv);
- return (PL_laststatval = -1);
}
}
- } else {
- report_evil_fh(gv);
- return (PL_laststatval = -1);
}
}
+ PL_laststatval = -1;
+ report_evil_fh(gv);
+ return -1;
}
}
- else if (PL_op->op_private & OPpFT_STACKED) {
+ else if ((PL_op->op_private & (OPpFT_STACKED|OPpFT_AFTER_t))
+ == OPpFT_STACKED)
return PL_laststatval;
return PL_laststatval;
- }
else {
else {
- SV* const sv =
P
OPs;
+ SV* const sv =
T
OPs;
const char *s;
STRLEN len;
const char *s;
STRLEN len;
- PUTBACK;
if ((gv = MAYBE_DEREF_GV_flags(sv,flags))) {
goto do_fstat;
}
if ((gv = MAYBE_DEREF_GV_flags(sv,flags))) {
goto do_fstat;
}
@@
-1327,22
+1334,23
@@
Perl_my_lstat_flags(pTHX_ const U32 flags)
dVAR;
static const char no_prev_lstat[] = "The stat preceding -l _ wasn't an lstat";
dSP;
dVAR;
static const char no_prev_lstat[] = "The stat preceding -l _ wasn't an lstat";
dSP;
- SV *sv;
const char *file;
if (PL_op->op_flags & OPf_REF) {
const char *file;
if (PL_op->op_flags & OPf_REF) {
- EXTEND(SP,1);
if (cGVOP_gv == PL_defgv) {
if (PL_laststype != OP_LSTAT)
Perl_croak(aTHX_ no_prev_lstat);
return PL_laststatval;
}
if (cGVOP_gv == PL_defgv) {
if (PL_laststype != OP_LSTAT)
Perl_croak(aTHX_ no_prev_lstat);
return PL_laststatval;
}
+ PL_laststatval = -1;
if (ckWARN(WARN_IO)) {
if (ckWARN(WARN_IO)) {
- Perl_warner(aTHX_ packWARN(WARN_IO), "Use of -l on filehandle %s",
- GvENAME(cGVOP_gv));
+ Perl_warner(aTHX_ packWARN(WARN_IO),
+ "Use of -l on filehandle %"HEKf,
+ HEKfARG(GvENAME_HEK(cGVOP_gv)));
}
}
- return
(PL_laststatval = -1)
;
+ return
-1
;
}
}
- else if (PL_op->op_private & OPpFT_STACKED) {
+ if ((PL_op->op_private & (OPpFT_STACKED|OPpFT_AFTER_t))
+ == OPpFT_STACKED) {
if (PL_laststype != OP_LSTAT)
Perl_croak(aTHX_ no_prev_lstat);
return PL_laststatval;
if (PL_laststype != OP_LSTAT)
Perl_croak(aTHX_ no_prev_lstat);
return PL_laststatval;
@@
-1350,9
+1358,7
@@
Perl_my_lstat_flags(pTHX_ const U32 flags)
PL_laststype = OP_LSTAT;
PL_statgv = NULL;
PL_laststype = OP_LSTAT;
PL_statgv = NULL;
- sv = POPs;
- PUTBACK;
- file = SvPV_flags_const_nolen(sv, flags);
+ file = SvPV_flags_const_nolen(TOPs, flags);
sv_setpv(PL_statname,file);
PL_laststatval = PerlLIO_lstat(file,&PL_statcache);
if (PL_laststatval < 0 && ckWARN(WARN_NEWLINE) && strchr(file, '\n'))
sv_setpv(PL_statname,file);
PL_laststatval = PerlLIO_lstat(file,&PL_statcache);
if (PL_laststatval < 0 && ckWARN(WARN_NEWLINE) && strchr(file, '\n'))
@@
-1559,6
+1565,10
@@
Perl_do_exec3(pTHX_ const char *incmd, int fd, int do_report)
#endif /* OS2 || WIN32 */
#endif /* OS2 || WIN32 */
+#ifdef VMS
+#include <starlet.h> /* for sys$delprc */
+#endif
+
I32
Perl_apply(pTHX_ I32 type, register SV **mark, register SV **sp)
{
I32
Perl_apply(pTHX_ I32 type, register SV **mark, register SV **sp)
{
@@
-1567,6
+1577,7
@@
Perl_apply(pTHX_ I32 type, register SV **mark, register SV **sp)
register I32 tot = 0;
const char *const what = PL_op_name[type];
const char *s;
register I32 tot = 0;
const char *const what = PL_op_name[type];
const char *s;
+ STRLEN len;
SV ** const oldmark = mark;
PERL_ARGS_ASSERT_APPLY;
SV ** const oldmark = mark;
PERL_ARGS_ASSERT_APPLY;
@@
-1677,12
+1688,14
@@
nothing in the core.
APPLY_TAINT_PROPER();
if (mark == sp)
break;
APPLY_TAINT_PROPER();
if (mark == sp)
break;
- s = SvPVx_
nolen_const(*++mark
);
+ s = SvPVx_
const(*++mark, len
);
if (isALPHA(*s)) {
if (isALPHA(*s)) {
- if (*s == 'S' && s[1] == 'I' && s[2] == 'G')
+ if (*s == 'S' && s[1] == 'I' && s[2] == 'G')
{
s += 3;
s += 3;
- if ((val = whichsig(s)) < 0)
- Perl_croak(aTHX_ "Unrecognized signal name \"%s\"",s);
+ len -= 3;
+ }
+ if ((val = whichsig_pvn(s, len)) < 0)
+ Perl_croak(aTHX_ "Unrecognized signal name \"%"SVf"\"", SVfARG(*mark));
}
else
val = SvIV(*mark);
}
else
val = SvIV(*mark);
@@
-1692,7
+1705,6
@@
nothing in the core.
/* kill() doesn't do process groups (job trees?) under VMS */
if (val < 0) val = -val;
if (val == SIGKILL) {
/* kill() doesn't do process groups (job trees?) under VMS */
if (val < 0) val = -val;
if (val == SIGKILL) {
-# include <starlet.h>
/* Use native sys$delprc() to insure that target process is
* deleted; supervisor-mode images don't pay attention to
* CRTL's emulation of Unix-style signals and kill()
/* Use native sys$delprc() to insure that target process is
* deleted; supervisor-mode images don't pay attention to
* CRTL's emulation of Unix-style signals and kill()
@@
-1762,7
+1774,7
@@
nothing in the core.
while (++mark <= sp) {
s = SvPV_nolen_const(*mark);
APPLY_TAINT_PROPER();
while (++mark <= sp) {
s = SvPV_nolen_const(*mark);
APPLY_TAINT_PROPER();
- if (P
L_euid
|| PL_unsafe) {
+ if (P
erlProc_geteuid()
|| PL_unsafe) {
if (UNLINK(s))
tot--;
}
if (UNLINK(s))
tot--;
}
@@
-1900,7
+1912,7
@@
Perl_cando(pTHX_ Mode_t mode, bool effective, register const Stat_t *statbufp)
# ifdef __CYGWIN__
if (ingroup(544,effective)) { /* member of Administrators */
# else
# ifdef __CYGWIN__
if (ingroup(544,effective)) { /* member of Administrators */
# else
- if ((effective ? P
L_euid : PL_uid) == 0) {
/* root is special */
+ if ((effective ? P
erlProc_geteuid() : PerlProc_getuid()) == 0) {
/* root is special */
# endif
if (mode == S_IXUSR) {
if (statbufp->st_mode & 0111 || S_ISDIR(statbufp->st_mode))
# endif
if (mode == S_IXUSR) {
if (statbufp->st_mode & 0111 || S_ISDIR(statbufp->st_mode))
@@
-1910,7
+1922,7
@@
Perl_cando(pTHX_ Mode_t mode, bool effective, register const Stat_t *statbufp)
return TRUE; /* root reads and writes anything */
return FALSE;
}
return TRUE; /* root reads and writes anything */
return FALSE;
}
- if (statbufp->st_uid == (effective ? P
L_euid : PL_uid
) ) {
+ if (statbufp->st_uid == (effective ? P
erlProc_geteuid() : PerlProc_getuid()
) ) {
if (statbufp->st_mode & mode)
return TRUE; /* ok as "user" */
}
if (statbufp->st_mode & mode)
return TRUE; /* ok as "user" */
}
@@
-1929,7
+1941,7
@@
static bool
S_ingroup(pTHX_ Gid_t testgid, bool effective)
{
dVAR;
S_ingroup(pTHX_ Gid_t testgid, bool effective)
{
dVAR;
- if (testgid == (effective ? P
L_egid : PL_gid
))
+ if (testgid == (effective ? P
erlProc_getegid() : PerlProc_getgid()
))
return TRUE;
#ifdef HAS_GETGROUPS
{
return TRUE;
#ifdef HAS_GETGROUPS
{
@@
-2372,7
+2384,13
@@
Perl_vms_start_glob
#endif
#endif /* !CSH */
#endif /* !DOSISH */
#endif
#endif /* !CSH */
#endif /* !DOSISH */
- save_hash(gv_fetchpvs("ENV", 0, SVt_PVHV));
+ {
+ GV * const envgv = gv_fetchpvs("ENV", 0, SVt_PVHV);
+ SV ** const home = hv_fetchs(GvHV(envgv), "HOME", 0);
+ if (home && *home) SvGETMAGIC(*home);
+ save_hash(gv_fetchpvs("ENV", 0, SVt_PVHV));
+ if (home && *home) SvSETMAGIC(*home);
+ }
(void)do_open(PL_last_in_gv, (char*)SvPVX_const(tmpcmd), SvCUR(tmpcmd),
FALSE, O_RDONLY, 0, NULL);
fp = IoIFP(io);
(void)do_open(PL_last_in_gv, (char*)SvPVX_const(tmpcmd), SvCUR(tmpcmd),
FALSE, O_RDONLY, 0, NULL);
fp = IoIFP(io);
@@
-2385,8
+2403,8
@@
Perl_vms_start_glob
* Local variables:
* c-indentation-style: bsd
* c-basic-offset: 4
* Local variables:
* c-indentation-style: bsd
* c-basic-offset: 4
- * indent-tabs-mode:
t
+ * indent-tabs-mode:
nil
* End:
*
* End:
*
- * ex: set ts=8 sts=4 sw=4
no
et:
+ * ex: set ts=8 sts=4 sw=4 et:
*/
*/