strip_tabs() is related to s_conf.c ONLY - moved it there

This commit is contained in:
Valery Yatsko 2008-04-20 09:38:26 +04:00
parent e3b33fe3e6
commit decf0486cc
3 changed files with 18 additions and 45 deletions

View file

@ -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

View file

@ -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)
{

View file

@ -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