Commit 7cc001cefb787ddacb53c74a94173674ac6bd587

Russell Belfer 2014-01-24T15:46:15

Add PHP and Javascript diff drivers Since I don't have permission yet on the code from Git, I decided I'd take a stab at writing patterns for PHP and Javascript myself. I think these are pretty weak, but probably better than the default behavior without them.

diff --git a/src/userdiff.h b/src/userdiff.h
index 1f23185..3187615 100644
--- a/src/userdiff.h
+++ b/src/userdiff.h
@@ -180,6 +180,22 @@ PATTERNS("csharp",
 	 "[a-zA-Z_][a-zA-Z0-9_]*"
 	 "|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?"
 	 "|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->"),
+
+PATTERNS("php",
+	 "^[ \t]*((public|private|protected|static|final)[ \t]+)*((class|function)[ \t].*)$",
+	 /* -- */
+	 "[a-zA-Z_][a-zA-Z0-9_]*"
+	 "|[-+0-9.e]+[fFlL]?|0[xX]?[0-9a-fA-F]+[lL]?"
+	 "|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->"),
+
+PATTERNS("javascript",
+	 "^[ \t]*(\(?function[ \t].*)$\n"
+	 "^[ \t]*(var[ \t]+[a-zA-Z_][a-zA-Z0-9_]*[ \t]*=[ \t]*function[ \t\(].*)$\n"
+	 "^[ \t]*([a-zA-Z_][a-zA-Z0-9_]*[ \t]*:[ \t]*function[ \t\(].*)$",
+	 /* -- */
+	 "[a-zA-Z_][a-zA-Z0-9_]*"
+	 "|[-+0-9.e]+[fFlL]?|0[xX]?[0-9a-fA-F]+[lL]?"
+	 "|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->"),
 };
 
 #undef IPATTERN