richter 2004/03/14 10:54:44
Modified: . Changes.pod MANIFEST Old.xs epdom.c epdom.h
epparse.c eppriv.h test.pl
Embperl Syntax.pm
Embperl/Syntax EmbperlBlocks.pm
test/cmp epobless2.htm epobless3.htm sub2.htm
Added: test/cmp subout.htm
test/html subout.htm
Log:
fixed problem with print OUT and sub call at start of sub
Revision Changes Path
1.237 +4 -1 embperl/Changes.pod
Index: Changes.pod
===================================================================
RCS file: /home/cvs/embperl/Changes.pod,v
retrieving revision 1.236
retrieving revision 1.237
diff -u -r1.236 -r1.237
--- Changes.pod 11 Mar 2004 22:31:12 -0000 1.236
+++ Changes.pod 14 Mar 2004 18:54:43 -0000 1.237
@@ -27,7 +27,10 @@
- Added sanity checks to epcrypto.c
- Added posibility to pass fdat&ffld parameter to
Embperl::Object::Execute.
-
+ - Fixed problem with print OUT and call of subroutines as first statement
+ of a subroutine. Reported by various people.
+
+
=head1 2.0b10 23. Jan 2004
- Added -break parameter for haveing precondition to
1.92 +2 -0 embperl/MANIFEST
Index: MANIFEST
===================================================================
RCS file: /home/cvs/embperl/MANIFEST,v
retrieving revision 1.91
retrieving revision 1.92
diff -u -r1.91 -r1.92
--- MANIFEST 8 Mar 2004 15:41:42 -0000 1.91
+++ MANIFEST 14 Mar 2004 18:54:43 -0000 1.92
@@ -346,6 +346,7 @@
test/cmp/ssiep.htm
test/cmp/stdout.htm
test/cmp/sub.htm
+test/cmp/subout.htm
test/cmp/subreq.htm
test/cmp/subtab.htm
test/cmp/subtextarea.htm
@@ -541,6 +542,7 @@
test/html/subexec.htm
test/html/subimp.htm
test/html/subimp.pm
+test/html/subout.htm
test/html/subreq.htm
test/html/subtab.htm
test/html/subtextarea.htm
1.7 +16 -2 embperl/Old.xs
Index: Old.xs
===================================================================
RCS file: /home/cvs/embperl/Old.xs,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Old.xs 7 Feb 2004 13:07:00 -0000 1.6
+++ Old.xs 14 Mar 2004 18:54:43 -0000 1.7
@@ -92,13 +92,27 @@
tReq * r = CurrReq ;
CODE:
{
- char * p = SvPV (sText, l) ;
+ tNode xChild ;
+ char * p = SvPV (sText, l) ;
/*
if (0) //Node_self(DomTree_self (r -> Component.xCurrDomTree), r ->
Component.xCurrNode) -> nType == ntypDocumentFraq)
Node_appendChild (r->pApp, DomTree_self (r -> Component.xCurrDomTree),
r -> Component.xCurrNode, r -> Component.nCurrRepeatLevel, ntypCDATA, 0, p, l, 0, 0,
NULL) ;
else
*/
- r -> Component.xCurrNode = Node_insertAfter_CDATA (r->pApp, p, l, (r ->
Component.nCurrEscMode & 3)== 3?1 + (r -> Component.nCurrEscMode & 4):r ->
Component.nCurrEscMode, DomTree_self (r -> Component.xCurrDomTree), r ->
Component.xCurrNode, r -> Component.nCurrRepeatLevel) ;
+ /*
+ if ((xChild = Node_firstChild(r->pApp,DomTree_self (r ->
Component.xCurrDomTree),
+ r -> Component.xCurrNode,r ->
Component.nCurrRepeatLevel)) &&
+ Node_self(DomTree_self (r -> Component.xCurrDomTree), r ->
Component.xCurrNode) -> nType != ntypDocumentFraq)
+ {
+ Node_insertBefore_CDATA (r->pApp, p, l, (r -> Component.nCurrEscMode &
3)== 3?1 + (r -> Component.nCurrEscMode & 4):r -> Component.nCurrEscMode,
+ DomTree_self (r -> Component.xCurrDomTree),
+ xChild, r -> Component.nCurrRepeatLevel) ;
+ }
+ else
+ */
+ {
+ r -> Component.xCurrNode = Node_insertAfter_CDATA (r->pApp, p, l, (r ->
Component.nCurrEscMode & 3)== 3?1 + (r -> Component.nCurrEscMode & 4):r ->
Component.nCurrEscMode, DomTree_self (r -> Component.xCurrDomTree), r ->
Component.xCurrNode, r -> Component.nCurrRepeatLevel) ;
+ }
r -> Component.bEscModeSet = 0 ;
}
1.16 +60 -1 embperl/epdom.c
Index: epdom.c
===================================================================
RCS file: /home/cvs/embperl/epdom.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- epdom.c 2 Feb 2004 19:29:57 -0000 1.15
+++ epdom.c 14 Mar 2004 18:54:43 -0000 1.16
@@ -2806,6 +2806,65 @@
/* */
/* ------------------------------------------------------------------------ */
+
+tNode Node_insertBefore_CDATA (/*in*/ tApp * a,
+ /*in*/ const char * sText,
+ /*in*/ int nTextLen,
+ /*in*/ int nEscMode,
+ /*in*/ tDomTree * pRefNodeDomTree,
+ /*in*/ tNode xRefNode,
+ /*in*/ tRepeatLevel nRefRepeatLevel)
+
+ {
+ tNodeData * pRefNode = Node_selfLevel (a, pRefNodeDomTree, xRefNode,
nRefRepeatLevel) ;
+ tNodeData * pPrevNode = Node_selfPreviousSibling (a, pRefNodeDomTree,
pRefNode, nRefRepeatLevel) ;
+
+
+ tNodeData * pNew = Node_newAndAppend (a, pRefNodeDomTree, pRefNode -> xParent,
nRefRepeatLevel, NULL, pRefNode -> nLinenumber, sizeof (tNodeData)) ;
+
+ pNew -> xChilds = 0 ;
+ pNew -> bFlags = 0 ;
+
+ if (nEscMode != -1)
+ {
+ pNew -> nType = (nEscMode & 8)?ntypText:((nEscMode &
3)?ntypTextHTML:ntypCDATA) ;
+ pNew -> bFlags &= ~(nflgEscXML + nflgEscUrl + nflgEscChar) ;
+ pNew -> bFlags |= (nEscMode ^ nflgEscChar) & (nflgEscXML + nflgEscUrl +
nflgEscChar) ;
+ }
+ else
+ pNew -> nType = ntypCDATA ;
+
+ pNew -> nText = String2Ndx (a, sText, nTextLen) ;
+
+
+ pRefNode = Node_selfCondCloneNode (a, pRefNodeDomTree, pRefNode,
nRefRepeatLevel) ;
+ if (pPrevNode)
+ pPrevNode = Node_selfCondCloneNode (a, pRefNodeDomTree, pPrevNode,
nRefRepeatLevel) ;
+ else
+ {
+ tNodeData * pParent ;
+
+ if ((pParent = Node_selfLevel (a, pRefNodeDomTree, pRefNode -> xParent,
nRefRepeatLevel)) == NULL ||
+ pParent -> xChilds != pRefNode -> xPrev)
+ pPrevNode = Node_selfLevel (a, pRefNodeDomTree, pRefNode -> xPrev,
nRefRepeatLevel) ; /* first one */
+ else
+ pPrevNode = NULL ;
+ }
+
+ if (pPrevNode)
+ {
+ pPrevNode -> xNext = pNew -> xNdx ;
+ pNew -> xPrev = pPrevNode -> xNdx ;
+ }
+ else
+ pNew -> xPrev = pRefNode -> xPrev ;
+ pRefNode -> xPrev = pNew -> xNdx ;
+ pNew -> xNext = pRefNode -> xNdx ;
+
+ return pNew -> xNdx ;
+ }
+
+
/* ------------------------------------------------------------------------ */
/* */
/* Node_insertAfter */
1.9 +8 -1 embperl/epdom.h
Index: epdom.h
===================================================================
RCS file: /home/cvs/embperl/epdom.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- epdom.h 23 Jan 2004 06:50:55 -0000 1.8
+++ epdom.h 14 Mar 2004 18:54:43 -0000 1.9
@@ -522,6 +522,13 @@
/*in*/ tNode xChild,
/*in*/ tRepeatLevel nRepeatLevel) ;
+tNode Node_insertBefore_CDATA (/*in*/ struct tApp * a,
+ /*in*/ const char * sText,
+ /*in*/ int nTextLen,
+ /*in*/ int nEscMode,
+ /*in*/ tDomTree * pRefNodeDomTree,
+ /*in*/ tNode xRefNode,
+ /*in*/ tRepeatLevel nRefRepeatLevel) ;
tNode Node_insertAfter (/*in*/ struct tApp * a,
/*in*/ tDomTree * pNewNodeDomTree,
1.11 +14 -2 embperl/epparse.c
Index: epparse.c
===================================================================
RCS file: /home/cvs/embperl/epparse.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- epparse.c 23 Jan 2004 06:50:55 -0000 1.10
+++ epparse.c 14 Mar 2004 18:54:43 -0000 1.11
@@ -333,6 +333,7 @@
p -> bMatchAll = GetHashValueInt (aTHX_ pHash, "matchall", 0) ;
p -> bDontEat = GetHashValueInt (aTHX_ pHash, "donteat", 0) ;
p -> bExitInside= GetHashValueInt (aTHX_ pHash, "exitinside", 0) ;
+ p -> bAddFirstChild = GetHashValueInt (aTHX_ pHash, "addfirstchild", 0) ;
p -> pStartTag = (struct tToken *)GetHashValueStrDup (aTHX_ r -> pThread
-> pMainPool, pHash, "starttag", NULL) ;
p -> pEndTag = (struct tToken *)GetHashValueStrDup (aTHX_ r -> pThread
-> pMainPool, pHash, "endtag", NULL) ;
p -> sParseTimePerlCode = GetHashValueStrDup (aTHX_ r -> pThread ->
pMainPool, pHash, "parsetimeperlcode", NULL) ;
@@ -373,7 +374,7 @@
}
if (r -> Component.Config.bDebug & dbgBuildToken)
- lprintf (r -> pApp, "[%d]TOKEN: %*c%s ... %s unesc=%d
nodetype=%d, cdatatype=%d, nodename=%s contains='%s'\n", r -> pThread -> nPid,
nLevel*2, ' ', p -> sText, p -> sEndText, p -> bUnescape, p -> nNodeType, p ->
nCDataType, p -> sNodeName?p -> sNodeName:"<null>", sC?sC:"") ;
+ lprintf (r -> pApp, "[%d]TOKEN: %*c%s ... %s unesc=%d
nodetype=%d, cdatatype=%d, nodename=%s contains='%s' addfirstchild=%d\n", r -> pThread
-> nPid, nLevel*2, ' ', p -> sText, p -> sEndText, p -> bUnescape, p -> nNodeType, p
-> nCDataType, p -> sNodeName?p -> sNodeName:"<null>", sC?sC:"", p -> bAddFirstChild)
;
if (p -> sNodeName)
{
@@ -819,6 +820,17 @@
Node_self (pDomTree, xNewNode) -> bFlags |= pToken ->
bAddFlags ;
if (!pToken -> pInside)
bInsideMustExist = 0 ;
+
+ if (pToken -> bAddFirstChild)
+ {
+ if (!(Node_appendChild (r -> pApp, pDomTree, xNewNode,
0, nCDataType,
+ 0,
+ "", 0,
+ 0, 0, NULL)))
+ {
+ return rc ;
+ }
+ }
}
else
{
1.9 +2 -1 embperl/eppriv.h
Index: eppriv.h
===================================================================
RCS file: /home/cvs/embperl/eppriv.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- eppriv.h 23 Jan 2004 06:50:55 -0000 1.8
+++ eppriv.h 14 Mar 2004 18:54:43 -0000 1.9
@@ -113,6 +113,7 @@
int bMatchAll ; /* match any start text */
int bDontEat ; /* don't eat the characters when
parsing this token (look ahead) */
int bExitInside ;/* when this tag is found exit the
inside table */
+ int bAddFirstChild;/* already add an empty CDATA node
child */
struct tTokenTable * pFollowedBy;/* table of tokens that can follow this one
*/
struct tTokenTable * pInside ; /* table of tokens that can apear
inside this one */
struct tToken * pStartTag ; /* token that contains definition for
the start of the current token */
1.138 +4 -1 embperl/test.pl
Index: test.pl
===================================================================
RCS file: /home/cvs/embperl/test.pl,v
retrieving revision 1.137
retrieving revision 1.138
diff -u -r1.137 -r1.138
--- test.pl 8 Mar 2004 15:41:43 -0000 1.137
+++ test.pl 14 Mar 2004 18:54:43 -0000 1.138
@@ -345,6 +345,9 @@
'sub2.htm' => {
'repeat' => 2,
},
+ 'subout.htm' => {
+ 'repeat' => 2,
+ },
'subouttab.htm' => {
'repeat' => 2,
},
1.4 +23 -1 embperl/Embperl/Syntax.pm
Index: Syntax.pm
===================================================================
RCS file: /home/cvs/embperl/Embperl/Syntax.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Syntax.pm 23 Jan 2004 06:50:56 -0000 1.3
+++ Syntax.pm 14 Mar 2004 18:54:43 -0000 1.4
@@ -905,6 +905,28 @@
This is mainly for defining subs, or using modules etc.
+=item addflags
+
+=item cdatatype
+
+=item forcetype
+
+=item insidemustexist
+
+=item matchall
+
+=item exitinside
+
+=item addfirstchild
+
+=item starttag
+
+=item endtag
+
+=item parsetimeperlcode
+
+=item contains
+
=back
1.5 +9 -4 embperl/Embperl/Syntax/EmbperlBlocks.pm
Index: EmbperlBlocks.pm
===================================================================
RCS file: /home/cvs/embperl/Embperl/Syntax/EmbperlBlocks.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- EmbperlBlocks.pm 23 Jan 2004 06:50:57 -0000 1.4
+++ EmbperlBlocks.pm 14 Mar 2004 18:54:44 -0000 1.5
@@ -154,12 +154,12 @@
sub AddMetaStartEnd
{
- my ($self, $cmdname, $endname, $procinfostart) = @_ ;
+ my ($self, $cmdname, $endname, $procinfostart, $taginfostart) = @_ ;
my $tag ;
my $pinfo ;
- $tag = $self -> AddMetaCmd ($cmdname, $procinfostart, {'nodetype' =>
&ntypStartTag}) ;
+ $tag = $self -> AddMetaCmd ($cmdname, $procinfostart, {'nodetype' =>
&ntypStartTag, (ref($taginfostart) eq 'HASH'?%$taginfostart:())}) ;
$tag = $self -> AddMetaCmd ($endname, undef, {'nodetype' => &ntypEndTag,
'starttag' => $cmdname}) ;
@@ -380,6 +380,12 @@
switchcodetype => 2,
callreturn => 1,
},
+ {
+ addfirstchild => 1,
+ },
+ ) ;
+
+=pod
{
perlcode => '}; sub %^subname% { my @_ep_save ;
Embperl::Cmd::SubStart($_ep_DomTree,%$q%,[EMAIL PROTECTED]); my $_ep_ret =
_ep_sub_%^subname% (@_); Embperl::Cmd::SubEnd($_ep_DomTree,[EMAIL PROTECTED]); return
$_ep_ret } ; $_ep_exports{%^"subname%} = \&%^subname% ; ',
removenode => 10,
@@ -388,7 +394,6 @@
switchcodetype => 1,
callreturn => 1,
}) ;
-=pod
$self -> AddMetaStartEnd ('sub', 'endsub',
{
perlcode => 'sub _ep_sub_%&<noname>% { ',
1.4 +12 -4 embperl/test/cmp/epobless2.htm
Index: epobless2.htm
===================================================================
RCS file: /home/cvs/embperl/test/cmp/epobless2.htm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- epobless2.htm 15 Nov 2002 06:17:41 -0000 1.3
+++ epobless2.htm 14 Mar 2004 18:54:44 -0000 1.4
@@ -9,18 +9,26 @@
txt2: txt2 from base dir <br>
-eposub1: <h1>eposub1</h1>
+eposub1:
+
+<h1>eposub1</h1>
<br>
-eposub2: <h1>eposub2</h1>
+eposub2:
+
+<h1>eposub2</h1>
<br>
-eposub1: <h1>eposub1</h1>
+eposub1:
+
+<h1>eposub1</h1>
+
+<br>eposub2:
-<br>eposub2: <h1>eposub2</h1>
+<h1>eposub2</h1>
<br> <hr> Footer <hr>
1.3 +12 -4 embperl/test/cmp/epobless3.htm
Index: epobless3.htm
===================================================================
RCS file: /home/cvs/embperl/test/cmp/epobless3.htm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- epobless3.htm 15 Nov 2002 06:17:41 -0000 1.2
+++ epobless3.htm 14 Mar 2004 18:54:44 -0000 1.3
@@ -5,13 +5,21 @@
<body>
<h1>another head from sub</h1>
-eposub1: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa <h1>eposub1</h1>
+eposub1: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
-<br>eposub1: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa <h1>eposub1</h1>
+<h1>eposub1</h1>
-<br>eposub2: bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb <h1>eposub2</h1>
+<br>eposub1: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
-<br>eposub2: bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb <h1>eposub2</h1>
+<h1>eposub1</h1>
+
+<br>eposub2: bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+
+<h1>eposub2</h1>
+
+<br>eposub2: bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+
+<h1>eposub2</h1>
<br> <hr> Footer <hr>
1.2 +10 -0 embperl/test/cmp/sub2.htm
Index: sub2.htm
===================================================================
RCS file: /home/cvs/embperl/test/cmp/sub2.htm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- sub2.htm 22 Jan 2004 20:40:14 -0000 1.1
+++ sub2.htm 14 Mar 2004 18:54:44 -0000 1.2
@@ -61,6 +61,16 @@
*txt*
*txt2* after txt1
----> txt3
+
+
+*txt2*
+*txt2* <h2>Here goes some normal html text <h2>
+*txt2*
+
+*txt*
+*txt* <h2>Here goes some normal html text <h2>
+*txt*
+*txt2* after txt1
*txt3* after txt3
========================================================
1.1 embperl/test/cmp/subout.htm
Index: subout.htm
===================================================================
<html>
<head>
<title>Tests for Embperl - Embperl sub Metacommand 2</title>
</head>
<body>
<h1>Tests for Embperl - Embperl sub Metacommand output</h1>
*1
*txt*
*txt* <h2>h2<h2>
*txt*
*2
*txt2*
*txt2* <h2>Here goes some normal html text <h2>
*txt2*
*txt*
*txt* <h2>h2<h2>
*txt*
*txt2* after txt1
*3
*txt*
*txt* <h2>h2<h2>
*txt*
*txt2*
*txt2* <h2>Here goes some normal html text <h2>
*txt2*
*txt*
*txt* <h2>h2<h2>
*txt*
*txt2* after txt1
*1+2
*txt*
*txt* <h2>h2<h2>
*txt*
*txt2*
*txt2* <h2>Here goes some normal html text <h2>
*txt2*
*txt*
*txt* <h2>h2<h2>
*txt*
*txt2* after txt1
*txt*
*txt* <h2>h2<h2>
*txt*
*txt2*
*txt2* <h2>Here goes some normal html text <h2>
*txt2*
*txt*
*txt* <h2>h2<h2>
*txt*
*txt2* after txt1
----> txt3
*txt2*
*txt2* <h2>Here goes some normal html text <h2>
*txt2*
*txt*
*txt* <h2>h2<h2>
*txt*
*txt2* after txt1
*txt3* after txt3
*4
*txt*
*txt* <h2>h2<h2>
*txt*
*5
sub 5
*6
sub 6
*7
sub 5
sub 7
*8
sub 6
sub 8
1.1 embperl/test/html/subout.htm
Index: subout.htm
===================================================================
<html>
<head>
<title>Tests for Embperl - Embperl sub Metacommand 2</title>
</head>
<body>
[###### sub 1 #####]
[$sub txt1$]
*txt*
*txt* <h2>[+ "h2" +]<h2>
*txt*
[$endsub$]
[###### sub 2 #####]
[$sub txt2$]
*txt2*
*txt2* <h2>Here goes some normal html text <h2>
*txt2*
[- txt1 -]
*txt2* after txt1
[$endsub$]
[###### sub 3 #####]
[$sub txt3$]
[- txt2 -]
*txt3* after txt3
[$endsub$]
[###### sub 4 #####]
[$sub txt4$]
[- txt1 -]
[$endsub$]
[###### sub 5 #####]
[$sub txt5$]
[+ "sub 5" +]
[$endsub$]
[###### sub 6 #####]
[$sub txt6$]
[- print OUT "sub 6\n" -]
[$endsub$]
[###### sub 7 #####]
[$sub txt7$]
[- txt5 -]
[+ "sub 7" +]
[$endsub$]
[###### sub 8 #####]
[$sub txt8$]
[- txt6 -]
[- print OUT "sub 8\n" -]
[$endsub$]
<h1>Tests for Embperl - Embperl sub Metacommand output</h1>
*1
[- txt1 -]
*2
[- txt2 -]
*3
[- txt1 -]
[- txt2 -]
*1+2
[- txt1 ; txt2 -]
[- txt1 ; txt2 -]
----> txt3
[- txt3 -]
*4
[- txt4 -]
*5
[- txt5 -]
*6
[- txt6 -]
*7
[- txt7 -]
*8
[- txt8 -]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]