{"thread":{"id":"13073","subject":"[PATCH] make --color-words separate word on ispunct","startedAt":"2008-04-12T10:33:41Z","lastAt":"2008-04-12T17:50:21Z","messageCount":4,"participants":["sgala@hisitech.com","Johannes Schindelin","Ping Yin","Santiago Gala"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"74195","messageId":"1207996421-29651-1-git-send-email-sgala@apache.org","threadId":"13073","inReplyTo":null,"subject":"[PATCH] make --color-words separate word on ispunct","fromName":"","fromEmail":"sgala@hisitech.com","sentAt":"2008-04-12T10:33:41Z","receivedAt":"2008-04-12T10:33:41Z","isPatch":true,"sender":{"key":"sgala@hisitech.com","avatar":null},"body":"Note that this may actually be harmful when trying to spot punctuation\nchanges, but for this use case I don't think color-words is helping\nnow either.\n\nSigned-off-by: Santiago Gala <sgala@apache.org>\n---\n diff.c |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 8022e67..d301fcc 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -448,7 +448,7 @@ static void diff_words_show(struct diff_words_data *diff_words)\n \tminus.ptr = xmalloc(minus.size);\n \tmemcpy(minus.ptr, diff_words->minus.text.ptr, minus.size);\n \tfor (i = 0; i < minus.size; i++)\n-\t\tif (isspace(minus.ptr[i]))\n+\t\tif (isspace(minus.ptr[i]) || ispunct(minus.ptr[i]))\n \t\t\tminus.ptr[i] = '\\n';\n \tdiff_words->minus.current = 0;\n \n@@ -456,7 +456,7 @@ static void diff_words_show(struct diff_words_data *diff_words)\n \tplus.ptr = xmalloc(plus.size);\n \tmemcpy(plus.ptr, diff_words->plus.text.ptr, plus.size);\n \tfor (i = 0; i < plus.size; i++)\n-\t\tif (isspace(plus.ptr[i]))\n+\t\tif (isspace(plus.ptr[i]) || ispunct(plus.ptr[i]))\n \t\t\tplus.ptr[i] = '\\n';\n \tdiff_words->plus.current = 0;\n \n-- \n1.5.5.44.gdfa65.dirty\n"},{"id":"74211","messageId":"alpine.DEB.1.00.0804121621560.16366@eeepc-johanness","threadId":"13073","inReplyTo":"1207996421-29651-1-git-send-email-sgala@apache.org","subject":"Re: [PATCH] make --color-words separate word on ispunct","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-04-12T15:23:32Z","receivedAt":"2008-04-12T15:23:32Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sat, 12 Apr 2008, sgala@hisitech.com wrote:\n\n> Note that this may actually be harmful when trying to spot punctuation \n> changes, but for this use case I don't think color-words is helping now \n> either.\n\nI do not know how commonly supported ispunct(), therefore I do not like \nthe patch too much.\n\nBesides, since long ago I want to make the list of boundary characters \nconfigurable, preferably as a tr(1) style list, but I have not come around \nto do that yet.\n\nCiao,\nDscho\n"},{"id":"74213","messageId":"46dff0320804120832x733000e8md813e3f8525b889a@mail.gmail.com","threadId":"13073","inReplyTo":"alpine.DEB.1.00.0804121621560.16366@eeepc-johanness","subject":"Re: [PATCH] make --color-words separate word on ispunct","fromName":"Ping Yin","fromEmail":"pkufranky@gmail.com","sentAt":"2008-04-12T15:32:19Z","receivedAt":"2008-04-12T15:32:19Z","isPatch":true,"sender":{"key":"pkufranky@gmail.com","avatar":"https://avatars.githubusercontent.com/u/5346?v=4"},"body":"On Sat, Apr 12, 2008 at 11:23 PM, Johannes Schindelin\n<Johannes.Schindelin@gmx.de> wrote:\n> Hi,\n>\n>\n>  On Sat, 12 Apr 2008, sgala@hisitech.com wrote:\n>\n>  > Note that this may actually be harmful when trying to spot punctuation\n>  > changes, but for this use case I don't think color-words is helping now\n>  > either.\n>\n>  I do not know how commonly supported ispunct(), therefore I do not like\n>  the patch too much.\n>\n>  Besides, since long ago I want to make the list of boundary characters\n>  configurable, preferably as a tr(1) style list, but I have not come around\n>  to do that yet.\n>\n\nIt is so good an idea. I look forward to it. Futher, should\n--color-words support\nmultibyte characters where every character is a boundary?\n\n\n\n-- \nPing Yin\n"},{"id":"74219","messageId":"1208022621.15135.19.camel@marlow","threadId":"13073","inReplyTo":"46dff0320804120832x733000e8md813e3f8525b889a@mail.gmail.com","subject":"Re: [PATCH] make --color-words separate word on ispunct","fromName":"Santiago Gala","fromEmail":"sgala@hisitech.com","sentAt":"2008-04-12T17:50:21Z","receivedAt":"2008-04-12T17:50:21Z","isPatch":true,"sender":{"key":"sgala@hisitech.com","avatar":null},"body":"El sáb, 12-04-2008 a las 23:32 +0800, Ping Yin escribió:\n> On Sat, Apr 12, 2008 at 11:23 PM, Johannes Schindelin\n> <Johannes.Schindelin@gmx.de> wrote:\n> > Hi,\n> >\n> >\n> >  On Sat, 12 Apr 2008, sgala@hisitech.com wrote:\n> >\n> >  > Note that this may actually be harmful when trying to spot punctuation\n> >  > changes, but for this use case I don't think color-words is helping now\n> >  > either.\n> >\n> >  I do not know how commonly supported ispunct(), therefore I do not like\n> >  the patch too much.\n> >\n\nI didn't like the patch that much either, but at least it was a quick\nproof of concept. :)\n\nre: support of ispunct, ispunct checks, according to the linux man page,\nfor:\n\nany printable character which is not a  space  or  an alphanumeric\ncharacter.\n\nso isspace(c) || ispunct(c) -> isprint(c) && !isalnum(c)\n\n> >  Besides, since long ago I want to make the list of boundary characters\n> >  configurable, preferably as a tr(1) style list, but I have not come around\n> >  to do that yet.\n> >\n\nThat would be cool, it was my first thought until I saw this \"easy try\".\nBut I'm not a C programmer, I was just trying to spot the correctness of\na few name additions in lines of comma separated ids of 100 names or\nsomething like that. The patch I sent is not perfect, but achieved 80%\nof what I wanted with 10 minutes of effort (including build, test and\nsending the patch).\n\nOn the other hand, while --color-words is very useful for text or\ndetecting typos, with big text changes it sometimes gives worse results\nthan --color, see for instance, on the git repo, the second hunk of\n\ngit diff --stat -p --color-words\nf59774add488a6c5fb440a4aaa7255f594b1027d^ -- builtin-fetch.c\n\n(and just --color) Not sure how to fix it, or, ideally, having some\nautomated way to switch between line-oriented coloring and word-oriented\ncoloring depending of density of changes.\n\n> \n> It is so good an idea. I look forward to it. Futher, should\n> --color-words support\n> multibyte characters where every character is a boundary?\n> \n\nThis would require more changes, to the\niswspace/iswpunct/iswprint/iswalnum functions, with associated change\nfrom chars to wide chars.\n\nRegards\nSantiago\n"}]}