From b17b09949bc42e45ea0c9188bec15b1e117bf696 Mon Sep 17 00:00:00 2001 From: Kevin Easton Date: Wed, 23 Mar 2011 11:17:23 +0000 Subject: [PATCH] Improve country() by using "static const" for lookup table (makes function 25% smaller) and const-correctness. Add .mobi TLD. git-svn-id: svn://svn.code.sf.net/p/bitchx/code/trunk@112 13b04d17-f746-0410-82c6-800466cd88b0 --- Changelog | 2 ++ include/misc.h | 2 +- source/functions.c | 1 - source/misc.c | 12 ++++++------ 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Changelog b/Changelog index 714247b..9f10c0c 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,7 @@ [Changes 1.2c01] +* Improve country() and add .mobi TLD. (caf) + * Apply fixes from darkfires removing non-standard use of arithmetic on void * values, to allow building on Irix. (caf) diff --git a/include/misc.h b/include/misc.h index aea53fa..cc3d010 100644 --- a/include/misc.h +++ b/include/misc.h @@ -118,7 +118,7 @@ ChannelList * BX_prepare_command (int *, char *, int); int timer_unban (void *, char *); void check_server_connect (int); - char *country(char *); + const char *country(char *); int do_newuser (char *, char *, char *); int char_fucknut (register unsigned char *, char, int); BanList *ban_is_on_channel(register char *, register ChannelList *); diff --git a/source/functions.c b/source/functions.c index 8dc6ef3..c597c61 100644 --- a/source/functions.c +++ b/source/functions.c @@ -5487,7 +5487,6 @@ BUILT_IN_FUNCTION(function_irclib, input) BUILT_IN_FUNCTION(function_country, input) { -extern char *country(char *); RETURN_STR(country(input)); } diff --git a/source/misc.c b/source/misc.c index 60b5696..5d2e7d7 100644 --- a/source/misc.c +++ b/source/misc.c @@ -4902,14 +4902,13 @@ void check_server_connect(int server) #endif } -char *country(char *hostname) +const char *country(char *hostname) { #ifndef BITCHX_LITE -typedef struct _domain { -char *code; -char *country; -} Domain; -Domain domain[] = { +static const struct { + const char *code; + const char *country; +} domain[] = { {"AC", "Ascension Island" }, {"AD", "Andorra" }, {"AE", "United Arab Emirates" }, @@ -5166,6 +5165,7 @@ Domain domain[] = { {"INFO", "Informational" }, {"INT", "International" }, {"MIL", "United States Military" }, + {"MOBI", "Mobile Device" }, {"MUSEUM", "Museum" }, {"NET", "Network" }, {"NAME", "Individuals" },