[[project @ 2005-01-12 05:36:40 by unknown_lamer] unknown_lamer**20050112053640 String removal phase 1: added trim, toLower, toUpper, and long2str to Utils. Converted StringTokenizer to use std::string internally. Did the same to Utils. Converted both to use _'s between tokens instead of CamelCase (because we all know that CamelCase is unreadable...). BotConfig is 99% done (just have to fix read_config). Fixed a potential but extremely unlikely buffer overflow. ] { hunk ./ChangeLog 1 +2005-01-12 Clinton Ebadi + + * source/UserList.C: Made to work with new Utils/StringTokenizer names + + * source/UserCommands.C: Made to work with new + Utils/StringTokenizer names + + * source/ShitList.C: Uses Utils.H now (Utils::trim_str & friends) + +2005-01-11 Clinton Ebadi + + * source/ShitList.C: Made to work with new StringTokenizer names + + * source/ServerQueueItem.C: Made to work with new StringTokenizer names + + * source/ServerQueue.C: Made to work with new Utils names + + * source/ScriptCommands.C: Made work with new Utils names + + * source/Person.C (getNick): Made work with new Utils names + + * source/String.H: Added substr prototypes + + * source/String.C (substr): Added substr as an alias of subString + (for compat with std::string before the transition) + + * source/Parser.C: Made to work with new Utils/StringTokenizer names + + * source/DCCParser.C: Made to work with new Utils names + + * source/DCCChatConnection.C: Made to work new Utils names + + * source/Commands.C: Made to work with new Utils names + + * source/Channel.C: Made to work with new Utils names + + * source/BotInterp.C: Made to work with new Utils + + * source/Bot.C: Made to work with new Utils/StringTokenizer names + + * source/String.C (operator=): Unremoved operator=(std::string) + + * source/String.H: Unremoved operator=(std::string) + + * source/BotConfig.C (read_config): Use Utils::trim_str + + * source/String.C (trim): Fixed bug (p->s[i] == '\r', s/i/j/) + + * source/Utils.C (trim_str): Implemented + + * source/Utils.H: Added tim_str (replaces String::trim) + + * source/BotConfig.C: Made everything work with new + StringTokenizer and Utils names + + * source/Utils.H: Added to_lower + Added to_upper + + * source/StringTokenizer.C (rest): uses std::isspace instead of + checking st[pos] against ' ' and '\t' + + * source/StringTokenizer.H: Removed CamelCasing + Renamed hasMoreTokens to more_tokens_p + + * source/StringTokenizer.C: Converted to use std::string + + * source/StringTokenizer.H: Converted to use std::string + + * source/String.C: Removed operator=(std::string) + + * source/String.H: Removed operator=(std::string) + + * source/Utils.C: Added copyright + Reformatted to match GNU coding standard more closely + Converted everything to use std::string + (get_nick): Renamed from getNick + (get_userhost): Renamed from getUserHost + (get_key): Renamed from getKey + (IP_p): Renamed from isIP + (make_wildcard): Renamed from makeWildcard + (channel_p): Renamed from isChannel + (wildcard_p): Renamed from isWildcard + (valid_channel_name_p): Renamed from isValidChannelName + (valid_nickname_p): Renamed from isValidNickName + (get_level): Renamed from getLevel + (str2time): Renamed from strToTime + (str2time): Fixed potential buffer overflow (num[512] => std::string) + (level2str): Renamed from levelToStr + (prot2str): Renamed from protToStr + (bool2str): Renamed from boolToStr + (long2str): Implemented + (scm2str): Renamed from scm2String + (str2scm): Renamed from string2SCM + + * source/BotConfig.C: Reformatted to fit GNU coding style more closely + + * source/Utils.H: Added long2str (long int -> std::string) + + * source/String.H: Added 2003 copyright (the year I last modified + it in) + + * source/String.C: Added 2002 copyright (the year I last modified + it in) + + * source/Utils.H: Updated Copyright + s/String/std::string/g + Removed camel casing and is* = *_p + xToY = x2y + + * source/BotConfig.C: Updated Copyright + + * source/BotConfig.H: Updated copyright + hunk ./ChangeLog 116 + * source/BotConfig.C (set_option_value): Take care of the case + where key is not already in the db + (add_watcher): Implemented + (read_config): Removed ',' token parsing (not needed) + hunk ./NEWS 18 +- Fixed a potential (but unlikely) buffer overflow in Utils::strToTime + (if there were more than 512 digits in part of the string form of + the time the buffer would overflow) hunk ./source/Bot.C 3 -// Copyright (C) 2002,2003 Clinton Ebadi +// Copyright (C) 2002,2003,2005 Clinton Ebadi hunk ./source/Bot.C 112 - temp = temp.trim(); + temp = Utils::trim_str (temp); hunk ./source/Bot.C 114 - if (st.countTokens(' ') != 2) { + if (st.count_tokens (' ') != 2) { hunk ./source/Bot.C 119 - alias = st.nextToken().toUpper(); - command = st.nextToken().toUpper(); + alias = Utils::to_upper (st.next_token()); + command = Utils::to_upper (st.next_token()); hunk ./source/Bot.C 212 - String command = st.nextToken('=').trim().toUpper(); - String parameters = st.nextToken('=').trim(); + String command = Utils::to_upper (Utils::trim_str (st.next_token('='))); + String parameters = Utils::trim_str (st.next_token('=')); hunk ./source/Bot.C 234 - String name = st2.nextToken().toLower(); - String key = st2.nextToken(); + String name = Utils::to_lower (st2.next_token()); + String key = st2.next_token(); hunk ./source/Bot.C 239 - String name = st2.nextToken(':').toLower(); - String mode = st2.nextToken(':'); - String keep = st2.nextToken(':'); - String key = st2.nextToken(':'); + String name = Utils::to_lower (st2.next_token(':')); + String mode = st2.next_token(':'); + String keep = st2.next_token(':'); + String key = st2.next_token(':'); hunk ./source/Bot.C 274 - String name = st2.nextToken(); - int port = std::atoi(st2.nextToken()); + String name = st2.next_token(); + int port = std::atoi(st2.next_token().c_str()); hunk ./source/Bot.C 278 - st2.nextToken())); + st2.next_token())); hunk ./source/Bot.C 398 + // FIXME: uses gh_list hunk ./source/Bot.C 400 - gh_list(Utils::string2SCM(String(s)), + gh_list(Utils::str2scm (std::string (s)), hunk ./source/BotConfig.C 2 -// Copyright (C) 2004 Clinton Ebadi +// Copyright (C) 2004,2005 Clinton Ebadi hunk ./source/BotConfig.C 21 +#include "Utils.H" hunk ./source/BotConfig.C 31 -bool BotConfig::read_config () +bool +BotConfig::read_config () hunk ./source/BotConfig.C 59 + // This is broken because overwrites existing values hunk ./source/BotConfig.C 61 - std::string command = st.nextToken('=').trim().toUpper(); - StringTokenizer params (st.nextToken('=').trim()); + std::string command = Utils::to_upper (Utils::trim_str(st.next_token('='))); + StringTokenizer params (Utils::trim_str (st.next_token('='))); hunk ./source/BotConfig.C 65 - t_watcher_list ()); - while (params.hasMoreTokens (',')) - { - options_db[command].first.push_back (params.nextToken (',').trim()); - } + t_watcher_list ()); + options_db[command].first.push_back (params.rest ()); + hunk ./source/BotConfig.C 73 -BotConfig::t_option_values BotConfig::get_option_values (std::string key) +BotConfig::t_option_values +BotConfig::get_option_values (std::string key) hunk ./source/BotConfig.C 85 -std::string BotConfig::set_config_file (std::string fname) +std::string +BotConfig::set_config_file (std::string fname) hunk ./source/BotConfig.C 128 -void BotConfig::set_option_value (std::string key, t_value_list values, +void +BotConfig::set_option_value (std::string key, t_value_list values, hunk ./source/BotConfig.C 145 + else + options_db[key] = t_option_values (values, t_watcher_list ()); hunk ./source/BotConfig.C 153 + +bool +BotConfig::add_watcher (std::string key, t_watcher new_watcher) +{ + t_options_db::iterator cf_iter = options_db.find (key); + + if (cf_iter != options_db.end ()) + { + cf_iter->second.second.push_front (new_watcher); + return true; + } + else + return false; +} hunk ./source/BotConfig.H 2 -// Copyright (C) 2004 Clinton Ebadi +// Copyright (C) 2004,2005 Clinton Ebadi hunk ./source/BotConfig.H 23 + NOTE: The key is always UPPERCASE internally. Keys are converted + automagically to uppercase by the anything that + hunk ./source/BotConfig.H 51 - BotConfig (std::string); + BotConfig (std::string); // sets config_filename but DOES NOT read config! hunk ./source/BotConfig.H 53 - bool read_config (); // true if read successfully + bool read_config (); // true if read successfully. This also clears the option_db. hunk ./source/BotInterp.C 38 - logPort = scm_open_file(Utils::string2SCM(fn), - Utils::string2SCM("a")); + logPort = scm_open_file(Utils::str2scm (fn), + Utils::str2scm ("a")); hunk ./source/BotInterp.C 77 - String rx = Utils::scm2String(regex).toUpper(); + String rx = Utils::to_upper (Utils::scm2str (regex)); hunk ./source/BotInterp.C 116 - if (scm_regexp_exec((*it)->regex, Utils::string2SCM(match), + if (scm_regexp_exec((*it)->regex, Utils::str2scm (match), hunk ./source/Channel.C 3 -// Copyright (C) 2002 Clinton Ebadi +// Copyright (C) 2002,2005 Clinton Ebadi hunk ./source/Channel.C 201 - String m = st.nextToken(), n; + String m = st.next_token(), n; hunk ./source/Channel.C 278 - channelLimit = (sign == '+' ? atoi(st.nextToken()) : + channelLimit = (sign == '+' ? std::atoi(st.next_token().c_str()) : hunk ./source/Channel.C 282 - channelKey = st.nextToken(); + channelKey = st.next_token(); hunk ./source/Channel.C 293 - n = st.nextToken(); + n = st.next_token(); hunk ./source/Channel.C 327 - u = getUser(st.nextToken()); + u = getUser(st.next_token()); hunk ./source/Channel.C 332 - String m = st.nextToken(); + String m = st.next_token(); hunk ./source/Commands.C 3 -// Copyright (C) 2002 Clinton Ebadi +// Copyright (C) 2002,2005 Clinton Ebadi hunk ./source/Commands.C 85 - if (!Utils::isWildcard(who)) + if (!Utils::wildcard_p(who)) hunk ./source/Commands.C 92 - mask = Utils::makeWildcard(mask); + mask = Utils::make_wildcard(mask); hunk ./source/Commands.C 130 - if (!Utils::isWildcard(mask)) { + if (!Utils::wildcard_p(mask)) { hunk ./source/Commands.C 134 - mask = Utils::makeWildcard(mask); + mask = Utils::make_wildcard(mask); hunk ./source/Commands.C 163 - if (!Utils::isWildcard(who)) + if (!Utils::wildcard_p(who)) hunk ./source/Commands.C 171 - dest = Utils::makeWildcard(dest); + dest = Utils::make_wildcard(dest); hunk ./source/Commands.C 221 - if (!Utils::isWildcard(who)) + if (!Utils::wildcard_p(who)) hunk ./source/Commands.C 229 - dest = Utils::makeWildcard(dest); + dest = Utils::make_wildcard(dest); hunk ./source/Commands.C 264 - if (!Utils::isWildcard(who)) { + if (!Utils::wildcard_p(who)) { hunk ./source/Commands.C 268 - dest = Utils::makeWildcard(who); + dest = Utils::make_wildcard(who); hunk ./source/Commands.C 288 - if (!Utils::isWildcard(who)) { + if (!Utils::wildcard_p(who)) { hunk ./source/Commands.C 292 - dest = Utils::makeWildcard(who); + dest = Utils::make_wildcard(who); hunk ./source/Commands.C 316 - if (!Utils::isWildcard(who)) { + if (!Utils::wildcard_p(who)) { hunk ./source/Commands.C 379 - if (!Utils::isValidChannelName(channel)) + if (!Utils::valid_channel_name_p(channel)) hunk ./source/Commands.C 424 - if (Utils::isWildcard(who)) { + if (Utils::wildcard_p(who)) { hunk ./source/Commands.C 499 - if (Utils::isChannel(who)) + if (Utils::channel_p(who)) hunk ./source/Commands.C 532 - if (nick == "" || !Utils::isValidNickName(nick)) + if (nick == "" || !Utils::valid_nickname_p(nick)) hunk ./source/Commands.C 549 - if (Utils::isChannel(who)) + if (Utils::channel_p(who)) hunk ./source/Commands.C 573 - if (Utils::isWildcard(who)) + if (Utils::wildcard_p(who)) hunk ./source/Commands.C 691 - if (!Utils::isWildcard(who)) + if (!Utils::wildcard_p(who)) hunk ./source/Commands.C 699 - dest = Utils::makeWildcard(dest); + dest = Utils::make_wildcard(dest); hunk ./source/DCCChatConnection.C 3 -// Copyright (C) 2002 Clinton Ebadi +// Copyright (C) 2002,2005 Clinton Ebadi hunk ./source/DCCChatConnection.C 42 - if (Utils::getLevel (bot, from->getAddress()) < User::FRIEND) + if (Utils::get_level (bot, from->getAddress()) < User::FRIEND) hunk ./source/DCCChatConnection.C 55 - string2SCM (from->getAddress ()), + str2scm (from->getAddress ()), hunk ./source/DCCParser.C 3 -// Copyright (C) 2002 Clinton Ebadi +// Copyright (C) 2002,2005 Clinton Ebadi hunk ./source/DCCParser.C 37 - scm_list_n (Utils:: - string2SCM (from->getAddress ()), - Utils::string2SCM (line), + scm_list_n (Utils::str2scm (from->getAddress ()), + Utils::str2scm (line), hunk ./source/Parser.C 3 -// Copyright (C) 2002,2003 Clinton Ebadi +// Copyright (C) 2002,2003,2005 Clinton Ebadi hunk ./source/Parser.C 82 - string2SCM (line), + str2scm (line), hunk ./source/Parser.C 87 - String fromMask = st.nextToken ().subString (1); + String fromMask = st.next_token ().substr (1); hunk ./source/Parser.C 92 - String command = st.nextToken (); + String command = st.next_token (); hunk ./source/Parser.C 105 - String realNick = st.nextToken (); + String realNick = st.next_token (); hunk ./source/Parser.C 138 - st.nextToken (':'); + st.next_token (':'); hunk ./source/Parser.C 141 - st.nextToken ('='); + st.next_token ('='); hunk ./source/Parser.C 143 - parameters = parameters.subString (1); + parameters = parameters.substr (1); hunk ./source/Parser.C 154 - st.nextToken (); - String nuh = st.nextToken () + "!"; - String uh = st.nextToken () + "@"; - uh = uh + st.nextToken (); + st.next_token (); + String nuh = st.next_token () + "!"; + String uh = st.next_token () + "@"; + uh = uh + st.next_token (); hunk ./source/Parser.C 167 - st.nextToken (); - String channel = st.nextToken (); + st.next_token (); + String channel = st.next_token (); hunk ./source/Parser.C 179 - st.nextToken (); - String channel = st.nextToken (); + st.next_token (); + String channel = st.next_token (); hunk ./source/Parser.C 190 - st.nextToken (); - String channel = st.nextToken (); + st.next_token (); + String channel = st.next_token (); hunk ./source/Parser.C 194 - c->channelTopic = st.rest ().subString (1); + c->channelTopic = st.rest ().substr (1); hunk ./source/Parser.C 201 - st.nextToken (); - String ch = st.nextToken (); - String uh = st.nextToken () + "@"; - uh = uh + st.nextToken (); - st.nextToken (); - String n = st.nextToken (); - String m = st.nextToken (); + st.next_token (); + String ch = st.next_token (); + String uh = st.next_token () + "@"; + uh = uh + st.next_token (); + st.next_token (); + String n = st.next_token (); + String m = st.next_token (); hunk ./source/Parser.C 238 - st.nextToken (); - st.nextToken (); - Channel *c = cnx->bot->channelList->getChannel (st.nextToken ()); + st.next_token (); + st.next_token (); + Channel *c = cnx->bot->channelList->getChannel (st.next_token ()); hunk ./source/Parser.C 243 - StringTokenizer st2 (st.nextToken (':')); - while (st2.hasMoreTokens ()) + StringTokenizer st2 (st.next_token (':')); + while (st2.more_tokens_p ()) hunk ./source/Parser.C 246 - nick = st2.nextToken (); + nick = st2.next_token (); hunk ./source/Parser.C 250 - nick = nick.subString (1); + nick = nick.substr (1); hunk ./source/Parser.C 255 - nick = nick.subString (1); + nick = nick.substr (1); hunk ./source/Parser.C 265 - st.nextToken (); - String ch = st.nextToken (); + st.next_token (); + String ch = st.next_token (); hunk ./source/Parser.C 275 - st.nextToken (); - String ch = st.nextToken (); + st.next_token (); + String ch = st.next_token (); hunk ./source/Parser.C 278 - c->addBan (st.nextToken (), -1); + c->addBan (st.next_token (), -1); hunk ./source/Parser.C 285 - st.nextToken (); - String nick = st.nextToken (); + st.next_token (); + String nick = st.next_token (); hunk ./source/Parser.C 307 - cnx->bot->nickName.subString (0, + cnx->bot->nickName.substr (0, hunk ./source/Parser.C 309 - cnx->bot->nickName.subString (i + 1); + cnx->bot->nickName.substr (i + 1); hunk ./source/Parser.C 311 - cnx->bot->nickName = cnx->bot->nickName.subString (0, 4) + + cnx->bot->nickName = cnx->bot->nickName.substr (0, 4) + hunk ./source/Parser.C 323 - st.nextToken (); + st.next_token (); hunk ./source/Parser.C 325 - st.nextToken () + "."); + st.next_token () + "."); hunk ./source/Parser.C 344 - st.nextToken (':'); + st.next_token (':'); hunk ./source/Parser.C 350 - string2SCM (nick), + str2scm (nick), hunk ./source/Parser.C 352 - string2SCM + str2scm hunk ./source/Parser.C 364 - String n = st.nextToken ('!'); - String uh = st.nextToken (); + String n = st.next_token ('!'); + String uh = st.next_token (); hunk ./source/Parser.C 367 - String c = st2.nextToken (':'); + String c = st2.next_token (':'); hunk ./source/Parser.C 373 - string2SCM (n), + str2scm (n), hunk ./source/Parser.C 375 - string2SCM (c), SCM_UNDEFINED)); + str2scm (c), SCM_UNDEFINED)); hunk ./source/Parser.C 382 - c = st3.nextToken ('\007'); + c = st3.next_token ('\007'); hunk ./source/Parser.C 420 - ch->getUser (n)->userkey = Utils::getKey (); + ch->getUser (n)->userkey = Utils::get_key (); hunk ./source/Parser.C 434 - String channel = st.nextToken (); - String target = st.nextToken (); - String reason = st.rest ().subString (1); + String channel = st.next_token (); + String target = st.next_token (); + String reason = st.rest ().substr (1); hunk ./source/Parser.C 443 - string2SCM + str2scm hunk ./source/Parser.C 446 - string2SCM (from-> + str2scm (from-> hunk ./source/Parser.C 450 - string2SCM + str2scm hunk ./source/Parser.C 453 - string2SCM + str2scm hunk ./source/Parser.C 493 - String ch = st.nextToken (); + String ch = st.next_token (); hunk ./source/Parser.C 501 - string2SCM (from-> + str2scm (from-> hunk ./source/Parser.C 505 - string2SCM (ch), + str2scm (ch), hunk ./source/Parser.C 507 - string2SCM (modes), + str2scm (modes), hunk ./source/Parser.C 510 - if (Utils::isChannel (ch)) + if (Utils::channel_p (ch)) hunk ./source/Parser.C 527 - String nn = rest.subString (1); + String nn = rest.substr (1); hunk ./source/Parser.C 533 - string2SCM + str2scm hunk ./source/Parser.C 536 - string2SCM (nn), + str2scm (nn), hunk ./source/Parser.C 571 - String to = st.nextToken (); - rest = st.rest ().subString (1); + String to = st.next_token (); + rest = st.rest ().substr (1); hunk ./source/Parser.C 576 - if (Utils::isChannel (to)) + if (Utils::channel_p (to)) hunk ./source/Parser.C 580 - string2SCM (nick), + str2scm (nick), hunk ./source/Parser.C 582 - string2SCM (to), + str2scm (to), hunk ./source/Parser.C 584 - string2SCM (rest), + str2scm (rest), hunk ./source/Parser.C 589 - string2SCM (nick), + str2scm (nick), hunk ./source/Parser.C 591 - string2SCM (rest), + str2scm (rest), hunk ./source/Parser.C 597 - rest = rest.subString (1, rest.length () - 2); + rest = rest.substr (1, rest.length () - 2); hunk ./source/Parser.C 599 - String command = st2.nextToken (); + String command = st2.next_token (); hunk ./source/Parser.C 606 - string2SCM (nick), + str2scm (nick), hunk ./source/Parser.C 608 - string2SCM + str2scm hunk ./source/Parser.C 611 - string2SCM (rest), + str2scm (rest), hunk ./source/Parser.C 617 - rest = st3.nextToken (); + rest = st3.next_token (); hunk ./source/Parser.C 636 - String to = st.nextToken (); - String fromUserhost = Utils::getUserhost (from->getAddress ()); - rest = st.rest ().subString (1); + String to = st.next_token (); + String fromUserhost = Utils::get_userhost (from->getAddress ()); + rest = st.rest ().substr (1); hunk ./source/Parser.C 646 - string2SCM (nick), + str2scm (nick), hunk ./source/Parser.C 652 - if (!Utils::isChannel (to)) + if (!Utils::channel_p (to)) hunk ./source/Parser.C 674 - rest = rest.subString (1, rest.length () - 2); - if (!Utils::isChannel (to)) + rest = rest.substr (1, rest.length () - 2); + if (!Utils::channel_p (to)) hunk ./source/Parser.C 686 - rest.subString (1, 5).toUpper () != "IDENT") && + rest.substr (1, 5).toUpper () != "IDENT") && hunk ./source/Parser.C 688 - rest.subString (1, 8).toUpper () != "PASSWORD") && - !Utils::isChannel (to)) + rest.substr (1, 8).toUpper () != "PASSWORD") && + !Utils::channel_p (to)) hunk ./source/Parser.C 703 - String channel = st.nextToken (); + String channel = st.next_token (); hunk ./source/Parser.C 707 - string2SCM (n), + str2scm (n), hunk ./source/Parser.C 709 - string2SCM + str2scm hunk ./source/Parser.C 752 - string2SCM (n), + str2scm (n), hunk ./source/Parser.C 754 - string2SCM (rest), + str2scm (rest), hunk ./source/Parser.C 770 - String channel = st.nextToken (); - String newTopic = st.rest ().subString (1); + String channel = st.next_token (); + String newTopic = st.rest ().substr (1); hunk ./source/Parser.C 778 - string2SCM (from-> + str2scm (from-> hunk ./source/Parser.C 782 - string2SCM + str2scm hunk ./source/Parser.C 785 - string2SCM + str2scm hunk ./source/Parser.C 800 - String command = st.nextToken ().toUpper (); + String command = Utils::to_upper (st.next_token ()); hunk ./source/Parser.C 803 - if (st.hasMoreTokens ()) + if (st.more_tokens_p ()) hunk ./source/Parser.C 812 - string2SCM (nick), + str2scm (nick), hunk ./source/Parser.C 814 - string2SCM (to), + str2scm (to), hunk ./source/Parser.C 816 - string2SCM + str2scm hunk ./source/Parser.C 819 - string2SCM (rest), + str2scm (rest), hunk ./source/Parser.C 847 - command = st2.nextToken ().toUpper (); + command = Utils::to_upper (st2.next_token ()); hunk ./source/Parser.C 851 - st2.nextToken (); + st2.next_token (); hunk ./source/Parser.C 853 - strtoul ((const char *) st2.nextToken (), 0, 0); - int port = atoi ((const char *) st2.nextToken ()); - if (port >= 1024 && Utils::getLevel (cnx->bot, from->getAddress ())) + std::strtoul (st2.next_token ().c_str(), 0, 0); + int port = std::atoi (st2.next_token().c_str()); + if (port >= 1024 && Utils::get_level (cnx->bot, from->getAddress ())) hunk ./source/Parser.C 868 - string2SCM (from-> + str2scm (from-> hunk ./source/Parser.C 872 - string2SCM (to), + str2scm (to), hunk ./source/Parser.C 874 - string2SCM (rest), + str2scm (rest), hunk ./source/Parser.C 885 - if (Utils::isChannel (to)) + if (Utils::channel_p (to)) hunk ./source/Parser.C 890 - string2SCM (from-> + str2scm (from-> hunk ./source/Parser.C 894 - string2SCM (to), + str2scm (to), hunk ./source/Parser.C 896 - string2SCM + str2scm hunk ./source/Parser.C 903 - string2SCM (from-> + str2scm (from-> hunk ./source/Parser.C 907 - string2SCM + str2scm hunk ./source/Parser.C 914 - String command = st.nextToken ().subString (1).toUpper (); - String rest = st.rest ().trim (); + String command = Utils::to_upper (st.next_token ().substr (1)); + String rest = Utils::trim_str (st.rest ()); hunk ./source/Parser.C 932 - if (Utils::isChannel (rest)) + if (Utils::channel_p (rest)) hunk ./source/Parser.C 935 - to = st.nextToken (); + to = st.next_token (); hunk ./source/Parser.C 938 - if (!Utils::isChannel (to)) + if (!Utils::channel_p (to)) hunk ./source/Parser.C 950 - level = Utils::getLevel (cnx->bot, from->getAddress (), to); + level = Utils::get_level (cnx->bot, from->getAddress (), to); hunk ./source/Parser.C 962 - level = Utils::getLevel (cnx->bot, from->getAddress ()); + level = Utils::get_level (cnx->bot, from->getAddress ()); hunk ./source/Parser.C 1008 - string2SCM (channel), + str2scm (channel), hunk ./source/Parser.C 1019 - param = st.nextToken (); + param = st.next_token (); hunk ./source/Parser.C 1021 - scm_listify (Utils::string2SCM (param), + scm_listify (Utils::str2scm (param), hunk ./source/Person.C 3 +// Copyright (c) 2005 Clinton Ebadi hunk ./source/Person.C 39 - return Utils::getNick(address); + return Utils::get_nick (address); hunk ./source/ScriptCommands.C 3 -// Copyright (C) 2002 Clinton Ebadi +// Copyright (C) 2002,2005 Clinton Ebadi hunk ./source/ScriptCommands.C 47 - Message m = Commands::Action(Interp::bot, Utils::scm2String(channel), - Utils::scm2String(message)); + Message m = Commands::Action(Interp::bot, Utils::scm2str(channel), + Utils::scm2str(message)); hunk ./source/ScriptCommands.C 61 - String wwho = Utils::scm2String (who); - String mask = Utils::scm2String (maskChannel); + String wwho = Utils::scm2str (who); + String mask = Utils::scm2str (maskChannel); hunk ./source/ScriptCommands.C 71 - passwd = Utils::scm2String (password); + passwd = Utils::scm2str (password); hunk ./source/ScriptCommands.C 78 - eexpire = Utils::strToTime (Utils::scm2String (expire)); + eexpire = Utils::str2time (Utils::scm2str (expire)); hunk ./source/ScriptCommands.C 100 - Utils::scm2String(servername), + Utils::scm2str(servername), hunk ./source/ScriptCommands.C 113 - String mmask = Utils::scm2String (mask); - String mmaskChannel = Utils::scm2String (maskChannel); + String mmask = Utils::scm2str (mask); + String mmaskChannel = Utils::scm2str (maskChannel); hunk ./source/ScriptCommands.C 124 - expire = Utils::strToTime (Utils::scm2String (expiration)); + expire = Utils::str2time (Utils::scm2str (expiration)); hunk ./source/ScriptCommands.C 132 - rreason = Utils::scm2String (reason); + rreason = Utils::scm2str (reason); hunk ./source/ScriptCommands.C 145 - Message m = Commands::Ban(Interp::bot, Utils::scm2String(channel), - Utils::scm2String(who)); + Message m = Commands::Ban(Interp::bot, Utils::scm2str(channel), + Utils::scm2str(who)); hunk ./source/ScriptCommands.C 181 - Message m = Commands::Cycle(Interp::bot, Utils::scm2String(channel)); + Message m = Commands::Cycle(Interp::bot, Utils::scm2str(channel)); hunk ./source/ScriptCommands.C 190 - Message m = Commands::Deban(Interp::bot, Utils::scm2String(channel), - Utils::scm2String(who)); + Message m = Commands::Deban(Interp::bot, Utils::scm2str(channel), + Utils::scm2str(who)); hunk ./source/ScriptCommands.C 210 - Message m = Commands::DelUser(Interp::bot, Utils::scm2String(who), - Utils::scm2String(maskChannel)); + Message m = Commands::DelUser(Interp::bot, Utils::scm2str(who), + Utils::scm2str(maskChannel)); hunk ./source/ScriptCommands.C 220 - Message m = Commands::DelShit(Interp::bot, Utils::scm2String(who), - Utils::scm2String(maskChannel)); + Message m = Commands::DelShit(Interp::bot, Utils::scm2str(who), + Utils::scm2str(maskChannel)); hunk ./source/ScriptCommands.C 230 - Message m = Commands::Deop(Interp::bot, Utils::scm2String(channel), - Utils::scm2String(who)); + Message m = Commands::Deop(Interp::bot, Utils::scm2str(channel), + Utils::scm2str(who)); hunk ./source/ScriptCommands.C 240 - r = Utils::scm2String(reason); + r = Utils::scm2str(reason); hunk ./source/ScriptCommands.C 249 - Message m = Commands::Do(Interp::bot, Utils::scm2String(command)); + Message m = Commands::Do(Interp::bot, Utils::scm2str(command)); hunk ./source/ScriptCommands.C 258 - Message m = Commands::Invite(Interp::bot, Utils::scm2String(channel), - Utils::scm2String(who)); + Message m = Commands::Invite(Interp::bot, Utils::scm2str(channel), + Utils::scm2str(who)); hunk ./source/ScriptCommands.C 269 - k = Utils::scm2String(key); - Message m = Commands::Join(Interp::bot, Utils::scm2String(channel), + k = Utils::scm2str(key); + Message m = Commands::Join(Interp::bot, Utils::scm2str(channel), hunk ./source/ScriptCommands.C 280 - Message m = Commands::Keep(Interp::bot, Utils::scm2String(channel), - Utils::scm2String(modes)); + Message m = Commands::Keep(Interp::bot, Utils::scm2str(channel), + Utils::scm2str(modes)); hunk ./source/ScriptCommands.C 293 - r = Utils::scm2String(reason); + r = Utils::scm2str(reason); hunk ./source/ScriptCommands.C 295 - Message m = Commands::Kick(Interp::bot, Utils::scm2String(channel), - Utils::scm2String(who), r); + Message m = Commands::Kick(Interp::bot, Utils::scm2str(channel), + Utils::scm2str(who), r); hunk ./source/ScriptCommands.C 307 - r = Utils::scm2String(reason); - Message m = Commands::KickBan(Interp::bot, Utils::scm2String(channel), - Utils::scm2String(who), r); + r = Utils::scm2str(reason); + Message m = Commands::KickBan(Interp::bot, Utils::scm2str(channel), + Utils::scm2str(who), r); hunk ./source/ScriptCommands.C 317 - Message m = Commands::Lock(Interp::bot, Utils::scm2String(channel)); + Message m = Commands::Lock(Interp::bot, Utils::scm2str(channel)); hunk ./source/ScriptCommands.C 332 - Message m = Commands::Mode(Interp::bot, Utils::scm2String(channel), - Utils::scm2String(mode)); + Message m = Commands::Mode(Interp::bot, Utils::scm2str(channel), + Utils::scm2str(mode)); hunk ./source/ScriptCommands.C 342 - Message m = Commands::Msg(Interp::bot, Utils::scm2String(nick), - Utils::scm2String(message)); + Message m = Commands::Msg(Interp::bot, Utils::scm2str(nick), + Utils::scm2str(message)); hunk ./source/ScriptCommands.C 359 - Message m = Commands::Nick(Interp::bot, Utils::scm2String(nick)); + Message m = Commands::Nick(Interp::bot, Utils::scm2str(nick)); hunk ./source/ScriptCommands.C 368 - Message m = Commands::Op(Interp::bot, Utils::scm2String(channel), - Utils::scm2String(who)); + Message m = Commands::Op(Interp::bot, Utils::scm2str(channel), + Utils::scm2str(who)); hunk ./source/ScriptCommands.C 377 - Message m = Commands::Part(Interp::bot, Utils::scm2String(channel)); + Message m = Commands::Part(Interp::bot, Utils::scm2str(channel)); hunk ./source/ScriptCommands.C 393 - Message m = Commands::Say(Interp::bot, Utils::scm2String(channel), - Utils::scm2String(message)); + Message m = Commands::Say(Interp::bot, Utils::scm2str(channel), + Utils::scm2str(message)); hunk ./source/ScriptCommands.C 418 - Message m = Commands::SetVersion(Interp::bot, Utils::scm2String(version)); + Message m = Commands::SetVersion(Interp::bot, Utils::scm2str(version)); hunk ./source/ScriptCommands.C 428 - Message m = Commands::TBan(Interp::bot, Utils::scm2String(channel), - Utils::scm2String(who), gh_scm2long(seconds)); + Message m = Commands::TBan(Interp::bot, Utils::scm2str(channel), + Utils::scm2str(who), gh_scm2long(seconds)); hunk ./source/ScriptCommands.C 441 - r = Utils::scm2String(reason); - Message m = Commands::TKBan(Interp::bot, Utils::scm2String(channel), - Utils::scm2String(who), + r = Utils::scm2str(reason); + Message m = Commands::TKBan(Interp::bot, Utils::scm2str(channel), + Utils::scm2str(who), hunk ./source/ScriptCommands.C 453 - Message m = Commands::Topic(Interp::bot, Utils::scm2String(channel), - Utils::scm2String(topic)); + Message m = Commands::Topic(Interp::bot, Utils::scm2str(channel), + Utils::scm2str(topic)); hunk ./source/ScriptCommands.C 462 - Message m = Commands::Unlock(Interp::bot, Utils::scm2String(channel)); + Message m = Commands::Unlock(Interp::bot, Utils::scm2str(channel)); hunk ./source/ScriptCommands.C 469 - return Utils::string2SCM(Interp::bot->nickName); + return Utils::str2scm(Interp::bot->nickName); hunk ./source/ScriptCommands.C 479 - Utils::string2SCM(serv->getHostName()), + Utils::str2scm(serv->getHostName()), hunk ./source/ScriptCommands.C 481 - Utils::string2SCM(serv->getPassword()), + Utils::str2scm(serv->getPassword()), hunk ./source/ScriptCommands.C 497 - Utils::string2SCM(s->getHostName()), + Utils::str2scm(s->getHostName()), hunk ./source/ScriptCommands.C 499 - Utils::string2SCM(s->getPassword()), + Utils::str2scm(s->getPassword()), hunk ./source/ScriptCommands.C 541 - String commandName = Utils::scm2String(scm_commandName).toUpper(); + String commandName = Utils::to_upper (Utils::scm2str(scm_commandName)); hunk ./source/ScriptCommands.C 586 - String commandName = Utils::scm2String(scm_commandName).toUpper(); + String commandName = Utils::to_upper (Utils::scm2str(scm_commandName)); hunk ./source/ScriptCommands.C 609 - rname = Utils::scm2String (name); + rname = Utils::scm2str (name); hunk ./source/ScriptCommands.C 632 - (Utils::scm2String (to), - Utils::scm2String (message))); + (Utils::scm2str (to), + Utils::scm2str (message))); hunk ./source/ScriptCommands.C 648 - IQUEUE->sendCTCP (Utils::scm2String (to), Utils::scm2String (command), - Utils::scm2String (message)); + IQUEUE->sendCTCP (Utils::scm2str (to), Utils::scm2str (command), + Utils::scm2str (message)); hunk ./source/ServerQueue.C 3 -// Copyright (C) 2002 Clinton Ebadi +// Copyright (C) 2002,2005 Clinton Ebadi hunk ./source/ServerQueue.C 102 - string2SCM (MNICK), + str2scm (MNICK), hunk ./source/ServerQueue.C 104 - string2SCM (to), + str2scm (to), hunk ./source/ServerQueue.C 106 - string2SCM (message), + str2scm (message), hunk ./source/ServerQueue.C 114 - string2SCM (MNICK), + str2scm (MNICK), hunk ./source/ServerQueue.C 116 - string2SCM (to), + str2scm (to), hunk ./source/ServerQueue.C 118 - string2SCM + str2scm hunk ./source/ServerQueue.C 121 - string2SCM (message), + str2scm (message), hunk ./source/ServerQueue.C 224 - if (Utils::isChannel (dest)) + if (Utils::channel_p (dest)) hunk ./source/ServerQueue.C 229 - string2SCM (Interp::bot->nickName), + str2scm (Interp::bot->nickName), hunk ./source/ServerQueue.C 231 - string2SCM (dest), + str2scm (dest), hunk ./source/ServerQueue.C 233 - string2SCM + str2scm hunk ./source/ServerQueue.C 240 - string2SCM (Interp::bot->nickName), + str2scm (Interp::bot->nickName), hunk ./source/ServerQueue.C 242 - string2SCM + str2scm hunk ./source/ServerQueueItem.C 3 +// Copyright (c) 2005 Clinton Ebadi hunk ./source/ServerQueueItem.C 49 - paramcount = st.countTokens(); + paramcount = st.count_tokens(); hunk ./source/ShitList.C 3 -// Copyright (C) 2002 Clinton Ebadi +// Copyright (C) 2002,2005 Clinton Ebadi hunk ./source/ShitList.C 27 +#include "Utils.H" hunk ./source/ShitList.C 59 - String mask = st.nextToken(':'); - String channelMask = st.nextToken(':'); - String level = st.nextToken(':'); - String expiration = st.nextToken(':'); - String reason = st.rest().trim(); + String mask = st.next_token(':'); + String channelMask = st.next_token(':'); + String level = st.next_token(':'); + String expiration = st.next_token(':'); + String reason = Utils::trim_str (st.rest()); hunk ./source/String.C 3 +// Copyright (C) 2002,2005 Clinton Ebadi hunk ./source/String.C 190 +String +String::substr (int s, int e) +{ + return subString (s, e); +} + hunk ./source/String.C 202 +String +String::substr (int s) +{ + return subString (s); +} + hunk ./source/String.C 248 - while (j > 0 && (p->s[j] == ' ' || p->s[j] == '\t' || p->s[i] == '\r')) + while (j > 0 && (p->s[j] == ' ' || p->s[j] == '\t' || p->s[j] == '\r')) hunk ./source/String.H 3 -// Copyright (c) 2002 Clinton Ebadi +// Copyright (c) 2002.2003,2005 Clinton Ebadi hunk ./source/String.H 57 + + String substr(int); + String substr(int, int); hunk ./source/StringTokenizer.C 3 +// Copyright (c) 2005 Clinton Ebadi hunk ./source/StringTokenizer.C 20 +#include +#include hunk ./source/StringTokenizer.C 23 -StringTokenizer::StringTokenizer(String string) - : st(string), pos(0) +StringTokenizer::StringTokenizer(std::string s) + : st(s), pos(0) hunk ./source/StringTokenizer.C 28 -StringTokenizer::hasMoreTokens() +StringTokenizer::more_tokens_p () hunk ./source/StringTokenizer.C 41 -StringTokenizer::hasMoreTokens(char c) +StringTokenizer::more_tokens_p (char c) hunk ./source/StringTokenizer.C 54 -StringTokenizer::countTokens() +StringTokenizer::count_tokens () hunk ./source/StringTokenizer.C 57 - StringTokenizer s(st); + StringTokenizer s (st); + + while (s.more_tokens_p ()) + { + s.next_token (); + i++; + } hunk ./source/StringTokenizer.C 65 - while (s.hasMoreTokens()) { - s.nextToken(); - i++; - } - hunk ./source/StringTokenizer.C 69 -StringTokenizer::countTokens(char c) +StringTokenizer::count_tokens (char c) hunk ./source/StringTokenizer.C 74 - while (s.hasMoreTokens(c)) { - s.nextToken(c); - i++; - } - + while (s.more_tokens_p (c)) + { + s.next_token (c); + i++; + } + hunk ./source/StringTokenizer.C 83 -String -StringTokenizer::nextToken() +std::string +StringTokenizer::next_token() hunk ./source/StringTokenizer.C 92 - if (st[j] == ' ' || st[j] == '\t') { - pos = j + 1; - return st.subString(i, j - 1); - } + if (st[j] == ' ' || st[j] == '\t') + { + pos = j + 1; + return st.substr (i, j - 1); + } hunk ./source/StringTokenizer.C 99 - return st.subString(i, st.length() - 1); + return st.substr (i, st.length() - 1); hunk ./source/StringTokenizer.C 102 -String -StringTokenizer::nextToken(char c, bool empty) +std::string +StringTokenizer::next_token (char c, bool empty) hunk ./source/StringTokenizer.C 110 - if (st[j] == c) { - pos = j + 1; - return st.subString(i, j - 1); - } + if (st[j] == c) + { + pos = j + 1; + return st.substr (i, j - 1); + } hunk ./source/StringTokenizer.C 118 - + hunk ./source/StringTokenizer.C 120 - return st.subString(i, st.length() - 1); + return st.substr (i, st.length() - 1); hunk ./source/StringTokenizer.C 123 -String +std::string hunk ./source/StringTokenizer.C 129 - while (pos < st.length() && (st[pos] == ' ' || st[pos] == '\t')) + // Skip whitespace + while (pos < st.length() && (std::isspace (st[pos]))) hunk ./source/StringTokenizer.C 133 - return st.subString(pos, st.length() - 1); + return st.substr (pos, st.length() - 1); hunk ./source/StringTokenizer.H 3 +// Copyright (c) 2005 Clinton Ebadi hunk ./source/StringTokenizer.H 22 -#include "String.H" +#include hunk ./source/StringTokenizer.H 24 -class StringTokenizer { - String st; +class StringTokenizer +{ + std::string st; hunk ./source/StringTokenizer.H 29 - StringTokenizer(String); + StringTokenizer(std::string); hunk ./source/StringTokenizer.H 32 - bool hasMoreTokens(); - bool hasMoreTokens(char); + bool more_tokens_p (); + bool more_tokens_p (char); hunk ./source/StringTokenizer.H 35 - int countTokens(); - int countTokens(char); + int count_tokens(); + int count_tokens(char); hunk ./source/StringTokenizer.H 38 - String nextToken(); - String nextToken(char, bool = false); + std::string next_token(); + std::string next_token(char, bool = false); hunk ./source/StringTokenizer.H 41 - String rest(); + std::string rest(); hunk ./source/UserCommands.C 3 -// Copyright (C) 2002 Clinton Ebadi +// Copyright (C) 2002,2005 Clinton Ebadi hunk ./source/UserCommands.C 25 +#include +#include +#include hunk ./source/UserCommands.C 33 -#include hunk ./source/UserCommands.C 77 - mask = who = st.nextToken(); - maskChannel = st.nextToken(); - level = st.nextToken(); - prot = st.nextToken(); - aop = st.nextToken(); - expiration = st.nextToken(); - passwd = st.nextToken(); + mask = who = st.next_token(); + maskChannel = st.next_token(); + level = st.next_token(); + prot = st.next_token(); + aop = st.next_token(); + expiration = st.next_token(); + passwd = st.next_token(); hunk ./source/UserCommands.C 91 -// if (!Utils::isWildcard(mask)) { +// if (!Utils::wildcard_p(mask)) { hunk ./source/UserCommands.C 97 -// mask = Utils::makeWildcard(mask); +// mask = Utils::make_wildcard(mask); hunk ./source/UserCommands.C 113 - if (l > Utils::getLevel(cnx->bot, from->getAddress())) { + if (l > Utils::get_level(cnx->bot, from->getAddress())) { hunk ./source/UserCommands.C 124 - e = Utils::strToTime(expiration); + e = Utils::str2time(expiration); hunk ./source/UserCommands.C 138 - Utils::levelToStr(l) + + Utils::level2str(l) + hunk ./source/UserCommands.C 140 - Utils::protToStr(p) + + Utils::prot2str(p) + hunk ./source/UserCommands.C 142 - Utils::boolToStr(a)); + Utils::bool2str(a)); hunk ./source/UserCommands.C 160 - String serverName = st.nextToken(); + String serverName = st.next_token(); hunk ./source/UserCommands.C 163 - if (st.hasMoreTokens()) { - String temp = st.nextToken(); + if (st.more_tokens_p()) { + String temp = st.next_token(); hunk ./source/UserCommands.C 186 - mask = who = st.nextToken(); - maskChannel = st.nextToken(); - level = st.nextToken(); - expiration = st.nextToken(); - reason = st.rest().trim(); + mask = who = st.next_token(); + maskChannel = st.next_token(); + level = st.next_token(); + expiration = st.next_token(); + reason = Utils::trim_str (st.rest()); hunk ./source/UserCommands.C 204 - if (!Utils::isWildcard(mask)) { + if (!Utils::wildcard_p(mask)) { hunk ./source/UserCommands.C 210 - mask = Utils::makeWildcard(mask); + mask = Utils::make_wildcard(mask); hunk ./source/UserCommands.C 225 - e = Utils::strToTime(expiration); + e = Utils::str2time(expiration); hunk ./source/UserCommands.C 255 - String newF = st.nextToken().toUpper(); - String oldF = st.nextToken().toUpper(); + String newF = Utils::to_upper (st.next_token()); + String oldF = Utils::to_upper (st.next_token()); hunk ./source/UserCommands.C 325 -// String mask = who = st.nextToken(); -// String maskChannel = st.nextToken(); -// String level = st.nextToken(); +// String mask = who = st.next_token(); +// String maskChannel = st.next_token(); +// String level = st.next_token(); hunk ./source/UserCommands.C 334 -// if (!Utils::isWildcard(mask)) { +// if (!Utils::wildcard_p(mask)) { hunk ./source/UserCommands.C 359 -// if (l > Utils::getLevel(cnx->bot, from->getAddress())) { +// if (l > Utils::get_level(cnx->bot, from->getAddress())) { hunk ./source/UserCommands.C 364 -// if (Utils::getLevel(cnx->bot, from->getAddress()) < uli->level) { +// if (Utils::get_level(cnx->bot, from->getAddress()) < uli->level) { hunk ./source/UserCommands.C 467 - String mask = who = st.nextToken(); - String maskChannel = st.nextToken(); + String mask = who = st.next_token(); + String maskChannel = st.next_token(); hunk ./source/UserCommands.C 475 - if (!Utils::isWildcard(mask)) { + if (!Utils::wildcard_p(mask)) { hunk ./source/UserCommands.C 481 - mask = Utils::makeWildcard(mask); + mask = Utils::make_wildcard(mask); hunk ./source/UserCommands.C 503 - String mask = who = st.nextToken(); - String maskChannel = st.nextToken(); + String mask = who = st.next_token(); + String maskChannel = st.next_token(); hunk ./source/UserCommands.C 511 - if (!Utils::isWildcard(mask)) { + if (!Utils::wildcard_p(mask)) { hunk ./source/UserCommands.C 517 - mask = Utils::makeWildcard(mask); + mask = Utils::make_wildcard(mask); hunk ./source/UserCommands.C 582 - int level = Utils::getLevel(cnx->bot, from->getAddress()); + int level = Utils::get_level(cnx->bot, from->getAddress()); hunk ./source/UserCommands.C 603 - String command = st.nextToken().toUpper(); + String command = Utils::to_upper (st.next_token()); hunk ./source/UserCommands.C 693 - channel = st.nextToken(); + channel = st.next_token(); hunk ./source/UserCommands.C 695 - if (!Utils::isValidChannelName(channel)) { + if (!Utils::valid_channel_name_p(channel)) { hunk ./source/UserCommands.C 746 - String who = st.nextToken(); + String who = st.next_token(); hunk ./source/UserCommands.C 748 - if (Utils::isWildcard(who)) { + if (Utils::wildcard_p(who)) { hunk ./source/UserCommands.C 765 - if (Utils::isWildcard(who)) { + if (Utils::wildcard_p(who)) { hunk ./source/UserCommands.C 798 - Ban(cnx, 0, channel, st.nextToken()); + Ban(cnx, 0, channel, st.next_token()); hunk ./source/UserCommands.C 859 - String who = st.nextToken(); + String who = st.next_token(); hunk ./source/UserCommands.C 931 - String nick = st.nextToken(); + String nick = st.next_token(); hunk ./source/UserCommands.C 938 - if (!Utils::isValidNickName(nick)) { + if (!Utils::valid_nickname_p(nick)) { hunk ./source/UserCommands.C 962 - st.nextToken('@'); + st.next_token('@'); hunk ./source/UserCommands.C 1014 - if (Utils::isWildcard(rest)) { + if (Utils::wildcard_p(rest)) { hunk ./source/UserCommands.C 1306 - String who = st.nextToken(); - String t = st.nextToken(); + String who = st.next_token(); + String t = st.next_token(); hunk ./source/UserCommands.C 1316 - if (Utils::isWildcard(who) && from) { + if (Utils::wildcard_p(who) && from) { hunk ./source/UserCommands.C 1333 - if (!Utils::isWildcard(who)) + if (!Utils::wildcard_p(who)) hunk ./source/UserCommands.C 1346 - if ((w = Utils::strToTime(t)) == 0) { + if ((w = Utils::str2time(t)) == 0) { hunk ./source/UserCommands.C 1352 - dest = Utils::makeWildcard(dest); + dest = Utils::make_wildcard(dest); hunk ./source/UserCommands.C 1384 - String who = st.nextToken(); - String t = st.nextToken(); + String who = st.next_token(); + String t = st.next_token(); hunk ./source/UserCommands.C 1425 - from->sendNotice((*it)->mask.getMask().pad(25) + " " + - (*it)->channelMask.getMask().pad(10) + " " + - Utils::levelToStr((*it)->level).pad(12) + " " + - Utils::protToStr((*it)->prot).pad(7) + " " + - Utils::boolToStr((*it)->aop).pad(5) + " " + - String((long)(*it)->expirationDate)); - + from->sendNotice((*it)->mask.getMask().pad(25) + + " " + + (*it)->channelMask.getMask().pad(10) + + " " + + String(Utils::level2str((*it)->level)).pad(12) + + " " + + String(Utils::prot2str((*it)->prot)).pad(7) + + " " + + String(Utils::bool2str((*it)->aop)).pad(5) + + " " + + String(Utils::long2str ((*it)->expirationDate))); + hunk ./source/UserCommands.C 1459 - Utils::levelToStr(uli->level) + + Utils::level2str(uli->level) + hunk ./source/UserCommands.C 1461 - Utils::protToStr(uli->prot) + + Utils::prot2str(uli->prot) + hunk ./source/UserCommands.C 1463 - Utils::boolToStr(uli->aop) + + Utils::bool2str(uli->aop) + hunk ./source/UserCommands.C 1465 - Utils::boolToStr(!uli->isStillValid()) + + Utils::bool2str(!uli->isStillValid()) + hunk ./source/UserCommands.C 1468 - Utils::boolToStr(uli && uli->identified) + + Utils::bool2str(uli && uli->identified) + hunk ./source/UserCommands.C 1487 - String otherNick = st.nextToken(); + String otherNick = st.next_token(); hunk ./source/UserCommands.C 1505 - Utils::levelToStr(uli->level) + + Utils::level2str(uli->level) + hunk ./source/UserCommands.C 1507 - Utils::protToStr(uli->prot) + + Utils::prot2str(uli->prot) + hunk ./source/UserCommands.C 1509 - Utils::boolToStr(uli->aop) + + Utils::bool2str(uli->aop) + hunk ./source/UserCommands.C 1511 - Utils::boolToStr(!uli->isStillValid()) + + Utils::bool2str(!uli->isStillValid()) + hunk ./source/UserCommands.C 1513 - Utils::boolToStr(uli && uli->identified)); + Utils::bool2str(uli && uli->identified)); hunk ./source/UserList.C 3 -// Copyright (C) 2002 Clinton Ebadi +// Copyright (C) 2002,2005 Clinton Ebadi hunk ./source/UserList.C 24 +#include "Utils.H" hunk ./source/UserList.C 53 - if (st.countTokens(':') != 7) { + if (st.count_tokens(':') != 7) { hunk ./source/UserList.C 58 - String mask = st.nextToken(':'); - String maskChannel = st.nextToken(':'); - String level = st.nextToken(':'); - String prot = st.nextToken(':'); - String aop = st.nextToken(':'); - String expiration = st.nextToken(':'); - String password = st.rest().trim(); + String mask = st.next_token(':'); + String maskChannel = st.next_token(':'); + String level = st.next_token(':'); + String prot = st.next_token(':'); + String aop = st.next_token(':'); + String expiration = st.next_token(':'); + String password = Utils::trim_str (st.rest()); hunk ./source/Utils.C 3 +// Copyright (c) 2005 Clinton Ebadi hunk ./source/Utils.C 25 +#include +#include hunk ./source/Utils.C 31 -String -Utils::getNick(String nuh) +std::string +Utils::get_nick (std::string nuh) hunk ./source/Utils.C 35 - return st.nextToken('!'); + return st.next_token('!'); hunk ./source/Utils.C 38 -String -Utils::getUserhost(String nuh) +std::string +Utils::get_userhost (std::string nuh) hunk ./source/Utils.C 42 - st.nextToken('@'); + st.next_token('@'); hunk ./source/Utils.C 46 -String -Utils::getKey() +std::string +Utils::get_key() hunk ./source/Utils.C 49 - return String((long)rand()); + return long2str (std::rand()); hunk ./source/Utils.C 53 -Utils::isIP(String host) +Utils::IP_p (std::string host) hunk ./source/Utils.C 56 - if (!isdigit(host[i]) && host[i]!='.') + if (!std::isdigit (host[i]) && host[i] !='.') hunk ./source/Utils.C 61 -String -Utils::makeWildcard(String mask) +std::string +Utils::make_wildcard (std::string mask) hunk ./source/Utils.C 64 - StringTokenizer st(mask); + StringTokenizer st (mask); hunk ./source/Utils.C 66 - st.nextToken('!', true); - String nick = "*"; + st.next_token('!', true); + std::string nick = "*"; hunk ./source/Utils.C 69 - String user = st.nextToken('@', true); + std::string user = st.next_token('@', true); hunk ./source/Utils.C 73 - user = user.subString(1); + user = user.substr (1); hunk ./source/Utils.C 75 - user = String("*") + user; + user = std::string("*") + user; hunk ./source/Utils.C 77 - String host = st.rest(); + std::string host = st.rest(); hunk ./source/Utils.C 79 - if (!isWildcard(host)) { - if (isIP(host)) { - host = st2.nextToken('.') + "."; - host = host + st2.nextToken('.') + "."; - host = host + st2.nextToken('.') + ".*"; - } else { - st2.nextToken('.', true); - if (st2.countTokens('.') > 1) - host = String("*.") + st2.rest(); + + if (!wildcard_p (host)) + { + if (IP_p (host)) + { + host = st2.next_token('.') + "."; + host = host + st2.next_token('.') + "."; + host = host + st2.next_token('.') + ".*"; + } + else + { + st2.next_token('.', true); + if (st2.count_tokens('.') > 1) + host = std::string("*.") + st2.rest(); + } + } + else + { + if (host == "") host = "*"; hunk ./source/Utils.C 99 - } else { - if (host == "") host = "*"; - } hunk ./source/Utils.C 101 - + hunk ./source/Utils.C 106 -Utils::isChannel(String c) +Utils::channel_p(std::string c) hunk ./source/Utils.C 112 -Utils::isWildcard(String c) +Utils::wildcard_p (std::string c) hunk ./source/Utils.C 114 - return (c.find('*') != -1); + return (c.find('*') != std::string::npos); hunk ./source/Utils.C 118 -Utils::isValidChannelName(String c) +Utils::valid_channel_name_p (std::string c) hunk ./source/Utils.C 120 - return isChannel(c) && c.find(',') == -1; + return channel_p (c) && c.find(',') == std::string::npos; hunk ./source/Utils.C 123 -#define isvalid(c) (((c) >= 'A' && (c) <= '~') || isdigit(c) || (c) == '-') +#define isvalid(c) (((c) >= 'A' && (c) <= '~') || std::isdigit(c) || (c) == '-') hunk ./source/Utils.C 126 -Utils::isValidNickName(String n) +Utils::valid_nickname_p (std::string n) hunk ./source/Utils.C 128 - if (n[0] == '-' || isdigit(n[0]) || n.length() > 9) + // FIXME: make max nick length configurable + if (n[0] == '-' || std::isdigit(n[0]) || n.length() > 9) hunk ./source/Utils.C 133 - if (!isvalid(n[i]) || isspace(n[i])) + if (!isvalid(n[i]) || std::isspace (n[i])) hunk ./source/Utils.C 140 -Utils::getLevel(Bot * b, String nuh) +Utils::get_level (Bot * b, std::string nuh) hunk ./source/Utils.C 146 -Utils::getLevel(Bot * b, String nuh, String channel) +Utils::get_level (Bot * b, std::string nuh, std::string channel) hunk ./source/Utils.C 148 - if (!isChannel(channel)) - return getLevel(b, nuh); + if (!channel_p (channel)) + return get_level(b, nuh); hunk ./source/Utils.C 151 - if (Channel * c = b->channelList->getChannel(channel)) { - User * u = c->getUser(getNick(nuh)); - if (u) - return u->getLevel(); - } else { + if (Channel * c = b->channelList->getChannel(channel)) + { + User * u = c->getUser(get_nick (nuh)); + if (u) + return u->getLevel(); + } + else { hunk ./source/Utils.C 164 -String -Utils::levelToStr(int l) +std::string +Utils::level2str(int l) hunk ./source/Utils.C 167 - switch (l) { - case User::USER: return "User"; - case User::TRUSTED_USER: return "Trusted User"; - case User::FRIEND: return "Friend"; - case User::MASTER: return "Master"; - } + switch (l) + { + case User::USER: return "User"; + case User::TRUSTED_USER: return "Trusted User"; + case User::FRIEND: return "Friend"; + case User::MASTER: return "Master"; + } + hunk ./source/Utils.C 178 -String -Utils::protToStr(int p) +std::string +Utils::prot2str(int p) hunk ./source/Utils.C 181 - switch (p) { - case User::NO_BAN: return "No ban"; - case User::NO_KICK: return "No kick"; - case User::NO_DEOP: return "No deop"; - } + switch (p) + { + case User::NO_BAN: return "No ban"; + case User::NO_KICK: return "No kick"; + case User::NO_DEOP: return "No deop"; + } + hunk ./source/Utils.C 191 -String -Utils::boolToStr(bool b) +std::string +Utils::bool2str(bool b) hunk ./source/Utils.C 194 + // FIXME: should these be lowercase? hunk ./source/Utils.C 198 +std::string +Utils::long2str (long l) +{ + std::ostringstream temp; + temp << l; + + return temp.str (); +} + hunk ./source/Utils.C 208 -Utils::strToTime(String str) +Utils::str2time(std::string str) hunk ./source/Utils.C 210 - char num[512]; - int len = 0; + std::string num; hunk ./source/Utils.C 212 - - num[0]='\0'; - - if (str.toLower() == "Inf") + + // Make sure that str is nominally valid before allocating a buffer + if (to_lower (str) == "inf") hunk ./source/Utils.C 216 - - if (!isdigit(str[0])) + + if (!std::isdigit (str[0])) hunk ./source/Utils.C 220 - for (int i = 0; i < str.length(); i++) { - switch (str[i]) { - case 'y': - case 'Y': - num[len] = '\0'; - len = 0; - ans += (atoi(num) * 31557600); - break; - case 'M': - num[len] = '\0'; - len = 0; - ans += (atoi(num) * 2629800); - break; - case 'd': - case 'D': - num[len] = '\0'; - len = 0; - ans += (atoi(num) * 86400); - break; - case 'h': - case 'H': - num[len] = '\0'; - len = 0; - ans += (atoi(num) * 3600); - break; - case 'm': - num[len] = '\0'; - len = 0; - ans += (atoi(num) * 60); - break; - case 's': - case 'S': - num[len] = '\0'; - len = 0; - ans += atoi(num); - default: - if (isdigit(str[i])) { - num[len++] = str[i]; - num[len] = '\0'; - } else - return 0; + num.reserve (512); // reverse a buffer to speed things up + + for (int i = 0; i < str.length(); i++) + { + switch (str[i]) + { + case 'y': + case 'Y': + ans += (std::atoi (num.c_str ()) * 31557600); + num.clear (); + break; + case 'M': + ans += (std::atoi (num.c_str ()) * 2629800); + num.clear (); + break; + case 'd': + case 'D': + ans += (std::atoi (num.c_str ()) * 86400); + num.clear (); + break; + case 'h': + case 'H': + ans += (std::atoi (num.c_str ()) * 3600); + num.clear (); + break; + case 'm': + ans += (std::atoi (num.c_str ()) * 60); + num.clear (); + break; + case 's': + case 'S': + ans += std::atoi (num.c_str ()); + num.clear (); + default: + if (std::isdigit(str[i])) + num += str[i]; + else + return 0; + } hunk ./source/Utils.C 260 - } + + if (!num.empty ()) + ans += std::atoi (num.c_str ()); + + return std::time (0) + ans; +} + +std::string +Utils::to_lower (std::string s) +{ + std::string::iterator it; + + for (it = s.begin (); it != s.end (); ++it) + *it = std::tolower (*it); + + return s; +} + +std::string +Utils::to_upper (std::string s) +{ + std::string::iterator it; hunk ./source/Utils.C 283 - if (len) - ans += atoi(num); + for (it = s.begin (); it != s.end (); ++it) + *it = std::toupper (*it); hunk ./source/Utils.C 286 - return time(0) + ans; + return s; +} + +std::string +Utils::trim_str (std::string s) +{ + int i = 0, j = s.length () - 1; + + while (i < j && std::isspace (s[i])) + i++; + + while (j > 0 && std::isspace (s[j])) + j--; + + return s.substr (i, j); hunk ./source/Utils.C 304 -// Returns a String from an SCM argument -String -Utils::scm2String(SCM s) +// Returns a std::string from an SCM argument +std::string +Utils::scm2str (SCM s) hunk ./source/Utils.C 308 + // FIXME: uses gh_, replace with scm_ hunk ./source/Utils.C 310 - String temp(tmp); + std::string temp (tmp); + hunk ./source/Utils.C 313 + hunk ./source/Utils.C 317 -// Returns a SCM from an String argument +// Returns a SCM from an std::string argument hunk ./source/Utils.C 319 -Utils::string2SCM(String s) +Utils::str2scm (std::string s) hunk ./source/Utils.C 321 - return gh_str02scm((char *)(const char *)s); + return gh_str02scm (s.c_str ()); hunk ./source/Utils.H 3 -// Copyright (c) 2002 Clinton Ebadi +// Copyright (c) 2002,2005 Clinton Ebadi hunk ./source/Utils.H 27 -#include "String.H" +#include + hunk ./source/Utils.H 37 - static String getNick(String); - static String getUserhost(String); - static String getKey(); - static String makeWildcard(String); + static std::string get_nick (std::string); + static std::string get_userhost (std::string); + static std::string get_key(); + + static int get_level (Bot *, std::string); + static int get_level (Bot *, std::string, std::string); + + static std::string make_wildcard (std::string); + + // predicates + static bool channel_p (std::string); + static bool wildcard_p (std::string); + static bool valid_channel_name_p (std::string); + static bool valid_nickname_p (std::string); + static bool IP_p (std::string); hunk ./source/Utils.H 53 - static bool isChannel(String); - static bool isWildcard(String); - static bool isValidChannelName(String); - static bool isValidNickName(String); - static bool isIP(String); + static std::string level2str (int); + static std::string prot2str (int); + static std::string bool2str (bool); + static std::string long2str (long); hunk ./source/Utils.H 58 - static int getLevel(Bot *, String); - static int getLevel(Bot *, String, String); + static std::time_t str2time(std::string); hunk ./source/Utils.H 60 - static String levelToStr(int); - static String protToStr(int); - static String boolToStr(bool); + // string case conversion + static std::string to_lower (std::string); + static std::string to_upper (std::string); hunk ./source/Utils.H 64 - static std::time_t strToTime(String); + static std::string trim_str (std::string); hunk ./source/Utils.H 67 - static String scm2String(SCM); - static SCM string2SCM(String); + static std::string scm2str (SCM); + static SCM str2scm (std::string); }