/* pp_pack.c
*
- * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
- * 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, by Larry Wall and others
+ * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
+ * 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by Larry Wall and others
*
* You may distribute under the terms of either the GNU General Public
* License or the Artistic License, as specified in the README file.
* wooden spoon, a short two-pronged fork and some skewers were stowed; and
* hidden at the bottom of the pack in a flat wooden box a dwindling treasure,
* some salt.
+ *
+ * [p.653 of _The Lord of the Rings_, IV/iv: "Of Herbs and Stewed Rabbit"]
*/
/* This file contains pp ("push/pop") functions that
char *s = SvPV(sv, len);
char *t;
+ PERL_ARGS_ASSERT_MUL128;
+
if (!strnEQ(s, "0000", 4)) { /* need to grow sv */
SV * const tmpNew = newSVpvs("0000000000");
S_bytes_to_uni(const U8 *start, STRLEN len, char *dest) {
const U8 * const end = start + len;
+ PERL_ARGS_ASSERT_BYTES_TO_UNI;
+
while (start < end) {
const UV uv = NATIVE_TO_ASCII(*start);
if (UNI_IS_INVARIANT(uv))
{
I32 total = 0;
+ PERL_ARGS_ASSERT_MEASURE_STRUCT;
+
while (next_symbol(symptr)) {
I32 len;
int size;
STATIC const char *
S_group_end(pTHX_ register const char *patptr, register const char *patend, char ender)
{
+ PERL_ARGS_ASSERT_GROUP_END;
+
while (patptr < patend) {
const char c = *patptr++;
S_get_num(pTHX_ register const char *patptr, I32 *lenptr )
{
I32 len = *patptr++ - '0';
+
+ PERL_ARGS_ASSERT_GET_NUM;
+
while (isDIGIT(*patptr)) {
if (len >= 0x7FFFFFFF/10)
Perl_croak(aTHX_ "pack/unpack repeat count overflow");
const char* patptr = symptr->patptr;
const char* const patend = symptr->patend;
+ PERL_ARGS_ASSERT_NEXT_SYMBOL;
+
symptr->flags &= ~FLAG_SLASH;
while (patptr < patend) {
need_utf8(const char *pat, const char *patend)
{
bool first = TRUE;
+
+ PERL_ARGS_ASSERT_NEED_UTF8;
+
while (pat < patend) {
if (pat[0] == '#') {
pat++;
STATIC char
first_symbol(const char *pat, const char *patend) {
+ PERL_ARGS_ASSERT_FIRST_SYMBOL;
+
while (pat < patend) {
if (pat[0] != '#') return pat[0];
pat++;
{
tempsym_t sym;
+ PERL_ARGS_ASSERT_UNPACKSTRING;
+
if (flags & FLAG_DO_UTF8) flags |= FLAG_WAS_UTF8;
else if (need_utf8(pat, patend)) {
/* We probably should try to avoid this in case a scalar context call
SV *sv;
const I32 start_sp_offset = SP - PL_stack_base;
howlen_t howlen;
-
I32 checksum = 0;
UV cuv = 0;
NV cdouble = 0.0;
bool explicit_length;
const bool unpack_only_one = (symptr->flags & FLAG_UNPACK_ONLY_ONE) != 0;
bool utf8 = (symptr->flags & FLAG_PARSE_UTF8) ? 1 : 0;
+
+ PERL_ARGS_ASSERT_UNPACK_REC;
+
symptr->strbeg = s - strbeg;
while (next_symbol(symptr)) {
symptr->previous = &savsym;
symptr->level++;
PUTBACK;
+ if (len && unpack_only_one) len = 1;
while (len--) {
symptr->patptr = savsym.grpbeg;
if (utf8) symptr->flags |= FLAG_PARSE_UTF8;
if (howlen == e_star || len > (strend - s) * 8)
len = (strend - s) * 8;
if (checksum) {
- if (!PL_bitcount) {
- int bits;
- Newxz(PL_bitcount, 256, char);
- for (bits = 1; bits < 256; bits++) {
- if (bits & 1) PL_bitcount[bits]++;
- if (bits & 2) PL_bitcount[bits]++;
- if (bits & 4) PL_bitcount[bits]++;
- if (bits & 8) PL_bitcount[bits]++;
- if (bits & 16) PL_bitcount[bits]++;
- if (bits & 32) PL_bitcount[bits]++;
- if (bits & 64) PL_bitcount[bits]++;
- if (bits & 128) PL_bitcount[bits]++;
- }
- }
if (utf8)
while (len >= 8 && s < strend) {
cuv += PL_bitcount[uni_to_byte(aTHX_ &s, strend, datumtype)];
bool skip = 1;
bool ignore = 0;
+ PERL_ARGS_ASSERT_IS_AN_INT;
+
while (*s) {
switch (*s) {
case ' ':
char *t = s;
int m = 0;
+ PERL_ARGS_ASSERT_DIV128;
+
*done = 1;
while (*t) {
const int i = m * 10 + (*t - '0');
dVAR;
tempsym_t sym;
+ PERL_ARGS_ASSERT_PACKLIST;
+
TEMPSYM_INIT(&sym, pat, patend, FLAG_PACK);
/* We're going to do changes through SvPVX(cat). Make sure it's valid.
const STRLEN cur = SvCUR(sv);
const STRLEN len = SvLEN(sv);
STRLEN extend;
+
+ PERL_ARGS_ASSERT_SV_EXP_GROW;
+
if (len - cur > needed) return SvPVX(sv);
extend = needed > len ? needed : len;
return SvGROW(sv, len+extend+1);
bool utf8 = (symptr->flags & FLAG_PARSE_UTF8) ? 1 : 0;
bool warn_utf8 = ckWARN(WARN_UTF8);
+ PERL_ARGS_ASSERT_PACK_REC;
+
if (symptr->level == 0 && found && symptr->code == 'U') {
marked_upgrade(aTHX_ cat, symptr);
symptr->flags |= FLAG_DO_UTF8;
}
memset(cur, datumtype == 'A' ? ' ' : '\0', len);
cur += len;
+ SvTAINT(cat);
break;
}
case 'B':
any OS that needs it, or removed if and when VOS implements
posix-976 (suggestion to support mapping to infinity).
Paul.Green@stratus.com 02-04-02. */
+{
+extern const float _float_constants[];
if (anv > FLT_MAX)
afloat = _float_constants[0]; /* single prec. inf. */
else if (anv < -FLT_MAX)
afloat = _float_constants[0]; /* single prec. inf. */
else afloat = (float) anv;
+}
#else /* __VOS__ */
# if defined(VMS) && !defined(__IEEE_FP)
/* IEEE fp overflow shenanigans are unavailable on VAX and optional
for any OS that needs it, or removed if and when VOS
implements posix-976 (suggestion to support mapping to
infinity). Paul.Green@stratus.com 02-04-02. */
+{
+extern const double _double_constants[];
if (anv > DBL_MAX)
adouble = _double_constants[0]; /* double prec. inf. */
else if (anv < -DBL_MAX)
adouble = _double_constants[0]; /* double prec. inf. */
else adouble = (double) anv;
+}
#else /* __VOS__ */
# if defined(VMS) && !defined(__IEEE_FP)
/* IEEE fp overflow shenanigans are unavailable on VAX and optional
register const char *patend = pat + fromlen;
MARK++;
- sv_setpvn(cat, "", 0);
+ sv_setpvs(cat, "");
SvUTF8_off(cat);
packlist(cat, pat, patend, MARK, SP + 1);