summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2014-01-27 11:45:06 -0800
committerRussell Belfer <rb@github.com>2014-01-27 11:45:06 -0800
commit082e82dba5b5174756b3a5fc2e385ccc59626164 (patch)
tree9191ea9e222c54163c275e1179600b02ebe264b2 /src
parent4115987739fb9cc4dd82edd9998db6dbb6bc9d95 (diff)
downloadlibgit2-082e82dba5b5174756b3a5fc2e385ccc59626164.tar.gz
Update Javascript userdiff driver and tests
Writing a sample Javascript driver pointed out some extra whitespace handling that needed to be done in the diff driver. This adds some tests with some sample javascript code that I pulled off of GitHub just to see what would happen. Also, to clean up the userdiff test data, I did a "git gc" and packed up the test objects.
Diffstat (limited to 'src')
-rw-r--r--src/diff_driver.c1
-rw-r--r--src/userdiff.h6
2 files changed, 4 insertions, 3 deletions
diff --git a/src/diff_driver.c b/src/diff_driver.c
index 9249d1415..4c9a0af65 100644
--- a/src/diff_driver.c
+++ b/src/diff_driver.c
@@ -437,6 +437,7 @@ static int diff_context_line__pattern_match(
i = (pmatch[1].rm_so >= 0) ? 1 : 0;
git_buf_consume(line, git_buf_cstr(line) + pmatch[i].rm_so);
git_buf_truncate(line, pmatch[i].rm_eo - pmatch[i].rm_so);
+ git_buf_rtrim(line);
return true;
}
diff --git a/src/userdiff.h b/src/userdiff.h
index 93b4d0d58..2257035ac 100644
--- a/src/userdiff.h
+++ b/src/userdiff.h
@@ -193,9 +193,9 @@ PATTERNS("php",
"|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->"),
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\(].*)$",
+ "^[ \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_]*"
"|[-+0-9.e]+[fFlL]?|0[xX]?[0-9a-fA-F]+[lL]?"