From 456cb7c4b92e46a77ddf0bdd6e0703146eba74f3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jonas=20Walld=C3=A9n?= <jonasw@roxen.com>
Date: Tue, 14 Jan 2020 10:18:36 +0100
Subject: [PATCH] Let client code detect support for new Search.Utils.Logger
 constructor, and simplify whitespace generation.

---
 lib/modules/Search.pmod/Utils.pmod | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/lib/modules/Search.pmod/Utils.pmod b/lib/modules/Search.pmod/Utils.pmod
index b5412407c0..62ca6a5d4b 100644
--- a/lib/modules/Search.pmod/Utils.pmod
+++ b/lib/modules/Search.pmod/Utils.pmod
@@ -672,7 +672,7 @@ class Logger {
   private int last_log_purge_time;
   private constant log_purge_freq = 8*60*60; // Purge log every 8 h or so.
 
-  private string indentation = "                    ";
+  private string indentation = " " * 20;
 
   private Sql.Sql get_db() {
     Sql.Sql db;
@@ -689,14 +689,18 @@ class Logger {
     return db;
   }
 
+  //  Detection constant for code that instantiate this class to avoid
+  //  compilation errors.
+  constant supports_flexible_indentation = 1;
+
   //! @decl void create(Sql.Sql db_object, int profile, int stderr_logging)
   //! @decl void create(string db_url, int profile, int stderr_logging)
-  void create(string|Sql.Sql _logdb, int _profile, int _stderr_logging, void|int indentation_width) {
+  void create(string|Sql.Sql _logdb, int _profile, int _stderr_logging, void|int(0..) indentation_width) {
     logdb = _logdb;
     profile = _profile;
     stderr_logging = _stderr_logging;
     if (!zero_type(indentation_width)) {
-      indentation = sprintf("%"+indentation_width+"n");
+      indentation = (" " * indentation_width);
     }
 
     // create table eventlog (event int unsigned auto_increment primary key,
-- 
GitLab