Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:45877 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 48600 invoked from network); 24 Oct 2009 16:27:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Oct 2009 16:27:35 -0000 Authentication-Results: pb1.pair.com smtp.mail=hermanradtke@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=hermanradtke@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.92.26 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: hermanradtke@gmail.com X-Host-Fingerprint: 74.125.92.26 qw-out-2122.google.com Received: from [74.125.92.26] ([74.125.92.26:46359] helo=qw-out-2122.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 65/D3-29207-6FA23EA4 for ; Sat, 24 Oct 2009 12:27:34 -0400 Received: by qw-out-2122.google.com with SMTP id 9so1107774qwb.59 for ; Sat, 24 Oct 2009 09:27:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=CT1WQzDT1qgofLUSoyXzP0vZ4HHdnQs87s46mD/cRxk=; b=HuvRSC8hkYUYdsatJR4cNQbAsXgoFCV6yeg1UnbBGdrNmDc2KEltFBFQcCfJj8jTCg Oh313xDVAOnx0aD2OTEKjpCcLpmlJxPOckVMor5GvQ8Y1Q6J33k9wh5p3uf/LUwgAjKP 1/RCqfuFgKevkKjhZoMDwawzZB4Q9dYUhtT3U= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=Td5cuREcKNfOan2oC9rw2WjwzFmKiWn0U87Swk52KuCBFMLJfGGeu6JsxgoXePiWZ2 Ir/A6ChXEGLUm8sq4snGCUNPhf1+wagZDtRNZrejeq+TwyPkqQ26pwa6AEIlJL7Wr9Np X/6mkG5q5tUHk1Nc054F4UVZEoCt6AA5GnwGc= MIME-Version: 1.0 Received: by 10.229.37.130 with SMTP id x2mr159486qcd.15.1256401651472; Sat, 24 Oct 2009 09:27:31 -0700 (PDT) Date: Sat, 24 Oct 2009 09:27:31 -0700 Message-ID: To: internals@lists.php.net Content-Type: text/plain; charset=UTF-8 Subject: differences in the way spl_autoload() works on windows and *nix with namespaces From: hermanradtke@gmail.com (Herman Radtke) It appears that spl_autoload() has implicit namespace autoloading support on windows due to the fact that the namespace operator is the same as the directory separator on windows. For example, the class foo\Bar will evaluate to the path "foo\Bar.php" on windows. I think spl_autoload() should also implicitly work on *nix to avoid confusion and allow for portability. I have started a patch below. I can provide tests if this is agreeable. Patch: Index: ext/spl/php_spl.c =================================================================== --- ext/spl/php_spl.c (revision 289895) +++ ext/spl/php_spl.c (working copy) @@ -229,8 +229,28 @@ zval *result = NULL; int ret; - class_file_len = spprintf(&class_file, 0, "%s%s", lc_name, file_extension); +#ifdef PHP_WIN32 + char *ns_name = estrndup(lc_name, class_name_len); +#else + char *ns_name; + if (strchr(lc_name, '\\')) { + ns_name = estrndup(class_name, class_name_len); + char *c = ns_name; + while(*c) { + if (*c == '\\') { + *c = '/'; + } + *c++; + } + } else { + ns_name = estrndup(lc_name, class_name_len); + } +#endif + class_file_len = spprintf(&class_file, 0, "%s%s", ns_name, file_extension); + + efree(ns_name); + ret = php_stream_open_for_zend_ex(class_file, &file_handle, ENFORCE_SAFE_MODE|USE_PATH|STREAM_OPEN_FOR_INCLUDE TSRMLS_CC); if (ret == SUCCESS) { -- Herman Radtke hermanradtke@gmail.com | http://hermanradtke.com