From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw1-x1134.google.com (mail-yw1-x1134.google.com [IPv6:2607:f8b0:4864:20::1134]) by sourceware.org (Postfix) with ESMTPS id 5369F3858C2C for ; Fri, 2 Jun 2023 06:17:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5369F3858C2C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=asu.edu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=asu.edu Received: by mail-yw1-x1134.google.com with SMTP id 00721157ae682-5689335d2b6so15473647b3.3 for ; Thu, 01 Jun 2023 23:17:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=asu-edu.20221208.gappssmtp.com; s=20221208; t=1685686637; x=1688278637; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=AjBEazJjaI9o9YG0PFTVmMO9ab6gyGmvwbwVG4rtigs=; b=gS1ClH/S7pfE3y4yvUGecmCEnQLspxcjpBYTgJzI3kOUtZsNUUtpgXZ8TED492eLk5 L5Zhv7dUDQf2Ai/hcTuYntUGR5PDyjFDYIkb7v1zFYHQSLfRBMM5XIchoV6UO8MZj45q NbuBs7zDkq05GDs3DSu3q/14qTZgXmdcPwD/OOQ8U9MBQLyCpt2qi0yBSmpsE/QzkQ4y Dc9InWOpBEKrHmtqtdjc2rxd61urFYN4E87lWI4vesNYq4q52SkZ8HBCXJ727b02ruf6 RlLY03BW290l8mkP9CtOwICLkiZ9yppqEJgZ9O0W6Sc8Caj18pTvhAWL3fE5WH1ghOkE nDHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685686637; x=1688278637; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=AjBEazJjaI9o9YG0PFTVmMO9ab6gyGmvwbwVG4rtigs=; b=d8dGd0GYSXWEtxkaKxwlCz630A4VlxZSqmE8J5SaQa8YKryjP+rYx9uSau+aRJf5PI XE0WdC6IVRph4gdVK9/QnhGiXXtUQQ1zbXNnclttBp9RuByV4O2yJ+dez4sKG3RPFqP3 4512nCaW3XxLjLRFmD9YXKziT5EVShZfEwcM2zys+M1bX69zDQ8hQEIPVvE+ANXQn8Bs 5i6CSenewIZ9sjVxpptCnqbnPLyeo9gEiQ+2ZwjlJwQhNn5zzsI8wcRQX6JxYRLqzxE6 QtuUOn2PqyFef1m74wHlzvyUR+rgaCt5iyIVPtMdV04pYFzWqulxhFW3FpmCkhcBanqz wxuA== X-Gm-Message-State: AC+VfDySH5J4m3A0G5GqGab3mj5oCXge3yjVmf6yTT5Ts2qbPZhSlI0G /maP0KmYV2F093Y9NlAFL/aaXexSiWzifxYgjyCsrg7i1uMoEM3K X-Google-Smtp-Source: ACHHUZ6n3Q3EVT75NtytUkD6l5Mr9x4lS4NSvUQizO1JGDBzanSVy6Ji3oq94L6xdBu8kEm+ZC4sasr/8uPjKQouBi0= X-Received: by 2002:a0d:cac9:0:b0:565:c1a7:d197 with SMTP id m192-20020a0dcac9000000b00565c1a7d197mr11431361ywd.39.1685686637369; Thu, 01 Jun 2023 23:17:17 -0700 (PDT) MIME-Version: 1.0 References: <87edmupgkl.fsf@oldenburg.str.redhat.com> <87a5xipffq.fsf@oldenburg.str.redhat.com> In-Reply-To: <87a5xipffq.fsf@oldenburg.str.redhat.com> From: Jayakrishna Vadayath Date: Thu, 1 Jun 2023 23:17:05 -0700 Message-ID: Subject: Re: Implementation of strtok To: Florian Weimer Cc: Jayakrishna Vadayath via Libc-alpha Content-Type: multipart/alternative; boundary="000000000000392b9c05fd1f81b5" X-Spam-Status: No, score=0.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,HTML_MESSAGE,KAM_DMARC_NONE,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --000000000000392b9c05fd1f81b5 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, Thank you for your reply. I was only looking at the return value section of the documentation. However, it makes sense to me now. Thank you. On Thu, Jun 1, 2023 at 11:05=E2=80=AFPM Florian Weimer = wrote: > * Jayakrishna Vadayath: > > > The man page of strtok mention that strtok returns a pointer to the > > next token or NULL if there are no more tokens : > > > https://urldefense.com/v3/__https://man7.org/linux/man-pages/man3/strtok.= 3.html__;!!IKRxdwAv5BmarQ!bQa53ZIha6p2oe0o-luVxpSJFX4pb7VPYYq36zBLfwHYp6-jr= FmUvqu99oGfoqfG3qYlrRhyElmpVpse$ > I can see how the > > "no more tokens" would apply in this case, but it seems like not many > > people are aware of this case. > > > > Can you list the descriptions of strtok that explain this behavior ? > > This part is quite clear to me: > > | The first call to strtok() sets this pointer to point to the first > | byte of the string. The start of the next token is determined by > | scanning forward for the next nondelimiter byte in str. If such a > | byte is found, it is taken as the start of the next token. If no such > | byte is found, then there are no more tokens, and strtok() returns > | NULL. > > The last sentence is really unambiguous. Maybe it's the double > negation? > > Thanks, > Florian > > --=20 Regards Jayakrishna Menon --000000000000392b9c05fd1f81b5--