char *t;
if (!strnEQ(s, "0000", 4)) { /* need to grow sv */
- SV *tmpNew = newSVpvn("0000000000", 10);
+ SV * const tmpNew = newSVpvn("0000000000", 10);
sv_catsv(tmpNew, sv);
SvREFCNT_dec(sv); /* free old sv */
# define DO_BO_PACK_N(var, type)
# define DO_BO_UNPACK_P(var)
# define DO_BO_PACK_P(var)
+# define DO_BO_UNPACK_PC(var)
+# define DO_BO_PACK_PC(var)
#else /* PERL_PACK_CAN_BYTEORDER */
# else
# define DO_BO_UNPACK_P(var) BO_CANT_DOIT(unpack, pointer)
# define DO_BO_PACK_P(var) BO_CANT_DOIT(pack, pointer)
+# define DO_BO_UNPACK_PC(var) BO_CANT_DOIT(unpack, pointer)
+# define DO_BO_PACK_PC(var) BO_CANT_DOIT(pack, pointer)
# endif
# if defined(my_htolen) && defined(my_letohn) && \
typedef U8 packprops_t;
#if 'J'-'I' == 1
/* ASCII */
-const packprops_t packprops[512] = {
+STATIC const packprops_t packprops[512] = {
/* normal */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
#else
/* EBCDIC (or bust) */
-const packprops_t packprops[512] = {
+STATIC const packprops_t packprops[512] = {
/* normal */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
STATIC U8
uni_to_byte(pTHX_ const char **s, const char *end, I32 datumtype)
{
- UV val;
STRLEN retlen;
- val = utf8n_to_uvchr((U8 *) *s, end-*s, &retlen,
+ UV val = utf8n_to_uvchr((U8 *) *s, end-*s, &retlen,
ckWARN(WARN_UTF8) ? 0 : UTF8_ALLOW_ANY);
/* We try to process malformed UTF-8 as much as possible (preferrably with
warnings), but these two mean we make no progress in the string and
STATIC bool
next_uni_uu(pTHX_ const char **s, const char *end, I32 *out)
{
- UV val;
STRLEN retlen;
- val = utf8n_to_uvchr((U8 *) *s, end-*s, &retlen, UTF8_CHECK_ONLY);
+ const UV val = utf8n_to_uvchr((U8 *) *s, end-*s, &retlen, UTF8_CHECK_ONLY);
if (val >= 0x100 || !ISUUCHAR(val) ||
retlen == (STRLEN) -1 || retlen == 0) {
*out = 0;
STATIC void
bytes_to_uni(pTHX_ const U8 *start, STRLEN len, char **dest) {
U8 buffer[UTF8_MAXLEN];
- const U8 *end = start + len;
+ const U8 * const end = start + len;
char *d = *dest;
while (start < end) {
const int length =
S_next_symbol(pTHX_ tempsym_t* symptr )
{
const char* patptr = symptr->patptr;
- const char* patend = symptr->patend;
+ const char* const patend = symptr->patend;
symptr->flags &= ~FLAG_SLASH;
version of the string. Users are advised to upgrade their pack string
themselves if they need to do a lot of unpacks like this on it
*/
-/* XXX These can be const */
STATIC bool
need_utf8(const char *pat, const char *patend)
{
if (symptr->howlen == e_star)
Perl_croak(aTHX_ "'P' must have an explicit size in unpack");
EXTEND(SP, 1);
- if (sizeof(char*) <= strend - s) {
+ if (s + sizeof(char*) <= strend) {
char *aptr;
SHIFT_VAR(utf8, s, strend, aptr, datumtype);
DO_BO_UNPACK_PC(aptr);
* (and just as fast as doing character arithmetic)
*/
if (PL_uudmap['M'] == 0) {
- int i;
+ size_t i;
- for (i = 0; i < sizeof(PL_uuemap); i += 1)
+ for (i = 0; i < sizeof(PL_uuemap); ++i)
PL_uudmap[(U8)PL_uuemap[i]] = i;
/*
* Because ' ' and '`' map to the same value,
The engine implementing pack() Perl function. Note: parameters next_in_list and
flags are not used. This call should not be used; use packlist instead.
-=cut */
-
+=cut
+*/
void
Perl_pack_cat(pTHX_ SV *cat, const char *pat, const char *patend, register SV **beglist, SV **endlist, SV ***next_in_list, U32 flags)
The engine implementing pack() Perl function.
-=cut */
-
+=cut
+*/
void
Perl_packlist(pTHX_ SV *cat, const char *pat, const char *patend, register SV **beglist, SV **endlist )
/* We're going to do changes through SvPVX(cat). Make sure it's valid.
Also make sure any UTF8 flag is loaded */
SvPV_force(cat, no_len);
- if (DO_UTF8(cat)) sym.flags |= FLAG_PARSE_UTF8 | FLAG_DO_UTF8;
+ if (DO_UTF8(cat))
+ sym.flags |= FLAG_PARSE_UTF8 | FLAG_DO_UTF8;
(void)pack_rec( cat, &sym, beglist, endlist );
}
ckWARN(WARN_PACK))
Perl_warner(aTHX_ packWARN(WARN_PACK),
"Character in 'c' format wrapped in pack");
- PUSH_BYTE(utf8, cur, aiv & 0xff);
+ PUSH_BYTE(utf8, cur, (U8)(aiv & 0xff));
}
break;
case 'C':
ckWARN(WARN_PACK))
Perl_warner(aTHX_ packWARN(WARN_PACK),
"Character in 'C' format wrapped in pack");
- *cur++ = aiv & 0xff;
+ *cur++ = (char)(aiv & 0xff);
}
break;
case 'W': {
SvGETMAGIC(fromstr);
if (!SvOK(fromstr)) aptr = NULL;
else {
- STRLEN n_a;
/* XXX better yet, could spirit away the string to
* a safe spot and hang on to it until the result
* of pack() (and all copies of the result) are
"Attempt to pack pointer to temporary value");
}
if (SvPOK(fromstr) || SvNIOK(fromstr))
- aptr = SvPV_nomg_const(fromstr, n_a);
+ aptr = SvPV_nomg_const_nolen(fromstr);
else
- aptr = SvPV_force_flags(fromstr, n_a, 0);
+ aptr = SvPV_force_flags_nolen(fromstr, 0);
}
DO_BO_PACK_PC(aptr);
PUSH_VAR(utf8, cur, aptr);
if (len <= 2) len = 45;
else len = len / 3 * 3;
if (len >= 64) {
- Perl_warner(aTHX_ packWARN(WARN_PACK),
+ if (ckWARN(WARN_PACK))
+ Perl_warner(aTHX_ packWARN(WARN_PACK),
"Field too wide in 'u' format in pack");
len = 63;
}