Commit 994a3006b61e0a729569770de51d5c13af6a23ed

Arthur Schreiber 2014-10-09T22:21:34

Update the javascript diff driver's function pattern.

diff --git a/src/userdiff.h b/src/userdiff.h
index 523f2f8..91c1f42 100644
--- a/src/userdiff.h
+++ b/src/userdiff.h
@@ -191,9 +191,9 @@ PATTERNS("php",
 	 "|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->"),
 
 PATTERNS("javascript",
-	 "^[ \t]*(function[ \t][a-zA-Z_][^\\{]*)\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_$]*(\\.[a-zA-Z0-9_$]+)*[ \t]*=[ \t]*function([ \t][a-zA-Z_$][a-zA-Z0-9_$]*)?[^\\{]*)\n"
+	 "([a-zA-Z_$][a-zA-Z0-9_$]*[ \t]*:[ \t]*function([ \t][a-zA-Z_$][a-zA-Z0-9_$]*)?[^\\{]*)\n"
+	 "[^a-zA-Z0-9_\\$](function([ \t][a-zA-Z_$][a-zA-Z0-9_$]*)?[^\\{]*)",
 	 /* -- */
 	 "[a-zA-Z_][a-zA-Z0-9_]*"
 	 "|[-+0-9.e]+[fFlL]?|0[xX]?[0-9a-fA-F]+[lL]?"
diff --git a/tests/resources/userdiff/expected/driver/diff.javascript b/tests/resources/userdiff/expected/driver/diff.javascript
index 44ea9cf..4cefe5c 100644
--- a/tests/resources/userdiff/expected/driver/diff.javascript
+++ b/tests/resources/userdiff/expected/driver/diff.javascript
@@ -2,7 +2,7 @@ diff --git a/files/file.javascript b/files/file.javascript
 index 0965b37..5391797 100644
 --- a/files/file.javascript
 +++ b/files/file.javascript
-@@ -4,4 +4,3 @@
+@@ -4,4 +4,3 @@ function(require, exports, module)
    var Key = require("./key")
 -    , Direction = require("./direction")
 -    , Image = require("./image");
@@ -15,12 +15,12 @@ index 0965b37..5391797 100644
 +    this.pixelX = 10;
 +    this.pixelY = 10;
  
-@@ -82,3 +81,3 @@ function Player(game)
+@@ -82,3 +81,3 @@ Player.prototype.moveUp = function()
    Player.prototype.moveLeft = function() {
 -    this.x -= 1;
 +    this.x -= 5;
      this.direction = Direction.LEFT;
-@@ -106,3 +105,3 @@ function Player(game)
+@@ -106,3 +105,3 @@ Player.prototype.draw = function(context)
  
 -    context.drawImage(this.image.data, offsetX, offsetY, 32, 48, this.pixelX, this.pixelY - 16, 32, 48);
 +    context.drawImage(this.image.data, offsetX, offsetY, 32, 48, this.pixelX, this.pixelY, 32, 48);