php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57025 Can't use functions that begin with _
Submitted: 2006-05-18 23:51 UTC Modified: 2006-05-19 09:46 UTC
From: tech-php at sklar dot com Assigned: wez (profile)
Status: Closed Package: ffi (PECL)
PHP Version: 5.1.2 OS:
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: tech-php at sklar dot com
New email:
PHP Version: OS:

 

 [2006-05-18 23:51 UTC] tech-php at sklar dot com
Description:
------------
I can't bind to the _getch() function in msvcrt.dll with FFI. I think this is because it begins with an underscore.

Reproduce code:
---------------
<?php
$z = new FFI("[lib='msvcrt.dll']
    int _getch();
");

while (($c = $z->_getch()) != ord("\r")) {
    $s .= chr($c);
}

print "You typed [$s]\n";

?>


Expected result:
----------------
Something similar to this, which works fine:

<?php
$z = new FFI("[lib='msvcrt.dll']
    int getchar();
");

while (($c = $z->getchar()) != ord("\r")) {
    $s .= chr($c);
}

print "You typed [$s]\n";

?>

Except that the characters wouldn't be echoed to the console, since that's how _getch() works

Actual result:
--------------
Fatal error: Call to undefined method FFI::_getch() in c:\getch.php on line 6

I am thinking that it is the leading underscore in _getch() because of the following code in the default case in parse_defs() in ffi_library.c:

if (isalpha(*c)) {
  while (isalnum(*c) || *c == '_') {
    c++;
  }

This seems to indicate that tokens must start with a letter but then can be alphanumeric or _.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-05-19 09:46 UTC] wez@php.net
This bug has been fixed in CVS.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on pecl.php.net.

In case this was a pecl.php.net website problem, the change will show
up on the website in short time.
 
Thank you for the report, and for helping us make PECL better.

Fixed in CVS.  A working version should show up on pecl4win.php.net "soonish".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC