{"thread":{"id":"43265","subject":"[PATCH] Increase length of function name buffer","startedAt":"2006-11-23T10:05:17Z","lastAt":"2006-11-24T06:47:44Z","messageCount":3,"participants":["Andy Parkins","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"294181","messageId":"200611231005.17859.andyparkins@gmail.com","threadId":"43265","inReplyTo":null,"subject":"[PATCH] Increase length of function name buffer","fromName":"Andy Parkins","fromEmail":"andyparkins@gmail.com","sentAt":"2006-11-23T10:05:17Z","receivedAt":"2006-11-23T10:05:17Z","isPatch":true,"sender":{"key":"andyparkins@gmail.com","avatar":null},"body":"In xemit.c:xdl_emit_diff() a buffer for showing the function name as\ncommentary is allocated; this buffer was 40 characters.  This is a bit\nsmall; particularly for C++ function names where there is often an\nidentical prefix (like void LongNamespace::LongClassName) on multiple\nfunctions, which makes the context the same everywhere.  In other words\nthe context is useless.  This patch increases that buffer to 80\ncharacters - which may still not be enough, but is better\n\nSigned-off-by: Andy Parkins <andyparkins@gmail.com>\n---\n xdiff/xemit.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/xdiff/xemit.c b/xdiff/xemit.c\nindex 07995ec..e291dc7 100644\n--- a/xdiff/xemit.c\n+++ b/xdiff/xemit.c\n@@ -118,7 +118,7 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,\n \t\t  xdemitconf_t const *xecfg) {\n \tlong s1, s2, e1, e2, lctx;\n \txdchange_t *xch, *xche;\n-\tchar funcbuf[40];\n+\tchar funcbuf[80];\n \tlong funclen = 0;\n \n \tif (xecfg->flags & XDL_EMIT_COMMON)\n-- \n1.4.3.GIT-dirty\n"},{"id":"295274","messageId":"7vbqmxkhpk.fsf@assigned-by-dhcp.cox.net","threadId":"43265","inReplyTo":"200611231005.17859.andyparkins@gmail.com","subject":"Re: [PATCH] Increase length of function name buffer","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-11-23T20:53:43Z","receivedAt":"2006-11-23T20:53:43Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Andy Parkins <andyparkins@gmail.com> writes:\n\n> In xemit.c:xdl_emit_diff() a buffer for showing the function name as\n> commentary is allocated; this buffer was 40 characters.  This is a bit\n> small; particularly for C++ function names where there is often an\n> identical prefix (like void LongNamespace::LongClassName) on multiple\n> functions, which makes the context the same everywhere.  In other words\n> the context is useless.  This patch increases that buffer to 80\n> characters - which may still not be enough, but is better.\n>\n> Signed-off-by: Andy Parkins <andyparkins@gmail.com>\n\nI agree this is a good problem to address.\n\nI wonder however which is easier to read, a loooong heading line\nas you do in this patch, or \"...TailOfVeryLongClassName::method\"\nthat still fits on a single line without terminal line-wrapping.\nEspecially with our default settings that runs \"less\" with -S to\ntruncate the right hand side of a long line, truncating at the\ntop (instead of at the tail as we currently do) might be easier\nto read.\n\nNot rejecting your implementation and asking to change the\npatch; asking for opinions from the list.\n"},{"id":"297995","messageId":"7vk61le3xr.fsf@assigned-by-dhcp.cox.net","threadId":"43265","inReplyTo":"7vbqmxkhpk.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Increase length of function name buffer","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-11-24T06:47:44Z","receivedAt":"2006-11-24T06:47:44Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <junkio@cox.net> writes:\n\n> Andy Parkins <andyparkins@gmail.com> writes:\n>\n>> In xemit.c:xdl_emit_diff() a buffer for showing the function name as\n>> commentary is allocated; this buffer was 40 characters.  This is a bit\n>> small;...\n >...\n> I wonder however which is easier to read, a loooong heading line\n> as you do in this patch, or \"...TailOfVeryLongClassName::method\"\n> that still fits on a single line without terminal line-wrapping.\n\nNah, I was stupid again.\n\nIt would give something silly like the attached patch if we do\nwhat I suggested (notice the function header line which does not\ngive us anything useful).\n\nWill apply your version as is.\n\n---\n\ndiff --git a/xdiff/xemit.c b/xdiff/xemit.c\nindex 07995ec..30d3df1 100644\n--- a/xdiff/xemit.c\n+++ b/xdiff/xemit.c\n@@ -87,8 +87,10 @@ long i, char *buf, long sz, long *ll) {\n \t\t    (isalpha((unsigned char)*rec) || /* identifier? */\n \t\t     *rec == '_' ||\t/* also identifier? */\n \t\t     *rec == '$')) {\t/* mysterious GNU diff's invention */\n-\t\t\tif (len > sz)\n+\t\t\tif (len > sz) {\n+\t\t\t\trec += len - sz;\n \t\t\t\tlen = sz;\n+\t\t\t}\n \t\t\twhile (0 < len && isspace((unsigned char)rec[len - 1]))\n \t\t\t\tlen--;\n \t\t\tmemcpy(buf, rec, len);\n"}]}