=== modified file 'lib/Tickit.xs'
--- lib/Tickit.xs 2017-02-15 14:55:28 +0000
+++ lib/Tickit.xs 2017-03-15 18:04:27 +0000
@@ -1547,15 +1547,15 @@
SV *text
Tickit::Pen pen
INIT:
+ char *bytes;
STRLEN len;
CODE:
- SvGETMAGIC(text);
- len = SvCUR(text);
+ bytes = SvPVutf8(text, len);
if(pen) {
tickit_renderbuffer_savepen(self);
tickit_renderbuffer_setpen(self, pen);
}
- RETVAL = tickit_renderbuffer_textn_at(self, line, col, SvPVutf8_nolen(text), len);
+ RETVAL = tickit_renderbuffer_textn_at(self, line, col, bytes, len);
if(pen)
tickit_renderbuffer_restore(self);
OUTPUT:
@@ -1567,18 +1567,18 @@
SV *text
Tickit::Pen pen
INIT:
+ char *bytes;
STRLEN len;
CODE:
if(!tickit_renderbuffer_has_cursorpos(self))
croak("Cannot ->text without a virtual cursor position");
- SvGETMAGIC(text);
- len = SvCUR(text);
+ bytes = SvPVutf8(text, len);
if(pen) {
tickit_renderbuffer_savepen(self);
tickit_renderbuffer_setpen(self, pen);
}
- RETVAL = tickit_renderbuffer_textn(self, SvPVutf8_nolen(text), len);
+ RETVAL = tickit_renderbuffer_textn(self, bytes, len);
if(pen)
tickit_renderbuffer_restore(self);
OUTPUT:
=== modified file 't/10renderbuffer-span.t'
--- t/10renderbuffer-span.t 2015-03-26 18:15:14 +0000
+++ t/10renderbuffer-span.t 2017-03-15 18:04:03 +0000
@@ -96,6 +96,30 @@
'RenderBuffer correctly gets MAGIC' );
}
+# Conversion of numerical arguments - RT120630
+{
+ tie my $sv, "FetchCounter";
+ my $count = 0;
+ {
+ package FetchCounter;
+ sub TIESCALAR { return bless [], shift }
+ sub FETCH { $count++; return "AB"; }
+ }
+
+ my $cols = $rb->text_at( 0, 4, $sv );
+ is( $cols, 2, "return from ->text_at on SvIV" );
+
+ $rb->goto( 1, 4 );
+ $rb->text( $sv );
+
+ $rb->flush_to_term( $term );
+ is_termlog( [ GOTO(0,4), SETPEN(), PRINT("AB"),
+ GOTO(1,4), SETPEN(), PRINT("AB") ],
+ 'RenderBuffer correctly converts SvIV' );
+
+ is( $count, 2, 'FETCH called only twice' );
+}
+
# Span splitting
{
my $pen = Tickit::Pen->new;