From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69EFEC4338F for ; Wed, 18 Aug 2021 14:18:42 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3322F60560; Wed, 18 Aug 2021 14:18:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3322F60560 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.sourceforge.net Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1mGMOv-0006h4-Qu; Wed, 18 Aug 2021 14:18:41 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mGMOu-0006gy-80 for linux-f2fs-devel@lists.sourceforge.net; Wed, 18 Aug 2021 14:18:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=LK8VlrRcKR0O2tJY3isCs3pM/e17RyWbKPDimZLEThA=; b=nGhDkMl30J/bApx/yi9CyncFzB Q5dTrjpiMBtYtN2lrnlxkVludAiGFYEaPVwYZcb+hZWJuNuprhcJbXdQhU2EU/smIEggRRG2wgq3a YDE8oseKUhNN7CvYXfghPA7UYcNBRWRxtAx0dycrk++BkhesjnGweUXMU70+e5bX67Bw=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=LK8VlrRcKR0O2tJY3isCs3pM/e17RyWbKPDimZLEThA=; b=cPgFHWF13t90zyBcoz//nYPIE6 voFxttYSHF8nqt8tqDB22MxZOsL3LxPGuW6xAzctYcuNI/a+YtvORWVHvxUcSMyT3Edq/o8w1G6fG 6oraol+gtbnkISif/xwQSc2/SWzMRX0SjJdjkiYMuWBazM95i4LeQHgrryTzTwoqgMWU=; Received: from casper.infradead.org ([90.155.50.34]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.3) id 1mGMOs-00081a-WE for linux-f2fs-devel@lists.sourceforge.net; Wed, 18 Aug 2021 14:18:40 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=LK8VlrRcKR0O2tJY3isCs3pM/e17RyWbKPDimZLEThA=; b=SaqTl615icihQdyj6cH4ZebOOY CqeeoB06hXy/5ZM5skyZ78sQVNip29QpdM9j85yX/SFLsWLpUAcoPHIU/Gqt5VV7SJBuNhPZfUJ8Q g9hTb0kCU+dKAcmGLsmpywLzdu+EvYilR0Ivo5PWtGU56Uj2FFBlXzonIV0iHe2SWXyCdKOw3gpLI uP60aLYIigfzV5uKBoVLPrhGQjKRmmpKqHXiW8k9Bb6phAzpp7LsS2+kShH8tQ5ZEKNLwhc14+JP4 I8P1rMGI+rnia2acIGH7zrH2dNt41qTZuaZ0Umdzua6iBCC8Kg+NQ1cMduVzkuNyK1idOLtn1pdyN 2XLJzoIw==; Received: from [2001:4bb8:188:1b1:5a9e:9f39:5a86:b20c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mGMN1-003un9-7F; Wed, 18 Aug 2021 14:17:03 +0000 From: Christoph Hellwig To: Gabriel Krisman Bertazi Date: Wed, 18 Aug 2021 16:06:47 +0200 Message-Id: <20210818140651.17181-8-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210818140651.17181-1-hch@lst.de> References: <20210818140651.17181-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html X-Headers-End: 1mGMOs-00081a-WE Subject: [f2fs-dev] [PATCH 07/11] unicode: simplify utf8len X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, Shreeya Patel , linux-f2fs-devel@lists.sourceforge.net Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net Just use the utf8nlen implementation with a (size_t)-1 len argument, similar to utf8_lookup. Also move the function to utf8-selftest.c, as it isn't used anywhere else. Signed-off-by: Christoph Hellwig --- fs/unicode/utf8-norm.c | 30 ------------------------------ fs/unicode/utf8-selftest.c | 5 +++++ fs/unicode/utf8n.h | 1 - 3 files changed, 5 insertions(+), 31 deletions(-) diff --git a/fs/unicode/utf8-norm.c b/fs/unicode/utf8-norm.c index 4b1b53391ce4..348d6e97553f 100644 --- a/fs/unicode/utf8-norm.c +++ b/fs/unicode/utf8-norm.c @@ -391,36 +391,6 @@ static utf8leaf_t *utf8lookup(const struct utf8data *data, return utf8nlookup(data, hangul, s, (size_t)-1); } -/* - * Length of the normalization of s. - * Return -1 if s is not valid UTF-8 unicode. - * - * A string of Default_Ignorable_Code_Point has length 0. - */ -ssize_t utf8len(const struct utf8data *data, const char *s) -{ - utf8leaf_t *leaf; - size_t ret = 0; - unsigned char hangul[UTF8HANGULLEAF]; - - if (!data) - return -1; - while (*s) { - leaf = utf8lookup(data, hangul, s); - if (!leaf) - return -1; - if (utf8agetab[LEAF_GEN(leaf)] > data->maxage) - ret += utf8clen(s); - else if (LEAF_CCC(leaf) == DECOMPOSE) - ret += strlen(LEAF_STR(leaf)); - else - ret += utf8clen(s); - s += utf8clen(s); - } - return ret; -} -EXPORT_SYMBOL(utf8len); - /* * Length of the normalization of s, touch at most len bytes. * Return -1 if s is not valid UTF-8 unicode. diff --git a/fs/unicode/utf8-selftest.c b/fs/unicode/utf8-selftest.c index 37f33890e012..80fb7c75acb2 100644 --- a/fs/unicode/utf8-selftest.c +++ b/fs/unicode/utf8-selftest.c @@ -160,6 +160,11 @@ static const struct { } }; +static ssize_t utf8len(const struct utf8data *data, const char *s) +{ + return utf8nlen(data, s, (size_t)-1); +} + static void check_utf8_nfdi(void) { int i; diff --git a/fs/unicode/utf8n.h b/fs/unicode/utf8n.h index e4c8a767cf7a..41182e5464df 100644 --- a/fs/unicode/utf8n.h +++ b/fs/unicode/utf8n.h @@ -39,7 +39,6 @@ extern const struct utf8data *utf8nfdicf(unsigned int maxage); * Returns 0 if only ignorable code points are present. * Returns -1 if the input is not valid UTF-8. */ -extern ssize_t utf8len(const struct utf8data *data, const char *s); extern ssize_t utf8nlen(const struct utf8data *data, const char *s, size_t len); /* Needed in struct utf8cursor below. */ -- 2.30.2 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54D28C4320A for ; Wed, 18 Aug 2021 14:22:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3E46F60560 for ; Wed, 18 Aug 2021 14:22:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239220AbhHROXY (ORCPT ); Wed, 18 Aug 2021 10:23:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239433AbhHROXS (ORCPT ); Wed, 18 Aug 2021 10:23:18 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95E14C07E5E0; Wed, 18 Aug 2021 07:18:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=LK8VlrRcKR0O2tJY3isCs3pM/e17RyWbKPDimZLEThA=; b=SaqTl615icihQdyj6cH4ZebOOY CqeeoB06hXy/5ZM5skyZ78sQVNip29QpdM9j85yX/SFLsWLpUAcoPHIU/Gqt5VV7SJBuNhPZfUJ8Q g9hTb0kCU+dKAcmGLsmpywLzdu+EvYilR0Ivo5PWtGU56Uj2FFBlXzonIV0iHe2SWXyCdKOw3gpLI uP60aLYIigfzV5uKBoVLPrhGQjKRmmpKqHXiW8k9Bb6phAzpp7LsS2+kShH8tQ5ZEKNLwhc14+JP4 I8P1rMGI+rnia2acIGH7zrH2dNt41qTZuaZ0Umdzua6iBCC8Kg+NQ1cMduVzkuNyK1idOLtn1pdyN 2XLJzoIw==; Received: from [2001:4bb8:188:1b1:5a9e:9f39:5a86:b20c] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mGMN1-003un9-7F; Wed, 18 Aug 2021 14:17:03 +0000 From: Christoph Hellwig To: Gabriel Krisman Bertazi Cc: Shreeya Patel , linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Subject: [PATCH 07/11] unicode: simplify utf8len Date: Wed, 18 Aug 2021 16:06:47 +0200 Message-Id: <20210818140651.17181-8-hch@lst.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210818140651.17181-1-hch@lst.de> References: <20210818140651.17181-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Just use the utf8nlen implementation with a (size_t)-1 len argument, similar to utf8_lookup. Also move the function to utf8-selftest.c, as it isn't used anywhere else. Signed-off-by: Christoph Hellwig --- fs/unicode/utf8-norm.c | 30 ------------------------------ fs/unicode/utf8-selftest.c | 5 +++++ fs/unicode/utf8n.h | 1 - 3 files changed, 5 insertions(+), 31 deletions(-) diff --git a/fs/unicode/utf8-norm.c b/fs/unicode/utf8-norm.c index 4b1b53391ce4..348d6e97553f 100644 --- a/fs/unicode/utf8-norm.c +++ b/fs/unicode/utf8-norm.c @@ -391,36 +391,6 @@ static utf8leaf_t *utf8lookup(const struct utf8data *data, return utf8nlookup(data, hangul, s, (size_t)-1); } -/* - * Length of the normalization of s. - * Return -1 if s is not valid UTF-8 unicode. - * - * A string of Default_Ignorable_Code_Point has length 0. - */ -ssize_t utf8len(const struct utf8data *data, const char *s) -{ - utf8leaf_t *leaf; - size_t ret = 0; - unsigned char hangul[UTF8HANGULLEAF]; - - if (!data) - return -1; - while (*s) { - leaf = utf8lookup(data, hangul, s); - if (!leaf) - return -1; - if (utf8agetab[LEAF_GEN(leaf)] > data->maxage) - ret += utf8clen(s); - else if (LEAF_CCC(leaf) == DECOMPOSE) - ret += strlen(LEAF_STR(leaf)); - else - ret += utf8clen(s); - s += utf8clen(s); - } - return ret; -} -EXPORT_SYMBOL(utf8len); - /* * Length of the normalization of s, touch at most len bytes. * Return -1 if s is not valid UTF-8 unicode. diff --git a/fs/unicode/utf8-selftest.c b/fs/unicode/utf8-selftest.c index 37f33890e012..80fb7c75acb2 100644 --- a/fs/unicode/utf8-selftest.c +++ b/fs/unicode/utf8-selftest.c @@ -160,6 +160,11 @@ static const struct { } }; +static ssize_t utf8len(const struct utf8data *data, const char *s) +{ + return utf8nlen(data, s, (size_t)-1); +} + static void check_utf8_nfdi(void) { int i; diff --git a/fs/unicode/utf8n.h b/fs/unicode/utf8n.h index e4c8a767cf7a..41182e5464df 100644 --- a/fs/unicode/utf8n.h +++ b/fs/unicode/utf8n.h @@ -39,7 +39,6 @@ extern const struct utf8data *utf8nfdicf(unsigned int maxage); * Returns 0 if only ignorable code points are present. * Returns -1 if the input is not valid UTF-8. */ -extern ssize_t utf8len(const struct utf8data *data, const char *s); extern ssize_t utf8nlen(const struct utf8data *data, const char *s, size_t len); /* Needed in struct utf8cursor below. */ -- 2.30.2