summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2007-07-08 00:25:59 -0700
committerJunio C Hamano <gitster@pobox.com>2007-07-08 00:25:59 -0700
commitd3a93dc96786847f9d148da42ecadee5f027c9a7 (patch)
treeabe8893187c9abedff255ac59cec02b9463ebf1d /diff.c
parentc956395e2bf94a50fe843935605914573f4c7787 (diff)
downloadgit-d3a93dc96786847f9d148da42ecadee5f027c9a7.tar.gz
diff.c: make built-in hunk header pattern a separate table
This would hopefully make it easier to maintain. Initially we would have "java" and "tex" defined, as they are the only ones we already have. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/diff.c b/diff.c
index b8473f58fb..cd6b0c4e0b 100644
--- a/diff.c
+++ b/diff.c
@@ -1216,9 +1216,22 @@ static const char *funcname_pattern(const char *ident)
return NULL;
}
+static struct builtin_funcname_pattern {
+ const char *name;
+ const char *pattern;
+} builtin_funcname_pattern[] = {
+ { "java", "!^[ ]*\\(catch\\|do\\|for\\|if\\|instanceof\\|"
+ "new\\|return\\|switch\\|throw\\|while\\)\n"
+ "^[ ]*\\(\\([ ]*"
+ "[A-Za-z_][A-Za-z_0-9]*\\)\\{2,\\}"
+ "[ ]*([^;]*$\\)" },
+ { "tex", "^\\(\\\\\\(sub\\)*section{.*\\)$" },
+};
+
static const char *diff_funcname_pattern(struct diff_filespec *one)
{
const char *ident, *pattern;
+ int i;
diff_filespec_check_attr(one);
ident = one->funcname_pattern_ident;
@@ -1240,12 +1253,9 @@ static const char *diff_funcname_pattern(struct diff_filespec *one)
* And define built-in fallback patterns here. Note that
* these can be overriden by the user's config settings.
*/
- if (!strcmp(ident, "java"))
- return "!^[ ]*\\(catch\\|do\\|for\\|if\\|instanceof\\|"
- "new\\|return\\|switch\\|throw\\|while\\)\n"
- "^[ ]*\\(\\([ ]*"
- "[A-Za-z_][A-Za-z_0-9]*\\)\\{2,\\}"
- "[ ]*([^;]*$\\)";
+ for (i = 0; i < ARRAY_SIZE(builtin_funcname_pattern); i++)
+ if (!strcmp(ident, builtin_funcname_pattern[i].name))
+ return builtin_funcname_pattern[i].pattern;
return NULL;
}