From: Vsevolod Stakhov Date: Tue, 15 Dec 2015 15:26:19 +0000 (+0000) Subject: Add support of '--.USE' in lua preprocessor X-Git-Tag: 1.1.0~294 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=f2fbc6350aaf45330b9eb6f4e14fc55739c21cd4;p=rspamd.git Add support of '--.USE' in lua preprocessor --- diff --git a/src/rspamadm/lua_preprocess.pl b/src/rspamadm/lua_preprocess.pl index 6384df28c..014db3a98 100644 --- a/src/rspamadm/lua_preprocess.pl +++ b/src/rspamadm/lua_preprocess.pl @@ -6,30 +6,42 @@ use strict; my ($in_dir, $out_dir) = @ARGV; my @files = <$in_dir/*.lua>; +sub quote_file { + my ($in, $out) = @_; + + while (<$in>) { + if (/^--.USE\s*"(\S+)"$/) { + open(my $inc, '<', "$in_dir/$1.lua.in") or die "missing include $1"; + quote_file($inc, $out); + } + else { + s/\"/\\"/g; + s/^(.*)$/"$1\\n"/; + print $out $_; + } + } +} + foreach my $file (@files) { - $file =~ /([^\/.]+)(.lua)$/; - my $fname = "$1$2"; - my $varname = "rspamadm_script_$1"; - my $definename = uc $varname; + if ($file =~ /([^\/.]+)(.lua)$/) { + my $fname = "$1$2"; + my $varname = "rspamadm_script_$1"; + my $definename = uc $varname; - open(IN, "< $file") or die "input missing"; - open(OUT, "> $out_dir/$fname.h") or die "output missing"; + open(my $in, '<', $file) or die "input missing"; + open(my $out, '>', "$out_dir/$fname.h") or die "output missing"; - print OUT <) { - $_ =~ s/^(.*)$/"$1\\n"/; - print OUT $_; - } - print OUT <