1
0
Fork 0

fix #275: struct parser for one line struct definition

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@891 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
3.0
Xuefer 11 years ago
parent 9c4d0397d8
commit ccd134de1e

@ -8,6 +8,7 @@ ChangeLog
* support for PHP_5_4
* reduce memory usage by caching 1 for multiple same content files
* correct __FILE__ __DIR__ supported for hardlinked files
* fixed #275: one line struct definition was confusing struct parser
* fixed #102: segv when var cacher is too small
* fixed #55: segv php tokenizer on certain special situation
* compiler errors: all compiler warning (E_STRICT only currently) is now cached and is supported for user handler

@ -10,6 +10,20 @@ function printstruct(structname) {
printf "define(`COUNTOF_%s', `%s')\n", structname, COUNTOF[structname];
printf "define(`SIZEOF_%s', `( %s )')\n", structname, SIZEOF[structname];
}
function countBrace(text, len, i, char, braceCount) {
len = length(text);
braceCount = 0;
for (i = 1; i <= len; ++i) {
char = substr(text, i, 1);
if (char == "{") {
braceCount = braceCount + 1;
}
else if (char == "}") {
braceCount = braceCount - 1;
}
}
return braceCount;
}
# multiline comment handling
{
@ -75,11 +89,8 @@ incomment {
next;
}
/.\{/ {
brace = brace + 1;
}
/.}/ {
brace = brace - 1;
/.[{}]/ {
brace += countBrace($0);
}
{
@ -169,13 +180,33 @@ incomment {
next;
}
/^typedef struct .*\{[^}]*$/ {
brace = 1;
instruct = 1;
brace = countBrace($0);
if (brace > 0) {
instruct = 1;
}
else {
brace = 0;
instruct = 0;
}
for (i in buffer) {
delete buffer[i];
}
next;
}
/^struct .*\{/ {
instruct = $2;
brace = 1;
/^struct .*\{.*/ {
brace = countBrace($0);
if (brace > 0) {
instruct = $2;
}
else {
brace = 0;
instruct = 0;
}
for (i in buffer) {
delete buffer[i];
}
next;
}

Loading…
Cancel
Save