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
add missing close paren in pod
[perl5.git]
/
doop.c
diff --git
a/doop.c
b/doop.c
index
1bd16b5
..
6a136d9
100644
(file)
--- a/
doop.c
+++ b/
doop.c
@@
-15,8
+15,8
@@
*/
/* This file contains some common functions needed to carry out certain
*/
/* This file contains some common functions needed to carry out certain
- * ops. For example
both pp_schomp() and pp_chomp() - scalar and array
- *
chomp operations - call the function do_chomp
() found in this file.
+ * ops. For example
, both pp_sprintf() and pp_prtf() call the function
+ *
do_printf
() found in this file.
*/
#include "EXTERN.h"
*/
#include "EXTERN.h"
@@
-30,7
+30,6
@@
STATIC I32
S_do_trans_simple(pTHX_ SV * const sv)
{
STATIC I32
S_do_trans_simple(pTHX_ SV * const sv)
{
- dVAR;
I32 matches = 0;
STRLEN len;
U8 *s = (U8*)SvPV_nomg(sv,len);
I32 matches = 0;
STRLEN len;
U8 *s = (U8*)SvPV_nomg(sv,len);
@@
-99,7
+98,6
@@
S_do_trans_simple(pTHX_ SV * const sv)
STATIC I32
S_do_trans_count(pTHX_ SV * const sv)
{
STATIC I32
S_do_trans_count(pTHX_ SV * const sv)
{
- dVAR;
STRLEN len;
const U8 *s = (const U8*)SvPV_nomg_const(sv, len);
const U8 * const send = s + len;
STRLEN len;
const U8 *s = (const U8*)SvPV_nomg_const(sv, len);
const U8 * const send = s + len;
@@
-137,7
+135,6
@@
S_do_trans_count(pTHX_ SV * const sv)
STATIC I32
S_do_trans_complex(pTHX_ SV * const sv)
{
STATIC I32
S_do_trans_complex(pTHX_ SV * const sv)
{
- dVAR;
STRLEN len;
U8 *s = (U8*)SvPV_nomg(sv, len);
U8 * const send = s+len;
STRLEN len;
U8 *s = (U8*)SvPV_nomg(sv, len);
U8 * const send = s+len;
@@
-301,7
+298,6
@@
S_do_trans_complex(pTHX_ SV * const sv)
STATIC I32
S_do_trans_simple_utf8(pTHX_ SV * const sv)
{
STATIC I32
S_do_trans_simple_utf8(pTHX_ SV * const sv)
{
- dVAR;
U8 *s;
U8 *send;
U8 *d;
U8 *s;
U8 *send;
U8 *d;
@@
-331,7
+327,7
@@
S_do_trans_simple_utf8(pTHX_ SV * const sv)
const U8 * const e = s + len;
while (t < e) {
const U8 ch = *t++;
const U8 * const e = s + len;
while (t < e) {
const U8 ch = *t++;
- hibit = !NATIVE_IS_INVARIANT(ch);
+ hibit = !NATIVE_
BYTE_
IS_INVARIANT(ch);
if (hibit) {
s = bytes_to_utf8(s, &len);
break;
if (hibit) {
s = bytes_to_utf8(s, &len);
break;
@@
-361,7
+357,7
@@
S_do_trans_simple_utf8(pTHX_ SV * const sv)
if (uv < none) {
s += UTF8SKIP(s);
matches++;
if (uv < none) {
s += UTF8SKIP(s);
matches++;
- d = uv
uni
_to_utf8(d, uv);
+ d = uv
chr
_to_utf8(d, uv);
}
else if (uv == none) {
const int i = UTF8SKIP(s);
}
else if (uv == none) {
const int i = UTF8SKIP(s);
@@
-372,7
+368,7
@@
S_do_trans_simple_utf8(pTHX_ SV * const sv)
else if (uv == extra) {
s += UTF8SKIP(s);
matches++;
else if (uv == extra) {
s += UTF8SKIP(s);
matches++;
- d = uv
uni
_to_utf8(d, final);
+ d = uv
chr
_to_utf8(d, final);
}
else
s += UTF8SKIP(s);
}
else
s += UTF8SKIP(s);
@@
-406,7
+402,6
@@
S_do_trans_simple_utf8(pTHX_ SV * const sv)
STATIC I32
S_do_trans_count_utf8(pTHX_ SV * const sv)
{
STATIC I32
S_do_trans_count_utf8(pTHX_ SV * const sv)
{
- dVAR;
const U8 *s;
const U8 *start = NULL;
const U8 *send;
const U8 *s;
const U8 *start = NULL;
const U8 *send;
@@
-432,7
+427,7
@@
S_do_trans_count_utf8(pTHX_ SV * const sv)
const U8 * const e = s + len;
while (t < e) {
const U8 ch = *t++;
const U8 * const e = s + len;
while (t < e) {
const U8 ch = *t++;
- hibit = !NATIVE_IS_INVARIANT(ch);
+ hibit = !NATIVE_
BYTE_
IS_INVARIANT(ch);
if (hibit) {
start = s = bytes_to_utf8(s, &len);
break;
if (hibit) {
start = s = bytes_to_utf8(s, &len);
break;
@@
-456,7
+451,6
@@
S_do_trans_count_utf8(pTHX_ SV * const sv)
STATIC I32
S_do_trans_complex_utf8(pTHX_ SV * const sv)
{
STATIC I32
S_do_trans_complex_utf8(pTHX_ SV * const sv)
{
- dVAR;
U8 *start, *send;
U8 *d;
I32 matches = 0;
U8 *start, *send;
U8 *d;
I32 matches = 0;
@@
-487,7
+481,7
@@
S_do_trans_complex_utf8(pTHX_ SV * const sv)
const U8 * const e = s + len;
while (t < e) {
const U8 ch = *t++;
const U8 * const e = s + len;
while (t < e) {
const U8 ch = *t++;
- hibit = !NATIVE_IS_INVARIANT(ch);
+ hibit = !NATIVE_
BYTE_
IS_INVARIANT(ch);
if (hibit) {
s = bytes_to_utf8(s, &len);
break;
if (hibit) {
s = bytes_to_utf8(s, &len);
break;
@@
-532,7
+526,7
@@
S_do_trans_complex_utf8(pTHX_ SV * const sv)
matches++;
s += UTF8SKIP(s);
if (uv != puv) {
matches++;
s += UTF8SKIP(s);
if (uv != puv) {
- d = uv
uni
_to_utf8(d, uv);
+ d = uv
chr
_to_utf8(d, uv);
puv = uv;
}
continue;
puv = uv;
}
continue;
@@
-550,13
+544,13
@@
S_do_trans_complex_utf8(pTHX_ SV * const sv)
if (havefinal) {
s += UTF8SKIP(s);
if (puv != final) {
if (havefinal) {
s += UTF8SKIP(s);
if (puv != final) {
- d = uv
uni
_to_utf8(d, final);
+ d = uv
chr
_to_utf8(d, final);
puv = final;
}
}
else {
STRLEN len;
puv = final;
}
}
else {
STRLEN len;
- uv = utf8n_to_uv
uni
(s, send - s, &len, UTF8_ALLOW_DEFAULT);
+ uv = utf8n_to_uv
chr
(s, send - s, &len, UTF8_ALLOW_DEFAULT);
if (uv != puv) {
Move(s, d, len, U8);
d += len;
if (uv != puv) {
Move(s, d, len, U8);
d += len;
@@
-585,7
+579,7
@@
S_do_trans_complex_utf8(pTHX_ SV * const sv)
if (uv < none) {
matches++;
s += UTF8SKIP(s);
if (uv < none) {
matches++;
s += UTF8SKIP(s);
- d = uv
uni
_to_utf8(d, uv);
+ d = uv
chr
_to_utf8(d, uv);
continue;
}
else if (uv == none) { /* "none" is unmapped character */
continue;
}
else if (uv == none) { /* "none" is unmapped character */
@@
-598,7
+592,7
@@
S_do_trans_complex_utf8(pTHX_ SV * const sv)
else if (uv == extra && !del) {
matches++;
s += UTF8SKIP(s);
else if (uv == extra && !del) {
matches++;
s += UTF8SKIP(s);
- d = uv
uni
_to_utf8(d, final);
+ d = uv
chr
_to_utf8(d, final);
continue;
}
matches++; /* "none+1" is delete character */
continue;
}
matches++; /* "none+1" is delete character */
@@
-624,7
+618,6
@@
S_do_trans_complex_utf8(pTHX_ SV * const sv)
I32
Perl_do_trans(pTHX_ SV *sv)
{
I32
Perl_do_trans(pTHX_ SV *sv)
{
- dVAR;
STRLEN len;
const I32 hasutf = (PL_op->op_private &
(OPpTRANS_FROM_UTF|OPpTRANS_TO_UTF));
STRLEN len;
const I32 hasutf = (PL_op->op_private &
(OPpTRANS_FROM_UTF|OPpTRANS_TO_UTF));
@@
-632,16
+625,13
@@
Perl_do_trans(pTHX_ SV *sv)
PERL_ARGS_ASSERT_DO_TRANS;
if (SvREADONLY(sv) && !(PL_op->op_private & OPpTRANS_IDENTICAL)) {
PERL_ARGS_ASSERT_DO_TRANS;
if (SvREADONLY(sv) && !(PL_op->op_private & OPpTRANS_IDENTICAL)) {
- if (SvIsCOW(sv))
- sv_force_normal_flags(sv, 0);
- if (SvREADONLY(sv))
- Perl_croak_no_modify(aTHX);
+ Perl_croak_no_modify();
}
(void)SvPV_const(sv, len);
if (!len)
return 0;
if (!(PL_op->op_private & OPpTRANS_IDENTICAL)) {
}
(void)SvPV_const(sv, len);
if (!len)
return 0;
if (!(PL_op->op_private & OPpTRANS_IDENTICAL)) {
- if (!SvPOKp(sv))
+ if (!SvPOKp(sv)
|| SvTHINKFIRST(sv)
)
(void)SvPV_force_nomg(sv, len);
(void)SvPOK_only_UTF8(sv);
}
(void)SvPV_force_nomg(sv, len);
(void)SvPOK_only_UTF8(sv);
}
@@
-673,12
+663,11
@@
Perl_do_trans(pTHX_ SV *sv)
}
void
}
void
-Perl_do_join(pTHX_
register SV *sv, SV *delim, register SV **mark, register
SV **sp)
+Perl_do_join(pTHX_
SV *sv, SV *delim, SV **mark,
SV **sp)
{
{
- dVAR;
SV ** const oldmark = mark;
SV ** const oldmark = mark;
-
register
I32 items = sp - mark;
-
register
STRLEN len;
+ I32 items = sp - mark;
+ STRLEN len;
STRLEN delimlen;
PERL_ARGS_ASSERT_DO_JOIN;
STRLEN delimlen;
PERL_ARGS_ASSERT_DO_JOIN;
@@
-709,7
+698,7
@@
Perl_do_join(pTHX_ register SV *sv, SV *delim, register SV **mark, register SV *
/* sv_setpv retains old UTF8ness [perl #24846] */
SvUTF8_off(sv);
/* sv_setpv retains old UTF8ness [perl #24846] */
SvUTF8_off(sv);
- if (
PL_tainting
&& SvMAGICAL(sv))
+ if (
TAINTING_get
&& SvMAGICAL(sv))
SvTAINTED_off(sv);
if (items-- > 0) {
SvTAINTED_off(sv);
if (items-- > 0) {
@@
-734,7
+723,6
@@
Perl_do_join(pTHX_ register SV *sv, SV *delim, register SV **mark, register SV *
void
Perl_do_sprintf(pTHX_ SV *sv, I32 len, SV **sarg)
{
void
Perl_do_sprintf(pTHX_ SV *sv, I32 len, SV **sarg)
{
- dVAR;
STRLEN patlen;
const char * const pat = SvPV_const(*sarg, patlen);
bool do_taint = FALSE;
STRLEN patlen;
const char * const pat = SvPV_const(*sarg, patlen);
bool do_taint = FALSE;
@@
-762,11
+750,17
@@
Perl_do_sprintf(pTHX_ SV *sv, I32 len, SV **sarg)
UV
Perl_do_vecget(pTHX_ SV *sv, SSize_t offset, int size)
{
UV
Perl_do_vecget(pTHX_ SV *sv, SSize_t offset, int size)
{
- dVAR;
STRLEN srclen, len, uoffset, bitoffs = 0;
STRLEN srclen, len, uoffset, bitoffs = 0;
- const unsigned char *s = (const unsigned char *) SvPV_const(sv, srclen);
+ const I32 svpv_flags = ((PL_op->op_flags & OPf_MOD || LVRET)
+ ? SV_UNDEF_RETURNS_NULL : 0);
+ unsigned char *s = (unsigned char *)
+ SvPV_flags(sv, srclen, (svpv_flags|SV_GMAGIC));
UV retnum = 0;
UV retnum = 0;
+ if (!s) {
+ s = (unsigned char *)"";
+ }
+
PERL_ARGS_ASSERT_DO_VECGET;
if (offset < 0)
PERL_ARGS_ASSERT_DO_VECGET;
if (offset < 0)
@@
-774,8
+768,11
@@
Perl_do_vecget(pTHX_ SV *sv, SSize_t offset, int size)
if (size < 1 || (size & (size-1))) /* size < 1 or not a power of two */
Perl_croak(aTHX_ "Illegal number of bits in vec");
if (size < 1 || (size & (size-1))) /* size < 1 or not a power of two */
Perl_croak(aTHX_ "Illegal number of bits in vec");
- if (SvUTF8(sv))
+ if (SvUTF8(sv))
{
(void) Perl_sv_utf8_downgrade(aTHX_ sv, TRUE);
(void) Perl_sv_utf8_downgrade(aTHX_ sv, TRUE);
+ /* PVX may have changed */
+ s = (unsigned char *) SvPV_flags(sv, srclen, svpv_flags);
+ }
if (size < 8) {
bitoffs = ((offset%8)*size)%8;
if (size < 8) {
bitoffs = ((offset%8)*size)%8;
@@
-843,7
+840,7
@@
Perl_do_vecget(pTHX_ SV *sv, SSize_t offset, int size)
((UV) s[uoffset + 1] << 48) +
((UV) s[uoffset + 2] << 40) +
((UV) s[uoffset + 3] << 32) +
((UV) s[uoffset + 1] << 48) +
((UV) s[uoffset + 2] << 40) +
((UV) s[uoffset + 3] << 32) +
- (
s[uoffset + 4] << 24);
+ (
(UV)
s[uoffset + 4] << 24);
else if (uoffset + 6 >= srclen)
retnum =
((UV) s[uoffset ] << 56) +
else if (uoffset + 6 >= srclen)
retnum =
((UV) s[uoffset ] << 56) +
@@
-860,7
+857,7
@@
Perl_do_vecget(pTHX_ SV *sv, SSize_t offset, int size)
((UV) s[uoffset + 3] << 32) +
((UV) s[uoffset + 4] << 24) +
((UV) s[uoffset + 5] << 16) +
((UV) s[uoffset + 3] << 32) +
((UV) s[uoffset + 4] << 24) +
((UV) s[uoffset + 5] << 16) +
- (
s[uoffset + 6] << 8);
+ (
(UV)
s[uoffset + 6] << 8);
}
#endif
}
}
#endif
}
@@
-907,11
+904,10
@@
Perl_do_vecget(pTHX_ SV *sv, SSize_t offset, int size)
void
Perl_do_vecset(pTHX_ SV *sv)
{
void
Perl_do_vecset(pTHX_ SV *sv)
{
- dVAR;
- register SSize_t offset, bitoffs = 0;
- register int size;
- register unsigned char *s;
- register UV lval;
+ SSize_t offset, bitoffs = 0;
+ int size;
+ unsigned char *s;
+ UV lval;
I32 mask;
STRLEN targlen;
STRLEN len;
I32 mask;
STRLEN targlen;
STRLEN len;
@@
-921,7
+917,8
@@
Perl_do_vecset(pTHX_ SV *sv)
if (!targ)
return;
if (!targ)
return;
- s = (unsigned char*)SvPV_force(targ, targlen);
+ s = (unsigned char*)SvPV_force_flags(targ, targlen,
+ SV_GMAGIC | SV_UNDEF_RETURNS_NULL);
if (SvUTF8(targ)) {
/* This is handled by the SvPOK_only below...
if (!Perl_sv_utf8_downgrade(aTHX_ targ, TRUE))
if (SvUTF8(targ)) {
/* This is handled by the SvPOK_only below...
if (!Perl_sv_utf8_downgrade(aTHX_ targ, TRUE))
@@
-993,18
+990,17
@@
Perl_do_vecset(pTHX_ SV *sv)
void
Perl_do_vop(pTHX_ I32 optype, SV *sv, SV *left, SV *right)
{
void
Perl_do_vop(pTHX_ I32 optype, SV *sv, SV *left, SV *right)
{
- dVAR;
#ifdef LIBERAL
#ifdef LIBERAL
-
register
long *dl;
-
register
long *ll;
-
register
long *rl;
+ long *dl;
+ long *ll;
+ long *rl;
#endif
#endif
-
register
char *dc;
+ char *dc;
STRLEN leftlen;
STRLEN rightlen;
STRLEN leftlen;
STRLEN rightlen;
-
register
const char *lc;
-
register
const char *rc;
-
register
STRLEN len;
+ const char *lc;
+ const char *rc;
+ STRLEN len;
STRLEN lensave;
const char *lsave;
const char *rsave;
STRLEN lensave;
const char *lsave;
const char *rsave;
@@
-1124,12
+1120,12
@@
Perl_do_vop(pTHX_ I32 optype, SV *sv, SV *left, SV *right)
else if (lulen)
dcsave = savepvn(lc, lulen);
if (sv == left || sv == right)
else if (lulen)
dcsave = savepvn(lc, lulen);
if (sv == left || sv == right)
- (void)sv_usepvn(sv, dcorig, needlen); /*
Uses Renew().
*/
+ (void)sv_usepvn(sv, dcorig, needlen); /*
uses Renew(); defaults to nomg
*/
SvCUR_set(sv, dc - dcorig);
if (rulen)
SvCUR_set(sv, dc - dcorig);
if (rulen)
- sv_catpvn(sv, dcsave, rulen);
+ sv_catpvn
_nomg
(sv, dcsave, rulen);
else if (lulen)
else if (lulen)
- sv_catpvn(sv, dcsave, lulen);
+ sv_catpvn
_nomg
(sv, dcsave, lulen);
else
*SvEND(sv) = '\0';
Safefree(dcsave);
else
*SvEND(sv) = '\0';
Safefree(dcsave);
@@
-1207,9
+1203,9
@@
Perl_do_vop(pTHX_ I32 optype, SV *sv, SV *left, SV *right)
mop_up:
len = lensave;
if (rightlen > len)
mop_up:
len = lensave;
if (rightlen > len)
- sv_catpvn(sv, rsave + len, rightlen - len);
+ sv_catpvn
_nomg
(sv, rsave + len, rightlen - len);
else if (leftlen > (STRLEN)len)
else if (leftlen > (STRLEN)len)
- sv_catpvn(sv, lsave + len, leftlen - len);
+ sv_catpvn
_nomg
(sv, lsave + len, leftlen - len);
else
*SvEND(sv) = '\0';
break;
else
*SvEND(sv) = '\0';
break;
@@
-1222,10
+1218,9
@@
finish:
OP *
Perl_do_kv(pTHX)
{
OP *
Perl_do_kv(pTHX)
{
- dVAR;
dSP;
HV * const keys = MUTABLE_HV(POPs);
dSP;
HV * const keys = MUTABLE_HV(POPs);
-
register
HE *entry;
+ HE *entry;
const I32 gimme = GIMME_V;
const I32 dokv = (PL_op->op_type == OP_RV2HV || PL_op->op_type == OP_PADHV);
/* op_type is OP_RKEYS/OP_RVALUES if pp_rkeys delegated to here */
const I32 gimme = GIMME_V;
const I32 dokv = (PL_op->op_type == OP_RV2HV || PL_op->op_type == OP_PADHV);
/* op_type is OP_RKEYS/OP_RVALUES if pp_rkeys delegated to here */
@@
-1290,8
+1285,8
@@
Perl_do_kv(pTHX)
* 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:
*/
*/