Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/811946/?format=api
{ "id": 811946, "url": "http://patchwork.ozlabs.org/api/patches/811946/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/patch/20170909104746.5948-3-robdclark@gmail.com/", "project": { "id": 18, "url": "http://patchwork.ozlabs.org/api/projects/18/?format=api", "name": "U-Boot", "link_name": "uboot", "list_id": "u-boot.lists.denx.de", "list_email": "u-boot@lists.denx.de", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20170909104746.5948-3-robdclark@gmail.com>", "list_archive_url": null, "date": "2017-09-09T10:47:40", "name": "[U-Boot,v2,2/5] lib: add some utf16 handling helpers", "commit_ref": "78178bb0c9dfe2a91a636a411291d8bab50e8a7d", "pull_url": null, "state": "accepted", "archived": false, "hash": "cadb6e9419a669995845de22232736b5c2530baf", "submitter": { "id": 18760, "url": "http://patchwork.ozlabs.org/api/people/18760/?format=api", "name": "Rob Clark", "email": "robdclark@gmail.com" }, "delegate": { "id": 3651, "url": "http://patchwork.ozlabs.org/api/users/3651/?format=api", "username": "trini", "first_name": "Tom", "last_name": "Rini", "email": "trini@ti.com" }, "mbox": "http://patchwork.ozlabs.org/project/uboot/patch/20170909104746.5948-3-robdclark@gmail.com/mbox/", "series": [ { "id": 2341, "url": "http://patchwork.ozlabs.org/api/series/2341/?format=api", "web_url": "http://patchwork.ozlabs.org/project/uboot/list/?series=2341", "date": "2017-09-09T10:47:38", "name": "vsprintf and short-wchar", "version": 2, "mbox": "http://patchwork.ozlabs.org/series/2341/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/811946/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/811946/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<u-boot-bounces@lists.denx.de>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org", "Authentication-Results": [ "ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)", "ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"kh4bmyop\"; dkim-atps=neutral" ], "Received": [ "from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xq9v92PMYz9s7h\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSat, 9 Sep 2017 20:50:13 +1000 (AEST)", "by lists.denx.de (Postfix, from userid 105)\n\tid F2EC8C21F36; Sat, 9 Sep 2017 10:48:51 +0000 (UTC)", "from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 3CED8C21EDC;\n\tSat, 9 Sep 2017 10:48:41 +0000 (UTC)", "by lists.denx.de (Postfix, from userid 105)\n\tid 83964C21D7D; Sat, 9 Sep 2017 10:48:05 +0000 (UTC)", "from mail-qk0-f196.google.com (mail-qk0-f196.google.com\n\t[209.85.220.196])\n\tby lists.denx.de (Postfix) with ESMTPS id 67F94C21EDB\n\tfor <u-boot@lists.denx.de>; Sat, 9 Sep 2017 10:48:02 +0000 (UTC)", "by mail-qk0-f196.google.com with SMTP id d70so2879258qkc.1\n\tfor <u-boot@lists.denx.de>; Sat, 09 Sep 2017 03:48:02 -0700 (PDT)", "from localhost ([2601:184:4780:aac0:25f8:dd96:a084:785a])\n\tby smtp.gmail.com with ESMTPSA id\n\tj7sm2568801qth.25.2017.09.09.03.47.59\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tSat, 09 Sep 2017 03:48:00 -0700 (PDT)" ], "X-Spam-Checker-Version": "SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de", "X-Spam-Level": "", "X-Spam-Status": "No, score=-0.0 required=5.0 tests=FREEMAIL_FROM,\n\tRCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,\n\tT_DKIM_INVALID\n\tautolearn=unavailable autolearn_force=no version=3.4.0", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=SfXf2qdjisgptbj7B91hcVC+qT0OFocZk8UhjJtFlJw=;\n\tb=kh4bmyophe2p+9kJ6aaD9dwrnpt0WWMwlnDqSMYXD+BGXkfRX9hUb0ebi+SNkp+q/f\n\t03kx6ko4ga63onaMvfuYutvFuPtfmd/Ovyme+JC5Ru6LSpbcKlRnpEtO7m9joVvRnROM\n\tYxACtEDnw4cB4kE9/97jzyJ3jVEAPaiSJBSl+hZoLao/abZNecXKPCD6rwcpz6RAWOl3\n\tb6OYhwhj2R9m6GyOOq/qdS729QOnyCGwrlpSfK//0ZLhuWixxeDOINn7M+MIo/YV4QRW\n\tAlem77xiqUhkeuvz0K9F+zhKA0gHWuuVEll2JFnUwpfgn992eCRWP9WhN+4Sqjcf+uum\n\tB9Ww==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=SfXf2qdjisgptbj7B91hcVC+qT0OFocZk8UhjJtFlJw=;\n\tb=OdUGwmbpP6FJdaMJ/ktTe6labjq+/t7WinpD2LplSl/gwa7S5hWSHeMcVsuWJhw2R/\n\tPGZCE3J4puD8y6dphwU1ZHGm2oS7PhxEV5NpdY+k4PRpdcpdWEwWIdprbWHaPxEZeWO9\n\tWbUjFr6VEK1T+PZByO+PU5s83Uo8wQAjzDr72ENp95jN53XLOdbl6LFau+tKB3Xeqwzf\n\tDRWIGnBapYL1t68pbyPCJwn2cULk/zT2Myy4iKN4dHTLsITRwEbTsEgfTrYAQ/baE6Pm\n\ticeM7NZGnSx94XDhsSrmaKFQ3RgvByL4UVnRLAiykSyrSaHee5n+veLyLvJWhAiV6W/l\n\txB3Q==", "X-Gm-Message-State": "AHPjjUiHAjtN+zXNTQ28lVW7GFwXOJe3MZ/wfzktkOzbPOxLfLZLQBE+\n\tfJpxeFwnFvSHbcAydb0=", "X-Google-Smtp-Source": "AOwi7QCzNj9L/EiZOqxEUI/L56XVuw4QIWg5g8hayW4vXU79ZN7lxz1D2ucuWKrQuSfXqpilDcGMhA==", "X-Received": "by 10.55.215.211 with SMTP id t80mr1003043qkt.30.1504954081052; \n\tSat, 09 Sep 2017 03:48:01 -0700 (PDT)", "From": "Rob Clark <robdclark@gmail.com>", "To": "U-Boot Mailing List <u-boot@lists.denx.de>", "Date": "Sat, 9 Sep 2017 06:47:40 -0400", "Message-Id": "<20170909104746.5948-3-robdclark@gmail.com>", "X-Mailer": "git-send-email 2.13.5", "In-Reply-To": "<20170909104746.5948-1-robdclark@gmail.com>", "References": "<20170909104746.5948-1-robdclark@gmail.com>", "Cc": "Heinrich Schuchardt <xypron.glpk@gmx.de>", "Subject": "[U-Boot] [PATCH v2 2/5] lib: add some utf16 handling helpers", "X-BeenThere": "u-boot@lists.denx.de", "X-Mailman-Version": "2.1.18", "Precedence": "list", "List-Id": "U-Boot discussion <u-boot.lists.denx.de>", "List-Unsubscribe": "<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>", "List-Archive": "<http://lists.denx.de/pipermail/u-boot/>", "List-Post": "<mailto:u-boot@lists.denx.de>", "List-Help": "<mailto:u-boot-request@lists.denx.de?subject=help>", "List-Subscribe": "<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"utf-8\"", "Content-Transfer-Encoding": "base64", "Errors-To": "u-boot-bounces@lists.denx.de", "Sender": "\"U-Boot\" <u-boot-bounces@lists.denx.de>" }, "content": "We'll eventually want these in a few places in efi_loader, and also\nvsprintf.\n\nSigned-off-by: Rob Clark <robdclark@gmail.com>\n---\n include/charset.h | 65 ++++++++++++++++++++++++++++\n lib/Makefile | 1 +\n lib/charset.c | 101 +++++++++++++++++++++++++++++++++++++++++++\n lib/efi_loader/efi_console.c | 17 ++------\n 4 files changed, 170 insertions(+), 14 deletions(-)\n create mode 100644 include/charset.h\n create mode 100644 lib/charset.c", "diff": "diff --git a/include/charset.h b/include/charset.h\nnew file mode 100644\nindex 0000000000..39279f746a\n--- /dev/null\n+++ b/include/charset.h\n@@ -0,0 +1,65 @@\n+/*\n+ * charset conversion utils\n+ *\n+ * Copyright (c) 2017 Rob Clark\n+ *\n+ * SPDX-License-Identifier: GPL-2.0+\n+ */\n+\n+#ifndef __CHARSET_H_\n+#define __CHARSET_H_\n+\n+#define MAX_UTF8_PER_UTF16 4\n+\n+/**\n+ * utf16_strlen() - Get the length of an utf16 string\n+ *\n+ * Returns the number of 16 bit characters in an utf16 string, not\n+ * including the terminating NULL character.\n+ *\n+ * @in the string to measure\n+ * @return the string length\n+ */\n+size_t utf16_strlen(const uint16_t *in);\n+\n+/**\n+ * utf16_strnlen() - Get the length of a fixed-size utf16 string.\n+ *\n+ * Returns the number of 16 bit characters in an utf16 string,\n+ * not including the terminating NULL character, but at most\n+ * 'count' number of characters. In doing this, utf16_strnlen()\n+ * looks at only the first 'count' characters.\n+ *\n+ * @in the string to measure\n+ * @count the maximum number of characters to count\n+ * @return the string length, up to a maximum of 'count'\n+ */\n+size_t utf16_strnlen(const uint16_t *in, size_t count);\n+\n+/**\n+ * utf16_strcpy() - UTF16 equivalent of strcpy()\n+ */\n+uint16_t *utf16_strcpy(uint16_t *dest, const uint16_t *src);\n+\n+/**\n+ * utf16_strdup() - UTF16 equivalent of strdup()\n+ */\n+uint16_t *utf16_strdup(const uint16_t *s);\n+\n+/**\n+ * utf16_to_utf8() - Convert an utf16 string to utf8\n+ *\n+ * Converts 'size' characters of the utf16 string 'src' to utf8\n+ * written to the 'dest' buffer.\n+ *\n+ * NOTE that a single utf16 character can generate up to 4 utf8\n+ * characters. See MAX_UTF8_PER_UTF16.\n+ *\n+ * @dest the destination buffer to write the utf8 characters\n+ * @src the source utf16 string\n+ * @size the number of utf16 characters to convert\n+ * @return the pointer to the first unwritten byte in 'dest'\n+ */\n+uint8_t *utf16_to_utf8(uint8_t *dest, const uint16_t *src, size_t size);\n+\n+#endif /* __CHARSET_H_ */\ndiff --git a/lib/Makefile b/lib/Makefile\nindex 2eef1eb80e..24df11b88f 100644\n--- a/lib/Makefile\n+++ b/lib/Makefile\n@@ -19,6 +19,7 @@ obj-$(CONFIG_OF_LIVE) += of_live.o\n obj-$(CONFIG_CMD_DHRYSTONE) += dhry/\n \n obj-$(CONFIG_AES) += aes.o\n+obj-y += charset.o\n obj-$(CONFIG_USB_TTY) += circbuf.o\n obj-y += crc7.o\n obj-y += crc8.o\ndiff --git a/lib/charset.c b/lib/charset.c\nnew file mode 100644\nindex 0000000000..ff76e88c77\n--- /dev/null\n+++ b/lib/charset.c\n@@ -0,0 +1,101 @@\n+/*\n+ * charset conversion utils\n+ *\n+ * Copyright (c) 2017 Rob Clark\n+ *\n+ * SPDX-License-Identifier: GPL-2.0+\n+ */\n+\n+#include <common.h>\n+#include <charset.h>\n+#include <malloc.h>\n+\n+/*\n+ * utf8/utf16 conversion mostly lifted from grub\n+ */\n+\n+size_t utf16_strlen(const uint16_t *in)\n+{\n+\tsize_t i;\n+\tfor (i = 0; in[i]; i++);\n+\treturn i;\n+}\n+\n+size_t utf16_strnlen(const uint16_t *in, size_t count)\n+{\n+\tsize_t i;\n+\tfor (i = 0; count-- && in[i]; i++);\n+\treturn i;\n+}\n+\n+uint16_t *utf16_strcpy(uint16_t *dest, const uint16_t *src)\n+{\n+\tuint16_t *tmp = dest;\n+\n+\twhile ((*dest++ = *src++) != '\\0')\n+\t\t/* nothing */;\n+\treturn tmp;\n+\n+}\n+\n+uint16_t *utf16_strdup(const uint16_t *s)\n+{\n+\tuint16_t *new;\n+\tif (!s || !(new = malloc((utf16_strlen(s) + 1) * 2)))\n+\t\treturn NULL;\n+\tutf16_strcpy(new, s);\n+\treturn new;\n+}\n+\n+/* Convert UTF-16 to UTF-8. */\n+uint8_t *utf16_to_utf8(uint8_t *dest, const uint16_t *src, size_t size)\n+{\n+\tuint32_t code_high = 0;\n+\n+\twhile (size--) {\n+\t\tuint32_t code = *src++;\n+\n+\t\tif (code_high) {\n+\t\t\tif (code >= 0xDC00 && code <= 0xDFFF) {\n+\t\t\t\t/* Surrogate pair. */\n+\t\t\t\tcode = ((code_high - 0xD800) << 10) + (code - 0xDC00) + 0x10000;\n+\n+\t\t\t\t*dest++ = (code >> 18) | 0xF0;\n+\t\t\t\t*dest++ = ((code >> 12) & 0x3F) | 0x80;\n+\t\t\t\t*dest++ = ((code >> 6) & 0x3F) | 0x80;\n+\t\t\t\t*dest++ = (code & 0x3F) | 0x80;\n+\t\t\t} else {\n+\t\t\t\t/* Error... */\n+\t\t\t\t*dest++ = '?';\n+\t\t\t\t/* *src may be valid. Don't eat it. */\n+\t\t\t\tsrc--;\n+\t\t\t}\n+\n+\t\t\tcode_high = 0;\n+\t\t} else {\n+\t\t\tif (code <= 0x007F) {\n+\t\t\t\t*dest++ = code;\n+\t\t\t} else if (code <= 0x07FF) {\n+\t\t\t\t*dest++ = (code >> 6) | 0xC0;\n+\t\t\t\t*dest++ = (code & 0x3F) | 0x80;\n+\t\t\t} else if (code >= 0xD800 && code <= 0xDBFF) {\n+\t\t\t\tcode_high = code;\n+\t\t\t\tcontinue;\n+\t\t\t} else if (code >= 0xDC00 && code <= 0xDFFF) {\n+\t\t\t\t/* Error... */\n+\t\t\t\t*dest++ = '?';\n+\t\t\t} else if (code < 0x10000) {\n+\t\t\t\t*dest++ = (code >> 12) | 0xE0;\n+\t\t\t\t*dest++ = ((code >> 6) & 0x3F) | 0x80;\n+\t\t\t\t*dest++ = (code & 0x3F) | 0x80;\n+\t\t\t} else {\n+\t\t\t\t*dest++ = (code >> 18) | 0xF0;\n+\t\t\t\t*dest++ = ((code >> 12) & 0x3F) | 0x80;\n+\t\t\t\t*dest++ = ((code >> 6) & 0x3F) | 0x80;\n+\t\t\t\t*dest++ = (code & 0x3F) | 0x80;\n+\t\t\t}\n+\t\t}\n+\t}\n+\n+\treturn dest;\n+}\ndiff --git a/lib/efi_loader/efi_console.c b/lib/efi_loader/efi_console.c\nindex 5ebce4b544..3fc82b8726 100644\n--- a/lib/efi_loader/efi_console.c\n+++ b/lib/efi_loader/efi_console.c\n@@ -7,6 +7,7 @@\n */\n \n #include <common.h>\n+#include <charset.h>\n #include <efi_loader.h>\n \n static bool console_size_queried;\n@@ -138,20 +139,8 @@ static efi_status_t EFIAPI efi_cout_reset(\n \n static void print_unicode_in_utf8(u16 c)\n {\n-\tchar utf8[4] = { 0 };\n-\tchar *b = utf8;\n-\n-\tif (c < 0x80) {\n-\t\t*(b++) = c;\n-\t} else if (c < 0x800) {\n-\t\t*(b++) = 192 + c / 64;\n-\t\t*(b++) = 128 + c % 64;\n-\t} else {\n-\t\t*(b++) = 224 + c / 4096;\n-\t\t*(b++) = 128 + c / 64 % 64;\n-\t\t*(b++) = 128 + c % 64;\n-\t}\n-\n+\tchar utf8[MAX_UTF8_PER_UTF16] = { 0 };\n+\tutf16_to_utf8((u8 *)utf8, &c, 1);\n \tputs(utf8);\n }\n \n", "prefixes": [ "U-Boot", "v2", "2/5" ] }