On Wed, Jan 10, 2007 at 05:55:52AM -0600, Steve Peters wrote:
> I finally had a chance to play with the Template-Toolkit test failures
> I saw with bleadperl. From my testing, change #27636 is the cause of the
> failures I'm seeing in t/tiedhash.t in Template-Toolkit.
>
> To follow along at home, here's a patch that's needed for Stash.xs to
> compile TT and to keep it from failing assertions while testing with a
> debugging Perl.
>
> --- xs/Stash.xs.old 2007-01-09 20:27:49.000000000 -0600
> +++ xs/Stash.xs 2007-01-09 22:06:30.000000000 -0600
> @@ -499,7 +499,7 @@
> }
>
> /* drop-through if not an object or method not found */
> - switch SvTYPE(SvRV(root)) {
> + switch (SvTYPE(SvRV(root))) {
>
> case SVt_PVHV: /* HASH */
> roothv = (HV *) SvRV(root);
> @@ -991,7 +991,7 @@
> STRLEN jlen;
> char *joint;
>
> - if ((svp = av_fetch(args, 0, FALSE)) != NULL) {
> + if (args && (svp = av_fetch(args, 0, FALSE)) != NULL) {
> joint = SvPV(*svp, jlen);
> } else {
> joint = " ";
>
>
> The hv_store() with the problems is below
>
> 519 /* avoid 'modification of read-only value' error */
> 520 newsv = newSVsv(value);
> 521 if (hv_store(roothv, key, key_len, newsv, 0)) {
> 522 /* invoke any tied magical STORE method */
> 523 debug(" - stored hash item\n");
> 524 SvSETMAGIC(newsv);
> 525 }
> 526 else {
> 527 printf(" - did not store hash item (hv_store() returned
> NUL L)\n");
> 528 }
> 529
> 530 return value;
> 531 break;
>
> I tried the simple solution of moving the SvSETMAGIC(newsv) to after the
> if, but the same test failures occured. So, TT must be dependant on code
> after the changed return executing. What code that exactly is, I don't
> know at this point.
>
I must have been sleepy when I tested this because the following change
fixes all the noise from Template Toolkit 2.15 with bleadperl. I also tested
with Perl 5.8.8, and everything passed there as well.
--- xs/Stash.xs.old 2007-01-09 20:27:49.000000000 -0600
+++ xs/Stash.xs 2007-01-16 15:14:48.000000000 -0600
@@ -499,7 +499,7 @@
}
/* drop-through if not an object or method not found */
- switch SvTYPE(SvRV(root)) {
+ switch (SvTYPE(SvRV(root))) {
case SVt_PVHV: /* HASH */
roothv = (HV *) SvRV(root);
@@ -518,14 +518,8 @@
/* avoid 'modification of read-only value' error */
newsv = newSVsv(value);
- if (hv_store(roothv, key, key_len, newsv, 0)) {
- /* invoke any tied magical STORE method */
- debug(" - stored hash item\n");
- SvSETMAGIC(newsv);
- }
- else {
- printf(" - did not store hash item (hv_store() returned
NULL)\n");
- }
+ hv_store(roothv, key, key_len, newsv, 0);
+ SvSETMAGIC(newsv);
return value;
break;
@@ -991,7 +985,7 @@
STRLEN jlen;
char *joint;
- if ((svp = av_fetch(args, 0, FALSE)) != NULL) {
+ if (args && (svp = av_fetch(args, 0, FALSE)) != NULL) {
joint = SvPV(*svp, jlen);
} else {
joint = " ";
Steve Peters
[EMAIL PROTECTED]
_______________________________________________
templates mailing list
[email protected]
http://lists.template-toolkit.org/mailman/listinfo/templates