@matheusbsbs / matheus-bagliano / commits / 6a6baf9b4e
Fork 0

diff: use extended regexp to find hunk headers

Using ERE elements such as "|" (alternation) by backquoting in BRE is a GNU extension and should not be done in portable programs. Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Sep 19, 2008 at 23:45 UTC 6a6baf9b4e819a0bbfd70627f966cd7144dd8301
1 file changed +17 -14
diff.c
+17 -14
@@ -1399,20 +1399,23 @@ static const struct funcname_pattern_entry *funcname_pattern(const char *ident)
1399 }
1400
1401 static const struct funcname_pattern_entry builtin_funcname_pattern[] = {
1402 - { "java", "!^[ ]*\\(catch\\|do\\|for\\|if\\|instanceof\\|"
1403 - "new\\|return\\|switch\\|throw\\|while\\)\n"
1404 - "^[ ]*\\(\\([ ]*"
1405 - "[A-Za-z_][A-Za-z_0-9]*\\)\\{2,\\}"
1406 - "[ ]*([^;]*\\)$", 0 },
1407 - { "pascal", "^\\(\\(procedure\\|function\\|constructor\\|"
1408 - "destructor\\|interface\\|implementation\\|"
1409 - "initialization\\|finalization\\)[ \t]*.*\\)$"
1410 - "\\|"
1411 - "^\\(.*=[ \t]*\\(class\\|record\\).*\\)$",
1412 - 0 },
1413 - { "bibtex", "\\(@[a-zA-Z]\\{1,\\}[ \t]*{\\{0,1\\}[ \t]*[^ \t\"@',\\#}{~%]*\\).*$", 0 },
1414 - { "tex", "^\\(\\\\\\(\\(sub\\)*section\\|chapter\\|part\\)\\*\\{0,1\\}{.*\\)$", 0 },
1415 - { "ruby", "^\\s*\\(\\(class\\|module\\|def\\)\\s.*\\)$", 0 },
1402 + { "java",
1403 + "!^[ \t]*(catch|do|for|if|instanceof|new|return|switch|throw|while)\n"
1404 + "^[ \t]*(([ \t]*[A-Za-z_][A-Za-z_0-9]*){2,}[ \t]*\\([^;]*)$",
1405 + REG_EXTENDED },
1406 + { "pascal",
1407 + "^((procedure|function|constructor|destructor|interface|"
1408 + "implementation|initialization|finalization)[ \t]*.*)$"
1409 + "|"
1410 + "^(.*=[ \t]*(class|record).*)$",
1411 + REG_EXTENDED },
1412 + { "bibtex", "(@[a-zA-Z]{1,}[ \t]*\{{0,1}[ \t]*[^ \t\"@',\\#}{~%]*).*$",
1413 + REG_EXTENDED },
1414 + { "tex",
1415 + "^(\\\\((sub)*section|chapter|part)\\*{0,1}\{.*)$",
1416 + REG_EXTENDED },
1417 + { "ruby", "^[ \t]*((class|module|def)[ \t].*)$",
1418 + REG_EXTENDED },
1419 };
1420
1421 static const struct funcname_pattern_entry *diff_funcname_pattern(struct diff_filespec *one)