diff -u -r ./kparse.c /home/nbkp1nr/github/k-perl/kparse.c
--- ./kparse.c 2012-04-08 15:39:27.000000000 -0500
+++ /home/nbkp1nr/github/k-perl/kparse.c 2012-04-18 20:57:37.361327186 -0500
@@ -165,6 +165,10 @@
break;
}
+ if ( k->t == KC || k->t == KG ) {
+ return result;
+ }
+
return newRV_noinc((SV*)result);
}
@@ -382,21 +386,18 @@
}
SV* byte_vector_from_k(K k) {
- AV *av = newAV();
- char byte_str[1];
+ char byte_str[k->n];
int i = 0;
for (i = 0; i < k->n; i++) {
if (kG(k)[i] == 0) {
- av_push(av, &PL_sv_undef);
continue;
}
- byte_str[0] = kG(k)[i];
- av_push(av, newSVpvn(byte_str, 1));
+ byte_str[i] = kG(k)[i];
}
- return (SV*)av;
+ return newSVpvn(byte_str, k->n);
}
SV* short_vector_from_k(K k) {
diff -u -r ./t/k.t /home/nbkp1nr/github/k-perl/t/k.t
--- ./t/k.t 2012-04-08 16:46:39.000000000 -0500
+++ /home/nbkp1nr/github/k-perl/t/k.t 2012-04-18 20:45:13.190224758 -0500
@@ -12,7 +12,7 @@
is $k->cmd('4 + 4'), 8, 'make an int';
- is_deeply $k->cmd(q/"abc"/), [qw/a b c/], 'make char vector';
+ is $k->cmd(q/"abc"/), "abc", 'make string';
my $timestamp = $k->cmd(q/2012.03.24D12:13:14.15161728/);
is "$timestamp", '385906394151617280', 'timestamp';
diff -u -r ./t/raw.t /home/nbkp1nr/github/k-perl/t/raw.t
--- ./t/raw.t 2012-04-08 16:46:39.000000000 -0500
+++ /home/nbkp1nr/github/k-perl/t/raw.t 2012-04-18 21:06:51.104563448 -0500
@@ -122,13 +122,13 @@
my ($handle) = @_;
is_deeply k( $handle, '(),0b' ), [ undef ], 'null boolean vector';
- is_deeply k( $handle, '(),0x00'), [ undef ], 'null byte vector';
+ is k( $handle, '(),0x00'), "\000", 'null byte vector';
is_deeply k( $handle, '(),0Nh' ), [ undef ], 'null short vector';
is_deeply k( $handle, '(),0N' ), [ undef ], 'null int vector';
is_deeply k( $handle, '(),0Nj' ), [ undef ], 'null long vector';
is_deeply k( $handle, '(),0Ne' ), [ undef ], 'null real vector';
is_deeply k( $handle, '(),0n' ), [ undef ], 'null float vector';
- is_deeply k( $handle, '()," "' ), [ ' ' ], 'null char vector'; # this ones weird
+ is_deeply k( $handle, '()," "' ), ' ', 'null char vector'; # this ones weird
is_deeply k( $handle, '(),`' ), [ undef ], 'null sym vector';
is_deeply k( $handle, '(),0Nm' ), [ undef ], 'null month vector';
is_deeply k( $handle, '(),0Nd' ), [ undef ], 'null day vector';
@@ -165,7 +165,7 @@
my ($handle) = @_;
is_deeply k($handle, '(0b;1b;0b)'), [undef, 1, undef], 'parse bool vector';
- is_deeply k($handle, '"abc"'), [qw(a b c)], 'parse char vector';
+ is_deeply k($handle, '"abc"'), "abc", 'parse char vector';
is_deeply k($handle, '(7h;8h;9h)'), [7, 8, 9], 'parse short vector';
is_deeply k($handle, '(7i;8i;9i)'), [7, 8, 9], 'parse int vector';