Rename db_bootstrap.sed to db_sql2c.sed
Side effect of the db schema patch, now a mere cosmetic change.
Change-Id: I47a101e3b76b2125d786f22bf100604cf5e8eb40
diff --git a/src/db_sql2c.sed b/src/db_sql2c.sed
new file mode 100644
index 0000000..1d301f8
--- /dev/null
+++ b/src/db_sql2c.sed
@@ -0,0 +1,25 @@
+# Input to this are sql/*.sql files.
+#
+# We want each SQL statement line wrapped in "...\n", and each end (";") to
+# become a comma:
+#
+# SOME SQL COMMAND (
+# that may span )
+# MULTIPLE LINES;
+# MORE;
+#
+# -->
+#
+# "SOME SQL COMMAND (\n"
+# " that may span )\n"
+# "MULTIPLE LINES\n", <--note the comma here
+# "MORE\n",
+#
+# just replacing ';' with '\n,' won't work, since sed is bad in printing
+# multiple lines. Also, how to input newlines to sed is not portable across
+# platforms.
+
+# Match excluding a trailing ';' as \1, keep any trailing ';' in \2
+s/^\(.*[^;]\)\(;\|\)$/"\1\\n"\2/
+# Replace trailing ';' as ','
+s/;$/,/