[interchange-cvs] interchange - heins modified 3 files

interchange-core@interchange.redhat.com interchange-core@interchange.redhat.com
Thu Feb 7 16:34:00 2002


User:      heins
Date:      2002-02-07 21:33:22 GMT
Modified:  lib/Vend Form.pm Parse.pm Parser.pm
Log:
	* Honor XML-style empty container tags.

			[set name="foo"/]

		is equivalent to

			[set name="foo"][/set]

	  If you are going to use this, you MUST name the parameters,
	  and you SHOULD quote them.

	  		[set foo /]         ---> Never works
	  		[set name=foo/]     ---> Does not work
	  		[set name=foo /]    ---> Works but not recommended
	  		[set name="foo" /]  ---> Recommended
	  		[set name="foo"/]   ---> OK

	  Benefits of this are removing a call to parse empty buffers,
	  and it should not add significant overhead.

	* Fix a couple of default setting problems in Form.pm.

Revision  Changes    Path
2.12      +7 -6      interchange/lib/Vend/Form.pm


rev 2.12, prev_rev 2.11
Index: Form.pm
===================================================================
RCS file: /anon_cvs/repository/interchange/lib/Vend/Form.pm,v
retrieving revision 2.11
retrieving revision 2.12
diff -u -r2.11 -r2.12
--- Form.pm	5 Feb 2002 08:33:08 -0000	2.11
+++ Form.pm	7 Feb 2002 21:33:21 -0000	2.12
@@ -1,6 +1,6 @@
 # Vend::Form - Generate Form widgets
 # 
-# $Id: Form.pm,v 2.11 2002/02/05 08:33:08 mheins Exp $
+# $Id: Form.pm,v 2.12 2002/02/07 21:33:21 mheins Exp $
 #
 # Copyright (C) 1996-2001 Red Hat, Inc. <interchange@redhat.com>
 #
@@ -36,7 +36,7 @@
 require Exporter;
 @ISA = qw(Exporter);
 
-$VERSION = substr(q$Revision: 2.11 $, 10);
+$VERSION = substr(q$Revision: 2.12 $, 10);
 
 @EXPORT = qw (
 	display
@@ -581,8 +581,8 @@
 		}
 	}
 	else {
-		$re_b = '(?:\0|^)';
-		$re_e = '(?:\0|$)';
+		$re_b = '^';
+		$re_e = '$';
 	}
 
 	my $limit;
@@ -622,7 +622,7 @@
 			$value =~ s/\*$// and $select = 1;
 		}
 
-		if ($default) {
+		if (defined $default) {
 			$select = '';
 		}
 
@@ -635,7 +635,7 @@
 		my $vvalue = $value;
 		$vvalue =~ s/"/&quot;/;
 		$run .= qq| value="$vvalue"|;
-		if ($default) {
+		if (length($default)) {
 			$regex	= qr/$re_b\Q$value\E$re_e/;
 			$default =~ $regex and $select = 1;
 		}
@@ -1047,6 +1047,7 @@
 		if $opt->{price};
 
 	$opt->{name} ||= $opt->{attribute};
+
 	if(defined $opt->{value}) {
 		# do nothing
 	}



2.11      +5 -5      interchange/lib/Vend/Parse.pm


rev 2.11, prev_rev 2.10
Index: Parse.pm
===================================================================
RCS file: /anon_cvs/repository/interchange/lib/Vend/Parse.pm,v
retrieving revision 2.10
retrieving revision 2.11
diff -u -r2.10 -r2.11
--- Parse.pm	5 Feb 2002 01:33:11 -0000	2.10
+++ Parse.pm	7 Feb 2002 21:33:21 -0000	2.11
@@ -1,6 +1,6 @@
 # Vend::Parse - Parse Interchange tags
 # 
-# $Id: Parse.pm,v 2.10 2002/02/05 01:33:11 mheins Exp $
+# $Id: Parse.pm,v 2.11 2002/02/07 21:33:21 mheins Exp $
 #
 # Copyright (C) 1996-2001 Red Hat, Inc. <interchange@redhat.com>
 #
@@ -35,7 +35,7 @@
 
 @ISA = qw(Exporter Vend::Parser);
 
-$VERSION = substr(q$Revision: 2.10 $, 10);
+$VERSION = substr(q$Revision: 2.11 $, 10);
 
 @EXPORT = ();
 @EXPORT_OK = qw(find_matching_end);
@@ -891,7 +891,7 @@
 
 sub start {
 	return html_start(@_) if $_[0]->{HTML};
-    my($self, $tag, $attr, $attrseq, $origtext) = @_;
+    my($self, $tag, $attr, $attrseq, $origtext, $empty_container) = @_;
 	$tag =~ tr/-/_/;   # canonical
 	$tag = lc $tag;
 	my $buf = \$self->{_buf};
@@ -1038,9 +1038,9 @@
 		# Handle embedded tags, but only if interpolate is 
 		# defined (always if using old tags)
 #::logDebug("look end for $tag, buf=" . length($$buf) );
-		$tmpbuf = find_matching_end($tag, $buf);
+		$tmpbuf = $empty_container ? '' : find_matching_end($tag, $buf);
 #::logDebug("FOUND end for $tag\nBuf " . length($$buf) . ":\n" . $$buf . "\nTmpbuf:\n$tmpbuf\n");
-		if ($attr->{interpolate}) {
+		if ($attr->{interpolate} and !$empty_container) {
 			my $p = new Vend::Parse;
 			$p->parse($tmpbuf);
 			$tmpbuf = $p->{ABORT} ? '' : $p->{OUT};



2.2       +5 -2      interchange/lib/Vend/Parser.pm


rev 2.2, prev_rev 2.1
Index: Parser.pm
===================================================================
RCS file: /anon_cvs/repository/interchange/lib/Vend/Parser.pm,v
retrieving revision 2.1
retrieving revision 2.2
diff -u -r2.1 -r2.2
--- Parser.pm	19 Oct 2001 00:32:37 -0000	2.1
+++ Parser.pm	7 Feb 2002 21:33:21 -0000	2.2
@@ -1,6 +1,6 @@
 # Vend::Parser - Interchange parser class
 #
-# $Id: Parser.pm,v 2.1 2001/10/19 00:32:37 mheins Exp $
+# $Id: Parser.pm,v 2.2 2002/02/07 21:33:21 mheins Exp $
 #
 # Copyright (C) 1997-2001 Red Hat, Inc. <interchange@redhat.com>
 #
@@ -66,7 +66,7 @@
 
 use HTML::Entities ();
 use vars qw($VERSION);
-$VERSION = substr(q$Revision: 2.1 $, 10);
+$VERSION = substr(q$Revision: 2.2 $, 10);
 
 
 sub new
@@ -244,6 +244,9 @@
 				# At the end there should be a closing "\] or >"
 				if ($$buf =~ s|^\]|| ) {
 					$self->start($tag, \%attr, \@attrseq, "$eaten]");
+				} elsif ($$buf =~ s|^/\s*]||) {
+					## Empty container tag
+					$self->start($tag, {}, [], $eaten, 1);
 				} elsif ($$buf =~ s|^([^\]\n]+\])||) {
 					$eaten .= $1;
 					$self->start($tag, {}, [], $eaten);