changeset 293:42ba48d54324

quotedb: Use utillib string splitting.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 26 Jan 2015 14:03:41 +0200
parents 9f90d6918626
children 2bb9bcfb104a
files quotedb.tcl
diffstat 1 files changed, 4 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/quotedb.tcl	Mon Jan 26 14:02:43 2015 +0200
+++ b/quotedb.tcl	Mon Jan 26 14:03:41 2015 +0200
@@ -13,6 +13,9 @@
 ### you wish. See "config.quotedb.example" for an example config file.
 source [file dirname [info script]]/config.quotedb
 
+### Required utillib.tcl
+source [file dirname [info script]]/utillib.tcl
+
 
 ##########################################################################
 # No need to look below this line
@@ -87,32 +90,6 @@
   return 1
 }
 
-proc qdb_split {str maxlen} {
-  set pos 0 
-  set len [string length $str]
-  set ulen 0
-  set ustr ""
-  set result {}
-  while {$pos < $len} {
-    set end [string wordend $str $pos]
-    set new [expr $end - $pos + 1]
-    if {$ulen + $new < $maxlen} {
-      append ustr [string range $str $pos $end]
-      set ulen [expr $ulen + $new]
-    } else {
-      append ustr [string range $str $pos $end]
-      lappend result $ustr
-      set ustr ""
-      set ulen 0
-    }
-    set pos [expr $end + 1]
-  }
-  if {$ustr != ""} {
-    lappend result $ustr
-  }
-  return $result
-}
-
 proc qdb_valid_user {upublic unick uchan uhand} {
   global qdb_msg_invalid_user
   if {$uhand == "" || $uhand == {}} {
@@ -334,7 +311,7 @@
   }
 
   qdb_handle eval $usql {
-    set qtmp [qdb_split "#${quoteID}: $utext ($uuser@[qdb_ctime $utime], $uvote)" 450]
+    set qtmp [utl_str_split "#${quoteID}: $utext ($uuser@[qdb_ctime $utime], $uvote)" 450]
     foreach qstr $qtmp {
       qdb_msg $upublic $unick $uchan $qstr
     }