r39562 - in /branches/upstream/libhtml-template-pro-perl/current: ./ lib/HTML/Template/ t/ templates-Pro/
ghostbar-guest at users.alioth.debian.org
ghostbar-guest at users.alioth.debian.org
Thu Jul 9 18:42:12 UTC 2009
Author: ghostbar-guest
Date: Thu Jul 9 18:41:39 2009
New Revision: 39562
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=39562
Log:
[svn-upgrade] Integrating new upstream version, libhtml-template-pro-perl (0.75)
Added:
branches/upstream/libhtml-template-pro-perl/current/provalue.c
branches/upstream/libhtml-template-pro-perl/current/provalue.h
branches/upstream/libhtml-template-pro-perl/current/t/05path_like_variable_scope.t
branches/upstream/libhtml-template-pro-perl/current/templates-Pro/test_loop6.out
branches/upstream/libhtml-template-pro-perl/current/templates-Pro/test_loop6.tmpl
Modified:
branches/upstream/libhtml-template-pro-perl/current/Changes
branches/upstream/libhtml-template-pro-perl/current/MANIFEST
branches/upstream/libhtml-template-pro-perl/current/META.yml
branches/upstream/libhtml-template-pro-perl/current/Makefile.PL
branches/upstream/libhtml-template-pro-perl/current/Pro.xs
branches/upstream/libhtml-template-pro-perl/current/README
branches/upstream/libhtml-template-pro-perl/current/expr.c
branches/upstream/libhtml-template-pro-perl/current/expr.y
branches/upstream/libhtml-template-pro-perl/current/lib/HTML/Template/Pro.pm
branches/upstream/libhtml-template-pro-perl/current/pbuffer.c
branches/upstream/libhtml-template-pro-perl/current/pbuffer.h
branches/upstream/libhtml-template-pro-perl/current/perl-HTML-Template-Pro.spec
branches/upstream/libhtml-template-pro-perl/current/procore.c
branches/upstream/libhtml-template-pro-perl/current/procore.h
branches/upstream/libhtml-template-pro-perl/current/t/HTML-Template-Pro.t
Modified: branches/upstream/libhtml-template-pro-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-template-pro-perl/current/Changes?rev=39562&op=diff
==============================================================================
--- branches/upstream/libhtml-template-pro-perl/current/Changes (original)
+++ branches/upstream/libhtml-template-pro-perl/current/Changes Thu Jul 9 18:41:39 2009
@@ -167,4 +167,7 @@
- memory leaks fix
(by Shigeki Morimoto <shigeki.morimoto at mixi.co.jp>)
-
+0.75 Wed Jul 1 23:23:36 EEST 2009
+ - pos value in log message.
+ (Shigeki Morimoto <shigeki.morimoto at mixi.co.jp>).
+ - fixed cpan rt #38486 (mixed loops && global_var=1)
Modified: branches/upstream/libhtml-template-pro-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-template-pro-perl/current/MANIFEST?rev=39562&op=diff
==============================================================================
--- branches/upstream/libhtml-template-pro-perl/current/MANIFEST (original)
+++ branches/upstream/libhtml-template-pro-perl/current/MANIFEST Thu Jul 9 18:41:39 2009
@@ -35,6 +35,8 @@
proscope.c
proscope.h
prostate.h
+provalue.c
+provalue.h
pstring.c
pstring.h
t/01coderefs.t
@@ -42,6 +44,7 @@
t/02random.t
t/03complex.t
t/04register.t
+t/05path_like_variable_scope.t
t/HTML-Template-Expr.t
t/HTML-Template-Pro.t
t/HTML-Template.t
@@ -120,6 +123,8 @@
templates-Pro/test_loop4.tmpl
templates-Pro/test_loop5.out
templates-Pro/test_loop5.tmpl
+templates-Pro/test_loop6.out
+templates-Pro/test_loop6.tmpl
templates-Pro/test_malloc.tmpl
templates-Pro/test_var1.out
templates-Pro/test_var1.tmpl
Modified: branches/upstream/libhtml-template-pro-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-template-pro-perl/current/META.yml?rev=39562&op=diff
==============================================================================
--- branches/upstream/libhtml-template-pro-perl/current/META.yml (original)
+++ branches/upstream/libhtml-template-pro-perl/current/META.yml Thu Jul 9 18:41:39 2009
@@ -1,6 +1,6 @@
--- #YAML:1.0
name: HTML-Template-Pro
-version: 0.74
+version: 0.75
abstract: Perl/XS module to use HTML Templates from CGI scripts
license: ~
author:
Modified: branches/upstream/libhtml-template-pro-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-template-pro-perl/current/Makefile.PL?rev=39562&op=diff
==============================================================================
--- branches/upstream/libhtml-template-pro-perl/current/Makefile.PL (original)
+++ branches/upstream/libhtml-template-pro-perl/current/Makefile.PL Thu Jul 9 18:41:39 2009
@@ -4,7 +4,7 @@
use File::Spec;
$Verbose = 1;
-$O_FILES=qw/procore.o pbuffer.o proscope.o expr.o pstring.o tmpllog.o/;
+$O_FILES=qw/procore.o provalue.o pbuffer.o proscope.o expr.o pstring.o tmpllog.o/;
# loadfile.o calc.o exprtool.o tagstack.o
my $INC='-I.';
@@ -25,11 +25,14 @@
# win 32 mmap is disabled by default
# $DEF{MMAP}=1;
$DEF{MMAP}=0;
+ # no, compiler is yet unknown here;
+ # and some creepy M**soft tools may not understand long long :(
+ # $DEF{INT64_NAME} = "long long";?
} else {
$DEF{MMAP}=has_mmap();
}
-$DEF{INT64_NAME} = find_int64();
+$DEF{INT64_NAME} ||= find_int64();
$DEF{INT64_NAME} ||= $Config{i64type};
my $i;
@@ -260,7 +263,7 @@
}
sub find_int64 {
- foreach my $type ('long long','long','int') {
+ foreach my $type ('__int64','long long','long','int') {
return $type if try_as_int64($type);
}
return;
Modified: branches/upstream/libhtml-template-pro-perl/current/Pro.xs
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-template-pro-perl/current/Pro.xs?rev=39562&op=diff
==============================================================================
--- branches/upstream/libhtml-template-pro-perl/current/Pro.xs (original)
+++ branches/upstream/libhtml-template-pro-perl/current/Pro.xs Thu Jul 9 18:41:39 2009
@@ -16,6 +16,7 @@
#include "ppport.h"
#include "tmplpro.h"
+#include "provalue.h"
typedef PerlIO * OutputStream;
@@ -96,11 +97,10 @@
}
static
-int perl_init_loop (struct scope_stack* variable_scope, PSTRING name) {
+int perl_init_loop (struct tmplpro_param *param, PSTRING name) {
AV* loops_AV;
int maxloop;
- struct ProLoopState* currentScope = getCurrentScope(variable_scope);
- SV** hashvalptr=hv_fetch((HV*)currentScope->param_HV,name.begin, name.endnext-name.begin, 0);
+ SV** hashvalptr=(SV**) walk_through_nested_loops(param,name);
if (hashvalptr==NULL) {
return 0;
} else {
@@ -113,7 +113,7 @@
loops_AV=(AV *)SvRV(*hashvalptr);
maxloop=av_len(loops_AV);
if (maxloop < 0) return 0;
- pushScope2(variable_scope, maxloop, loops_AV);
+ pushScope2(¶m->var_scope_stack, maxloop, loops_AV);
return 1;
}
}
Modified: branches/upstream/libhtml-template-pro-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-template-pro-perl/current/README?rev=39562&op=diff
==============================================================================
--- branches/upstream/libhtml-template-pro-perl/current/README (original)
+++ branches/upstream/libhtml-template-pro-perl/current/README Thu Jul 9 18:41:39 2009
@@ -1,4 +1,4 @@
-HTML-Template-Pro version 0.69
+HTML-Template-Pro version 0.75
==============================
DESCRIPTION
@@ -11,7 +11,7 @@
available or in case of disk usage and memory limitations.
HTML::Template::Pro is a fast lightweight C/Perl+XS reimplementation
-of HTML::Template (as of 2.8) and HTML::Template::Expr (as of 0.0.5).
+of HTML::Template (as of 2.9) and HTML::Template::Expr (as of 0.0.5).
It is not intended to be a complete replacement,
but to be a fast implementation of HTML::Template if you don't need
quering, the extended facility of HTML::Template.
@@ -91,9 +91,10 @@
COPYRIGHT AND LICENCE
-Copyright (C) 2005-2008 by I. Yu. Vlasenko.
+Copyright (C) 2005-2009 by I. Yu. Vlasenko.
Pieces of code in Pro.pm and documentation of HTML::Template are
-copyright (C) 2000-2006 Sam Tregar (sam at tregar.com)
+copyright (C) 2000-2009 Sam Tregar (sam at tregar.com)
+Other contributors to the code base are listed in Changes.
The template syntax, interface conventions and a large piece of documentation
of HTML::Template::Pro are based on CPAN module HTML::Template
Modified: branches/upstream/libhtml-template-pro-perl/current/expr.c
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-template-pro-perl/current/expr.c?rev=39562&op=diff
==============================================================================
--- branches/upstream/libhtml-template-pro-perl/current/expr.c (original)
+++ branches/upstream/libhtml-template-pro-perl/current/expr.c Thu Jul 9 18:41:39 2009
@@ -1971,7 +1971,7 @@
static
void
expr_debug(struct tmplpro_state* state, char const *msg1, char const *msg2) {
- tmpl_log(NULL, TMPL_LOG_ERROR, "EXPR:at pos %d: %s %s\n", (state->expr_curpos)-(state->expr).begin,msg1,msg2);
+ tmpl_log(NULL, TMPL_LOG_ERROR, "EXPR:at pos %td [%td]: %s %s\n", (state->expr_curpos)-(state->top),(state->expr_curpos)-(state->expr).begin,msg1,msg2);
}
static
@@ -2107,7 +2107,7 @@
if (! state->param->case_sensitive) {
lowercase_pstring_inplace(name);
}
- varvalue=get_variable_value(state, name);
+ varvalue=get_variable_value(state->param, name);
/* tmpl_log(NULL, TMPL_LOG_ERROR, "lex:detected var %s=%s\n", name.begin,varvalue.begin); */
if (varvalue.begin==NULL) {
/*(*lvalp).numval.val.strval=(PSTRING) {(state->expr_curpos), (state->expr_curpos)};*/
Modified: branches/upstream/libhtml-template-pro-perl/current/expr.y
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-template-pro-perl/current/expr.y?rev=39562&op=diff
==============================================================================
--- branches/upstream/libhtml-template-pro-perl/current/expr.y (original)
+++ branches/upstream/libhtml-template-pro-perl/current/expr.y Thu Jul 9 18:41:39 2009
@@ -224,7 +224,7 @@
static
void
expr_debug(struct tmplpro_state* state, char const *msg1, char const *msg2) {
- tmpl_log(NULL, TMPL_LOG_ERROR, "EXPR:at pos %d: %s %s\n", (state->expr_curpos)-(state->expr).begin,msg1,msg2);
+ tmpl_log(NULL, TMPL_LOG_ERROR, "EXPR:at pos %td [%td]: %s %s\n", (state->expr_curpos)-(state->top),(state->expr_curpos)-(state->expr).begin,msg1,msg2);
}
static
@@ -360,7 +360,7 @@
if (! state->param->case_sensitive) {
lowercase_pstring_inplace(name);
}
- varvalue=get_variable_value(state, name);
+ varvalue=get_variable_value(state->param, name);
/* tmpl_log(NULL, TMPL_LOG_ERROR, "lex:detected var %s=%s\n", name.begin,varvalue.begin); */
if (varvalue.begin==NULL) {
/*(*lvalp).numval.val.strval=(PSTRING) {(state->expr_curpos), (state->expr_curpos)};*/
Modified: branches/upstream/libhtml-template-pro-perl/current/lib/HTML/Template/Pro.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-template-pro-perl/current/lib/HTML/Template/Pro.pm?rev=39562&op=diff
==============================================================================
--- branches/upstream/libhtml-template-pro-perl/current/lib/HTML/Template/Pro.pm (original)
+++ branches/upstream/libhtml-template-pro-perl/current/lib/HTML/Template/Pro.pm Thu Jul 9 18:41:39 2009
@@ -9,7 +9,7 @@
use vars qw($VERSION @ISA);
@ISA = qw(DynaLoader);
-$VERSION = '0.74';
+$VERSION = '0.75';
bootstrap HTML::Template::Pro $VERSION;
Modified: branches/upstream/libhtml-template-pro-perl/current/pbuffer.c
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-template-pro-perl/current/pbuffer.c?rev=39562&op=diff
==============================================================================
--- branches/upstream/libhtml-template-pro-perl/current/pbuffer.c (original)
+++ branches/upstream/libhtml-template-pro-perl/current/pbuffer.c Thu Jul 9 18:41:39 2009
@@ -29,6 +29,5 @@
/*
* Local Variables:
* mode: c
- * coding: cp1251
* End:
*/
Modified: branches/upstream/libhtml-template-pro-perl/current/pbuffer.h
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-template-pro-perl/current/pbuffer.h?rev=39562&op=diff
==============================================================================
--- branches/upstream/libhtml-template-pro-perl/current/pbuffer.h (original)
+++ branches/upstream/libhtml-template-pro-perl/current/pbuffer.h Thu Jul 9 18:41:39 2009
@@ -19,6 +19,5 @@
/*
* Local Variables:
* mode: c
- * coding: cp1251
* End:
*/
Modified: branches/upstream/libhtml-template-pro-perl/current/perl-HTML-Template-Pro.spec
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-template-pro-perl/current/perl-HTML-Template-Pro.spec?rev=39562&op=diff
==============================================================================
--- branches/upstream/libhtml-template-pro-perl/current/perl-HTML-Template-Pro.spec (original)
+++ branches/upstream/libhtml-template-pro-perl/current/perl-HTML-Template-Pro.spec Thu Jul 9 18:41:39 2009
@@ -6,7 +6,7 @@
%define module HTML-Template-Pro
Name: perl-%module
-Version: 0.74
+Version: 0.75
Release: alt1
Packager: Igor Yu. Vlasenko <viy at altlinux.org>
@@ -54,6 +54,9 @@
%perl_vendor_man3dir/*
%changelog
+* Wed Jul 01 2009 Igor Vlasenko <viy at altlinux.ru> 0.75-alt1
+- new version; see Changes
+
* Fri Apr 03 2009 Igor Vlasenko <viy at altlinux.ru> 0.74-alt1
- new version; see Changes
Modified: branches/upstream/libhtml-template-pro-perl/current/procore.c
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-template-pro-perl/current/procore.c?rev=39562&op=diff
==============================================================================
--- branches/upstream/libhtml-template-pro-perl/current/procore.c (original)
+++ branches/upstream/libhtml-template-pro-perl/current/procore.c Thu Jul 9 18:41:39 2009
@@ -8,6 +8,7 @@
#include "procore.h"
#include "prostate.h"
+#include "provalue.h"
#include "tagstack.h"
#include "pbuffer.h"
#include "proscope.h"
@@ -97,13 +98,13 @@
static
PSTRING
-get_loop_context_vars_value (struct tmplpro_state *state, PSTRING name) {
+get_loop_context_vars_value (struct tmplpro_param *param, PSTRING name) {
static char* FalseString="0";
static char* TrueString ="1";
static char buffer[20]; /* for snprintf %d */
int loop;
PSTRING retval={NULL,NULL};
- if (curScopeLevel(&state->param->var_scope_stack)>0
+ if (curScopeLevel(¶m->var_scope_stack)>0
&& name.endnext-name.begin>4
&& '_'==*(name.begin)
&& '_'==*(name.begin+1)
@@ -111,7 +112,7 @@
/* we can meet loop variables here -- try it first */
/* length of its name >4 */
/* __first__ __last__ __inner__ __odd__ __counter__ */
- struct ProLoopState* currentScope = getCurrentScope(&state->param->var_scope_stack);
+ struct ProLoopState* currentScope = getCurrentScope(¶m->var_scope_stack);
PSTRING shiftedname; /* (PSTRING) {name.begin+2,name.endnext} */
shiftedname.begin=name.begin+2;
shiftedname.endnext=name.endnext;
@@ -275,54 +276,13 @@
state->tag_start - state->top);
}
-static
-ABSTRACT_VALUE* walk_through_nested_loops (struct tmplpro_state *state, PSTRING name) {
- int PrevHash;
- struct ProLoopState* currentScope;
- ABSTRACT_VALUE* valptr;
- /* Shigeki Morimoto path_like_variable_scope extension */
- if (state->param->path_like_variable_scope) {
- if(*(name.begin) == '/' || strncmp(name.begin, "../", 3) == 0){
- PSTRING tmp_name;
- int GoalHash;
- if(*(name.begin) == '/'){
- tmp_name.begin = name.begin+1; // skip '/'
- tmp_name.endnext = name.endnext;
- GoalHash = 0;
- }else{
- tmp_name.begin = name.begin;
- tmp_name.endnext = name.endnext;
- GoalHash = curScopeLevel(&state->param->var_scope_stack);
- while(strncmp(tmp_name.begin, "../", 3) == 0){
- tmp_name.begin = tmp_name.begin + 3; // skip '../'
- GoalHash --;
- }
- }
- valptr = state->param->getAbstractValFuncPtr(getScope(&state->param->var_scope_stack, GoalHash)->param_HV, tmp_name);
- return valptr;
- }
- }
- /* end Shigeki Morimoto path_like_variable_scope extension */
-
- currentScope = getCurrentScope(&state->param->var_scope_stack);
- valptr= state->param->getAbstractValFuncPtr(currentScope->param_HV, name);
- if ((0==state->param->global_vars) || (valptr)) return valptr;
- PrevHash=curScopeLevel(&state->param->var_scope_stack)-1;
- while (PrevHash>=0) {
- valptr=state->param->getAbstractValFuncPtr(getScope(&state->param->var_scope_stack, PrevHash)->param_HV,name);
- if (valptr!=NULL) return valptr;
- PrevHash--;
- }
- return NULL;
-}
-
-PSTRING get_variable_value (struct tmplpro_state *state, PSTRING name) {
+PSTRING get_variable_value (struct tmplpro_param *param, PSTRING name) {
PSTRING varvalue ={NULL, NULL};
- if (state->param->loop_context_vars) {
- varvalue=get_loop_context_vars_value(state, name);
+ if (param->loop_context_vars) {
+ varvalue=get_loop_context_vars_value(param, name);
}
if (varvalue.begin==NULL) {
- varvalue=(state->param->abstractVal2pstringFuncPtr)(walk_through_nested_loops(state, name));
+ varvalue=(param->abstractVal2pstringFuncPtr)(walk_through_nested_loops(param, name));
}
return varvalue;
}
@@ -337,7 +297,7 @@
if (state->is_expr) {
varvalue=parse_expr(name, state);
} else
- varvalue=get_variable_value(state, name);
+ varvalue=get_variable_value(state->param, name);
if (debuglevel>=TMPL_LOG_DEBUG) {
if (varvalue.begin!=NULL) {
tmpl_log(state,TMPL_LOG_DEBUG,"variable value = %.*s\n",(int)(varvalue.endnext-varvalue.begin),varvalue.begin);
@@ -402,7 +362,7 @@
ifval=is_pstring_true(parse_expr(name, state));
} else
if (state->param->loop_context_vars) {
- PSTRING loop_var=get_loop_context_vars_value(state, name);
+ PSTRING loop_var=get_loop_context_vars_value(state->param, name);
if (loop_var.begin!=NULL) {
ifval=is_pstring_true(loop_var);
}
@@ -410,9 +370,9 @@
if (ifval==-1) {
userSuppliedIsTrueFunc = state->param->isAbstractValTrueFuncPtr;
if (userSuppliedIsTrueFunc!=NULL) {
- ifval=(userSuppliedIsTrueFunc)(walk_through_nested_loops(state, name));
+ ifval=(userSuppliedIsTrueFunc)(walk_through_nested_loops(state->param, name));
} else {
- ifval=is_pstring_true((state->param->abstractVal2pstringFuncPtr)(walk_through_nested_loops(state, name)));
+ ifval=is_pstring_true((state->param->abstractVal2pstringFuncPtr)(walk_through_nested_loops(state->param, name)));
}
}
return ifval;
@@ -584,7 +544,7 @@
#ifdef DEBUG
tmpl_log(state,TMPL_LOG_DEBUG2,"tag_handler_loop:before InitLoopFuncPtr\n");
#endif
- if (state->is_visible && (*state->param->InitLoopFuncPtr)(&state->param->var_scope_stack,name) && next_loop(state)) {
+ if (state->is_visible && (*state->param->InitLoopFuncPtr)(state->param,name) && next_loop(state)) {
iftag.value=1; /* the loop is non - empty */
} else {
/* empty loop is equal to <if false> ... </if> */
@@ -1021,6 +981,5 @@
/*
* Local Variables:
* mode: c
- * coding: cp1251
* End:
*/
Modified: branches/upstream/libhtml-template-pro-perl/current/procore.h
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-template-pro-perl/current/procore.h?rev=39562&op=diff
==============================================================================
--- branches/upstream/libhtml-template-pro-perl/current/procore.h (original)
+++ branches/upstream/libhtml-template-pro-perl/current/procore.h Thu Jul 9 18:41:39 2009
@@ -48,7 +48,7 @@
typedef void (*writerfunc) (char* begin, char* endnext);
-typedef int (*init_loop_func) (struct scope_stack*, PSTRING name);
+typedef int (*init_loop_func) (struct tmplpro_param *, PSTRING name);
typedef int (*next_loop_func) (struct ProLoopState*);
typedef ABSTRACT_VALUE* (*get_ABSTRACT_VALUE_func) (ABSTRACT_MAP*, PSTRING name);
@@ -134,10 +134,7 @@
int tmplpro_exec_tmpl_in_memory (PSTRING memarea, struct tmplpro_param* param);
-/* private : to hide */
-struct tmplpro_state;
-
-PSTRING get_variable_value (struct tmplpro_state *state, PSTRING name);
+PSTRING get_variable_value (struct tmplpro_param *param, PSTRING name);
/*
Added: branches/upstream/libhtml-template-pro-perl/current/provalue.c
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-template-pro-perl/current/provalue.c?rev=39562&op=file
==============================================================================
--- branches/upstream/libhtml-template-pro-perl/current/provalue.c (added)
+++ branches/upstream/libhtml-template-pro-perl/current/provalue.c Thu Jul 9 18:41:39 2009
@@ -1,0 +1,54 @@
+/* -*- c -*-
+ * File: provalue.c
+ * Author: Igor Vlasenko <vlasenko at imath.kiev.ua>
+ * Created: Sun Jul 5 17:38:20 2009
+ */
+
+#include "procore.h"
+#include<string.h>
+
+ABSTRACT_VALUE* walk_through_nested_loops (struct tmplpro_param *param, PSTRING name) {
+ int PrevHash;
+ struct ProLoopState* currentScope;
+ ABSTRACT_VALUE* valptr;
+ /* Shigeki Morimoto path_like_variable_scope extension */
+ if (param->path_like_variable_scope) {
+ if(*(name.begin) == '/' || strncmp(name.begin, "../", 3) == 0){
+ PSTRING tmp_name;
+ int GoalHash;
+ if(*(name.begin) == '/'){
+ tmp_name.begin = name.begin+1; // skip '/'
+ tmp_name.endnext = name.endnext;
+ GoalHash = 0;
+ }else{
+ tmp_name.begin = name.begin;
+ tmp_name.endnext = name.endnext;
+ GoalHash = curScopeLevel(¶m->var_scope_stack);
+ while(strncmp(tmp_name.begin, "../", 3) == 0){
+ tmp_name.begin = tmp_name.begin + 3; // skip '../'
+ GoalHash --;
+ }
+ }
+ valptr = param->getAbstractValFuncPtr(getScope(¶m->var_scope_stack, GoalHash)->param_HV, tmp_name);
+ return valptr;
+ }
+ }
+ /* end Shigeki Morimoto path_like_variable_scope extension */
+
+ currentScope = getCurrentScope(¶m->var_scope_stack);
+ valptr= param->getAbstractValFuncPtr(currentScope->param_HV, name);
+ if ((0==param->global_vars) || (valptr)) return valptr;
+ PrevHash=curScopeLevel(¶m->var_scope_stack)-1;
+ while (PrevHash>=0) {
+ valptr=param->getAbstractValFuncPtr(getScope(¶m->var_scope_stack, PrevHash)->param_HV,name);
+ if (valptr!=NULL) return valptr;
+ PrevHash--;
+ }
+ return NULL;
+}
+
+/*
+ * Local Variables:
+ * mode: c
+ * End:
+ */
Added: branches/upstream/libhtml-template-pro-perl/current/provalue.h
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-template-pro-perl/current/provalue.h?rev=39562&op=file
==============================================================================
--- branches/upstream/libhtml-template-pro-perl/current/provalue.h (added)
+++ branches/upstream/libhtml-template-pro-perl/current/provalue.h Thu Jul 9 18:41:39 2009
@@ -1,0 +1,13 @@
+#ifndef _PROVALUE_H
+#define _PROVALUE_H 1
+
+ABSTRACT_VALUE* walk_through_nested_loops (struct tmplpro_param *param, PSTRING name);
+
+
+#endif /* provalue.h */
+
+/*
+ * Local Variables:
+ * mode: c
+ * End:
+ */
Added: branches/upstream/libhtml-template-pro-perl/current/t/05path_like_variable_scope.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-template-pro-perl/current/t/05path_like_variable_scope.t?rev=39562&op=file
==============================================================================
--- branches/upstream/libhtml-template-pro-perl/current/t/05path_like_variable_scope.t (added)
+++ branches/upstream/libhtml-template-pro-perl/current/t/05path_like_variable_scope.t Thu Jul 9 18:41:39 2009
@@ -1,0 +1,59 @@
+use strict;
+use warnings;
+use Test::More qw(no_plan);
+use lib qw(../blib);
+use HTML::Template::Pro;
+
+my $template_text=<<"END;";
+<TMPL_LOOP NAME=class>
+ <TMPL_LOOP NAME=person>
+ <TMPL_VAR NAME="../teacher_name"> <!-- access to class.teacher_name -->
+ <TMPL_VAR NAME="name">
+ <TMPL_VAR NAME="age">
+ <TMPL_VAR NAME="/top_level_value"> <!-- access to top level value -->
+ <TMPL_VAR EXPR="{/top_level_value} * 5"> <!-- need {} to use path_like_variable in EXPR -->
+ </TMPL_LOOP>
+</TMPL_LOOP>
+END;
+
+my $template = HTML::Template->new(
+ path_like_variable_scope => 1,
+ scalarref => \$template_text,
+);
+$template->param(top_level_value => "3",
+ class => [
+ {
+ teacher_name => "Adam",
+ person => [
+ {
+ name => "Jon",
+ age => "20",
+ },
+ {
+ name => "Bob",
+ age => "21",
+ },
+ ],
+ },
+ {
+ }
+]);
+is($template->output, <<"END;");
+
+
+ Adam <!-- access to class.teacher_name -->
+ Jon
+ 20
+ 3 <!-- access to top level value -->
+ 15 <!-- need {} to use path_like_variable in EXPR -->
+
+ Adam <!-- access to class.teacher_name -->
+ Bob
+ 21
+ 3 <!-- access to top level value -->
+ 15 <!-- need {} to use path_like_variable in EXPR -->
+
+
+
+
+END;
Modified: branches/upstream/libhtml-template-pro-perl/current/t/HTML-Template-Pro.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-template-pro-perl/current/t/HTML-Template-Pro.t?rev=39562&op=diff
==============================================================================
--- branches/upstream/libhtml-template-pro-perl/current/t/HTML-Template-Pro.t (original)
+++ branches/upstream/libhtml-template-pro-perl/current/t/HTML-Template-Pro.t Thu Jul 9 18:41:39 2009
@@ -6,7 +6,7 @@
# change 'tests => 1' to 'tests => last_test_to_print';
use Test;
-BEGIN {plan tests => 1+2*(18+4+1) };
+BEGIN {plan tests => 1+2*(19+4+1) };
use File::Spec;
#use HTML::Template;
use HTML::Template::Pro;
@@ -31,6 +31,8 @@
{LOOPVAR1=>'LOOP3-VAR1',LOOPVAR2=>'LOOP3-VAR2',LOOPVAR3=>'LOOP3-VAR3',LOOPVAR10=>'LOOP3-VAR10'},
{LOOPVAR1=>'LOOP4-VAR1',LOOPVAR2=>'LOOP4-VAR2',LOOPVAR3=>'LOOP4-VAR3',LOOPVAR10=>'LOOP4-VAR10'},
]);
+my @outer=({TEST=>'1'},{TEST=>'2'},{TEST=>'3'});
+my @inner=({TST=>'A'},{TST=>'B'});
if ($ENV{HTMLTEMPLATEPROBROKEN}) {
# manual test
@@ -59,6 +61,7 @@
test_tmpl('test_loop3', @varset1, @refset1);
test_tmpl('test_loop4', @varset1, @refset1);
test_tmpl('test_loop5', @varset1, @refset1);
+test_tmpl_options('test_loop6',[loop_context_vars=>1,debug=>1,global_vars=>1,die_on_bad_params=>0], INNER=>\@inner, OUTER=>\@outer);
# todo: use config.h and grep defines from here
# if IMITATE==1 (-DCOMPAT_ALLOW_NAME_IN_CLOSING_TAG)
@@ -82,16 +85,27 @@
# -------------------------
-sub test_tmpl {
+
+sub test_tmpl_options {
my $file=shift;
+ my $optref=shift;
my $tmpl;
print "\n--------------- Test: $file ---------------------\n";
chdir 'templates-Pro';
# $tmpl=HTML::Template->new(filename=>$file.'.tmpl', die_on_bad_params=>0, strict=>0);
- $tmpl=HTML::Template::Pro->new(filename=>$file.'.tmpl', loop_context_vars=>1, case_sensitive=>0,debug=>$DEBUG);
+ $tmpl=HTML::Template::Pro->new(filename=>$file.'.tmpl', @$optref,debug=>$DEBUG);
$tmpl->param(@_);
&dryrun($tmpl,$file);
chdir '..';
+}
+
+sub test_tmpl {
+ my ($file, at args)=@_;
+ &test_tmpl_options($file, [
+ loop_context_vars=>1,
+ case_sensitive=>0,
+ debug=>$DEBUG
+ ], at args);
}
sub dryrun {
Added: branches/upstream/libhtml-template-pro-perl/current/templates-Pro/test_loop6.out
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-template-pro-perl/current/templates-Pro/test_loop6.out?rev=39562&op=file
==============================================================================
--- branches/upstream/libhtml-template-pro-perl/current/templates-Pro/test_loop6.out (added)
+++ branches/upstream/libhtml-template-pro-perl/current/templates-Pro/test_loop6.out Thu Jul 9 18:41:39 2009
@@ -1,0 +1,33 @@
+<H1> test_loop6: global vars inside a loop </H1>
+
+Inside a Loop
+
+1
+
+A
+
+B
+
+
+2
+
+A
+
+B
+
+
+3
+
+A
+
+B
+
+
+Outide a Loop
+
+A
+
+B
+
+
+<H1> end test_loop6 </H1>
Added: branches/upstream/libhtml-template-pro-perl/current/templates-Pro/test_loop6.tmpl
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libhtml-template-pro-perl/current/templates-Pro/test_loop6.tmpl?rev=39562&op=file
==============================================================================
--- branches/upstream/libhtml-template-pro-perl/current/templates-Pro/test_loop6.tmpl (added)
+++ branches/upstream/libhtml-template-pro-perl/current/templates-Pro/test_loop6.tmpl Thu Jul 9 18:41:39 2009
@@ -1,0 +1,15 @@
+<H1> test_loop6: global vars inside a loop </H1>
+
+Inside a Loop
+<TMPL_LOOP NAME="OUTER">
+<TMPL_VAR NAME="TEST">
+<TMPL_LOOP NAME="INNER">
+<TMPL_VAR NAME="TST">
+</TMPL_LOOP>
+</TMPL_LOOP>
+Outide a Loop
+<TMPL_LOOP NAME="INNER">
+<TMPL_VAR NAME="TST">
+</TMPL_LOOP>
+
+<H1> end test_loop6 </H1>
More information about the Pkg-perl-cvs-commits
mailing list