Newx(ary,size,SV*);
AvALLOC(av) = ary;
SvPV_set(av, (char*)ary);
- AvFILLp(av) = size - 1;
- AvMAX(av) = size - 1;
+ AvFILLp(av) = AvMAX(av) = size - 1;
for (i = 0; i < size; i++) {
assert (*strp);
ary[i] = newSV(0);
SvREFCNT_dec(AvARRAY(av)[--key]);
}
Safefree(AvALLOC(av));
- AvALLOC(av) = 0;
+ AvALLOC(av) = NULL;
SvPV_set(av, NULL);
AvMAX(av) = AvFILLp(av) = -1;
}
STRLEN olen = len;
char *tend;
int dodup = 0;
- PerlIO *that_fp = NULL;
type = savepvn(oname, len);
tend = type+len;
fp = supplied_fp;
}
else {
+ PerlIO *that_fp = NULL;
if (num_svs > 1) {
Perl_croak(aTHX_ "More than one argument to '%c&' open",IoTYPE(io));
}
thatio = sv_2io(*svp);
}
else {
- GV *thatgv;
- thatgv = gv_fetchpvn_flags(type, tend - type,
+ GV * const thatgv = gv_fetchpvn_flags(type, tend - type,
0, SVt_PVIO);
thatio = GvIO(thatgv);
}
if (io && (IoFLAGS(io) & IOf_ARGV)
&& PL_argvout_stack && AvFILLp(PL_argvout_stack) >= 0)
{
- GV *oldout = (GV*)av_pop(PL_argvout_stack);
+ GV * const oldout = (GV*)av_pop(PL_argvout_stack);
setdefout(oldout);
SvREFCNT_dec(oldout);
return NULL;
/* code courtesy of William Kucharski */
#define HAS_CHSIZE
- struct flock fl;
Stat_t filebuf;
if (PerlLIO_fstat(fd, &filebuf) < 0)
}
else {
/* truncate length */
-
+ struct flock fl;
fl.l_whence = 0;
fl.l_len = 0;
fl.l_start = length;
else if (DO_UTF8(sv)) {
STRLEN tmplen = len;
bool utf8 = TRUE;
- U8 *result = bytes_from_utf8((const U8*) tmps, &tmplen, &utf8);
+ U8 * const result = bytes_from_utf8((const U8*) tmps, &tmplen, &utf8);
if (!utf8) {
tmpbuf = result;
tmps = (char *) tmpbuf;
* io the write failure can be delayed until the flush/close. --jhi */
if (len && (PerlIO_write(fp,tmps,len) == 0))
happy = FALSE;
- if (tmpbuf)
- Safefree(tmpbuf);
+ Safefree(tmpbuf);
return happy ? !PerlIO_error(fp) : FALSE;
}
if (s[-1] == '\'') {
*--s = '\0';
PERL_FPU_PRE_EXEC
- PerlProc_execl(PL_cshname,"csh", flags, ncmd, (char*)0);
+ PerlProc_execl(PL_cshname, "csh", flags, ncmd, NULL);
PERL_FPU_POST_EXEC
*s = '\'';
Safefree(cmd);
}
doshell:
PERL_FPU_PRE_EXEC
- PerlProc_execl(PL_sh_path, "sh", "-c", cmd, (char*)0);
+ PerlProc_execl(PL_sh_path, "sh", "-c", cmd, NULL);
PERL_FPU_POST_EXEC
Safefree(cmd);
return FALSE;
#endif
}
else {
- I32 n;
STRLEN len;
const char *mbuf = SvPV_const(mstr, len);
- if ((n = len) > msize)
- n = msize;
+ const I32 n = (len > msize) ? msize : len;
Copy(mbuf, shm + mpos, n, char);
if (n < msize)
memzero(shm + mpos + n, msize - n);
bool
Perl_is_utf8_string(pTHX_ const U8 *s, STRLEN len)
{
+ const U8* const send = s + (len ? len : strlen((const char *)s));
const U8* x = s;
- const U8* send;
PERL_UNUSED_CONTEXT;
- if (!len)
- len = strlen((const char *)s);
- send = s + len;
while (x < send) {
STRLEN c;
bool
Perl_is_utf8_string_loclen(pTHX_ const U8 *s, STRLEN len, const U8 **ep, STRLEN *el)
{
+ const U8* const send = s + (len ? len : strlen((const char *)s));
const U8* x = s;
- const U8* send;
STRLEN c;
STRLEN outlen = 0;
PERL_UNUSED_CONTEXT;
- if (!len)
- len = strlen((const char *)s);
- send = s + len;
-
while (x < send) {
/* Inline the easy bits of is_utf8_char() here for speed... */
if (UTF8_IS_INVARIANT(*x))
}
}
- *is_utf8 = 0;
+ *is_utf8 = FALSE;
Newx(d, (*len) - count + 1, U8);
s = start; start = d;
if (special && (uv1 == 0xDF || uv1 > 0xFF)) {
/* It might be "special" (sometimes, but not always,
* a multicharacter mapping) */
- HV *hv;
+ HV * const hv = get_hv(special, FALSE);
SV **svp;
- if ((hv = get_hv(special, FALSE)) &&
+ if (hv &&
(svp = hv_fetch(hv, (const char*)tmpbuf, UNISKIP(uv1), FALSE)) &&
(*svp)) {
const char *s;
U32 bit;
SV *swatch;
U8 tmputf8[2];
- UV c = NATIVE_TO_ASCII(*ptr);
+ const UV c = NATIVE_TO_ASCII(*ptr);
if (!do_utf8 && !UNI_IS_INVARIANT(c)) {
tmputf8[0] = (U8)UTF8_EIGHT_BIT_HI(c);
l = (U8*)SvPV(*listsvp, lcur);
lend = l + lcur;
while (l < lend) {
- UV min, max, val, key;
+ UV min, max, val;
STRLEN numlen;
I32 flags = PERL_SCAN_SILENT_ILLDIGIT | PERL_SCAN_DISALLOW_PREFIX;
continue;
if (octets) {
+ UV key;
if (min < start) {
if (!none || val < none) {
val += start - min;
}
}
else { /* bits == 1, then val should be ignored */
+ UV key;
if (min < start)
min = start;
for (key = min; key <= max; key++) {
U8 *s, *o, *nl;
STRLEN slen, olen;
- U8 opc = *x++;
+ const U8 opc = *x++;
if (opc == '\n')
continue;
else {
STRLEN otheroctets = otherbits >> 3;
STRLEN offset = 0;
- U8* send = s + slen;
+ U8* const send = s + slen;
while (s < send) {
UV otherval = 0;
{
register I32 tolen;
PERL_UNUSED_CONTEXT;
+
for (tolen = 0; from < fromend; from++, tolen++) {
if (*from == '\\') {
- if (from[1] == delim)
- from++;
- else {
+ if (from[1] != delim) {
if (to < toend)
*to++ = *from;
tolen++;
- from++;
}
+ from++;
}
else if (*from == delim)
break;
Perl_new_warnings_bitfield(pTHX_ STRLEN *buffer, const char *const bits,
STRLEN size) {
const MEM_SIZE len_wanted = sizeof(STRLEN) + size;
+ PERL_UNUSED_CONTEXT;
buffer = specialWARN(buffer) ? PerlMemShared_malloc(len_wanted)
: PerlMemShared_realloc(buffer, len_wanted);
I32 max;
char **tmpenv;
- for (max = i; environ[max]; max++) ;
+ max = i;
+ while (environ[max])
+ max++;
tmpenv = (char**)safesysmalloc((max+2) * sizeof(char*));
for (j=0; j<max; j++) { /* copy environment */
const int len = strlen(environ[j]);
I32
Perl_unlnk(pTHX_ const char *f) /* unlink all versions of a file */
{
- I32 i;
+ I32 retries = 0;
- for (i = 0; PerlLIO_unlink(f) >= 0; i++) ;
- return i ? 0 : -1;
+ while (PerlLIO_unlink(f) >= 0)
+ retries++;
+ return retries ? 0 : -1;
}
#endif
if (*p) {
if (isDIGIT(*p)) {
opt = (U32) atoi(p);
- while (isDIGIT(*p)) p++;
+ while (isDIGIT(*p))
+ p++;
if (*p && *p != '\n' && *p != '\r')
Perl_croak(aTHX_ "Unknown Unicode option letter '%c'", *p);
}
UV myseed = 0;
if (s)
- while (isSPACE(*s)) s++;
+ while (isSPACE(*s))
+ s++;
if (s && isDIGIT(*s))
myseed = (UV)Atoul(s);
else