Commits

Anonymous committed 35413eb

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

  • Participants
  • Parent commits b8c7b79

Comments (0)

Files changed (3)

File include/irc_string.h

  */
 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
 

File src/irc_string.c

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

File src/s_conf.c

 	}
 }
 
+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