const int bits_in_uv = 8 * sizeof(cuv);
char* strrelbeg = s;
bool beyond = FALSE;
+ bool explicit_length;
bool unpack_only_one = (symptr->flags & FLAG_UNPACK_ONLY_ONE) != 0;
while (next_symbol(symptr)) {
break;
}
+ explicit_length = TRUE;
redo_switch:
beyond = s >= strend;
{
case 'C':
unpack_C: /* unpack U will jump here if not UTF-8 */
if (len == 0) {
- symptr->flags &= ~FLAG_UNPACK_DO_UTF8;
+ if (explicit_length)
+ symptr->flags &= ~FLAG_UNPACK_DO_UTF8;
break;
}
if (checksum) {
break;
case 'U':
if (len == 0) {
- symptr->flags |= FLAG_UNPACK_DO_UTF8;
+ if (explicit_length)
+ symptr->flags |= FLAG_UNPACK_DO_UTF8;
break;
}
if ((symptr->flags & FLAG_UNPACK_DO_UTF8) == 0)
Perl_croak(aTHX_ "Code missing after '/' in unpack" );
}
datumtype = symptr->code;
+ explicit_length = FALSE;
goto redo_switch;
}
}
my $no_signedness = $] > 5.009 ? '' :
"Signed/unsigned pack modifiers not available on this perl";
-plan tests => 13859;
+plan tests => 13863;
use strict;
use warnings;
is($x[0], 'b', 'before scope');
is($x[1], 225, 'after scope');
}
+
+{
+ # counted length prefixes shouldn't change C0/U0 mode
+ # (note the length is actually 0 in this test)
+ is(join(',', unpack("aC/UU", "b\0\341\277\274")), 'b,225');
+ is(join(',', unpack("aC/CU", "b\0\341\277\274")), 'b,225');
+ is(join(',', unpack("aU0C/UU", "b\0\341\277\274")), 'b,8188');
+ is(join(',', unpack("aU0C/CU", "b\0\341\277\274")), 'b,8188');
+}