#!/usr/bin/perl

use strict;

  open(FILE, "<$ARGV[0]");
  my $file = join("", <FILE>);
  close(FILE);
  # strip comments
  $file =~ s:/\*.*?\*/: :gs;
  $file =~ s/\/\/[^\n]+//gs;

  # single-linify multiple lines
  $file =~ s/\\ ?\n//gs;

  # convert hex to decimal since perl will treat
  # hex as a string if we read it like C would
  $file =~ s/0x([a-f0-9]+)/hex($1)/egi;

  # make the code look a little more pretty
  $file =~ s/\n{2,}/\n/g;

  # do some conversions for lame systems
  # that don't support some characters
  $file =~ s'\?\?\('['g;
  $file =~ s'\?\?\)']'g;
  $file =~ s'\?\?<'{'g;
  $file =~ s'\?\?>'}'g;
  $file =~ s'\?\?='#'g;
  $file =~ s'\?\?/'\\'g;
  $file =~ s'\?\?\''^'g;
  $file =~ s'\?\?!'|'g;
  $file =~ s'\?\?-'~'g;
  $file =~ s'<%'{'g;
  $file =~ s'%>'}'g;
  $file =~ s'<%'{'g;
  $file =~ s'<:'['g;   
  $file =~ s':>']'g;
  $file =~ s'%:'#'g;
  $file =~ s'%:%:'##'g;
  $file =~ s/(^|\n)\s*/$1/gs;
  $file =~ s/(^|\n)#\s*/$1#/gs;

foreach my $line (split(/\n/, $file)) {
  if ($line =~ /^#define\s*

print "$file\n";
