PHP: Recognize vertical tab (\v) and form-feed (\f) as whitespaces
Even though PHP doesn't handle those very well (it emits warnings about "unexpected character"), it still counts them as whitespaces, so properly handle them as such.
This commit is contained in:
parent
0101365b1f
commit
6063e077c3
@ -672,9 +672,15 @@ static keywordId analyzeToken (vString *const name, langType language)
|
||||
return result;
|
||||
}
|
||||
|
||||
static boolean isSpace (int c)
|
||||
{
|
||||
return (c == '\t' || c == ' ' || c == '\v' ||
|
||||
c == '\n' || c == '\r' || c == '\f');
|
||||
}
|
||||
|
||||
static int skipWhitespaces (int c)
|
||||
{
|
||||
while (c == '\t' || c == ' ' || c == '\n' || c == '\r')
|
||||
while (isSpace (c))
|
||||
c = fileGetc ();
|
||||
return c;
|
||||
}
|
||||
@ -695,10 +701,7 @@ static boolean isOpenScriptLanguagePhp (int c)
|
||||
tolower ((c = fileGetc ())) != 'i' ||
|
||||
tolower ((c = fileGetc ())) != 'p' ||
|
||||
tolower ((c = fileGetc ())) != 't' ||
|
||||
((c = fileGetc ()) != '\t' &&
|
||||
c != ' ' &&
|
||||
c != '\n' &&
|
||||
c != '\r') ||
|
||||
! isSpace ((c = fileGetc ())) ||
|
||||
tolower ((c = skipWhitespaces (c))) != 'l' ||
|
||||
tolower ((c = fileGetc ())) != 'a' ||
|
||||
tolower ((c = fileGetc ())) != 'n' ||
|
||||
@ -806,10 +809,7 @@ getNextChar:
|
||||
else
|
||||
c = fileGetc ();
|
||||
|
||||
while (c == '\t' || c == ' ' || c == '\n' || c == '\r')
|
||||
{
|
||||
c = fileGetc ();
|
||||
}
|
||||
c = skipWhitespaces (c);
|
||||
|
||||
token->lineNumber = getSourceLineNumber ();
|
||||
token->filePosition = getInputFilePosition ();
|
||||
|
@ -231,6 +231,7 @@ test_sources = \
|
||||
traits.php \
|
||||
union.f \
|
||||
value.f \
|
||||
whitespaces.php \
|
||||
$(NULL)
|
||||
test_results = $(test_sources:=.tags)
|
||||
|
||||
|
34
tests/ctags/whitespaces.php
Normal file
34
tests/ctags/whitespaces.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
function a () {}
|
||||
|
||||
function
|
||||
b
|
||||
()
|
||||
{}
|
||||
|
||||
functionc(){}
|
||||
|
||||
functiond(){}
|
||||
|
||||
function
e
()
{}
|
||||
|
||||
function f () {}
|
||||
|
||||
function
|
||||
g
|
||||
()
|
||||
{}
|
||||
|
||||
function h(){}
|
||||
|
||||
|
||||
/* for live PHP tests */
|
||||
var_dump(a());
|
||||
var_dump(b());
|
||||
var_dump(c());
|
||||
var_dump(d());
|
||||
var_dump(e());
|
||||
var_dump(f());
|
||||
var_dump(g());
|
||||
var_dump(h());
|
9
tests/ctags/whitespaces.php.tags
Normal file
9
tests/ctags/whitespaces.php.tags
Normal file
@ -0,0 +1,9 @@
|
||||
# format=tagmanager
|
||||
aÌ16Í()Ö0
|
||||
bÌ16Í()Ö0
|
||||
cÌ16Í()Ö0
|
||||
dÌ16Í()Ö0
|
||||
eÌ16Í()Ö0
|
||||
fÌ16Í()Ö0
|
||||
gÌ16Í()Ö0
|
||||
hÌ16Í()Ö0
|
Loading…
x
Reference in New Issue
Block a user