{
dSP; dTARGET;
PerlIO *fp;
- STRLEN n_a;
- char *tmps = POPpx;
+ const char *tmps = POPpconstx;
const I32 gimme = GIMME_V;
const char *mode = "r";
mode = "rb";
else if (PL_op->op_private & OPpOPEN_IN_CRLF)
mode = "rt";
- fp = PerlProc_popen(tmps, (char *)mode);
+ fp = PerlProc_popen((char*)tmps, (char *)mode);
if (fp) {
const char *type = NULL;
if (PL_curcop->cop_io) {
- type = SvPV_nolen(PL_curcop->cop_io);
+ type = SvPV_nolen_const(PL_curcop->cop_io);
}
if (type && *type)
PerlIO_apply_layers(aTHX_ fp,mode,type);
else {
tmpsv = TOPs;
}
- tmps = SvPV(tmpsv, len);
+ tmps = SvPV_const(tmpsv, len);
if ((!tmps || !len) && PL_errgv) {
SV *error = ERRSV;
- (void)SvUPGRADE(error, SVt_PV);
+ SvUPGRADE(error, SVt_PV);
if (SvPOK(error) && SvCUR(error))
sv_catpv(error, "\t...caught");
tmpsv = error;
- tmps = SvPV(tmpsv, len);
+ tmps = SvPV_const(tmpsv, len);
}
if (!tmps || !len)
tmpsv = sv_2mortal(newSVpvn("Warning: something's wrong", 26));
dTARGET;
do_join(TARG, &PL_sv_no, MARK, SP);
tmpsv = TARG;
- tmps = SvPV(tmpsv, len);
+ tmps = SvPV_const(tmpsv, len);
multiarg = 1;
SP = MARK + 1;
}
else {
tmpsv = TOPs;
- tmps = SvROK(tmpsv) ? Nullch : SvPV(tmpsv, len);
+ tmps = SvROK(tmpsv) ? Nullch : SvPV_const(tmpsv, len);
}
if (!tmps || !len) {
SV *error = ERRSV;
- (void)SvUPGRADE(error, SVt_PV);
+ SvUPGRADE(error, SVt_PV);
if (multiarg ? SvROK(error) : SvROK(tmpsv)) {
if (!multiarg)
SvSetSV(error,tmpsv);
if (SvPOK(error) && SvCUR(error))
sv_catpv(error, "\t...propagated");
tmpsv = error;
- tmps = SvPV(tmpsv, len);
+ tmps = SvPV_const(tmpsv, len);
}
}
if (!tmps || !len)
GV *gv;
SV *sv;
IO *io;
- char *tmps;
+ const char *tmps;
STRLEN len;
MAGIC *mg;
bool ok;
sv = GvSV(gv);
}
- tmps = SvPV(sv, len);
- ok = do_openn(gv, tmps, len, FALSE, O_RDONLY, 0, Nullfp, MARK+1, (SP-MARK));
+ tmps = SvPV_const(sv, len);
+ ok = do_openn(gv, (char *)tmps, len, FALSE, O_RDONLY, 0, Nullfp, MARK+1, (SP-MARK));
SP = ORIGMARK;
if (ok)
PUSHi( (I32)PL_forkprocess );
PUTBACK;
if (PerlIO_binmode(aTHX_ fp,IoTYPE(io),mode_from_discipline(discp),
- (discp) ? SvPV_nolen(discp) : Nullch)) {
+ (discp) ? SvPV_nolen_const(discp) : Nullch)) {
if (IoOFP(io) && IoOFP(io) != IoIFP(io)) {
if (!PerlIO_binmode(aTHX_ IoOFP(io),IoTYPE(io),
mode_from_discipline(discp),
- (discp) ? SvPV_nolen(discp) : Nullch)) {
+ (discp) ? SvPV_nolen_const(discp) : Nullch)) {
SPAGAIN;
RETPUSHUNDEF;
}
struct timeval *tbuf = &timebuf;
I32 growsize;
char *fd_sets[4];
- STRLEN n_a;
#if BYTEORDER != 0x1234 && BYTEORDER != 0x12345678
I32 masksize;
I32 offset;
SP -= 4;
for (i = 1; i <= 3; i++) {
- if (!SvPOK(SP[i]))
+ SV *sv = SP[i];
+ if (SvOK(sv) && SvREADONLY(sv)) {
+ if (SvIsCOW(sv))
+ sv_force_normal_flags(sv, 0);
+ if (SvREADONLY(sv))
+ DIE(aTHX_ PL_no_modify);
+ }
+ if (!SvPOK(sv))
continue;
- j = SvCUR(SP[i]);
+ j = SvCUR(sv);
if (maxlen < j)
maxlen = j;
}
continue;
}
else if (!SvPOK(sv))
- SvPV_force(sv,n_a); /* force string conversion */
+ SvPV_force_nolen(sv); /* force string conversion */
j = SvLEN(sv);
if (j < growsize) {
Sv_Grow(sv, growsize);
if (!cv) {
if (fgv) {
SV * const tmpsv = sv_newmortal();
- char *name;
+ const char *name;
gv_efullname4(tmpsv, fgv, Nullch, FALSE);
- name = SvPV_nolen(tmpsv);
+ name = SvPV_nolen_const(tmpsv);
if (name && *name)
DIE(aTHX_ "Undefined format \"%s\" called", name);
}
SV * const sv = sv_newmortal();
const char *name;
gv_efullname4(sv, fgv, Nullch, FALSE);
- name = SvPV_nolen(sv);
+ name = SvPV_nolen_const(sv);
if (name && *name)
DIE(aTHX_ "Undefined top format \"%s\" called",name);
}
dSP;
GV *gv;
SV *sv;
- char *tmps;
+ const char *tmps;
STRLEN len;
const int perm = (MAXARG > 3) ? POPi : 0666;
const int mode = POPi;
/* Need TIEHANDLE method ? */
- tmps = SvPV(sv, len);
- if (do_open(gv, tmps, len, TRUE, mode, perm, Nullfp)) {
+ tmps = SvPV_const(sv, len);
+ /* FIXME? do_open should do const */
+ if (do_open(gv, (char*)tmps, len, TRUE, mode, perm, Nullfp)) {
IoLINES(GvIOp(gv)) = 0;
PUSHs(&PL_sv_yes);
}
SvCUR_set(bufsv, offset);
read_target = sv_newmortal();
- (void)SvUPGRADE(read_target, SVt_PV);
+ SvUPGRADE(read_target, SVt_PV);
buffer = SvGROW(read_target, (STRLEN)(length + 1));
}
GV *gv;
IO *io;
SV *bufsv;
- char *buffer;
+ const char *buffer;
Size_t length;
SSize_t retval;
STRLEN blen;
bufsv = sv_2mortal(newSVsv(bufsv));
buffer = sv_2pvutf8(bufsv, &blen);
} else
- buffer = SvPV(bufsv, blen);
+ buffer = SvPV_const(bufsv, blen);
}
else {
if (DO_UTF8(bufsv)) {
bufsv = sv_2mortal(newSVsv(bufsv));
sv_utf8_downgrade(bufsv, FALSE);
}
- buffer = SvPV(bufsv, blen);
+ buffer = SvPV_const(bufsv, blen);
}
if (PL_op->op_type == OP_SYSWRITE) {
if (length > blen - offset)
length = blen - offset;
if (DO_UTF8(bufsv)) {
- buffer = (char*)utf8_hop((U8 *)buffer, offset);
+ buffer = (const char*)utf8_hop((const U8 *)buffer, offset);
length = utf8_hop((U8 *)buffer, length) - (U8 *)buffer;
}
else {
}
else {
SV *sv = POPs;
- char *name;
- STRLEN n_a;
+ const char *name;
if (SvTYPE(sv) == SVt_PVGV) {
tmpgv = (GV*)sv; /* *main::FRED for example */
goto do_ftruncate_io;
}
- name = SvPV(sv, n_a);
+ name = SvPV_nolen_const(sv);
TAINT_PROPER("truncate");
#ifdef HAS_TRUNCATE
if (truncate(name, len) < 0)
extern void GETUSERMODE();
#endif
SV *addrsv = POPs;
- char *addr;
+ /* OK, so on what platform does bind modify addr? */
+ const char *addr;
GV *gv = (GV*)POPs;
register IO *io = GvIOn(gv);
STRLEN len;
if (!io || !IoIFP(io))
goto nuts;
- addr = SvPV(addrsv, len);
+ addr = SvPV_const(addrsv, len);
TAINT_PROPER("bind");
#ifdef MPE /* Deal with MPE bind() peculiarities */
if (((struct sockaddr *)addr)->sa_family == AF_INET) {
#ifdef HAS_SOCKET
dSP;
SV *addrsv = POPs;
- char *addr;
+ const char *addr;
GV *gv = (GV*)POPs;
register IO *io = GvIOn(gv);
STRLEN len;
if (!io || !IoIFP(io))
goto nuts;
- addr = SvPV(addrsv, len);
+ addr = SvPV_const(addrsv, len);
TAINT_PROPER("connect");
if (PerlSock_connect(PerlIO_fileno(IoIFP(io)), (struct sockaddr *)addr, len) >= 0)
RETPUSHYES;
PUSHs(sv);
break;
case OP_SSOCKOPT: {
- char *buf;
+ const char *buf;
int aint;
if (SvPOKp(sv)) {
STRLEN l;
- buf = SvPV(sv, l);
+ buf = SvPV_const(sv, l);
len = l;
}
else {
aint = (int)SvIV(sv);
- buf = (char*)&aint;
+ buf = (const char*)&aint;
len = sizeof(int);
}
if (PerlSock_setsockopt(fd, lvl, optname, buf, len) < 0)
{
static const char nowhere[] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
/* If the call succeeded, make sure we don't have a zeroed port/addr */
- if (((struct sockaddr *)SvPVX(sv))->sa_family == AF_INET &&
- !memcmp((char *)SvPVX(sv) + sizeof(u_short), nowhere,
+ if (((struct sockaddr *)SvPVX_const(sv))->sa_family == AF_INET &&
+ !memcmp((char *)SvPVX_const(sv) + sizeof(u_short), nowhere,
sizeof(u_short) + sizeof(struct in_addr))) {
goto nuts2;
}
GV *gv;
I32 gimme;
I32 max = 13;
- STRLEN n_a;
if (PL_op->op_flags & OPf_REF) {
gv = cGVOP_gv;
"lstat() on filehandle %s", GvENAME(gv));
goto do_fstat;
}
- sv_setpv(PL_statname, SvPV(sv,n_a));
+ sv_setpv(PL_statname, SvPV_nolen_const(sv));
PL_statgv = Nullgv;
PL_laststype = PL_op->op_type;
if (PL_op->op_type == OP_LSTAT)
- PL_laststatval = PerlLIO_lstat(SvPV(PL_statname, n_a), &PL_statcache);
+ PL_laststatval = PerlLIO_lstat(SvPV_nolen_const(PL_statname), &PL_statcache);
else
- PL_laststatval = PerlLIO_stat(SvPV(PL_statname, n_a), &PL_statcache);
+ PL_laststatval = PerlLIO_stat(SvPV_nolen_const(PL_statname), &PL_statcache);
if (PL_laststatval < 0) {
- if (ckWARN(WARN_NEWLINE) && strchr(SvPV(PL_statname, n_a), '\n'))
+ if (ckWARN(WARN_NEWLINE) && strchr(SvPV_nolen_const(PL_statname), '\n'))
Perl_warner(aTHX_ packWARN(WARN_NEWLINE), PL_warn_nl, "stat");
max = 0;
}
STACKED_FTEST_CHECK;
#if defined(HAS_ACCESS) && defined(R_OK)
if ((PL_op->op_private & OPpFT_ACCESS) && SvPOK(TOPs)) {
- STRLEN n_a;
result = access(POPpx, R_OK);
if (result == 0)
RETPUSHYES;
STACKED_FTEST_CHECK;
#if defined(HAS_ACCESS) && defined(W_OK)
if ((PL_op->op_private & OPpFT_ACCESS) && SvPOK(TOPs)) {
- STRLEN n_a;
result = access(POPpx, W_OK);
if (result == 0)
RETPUSHYES;
STACKED_FTEST_CHECK;
#if defined(HAS_ACCESS) && defined(X_OK)
if ((PL_op->op_private & OPpFT_ACCESS) && SvPOK(TOPs)) {
- STRLEN n_a;
result = access(POPpx, X_OK);
if (result == 0)
RETPUSHYES;
STACKED_FTEST_CHECK;
#ifdef PERL_EFF_ACCESS_R_OK
if ((PL_op->op_private & OPpFT_ACCESS) && SvPOK(TOPs)) {
- STRLEN n_a;
result = PERL_EFF_ACCESS_R_OK(POPpx);
if (result == 0)
RETPUSHYES;
STACKED_FTEST_CHECK;
#ifdef PERL_EFF_ACCESS_W_OK
if ((PL_op->op_private & OPpFT_ACCESS) && SvPOK(TOPs)) {
- STRLEN n_a;
result = PERL_EFF_ACCESS_W_OK(POPpx);
if (result == 0)
RETPUSHYES;
STACKED_FTEST_CHECK;
#ifdef PERL_EFF_ACCESS_X_OK
if ((PL_op->op_private & OPpFT_ACCESS) && SvPOK(TOPs)) {
- STRLEN n_a;
result = PERL_EFF_ACCESS_X_OK(POPpx);
if (result == 0)
RETPUSHYES;
if (GvIO(gv) && IoIFP(GvIOp(gv)))
fd = PerlIO_fileno(IoIFP(GvIOp(gv)));
else if (tmpsv && SvOK(tmpsv)) {
- STRLEN n_a;
- char *tmps = SvPV(tmpsv, n_a);
+ const char *tmps = SvPV_nolen_const(tmpsv);
if (isDIGIT(*tmps))
fd = atoi(tmps);
else
register IO *io;
register SV *sv;
GV *gv;
- STRLEN n_a;
PerlIO *fp;
STACKED_FTEST_CHECK;
really_filename:
PL_statgv = Nullgv;
PL_laststype = OP_STAT;
- sv_setpv(PL_statname, SvPV(sv, n_a));
+ sv_setpv(PL_statname, SvPV_nolen_const(sv));
if (!(fp = PerlIO_open(SvPVX_const(PL_statname), "r"))) {
- if (ckWARN(WARN_NEWLINE) && strchr(SvPV(PL_statname, n_a), '\n'))
+ if (ckWARN(WARN_NEWLINE) && strchr(SvPV_nolen_const(PL_statname),
+ '\n'))
Perl_warner(aTHX_ packWARN(WARN_NEWLINE), PL_warn_nl, "open");
RETPUSHUNDEF;
}
PP(pp_chdir)
{
dSP; dTARGET;
- char *tmps;
+ const char *tmps;
SV **svp;
- STRLEN n_a;
if( MAXARG == 1 )
- tmps = POPpx;
+ tmps = POPpconstx;
else
tmps = 0;
{
if( MAXARG == 1 )
deprecate("chdir('') or chdir(undef) as chdir()");
- tmps = SvPV(*svp, n_a);
+ tmps = SvPV_nolen_const(*svp);
}
else {
PUSHi(0);
{
#ifdef HAS_CHROOT
dSP; dTARGET;
- STRLEN n_a;
char *tmps = POPpx;
TAINT_PROPER("chroot");
PUSHi( chroot(tmps) >= 0 );
{
dSP; dTARGET;
int anum;
- STRLEN n_a;
-
- char *tmps2 = POPpx;
- char *tmps = SvPV(TOPs, n_a);
+ const char *tmps2 = POPpconstx;
+ const char *tmps = SvPV_nolen_const(TOPs);
TAINT_PROPER("rename");
#ifdef HAS_RENAME
anum = PerlLIO_rename(tmps, tmps2);
{
#ifdef HAS_LINK
dSP; dTARGET;
- STRLEN n_a;
- char *tmps2 = POPpx;
- char *tmps = SvPV(TOPs, n_a);
+ const char *tmps2 = POPpconstx;
+ const char *tmps = SvPV_nolen_const(TOPs);
TAINT_PROPER("link");
SETi( PerlLIO_link(tmps, tmps2) >= 0 );
RETURN;
{
#ifdef HAS_SYMLINK
dSP; dTARGET;
- STRLEN n_a;
- char *tmps2 = POPpx;
- char *tmps = SvPV(TOPs, n_a);
+ const char *tmps2 = POPpconstx;
+ const char *tmps = SvPV_nolen_const(TOPs);
TAINT_PROPER("symlink");
SETi( symlink(tmps, tmps2) >= 0 );
RETURN;
dSP;
#ifdef HAS_SYMLINK
dTARGET;
- char *tmps;
+ const char *tmps;
char buf[MAXPATHLEN];
int len;
- STRLEN n_a;
#ifndef INCOMPLETE_TAINTS
TAINT;
#endif
- tmps = POPpx;
+ tmps = POPpconstx;
len = readlink(tmps, buf, sizeof(buf) - 1);
EXTEND(SP, 1);
if (len < 0)
* -d, chdir(), chmod(), chown(), chroot(), fcntl()?,
* (mkdir()), opendir(), rename(), rmdir(), stat(). --jhi */
-#define TRIMSLASHES(tmps,len,copy) (tmps) = SvPV(TOPs, (len)); \
+#define TRIMSLASHES(tmps,len,copy) (tmps) = SvPV_const(TOPs, (len)); \
if ((len) > 1 && (tmps)[(len)-1] == '/') { \
do { \
(len)--; \
int oldumask;
#endif
STRLEN len;
- char *tmps;
+ const char *tmps;
bool copy = FALSE;
if (MAXARG > 1)
{
dSP; dTARGET;
STRLEN len;
- char *tmps;
+ const char *tmps;
bool copy = FALSE;
TRIMSLASHES(tmps,len,copy);
{
#if defined(Direntry_t) && defined(HAS_READDIR)
dSP;
- STRLEN n_a;
- char *dirname = POPpx;
+ const char *dirname = POPpconstx;
GV *gv = (GV*)POPs;
register IO *io = GvIOn(gv);
{
dSP; dMARK; dORIGMARK; dTARGET;
I32 value;
- STRLEN n_a;
int result;
if (PL_tainting) {
TAINT_ENV();
while (++MARK <= SP) {
- (void)SvPV_nolen(*MARK); /* stringify for taint check */
+ (void)SvPV_nolen_const(*MARK); /* stringify for taint check */
if (PL_tainted)
break;
}
else if (SP - MARK != 1)
value = (I32)do_aexec5(Nullsv, MARK, SP, pp[1], did_pipes);
else {
- value = (I32)do_exec3(SvPVx(sv_mortalcopy(*SP), n_a), pp[1], did_pipes);
+ value = (I32)do_exec3(SvPVx_nolen(sv_mortalcopy(*SP)), pp[1], did_pipes);
}
PerlProc__exit(-1);
}
# endif
}
else {
- value = (I32)do_spawn(SvPVx(sv_mortalcopy(*SP), n_a));
+ value = (I32)do_spawn(SvPVx_nolen(sv_mortalcopy(*SP)));
}
if (PL_statusvalue == -1) /* hint that value must be returned as is */
result = 1;
{
dSP; dMARK; dORIGMARK; dTARGET;
I32 value;
- STRLEN n_a;
if (PL_tainting) {
TAINT_ENV();
while (++MARK <= SP) {
- (void)SvPV_nolen(*MARK); /* stringify for taint check */
+ (void)SvPV_nolen_const(*MARK); /* stringify for taint check */
if (PL_tainted)
break;
}
#endif
else {
#ifdef VMS
- value = (I32)vms_do_exec(SvPVx(sv_mortalcopy(*SP), n_a));
+ value = (I32)vms_do_exec(SvPVx_nolen(sv_mortalcopy(*SP)));
#else
# ifdef __OPEN_VM
- (void) do_spawn(SvPVx(sv_mortalcopy(*SP), n_a));
+ (void) do_spawn(SvPVx_nolen(sv_mortalcopy(*SP)));
value = 0;
# else
- value = (I32)do_exec(SvPVx(sv_mortalcopy(*SP), n_a));
+ value = (I32)do_exec(SvPVx_nolen(sv_mortalcopy(*SP)));
# endif
#endif
}
#endif
struct hostent *hent;
unsigned long len;
- STRLEN n_a;
EXTEND(SP, 10);
if (which == OP_GHBYNAME) {
struct netent *getnetent(void);
#endif
struct netent *nent;
- STRLEN n_a;
if (which == OP_GNBYNAME){
#ifdef HAS_GETNETBYNAME
struct protoent *getprotoent(void);
#endif
struct protoent *pent;
- STRLEN n_a;
if (which == OP_GPBYNAME) {
#ifdef HAS_GETPROTOBYNAME
struct servent *getservent(void);
#endif
struct servent *sent;
- STRLEN n_a;
if (which == OP_GSBYNAME) {
#ifdef HAS_GETSERVBYNAME
dSP;
I32 which = PL_op->op_type;
register SV *sv;
- STRLEN n_a;
struct passwd *pwent = NULL;
/*
* We currently support only the SysV getsp* shadow password interface.
register char **elem;
register SV *sv;
struct group *grent;
- STRLEN n_a;
if (which == OP_GGRNAM) {
char* name = POPpbytex;
unsigned long a[20];
register I32 i = 0;
I32 retval = -1;
- STRLEN n_a;
if (PL_tainting) {
while (++MARK <= SP) {
else if (*MARK == &PL_sv_undef)
a[i++] = 0;
else
- a[i++] = (unsigned long)SvPV_force(*MARK, n_a);
+ a[i++] = (unsigned long)SvPV_force_nolen(*MARK);
if (i > 15)
break;
}