From patchwork Thu Feb 10 07:05:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 541392 Delivered-To: patch@linaro.org Received: by 2002:ad5:420f:0:0:0:0:0 with SMTP id e15csp2005441imo; Wed, 9 Feb 2022 23:05:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJxDD0IYUI+NPJrON8JCdN1RH5p7EihkX/qKu/xqmUq1h6E6603r5Qm1vsF2xizBnhJYsw/8 X-Received: by 2002:aa7:ca4d:: with SMTP id j13mr7018205edt.400.1644476753730; Wed, 09 Feb 2022 23:05:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644476753; cv=none; d=google.com; s=arc-20160816; b=VCd4gwD9ZnSlqB24iIUGehtXvoW7Lp3oIS/WMWxcfAmQfGvq4/KNH+/LdVfz2EEXut l3DYkWr5ufyFMd56vzYGCY3D9HDa0r+wnQIrxpjrE4MZnb3uArmI1X9cyie/ldK/txCd SYhyAZEiXoe9D1+Vjg8SJzwvQuPvp1R5mpf4ByuGpPHecTGdT6cS7u5gEWbF432/AERV k/gi3y9PjAE/F2v0vXcJc+KutRQSF4TL6j8aKNwQSynmIvj4UBiMI3jLp/5f16zZ8r/u SKPI0wehy5CTPfVHG6EwkGUjBZrouF5XSAtWJa5G4QSNK5EvkTG6JpEzFLkL8AT+jZ7f dJjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=uN804H7feKjwfjiQ39lrF1mzhZ031CihIH/+w/eoAuQ=; b=PLwXc55WWpcWZhqZmCjR8SMV9S8cYDCi5hMWy1eZ32ORwuc8VcTvGpqOh8KNKdoMAL zs5K3lTH77B0RKqpxHHMfj8ZTTfnXEaDkvhh2L5dKV5JP0u3FoNnDxA/3SARrcMZ0NtS BCdB+X4XlgrpnXb8aHy3kEoIzWyTUt2Ycr41uWkh+YvmZRzztra5a72O5oS513oE4YfX rWPXuB/qZvKunIDFsBTSxbGBlf1s+q1deOJGSkSpzQ0A8AdbDRXYlvPoSr0pKAa+59cO Myv55UtlGCP4AS3ccpJO9cjgg25VKWm2ySg4QlUVu1DX/a/teN3eVi5289Vwy5ZCvgPr uszA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YQVAc0wg; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id f19si15383693edd.169.2022.02.09.23.05.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 23:05:53 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YQVAc0wg; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 76E2F81F4D; Thu, 10 Feb 2022 08:05:36 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="YQVAc0wg"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A1ABC80FDE; Thu, 10 Feb 2022 08:05:31 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id C16FF80FDE for ; Thu, 10 Feb 2022 08:05:27 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=masahisa.kojima@linaro.org Received: by mail-pl1-x62c.google.com with SMTP id y17so1058917plg.7 for ; Wed, 09 Feb 2022 23:05:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=uN804H7feKjwfjiQ39lrF1mzhZ031CihIH/+w/eoAuQ=; b=YQVAc0wgpY3y33ozs1JLfoivvkYVWCtQhHTt3byXc1x84QQIOPE9uF0hSHbqplOeQI rjfos05sjKg8uOwCDEjts4MNtUaE7r/sW6r3mFMz0gSw0A105DEVcNBomtP0IqefJGSU hLqak5AmeYE8SzFKP9pmS7d458jF67WI8KbqKdS9rHQS+JJGZfl8+JX2LSw2E6D/Ldrk 0s+Xj0PnZ9+vc8jRJMNp2fX2vsSR7txBDN/X6RVcuxYWc+vBeJb/uIbUVnQWdQ835qUU 7v7jNM8BlfYG2YLT4yYa5keIQVlzfloHo7Ivic9Rl6OuudBOC5tKL5A9kl78MjLSfJ7t lRqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=uN804H7feKjwfjiQ39lrF1mzhZ031CihIH/+w/eoAuQ=; b=v0DY65Vq5GS3GDdlWDYz787yojqkcF0f1IVl19A963HU2k4AtfGJkv/TpfyQCOGMOn Q7W5zhoicqB7uljTP8TUzfuAi4SnZ+3UMfog2dCv7Kasi65zqwiveVaNUNXL5NOiQzF7 1RmqwYUB7ZjOx1DypRptlvMck31sguqfPKUQGWgB9RbD6rGONzsa3332yBmrQMlvRbRW 4DD8FO1keefWUdOaAlxbDOckBQLke6Hq7+HPhzI7gzW9/MO10ieNXGjVxzyMpUJ/Yp0l B6ZVqfr3ZqafBzQpnqe/8FX1NcfDAcwHikpZNX3skSJb/vxClj5GUbgApo6a5scM2kCk Fg2g== X-Gm-Message-State: AOAM531f+rOUY/P651mpB+7nUTsJ/1+dkir01Mir7rBnaO9518HwlGj4 zOk43Bi9HAUIjAVouuUxsAnVRG7aTpdMew== X-Received: by 2002:a17:90b:188a:: with SMTP id mn10mr1319732pjb.186.1644476726198; Wed, 09 Feb 2022 23:05:26 -0800 (PST) Received: from localhost.localdomain ([2400:2411:502:a100:82fa:5bff:fe4b:26b1]) by smtp.gmail.com with ESMTPSA id q1sm984428pjd.48.2022.02.09.23.05.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 23:05:25 -0800 (PST) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Takahiro Akashi , Francois Ozog , Mark Kettenis , Masahisa Kojima Subject: [PATCH 2/3] lib/charset: add u16_strcat() function Date: Thu, 10 Feb 2022 16:05:35 +0900 Message-Id: <20220210070537.28667-3-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220210070537.28667-1-masahisa.kojima@linaro.org> References: <20220210070537.28667-1-masahisa.kojima@linaro.org> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean Provide u16 string version of strcat(). Signed-off-by: Masahisa Kojima --- include/charset.h | 13 +++++++++++++ lib/charset.c | 12 ++++++++++++ 2 files changed, 25 insertions(+) diff --git a/include/charset.h b/include/charset.h index b93d023092..baba9d7c14 100644 --- a/include/charset.h +++ b/include/charset.h @@ -259,6 +259,19 @@ u16 *u16_strcpy(u16 *dest, const u16 *src); */ u16 *u16_strdup(const void *src); +/** + * u16_strcat() - append u16 string + * + * Append the src string to the dest string, overwriting the terminating + * null word at the end of dest, and then adds a terminating null word. + * The dest string must have enough space for the result. + * + * @dest: destination buffer (null terminated) + * @src: source buffer (null terminated) + * Return: 'dest' address + */ +u16 *u16_strcat(u16 *dest, const u16 *src); + /** * utf16_to_utf8() - Convert an utf16 string to utf8 * diff --git a/lib/charset.c b/lib/charset.c index f44c58d9d8..f0eaf6c1ae 100644 --- a/lib/charset.c +++ b/lib/charset.c @@ -428,6 +428,18 @@ u16 *u16_strdup(const void *src) return new; } +u16 *u16_strcat(u16 *dest, const u16 *src) +{ + u16 *tmp = dest; + + while (*dest) + dest++; + while ((*dest++ = *src++) != u'\0') + ; + + return tmp; +} + /* Convert UTF-16 to UTF-8. */ uint8_t *utf16_to_utf8(uint8_t *dest, const uint16_t *src, size_t size) {