From b7150bb0c3f1f0142b076ae3345467c1b2102c11 Mon Sep 17 00:00:00 2001 From: acli Date: Sun, 22 Feb 2004 07:00:16 +0000 Subject: [PATCH] Ugly hack to get rid of the close tag in pathetic "foo %s"-like strings --- misc/translator/TmplTokenizer.pm | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/misc/translator/TmplTokenizer.pm b/misc/translator/TmplTokenizer.pm index 5227b0bf74..4b16df05ac 100644 --- a/misc/translator/TmplTokenizer.pm +++ b/misc/translator/TmplTokenizer.pm @@ -485,6 +485,20 @@ sub next_token { for (my $i = 0; $i < $n_trailing_spaces; $i += 1) { push @{$this->{_queue}}, pop @structure; } + # FIXME: If the last token is a close tag but there are no tags + # FIXME: before it, drop the close tag back into the queue. This + # FIXME: is an ugly hack to get rid of "foo %s" type mess. + if (@structure >= 2 + && $structure[$#structure]->type == TmplTokenType::TAG + && $structure[$#structure]->string =~ /^<\//) { + my $has_other_tags_p = 0; + for (my $i = 0; $i < $#structure; $i += 1) { + $has_other_tags_p = 1 + if $structure[$i]->type == TmplTokenType::TAG; + last if $has_other_tags_p; + } + push @{$this->{_queue}}, pop @structure unless $has_other_tags_p + } if (@structure < 2) { # Nothing to do ; -- 2.39.5