From 87854885736030f43ff5fc8d97eeb07c40e758e5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?=
 <grubba@grubba.org>
Date: Thu, 1 Jul 1999 22:13:41 +0200
Subject: [PATCH] Got rid of some circular references.

Rev: lib/modules/Sql.pmod/sql.pike:1.33
Rev: lib/modules/Sql.pmod/sql_util.pmod:1.1
---
 .gitattributes                     |  1 +
 lib/modules/Sql.pmod/sql.pike      | 24 ++++++++-----------
 lib/modules/Sql.pmod/sql_util.pmod | 37 ++++++++++++++++++++++++++++++
 3 files changed, 47 insertions(+), 15 deletions(-)
 create mode 100644 lib/modules/Sql.pmod/sql_util.pmod

diff --git a/.gitattributes b/.gitattributes
index 6bb4c42919..c43dc1b497 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -78,6 +78,7 @@ testfont binary
 /lib/modules/Sql.pmod/postgres.pike foreign_ident
 /lib/modules/Sql.pmod/sql.pike foreign_ident
 /lib/modules/Sql.pmod/sql_result.pike foreign_ident
+/lib/modules/Sql.pmod/sql_util.pmod foreign_ident
 /lib/modules/Stdio.pmod foreign_ident
 /lib/modules/Stdio.pmod/Readline.pike foreign_ident
 /lib/modules/Stdio.pmod/Terminfo.pmod foreign_ident
diff --git a/lib/modules/Sql.pmod/sql.pike b/lib/modules/Sql.pmod/sql.pike
index 13710a0414..a8363d02a0 100644
--- a/lib/modules/Sql.pmod/sql.pike
+++ b/lib/modules/Sql.pmod/sql.pike
@@ -1,5 +1,5 @@
 /*
- * $Id: sql.pike,v 1.32 1999/07/01 02:16:00 per Exp $
+ * $Id: sql.pike,v 1.33 1999/07/01 20:13:40 grubba Exp $
  *
  * Implements the generic parts of the SQL-interface
  *
@@ -8,7 +8,7 @@
 
 //.
 //. File:	sql.pike
-//. RCSID:	$Id: sql.pike,v 1.32 1999/07/01 02:16:00 per Exp $
+//. RCSID:	$Id: sql.pike,v 1.33 1999/07/01 20:13:40 grubba Exp $
 //. Author:	Henrik Grubbström (grubba@idonex.se)
 //.
 //. Synopsis:	Implements the generic parts of the SQL-interface.
@@ -35,11 +35,7 @@ int case_convert;
 //. - quote
 //.   Quote a string so that it can safely be put in a query.
 //. > s - String to quote.
-function(string:string) quote = lambda (string s)
-{
-  // This lambda is overridden from master_sql in create().
-  return(replace(s, "\'", "\'\'"));
-};
+function(string:string) quote = .sql_util.quote;
 
 //. - encode_time
 //.   Converts a system time value to an appropriately formatted time
@@ -258,15 +254,13 @@ void create(void|string|object host, void|string db,
       }
   }
 
-  function fallback =
-    lambda () {throw_error ("Function not supported in this database.");};
   if (master_sql->quote) quote = master_sql->quote;
-  encode_time = master_sql->encode_time || fallback;
-  decode_time = master_sql->decode_time || fallback;
-  encode_date = master_sql->encode_date || fallback;
-  decode_date = master_sql->decode_date || fallback;
-  encode_datetime = master_sql->encode_datetime || fallback;
-  decode_datetime = master_sql->decode_datetime || fallback;
+  encode_time = master_sql->encode_time || .sql_util.fallback;
+  decode_time = master_sql->decode_time || .sql_util.fallback;
+  encode_date = master_sql->encode_date || .sql_util.fallback;
+  decode_date = master_sql->decode_date || .sql_util.fallback;
+  encode_datetime = master_sql->encode_datetime || .sql_util.fallback;
+  decode_datetime = master_sql->decode_datetime || .sql_util.fallback;
 }
 
 static private array(mapping(string:mixed)) res_obj_to_array(object res_obj)
diff --git a/lib/modules/Sql.pmod/sql_util.pmod b/lib/modules/Sql.pmod/sql_util.pmod
new file mode 100644
index 0000000000..c2db2709de
--- /dev/null
+++ b/lib/modules/Sql.pmod/sql_util.pmod
@@ -0,0 +1,37 @@
+/*
+ * $Id: sql_util.pmod,v 1.1 1999/07/01 20:13:41 grubba Exp $
+ *
+ * Some SQL utility functions.
+ * They are kept here to avoid circular references.
+ *
+ * Henrik Grubbström 1999-07-01
+ */
+
+//.
+//. File:	sql_util.pmod
+//. RCSID:	$Id: sql_util.pmod,v 1.1 1999/07/01 20:13:41 grubba Exp $
+//. Author:	Henrik Grubbström (grubba@idonex.se)
+//.
+//. Synopsis:	Some SQL utility functions
+//.
+//. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+//.
+//. These functions are kept here mainly to avoid circular references.
+//.
+
+#define throw_error(X)	throw(({ (X), backtrace() }))
+
+//. - quote
+//.   Quote a string so that it can safely be put in a query.
+//. > s - String to quote.
+string quote(string s)
+{
+  return(replace(s, "\'", "\'\'"));
+}
+
+//. - fallback
+//.   Throw an error in case an unimplemented function is called.
+void fallback(void)
+{
+  throw_error ("Function not supported in this database.");
+}
-- 
GitLab