Skip to content

Stdlib: sscanf()/fscanf() %[scanset] conversion — rejected, scansets unsupported (ext/standard/formatted_io.c) #11281

Closed

Description

@PurHur

Category

stdlib · php-src-strict

Problem

sscanf() must support %[...] scanset conversions (character classes, negation, ranges) per php-src formatted_io.c. This compiler rejects any %[ format with ValueError: Bad scan conversion character "[" instead of returning the matched prefix.

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]'));
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro/maintainer_gap_sscanf_scanset.php
php bin/vm.php test/repro/maintainer_gap_sscanf_scanset.php'
Format Zend PHP 8.2 This compiler VM
%[a-z] on abc123 ['abc'] ValueError ❌
%[a-c] on abc123 ['abc'] ValueError ❌
%[^0-9] on xyz ['xyz'] ValueError ❌

Scope (PHP-in-PHP)

Layer Path
VM ext/standard/VmSscanf.php — implement scanset lexer/parser + assignment (port formatted_io.c semantics)
fscanf share scanner with VmFscanf path
Tests repro + compliance case for inclusive/negated/range scansets

Done when (php-src-strict)

  • Repro scansets return Zend-matching prefixes; trailing input left unconsumed as in php-src.
  • Related length-modifier gaps (%ld, %hhd, …) may be separate issues; this ticket is scanset-only.

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 24, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib — batch (issues #11187, #11281)

  3. PurHur commented on Jun 24, 2026

    @PurHur
    OwnerAuthor

    Merged #11318 — %[scanset] inclusive/negated/range conversions in VmSscanf; repro + compliance green on VM and AOT lint.

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