File: reallocate_pl_linestr

package info (click to toggle)
libsignatures-perl 0.06-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 380 kB
  • sloc: perl: 1,235; makefile: 2
file content (46 lines) | stat: -rw-r--r-- 1,239 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
Description: With Perl >= 5.13.6, reallocate PL_linestr in a block
 hook to avoid reallocations; borrowed loosely from Devel::Declare
Author: Colin Watson <cjwatson@ubuntu.com>
Bug-Debian: http://bugs.debian.org/636132
Bug-Ubuntu: https://bugs.launchpad.net/bugs/935261
Forwarded: https://rt.cpan.org/Public/Bug/Display.html?id=66997

--- signatures-0.05.orig/signatures.xs
+++ signatures-0.05/signatures.xs
@@ -241,6 +241,16 @@
 	return ret;
 }
 
+#if PERL_BCDVERSION >= 0x5013006
+STATIC void
+block_start (pTHX_ int full) {
+	PERL_UNUSED_VAR (full);
+
+	if (SvLEN (PL_linestr) < 16384)
+		lex_grow_linestr (16384);
+}
+#endif
+
 STATIC OP *
 before_eval (pTHX_ OP *op, void *user_data) {
 	dSP;
@@ -293,12 +303,19 @@
 		char *f_class
 	PREINIT:
 		userdata_t *ud;
+#if PERL_BCDVERSION >= 0x5013006
+		static BHK bhk;
+#endif
 	INIT:
 		Newx (ud, 1, userdata_t);
 		ud->class = newSVsv (class);
 		ud->f_class = f_class;
 	CODE:
 		ud->parser_id = hook_parser_setup ();
+#if PERL_BCDVERSION >= 0x5013006
+		BhkENTRY_set (&bhk, bhk_start, block_start);
+		Perl_blockhook_register (aTHX_ &bhk);
+#endif
 		ud->eval_hook = hook_op_check (OP_ENTEREVAL, handle_eval, ud);
 		RETVAL = (UV)hook_op_check (OP_CONST, handle_proto, ud);
 	OUTPUT: