From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 3100E3857341 for ; Fri, 2 Jun 2023 06:05:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3100E3857341 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685685919; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=HY5PnC9sk0+3c3JEXA2ZOYlj13AJ1+6xB47DoL3kLbI=; b=ZR2INCyDpBw2rstLw8dNxXKg+jBroa49Gvz46XQ6jFIqfNDq6g5gtUef9PGDYKGtlLR6XI lS/vT3wdSCutje96Eq1f0p3ANqE9BT89oqhk/83rgnr9Ft/E0OS+7to3ANJwAkYSCcGEzI wLj5tDGCmhJA7/sdlL5jZFLVXcnFHwk= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-35-eqEW-EzaN12TyoL3D5wG_Q-1; Fri, 02 Jun 2023 02:05:16 -0400 X-MC-Unique: eqEW-EzaN12TyoL3D5wG_Q-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E452D3C11CDF; Fri, 2 Jun 2023 06:05:15 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4CDDA492B0A; Fri, 2 Jun 2023 06:05:15 +0000 (UTC) From: Florian Weimer To: Jayakrishna Vadayath Cc: Jayakrishna Vadayath via Libc-alpha Subject: Re: Implementation of strtok References: <87edmupgkl.fsf@oldenburg.str.redhat.com> Date: Fri, 02 Jun 2023 08:05:13 +0200 In-Reply-To: (Jayakrishna Vadayath's message of "Thu, 1 Jun 2023 22:52:56 -0700") Message-ID: <87a5xipffq.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: * 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://man7.org/linux/man-pages/man3/strtok.3.html 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