Newsgroups: php.internals,php.internals Path: news.php.net Xref: news.php.net php.internals:131006 php.internals:131007 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: by lists.php.net (Postfix, from userid 65534) id 0330F1A00BD; Sun, 24 May 2026 22:55:00 +0000 (UTC) To: internals@lists.php.net,internals@lists.php.net Message-ID: Date: Mon, 25 May 2026 00:55:00 +0200 Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] Documenting sscanf()'s and fscanf's underflow Content-Language: en-GB References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 86.92.4.88 From: jordikroon@me.com (Jordi Kroon) On 24/05/2026 10:38 pm, mickmackusa wrote: > Hi all, may I request that the documentation pages for sscanf() and > fscanf() be reviewed? > > Last week, I tripped over a bug in my code because, despite using and > loving sscanf() for many years, the function unexpectedly returned -1 > for the number of successful captures when I expected 0. > > I've documented the encounter here: https://stackoverflow.com/ > q/79942833/2943403 > > I have been doing a fair amount of Google searching, but either my > keywords are not ideal or there really is no mention of this floating > around (even the C++ pages that I read don't mention it). > > Thanks, > mickmackusa `sscanf()` and `fscanf()` may return -1 when the end of the input is reached before any value has been successfully parsed. That behaviour is currently missing from the documentation. I opened a PR to cover this: https://github.com/php/doc-en/pull/5580 Specific commit: https://github.com/php/doc-en/commit/7af7c98e4f7c983581dc05c58b958bb6c0c1267b Feel free to check and reply in the PR conversation if you think the wording should be adjusted. -- Regards, Jordi Kroon