aboutsummaryrefslogtreecommitdiff
path: root/install-win32/nsitran.pl
blob: 49512b440e5ded30fc11f4eefe915128397eedfd (plain) (blame)
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
# This is a simple language translator.  It translates
# the NSIS format of version.nsi to either C, sh, or Javascript.

($mode) = @ARGV;

$comment = "This file was automatically generated by nsitran.pl";

print "// $comment\n" if ($mode eq "c");
print "# $comment\n" if ($mode eq "sh");
print "// $comment\n" if ($mode eq "js");

print "\n";

while (<STDIN>) {
  chomp;
  if (/^\s*$/) {
    print "\n";
  } elsif (/^[#;](.*)$/) {
    print "//$1\n" if ($mode eq "c");
    print "#$1\n" if ($mode eq "sh");
    print "//$1\n" if ($mode eq "js");
  } elsif (/^!define\s+(\w+)\s+(.+)$/) {
    print "#define $1 $2\n" if ($mode eq "c");
    print "[ -z \"\$$1\" ] && export $1=$2\n[ \"\$$1\" = \"null\" ] && unset $1\n" if ($mode eq "sh");
    print "var $1=$2;\n" if ($mode eq "js");
  }
}