diff src/cjr_print.sml @ 432:5de838fb0950

Avoid using libpq when unneeded
author Adam Chlipala <adamc@hcoop.net>
date Sun, 26 Oct 2008 08:41:17 -0400
parents 7009b0ac1501
children 659c17441250
line wrap: on
line diff
--- a/src/cjr_print.sml	Sat Oct 25 18:58:45 2008 -0400
+++ b/src/cjr_print.sml	Sun Oct 26 08:41:17 2008 -0400
@@ -1341,6 +1341,7 @@
                             string "}",
                             newline]
 
+      | DPreparedStatements [] => box []
       | DPreparedStatements ss =>
         box [string "static void uw_db_prepare(uw_context ctx) {",
              newline,
@@ -2182,6 +2183,8 @@
                                 end) sequences,
 
                  string "}"]
+
+        val hasDb = List.exists (fn (DDatabase _, _) => true | _ => false) ds
     in
         box [string "#include <stdio.h>",
              newline,
@@ -2191,8 +2194,11 @@
              newline,
              string "#include <math.h>",
              newline,
-             string "#include <postgresql/libpq-fe.h>",
-             newline,
+             if hasDb then
+                 box [string "#include <postgresql/libpq-fe.h>",
+                      newline]
+             else
+                 box [],
              newline,
              string "#include \"",
              string (OS.Path.joinDirFile {dir = Config.includ,
@@ -2222,7 +2228,10 @@
              string "}",
              newline,
              newline,
-             validate,
+             if hasDb then
+                 validate
+             else
+                 box [],
              newline,
              if List.exists (fn (DDatabase _, _) => true | _ => false) ds then
                  box []