@matheusbsbs / matheus-bagliano / commits / 6d2f208c3d
Fork 0

diff: Support visibility modifiers in the PHP hunk header regexp

Starting with PHP5, class methods can have a visibility modifier, which caused the methods not to be matched by the existing regexp, so extend the regexp to match those modifiers. And while we're at it, allow the "static" modifier as well. Since the "static" modifier can appear either before or after the visibility modifier, let's just allow any number of modifiers to appear in any order, as that simplifies the regexp and shouldn't cause any false positives. Signed-off-by: Björn Steinbrink <B.Steinbrink@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Björn Steinbrink committed May 23, 2010 at 20:05 UTC 6d2f208c3dd39493f4d45ea67c55a1b7fe06626a
1 file changed +3 -1
userdiff.c
+3 -1
@@ -44,7 +44,9 @@ PATTERNS("pascal",
44 "|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+"
45 "|<>|<=|>=|:=|\\.\\."
46 "|[^[:space:]]|[\x80-\xff]+"),
47 -PATTERNS("php", "^[\t ]*((function|class).*)",
47 +PATTERNS("php",
48 + "^[\t ]*(((public|protected|private|static)[\t ]+)*function.*)$\n"
49 + "^[\t ]*(class.*)$",
50 /* -- */
51 "[a-zA-Z_][a-zA-Z0-9_]*"
52 "|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+"