Skip to content

php-in-php: strnatcmp()/strnatcasecmp() — delete phpc_strnatcmp.c + phpc_strnatcasecmp.c (~155 lines) #5517

Description

@PurHur

Category

php-in-php

Problem

Natural-order string compares are implemented in ext/standard/ for VM (strnatcmp.php, strnatcasecmp.php, VmString), but JIT/AOT still pull in separate C files:

  • lib/AOT/runtime/phpc_strnatcmp.c (~72 lines)
  • lib/AOT/runtime/phpc_strnatcasecmp.c (~83 lines)

Zend reference is PHP-level string comparison; no need for permanent C tables.

php-src reference

Scope (this repo)

  • Delete both .c files; drop from lib/AOT/Linker.php
  • JIT: lower to VmString natural-order helpers (or inline LLVM from PHPlowering)
  • Keep VM semantics in ext/standard/strnatcmp.php / strnatcasecmp.php

Repro

<?php var_export(strnatcmp('2', '10'));
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
cd /compiler
php repro.php    # expect: -1
php bin/vm.php repro.php
'

Both already print -1 today; acceptance is link without C + JIT/AOT parity.

Done when

  • C files removed; targeted tests green
  • PR notes ~155 lines deleted from lib/AOT/runtime/

Activity

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:compilerCompiler / CFG / JITarea:vmVirtual machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-0:FoundationPhase 0 – foundation & DevExphase-4:stdlibPhase 4 – stdlib for web apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions