freeside/bin masonize,1.3,1.4
ivan
ivan at pouncequick.420.am
Fri Jun 18 03:28:14 PDT 2004
Update of /home/cvs/cvsroot/freeside/bin
In directory pouncequick:/tmp/cvs-serv13145/bin
Modified Files:
masonize
Log Message:
masonize fix: avoid newline prepend fix from borking indented first <%, fixes customer search by otaker under mason, closes: Bug#830
Index: masonize
===================================================================
RCS file: /home/cvs/cvsroot/freeside/bin/masonize,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- masonize 8 Aug 2003 05:42:13 -0000 1.3
+++ masonize 18 Jun 2004 10:28:11 -0000 1.4
@@ -6,34 +6,38 @@
@file = <F>;
#print "$file ". scalar(@file). "\n";
close $file;
- system("chmod u+w $file");
- open(W,">$file") or die "can't open $file for writing: $!";
- select W; $| = 1; select STDOUT;
$newline = ''; #avoid prepending extraneous newlines
$all = join('', at file);
+ $w = '';
+
$mode = 'html';
while ( length($all) ) {
if ( $mode eq 'html' ) {
if ( $all =~ /^(.+?)(<%=?.*)$/s && $1 !~ /<%/s ) {
- print W $1;
+ $w .= $1;
$all = $2;
next;
} elsif ( $all =~ /^<%=(.*)$/s ) {
- print W '<%';
+ $w .= '<%';
$all = $1;
$mode = 'perlv';
#die;
next;
} elsif ( $all =~ /^<%(.*)$/s ) {
- print W $newline; $newline = "\n";
+ $w .= $newline; $newline = "\n";
$all = $1;
$mode = 'perlc';
+
+ #avoid newline prepend fix from borking indented first <%
+ $w =~ s/\n\s+\z/\n/;
+ $w .= "\n" if $w =~ /.+\z/;
+
next;
} elsif ( $all !~ /<%/s ) {
- print W $all;
+ $w .= $all;
last;
} else {
warn length($all); die;
@@ -43,7 +47,7 @@
} elsif ( $mode eq 'perlv' ) {
if ( $all =~ /^(.*?%>)(.*)$/s ) {
- print W $1;
+ $w .= $1;
$all=$2;
$mode = 'html';
next;
@@ -53,13 +57,13 @@
} elsif ( $mode eq 'perlc' ) {
if ( $all =~ /^([^\n]*?)%>(.*)$/s ) {
- print W "%$1\n";
+ $w .= "%$1\n";
$all=$2;
$mode='html';
next;
}
if ( $all =~ /^([^\n]*)\n(.*)$/s ) {
- print W "%$1\n";
+ $w .= "%$1\n";
$all=$2;
next;
}
@@ -68,5 +72,9 @@
}
+ system("chmod u+w $file");
+ select W; $| = 1; select STDOUT;
+ open(W,">$file") or die "can't open $file for writing: $!";
+ print W $w;
close W;
}
More information about the freeside-commits
mailing list