Skip to content

Commit

Permalink
Fixed numeric code (allow -0 to be accepted). Bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
mnunberg committed Apr 8, 2012
1 parent ee3f8a2 commit 8df1d89
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
8 changes: 5 additions & 3 deletions SL.xs
Expand Up @@ -142,7 +142,9 @@ pljsonsl_common_mknumeric_THX(pTHX_
case JSONSL_SPECIALf_SIGNED:
nbuf--;
if (nbuf == 0) { die_numeric("found lone '-'"); }
if (buf[1] == '0') { die_numeric("0 after '-'"); }
if (nbuf > 1 && buf[1] == '0') {
die_numeric("Leading 0 after '-'");
}
if (nbuf < (IV_DIG-1)) {
newsv = newSViv(-((IV)state->nelem));
break;
Expand All @@ -151,7 +153,7 @@ pljsonsl_common_mknumeric_THX(pTHX_
break;

default:
if (state->special_flags & (JSONSL_SPECIALf_FLOAT|JSONSL_SPECIALf_EXPONENT)) {
if (state->special_flags & JSONSL_SPECIALf_NUMNOINT) {
newsv = jsonxs_inline_process_number(buf);
}
break;
Expand Down Expand Up @@ -1077,7 +1079,7 @@ pltuba_process_accum_THX(pTHX_
SV *newsv;

if ( (state->special_flags & JSONSL_SPECIALf_NUMERIC) &&
(state->special_flags & JSONSL_SPECIALf_NUMERIC) == 0) {
(state->special_flags & JSONSL_SPECIALf_NUMNOINT) == 0) {
goto GT_NONEWSV;

} else if (state->special_flags & JSONSL_SPECIALf_NUMNOINT) {
Expand Down
10 changes: 5 additions & 5 deletions eg/tuba.pl
Expand Up @@ -42,7 +42,7 @@ package My::Giant::Tuba;

sub on_any {
my ($tuba,$info,$data) = @_;

#print Dumper(\@_);
#use constant comparisons
if ($info->{Type} == TUBA_TYPE_JSON) {
printf STDERR ("JSON DOCUMENT: %c\n\n", $info->{Mode});
Expand All @@ -60,12 +60,11 @@ sub on_any {
} elsif ($info->{Type} =~ m,[\[\{],) {
if ($info->{Mode} eq '+') {
print $info->{Type} . "\n";
} else {

} else {
print $JSON::SL::Tuba::CloseTokens{$info->{Type}} . ",\n";
}
} else {
if (defined $data) {
if (@_ == 3) {
print $data . ",\n"
} else {
die ("hrrm.. what have we here?")
Expand Down Expand Up @@ -102,6 +101,7 @@ sub new {


foreach (1..$Iterations) {
my $o = My::Giant::Tuba->new();
my $o = My::Giant::Tuba->new();
$o->utf8(1);
$o->parse($_) for @Chunks;
}
2 changes: 1 addition & 1 deletion lib/JSON/SL.pm
Expand Up @@ -16,7 +16,7 @@ use base qw(Exporter);
our @EXPORT_OK = qw(decode_json unescape_json_string);

BEGIN {
$VERSION = '0.0_5';
$VERSION = '0.06';
require XSLoader;
XSLoader::load(__PACKAGE__, $VERSION);
}
Expand Down
3 changes: 1 addition & 2 deletions lib/JSON/SL/Tuba.pm
Expand Up @@ -524,8 +524,7 @@ it.
=head1 BUGS AND CAVEATS
At this release, no tests have been implemented.
It would be nice to provide an error handler.
=head2 Info Hash
Expand Down

0 comments on commit 8df1d89

Please sign in to comment.