[project @ 2005-01-12 22:40:22 by unknown_lamer]
authorunknown_lamer <unknown>
Wed, 12 Jan 2005 22:40:22 +0000 (22:40 +0000)
committerunknown_lamer <unknown>
Wed, 12 Jan 2005 22:40:22 +0000 (22:40 +0000)
Fixed a segfault in BotConfig (call watchers was in the wrong place),
fixed trim of last non-space char from a string in Utils::trim_str

ChangeLog
TODO
source/BotConfig.C
source/Utils.C

index 42c2c04..8ebca58 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2005-01-12  Clinton Ebadi  <clinton@unknownlamer.org>
 
+       * source/BotConfig.C (set_option_value): Put watcher calling
+       inside of if (cf_iter != end()) to fix a segfault (if the cf_iter
+       = end then there are no watchers since this is a new value and
+       references cf_iter->second segfaults)
+
+       * source/Utils.C (trim_str): Fixed bug (last non-space character
+       was being cut off)
+
        * source/BotConfig.C (read_config): Made to use set_option_value
        instead of manipulating options_db directly
 
diff --git a/TODO b/TODO
index 02e2735..1d1f205 100644 (file)
--- a/TODO
+++ b/TODO
@@ -4,7 +4,7 @@ Done:
 * Abstract DCC support so that DCC FILE may be easily implemented
 
 2.2:
-* Utils::isValidNickName should have a configurable max nick length
+* Utils::valid_nickname_p should have a configurable max nick length
    (now that most networks allow for longer than nine character
    nicks). This is dependant upon the new configuration system
 * Finish adding commands to Scheme for sending messages
@@ -12,7 +12,7 @@ Done:
 * Add util functions for doing stuff like quoting CTCP messages
 * Finish adding hooks/send hooks
 * Write Texinfo manual
-* Configuration Database
+* More Generic Configuration Database
 * Improve the help system
 * DCC FILE support (sending and recieving)
 * XDCC file server script (requires DCC FILE support)
@@ -40,29 +40,21 @@ Scripting:
 
 Networking:
 * Add a networked interface to guile repl
-   - This can be done as a script, but requires non-coop threads
-     support to be done easily
+   - This can (should) be done as a script, but requires non-coop threads
+     support to be done easily (and thus requires Guile 1.8)
    - Admins only
    - Telnet
    - Store authorized users and passwords in bot.telnet file
    - Bot master can add new telnet users
    - MUST HAVE PASSWORD
-   - Maybe use SSL?
 
 Definitely 3.0:
 * Remove gh_* when Guile 1.8 is released
 * Make it possible to use Scheme functions in the Parser itself
 * Replace large select-loop in Bot::waitForInput with multithreaded
-   CC++ sockets (this will require locking around everything Guile
-   related). UPDATE[2002-11-02]: Guile CVS now has coop threads built
-   on top of pthreads, which I could probably use when 1.8 nears
-   release.
-   UPDATE[2002-12-22]: Guile CVS now has support for full pthreads, no
-   more coop stuff. After 1.8 is released threads will probably be
-   used.
    - To clarify: There will be one thread for DCCs and another thread
-   for the current irc server connection, each with its own select
-   loop. There may also be a thread for the network repls if I
-   implement those.
+      for the current irc server connection, each with its own select
+      loop. There may also be a thread for the network repls if I
+      implement those.
 * New config values in config db should be added before old values
    (this is faster but breaks the way server lists work in 2.x)
\ No newline at end of file
index 2fe386c..e8ebc08 100644 (file)
@@ -61,6 +61,13 @@ BotConfig::read_config ()
       StringTokenizer params (Utils::trim_str (st.next_token('=')));
 
       set_option_value (command, params.rest (), true);
+      std::cerr << "done.\n";
+
+      for (t_options_db::const_iterator cit = options_db.begin (); 
+          cit != options_db.end ();
+          ++cit)
+       std::cerr << "options_db[" << command << "] = " << options_db[command].first.front ()
+                 << std::endl;
     
     }
   return true;
@@ -113,8 +120,7 @@ namespace
     
     run_fun_ (std::string k, BotConfig::t_value_list& vl, bool a)
       : key (k), vals (vl), appended (a) 
-    {}
-
+    { }
     void operator() (BotConfig::t_watcher w)
     {
       w (key, vals, appended);
@@ -126,8 +132,9 @@ void
 BotConfig::set_option_value (std::string key, t_value_list values, 
                                  bool append)
 {
-  t_options_db::iterator cf_iter = options_db.find (key);
   key = Utils::to_upper (key); // keys are case insensitive
+  t_options_db::iterator cf_iter = options_db.find (key);
+  
 
   if (cf_iter != options_db.end ())
     {
@@ -139,14 +146,14 @@ BotConfig::set_option_value (std::string key, t_value_list values,
        }
       else
        cf_iter->second.first = values;
+
+      // call watchers
+      std::for_each (cf_iter->second.second.begin (),
+                    cf_iter->second.second.end (),
+                    run_fun_ (key, values, append));
     }
   else
     options_db[key] = t_option_values (values, t_watcher_list ());
-
-  // Call Watchers
-  std::for_each (cf_iter->second.second.begin (),
-                cf_iter->second.second.end (),
-                run_fun_ (key, values, append));
 }
 
 void
index 7cc0fa1..67a316d 100644 (file)
@@ -289,7 +289,7 @@ Utils::to_upper (std::string s)
 std::string
 Utils::trim_str (std::string s)
 {
-  int i = 0, j = s.length () - 1;
+  int i = 0, j = s.length ();
 
   while (i < j && std::isspace (s[i]))
     i++;