Skip to content

Regression: sscanf() %[scanset] — returns NULL not scanned token array (re-#11281, ext/standard/formatted_io.c) #11374

Closed

Description

@PurHur

Category

stdlib · php-src-strict

Problem

sscanf() with %[...] scanset conversions returns NULL for every assignment. Zend returns a one-element array with the matched prefix. Compliance guard test/compliance/cases/stdlib/sscanf_scanset.phpt exists from #11281 (closed) but VM still fails.

./script/docker-exec.sh -- php test/repro/maintainer_gap_sscanf_scanset.php          # Zend: arrays
./script/docker-exec.sh -- php bin/vm.php test/repro/maintainer_gap_sscanf_scanset.php  # VM: NULL ❌

php-src reference

Repro

test/repro/maintainer_gap_sscanf_scanset.php:

<?php
declare(strict_types=1);
var_export(sscanf('abc123', '%[a-z]'));
var_export(sscanf('abc123', '%[a-c]'));
var_export(sscanf('xyz', '%[^0-9]'));
Call Zend VM today
'%[a-z]' on 'abc123' array(0 => 'abc') NULL ❌
'%[a-c]' on 'abc123' array(0 => 'abc') NULL ❌
'%[^0-9]' on 'xyz' array(0 => 'xyz') NULL ❌

Implementation hints (PHP-in-PHP)

  • Wire VmSscanf::scanSetConversion() through the existing formatted-io scanner in PHP; avoid new C in runtime/
  • Keep fscanf() stream path in sync once sscanf scanset works
  • Compliance: test/compliance/cases/stdlib/sscanf_scanset.phpt must pass on VM

Done when (php-src-strict)

  • All three scanset forms in repro match Zend on VM
  • sscanf_scanset.phpt green on VM

Related

Activity

  1. added
    enhancementNew feature or request
    phase-4:stdlibPhase 4 – stdlib for web apps
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jun 24, 2026
  2. PurHur commented on Jun 25, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib — batch (issues #11625, #11603, #11374)

  3. PurHur commented on Jun 25, 2026

    @PurHur
    OwnerAuthor

    Already green on master — php bin/vm.php test/repro/maintainer_gap_sscanf_scanset.php returns scanned arrays; sscanf_scanset.phpt passes. No additional code change required this run.

  4. PurHur commented on Jul 13, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib — starting this run

  5. PurHur commented on Jul 13, 2026

    @PurHur
    OwnerAuthor

    claim released: repro green on master — maintainer_gap_sscanf_scanset.php prints array(0=>'abc')/array(0=>'xyz') on VM matching Zend. Pivoting.

  6. PurHur commented on Jul 13, 2026

    @PurHur
    OwnerAuthor

    Stale vs php-src-strict — repro green on master.

    php bin/vm.php test/repro/maintainer_gap_sscanf_scanset.php
    array ( 0 => 'abc', ) array ( 0 => 'abc', ) array ( 0 => 'xyz', )
    

    Matches Zend 8.2. Compliance guard sscanf_scanset.phpt from #11281. Closed by lane-B worker triage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions