6 s/\t|\r|\n/ /g; # convert spacings to whitespaces
7 s/[^\/]\/\
*.*?\
*\
///g
; # remove comments (careful: hinttags look like comment!)
8 s/ {2,}/ /g; # strip whitespaces
9 s/(^|\(|\)|;|,|:|\}|\{|=|\+|\-|\*|\&|\||\<|\>|!) +/$1/g;
10 s/ +($|\(|\)|;|,|:|\}|\{|=|\+|\-|\*|\&|\||\<|\>|!)/$1/g;
11 s/\\/\\\\/g; # escape backslashes
12 s/\"/\\\"/g; # escape quotes
16 if (scalar @ARGV < 1) {
17 print "usage: js-merge-helper.pl jsfile ... \n";
21 my ($jsfile, $define, $js);
25 $jsfile = shift @ARGV;
26 my @fn = split /\//, $jsfile;
30 $define = "JS_".uc($1);
33 open(JSFILE
, $jsfile) or die "Failed to open file: $!";
34 $_ = do { local $/; <JSFILE
> };
37 $js = escape_c_string
($_);
39 print "#define $define ";
40 printf "\"%s\"\n", $js;