Permalink
Browse files

Fixed numeric code (allow -0 to be accepted). Bump version

  • Loading branch information...
1 parent ee3f8a2 commit 8df1d893a7f5dd51c87aa6852660abde47101a0a @mnunberg committed Apr 8, 2012
Showing with 12 additions and 11 deletions.
  1. +5 −3 SL.xs
  2. +5 −5 eg/tuba.pl
  3. +1 −1 lib/JSON/SL.pm
  4. +1 −2 lib/JSON/SL/Tuba.pm
View
8 SL.xs
@@ -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;
@@ -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;
@@ -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) {
View
@@ -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});
@@ -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?")
@@ -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;
}
View
@@ -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);
}
View
@@ -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

0 comments on commit 8df1d89

Please sign in to comment.