All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heinrich Schuchardt <xypron.glpk@gmx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 12/17] lib: charset: remove obsolete functions
Date: Fri, 31 Aug 2018 21:31:34 +0200	[thread overview]
Message-ID: <20180831193139.2517-13-xypron.glpk@gmx.de> (raw)
In-Reply-To: <20180831193139.2517-1-xypron.glpk@gmx.de>

Remove functions:
- utf8_to_utf16()
- utf16_strcpy()
- utf16_strdup()

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
v2
	no chanage
---
 include/charset.h | 23 --------------
 lib/charset.c     | 79 -----------------------------------------------
 2 files changed, 102 deletions(-)

diff --git a/include/charset.h b/include/charset.h
index cf41eb5e5f..90870513ef 100644
--- a/include/charset.h
+++ b/include/charset.h
@@ -167,16 +167,6 @@ size_t u16_strlen(const u16 *in);
  */
 size_t u16_strnlen(const u16 *in, size_t count);
 
-/**
- * utf16_strcpy() - UTF16 equivalent of strcpy()
- */
-uint16_t *utf16_strcpy(uint16_t *dest, const uint16_t *src);
-
-/**
- * utf16_strdup() - UTF16 equivalent of strdup()
- */
-uint16_t *utf16_strdup(const uint16_t *s);
-
 /**
  * utf16_to_utf8() - Convert an utf16 string to utf8
  *
@@ -193,17 +183,4 @@ uint16_t *utf16_strdup(const uint16_t *s);
  */
 uint8_t *utf16_to_utf8(uint8_t *dest, const uint16_t *src, size_t size);
 
-/**
- * utf8_to_utf16() - Convert an utf8 string to utf16
- *
- * Converts up to 'size' characters of the utf16 string 'src' to utf8
- * written to the 'dest' buffer. Stops at 0x00.
- *
- * @dest   the destination buffer to write the utf8 characters
- * @src    the source utf16 string
- * @size   maximum number of utf16 characters to convert
- * @return the pointer to the first unwritten byte in 'dest'
- */
-uint16_t *utf8_to_utf16(uint16_t *dest, const uint8_t *src, size_t size);
-
 #endif /* __CHARSET_H_ */
diff --git a/lib/charset.c b/lib/charset.c
index e82622a7f8..39c8329830 100644
--- a/lib/charset.c
+++ b/lib/charset.c
@@ -256,29 +256,6 @@ size_t u16_strnlen(const u16 *in, size_t count)
 	return i;
 }
 
-uint16_t *utf16_strcpy(uint16_t *dest, const uint16_t *src)
-{
-	uint16_t *tmp = dest;
-
-	while ((*dest++ = *src++) != '\0')
-		/* nothing */;
-	return tmp;
-
-}
-
-uint16_t *utf16_strdup(const uint16_t *s)
-{
-	uint16_t *new;
-
-	if (!s)
-		return NULL;
-	new = malloc((u16_strlen(s) + 1) * 2);
-	if (!new)
-		return NULL;
-	utf16_strcpy(new, s);
-	return new;
-}
-
 /* Convert UTF-16 to UTF-8.  */
 uint8_t *utf16_to_utf8(uint8_t *dest, const uint16_t *src, size_t size)
 {
@@ -331,59 +308,3 @@ uint8_t *utf16_to_utf8(uint8_t *dest, const uint16_t *src, size_t size)
 
 	return dest;
 }
-
-uint16_t *utf8_to_utf16(uint16_t *dest, const uint8_t *src, size_t size)
-{
-	while (size--) {
-		int extension_bytes;
-		uint32_t code;
-
-		extension_bytes = 0;
-		if (*src <= 0x7f) {
-			code = *src++;
-			/* Exit on zero byte */
-			if (!code)
-				size = 0;
-		} else if (*src <= 0xbf) {
-			/* Illegal code */
-			code = '?';
-		} else if (*src <= 0xdf) {
-			code = *src++ & 0x1f;
-			extension_bytes = 1;
-		} else if (*src <= 0xef) {
-			code = *src++ & 0x0f;
-			extension_bytes = 2;
-		} else if (*src <= 0xf7) {
-			code = *src++ & 0x07;
-			extension_bytes = 3;
-		} else {
-			/* Illegal code */
-			code = '?';
-		}
-
-		for (; extension_bytes && size; --size, --extension_bytes) {
-			if ((*src & 0xc0) == 0x80) {
-				code <<= 6;
-				code |= *src++ & 0x3f;
-			} else {
-				/* Illegal code */
-				code = '?';
-				++src;
-				--size;
-				break;
-			}
-		}
-
-		if (code < 0x10000) {
-			*dest++ = code;
-		} else {
-			/*
-			 * Simplified expression for
-			 * (((code - 0x10000) >> 10) & 0x3ff) | 0xd800
-			 */
-			*dest++ = (code >> 10) + 0xd7c0;
-			*dest++ = (code & 0x3ff) | 0xdc00;
-		}
-	}
-	return dest;
-}
-- 
2.18.0

  parent reply	other threads:[~2018-08-31 19:31 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-31 19:31 [U-Boot] [PATCH v2 00/17][RESENT] efi_loader: EFI_UNICODE_COLLATION_PROTOCOL Heinrich Schuchardt
2018-08-31 19:31 ` [U-Boot] [PATCH v2 01/17] vsprintf.c: use #if CONFIG_IS_ENABLED(EFI_LOADER) Heinrich Schuchardt
2018-08-31 19:31 ` [U-Boot] [PATCH v2 02/17] test: print_ut.c " Heinrich Schuchardt
2018-08-31 19:31 ` [U-Boot] [PATCH v2 03/17] lib: build charset.o only if needed Heinrich Schuchardt
2018-08-31 19:31 ` [U-Boot] [PATCH v2 04/17] efi_loader: rename utf16_strlen, utf16_strnlen Heinrich Schuchardt
2018-08-31 19:31 ` [U-Boot] [PATCH v2 05/17] lib: charset: utility functions for Unicode Heinrich Schuchardt
2018-08-31 19:31 ` [U-Boot] [PATCH v2 06/17] test: unit tests for Unicode functions Heinrich Schuchardt
2018-08-31 19:31 ` [U-Boot] [PATCH v2 07/17] lib: vsprintf: correct printing of Unicode strings Heinrich Schuchardt
2018-09-01  9:31   ` Alexander Graf
2018-08-31 19:31 ` [U-Boot] [PATCH v2 08/17] test: test printing Unicode Heinrich Schuchardt
2018-08-31 19:31 ` [U-Boot] [PATCH v2 09/17] efi_loader: remove limit on variable length Heinrich Schuchardt
2018-08-31 19:31 ` [U-Boot] [PATCH v2 10/17] efi_loader: don't use unlimited stack as buffer Heinrich Schuchardt
2018-08-31 19:31 ` [U-Boot] [PATCH v2 11/17] efi_loader: buffer size for load options Heinrich Schuchardt
2018-08-31 19:31 ` Heinrich Schuchardt [this message]
2018-08-31 19:31 ` [U-Boot] [PATCH v2 13/17] efi_loader: capitalization table Heinrich Schuchardt
2018-09-01  9:43   ` Alexander Graf
2018-09-01  9:50     ` Alexander Graf
2018-08-31 19:31 ` [U-Boot] [PATCH 14/17] lib: charset: upper/lower case conversion Heinrich Schuchardt
2018-08-31 19:31 ` [U-Boot] [PATCH v2 15/17] test: tests for utf_to_lower() utf_to_upper() Heinrich Schuchardt
2018-09-01  9:47   ` Alexander Graf
2018-08-31 19:31 ` [U-Boot] [PATCH v2 16/17] efi_loader: EFI_UNICODE_COLLATION_PROTOCOL Heinrich Schuchardt
2018-08-31 19:31 ` [U-Boot] [PATCH v2 17/17] efi_selftest: EFI_UNICODE_COLLATION_PROTOCOL Heinrich Schuchardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180831193139.2517-13-xypron.glpk@gmx.de \
    --to=xypron.glpk@gmx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.