Index: /trunk/ippTools/share/Makefile.am
===================================================================
--- /trunk/ippTools/share/Makefile.am	(revision 24387)
+++ /trunk/ippTools/share/Makefile.am	(revision 24388)
@@ -1,6 +1,5 @@
 pxadmin_create_mirror_tables.sql: pxadmin_create_tables.sql
 	-$(RM) pxadmin_create_mirror_tables.sql
-	$(SED) -n -e '/^  *$$/ d' -e 's/--.*//' -e '/./ H' -e '/;/ !b' -e 'x ; s/\n//g ; /^CREATE TABLE receive/ { b print }' -e 's/AUTO_INCREMENT//g ; s/,\{0,1\} *FOREIGN *KEY *([a-zA-Z][a-zA-Z0-9\-\_, ]*) *REFERENCES *[a-zA-Z]\{1,\}([a-zA-Z][a-zA-Z0-9\-\_, ]*)//g' -e ': print' -e 's/( */(/g ; s/ *)/)/g ; s/  */ /g ; p ; s/.*//g ; x'  pxadmin_create_tables.sql > pxadmin_create_mirror_tables.sql
-	echo '-- This comment line is here to avoid empty query error.' >> pxadmin_create_mirror_tables.sql
+	./parse_pxadmin_create_tables.pl pxadmin_create_tables.sql > pxadmin_create_mirror_tables.sql
 
 dist_pkgdata_DATA = \
Index: /trunk/ippTools/share/parse_pxadmin_create_tables.pl
===================================================================
--- /trunk/ippTools/share/parse_pxadmin_create_tables.pl	(revision 24388)
+++ /trunk/ippTools/share/parse_pxadmin_create_tables.pl	(revision 24388)
@@ -0,0 +1,34 @@
+#!/usr/bin/env perl
+
+use warnings;
+use strict;
+
+my $ctr=0;
+my $old="";
+while (<>) {
+    s/^\s+//;    #remove whitespace from front
+    s/\s*--.*\n$//;   # remove all comments
+    s/\s+/ /g; # kill the middle whitespace
+    s/\s*$//; # kill the whitespace at the end of the line
+# if ($_ !~ /;$/ ) {chomp $_};
+    s/;$/;\n/; # add back in the \n that was removed as whitespace but only for ;
+    s/,$/, /; # add space at end of , if at end of line
+    if (m/CREATE\s+TABLE\s+receive/) {$ctr = 1;}
+    if (m/;/) {$ctr = 0;}
+    if ($ctr == 0) {
+	s/AUTO_INCREMENT// ;
+  	if (/FOREIGN\s+KEY/) {
+	    if (!/, $/) {           #if FOREIGN KEY line doesn't have ,
+		$old =~ s/,\s*$//;       #remove , from previous line
+		print $old;
+		$old="";
+	    }
+	} else {
+	    print $old;
+	    $old=$_;
+	} 
+    } else { print $_; 
+	 }
+}
+print $old;
+print "-- This comment line is here to avoid empty query error.\n";
