From 8e5fc28bfcd4442ec179cf14266352c37f6c8ba8 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 18 May 2015 08:59:38 +0200 Subject: [PATCH] refactoring more of goodies.h into strings.h --- src/kernel/region.c | 2 +- src/kernel/spell.c | 2 +- src/kernel/unit.c | 2 +- src/modules/arena.c | 2 +- src/modules/museum.c | 2 +- src/util/crmessage.c | 2 +- src/util/goodies.c | 21 --------------------- src/util/goodies.h | 11 ++++------- src/util/language.c | 2 +- src/util/message.c | 2 +- src/util/nrmessage.c | 2 +- src/util/strings.c | 18 ++++++++++++++++++ src/util/strings.h | 10 +++++----- 13 files changed, 36 insertions(+), 42 deletions(-) diff --git a/src/kernel/region.c b/src/kernel/region.c index b227394a8..852a6f0cb 100644 --- a/src/kernel/region.c +++ b/src/kernel/region.c @@ -42,7 +42,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. /* util includes */ #include #include -#include +#include #include #include #include diff --git a/src/kernel/spell.c b/src/kernel/spell.c index 2e95de30c..8a23afd4a 100644 --- a/src/kernel/spell.c +++ b/src/kernel/spell.c @@ -22,7 +22,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. /* util includes */ #include -#include +#include #include #include #include diff --git a/src/kernel/unit.c b/src/kernel/unit.c index ea2bbd950..6a0e22f08 100644 --- a/src/kernel/unit.c +++ b/src/kernel/unit.c @@ -48,7 +48,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include -#include +#include #include #include #include diff --git a/src/modules/arena.c b/src/modules/arena.c index fa08d74ac..fea4743de 100644 --- a/src/modules/arena.c +++ b/src/modules/arena.c @@ -49,7 +49,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include -#include +#include #include #include #include diff --git a/src/modules/museum.c b/src/modules/museum.c index 27722f0f3..4914e11bd 100644 --- a/src/modules/museum.c +++ b/src/modules/museum.c @@ -43,7 +43,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include #include -#include +#include #include #include diff --git a/src/util/crmessage.c b/src/util/crmessage.c index 517adfd6e..942ba2610 100644 --- a/src/util/crmessage.c +++ b/src/util/crmessage.c @@ -15,7 +15,7 @@ #include "crmessage.h" #include "message.h" -#include "goodies.h" +#include "strings.h" #include "log.h" #include diff --git a/src/util/goodies.c b/src/util/goodies.c index b46f9cb7a..5c73bfd93 100644 --- a/src/util/goodies.c +++ b/src/util/goodies.c @@ -19,12 +19,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include #include "goodies.h" -#include "unicode.h" - /* libc includes */ -#include #include -#include /* Simple Integer-Liste */ @@ -53,23 +49,6 @@ int *intlist_find(int *i_p, int fi) return NULL; } -char *set_string(char **s, const char *neu) -{ - if (neu == NULL) { - free(*s); - *s = NULL; - } - else if (*s == NULL) { - *s = malloc(strlen(neu) + 1); - strcpy(*s, neu); - } - else { - *s = realloc(*s, strlen(neu) + 1); - strcpy(*s, neu); - } - return *s; -} - static int spc_email_isvalid(const char *address) { int count = 0; diff --git a/src/util/goodies.h b/src/util/goodies.h index da18b2b36..c619c4958 100644 --- a/src/util/goodies.h +++ b/src/util/goodies.h @@ -19,18 +19,15 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #ifndef GOODIES_H #define GOODIES_H -#include "strings.h" - #ifdef __cplusplus extern "C" { #endif - extern char *set_string(char **s, const char *neu); - extern int set_email(char **pemail, const char *newmail); + int set_email(char **pemail, const char *newmail); - extern int *intlist_init(void); - extern int *intlist_add(int *i_p, int i); - extern int *intlist_find(int *i_p, int i); + int *intlist_init(void); + int *intlist_add(int *i_p, int i); + int *intlist_find(int *i_p, int i); #ifdef __cplusplus } diff --git a/src/util/language.c b/src/util/language.c index 677832636..79697f95f 100644 --- a/src/util/language.c +++ b/src/util/language.c @@ -21,7 +21,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include "language_struct.h" #include "log.h" -#include "goodies.h" +#include "strings.h" #include "umlaut.h" #include diff --git a/src/util/message.c b/src/util/message.c index 302e8d57c..b082d9d98 100644 --- a/src/util/message.c +++ b/src/util/message.c @@ -14,7 +14,7 @@ #include #include "message.h" -#include "goodies.h" +#include "strings.h" #include "log.h" #include "quicklist.h" diff --git a/src/util/nrmessage.c b/src/util/nrmessage.c index 5543b87ef..640cb81e6 100644 --- a/src/util/nrmessage.c +++ b/src/util/nrmessage.c @@ -21,7 +21,7 @@ #include "message.h" #include "language.h" #include "translation.h" -#include "goodies.h" +#include "strings.h" /* libc includes */ #include diff --git a/src/util/strings.c b/src/util/strings.c index 7a3660ed5..3f3d7dc36 100644 --- a/src/util/strings.c +++ b/src/util/strings.c @@ -21,6 +21,24 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. /* libc includes */ #include #include +#include + +char *set_string(char **s, const char *neu) +{ + if (neu == NULL) { + free(*s); + *s = NULL; + } + else if (*s == NULL) { + *s = malloc(strlen(neu) + 1); + strcpy(*s, neu); + } + else { + *s = realloc(*s, strlen(neu) + 1); + strcpy(*s, neu); + } + return *s; +} unsigned int hashstring(const char *s) { diff --git a/src/util/strings.h b/src/util/strings.h index 4157fc853..7178cf179 100644 --- a/src/util/strings.h +++ b/src/util/strings.h @@ -22,11 +22,11 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. extern "C" { #endif - extern unsigned int hashstring(const char *s); - extern const char *escape_string(const char *str, char *buffer, - size_t len); - extern unsigned int jenkins_hash(unsigned int a); - extern unsigned int wang_hash(unsigned int a); + char *set_string(char **s, const char *neu); + unsigned int hashstring(const char *s); + const char *escape_string(const char *str, char *buffer, size_t len); + unsigned int jenkins_hash(unsigned int a); + unsigned int wang_hash(unsigned int a); /* benchmark for units: * JENKINS_HASH: 5.25 misses/hit (with good cache behavior)