get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/956569/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 956569,
    "url": "http://patchwork.ozlabs.org/api/patches/956569/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/uboot/patch/20180811152820.26817-5-xypron.glpk@gmx.de/",
    "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": "<20180811152820.26817-5-xypron.glpk@gmx.de>",
    "list_archive_url": null,
    "date": "2018-08-11T15:28:09",
    "name": "[U-Boot,04/15] test: unit tests for Unicode functions",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "232e1c93cb83b5522513f48ec1910063c57c47f0",
    "submitter": {
        "id": 61270,
        "url": "http://patchwork.ozlabs.org/api/people/61270/?format=api",
        "name": "Heinrich Schuchardt",
        "email": "xypron.glpk@gmx.de"
    },
    "delegate": {
        "id": 3400,
        "url": "http://patchwork.ozlabs.org/api/users/3400/?format=api",
        "username": "agraf",
        "first_name": "Alexander",
        "last_name": "Graf",
        "email": "agraf@suse.de"
    },
    "mbox": "http://patchwork.ozlabs.org/project/uboot/patch/20180811152820.26817-5-xypron.glpk@gmx.de/mbox/",
    "series": [
        {
            "id": 60397,
            "url": "http://patchwork.ozlabs.org/api/series/60397/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/uboot/list/?series=60397",
            "date": "2018-08-11T15:28:06",
            "name": "efi_loader: EFI_UNICODE_COLLATION_PROTOCOL",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/60397/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/956569/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/956569/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\tdmarc=none (p=none dis=none) header.from=gmx.de"
        ],
        "Received": [
            "from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 41nmNG1nrzz9s9N\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSun, 12 Aug 2018 01:38:06 +1000 (AEST)",
            "by lists.denx.de (Postfix, from userid 105)\n\tid E16F5C21DE8; Sat, 11 Aug 2018 15:32:43 +0000 (UTC)",
            "from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id A82D7C21E7D;\n\tSat, 11 Aug 2018 15:28:56 +0000 (UTC)",
            "by lists.denx.de (Postfix, from userid 105)\n\tid DC342C21E15; Sat, 11 Aug 2018 15:28:52 +0000 (UTC)",
            "from mout.gmx.net (mout.gmx.net [212.227.17.21])\n\tby lists.denx.de (Postfix) with ESMTPS id 14665C21C93\n\tfor <u-boot@lists.denx.de>; Sat, 11 Aug 2018 15:28:47 +0000 (UTC)",
            "from LT02.fritz.box ([88.152.14.153]) by mail.gmx.com (mrgmx102\n\t[212.227.17.174]) with ESMTPSA (Nemesis) id 0LqW8j-1gRzRL2tBR-00e7wc;\n\tSat, 11 Aug 2018 17:28:42 +0200"
        ],
        "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\tautolearn=unavailable autolearn_force=no version=3.4.0",
        "From": "Heinrich Schuchardt <xypron.glpk@gmx.de>",
        "To": "Alexander Graf <agraf@suse.de>",
        "Date": "Sat, 11 Aug 2018 17:28:09 +0200",
        "Message-Id": "<20180811152820.26817-5-xypron.glpk@gmx.de>",
        "X-Mailer": "git-send-email 2.18.0",
        "In-Reply-To": "<20180811152820.26817-1-xypron.glpk@gmx.de>",
        "References": "<20180811152820.26817-1-xypron.glpk@gmx.de>",
        "X-Provags-ID": "V03:K1:SGO/++yKoewz2SD40+vskcBSxtu82xsH83yc6Srwc+bcOCYwtZW\n\tuWVG8Ts9QT1tzI1X+8hlXdjED6CPpk/TvmNaKbd9LhxD6xfiHe6+838coC5hQtMMLPA6BU/\n\t1RUNleANuVuX/+u6vjQ5Y8K+AlC+DcI0qDyajPMYGGmIt90fs8/Zgm7+EPcnyoT5CGO/0N1\n\tnFh31D6gwhDnMtXBpqkag==",
        "X-UI-Out-Filterresults": "notjunk:1; V01:K0:PJJHINGvV6o=:fw7vpZYTPLFE3EtV9cXkD7\n\tJ/0KUhCkl5BLmbr1BT1U7oHznFteKN7DQUZW8cXaHlyqlobmModpMhW1lp27iJgxqzxrZbh12\n\tFBfzdvdmxuUZuDPDbyAm50JqnE7Nu3ZbuP5NkHOnnagG7e7cFFfdWgQmYbROSjgzTbJoioS/z\n\tCZuHYk8V7C1Ye3yqwBG4jNqJCFotWEMhQCqHH1EWPzyveUu9LFPaOHHIMlbdX/cRR4PReB/g8\n\tqVkcZJCSlxUdpqx4pJ4sWO/4ids8GgtPmfhK//snX4DdeIisOWZYlhOfuAcopW6FzUa3tfsVE\n\t62+TubWpJhyG7pPjxsYOY8BFJvi9rxS8uHgVHzYiVrwWlU8qjeMxIUC5i3mYAbSLnvgLTZEZ4\n\tp1DgCw2Z4Jop+UW/D9qfl8ZBrDN15xDNgL1vt3iiBW/UPupDCEUMaffgQfuhsDoLa7IER3+Ra\n\tAA9nABKwBAI+04ykBspor1LdJ4Q56puVyqE4mhjfawhs83z+jvUzTor04wx6j2tmfkEQIpPpj\n\tTcX/1c9mmZqkleYOEzxfjpkfbIPT4bsqd90fVhDFkuYwFOgugud/mI+C5/3kQ3QwXEu3bU3xB\n\tXiGrVNJ65VzR+YboNciYnffnV0XW+rSSpjs7TC2ThdN7IUvtEOk8ShXvDMaVLpr9I+4rscUIY\n\tEUzpAJxPnVrOor/DBkgdJWvl5Uk0aadcZ2gw2oo4NhUFHtVoK43Fcom0VNfIdptucUNMpmy5y\n\tgnOKGR8qPdTRErlsZanPI9sPqejddKhD03HTkE9jQZFqog3GmYbLXyTvCcA=",
        "Cc": "Heinrich Schuchardt <xypron.glpk@gmx.de>, u-boot@lists.denx.de",
        "Subject": "[U-Boot] [PATCH 04/15] test: unit tests for Unicode functions",
        "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": "Provide unit tests for Unicode functions.\n\nSigned-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>\n---\n MAINTAINERS           |   1 +\n include/test/suites.h |   3 +-\n test/Kconfig          |   8 +\n test/Makefile         |   1 +\n test/cmd_ut.c         |  14 +-\n test/unicode_ut.c     | 470 ++++++++++++++++++++++++++++++++++++++++++\n 6 files changed, 493 insertions(+), 4 deletions(-)\n create mode 100644 test/unicode_ut.c",
    "diff": "diff --git a/MAINTAINERS b/MAINTAINERS\nindex 51a1472cf8..a324139471 100644\n--- a/MAINTAINERS\n+++ b/MAINTAINERS\n@@ -374,6 +374,7 @@ F:\tinclude/asm-generic/pe.h\n F:\tlib/charset.c\n F:\tlib/efi*/\n F:\ttest/py/tests/test_efi*\n+F:\ttest/unicode_ut.c\n F:\tcmd/bootefi.c\n F:\ttools/file2include.c\n \ndiff --git a/include/test/suites.h b/include/test/suites.h\nindex b5019a7cd2..8e4eac60eb 100644\n--- a/include/test/suites.h\n+++ b/include/test/suites.h\n@@ -23,10 +23,11 @@ struct unit_test;\n int cmd_ut_category(const char *name, struct unit_test *tests, int n_ents,\n \t\t    int argc, char * const argv[]);\n \n+int do_ut_compression(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]);\n int do_ut_dm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);\n int do_ut_env(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);\n int do_ut_overlay(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);\n int do_ut_time(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);\n-int do_ut_compression(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]);\n+int do_ut_unicode(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]);\n \n #endif /* __TEST_SUITES_H__ */\ndiff --git a/test/Kconfig b/test/Kconfig\nindex 3643761bc6..de16d179d0 100644\n--- a/test/Kconfig\n+++ b/test/Kconfig\n@@ -15,6 +15,14 @@ config UT_TIME\n \t  problems. But if you are having problems with udelay() and the like,\n \t  this is a good place to start.\n \n+config UT_UNICODE\n+\tbool \"Unit tests for Unicode functions\"\n+\tdepends on UNIT_TEST\n+\tdefault y\n+\thelp\n+\t  Enables the 'ut unicode' command which tests that the functions for\n+\t  manipulating Unicode strings work correctly.\n+\n source \"test/dm/Kconfig\"\n source \"test/env/Kconfig\"\n source \"test/overlay/Kconfig\"\ndiff --git a/test/Makefile b/test/Makefile\nindex 1092011fdb..a5f52fd5ad 100644\n--- a/test/Makefile\n+++ b/test/Makefile\n@@ -8,4 +8,5 @@ obj-$(CONFIG_SANDBOX) += command_ut.o\n obj-$(CONFIG_SANDBOX) += compression.o\n obj-$(CONFIG_SANDBOX) += print_ut.o\n obj-$(CONFIG_UT_TIME) += time_ut.o\n+obj-$(CONFIG_UT_UNICODE) += unicode_ut.o\n obj-$(CONFIG_$(SPL_)LOG) += log/\ndiff --git a/test/cmd_ut.c b/test/cmd_ut.c\nindex 934a5a931b..d6a2593850 100644\n--- a/test/cmd_ut.c\n+++ b/test/cmd_ut.c\n@@ -49,6 +49,10 @@ static cmd_tbl_t cmd_ut_sub[] = {\n #ifdef CONFIG_UT_TIME\n \tU_BOOT_CMD_MKENT(time, CONFIG_SYS_MAXARGS, 1, do_ut_time, \"\", \"\"),\n #endif\n+#if defined(CONFIG_UT_UNICODE) && \\\n+\t!defined(CONFIG_SPL_BUILD) && !defined(API_BUILD)\n+\tU_BOOT_CMD_MKENT(unicode, CONFIG_SYS_MAXARGS, 1, do_ut_unicode, \"\", \"\"),\n+#endif\n #ifdef CONFIG_SANDBOX\n \tU_BOOT_CMD_MKENT(compression, CONFIG_SYS_MAXARGS, 1, do_ut_compression,\n \t\t\t \"\", \"\"),\n@@ -93,6 +97,9 @@ static int do_ut(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])\n #ifdef CONFIG_SYS_LONGHELP\n static char ut_help_text[] =\n \t\"all - execute all enabled tests\\n\"\n+#ifdef CONFIG_SANDBOX\n+\t\"ut compression - Test compressors and bootm decompression\\n\"\n+#endif\n #ifdef CONFIG_UT_DM\n \t\"ut dm [test-name]\\n\"\n #endif\n@@ -105,11 +112,12 @@ static char ut_help_text[] =\n #ifdef CONFIG_UT_TIME\n \t\"ut time - Very basic test of time functions\\n\"\n #endif\n-#ifdef CONFIG_SANDBOX\n-\t\"ut compression - Test compressors and bootm decompression\\n\"\n+#if defined(CONFIG_UT_UNICODE) && \\\n+\t!defined(CONFIG_SPL_BUILD) && !defined(API_BUILD)\n+\t\"ut unicode - test Unicode functions\\n\"\n #endif\n \t;\n-#endif\n+#endif /* CONFIG_SYS_LONGHELP */\n \n U_BOOT_CMD(\n \tut, CONFIG_SYS_MAXARGS, 1, do_ut,\ndiff --git a/test/unicode_ut.c b/test/unicode_ut.c\nnew file mode 100644\nindex 0000000000..29316606c4\n--- /dev/null\n+++ b/test/unicode_ut.c\n@@ -0,0 +1,470 @@\n+// SPDX-License-Identifier: GPL-2.0+\n+/*\n+ * Unit tests for Unicode functions\n+ *\n+ * Copyright (c) 2018 Heinrich Schuchardt <xypron.glpk@gmx.de>\n+ */\n+\n+#include <common.h>\n+#include <charset.h>\n+#include <command.h>\n+#include <errno.h>\n+\n+/* Constants c1-c4 and d1-d4 encode the same letters */\n+\n+/* Six characters translating to one utf-8 byte each. */\n+static const u16 c1[] = {0x55, 0x2d, 0x42, 0x6f, 0x6f, 0x74, 0x00};\n+/* One character translating to two utf-8 bytes */\n+static const u16 c2[] = {0x6b, 0x61, 0x66, 0x62, 0xe1, 0x74, 0x75, 0x72, 0x00};\n+/* Three characters translating to three utf-8 bytes each */\n+static const u16 c3[] = {0x6f5c, 0x6c34, 0x8266, 0x00};\n+/* Three letters translating to four utf-8 bytes each */\n+static const u16 c4[] = {0xd801, 0xdc8d, 0xd801, 0xdc96, 0xd801, 0xdc87,\n+\t\t\t 0x0000};\n+\n+/* Six characters translating to one utf-16 word each. */\n+static const char d1[] = {0x55, 0x2d, 0x42, 0x6f, 0x6f, 0x74, 0x00};\n+/* Eight characters translating to one utf-16 word each */\n+static const char d2[] = {0x6b, 0x61, 0x66, 0x62, 0xc3, 0xa1, 0x74, 0x75,\n+\t\t\t  0x72, 0x00};\n+/* Three characters translating to one utf-16 word each */\n+static const char d3[] = {0xe6, 0xbd, 0x9c, 0xe6, 0xb0, 0xb4, 0xe8, 0x89,\n+\t\t\t  0xa6, 0x00};\n+/* Three letters translating to two utf-16 word each */\n+static const char d4[] = {0xf0, 0x90, 0x92, 0x8d, 0xf0, 0x90, 0x92, 0x96,\n+\t\t\t  0xf0, 0x90, 0x92, 0x87, 0x00};\n+\n+static int ut_utf8_get(void)\n+{\n+\tconst char *s;\n+\ts32 code;\n+\tint i;\n+\n+\t/* Check characters less than 0x800 */\n+\ts = d2;\n+\tfor (i = 0; i < 8; ++i) {\n+\t\tcode = utf8_get((const char **)&s);\n+\t\t/* c2 is the utf-8 encoding of d2 */\n+\t\tif (code != c2[i])\n+\t\t\treturn -1;\n+\t\tif (!code)\n+\t\t\tbreak;\n+\t}\n+\tif (s != d2 + 9)\n+\t\treturn -1;\n+\n+\t/* Check characters less than 0x10000 */\n+\ts = d3;\n+\tfor (i = 0; i < 4; ++i) {\n+\t\tcode = utf8_get((const char **)&s);\n+\t\t/* c3 is the utf-8 encoding of d3 */\n+\t\tif (code != c3[i])\n+\t\t\treturn -1;\n+\t\tif (!code)\n+\t\t\tbreak;\n+\t}\n+\tif (s != d3 + 9)\n+\t\treturn -1;\n+\n+\t/* Check character greater 0xffff */\n+\ts = d4;\n+\tcode = utf8_get((const char **)&s);\n+\tif (code != 0x0001048d)\n+\t\treturn -1;\n+\tif (s != d4 + 4)\n+\t\treturn -1;\n+\n+\treturn 0;\n+}\n+\n+static int ut_utf8_put(void)\n+{\n+\tchar buffer[8] = { 0, };\n+\tchar *pos;\n+\n+\t/* Commercial at, translates to one character */\n+\tpos = buffer;\n+\tif (utf8_put('@', &pos))\n+\t\treturn -1;\n+\tif (pos - buffer != 1)\n+\t\treturn -1;\n+\tif (buffer[0] != '@' || buffer[1])\n+\t\treturn -1;\n+\n+\t/* Latin letter G with acute, translates to two charactes */\n+\tpos = buffer;\n+\tif (utf8_put(0x1f4, &pos))\n+\t\treturn -1;\n+\tif (pos - buffer != 2)\n+\t\treturn -1;\n+\tif (buffer[0] != (char)0xc7 || buffer[1] != (char)0xb4 || buffer[2])\n+\t\treturn -1;\n+\n+\t/* Tagalog letter i, translates to three characters */\n+\tpos = buffer;\n+\tif (utf8_put(0x1701, &pos))\n+\t\treturn -1;\n+\tif (pos - buffer != 3)\n+\t\treturn -1;\n+\tif (buffer[0] != (char)0xe1 || buffer[1] != (char)0x9c ||\n+\t    buffer[2] != (char)0x81 || buffer[3])\n+\t\treturn -1;\n+\n+\t/* Hamster face, translates to four characters */\n+\tpos = buffer;\n+\tif (utf8_put(0x1f439, &pos))\n+\t\treturn -1;\n+\tif (pos - buffer != 4)\n+\t\treturn -1;\n+\tif (buffer[0] != (char)0xf0 || buffer[1] != (char)0x9f ||\n+\t    buffer[2] != (char)0x90 || buffer[3] != (char)0xb9 || buffer[4])\n+\t\treturn -1;\n+\n+\t/* Illegal code */\n+\tpos = buffer;\n+\tif (utf8_put(0xd888, &pos) != -1)\n+\t\treturn -1;\n+\n+\treturn 0;\n+}\n+\n+int ut_utf8_utf16_strlen(void)\n+{\n+\tif (utf8_utf16_strlen(d1) != 6)\n+\t\treturn 1;\n+\tif (utf8_utf16_strlen(d2) != 8)\n+\t\treturn 1;\n+\tif (utf8_utf16_strlen(d3) != 3)\n+\t\treturn 1;\n+\tif (utf8_utf16_strlen(d4) != 6)\n+\t\treturn 1;\n+\treturn 0;\n+}\n+\n+int ut_utf8_utf16_strnlen(void)\n+{\n+\tif (utf8_utf16_strnlen(d1, 3) != 3)\n+\t\treturn 1;\n+\tif (utf8_utf16_strnlen(d1, 13) != 6)\n+\t\treturn 1;\n+\tif (utf8_utf16_strnlen(d2, 6) != 6)\n+\t\treturn 1;\n+\tif (utf8_utf16_strnlen(d3, 2) != 2)\n+\t\treturn 1;\n+\tif (utf8_utf16_strnlen(d4, 2) != 4)\n+\t\treturn 1;\n+\tif (utf8_utf16_strnlen(d4, 3) != 6)\n+\t\treturn 1;\n+\treturn 0;\n+}\n+\n+int ut_u16_strcmp(const u16 *a1, const u16 *a2, size_t count)\n+{\n+\tfor (; (*a1 || *a2) && count; ++a1, ++a2, --count) {\n+\t\tif (*a1 < *a2)\n+\t\t\treturn -1;\n+\t\tif (*a1 > *a2)\n+\t\t\treturn 1;\n+\t}\n+\treturn 0;\n+}\n+\n+int ut_utf8_utf16_strcpy(void)\n+{\n+\tu16 buf[16];\n+\tu16 *pos;\n+\n+\tpos = buf;\n+\tutf8_utf16_strcpy(&pos, d1);\n+\tif (pos - buf != 6)\n+\t\treturn 1;\n+\tif (ut_u16_strcmp(buf, c1, 16))\n+\t\treturn 1;\n+\n+\tpos = buf;\n+\tutf8_utf16_strcpy(&pos, d2);\n+\tif (pos - buf != 8)\n+\t\treturn 1;\n+\tif (ut_u16_strcmp(buf, c2, 16))\n+\t\treturn 1;\n+\n+\tpos = buf;\n+\tutf8_utf16_strcpy(&pos, d3);\n+\tif (pos - buf != 3)\n+\t\treturn 1;\n+\tif (ut_u16_strcmp(buf, c3, 16))\n+\t\treturn 1;\n+\n+\tpos = buf;\n+\tutf8_utf16_strcpy(&pos, d4);\n+\tif (pos - buf != 6)\n+\t\treturn 1;\n+\tif (ut_u16_strcmp(buf, c4, 16))\n+\t\treturn 1;\n+\n+\treturn 0;\n+}\n+\n+int ut_utf8_utf16_strncpy(void)\n+{\n+\tu16 buf[16];\n+\tu16 *pos;\n+\n+\tpos = buf;\n+\tmemset(buf, 0, sizeof(buf));\n+\tutf8_utf16_strncpy(&pos, d1, 4);\n+\tif (pos - buf != 4)\n+\t\treturn 1;\n+\tif (buf[4])\n+\t\treturn 1;\n+\tif (ut_u16_strcmp(buf, c1, 4))\n+\t\treturn 1;\n+\n+\tpos = buf;\n+\tmemset(buf, 0, sizeof(buf));\n+\tutf8_utf16_strncpy(&pos, d2, 10);\n+\tif (pos - buf != 8)\n+\t\treturn 1;\n+\tif (!buf[4])\n+\t\treturn 1;\n+\tif (ut_u16_strcmp(buf, c2, SIZE_MAX))\n+\t\treturn 1;\n+\n+\tpos = buf;\n+\tmemset(buf, 0, sizeof(buf));\n+\tutf8_utf16_strncpy(&pos, d3, 2);\n+\tif (pos - buf != 2)\n+\t\treturn 1;\n+\tif (buf[2])\n+\t\treturn 1;\n+\tif (ut_u16_strcmp(buf, c3, 2))\n+\t\treturn 1;\n+\n+\tpos = buf;\n+\tmemset(buf, 0, sizeof(buf));\n+\tutf8_utf16_strncpy(&pos, d4, 2);\n+\tif (pos - buf != 4)\n+\t\treturn 1;\n+\tif (buf[4])\n+\t\treturn 1;\n+\tif (ut_u16_strcmp(buf, c4, 4))\n+\t\treturn 1;\n+\n+\tpos = buf;\n+\tmemset(buf, 0, sizeof(buf));\n+\tutf8_utf16_strncpy(&pos, d4, 10);\n+\tif (pos - buf != 6)\n+\t\treturn 1;\n+\tif (!buf[5])\n+\t\treturn 1;\n+\tif (ut_u16_strcmp(buf, c4, SIZE_MAX))\n+\t\treturn 1;\n+\n+\treturn 0;\n+}\n+\n+static int ut_utf16_get(void)\n+{\n+\tconst u16 *s;\n+\ts32 code;\n+\tint i;\n+\n+\t/* Check characters less than 0x10000 */\n+\ts = c2;\n+\tfor (i = 0; i < 9; ++i) {\n+\t\tcode = utf16_get((const u16 **)&s);\n+\t\tif (code != c2[i])\n+\t\t\treturn -1;\n+\t\tif (!code)\n+\t\t\tbreak;\n+\t}\n+\tif (s != c2 + 8)\n+\t\treturn -1;\n+\n+\t/* Check character greater 0xffff */\n+\ts = c4;\n+\tcode = utf16_get((const u16 **)&s);\n+\tif (code != 0x0001048d)\n+\t\treturn -1;\n+\tif (s != c4 + 2)\n+\t\treturn -1;\n+\n+\treturn 0;\n+}\n+\n+static int ut_utf16_put(void)\n+{\n+\tu16 buffer[4] = { 0, };\n+\tu16 *pos;\n+\n+\t/* Commercial at, translates to one word */\n+\tpos = buffer;\n+\tif (utf16_put('@', &pos))\n+\t\treturn -1;\n+\tif (pos - buffer != 1)\n+\t\treturn -1;\n+\tif (buffer[0] != (u16)'@' || buffer[1])\n+\t\treturn -1;\n+\n+\t/* Hamster face, translates to two words */\n+\tpos = buffer;\n+\tif (utf16_put(0x1f439, &pos))\n+\t\treturn -1;\n+\tif (pos - buffer != 2)\n+\t\treturn -1;\n+\tif (buffer[0] != (u16)0xd83d || buffer[1] != (u16)0xdc39 || buffer[2])\n+\t\treturn -1;\n+\n+\t/* Illegal code */\n+\tpos = buffer;\n+\tif (utf16_put(0xd888, &pos) != -1)\n+\t\treturn -1;\n+\n+\treturn 0;\n+}\n+\n+int ut_utf16_utf8_strlen(void)\n+{\n+\tif (utf16_utf8_strlen(c1) != 6)\n+\t\treturn 1;\n+\tif (utf16_utf8_strlen(c2) != 9)\n+\t\treturn 1;\n+\tif (utf16_utf8_strlen(c3) != 9)\n+\t\treturn 1;\n+\tif (utf16_utf8_strlen(c4) != 12)\n+\t\treturn 1;\n+\treturn 0;\n+}\n+\n+int ut_utf16_utf8_strnlen(void)\n+{\n+\tif (utf16_utf8_strnlen(c1, 3) != 3)\n+\t\treturn 1;\n+\tif (utf16_utf8_strnlen(c1, 13) != 6)\n+\t\treturn 1;\n+\tif (utf16_utf8_strnlen(c2, 6) != 7)\n+\t\treturn 1;\n+\tif (utf16_utf8_strnlen(c3, 2) != 6)\n+\t\treturn 1;\n+\tif (utf16_utf8_strnlen(c4, 2) != 8)\n+\t\treturn 1;\n+\tif (utf16_utf8_strnlen(c4, 3) != 12)\n+\t\treturn 1;\n+\treturn 0;\n+}\n+\n+int ut_utf16_utf8_strcpy(void)\n+{\n+\tchar buf[16];\n+\tchar *pos;\n+\n+\tpos = buf;\n+\tutf16_utf8_strcpy(&pos, c1);\n+\tif (pos - buf != 6)\n+\t\treturn 1;\n+\tif (strcmp(buf, d1))\n+\t\treturn 1;\n+\n+\tpos = buf;\n+\tutf16_utf8_strcpy(&pos, c2);\n+\tif (pos - buf != 9)\n+\t\treturn 1;\n+\tif (strcmp(buf, d2))\n+\t\treturn 1;\n+\n+\tpos = buf;\n+\tutf16_utf8_strcpy(&pos, c3);\n+\tif (pos - buf != 9)\n+\t\treturn 1;\n+\tif (strcmp(buf, d3))\n+\t\treturn 1;\n+\n+\tpos = buf;\n+\tutf16_utf8_strcpy(&pos, c4);\n+\tif (pos - buf != 12)\n+\t\treturn 1;\n+\tif (strcmp(buf, d4))\n+\t\treturn 1;\n+\n+\treturn 0;\n+}\n+\n+int ut_utf16_utf8_strncpy(void)\n+{\n+\tchar buf[16];\n+\tchar *pos;\n+\n+\tpos = buf;\n+\tmemset(buf, 0, sizeof(buf));\n+\tutf16_utf8_strncpy(&pos, c1, 4);\n+\tif (pos - buf != 4)\n+\t\treturn 1;\n+\tif (buf[4])\n+\t\treturn 1;\n+\tif (strncmp(buf, d1, 4))\n+\t\treturn 1;\n+\n+\tpos = buf;\n+\tmemset(buf, 0, sizeof(buf));\n+\tutf16_utf8_strncpy(&pos, c2, 10);\n+\tif (pos - buf != 9)\n+\t\treturn 1;\n+\tif (!buf[4])\n+\t\treturn 1;\n+\tif (strncmp(buf, d2, SIZE_MAX))\n+\t\treturn 1;\n+\n+\tpos = buf;\n+\tmemset(buf, 0, sizeof(buf));\n+\tutf16_utf8_strncpy(&pos, c3, 2);\n+\tif (pos - buf != 6)\n+\t\treturn 1;\n+\tif (buf[6])\n+\t\treturn 1;\n+\tif (strncmp(buf, d3, 6))\n+\t\treturn 1;\n+\n+\tpos = buf;\n+\tmemset(buf, 0, sizeof(buf));\n+\tutf16_utf8_strncpy(&pos, c4, 2);\n+\tif (pos - buf != 8)\n+\t\treturn 1;\n+\tif (buf[8])\n+\t\treturn 1;\n+\tif (strncmp(buf, d4, 8))\n+\t\treturn 1;\n+\n+\tpos = buf;\n+\tmemset(buf, 0, sizeof(buf));\n+\tutf16_utf8_strncpy(&pos, c4, 10);\n+\tif (pos - buf != 12)\n+\t\treturn 1;\n+\tif (!buf[5])\n+\t\treturn 1;\n+\tif (strncmp(buf, d4, SIZE_MAX))\n+\t\treturn 1;\n+\n+\treturn 0;\n+}\n+\n+int do_ut_unicode(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])\n+{\n+\tint ret = 0;\n+\n+\tret |= ut_utf8_get();\n+\tret |= ut_utf8_put();\n+\tret |= ut_utf8_utf16_strlen();\n+\tret |= ut_utf8_utf16_strnlen();\n+\tret |= ut_utf8_utf16_strcpy();\n+\tret |= ut_utf8_utf16_strncpy();\n+\tret |= ut_utf16_get();\n+\tret |= ut_utf16_put();\n+\tret |= ut_utf16_utf8_strlen();\n+\tret |= ut_utf16_utf8_strnlen();\n+\tret |= ut_utf16_utf8_strcpy();\n+\tret |= ut_utf16_utf8_strncpy();\n+\n+\tprintf(\"Test %s\\n\", ret ? \"failed\" : \"passed\");\n+\n+\treturn ret ? CMD_RET_FAILURE : CMD_RET_SUCCESS;\n+}\n",
    "prefixes": [
        "U-Boot",
        "04/15"
    ]
}