summaryrefslogtreecommitdiffstats
path: root/install-win32/macro.pl
blob: 6e7afdc3cc1caf992da73590f3c906d878c6b76b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Simple macro processor.

# Macros are defined in a control file that follows
# NSIS format such as version.nsi.  Stdin is then
# copied to stdout, and any occurrence of @@MACRO@@ is
# substituted.

die "usage: macro.pl <control-file>" if (@ARGV < 1);
($control_file) = @ARGV;

open(CONTROL, "< $control_file") or die "cannot open $control_file";

%Parms = ();

while (<CONTROL>) {
  chomp;
  if (/^!define\s+(\w+)\s+['"]?(.+?)['"]?\s*$/) {
    $Parms{$1} = $2
  }
}

while (<STDIN>) {
  s{
    @@
    \s*
    (
      \w+
    )
    \s*
    @@
  }{
    $Parms{$1}
   }xge;
  print;
}