diff --git a/src/cache.c b/src/cache.c index 708c99e..c72b333 100644 --- a/src/cache.c +++ b/src/cache.c @@ -74,6 +74,35 @@ init_cache(void) help_dict_user = irc_dictionary_create(strcasecmp); } +/* + * removes tabs from src, replaces with 8 spaces, and returns the length + * of the new string. if the new string would be greater than destlen, + * it is truncated to destlen - 1 + */ +static size_t +untabify(char *dest, const char *src, size_t destlen) +{ + size_t x = 0, i; + const char *s = src; + char *d = dest; + + while(*s != '\0' && x < destlen - 1) + { + if(*s == '\t') + { + for(i = 0; i < 8 && x < destlen - 1; i++, x++, d++) + *d = ' '; + s++; + } else + { + *d++ = *s++; + x++; + } + } + *d = '\0'; + return x; +} + /* cache_file() * * inputs - file to cache, files "shortname", flags to set