{"thread":{"id":"15582","subject":"[PATCH v2 1/4] diff.c: return pattern entry pointer rather than just the hunk header pattern","startedAt":"2008-09-18T22:40:48Z","lastAt":"2008-09-29T21:52:01Z","messageCount":26,"participants":["Brandon Casey","Johan Herland","Boyd Lynn Gerber","Junio C Hamano","Gustaf Hendeby"],"isPatch":true,"patchVersion":2,"patchTotal":4},"messages":[{"id":"91077","messageId":"hvD4CKeY-shT7TB0JLaQn02KLTvzB720kcwBxBfYbo3S2ySzNzsn9g@cipher.nrlssc.navy.mil","threadId":"15582","inReplyTo":"7vskry1485.fsf@gitster.siamese.dyndns.org","subject":"[PATCH v2 1/4] diff.c: return pattern entry pointer rather than just the hunk header pattern","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-09-18T22:40:48Z","receivedAt":"2008-09-18T22:40:48Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"This is in preparation for associating a flag with each pattern which will\ncontrol how the pattern is interpreted. For example, as a basic or extended\nregular expression.\n\nSigned-off-by: Brandon Casey <casey@nrlssc.navy.mil>\n---\n\n\nJunio C Hamano wrote:\n> Brandon Casey <casey@nrlssc.navy.mil> writes:\n> \n>> diff --git a/diff.c b/diff.c\n>> index 998dcaa..e040088 100644\n>> --- a/diff.c\n>> +++ b/diff.c\n>> @@ -94,6 +94,8 @@ static int parse_lldiff_command(const char *var, const char *ep, const char *val\n>>   * 'diff.<what>.funcname' attribute can be specified in the configuration\n>>   * to define a customized regexp to find the beginning of a function to\n>>   * be used for hunk header lines of \"diff -p\" style output.\n>> + * Note: If this structure is modified, it must retain the ability to be cast\n>> + * to a struct funcname_pattern_entry, defined elsewhere.\n>>   */\n> \n> Yuck.  Why not do:\n> \n> \tstruct funcname_pattern_entry {\n>         \t/* whatever fields one entry needs */\n> \t};\n>         static struct funcname_pattern_list {\n>         \tstruct funcname_pattern_list *next;\n>         \tstruct funcname_pattern_entry e;\n> \t} *funcname_pattern_list;\n\n<...>\n\n> Then you do not have to worry about casting things up and down, right?\n\n\n diff.c |   55 ++++++++++++++++++++++++++++---------------------------\n 1 files changed, 28 insertions(+), 27 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 998dcaa..3928124 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -95,32 +95,35 @@ static int parse_lldiff_command(const char *var, const char *ep, const char *val\n  * to define a customized regexp to find the beginning of a function to\n  * be used for hunk header lines of \"diff -p\" style output.\n  */\n-static struct funcname_pattern {\n+struct funcname_pattern_entry {\n \tchar *name;\n \tchar *pattern;\n-\tstruct funcname_pattern *next;\n+};\n+static struct funcname_pattern_list {\n+\tstruct funcname_pattern_list *next;\n+\tstruct funcname_pattern_entry e;\n } *funcname_pattern_list;\n \n static int parse_funcname_pattern(const char *var, const char *ep, const char *value)\n {\n \tconst char *name;\n \tint namelen;\n-\tstruct funcname_pattern *pp;\n+\tstruct funcname_pattern_list *pp;\n \n \tname = var + 5; /* \"diff.\" */\n \tnamelen = ep - name;\n \n \tfor (pp = funcname_pattern_list; pp; pp = pp->next)\n-\t\tif (!strncmp(pp->name, name, namelen) && !pp->name[namelen])\n+\t\tif (!strncmp(pp->e.name, name, namelen) && !pp->e.name[namelen])\n \t\t\tbreak;\n \tif (!pp) {\n \t\tpp = xcalloc(1, sizeof(*pp));\n-\t\tpp->name = xmemdupz(name, namelen);\n+\t\tpp->e.name = xmemdupz(name, namelen);\n \t\tpp->next = funcname_pattern_list;\n \t\tfuncname_pattern_list = pp;\n \t}\n-\tfree(pp->pattern);\n-\tpp->pattern = xstrdup(value);\n+\tfree(pp->e.pattern);\n+\tpp->e.pattern = xstrdup(value);\n \treturn 0;\n }\n \n@@ -1382,20 +1385,17 @@ int diff_filespec_is_binary(struct diff_filespec *one)\n \treturn one->is_binary;\n }\n \n-static const char *funcname_pattern(const char *ident)\n+static const struct funcname_pattern_entry *funcname_pattern(const char *ident)\n {\n-\tstruct funcname_pattern *pp;\n+\tstruct funcname_pattern_list *pp;\n \n \tfor (pp = funcname_pattern_list; pp; pp = pp->next)\n-\t\tif (!strcmp(ident, pp->name))\n-\t\t\treturn pp->pattern;\n+\t\tif (!strcmp(ident, pp->e.name))\n+\t\t\treturn &pp->e;\n \treturn NULL;\n }\n \n-static struct builtin_funcname_pattern {\n-\tconst char *name;\n-\tconst char *pattern;\n-} builtin_funcname_pattern[] = {\n+static const struct funcname_pattern_entry builtin_funcname_pattern[] = {\n \t{ \"bibtex\", \"\\\\(@[a-zA-Z]\\\\{1,\\\\}[ \\t]*{\\\\{0,1\\\\}[ \\t]*[^ \\t\\\"@',\\\\#}{~%]*\\\\).*$\" },\n \t{ \"html\", \"^\\\\s*\\\\(<[Hh][1-6]\\\\s.*>.*\\\\)$\" },\n \t{ \"java\", \"!^[ \t]*\\\\(catch\\\\|do\\\\|for\\\\|if\\\\|instanceof\\\\|\"\n@@ -1415,9 +1415,10 @@ static struct builtin_funcname_pattern {\n \t{ \"tex\", \"^\\\\(\\\\\\\\\\\\(\\\\(sub\\\\)*section\\\\|chapter\\\\|part\\\\)\\\\*\\\\{0,1\\\\}{.*\\\\)$\" },\n };\n \n-static const char *diff_funcname_pattern(struct diff_filespec *one)\n+static const struct funcname_pattern_entry *diff_funcname_pattern(struct diff_filespec *one)\n {\n-\tconst char *ident, *pattern;\n+\tconst char *ident;\n+\tconst struct funcname_pattern_entry *pe;\n \tint i;\n \n \tdiff_filespec_check_attr(one);\n@@ -1432,9 +1433,9 @@ static const char *diff_funcname_pattern(struct diff_filespec *one)\n \t\treturn funcname_pattern(\"default\");\n \n \t/* Look up custom \"funcname.$ident\" regexp from config. */\n-\tpattern = funcname_pattern(ident);\n-\tif (pattern)\n-\t\treturn pattern;\n+\tpe = funcname_pattern(ident);\n+\tif (pe)\n+\t\treturn pe;\n \n \t/*\n \t * And define built-in fallback patterns here.  Note that\n@@ -1442,7 +1443,7 @@ static const char *diff_funcname_pattern(struct diff_filespec *one)\n \t */\n \tfor (i = 0; i < ARRAY_SIZE(builtin_funcname_pattern); i++)\n \t\tif (!strcmp(ident, builtin_funcname_pattern[i].name))\n-\t\t\treturn builtin_funcname_pattern[i].pattern;\n+\t\t\treturn &builtin_funcname_pattern[i];\n \n \treturn NULL;\n }\n@@ -1520,11 +1521,11 @@ static void builtin_diff(const char *name_a,\n \t\txdemitconf_t xecfg;\n \t\txdemitcb_t ecb;\n \t\tstruct emit_callback ecbdata;\n-\t\tconst char *funcname_pattern;\n+\t\tconst struct funcname_pattern_entry *pe;\n \n-\t\tfuncname_pattern = diff_funcname_pattern(one);\n-\t\tif (!funcname_pattern)\n-\t\t\tfuncname_pattern = diff_funcname_pattern(two);\n+\t\tpe = diff_funcname_pattern(one);\n+\t\tif (!pe)\n+\t\t\tpe = diff_funcname_pattern(two);\n \n \t\tmemset(&xecfg, 0, sizeof(xecfg));\n \t\tmemset(&ecbdata, 0, sizeof(ecbdata));\n@@ -1536,8 +1537,8 @@ static void builtin_diff(const char *name_a,\n \t\txpp.flags = XDF_NEED_MINIMAL | o->xdl_opts;\n \t\txecfg.ctxlen = o->context;\n \t\txecfg.flags = XDL_EMIT_FUNCNAMES;\n-\t\tif (funcname_pattern)\n-\t\t\txdiff_set_find_func(&xecfg, funcname_pattern);\n+\t\tif (pe)\n+\t\t\txdiff_set_find_func(&xecfg, pe->pattern);\n \t\tif (!diffopts)\n \t\t\t;\n \t\telse if (!prefixcmp(diffopts, \"--unified=\"))\n-- \n1.6.0.1.244.gdc19\n"},{"id":"91078","messageId":"vc3PiW75EtfA2s7uG7Mc0ZZihWefo_j7-_zka5gGEunnBX0XH27qfg@cipher.nrlssc.navy.mil","threadId":"15582","inReplyTo":"7vskry1485.fsf@gitster.siamese.dyndns.org","subject":"[PATCH v2 2/4] diff.c: associate a flag with each pattern and use it for compiling regex","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-09-18T22:42:48Z","receivedAt":"2008-09-18T22:42:48Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"This is in preparation for allowing extended regular expression patterns.\n\nSigned-off-by: Brandon Casey <casey@nrlssc.navy.mil>\n---\n diff.c            |   27 +++++++++++++++------------\n xdiff-interface.c |    4 ++--\n xdiff-interface.h |    2 +-\n 3 files changed, 18 insertions(+), 15 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 3928124..08cdd8f 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -98,13 +98,14 @@ static int parse_lldiff_command(const char *var, const char *ep, const char *val\n struct funcname_pattern_entry {\n \tchar *name;\n \tchar *pattern;\n+\tint cflags;\n };\n static struct funcname_pattern_list {\n \tstruct funcname_pattern_list *next;\n \tstruct funcname_pattern_entry e;\n } *funcname_pattern_list;\n \n-static int parse_funcname_pattern(const char *var, const char *ep, const char *value)\n+static int parse_funcname_pattern(const char *var, const char *ep, const char *value, int cflags)\n {\n \tconst char *name;\n \tint namelen;\n@@ -124,6 +125,7 @@ static int parse_funcname_pattern(const char *var, const char *ep, const char *v\n \t}\n \tfree(pp->e.pattern);\n \tpp->e.pattern = xstrdup(value);\n+\tpp->e.cflags = cflags;\n \treturn 0;\n }\n \n@@ -192,7 +194,8 @@ int git_diff_basic_config(const char *var, const char *value, void *cb)\n \t\t\tif (!strcmp(ep, \".funcname\")) {\n \t\t\t\tif (!value)\n \t\t\t\t\treturn config_error_nonbool(var);\n-\t\t\t\treturn parse_funcname_pattern(var, ep, value);\n+\t\t\t\treturn parse_funcname_pattern(var, ep, value,\n+\t\t\t\t\t0);\n \t\t\t}\n \t\t}\n \t}\n@@ -1396,23 +1399,23 @@ static const struct funcname_pattern_entry *funcname_pattern(const char *ident)\n }\n \n static const struct funcname_pattern_entry builtin_funcname_pattern[] = {\n-\t{ \"bibtex\", \"\\\\(@[a-zA-Z]\\\\{1,\\\\}[ \\t]*{\\\\{0,1\\\\}[ \\t]*[^ \\t\\\"@',\\\\#}{~%]*\\\\).*$\" },\n-\t{ \"html\", \"^\\\\s*\\\\(<[Hh][1-6]\\\\s.*>.*\\\\)$\" },\n+\t{ \"bibtex\", \"\\\\(@[a-zA-Z]\\\\{1,\\\\}[ \\t]*{\\\\{0,1\\\\}[ \\t]*[^ \\t\\\"@',\\\\#}{~%]*\\\\).*$\", 0 },\n+\t{ \"html\", \"^\\\\s*\\\\(<[Hh][1-6]\\\\s.*>.*\\\\)$\", 0 },\n \t{ \"java\", \"!^[ \t]*\\\\(catch\\\\|do\\\\|for\\\\|if\\\\|instanceof\\\\|\"\n \t\t\t\"new\\\\|return\\\\|switch\\\\|throw\\\\|while\\\\)\\n\"\n \t\t\t\"^[ \t]*\\\\(\\\\([ \t]*\"\n \t\t\t\"[A-Za-z_][A-Za-z_0-9]*\\\\)\\\\{2,\\\\}\"\n-\t\t\t\"[ \t]*([^;]*\\\\)$\" },\n+\t\t\t\"[ \t]*([^;]*\\\\)$\", 0 },\n \t{ \"pascal\", \"^\\\\(\\\\(procedure\\\\|function\\\\|constructor\\\\|\"\n \t\t\t\"destructor\\\\|interface\\\\|implementation\\\\|\"\n \t\t\t\"initialization\\\\|finalization\\\\)[ \\t]*.*\\\\)$\"\n \t\t\t\"\\\\|\"\n-\t\t\t\"^\\\\(.*=[ \\t]*\\\\(class\\\\|record\\\\).*\\\\)$\"\n-\t\t\t},\n-\t{ \"php\", \"^[\\t ]*\\\\(\\\\(function\\\\|class\\\\).*\\\\)\" },\n-\t{ \"python\", \"^\\\\s*\\\\(\\\\(class\\\\|def\\\\)\\\\s.*\\\\)$\" },\n-\t{ \"ruby\", \"^\\\\s*\\\\(\\\\(class\\\\|module\\\\|def\\\\)\\\\s.*\\\\)$\" },\n-\t{ \"tex\", \"^\\\\(\\\\\\\\\\\\(\\\\(sub\\\\)*section\\\\|chapter\\\\|part\\\\)\\\\*\\\\{0,1\\\\}{.*\\\\)$\" },\n+\t\t\t\"^\\\\(.*=[ \\t]*\\\\(class\\\\|record\\\\).*\\\\)$\",\n+\t\t\t0 },\n+\t{ \"php\", \"^[\\t ]*\\\\(\\\\(function\\\\|class\\\\).*\\\\)\", 0 },\n+\t{ \"python\", \"^\\\\s*\\\\(\\\\(class\\\\|def\\\\)\\\\s.*\\\\)$\", 0 },\n+\t{ \"ruby\", \"^\\\\s*\\\\(\\\\(class\\\\|module\\\\|def\\\\)\\\\s.*\\\\)$\", 0 },\n+\t{ \"tex\", \"^\\\\(\\\\\\\\\\\\(\\\\(sub\\\\)*section\\\\|chapter\\\\|part\\\\)\\\\*\\\\{0,1\\\\}{.*\\\\)$\", 0 },\n };\n \n static const struct funcname_pattern_entry *diff_funcname_pattern(struct diff_filespec *one)\n@@ -1538,7 +1541,7 @@ static void builtin_diff(const char *name_a,\n \t\txecfg.ctxlen = o->context;\n \t\txecfg.flags = XDL_EMIT_FUNCNAMES;\n \t\tif (pe)\n-\t\t\txdiff_set_find_func(&xecfg, pe->pattern);\n+\t\t\txdiff_set_find_func(&xecfg, pe->pattern, pe->cflags);\n \t\tif (!diffopts)\n \t\t\t;\n \t\telse if (!prefixcmp(diffopts, \"--unified=\"))\ndiff --git a/xdiff-interface.c b/xdiff-interface.c\nindex 944ad98..7f1a7d3 100644\n--- a/xdiff-interface.c\n+++ b/xdiff-interface.c\n@@ -218,7 +218,7 @@ static long ff_regexp(const char *line, long len,\n \treturn result;\n }\n \n-void xdiff_set_find_func(xdemitconf_t *xecfg, const char *value)\n+void xdiff_set_find_func(xdemitconf_t *xecfg, const char *value, int cflags)\n {\n \tint i;\n \tstruct ff_regs *regs;\n@@ -243,7 +243,7 @@ void xdiff_set_find_func(xdemitconf_t *xecfg, const char *value)\n \t\t\texpression = buffer = xstrndup(value, ep - value);\n \t\telse\n \t\t\texpression = value;\n-\t\tif (regcomp(&reg->re, expression, 0))\n+\t\tif (regcomp(&reg->re, expression, cflags))\n \t\t\tdie(\"Invalid regexp to look for hunk header: %s\", expression);\n \t\tfree(buffer);\n \t\tvalue = ep + 1;\ndiff --git a/xdiff-interface.h b/xdiff-interface.h\nindex 558492b..23c49b9 100644\n--- a/xdiff-interface.h\n+++ b/xdiff-interface.h\n@@ -16,6 +16,6 @@ int parse_hunk_header(char *line, int len,\n int read_mmfile(mmfile_t *ptr, const char *filename);\n int buffer_is_binary(const char *ptr, unsigned long size);\n \n-extern void xdiff_set_find_func(xdemitconf_t *xecfg, const char *line);\n+extern void xdiff_set_find_func(xdemitconf_t *xecfg, const char *line, int cflags);\n \n #endif\n-- \n1.6.0.1.244.gdc19\n"},{"id":"91079","messageId":"fjsVcwP3ERAtOSloTT6E_M76x0-uAuN_SFta0ReZcFZ1h58s6M4jTQ@cipher.nrlssc.navy.mil","threadId":"15582","inReplyTo":"7vskry1485.fsf@gitster.siamese.dyndns.org","subject":"[PATCH v2 3/4] diff.*.xfuncname which uses \"extended\" regex's for hunk header selection","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-09-18T22:44:33Z","receivedAt":"2008-09-18T22:44:33Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"Currently, the hunk headers produced by 'diff -p' are customizable by\nsetting the diff.*.funcname option in the config file. The 'funcname' option\ntakes a basic regular expression. This functionality was designed using the\nGNU regex library which, by default, allows using backslashed versions of\nsome extended regular expression operators, even in Basic Regular Expression\nmode. For example, the following characters, when backslashed, are\ninterpreted according to the extended regular expression rules: ?, +, and |.\nAs such, the builtin funcname patterns were created using some extended\nregular expression operators.\n\nOther platforms which adhere more strictly to the POSIX spec do not\ninterpret the backslashed extended RE operators in Basic Regular Expression\nmode. This causes the pattern matching for the builtin funcname patterns to\nfail on those platforms.\n\nIntroduce a new option 'xfuncname' which uses extended regular expressions,\nand advertise it _instead_ of funcname. Since most users are on GNU\nplatforms, the majority of funcname patterns are created and tested there.\nAdvertising only xfuncname should help to avoid the creation of non-portable\npatterns which work with GNU regex but not elsewhere.\n\nAdditionally, the extended regular expressions may be less ugly and\ncomplicated compared to the basic RE since many common special operators do\nnot need to be backslashed.\n\nFor example, the GNU Basic RE:\n\n    ^[ \t]*\\\\(\\\\(public\\\\|static\\\\).*\\\\)$\n\nbecomes the following Extended RE:\n\n    ^[ \t]*((public|static).*)$\n\nSigned-off-by: Brandon Casey <casey@nrlssc.navy.mil>\n---\n Documentation/gitattributes.txt |    4 ++--\n diff.c                          |    5 +++++\n t/t4018-diff-funcname.sh        |    2 +-\n 3 files changed, 8 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt\nindex 6f3551d..9a75257 100644\n--- a/Documentation/gitattributes.txt\n+++ b/Documentation/gitattributes.txt\n@@ -288,13 +288,13 @@ for paths.\n *.tex\tdiff=tex\n ------------------------\n \n-Then, you would define \"diff.tex.funcname\" configuration to\n+Then, you would define \"diff.tex.xfuncname\" configuration to\n specify a regular expression that matches a line that you would\n want to appear as the hunk header, like this:\n \n ------------------------\n [diff \"tex\"]\n-\tfuncname = \"^\\\\(\\\\\\\\\\\\(sub\\\\)*section{.*\\\\)$\"\n+\txfuncname = \"^(\\\\\\\\(sub)*section\\\\{.*)$\"\n ------------------------\n \n Note.  A single level of backslashes are eaten by the\ndiff --git a/diff.c b/diff.c\nindex 08cdd8f..9d8fd2b 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -196,6 +196,11 @@ int git_diff_basic_config(const char *var, const char *value, void *cb)\n \t\t\t\t\treturn config_error_nonbool(var);\n \t\t\t\treturn parse_funcname_pattern(var, ep, value,\n \t\t\t\t\t0);\n+\t\t\t} else if (!strcmp(ep, \".xfuncname\")) {\n+\t\t\t\tif (!value)\n+\t\t\t\t\treturn config_error_nonbool(var);\n+\t\t\t\treturn parse_funcname_pattern(var, ep, value,\n+\t\t\t\t\tREG_EXTENDED);\n \t\t\t}\n \t\t}\n \t}\ndiff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh\nindex 18bcd97..602d68f 100755\n--- a/t/t4018-diff-funcname.sh\n+++ b/t/t4018-diff-funcname.sh\n@@ -58,7 +58,7 @@ test_expect_success 'last regexp must not be negated' '\n '\n \n test_expect_success 'alternation in pattern' '\n-\tgit config diff.java.funcname \"^[ \t]*\\\\(\\\\(public\\\\|static\\\\).*\\\\)$\"\n+\tgit config diff.java.xfuncname \"^[ \t]*((public|static).*)$\" &&\n \tgit diff --no-index Beer.java Beer-correct.java |\n \tgrep \"^@@.*@@ public static void main(\"\n '\n-- \n1.6.0.1.244.gdc19\n"},{"id":"91080","messageId":"4i0Mu795rKpv37JoHytmE6kODBjwgwITn0-DuKdZiFs3ZnUlyJC-Fw@cipher.nrlssc.navy.mil","threadId":"15582","inReplyTo":"7vskry1485.fsf@gitster.siamese.dyndns.org","subject":"[PATCH v2 4/4] diff.c: convert builtin funcname patterns to non-GNU extended regex syntax","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-09-18T22:47:18Z","receivedAt":"2008-09-18T22:47:18Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"The 'non-GNU' part of this basic RE to extended RE conversion means '\\\\s' was\nconverted to ' '.\n\nSigned-off-by: Brandon Casey <casey@nrlssc.navy.mil>\n---\n diff.c |   35 ++++++++++++++++++-----------------\n 1 files changed, 18 insertions(+), 17 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 9d8fd2b..c74f1a3 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -1404,23 +1404,24 @@ static const struct funcname_pattern_entry *funcname_pattern(const char *ident)\n }\n \n static const struct funcname_pattern_entry builtin_funcname_pattern[] = {\n-\t{ \"bibtex\", \"\\\\(@[a-zA-Z]\\\\{1,\\\\}[ \\t]*{\\\\{0,1\\\\}[ \\t]*[^ \\t\\\"@',\\\\#}{~%]*\\\\).*$\", 0 },\n-\t{ \"html\", \"^\\\\s*\\\\(<[Hh][1-6]\\\\s.*>.*\\\\)$\", 0 },\n-\t{ \"java\", \"!^[ \t]*\\\\(catch\\\\|do\\\\|for\\\\|if\\\\|instanceof\\\\|\"\n-\t\t\t\"new\\\\|return\\\\|switch\\\\|throw\\\\|while\\\\)\\n\"\n-\t\t\t\"^[ \t]*\\\\(\\\\([ \t]*\"\n-\t\t\t\"[A-Za-z_][A-Za-z_0-9]*\\\\)\\\\{2,\\\\}\"\n-\t\t\t\"[ \t]*([^;]*\\\\)$\", 0 },\n-\t{ \"pascal\", \"^\\\\(\\\\(procedure\\\\|function\\\\|constructor\\\\|\"\n-\t\t\t\"destructor\\\\|interface\\\\|implementation\\\\|\"\n-\t\t\t\"initialization\\\\|finalization\\\\)[ \\t]*.*\\\\)$\"\n-\t\t\t\"\\\\|\"\n-\t\t\t\"^\\\\(.*=[ \\t]*\\\\(class\\\\|record\\\\).*\\\\)$\",\n-\t\t\t0 },\n-\t{ \"php\", \"^[\\t ]*\\\\(\\\\(function\\\\|class\\\\).*\\\\)\", 0 },\n-\t{ \"python\", \"^\\\\s*\\\\(\\\\(class\\\\|def\\\\)\\\\s.*\\\\)$\", 0 },\n-\t{ \"ruby\", \"^\\\\s*\\\\(\\\\(class\\\\|module\\\\|def\\\\)\\\\s.*\\\\)$\", 0 },\n-\t{ \"tex\", \"^\\\\(\\\\\\\\\\\\(\\\\(sub\\\\)*section\\\\|chapter\\\\|part\\\\)\\\\*\\\\{0,1\\\\}{.*\\\\)$\", 0 },\n+\t{ \"bibtex\", \"(@[a-zA-Z]{1,}[ \\t]*\\\\{{0,1}[ \\t]*[^ \\t\\\"@',\\\\#\\\\}\\\\{~%]*).*$\", REG_EXTENDED },\n+\t{ \"html\", \"^ *(<[Hh][1-6] .*>.*)$\", REG_EXTENDED },\n+\t{ \"java\", \"!^[ \t]*(catch|do|for|if|instanceof|\"\n+\t\t\t\"new|return|switch|throw|while)\\n\"\n+\t\t\t\"^[ \t]*(([ \t]*\"\n+\t\t\t\"[A-Za-z_][A-Za-z_0-9]*){2,}\"\n+\t\t\t\"[ \t]*\\\\([^;]*)$\", REG_EXTENDED },\n+\t{ \"pascal\", \"^((procedure|function|constructor|\"\n+\t\t\t\"destructor|interface|implementation|\"\n+\t\t\t\"initialization|finalization)[ \\t]*.*)$\"\n+\t\t\t\"|\"\n+\t\t\t\"^(.*=[ \\t]*(class|record).*)$\",\n+\t\t\tREG_EXTENDED },\n+\t{ \"php\", \"^[\\t ]*((function|class).*)\", REG_EXTENDED },\n+\t{ \"python\", \"^ *((class|def)\\\\s.*)$\", REG_EXTENDED },\n+\t{ \"ruby\", \"^ *((class|module|def) .*)$\", REG_EXTENDED },\n+\t{ \"tex\", \"^(\\\\\\\\((sub)*section|chapter|part)\\\\*{0,1}\\\\{.*)$\",\n+\t\tREG_EXTENDED },\n };\n \n static const struct funcname_pattern_entry *diff_funcname_pattern(struct diff_filespec *one)\n-- \n1.6.0.1.244.gdc19\n"},{"id":"91082","messageId":"azRDXO9YgAHlqbMUTpBfy26HVw0xzYFwnT5x-l_nqDw@cipher.nrlssc.navy.mil","threadId":"15582","inReplyTo":"4i0Mu795rKpv37JoHytmE6kODBjwgwITn0-DuKdZiFs3ZnUlyJC-Fw@cipher.nrlssc.navy.mil","subject":"Re: [PATCH v2 4/4] diff.c: convert builtin funcname patterns to non-GNU extended regex syntax","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-09-18T22:59:27Z","receivedAt":"2008-09-18T22:59:27Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"Brandon Casey wrote:\n\n> +\t{ \"java\", \"!^[ \t]*(catch|do|for|if|instanceof|\"\n> +\t\t\t\"new|return|switch|throw|while)\\n\"\n> +\t\t\t\"^[ \t]*(([ \t]*\"\n> +\t\t\t\"[A-Za-z_][A-Za-z_0-9]*){2,}\"\n\nI don't understand the last two lines above.\n\nIs it possible for the second bracketed space and tab to match\nanything? Wouldn't the first one consume all space and tab?\n\nAssuming it is possible for the second brackets to match\nsuccessfully, why would we want to capture this leading\nspace?\n\nIt looks like both of the following lines would match:\n\n   ' a'\n   'ab'\n\nbut not this\n\n    'a'\n\nWould it be better written like:\n\n\"^[ \t]*(([A-Za-z_][A-Za-z_0-9]*)\"\n\n> +\t\t\t\"[ \t]*\\\\([^;]*)$\", REG_EXTENDED },\n\n<snip>\n\n\n-brandon\n"},{"id":"91084","messageId":"200809190140.15489.johan@herland.net","threadId":"15582","inReplyTo":"4i0Mu795rKpv37JoHytmE6kODBjwgwITn0-DuKdZiFs3ZnUlyJC-Fw@cipher.nrlssc.navy.mil","subject":"Re: [PATCH v2 4/4] diff.c: convert builtin funcname patterns to non-GNU extended regex syntax","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2008-09-18T23:40:15Z","receivedAt":"2008-09-18T23:40:15Z","isPatch":true,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"On Friday 19 September 2008, Brandon Casey wrote:\n> The 'non-GNU' part of this basic RE to extended RE conversion means '\\\\s'\n> was converted to ' '.\n\nShouldn't that be '[ \\t]' instead? At least I would like that for the HTML \npattern.\n\n\nHave fun!\n\n...Johan\n\n-- \nJohan Herland, <johan@herland.net>\nwww.herland.net\n"},{"id":"91126","messageId":"pkDB-Ku6Wgh0oYLOf6pWNHJMXdy7I_ZG5lIyvIEdaaaGQxO3kjqHBQ@cipher.nrlssc.navy.mil","threadId":"15582","inReplyTo":"200809190140.15489.johan@herland.net","subject":"Re: [PATCH v2 4/4] diff.c: convert builtin funcname patterns to non-GNU extended regex syntax","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-09-19T15:55:11Z","receivedAt":"2008-09-19T15:55:11Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"Johan Herland wrote:\n> On Friday 19 September 2008, Brandon Casey wrote:\n>> The 'non-GNU' part of this basic RE to extended RE conversion means '\\\\s'\n>> was converted to ' '.\n> \n> Shouldn't that be '[ \\t]' instead? At least I would like that for the HTML \n> pattern.\n\nAh, yes, I think you are right.\n\n-brandon\n"},{"id":"91128","messageId":"RvgrrcxK92TUU52XizpRyxykjZ7Bi6GV1bEGpjFUOlB7EfvuSDNySA@cipher.nrlssc.navy.mil","threadId":"15582","inReplyTo":"azRDXO9YgAHlqbMUTpBfy26HVw0xzYFwnT5x-l_nqDw@cipher.nrlssc.navy.mil","subject":"Re: [PATCH v2 4/4] diff.c: convert builtin funcname patterns to non-GNU extended regex syntax","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-09-19T15:59:20Z","receivedAt":"2008-09-19T15:59:20Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"Brandon Casey wrote:\n> Brandon Casey wrote:\n> \n>> +\t{ \"java\", \"!^[ \t]*(catch|do|for|if|instanceof|\"\n>> +\t\t\t\"new|return|switch|throw|while)\\n\"\n>> +\t\t\t\"^[ \t]*(([ \t]*\"\n>> +\t\t\t\"[A-Za-z_][A-Za-z_0-9]*){2,}\"\n> \n> I don't understand the last two lines above.\n\nok, I figured it out.\n\nI was interpretting the {2,} part in\n\n  ([ \t]*[A-Za-z_][A-Za-z_0-9]*){2,}\n\nas requiring two characters, instead of two or more repetitions of\nthe pattern inside the parenthesis.\n\n-brandon\n"},{"id":"91135","messageId":"alpine.LNX.1.10.0809191209450.10710@suse104.zenez.com","threadId":"15582","inReplyTo":"hvD4CKeY-shT7TB0JLaQn02KLTvzB720kcwBxBfYbo3S2ySzNzsn9g@cipher.nrlssc.navy.mil","subject":"Re: [PATCH v2 1/4] diff.c: return pattern entry pointer rather than just the hunk header pattern","fromName":"Boyd Lynn Gerber","fromEmail":"gerberb@zenez.com","sentAt":"2008-09-19T18:14:11Z","receivedAt":"2008-09-19T18:14:11Z","isPatch":true,"sender":{"key":"gerberb@zenez.com","avatar":null},"body":"So on these patches,\nWhat do you want me to do?  I applied them and things kinda worked.  The \nproblem is pine/alpine messes them up a bit and it is not easy to manually \nfix them.  It would be easier to git clone/pull them from either a site or \nthe trees.  I do think that on some we should use the actual charact vers \nthe C-syntax.  \"\\t\" for example.\n\n--\nBoyd Gerber <gerberb@zenez.com>\nZENEZ\t1042 East Fort Union #135, Midvale Utah  84047\n"},{"id":"91137","messageId":"IWyC0OwsyyNa-yfA29138St-i1ziYm_Ijietm8MzVB8@cipher.nrlssc.navy.mil","threadId":"15582","inReplyTo":"alpine.LNX.1.10.0809191209450.10710@suse104.zenez.com","subject":"Re: [PATCH v2 1/4] diff.c: return pattern entry pointer rather than just the hunk header pattern","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-09-19T19:11:59Z","receivedAt":"2008-09-19T19:11:59Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"Boyd Lynn Gerber wrote:\n> So on these patches,\n> What do you want me to do?  I applied them and things kinda worked.\n\nTest t4018-diff-funcname.sh should pass. As Johan mentioned, in the\nlast patch '\\\\s' should have been converted to '[ \\t]', rather than\nto just ' ', but that should not affect the test and should only\naffect html, python, and ruby patterns.\n\nIt would be nice if the tests were expanded.\n\n>  The\n> problem is pine/alpine messes them up a bit and it is not easy to\n> manually fix them.  It would be easier to git clone/pull them from\n> either a site or the trees.  \n\nI expect they will be in Junio's tree soon, most likely the master\nbranch.\n\n>I do think that on some we should use the\n> actual charact vers the C-syntax.  \"\\t\" for example.\n\n\"\\t\" is safe to use since it is interpreted by git in config.c: parse_value(),\nnot by the regex library. I was also concerned about that character until I\ntraced the code to parse_value(). Junio is right that better documentation of\nthis feature is needed.\n\n-brandon\n"},{"id":"91143","messageId":"7v7i97swv3.fsf@gitster.siamese.dyndns.org","threadId":"15582","inReplyTo":"4i0Mu795rKpv37JoHytmE6kODBjwgwITn0-DuKdZiFs3ZnUlyJC-Fw@cipher.nrlssc.navy.mil","subject":"Re: [PATCH v2 4/4] diff.c: convert builtin funcname patterns to non-GNU extended regex syntax","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-09-19T20:29:20Z","receivedAt":"2008-09-19T20:29:20Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Brandon Casey <casey@nrlssc.navy.mil> writes:\n\n> The 'non-GNU' part of this basic RE to extended RE conversion means '\\\\s' was\n> converted to ' '.\n\nI think a large part of this series should be in 'maint', as the existing\nhunk head pattern engine does _not_ work for people without GNU regexp.\n\nI've created two branches to house this topic:\n\n - bc/maint-diff-hunk-header-fix is rebased to 'maint', so that after\n   testing we can merge it to 'maint' for 1.6.0.3 and later versions.\n\n   Its current tip is at 45d9414;\n\n - bc/master-diff-hunk-header-fix forks from the above, and merges later\n   \"language\" additions that happened on 'master'.  We can merge this\n   after testing to 'master' for 1.6.1.\n\n   Its current tip is at dde4af4.\n\nNeither has [4/4] on it.  I'd like two patches so that:\n\n * [PATCH 1/2] applies to bc/maint-diff-hunk-header-fix, so that the\n   languages in 1.6.0.2 are fixed for non GNU platforms;\n\n * After applying [1/2] to bc/maint-diff-hunk-header-fix, I'll merge the\n   branch to bc/master-diff-hunk-header-fix and then...\n\n * [PATCH 2/2] applies on top of it to convert new languages that are\n   supported only on 'master' to use xfuncname.\n"},{"id":"91164","messageId":"7vy71n482x.fsf@gitster.siamese.dyndns.org","threadId":"15582","inReplyTo":"7v7i97swv3.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH v2 4/4] diff.c: convert builtin funcname patterns to non-GNU extended regex syntax","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-09-20T06:58:30Z","receivedAt":"2008-09-20T06:58:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Neither has [4/4] on it.  I'd like two patches so that:\n>\n>  * [PATCH 1/2] applies to bc/maint-diff-hunk-header-fix, so that the\n>    languages in 1.6.0.2 are fixed for non GNU platforms;\n>\n>  * After applying [1/2] to bc/maint-diff-hunk-header-fix, I'll merge the\n>    branch to bc/master-diff-hunk-header-fix and then...\n>\n>  * [PATCH 2/2] applies on top of it to convert new languages that are\n>    supported only on 'master' to use xfuncname.\n\nHere is [1/2] to be applied on top of 45d9414 (diff.*.xfuncname which uses\n\"extended\" regex's for hunk header selection, 2008-09-18).\n\nTesting appreciated.\n\n-- >8 --\nSubject: [PATCH] diff: use extended regexp to find hunk headers\n\nUsing ERE elements such as \"|\" (alternation) by backquoting in BRE\nis a GNU extension and should not be done in portable programs.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c |   31 +++++++++++++++++--------------\n 1 files changed, 17 insertions(+), 14 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex dabb4b4..175a044 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -1399,20 +1399,23 @@ static const struct funcname_pattern_entry *funcname_pattern(const char *ident)\n }\n \n static const struct funcname_pattern_entry builtin_funcname_pattern[] = {\n-\t{ \"java\", \"!^[ \t]*\\\\(catch\\\\|do\\\\|for\\\\|if\\\\|instanceof\\\\|\"\n-\t\t\t\"new\\\\|return\\\\|switch\\\\|throw\\\\|while\\\\)\\n\"\n-\t\t\t\"^[ \t]*\\\\(\\\\([ \t]*\"\n-\t\t\t\"[A-Za-z_][A-Za-z_0-9]*\\\\)\\\\{2,\\\\}\"\n-\t\t\t\"[ \t]*([^;]*\\\\)$\", 0 },\n-\t{ \"pascal\", \"^\\\\(\\\\(procedure\\\\|function\\\\|constructor\\\\|\"\n-\t\t\t\"destructor\\\\|interface\\\\|implementation\\\\|\"\n-\t\t\t\"initialization\\\\|finalization\\\\)[ \\t]*.*\\\\)$\"\n-\t\t\t\"\\\\|\"\n-\t\t\t\"^\\\\(.*=[ \\t]*\\\\(class\\\\|record\\\\).*\\\\)$\",\n-\t\t\t0 },\n-\t{ \"bibtex\", \"\\\\(@[a-zA-Z]\\\\{1,\\\\}[ \\t]*{\\\\{0,1\\\\}[ \\t]*[^ \\t\\\"@',\\\\#}{~%]*\\\\).*$\", 0 },\n-\t{ \"tex\", \"^\\\\(\\\\\\\\\\\\(\\\\(sub\\\\)*section\\\\|chapter\\\\|part\\\\)\\\\*\\\\{0,1\\\\}{.*\\\\)$\", 0 },\n-\t{ \"ruby\", \"^\\\\s*\\\\(\\\\(class\\\\|module\\\\|def\\\\)\\\\s.*\\\\)$\", 0 },\n+\t{ \"java\",\n+\t  \"!^[ \\t]*(catch|do|for|if|instanceof|new|return|switch|throw|while)\\n\"\n+\t  \"^[ \\t]*(([ \\t]*[A-Za-z_][A-Za-z_0-9]*){2,}[ \\t]*\\\\([^;]*)$\",\n+\t  REG_EXTENDED },\n+\t{ \"pascal\",\n+\t  \"^((procedure|function|constructor|destructor|interface|\"\n+\t\t\"implementation|initialization|finalization)[ \\t]*.*)$\"\n+\t  \"|\"\n+\t  \"^(.*=[ \\t]*(class|record).*)$\",\n+\t  REG_EXTENDED },\n+\t{ \"bibtex\", \"(@[a-zA-Z]{1,}[ \\t]*\\{{0,1}[ \\t]*[^ \\t\\\"@',\\\\#}{~%]*).*$\",\n+\t  REG_EXTENDED },\n+\t{ \"tex\",\n+\t  \"^(\\\\\\\\((sub)*section|chapter|part)\\\\*{0,1}\\{.*)$\",\n+\t  REG_EXTENDED },\n+\t{ \"ruby\", \"^[ \\t]*((class|module|def)[ \\t].*)$\",\n+\t  REG_EXTENDED },\n };\n \n static const struct funcname_pattern_entry *diff_funcname_pattern(struct diff_filespec *one)\n"},{"id":"91165","messageId":"7vtzcb47vh.fsf@gitster.siamese.dyndns.org","threadId":"15582","inReplyTo":"7v7i97swv3.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH v2 4/4] diff.c: convert builtin funcname patterns to non-GNU extended regex syntax","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-09-20T07:02:58Z","receivedAt":"2008-09-20T07:02:58Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Neither has [4/4] on it.  I'd like two patches so that:\n>\n>  * [PATCH 1/2] applies to bc/maint-diff-hunk-header-fix, so that the\n>    languages in 1.6.0.2 are fixed for non GNU platforms;\n>\n>  * After applying [1/2] to bc/maint-diff-hunk-header-fix, I'll merge the\n>    branch to bc/master-diff-hunk-header-fix and then...\n>\n>  * [PATCH 2/2] applies on top of it to convert new languages that are\n>    supported only on 'master' to use xfuncname.\n\nIf you apply the previous one on top of 45d9414 (diff.*.xfuncname which\nuses \"extended\" regex's for hunk header selection, 2008-09-18), and then\nmerge the result to dde4af4 (Merge branch 'bc/maint-diff-hunk-header-fix'\ninto bc/master-diff-hunk-header-fix, 2008-09-18), you will get some\ntrivial conflicts.  This patch is [2/2] that applies on top of that merge,\nand should result in this:\n\nstatic const struct funcname_pattern_entry builtin_funcname_pattern[] = {\n\t{ \"bibtex\", \"(@[a-zA-Z]{1,}[ \\t]*\\{{0,1}[ \\t]*[^ \\t\\\"@',\\\\#}{~%]*).*$\",\n\t  REG_EXTENDED },\n\t{ \"html\", \"^[ \\t]*(<[Hh][1-6][ \\t].*>.*)$\", REG_EXTENDED },\n\t{ \"java\",\n\t  \"!^[ \\t]*(catch|do|for|if|instanceof|new|return|switch|throw|while)\\n\"\n\t  \"^[ \\t]*(([ \\t]*[A-Za-z_][A-Za-z_0-9]*){2,}[ \\t]*\\\\([^;]*)$\",\n\t  REG_EXTENDED },\n\t{ \"pascal\",\n\t  \"^((procedure|function|constructor|destructor|interface|\"\n\t\t\"implementation|initialization|finalization)[ \\t]*.*)$\"\n\t  \"|\"\n\t  \"^(.*=[ \\t]*(class|record).*)$\",\n\t  REG_EXTENDED },\n\t{ \"php\", \"^[\\t ]*((function|class).*)\", REG_EXTENDED },\n\t{ \"python\", \"^[ \\t]*((class|def)[ \\t].*)$\", REG_EXTENDED },\n\t{ \"ruby\", \"^[ \\t]*((class|module|def)[ \\t].*)$\",\n\t  REG_EXTENDED },\n\t{ \"tex\",\n\t  \"^(\\\\\\\\((sub)*section|chapter|part)\\\\*{0,1}\\{.*)$\",\n\t  REG_EXTENDED },\n};\n\n-- >8 --\nSubject: [PATCH] diff: use extended regexp to find hunk headers\n\nUsing ERE elements such as \"|\" (alternation) by backquoting in BRE\nis a GNU extension and should not be done in portable programs.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c |    6 +++---\n 1 files changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 5b9b074..a733010 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -1406,7 +1406,7 @@ static const struct funcname_pattern_entry *funcname_pattern(const char *ident)\n static const struct funcname_pattern_entry builtin_funcname_pattern[] = {\n \t{ \"bibtex\", \"(@[a-zA-Z]{1,}[ \\t]*\\{{0,1}[ \\t]*[^ \\t\\\"@',\\\\#}{~%]*).*$\",\n \t  REG_EXTENDED },\n-\t{ \"html\", \"^\\\\s*\\\\(<[Hh][1-6]\\\\s.*>.*\\\\)$\", 0 },\n+\t{ \"html\", \"^[ \\t]*(<[Hh][1-6][ \\t].*>.*)$\", REG_EXTENDED },\n \t{ \"java\",\n \t  \"!^[ \\t]*(catch|do|for|if|instanceof|new|return|switch|throw|while)\\n\"\n \t  \"^[ \\t]*(([ \\t]*[A-Za-z_][A-Za-z_0-9]*){2,}[ \\t]*\\\\([^;]*)$\",\n@@ -1417,8 +1417,8 @@ static const struct funcname_pattern_entry builtin_funcname_pattern[] = {\n \t  \"|\"\n \t  \"^(.*=[ \\t]*(class|record).*)$\",\n \t  REG_EXTENDED },\n-\t{ \"php\", \"^[\\t ]*\\\\(\\\\(function\\\\|class\\\\).*\\\\)\", 0 },\n-\t{ \"python\", \"^\\\\s*\\\\(\\\\(class\\\\|def\\\\)\\\\s.*\\\\)$\", 0 },\n+\t{ \"php\", \"^[\\t ]*((function|class).*)\", REG_EXTENDED },\n+\t{ \"python\", \"^[ \\t]*((class|def)[ \\t].*)$\", REG_EXTENDED },\n \t{ \"ruby\", \"^[ \\t]*((class|module|def)[ \\t].*)$\",\n \t  REG_EXTENDED },\n \t{ \"tex\",\n-- \n1.6.0.2.414.g0bf11\n"},{"id":"91166","messageId":"7vej3f45mc.fsf@gitster.siamese.dyndns.org","threadId":"15582","inReplyTo":"7vtzcb47vh.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH v2 4/4] diff.c: convert builtin funcname patterns to non-GNU extended regex syntax","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-09-20T07:51:39Z","receivedAt":"2008-09-20T07:51:39Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> static const struct funcname_pattern_entry builtin_funcname_pattern[] = {\n> \t{ \"bibtex\", \"(@[a-zA-Z]{1,}[ \\t]*\\{{0,1}[ \\t]*[^ \\t\\\"@',\\\\#}{~%]*).*$\",\n> \t  REG_EXTENDED },\n> \t{ \"html\", \"^[ \\t]*(<[Hh][1-6][ \\t].*>.*)$\", REG_EXTENDED },\n> \t{ \"java\",\n> \t  \"!^[ \\t]*(catch|do|for|if|instanceof|new|return|switch|throw|while)\\n\"\n> \t  \"^[ \\t]*(([ \\t]*[A-Za-z_][A-Za-z_0-9]*){2,}[ \\t]*\\\\([^;]*)$\",\n> \t  REG_EXTENDED },\n> \t{ \"pascal\",\n> \t  \"^((procedure|function|constructor|destructor|interface|\"\n> \t\t\"implementation|initialization|finalization)[ \\t]*.*)$\"\n> \t  \"|\"\n> \t  \"^(.*=[ \\t]*(class|record).*)$\",\n> \t  REG_EXTENDED },\n> \t{ \"php\", \"^[\\t ]*((function|class).*)\", REG_EXTENDED },\n> \t{ \"python\", \"^[ \\t]*((class|def)[ \\t].*)$\", REG_EXTENDED },\n> \t{ \"ruby\", \"^[ \\t]*((class|module|def)[ \\t].*)$\",\n> \t  REG_EXTENDED },\n> \t{ \"tex\",\n> \t  \"^(\\\\\\\\((sub)*section|chapter|part)\\\\*{0,1}\\{.*)$\",\n> \t  REG_EXTENDED },\n> };\n\nOn the \"Objective-C hunk header\" topic, I mentioned that I wondered how a\nconstruct like:\n\n\t\"( A | B ) | ( C | D )\"\n\ncould possibly work, given that xdiff-interface.c::ff_regexp() uses a\nregmatch_t array with only two elements to capture (which means it can\nonly capture $0 and $1).\n\nIt turns out that the function is not really prepared to do this\nproperly.  In order to cope with a pattern without _any_ capturing\nparentheses in the regexp, it has a trick to use $0 if $1 is undefined.\n\nIn other words, if you write:\n\n\t\"junk ( A | B ) | garbage ( C | D )\"\n\nthen lines \"junk A\", \"junk B\", \"garbage C\" and \"garbage D\" would all match\nand be on the hunk header line.  However, \"garbage\" is not stripped out\n(while \"junk\" does get left out of the capture).\n\nThis happens not to be a problem with any of the above built-in patterns.\nThe risky one is \"pascal\", but it's $2 captures the entire line anyway, so\nit does not make any difference if the code used $0 instead.  E.g.  a line\nthat matches the second alternative, \"foo = class bar\", will be captured\nas $0 and this is the same as (un)captured $2.\n\nBut it would be a good idea to fix this while our attention to the issue\nis still fresh.  As we discussed earlier, we can replace the top-level \"|\"\nwith \"\\n\" and fix the semantics of multiple positive regexp to grab $1 (or\n$0 if $1 is unavaialble) of the first positive one.  If we did so, when\nthe pattern\n\n\t\"junk ( A | B ) | garbage ( C | D )\"\n\nmatches a line \"garbage C\", the initial garbage part will not be included\ninside the capture.\n\nHere is such a proposed fix.\n\n-- >8 --\ndiff: fix \"multiple regexp\" semantics to find hunk header comment\n\nWhen multiple regular expressions are concatenated with \"\\n\", they were\ntraditionally AND'ed together, and only a line that matches _all_ of them\nwere taken as a match.  This however is unwieldy when multiple regexp\nfeature is used to specify alternatives.\n\nThis fixes the semantics to take the first match.  A nagative pattern, if\nmatches, makes the line to fail.  A positive pattern, if matches, will be\nthe final match and what it captures in $1 is used as the hunk header\ncomment.\n\nWe could write alternatives using \"|\" in ERE, but the machinery can only\nuse captured $1 as the hunk header comment (or $0 if there is no match in\n$1), so you cannot write:\n\n    \"junk ( A | B ) | garbage ( C | D )\"\n\nand expect both \"junk\" and \"garbage\" to get stripped with the existing\ncode.  With this fix, you can write it as:\n\n    \"junk ( A | B ) \\n garbage ( C | D )\"\n\nand the way capture works would match the user expectation more\nnaturally.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n diff.c            |    2 +-\n xdiff-interface.c |   17 ++++++++++-------\n 2 files changed, 11 insertions(+), 8 deletions(-)\n\ndiff --git c/diff.c w/diff.c\nindex a733010..1bcbbd5 100644\n--- c/diff.c\n+++ w/diff.c\n@@ -1414,7 +1414,7 @@ static const struct funcname_pattern_entry builtin_funcname_pattern[] = {\n \t{ \"pascal\",\n \t  \"^((procedure|function|constructor|destructor|interface|\"\n \t\t\"implementation|initialization|finalization)[ \\t]*.*)$\"\n-\t  \"|\"\n+\t  \"\\n\"\n \t  \"^(.*=[ \\t]*(class|record).*)$\",\n \t  REG_EXTENDED },\n \t{ \"php\", \"^[\\t ]*((function|class).*)\", REG_EXTENDED },\ndiff --git c/xdiff-interface.c w/xdiff-interface.c\nindex 7f1a7d3..6c6bb19 100644\n--- c/xdiff-interface.c\n+++ w/xdiff-interface.c\n@@ -194,26 +194,29 @@ static long ff_regexp(const char *line, long len,\n \tchar *line_buffer = xstrndup(line, len); /* make NUL terminated */\n \tstruct ff_regs *regs = priv;\n \tregmatch_t pmatch[2];\n-\tint result = 0, i;\n+\tint i;\n+\tint result = -1;\n \n \tfor (i = 0; i < regs->nr; i++) {\n \t\tstruct ff_reg *reg = regs->array + i;\n-\t\tif (reg->negate ^ !!regexec(&reg->re,\n-\t\t\t\t\tline_buffer, 2, pmatch, 0)) {\n-\t\t\tfree(line_buffer);\n-\t\t\treturn -1;\n+\t\tif (!regexec(&reg->re, line_buffer, 2, pmatch, 0)) {\n+\t\t\tif (reg->negate)\n+\t\t\t\tgoto fail;\n+\t\t\tbreak;\n \t\t}\n \t}\n+\tif (regs->nr <= i)\n+\t\tgoto fail;\n \ti = pmatch[1].rm_so >= 0 ? 1 : 0;\n \tline += pmatch[i].rm_so;\n \tresult = pmatch[i].rm_eo - pmatch[i].rm_so;\n \tif (result > buffer_size)\n \t\tresult = buffer_size;\n \telse\n-\t\twhile (result > 0 && (isspace(line[result - 1]) ||\n-\t\t\t\t\tline[result - 1] == '\\n'))\n+\t\twhile (result > 0 && (isspace(line[result - 1])))\n \t\t\tresult--;\n \tmemcpy(buffer, line, result);\n+ fail:\n \tfree(line_buffer);\n \treturn result;\n }\n"},{"id":"91196","messageId":"loom.20080920T200157-713@post.gmane.org","threadId":"15582","inReplyTo":"7vy71n482x.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH v2 4/4] diff.c: convert builtin funcname patterns to non-GNU extended regex syntax","fromName":"Brandon Casey","fromEmail":"drafnel@gmail.com","sentAt":"2008-09-20T21:03:24Z","receivedAt":"2008-09-20T21:03:24Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"Junio C Hamano <gitster <at> pobox.com> writes:\n\n> Here is [1/2] to be applied on top of 45d9414 (diff.*.xfuncname which uses\n> \"extended\" regex's for hunk header selection, 2008-09-18).\n> \n> Testing appreciated.\n\n> +\t{ \"bibtex\", \"(@[a-zA-Z]{1,}[ \\t]*\\{{0,1}[ \\t]*[^ \\t\\\"@',\\\\#}{~%]*).*$\",\n> +\t  REG_EXTENDED },\n> +\t{ \"tex\",\n> +\t  \"^(\\\\\\\\((sub)*section|chapter|part)\\\\*{0,1}\\{.*)$\",\n\nI think you need double backslash '\\\\' before '{' in the two places in these\npatterns where you only have a single backslash.\n\n-brandon\n"},{"id":"91205","messageId":"7vmyi21mf8.fsf@gitster.siamese.dyndns.org","threadId":"15582","inReplyTo":"loom.20080920T200157-713@post.gmane.org","subject":"Re: [PATCH v2 4/4] diff.c: convert builtin funcname patterns to non-GNU extended regex syntax","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-09-20T22:29:15Z","receivedAt":"2008-09-20T22:29:15Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Brandon Casey <drafnel@gmail.com> writes:\n\n> Junio C Hamano <gitster <at> pobox.com> writes:\n>\n>> Here is [1/2] to be applied on top of 45d9414 (diff.*.xfuncname which uses\n>> \"extended\" regex's for hunk header selection, 2008-09-18).\n>> \n>> Testing appreciated.\n>\n>> +\t{ \"bibtex\", \"(@[a-zA-Z]{1,}[ \\t]*\\{{0,1}[ \\t]*[^ \\t\\\"@',\\\\#}{~%]*).*$\",\n>> +\t  REG_EXTENDED },\n>> +\t{ \"tex\",\n>> +\t  \"^(\\\\\\\\((sub)*section|chapter|part)\\\\*{0,1}\\{.*)$\",\n>\n> I think you need double backslash '\\\\' before '{' in the two places in these\n> patterns where you only have a single backslash.\n\nThanks.  Any other nits?\n"},{"id":"91288","messageId":"48D75752.2050409@isy.liu.se","threadId":"15582","inReplyTo":"4i0Mu795rKpv37JoHytmE6kODBjwgwITn0-DuKdZiFs3ZnUlyJC-Fw@cipher.nrlssc.navy.mil","subject":"Re: [PATCH v2 4/4] diff.c: convert builtin funcname patterns to non-GNU extended regex syntax","fromName":"Gustaf Hendeby","fromEmail":"hendeby@isy.liu.se","sentAt":"2008-09-22T08:29:06Z","receivedAt":"2008-09-22T08:29:06Z","isPatch":true,"sender":{"key":"hendeby@isy.liu.se","avatar":"https://avatars.githubusercontent.com/u/730316?v=4"},"body":"On 09/19/2008 12:47 AM, Brandon Casey wrote:\n> The 'non-GNU' part of this basic RE to extended RE conversion means '\\\\s' was\n> converted to ' '.\n\nI've tested the converted BibTeX pattern and it seems to work as expected.\n\n/Gustaf\n"},{"id":"91328","messageId":"i-l9YX2TO45e2OB9LuoxrAN6a2iFYaH_eEGlVmRsP0oa97XuwX4eGQ@cipher.nrlssc.navy.mil","threadId":"15582","inReplyTo":"7vmyi21mf8.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH v2 4/4] diff.c: convert builtin funcname patterns to non-GNU extended regex syntax","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-09-22T16:59:47Z","receivedAt":"2008-09-22T16:59:47Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"Junio C Hamano wrote:\n> Brandon Casey <drafnel@gmail.com> writes:\n> \n>> Junio C Hamano <gitster <at> pobox.com> writes:\n>>\n>>> Here is [1/2] to be applied on top of 45d9414 (diff.*.xfuncname which uses\n>>> \"extended\" regex's for hunk header selection, 2008-09-18).\n>>>\n>>> Testing appreciated.\n>>> +\t{ \"bibtex\", \"(@[a-zA-Z]{1,}[ \\t]*\\{{0,1}[ \\t]*[^ \\t\\\"@',\\\\#}{~%]*).*$\",\n>>> +\t  REG_EXTENDED },\n>>> +\t{ \"tex\",\n>>> +\t  \"^(\\\\\\\\((sub)*section|chapter|part)\\\\*{0,1}\\{.*)$\",\n>> I think you need double backslash '\\\\' before '{' in the two places in these\n>> patterns where you only have a single backslash.\n> \n> Thanks.  Any other nits?\n\nJust a single minor one on the \"fix multiple regexp semantics\" patch.\n\nThis:\n\n \tfor (i = 0; i < regs->nr; i++) {\n\t\t...\n\t}\n+\tif (regs->nr <= i)\n\nmakes me use my brain (I try to avoid that).\n\nI only mention it since I've seen discussions in the past about this sort\nof ordering, and you seem to have accepted that it can be confusing to\nnative english speakers who would \"read\" the 'if' statement. The ordering\nabove puts emphasis on the value of regs->nr, when it is actually the value\nof 'i' that is being tested (since regs->nr is unchanging).\n\nI'll do some testing on non-GNU platforms today.\n\n-brandon\n"},{"id":"91344","messageId":"b-t750rmbNQ3RJMPXbQJmYFebFR6SfB9QBkJdDzbG7GGT_3aZBkCfw@cipher.nrlssc.navy.mil","threadId":"15582","inReplyTo":"7vy71n482x.fsf@gitster.siamese.dyndns.org","subject":"[PATCH bc/maint-diff-hunk-header] t4018-diff-funcname: test syntax of builtin xfuncname patterns","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-09-22T23:19:05Z","receivedAt":"2008-09-22T23:19:05Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>\n---\n\n\nHow about something like this on top of your ERE conversion patch.\nIt will test that regcomp() completes successfully.\n\n-brandon\n\n\n t/t4018-diff-funcname.sh |   11 +++++++++++\n 1 files changed, 11 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh\nindex 602d68f..76919a4 100755\n--- a/t/t4018-diff-funcname.sh\n+++ b/t/t4018-diff-funcname.sh\n@@ -32,7 +32,18 @@ EOF\n \n sed 's/beer\\\\/beer,\\\\/' < Beer.java > Beer-correct.java\n \n+builtin_patterns=\"bibtex java pascal ruby tex\"\n+for p in $builtin_patterns\n+do\n+\ttest_expect_success \"builtin $p pattern compiles\" '\n+\t\techo \"*.java diff=$p\" > .gitattributes &&\n+\t\tgit diff --no-index Beer.java Beer-correct.java 2>&1 |\n+\t\t\ttest_must_fail grep \"fatal\" > /dev/null\n+\t'\n+done\n+\n test_expect_success 'default behaviour' '\n+\trm -f .gitattributes &&\n \tgit diff --no-index Beer.java Beer-correct.java |\n \tgrep \"^@@.*@@ public class Beer\"\n '\n-- \n1.6.0.1.244.gdc19\n"},{"id":"91345","messageId":"CTXDOuN2-1v4gLJ9IqQwhgSzVh_BwEQIV70MoNH_beVI1QE7-TLy7g@cipher.nrlssc.navy.mil","threadId":"15582","inReplyTo":"b-t750rmbNQ3RJMPXbQJmYFebFR6SfB9QBkJdDzbG7GGT_3aZBkCfw@cipher.nrlssc.navy.mil","subject":"[PATCH bc/master-diff-hunk-header] t4018-diff-funcname: test syntax of builtin xfuncname patterns","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-09-22T23:26:20Z","receivedAt":"2008-09-22T23:26:20Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>\n---\n\n\nAnd then this goes on top of bc/master-diff-hunk-header once\nbc/maint-diff-hunk-header with the previous patch is merged in.\n\n-brandon\n\n\n t/t4018-diff-funcname.sh |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh\nindex 76919a4..5b58f50 100755\n--- a/t/t4018-diff-funcname.sh\n+++ b/t/t4018-diff-funcname.sh\n@@ -32,7 +32,7 @@ EOF\n \n sed 's/beer\\\\/beer,\\\\/' < Beer.java > Beer-correct.java\n \n-builtin_patterns=\"bibtex java pascal ruby tex\"\n+builtin_patterns=\"bibtex html java pascal php python ruby tex\"\n for p in $builtin_patterns\n do\n \ttest_expect_success \"builtin $p pattern compiles\" '\n-- \n1.6.0.1.244.gdc19\n"},{"id":"91348","messageId":"200809230249.23298.johan@herland.net","threadId":"15582","inReplyTo":"CTXDOuN2-1v4gLJ9IqQwhgSzVh_BwEQIV70MoNH_beVI1QE7-TLy7g@cipher.nrlssc.navy.mil","subject":"[PATCH] diff funcname_pattern: Allow HTML header tags without attributes","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2008-09-23T00:49:23Z","receivedAt":"2008-09-23T00:49:23Z","isPatch":true,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"Signed-off-by: Johan Herland <johan@herland.net>\n---\n\nOn Tuesday 23 September 2008, Brandon Casey wrote:\n> And then this goes on top of bc/master-diff-hunk-header once\n> bc/maint-diff-hunk-header with the previous patch is merged in.\n\nAfter looking over this once more, I think the HTML regexp should be\nchanged as follows. This fixes a buglet that was part of my original\nHTML pattern, and although this patch textually depends on Brandon's\nwork, it is conceptually independent of his refactorization.\n\n\nHave fun!\n\n...Johan\n\n diff.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex d0e7319..c8b72f4 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -1424,7 +1424,7 @@ static const struct funcname_pattern_entry *funcname_pattern(const char *ident)\n static const struct funcname_pattern_entry builtin_funcname_pattern[] = {\n \t{ \"bibtex\", \"(@[a-zA-Z]{1,}[ \\t]*\\{{0,1}[ \\t]*[^ \\t\\\"@',\\\\#}{~%]*).*$\",\n \t  REG_EXTENDED },\n-\t{ \"html\", \"^[ \\t]*(<[Hh][1-6][ \\t].*>.*)$\", REG_EXTENDED },\n+\t{ \"html\", \"^[ \\t]*(<[Hh][1-6]([ \\t].*)?>.*)$\", REG_EXTENDED },\n \t{ \"java\",\n \t  \"!^[ \\t]*(catch|do|for|if|instanceof|new|return|switch|throw|while)\\n\"\n \t  \"^[ \\t]*(([ \\t]*[A-Za-z_][A-Za-z_0-9]*){2,}[ \\t]*\\\\([^;]*)$\",\n-- \n1.6.0.2.405.g3cc38\n"},{"id":"91349","messageId":"7v7i93ws64.fsf@gitster.siamese.dyndns.org","threadId":"15582","inReplyTo":"200809230249.23298.johan@herland.net","subject":"Re: [PATCH] diff funcname_pattern: Allow HTML header tags without attributes","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-09-23T01:46:11Z","receivedAt":"2008-09-23T01:46:11Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johan Herland <johan@herland.net> writes:\n\n> After looking over this once more, I think the HTML regexp should be\n> changed as follows. This fixes a buglet that was part of my original\n> HTML pattern, and although this patch textually depends on Brandon's\n> work, it is conceptually independent of his refactorization.\n> ...\n> -\t{ \"html\", \"^[ \\t]*(<[Hh][1-6][ \\t].*>.*)$\", REG_EXTENDED },\n> +\t{ \"html\", \"^[ \\t]*(<[Hh][1-6]([ \\t].*)?>.*)$\", REG_EXTENDED },\n\nI do not think these two particularly would make much difference.  Why\nisn't it simply...\n\n\t\"<[Hh][1-6].*\"\n\nwithout even any capture or anchor?\n\nIt would falsely hit oddball cases like <h1foo> which is not <h1>, but\nanybody who uses such a nonstandard thing deserves it, imnvho ;-).\n"},{"id":"91350","messageId":"200809230405.04471.johan@herland.net","threadId":"15582","inReplyTo":"7v7i93ws64.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] diff funcname_pattern: Allow HTML header tags without attributes","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2008-09-23T02:05:04Z","receivedAt":"2008-09-23T02:05:04Z","isPatch":true,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"On Tuesday 23 September 2008, Junio C Hamano wrote:\n> Johan Herland <johan@herland.net> writes:\n> > After looking over this once more, I think the HTML regexp should be\n> > changed as follows. This fixes a buglet that was part of my original\n> > HTML pattern, and although this patch textually depends on Brandon's\n> > work, it is conceptually independent of his refactorization.\n> > ...\n> > -\t{ \"html\", \"^[ \\t]*(<[Hh][1-6][ \\t].*>.*)$\", REG_EXTENDED },\n> > +\t{ \"html\", \"^[ \\t]*(<[Hh][1-6]([ \\t].*)?>.*)$\", REG_EXTENDED },\n>\n> I do not think these two particularly would make much difference.  Why\n> isn't it simply...\n>\n> \t\"<[Hh][1-6].*\"\n>\n> without even any capture or anchor?\n>\n> It would falsely hit oddball cases like <h1foo> which is not <h1>, but\n> anybody who uses such a nonstandard thing deserves it, imnvho ;-).\n\nOk. I agree. Go ahead.\n\n\n...Johan\n\n-- \nJohan Herland, <johan@herland.net>\nwww.herland.net\n"},{"id":"91443","messageId":"qzJgAPRiQZfGnPgFs3xqeXM_jkaODH54dU-hZgP_AftxmMjJxFOfyQ@cipher.nrlssc.navy.mil","threadId":"15582","inReplyTo":"i-l9YX2TO45e2OB9LuoxrAN6a2iFYaH_eEGlVmRsP0oa97XuwX4eGQ@cipher.nrlssc.navy.mil","subject":"Re: [PATCH v2 4/4] diff.c: convert builtin funcname patterns to non-GNU extended regex syntax","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-09-24T00:04:40Z","receivedAt":"2008-09-24T00:04:40Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"Brandon Casey wrote:\n\n> I'll do some testing on non-GNU platforms today.\n\nWell, all I've done is compile, and it compiles and runs the\ntests correctly. Thought I'd let you know I did at least that.\n\n-brandon\n"},{"id":"91708","messageId":"ZOivOHIiBa1yoDqFPq18uB0VuTttUsV4lS5k7YcyEsM@cipher.nrlssc.navy.mil","threadId":"15582","inReplyTo":"qzJgAPRiQZfGnPgFs3xqeXM_jkaODH54dU-hZgP_AftxmMjJxFOfyQ@cipher.nrlssc.navy.mil","subject":"Re: [PATCH v2 4/4] diff.c: convert builtin funcname patterns to non-GNU extended regex syntax","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-09-26T17:49:17Z","receivedAt":"2008-09-26T17:49:17Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"\nShawn,\n\nWhen you get around to merging this series into maint and master,\nyou'll probably want to redo the merge of Junio's\nbc/maint-diff-hunk-header-fix into bc/master-diff-hunk-header-fix.\n\nAfter applying 'diff hunkpattern: fix misconverted \"\\{\" tex macro introducers'\nto bc/maint-diff-hunk-header-fix, he made a mistake when merging\n96d1a8e9 into his bc/master-diff-hunk-header-fix which was at 3d8dccd7 to\nproduce 92bb9785. (gitk fdac6692 makes this easier to see. fdac6692 should\nbe the current tip of bc/master-diff-hunk...)\n\nThe resulting diff.c in 92bb9785, contains _two_ bibtex patterns, one fixed\nby the 'diff hunkpattern:...' patch, and one unfixed. The broken bibtex\npattern was eventually fixed, but the duplicate pattern is still there on\nthe tip of that branch and in next. It would be nice if the merge could be\nredone.\n\nHere are the commands, since sometimes it makes more sense this way:\n\ngit branch bc/maint-diff-hunk-header-fix 96d1a8e9\ngit checkout -b bc/master-diff-hunk-header-fix 3d8dccd7\ngit merge bc/maint-diff-hunk-header-fix\n# fix conflict, make sure you choose the right bibtex pattern\n# and delete the other. The builtin-funcname patterns were\n# also alphabetized on the master branch, so the correct bibtex\n# should be moved to the first entry.\n\n# then reapply the other two patches\ngit checkout bc/maint-diff-hunk-header-fix\ngit cherry-pick e3bf5e43\ngit checkout bc/master-diff-hunk-header-fix\ngit merge bc/maint-diff-hunk-header-fix\ngit cherry-pick fdac6692\ngit commit --amend\n# Remove Junio's comment about 'fixes bibtex pattern breakage exposed\n# by this test'\n\n-brandon\n"},{"id":"91883","messageId":"JQHRn-pjQtWl2uVwYYUaYhDMb4iGr1mbVT_C8PZkoJXkQVnH42a98w@cipher.nrlssc.navy.mil","threadId":"15582","inReplyTo":"ZOivOHIiBa1yoDqFPq18uB0VuTttUsV4lS5k7YcyEsM@cipher.nrlssc.navy.mil","subject":"[PATCH] diff.c: remove duplicate bibtex pattern introduced by merge 92bb9785","fromName":"Brandon Casey","fromEmail":"casey@nrlssc.navy.mil","sentAt":"2008-09-29T21:52:01Z","receivedAt":"2008-09-29T21:52:01Z","isPatch":true,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil>\n---\n diff.c |    2 --\n 1 files changed, 0 insertions(+), 2 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex b001d7b..7c982b4 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -1439,8 +1439,6 @@ static const struct funcname_pattern_entry builtin_funcname_pattern[] = {\n \t{ \"python\", \"^[ \\t]*((class|def)[ \\t].*)$\", REG_EXTENDED },\n \t{ \"ruby\", \"^[ \\t]*((class|module|def)[ \\t].*)$\",\n \t  REG_EXTENDED },\n-\t{ \"bibtex\", \"(@[a-zA-Z]{1,}[ \\t]*\\\\{{0,1}[ \\t]*[^ \\t\\\"@',\\\\#}{~%]*).*$\",\n-\t  REG_EXTENDED },\n \t{ \"tex\",\n \t  \"^(\\\\\\\\((sub)*section|chapter|part)\\\\*{0,1}\\\\{.*)$\",\n \t  REG_EXTENDED },\n-- \n1.6.0.2.323.g7c850\n"}]}