commit 26a38ce1e8a0c3d30fd60445db1ff36a3caceff9
parent 35ed20e3d46752766ec8f286884d525ed753830d
Author: Kyle Milz <kmilz@ucalgary.ca>
Date: Wed, 19 Sep 2012 17:18:20 -0600
forgot js helper.
Diffstat:
1 file changed, 26 insertions(+), 0 deletions(-)
diff --git a/js-merge-helper.pl b/js-merge-helper.pl
@@ -0,0 +1,26 @@
+#!/bin/env perl -w
+use strict;
+
+sub escape_c_string {
+ shift;
+ s/\t|\r|\n/ /g; # convert spacings to whitespaces
+ s/[^\/]\/\*.*?\*\///g; # remove comments (careful: hinttags look like comment!)
+ s/ {2,}/ /g; # strip whitespaces
+ s/(^|\(|\)|;|,|:|\}|\{|=|\+|\-|\*|\&|\||\<|\>|!) +/$1/g;
+ s/ +($|\(|\)|;|,|:|\}|\{|=|\+|\-|\*|\&|\||\<|\>|!)/$1/g;
+ s/\\/\\\\/g; # escape backslashes
+ s/\"/\\\"/g; # escape quotes
+ return $_
+}
+
+open(JSFILE, "hinting.js") or die "Failed to open file: $!";
+$_ = do { local $/; <JSFILE> };
+close(JSFILE);
+my $js_hints = escape_c_string($_);
+
+open(HFILE, ">javascript.h") or die "Failed to open javascript.h: $!";
+print HFILE "#define JS_SETUP_HINTS ";
+printf HFILE "\"%s\"\n", $js_hints;
+close(HFILE);
+
+exit;