handle indentation in proxy driver template code more flexibly
use the indentation of the placeholder, not the replacement. this doesn't matter right now, as all placeholders are indented by one step, but that will change soon. the indent function cannot be inlined into the substitution, as for some reason ^ then matches the end of the string, not the embedded line starts (with perl v5.32). also, $1 needs to go into a temporary anyway.
This commit is contained in:
parent
ba7b634186
commit
cd6f18fd2b
|
@ -50,6 +50,7 @@ while (<$ins>) {
|
||||||
$defines{$define} = $conts;
|
$defines{$define} = $conts;
|
||||||
$define = undef;
|
$define = undef;
|
||||||
} else {
|
} else {
|
||||||
|
($_ eq "\n") or s/^\t// or die("DEFINE content is not indented: $_");
|
||||||
$conts .= $_;
|
$conts .= $_;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -122,6 +123,12 @@ sub make_format($)
|
||||||
return $_;
|
return $_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub indent($$)
|
||||||
|
{
|
||||||
|
my ($str, $indent) = @_;
|
||||||
|
return $str =~ s,^(?=.),$indent,smgr;
|
||||||
|
}
|
||||||
|
|
||||||
open(my $outh, ">".$out_source) or die("Cannot create $out_source: $!\n");
|
open(my $outh, ">".$out_source) or die("Cannot create $out_source: $!\n");
|
||||||
|
|
||||||
for (@ptypes) {
|
for (@ptypes) {
|
||||||
|
@ -161,7 +168,7 @@ for (@ptypes) {
|
||||||
$replace{$1} = $defines{$_} if (/^${cmd_name}_(.*)$/);
|
$replace{$1} = $defines{$_} if (/^${cmd_name}_(.*)$/);
|
||||||
}
|
}
|
||||||
my $text = $templates{$template};
|
my $text = $templates{$template};
|
||||||
$text =~ s/^\h*\@(\w+)\@\n/$replace{$1} \/\/ ""/smeg;
|
$text =~ s/^(\h*)\@(\w+)\@\n/indent($replace{$2} \/\/ "", $1)/smeg;
|
||||||
$text =~ s/\@(\w+)\@/$replace{$1} \/\/ ""/eg;
|
$text =~ s/\@(\w+)\@/$replace{$1} \/\/ ""/eg;
|
||||||
print $outh $text."\n";
|
print $outh $text."\n";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user