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 Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DBCA4C433EF for ; Sun, 6 Mar 2022 03:10:09 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DD4F083D05; Sun, 6 Mar 2022 04:09:16 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Z/QuCycK"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A088883BD4; Sun, 6 Mar 2022 04:08:47 +0100 (CET) Received: from mail-oo1-xc2d.google.com (mail-oo1-xc2d.google.com [IPv6:2607:f8b0:4864:20::c2d]) (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 DFF2183C4D for ; Sun, 6 Mar 2022 04:08:34 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@google.com Received: by mail-oo1-xc2d.google.com with SMTP id 6-20020a4a0906000000b0031d7eb98d31so13881985ooa.10 for ; Sat, 05 Mar 2022 19:08:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=oiVkggSXUJQIebz3As9glzRQ8oyZ8N2ESTDaz8DinWg=; b=Z/QuCycKzjKkT51LYBUtrO9iziupay9zPqfNfw/3gHhznZ+O0HMrXsL3jDb3/W+nDl EWb54dG/uzxSDovUTKyDL5LEQlCHgmfZsCdGJHS2LjT3fabhNBs9gGO+5De9IVhOnwt3 uGcXQNbYjuWt1jmL/20gsxVIfOTjoS7BrkR4g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=oiVkggSXUJQIebz3As9glzRQ8oyZ8N2ESTDaz8DinWg=; b=ZcoNZA1l+77noN5aF+9OdRhrl1g1bKOSh9Gl7k6+L3V5KOSCVjrkVFCECyV3xWQRKQ MymE5Ib+V6VWkJx5lk39Sb9hCxWzFJBpy4iBO6rpTwqizqnfekEc2ZNzDgv0s05+o8/D xkFZ+Uq1TMVJn+Ln1VaKeAlMUHJNl0N2Vr3WCUUIPZLaAHmTt/Bh/wQV9NnfhWTI2noV sHqQ9TrvK/rlMxX8K9aMWASQlYHi8Pl0YyuBxfHX+s/8pbCY/CXD2K3YuqTxP4rX934D R/mGWJq4VECXGR1JOG182u1zDkOjItLQ69OxcdqMbjtcVKphtB4lN/cvEZ7JoO1xxckT MWig== X-Gm-Message-State: AOAM5317OfWDVpmxJ30qHLGI0uR4pdc/nmV1JZ4NyZpr0JYMNXupB6Ge 1oK5jmL57vw8LywjF6jgr1QIvnwDteHMvI08mpOwjw== X-Google-Smtp-Source: ABdhPJy1TdRykhqR9FgqJmKLSnWf50UlETx3y11/QkRvL8mxfnDHuPedKnR2OgMGR5Q5ZFvwCh8VcZerLcKHxpLzpmo= X-Received: by 2002:a05:6870:14cf:b0:d9:a9ce:92a9 with SMTP id l15-20020a05687014cf00b000d9a9ce92a9mr2721198oab.64.1646536113328; Sat, 05 Mar 2022 19:08:33 -0800 (PST) MIME-Version: 1.0 References: <20220119014315.1938157-1-sjg@chromium.org> <20220119014315.1938157-5-sjg@chromium.org> <8d8796be-f5ad-15ed-4a03-97519f9c172c@gmx.de> <20220120031605.GC42867@laputa> In-Reply-To: <20220120031605.GC42867@laputa> From: Simon Glass Date: Sat, 5 Mar 2022 20:08:21 -0700 Message-ID: Subject: Re: [PATCH v3 04/31] lib: Add a way to find the postiion of a trailing number To: AKASHI Takahiro , Heinrich Schuchardt , Simon Glass , U-Boot Mailing List , Ilias Apalodimas , Daniel Schwierzeck , Dennis Gilmore , Steffen Jaeckel , Lukas Auer , Michal Simek , Tom Rini Content-Type: text/plain; charset="UTF-8" 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 Hi Takahiro, On Wed, 19 Jan 2022 at 20:16, AKASHI Takahiro wrote: > > On Wed, Jan 19, 2022 at 12:27:09PM +0100, Heinrich Schuchardt wrote: > > On 1/19/22 02:42, Simon Glass wrote: > > > At present it is not possible to find out which part of the string is the > > > number part and which is before it. Add a new variant which provides this > > > feature, so we can separate the two in the caller. > > > > > > Signed-off-by: Simon Glass > > > --- > > > > > > Changes in v3: > > > - Change the function to return a pointer to the first digit > > > - Add some tests, including one for 'abc123def456' > > > > > > include/vsprintf.h | 18 ++++++++++++++++++ > > > lib/strto.c | 14 ++++++++++++-- > > > test/str_ut.c | 13 ++++++++++++- > > > 3 files changed, 42 insertions(+), 3 deletions(-) > > > > > > diff --git a/include/vsprintf.h b/include/vsprintf.h > > > index 01d2248e04d..ce7a7aaa1cc 100644 > > > --- a/include/vsprintf.h > > > +++ b/include/vsprintf.h > > > @@ -118,6 +118,24 @@ long trailing_strtol(const char *str); > > > */ > > > long trailing_strtoln(const char *str, const char *end); > > > > > > +/** > > > + * trailing_strtoln_end() - extract trailing integer from a fixed-length string > > > + * > > > + * Given a fixed-length string this finds a trailing number on the string > > > + * and returns it. For example, "abc123" would return 123. Only the > > > + * characters between @str and @end - 1 are examined. If @end is NULL, it is > > > + * set to str + strlen(str). > > > + * > > > + * @str: String to exxamine > > > + * @end: Pointer to end of string to examine, or NULL to use the > > > + * whole string > > > + * @endp: If non-NULL, this is set to point to the character where the > > > + * number starts, e.g. for "mmc0" this would be point to the '0'; if no > > > + * trailing number is found, it is set to the end of the string > > > + * @return training number if found, else -1 > > > > Return: > > > > https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html#function-documentation > > One of other common mistakes(?) that I can see in the repository is > a violation of the rule below: > ===8<=== > Function parameters > ~~~~~~~~~~~~~~~~~~~ > > Each function argument should be described in order, immediately following > ^^^^^^^^^^^^^^^^^^^^^ > the short function description. Do not leave a blank line between the > function description and the arguments, nor between the arguments. > ===>8=== > > For instance, in this patch, > > > +/** > > > + * trailing_strtoln_end() - extract trailing integer from a fixed-length string > > > + * > > > + * Given a fixed-length string this finds a trailing number on the string > > > + * and returns it. For example, "abc123" would return 123. Only the > > > + * characters between @str and @end - 1 are examined. If @end is NULL, it is > > > + * set to str + strlen(str). > > > + * > > > + * @str: String to exxamine > (snip) > > The structure of trailing_strtoln_end() looks like: > > > > > > > Doesn't this matter so far in formatting Sphinx texts? It doesn't seem to, luckily. I'm not too impressed with how simplistic Sphinx is with formatting, but it seems OK in that case. Regards, Simon