dovecot: Removed unused charset_to_utf8_string() and charset_to_...

dovecot at dovecot.org dovecot at dovecot.org
Fri Jul 20 17:39:13 EEST 2007


details:   http://hg.dovecot.org/dovecot/rev/0d3583b02a32
changeset: 6126:0d3583b02a32
user:      Timo Sirainen <tss at iki.fi>
date:      Fri Jul 20 17:01:39 2007 +0300
description:
Removed unused charset_to_utf8_string() and charset_to_ucase_utf8_string()

diffstat:

3 files changed, 133 deletions(-)
src/lib-charset/charset-iconv.c |   85 ---------------------------------------
src/lib-charset/charset-utf8.c  |   37 ----------------
src/lib-charset/charset-utf8.h  |   11 -----

diffs (159 lines):

diff -r b9c1336fd4e4 -r 0d3583b02a32 src/lib-charset/charset-iconv.c
--- a/src/lib-charset/charset-iconv.c	Fri Jul 20 17:00:01 2007 +0300
+++ b/src/lib-charset/charset-iconv.c	Fri Jul 20 17:01:39 2007 +0300
@@ -144,89 +144,4 @@ charset_to_utf8(struct charset_translati
 	}
 }
 
-static const char *
-charset_to_utf8_string_int(const char *charset, bool *unknown_charset,
-			   const unsigned char *data, size_t size,
-			   size_t *utf8_size_r, bool ucase)
-{
-	iconv_t cd;
-	ICONV_CONST char *inbuf;
-	char *outbuf, *outpos;
-	size_t inleft, outleft, outsize, pos;
-
-	if (charset == NULL || charset_is_utf8(charset)) {
-		if (unknown_charset != NULL)
-			*unknown_charset = FALSE;
-
-		if (!ucase) {
-			if (utf8_size_r != NULL)
-				*utf8_size_r = size;
-			return t_strndup(data, size);
-		}
-
-		return charset_utf8_ucase_strdup(data, size, utf8_size_r);
-	}
-
-	cd = iconv_open("UTF-8", charset);
-	if (cd == (iconv_t)-1) {
-		if (unknown_charset != NULL)
-			*unknown_charset = TRUE;
-		return NULL;
-	}
-
-	if (unknown_charset != NULL)
-		*unknown_charset = FALSE;
-
-	inbuf = (ICONV_CONST char *) data;
-	inleft = size;
-
-	outsize = outleft = inleft * 2;
-	outbuf = outpos = t_buffer_get(outsize + 1);
-
-	while (iconv(cd, &inbuf, &inleft, &outpos, &outleft) == (size_t)-1) {
-		if (errno != E2BIG) {
-			/* invalid data */
-			iconv_close(cd);
-			return NULL;
-		}
-
-		/* output buffer too small, grow it */
-		pos = outsize - outleft;
-		outsize *= 2;
-		outleft = outsize - pos;
-
-		outbuf = t_buffer_reget(outbuf, outsize + 1);
-		outpos = outbuf + pos;
-	}
-
-	if (utf8_size_r != NULL)
-		*utf8_size_r = (size_t) (outpos - outbuf);
-	*outpos++ = '\0';
-	t_buffer_alloc((size_t) (outpos - outbuf));
-
-	if (ucase)
-		str_ucase(outbuf); /* FIXME: utf8 */
-
-	iconv_close(cd);
-	return outbuf;
-}
-
-const char *
-charset_to_utf8_string(const char *charset, bool *unknown_charset,
-		       const unsigned char *data, size_t size,
-		       size_t *utf8_size_r)
-{
-	return charset_to_utf8_string_int(charset, unknown_charset,
-					  data, size, utf8_size_r, FALSE);
-}
-
-const char *
-charset_to_ucase_utf8_string(const char *charset, bool *unknown_charset,
-			     const unsigned char *data, size_t size,
-			     size_t *utf8_size_r)
-{
-	return charset_to_utf8_string_int(charset, unknown_charset,
-					  data, size, utf8_size_r, TRUE);
-}
-
 #endif
diff -r b9c1336fd4e4 -r 0d3583b02a32 src/lib-charset/charset-utf8.c
--- a/src/lib-charset/charset-utf8.c	Fri Jul 20 17:00:01 2007 +0300
+++ b/src/lib-charset/charset-utf8.c	Fri Jul 20 17:01:39 2007 +0300
@@ -89,41 +89,4 @@ charset_to_utf8(struct charset_translati
 	return CHARSET_RET_OK;
 }
 
-const char *
-charset_to_utf8_string(const char *charset, bool *unknown_charset,
-		       const unsigned char *data, size_t size,
-		       size_t *utf8_size_r)
-{
-	if (charset == NULL || strcasecmp(charset, "us-ascii") == 0 ||
-	    strcasecmp(charset, "ascii") == 0 ||
-	    strcasecmp(charset, "UTF-8") == 0 ||
-	    strcasecmp(charset, "UTF8") == 0) {
-		if (unknown_charset != NULL)
-			*unknown_charset = FALSE;
-		if (utf8_size_r != NULL)
-			*utf8_size_r = size;
-		return t_strndup(data, size);
-	} else {
-		if (unknown_charset != NULL)
-			*unknown_charset = TRUE;
-		return NULL;
-	}
-}
-
-const char *
-charset_to_ucase_utf8_string(const char *charset, bool *unknown_charset,
-			     const unsigned char *data, size_t size,
-			     size_t *utf8_size_r)
-{
-	if (charset == NULL || charset_is_utf8(charset)) {
-		if (unknown_charset != NULL)
-			*unknown_charset = FALSE;
-		return charset_utf8_ucase_strdup(data, size, utf8_size_r);
-	} else {
-		if (unknown_charset != NULL)
-			*unknown_charset = TRUE;
-		return NULL;
-	}
-}
-
 #endif
diff -r b9c1336fd4e4 -r 0d3583b02a32 src/lib-charset/charset-utf8.h
--- a/src/lib-charset/charset-utf8.h	Fri Jul 20 17:00:01 2007 +0300
+++ b/src/lib-charset/charset-utf8.h	Fri Jul 20 17:01:39 2007 +0300
@@ -24,17 +24,6 @@ charset_to_utf8(struct charset_translati
 charset_to_utf8(struct charset_translation *t,
 		const unsigned char *src, size_t *src_size, buffer_t *dest);
 
-/* Simple wrappers for above functions. If utf8_size is non-NULL, it's set
-   to same as strlen(returned data). */
-const char *
-charset_to_utf8_string(const char *charset, bool *unknown_charset,
-		       const unsigned char *data, size_t size,
-		       size_t *utf8_size_r);
-const char *
-charset_to_ucase_utf8_string(const char *charset, bool *unknown_charset,
-			     const unsigned char *data, size_t size,
-			     size_t *utf8_size_r);
-
 void charset_utf8_ucase_write(buffer_t *dest, size_t destpos,
 			      const unsigned char *src, size_t src_size);
 const char *charset_utf8_ucase_strdup(const unsigned char *data, size_t size,


More information about the dovecot-cvs mailing list