{"id":811943,"url":"http://patchwork.ozlabs.org/api/patches/811943/?format=json","web_url":"http://patchwork.ozlabs.org/project/uboot/patch/20170909104746.5948-4-robdclark@gmail.com/","project":{"id":18,"url":"http://patchwork.ozlabs.org/api/projects/18/?format=json","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-4-robdclark@gmail.com>","list_archive_url":null,"date":"2017-09-09T10:47:41","name":"[U-Boot,v2,3/5] vsprintf.c: add UTF-16 string (%ls) support","commit_ref":"274325c50951dd16ad2a6f45e79dc062ad47011b","pull_url":null,"state":"accepted","archived":false,"hash":"48dcd341cbe026086e4348d6a6806bbda9a24e66","submitter":{"id":18760,"url":"http://patchwork.ozlabs.org/api/people/18760/?format=json","name":"Rob Clark","email":"robdclark@gmail.com"},"delegate":{"id":3651,"url":"http://patchwork.ozlabs.org/api/users/3651/?format=json","username":"trini","first_name":"Tom","last_name":"Rini","email":"trini@ti.com"},"mbox":"http://patchwork.ozlabs.org/project/uboot/patch/20170909104746.5948-4-robdclark@gmail.com/mbox/","series":[{"id":2341,"url":"http://patchwork.ozlabs.org/api/series/2341/?format=json","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/811943/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/811943/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=\"t1HCfbDn\"; dkim-atps=neutral"],"Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xq9sg1gxZz9s7h\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSat,  9 Sep 2017 20:48:55 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid C467AC21E3C; Sat,  9 Sep 2017 10:48:34 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id CCA90C21DDD;\n\tSat,  9 Sep 2017 10:48:32 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid 39B04C21E7C; Sat,  9 Sep 2017 10:48:10 +0000 (UTC)","from mail-qk0-f195.google.com (mail-qk0-f195.google.com\n\t[209.85.220.195])\n\tby lists.denx.de (Postfix) with ESMTPS id 99BA7C21DEF\n\tfor <u-boot@lists.denx.de>; Sat,  9 Sep 2017 10:48:06 +0000 (UTC)","by mail-qk0-f195.google.com with SMTP id o77so2876217qke.2\n\tfor <u-boot@lists.denx.de>; Sat, 09 Sep 2017 03:48:06 -0700 (PDT)","from localhost ([2601:184:4780:aac0:25f8:dd96:a084:785a])\n\tby smtp.gmail.com with ESMTPSA id\n\tt90sm2743976qkl.77.2017.09.09.03.48.04\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tSat, 09 Sep 2017 03:48:04 -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=vpDjQnR98rBNdK51l4DWWHbHnKNdF6CVj8Dd9an5qJw=;\n\tb=t1HCfbDnKZ29tU77OD9pynXbStBXaV3YMxcen3ZImC/rYVbL9EGA2atx+bWq0lfRDd\n\taezz3E0deWhU9hZbsviDvkmTTh1qRZSVWKNrex2QokWMGXeq2LXrMbox25fvbQEPmwAr\n\ttsp4zFfDwgpz/U1Y2heqNAzUFv/XzfE4mFRsfxYNynDJxcfN8azertYXCa3Lyj3FEM30\n\tJYZQuwC8o5I55skhPwVk8D613GUCtwwMnoYxrK7UfZxd5B6bnuw4ycdoh0n3NmI1wcQe\n\tg3txA27p+Nv1GvlS8OFDFlUkg5HM4jEgsKEHQzdpwByvhvd7PXh+9XGhgfM6JdAr5NsQ\n\tm5AQ==","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=vpDjQnR98rBNdK51l4DWWHbHnKNdF6CVj8Dd9an5qJw=;\n\tb=E22bTaT/YKsL8T1TeKFmi+ucqvALBWdTMcYWEesdOaMfImnkB7yHT7emzN5T6ghHTz\n\t6PymqvyxZycDO+eoaxDWIuauys+IoIsd9BDqbofJ402kTaflIKsu2mAe+z9gJWQX2Phy\n\tiEu//aEEdqtOTUktWYl64vyChJN/OSBELskdWXrLPrdyHQnixjGLMMSKPdZG5RXWypYa\n\tZ/mCGAT5+hw6AIumjtzTU0jpCs4KeALHuAVvK+v+1txBYFR6QV0cMoTck3m7p8O/KVPe\n\t/cStGgy06UQqCfTNaYctkox28B0EzzfRKuK98s+utky+lwvNbUbn2FVkqnEbhBoHHQql\n\tX0Aw==","X-Gm-Message-State":"AHPjjUh0m9qN5tZBdJkXtHBwqqRR2mS/f316Q/VP5EVfOZF30g3TP950\n\t/i+DhqV2dDngdliO/jY=","X-Google-Smtp-Source":"AOwi7QB1J+PZl9aNwRhupvRNqr/4KCVUY1iRwcku9H7L0VMVaCpK1dTGbZ93KeFFpKCdxlVx9NdgoA==","X-Received":"by 10.55.153.193 with SMTP id b184mr7337721qke.314.1504954085381;\n\tSat, 09 Sep 2017 03:48:05 -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:41 -0400","Message-Id":"<20170909104746.5948-4-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>, Stefan Roese <sr@denx.de>","Subject":"[U-Boot] [PATCH v2 3/5] vsprintf.c: add UTF-16 string (%ls) support","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":"This is convenient for efi_loader which deals a lot with UTF-16.  Only\nenabled with CC_SHORT_WCHAR, leaving room to add a UTF-32 version when\nCC_SHORT_WCHAR is not enabled.\n\nSigned-off-by: Rob Clark <robdclark@gmail.com>\nReviewed-by: Simon Glass <sjg@chromium.org>\n---\n examples/api/Makefile |  1 +\n lib/vsprintf.c        | 30 ++++++++++++++++++++++++++++--\n 2 files changed, 29 insertions(+), 2 deletions(-)","diff":"diff --git a/examples/api/Makefile b/examples/api/Makefile\nindex dab6398bab..87c15d0f68 100644\n--- a/examples/api/Makefile\n+++ b/examples/api/Makefile\n@@ -34,6 +34,7 @@ EXT_COBJ-y += lib/div64.o\n EXT_COBJ-y += lib/string.o\n EXT_COBJ-y += lib/time.o\n EXT_COBJ-y += lib/vsprintf.o\n+EXT_COBJ-y += lib/charset.o\n EXT_SOBJ-$(CONFIG_PPC) += arch/powerpc/lib/ppcstring.o\n ifeq ($(ARCH),arm)\n EXT_SOBJ-$(CONFIG_USE_ARCH_MEMSET) += arch/arm/lib/memset.o\ndiff --git a/lib/vsprintf.c b/lib/vsprintf.c\nindex 874a2951f7..97bed9d36d 100644\n--- a/lib/vsprintf.c\n+++ b/lib/vsprintf.c\n@@ -17,6 +17,7 @@\n #include <linux/ctype.h>\n \n #include <common.h>\n+#include <charset.h>\n \n #include <div64.h>\n #define noinline __attribute__((noinline))\n@@ -270,6 +271,26 @@ static char *string(char *buf, char *end, char *s, int field_width,\n \treturn buf;\n }\n \n+static char *string16(char *buf, char *end, u16 *s, int field_width,\n+\t\tint precision, int flags)\n+{\n+\tu16 *str = s ? s : L\"<NULL>\";\n+\tint utf16_len = utf16_strnlen(str, precision);\n+\tu8 utf8[utf16_len * MAX_UTF8_PER_UTF16];\n+\tint utf8_len, i;\n+\n+\tutf8_len = utf16_to_utf8(utf8, str, utf16_len) - utf8;\n+\n+\tif (!(flags & LEFT))\n+\t\twhile (utf8_len < field_width--)\n+\t\t\tADDCH(buf, ' ');\n+\tfor (i = 0; i < utf8_len; ++i)\n+\t\tADDCH(buf, utf8[i]);\n+\twhile (utf8_len < field_width--)\n+\t\tADDCH(buf, ' ');\n+\treturn buf;\n+}\n+\n #ifdef CONFIG_CMD_NET\n static const char hex_asc[] = \"0123456789abcdef\";\n #define hex_asc_lo(x)\thex_asc[((x) & 0x0f)]\n@@ -528,8 +549,13 @@ repeat:\n \t\t\tcontinue;\n \n \t\tcase 's':\n-\t\t\tstr = string(str, end, va_arg(args, char *),\n-\t\t\t\t     field_width, precision, flags);\n+\t\t\tif (qualifier == 'l' && !IS_ENABLED(CONFIG_SPL_BUILD)) {\n+\t\t\t\tstr = string16(str, end, va_arg(args, u16 *),\n+\t\t\t\t\t       field_width, precision, flags);\n+\t\t\t} else {\n+\t\t\t\tstr = string(str, end, va_arg(args, char *),\n+\t\t\t\t\t     field_width, precision, flags);\n+\t\t\t}\n \t\t\tcontinue;\n \n \t\tcase 'p':\n","prefixes":["U-Boot","v2","3/5"]}