Segfault with tokenizer on Win32
| From: | Sebastian Bergmann | Date: | Wed, 08 May 2002 15:47:04 +0000 |
| Subject: | Segfault with tokenizer on Win32 | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-83818@lists.php.net to get a copy of this message | ||
Does anyone have an idea why the following code crashes on Win32 in
Release_TS mode, but not in Debug_TS mode (hence no stacktrace)?
<?php
class CodeParser {
var $tokens = array();
function CodeParser($file = '') {
if (!empty($file)) {
$this->parse($file);
}
}
function parse($file) {
$this->tokens = token_get_all(
implode(
'',
file($file)
)
);
}
function getSource() {
$source = '';
$state = 0;
foreach ($this->tokens as $token) {
if (is_array($token)) {
if ($state == 1 && $token[0] == T_STRING) {
$token[1] = preg_replace(
'!([a-z])([A-Z])!e',
'"$1_".strtolower("$2")',
$token[1]
);
$state = 0;
}
else if ($token[0] == T_FUNCTION) {
$state = 1;
}
$buffer = $token[1];
} else {
$buffer = $token;
}
$source .= $buffer;
}
return $source;
}
function getTokens() {
return $this->tokens;
}
}
?>
--
Sebastian Bergmann
http://sebastian-bergmann.de/ http://phpOpenTracker.de/
Did I help you? Consider a gift: http://wishlist.sebastian-bergmann.de/