git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] diff: Support visibility modifiers in the PHP hunk header regexp

From
Björn Steinbrink <b.steinbrink@gmx.de>
Date
May 23, 2010, 18:05 UTC
Message-ID
<20100523180540.GA29729@atjola.homenet>

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>
---
 userdiff.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/userdiff.c b/userdiff.c
index 67003fb..c49cc1b 100644
--- a/userdiff.c
+++ b/userdiff.c
@@ -45,7 +45,9 @@ PATTERNS("pascal",
 	 "|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+"
 	 "|<>|<=|>=|:=|\\.\\."
 	 "|[^[:space:]]|[\x80-\xff]+"),
-PATTERNS("php", "^[\t ]*((function|class).*)",
+PATTERNS("php",
+	 "^[\t ]*(((public|protected|private|static)[\t ]+)*function.*)$\n"
+	 "^[\t ]*(class.*)$",
 	 /* -- */
 	 "[a-zA-Z_][a-zA-Z0-9_]*"
 	 "|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+"
-- 
1.7.1.227.g12cb1
Message 1 of 1 in “diff: Support visibility modifiers in the PHP hunk header regexp”
  1. diff: Support visibility modifiers in the PHP hunk header regexpBjörn Steinbrink, May 23, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.