From decf0486cc9885c10004e67cd8686ae85d60a277 Mon Sep 17 00:00:00 2001 From: Valery Yatsko Date: Sun, 20 Apr 2008 09:38:26 +0400 Subject: [PATCH] strip_tabs() is related to s_conf.c ONLY - moved it there --- include/irc_string.h | 6 ------ src/irc_string.c | 39 --------------------------------------- src/s_conf.c | 18 ++++++++++++++++++ 3 files changed, 18 insertions(+), 45 deletions(-) diff --git a/include/irc_string.h b/include/irc_string.h index 3bddd4dd..63548450 100644 --- a/include/irc_string.h +++ b/include/irc_string.h @@ -83,12 +83,6 @@ extern char *canonize(char *); */ char *strip_colour(char *string); -/* - * strip_tabs - convert tabs to spaces - * - jdc - */ -char *strip_tabs(char *dest, const unsigned char *src, size_t len); - #define EmptyString(x) ((x) == NULL || *(x) == '\0') #define CheckEmpty(x) EmptyString(x) ? "" : x diff --git a/src/irc_string.c b/src/irc_string.c index f16916bb..6d7b8ea5 100644 --- a/src/irc_string.c +++ b/src/irc_string.c @@ -29,45 +29,6 @@ #include "client.h" #include "setup.h" -#ifndef INT16SZ -#define INT16SZ 2 -#endif - -/* - * strip_tabs(dst, src, length) - * - * Copies src to dst, while converting all \t (tabs) into spaces. - * - * NOTE: jdc: I have a gut feeling there's a faster way to do this. - */ -char * -strip_tabs(char *dest, const unsigned char *src, size_t len) -{ - char *d = dest; - /* Sanity check; we don't want anything nasty... */ - s_assert(0 != dest); - s_assert(0 != src); - - if(dest == NULL || src == NULL) - return NULL; - - while(*src && (len > 0)) - { - if(*src == '\t') - { - *d++ = ' '; /* Translate the tab into a space */ - } - else - { - *d++ = *src; /* Copy src to dst */ - } - ++src; - --len; - } - *d = '\0'; /* Null terminate, thanks and goodbye */ - return dest; -} - char * strip_colour(char *string) { diff --git a/src/s_conf.c b/src/s_conf.c index eafceb43..a8ec861a 100644 --- a/src/s_conf.c +++ b/src/s_conf.c @@ -1507,6 +1507,24 @@ conf_add_d_conf(struct ConfItem *aconf) } } +static char * +strip_tabs(char *dest, const char *src, size_t len) +{ + char *d = dest; + + if(dest == NULL || src == NULL) + return NULL; + + rb_strlcpy(dest, src, len); + + while(*d) + { + if(*d == '\t') + *d = ' '; + d++; + } + return dest; +} /* * yyerror