git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Increase length of function name buffer
@ 2006-11-23 10:05 Andy Parkins
  2006-11-23 20:53 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Parkins @ 2006-11-23 10:05 UTC (permalink / raw)
  To: git

In xemit.c:xdl_emit_diff() a buffer for showing the function name as
commentary is allocated; this buffer was 40 characters.  This is a bit
small; particularly for C++ function names where there is often an
identical prefix (like void LongNamespace::LongClassName) on multiple
functions, which makes the context the same everywhere.  In other words
the context is useless.  This patch increases that buffer to 80
characters - which may still not be enough, but is better

Signed-off-by: Andy Parkins <andyparkins@gmail.com>
---
 xdiff/xemit.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/xdiff/xemit.c b/xdiff/xemit.c
index 07995ec..e291dc7 100644
--- a/xdiff/xemit.c
+++ b/xdiff/xemit.c
@@ -118,7 +118,7 @@ int xdl_emit_diff(xdfenv_t *xe, xdchange_t *xscr, xdemitcb_t *ecb,
 		  xdemitconf_t const *xecfg) {
 	long s1, s2, e1, e2, lctx;
 	xdchange_t *xch, *xche;
-	char funcbuf[40];
+	char funcbuf[80];
 	long funclen = 0;
 
 	if (xecfg->flags & XDL_EMIT_COMMON)
-- 
1.4.3.GIT-dirty

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Increase length of function name buffer
  2006-11-23 10:05 [PATCH] Increase length of function name buffer Andy Parkins
@ 2006-11-23 20:53 ` Junio C Hamano
  2006-11-24  6:47   ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2006-11-23 20:53 UTC (permalink / raw)
  To: Andy Parkins; +Cc: git

Andy Parkins <andyparkins@gmail.com> writes:

> In xemit.c:xdl_emit_diff() a buffer for showing the function name as
> commentary is allocated; this buffer was 40 characters.  This is a bit
> small; particularly for C++ function names where there is often an
> identical prefix (like void LongNamespace::LongClassName) on multiple
> functions, which makes the context the same everywhere.  In other words
> the context is useless.  This patch increases that buffer to 80
> characters - which may still not be enough, but is better.
>
> Signed-off-by: Andy Parkins <andyparkins@gmail.com>

I agree this is a good problem to address.

I wonder however which is easier to read, a loooong heading line
as you do in this patch, or "...TailOfVeryLongClassName::method"
that still fits on a single line without terminal line-wrapping.
Especially with our default settings that runs "less" with -S to
truncate the right hand side of a long line, truncating at the
top (instead of at the tail as we currently do) might be easier
to read.

Not rejecting your implementation and asking to change the
patch; asking for opinions from the list.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Increase length of function name buffer
  2006-11-23 20:53 ` Junio C Hamano
@ 2006-11-24  6:47   ` Junio C Hamano
  0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2006-11-24  6:47 UTC (permalink / raw)
  To: Andy Parkins; +Cc: git

Junio C Hamano <junkio@cox.net> writes:

> Andy Parkins <andyparkins@gmail.com> writes:
>
>> In xemit.c:xdl_emit_diff() a buffer for showing the function name as
>> commentary is allocated; this buffer was 40 characters.  This is a bit
>> small;...
 >...
> I wonder however which is easier to read, a loooong heading line
> as you do in this patch, or "...TailOfVeryLongClassName::method"
> that still fits on a single line without terminal line-wrapping.

Nah, I was stupid again.

It would give something silly like the attached patch if we do
what I suggested (notice the function header line which does not
give us anything useful).

Will apply your version as is.

---

diff --git a/xdiff/xemit.c b/xdiff/xemit.c
index 07995ec..30d3df1 100644
--- a/xdiff/xemit.c
+++ b/xdiff/xemit.c
@@ -87,8 +87,10 @@ long i, char *buf, long sz, long *ll) {
 		    (isalpha((unsigned char)*rec) || /* identifier? */
 		     *rec == '_' ||	/* also identifier? */
 		     *rec == '$')) {	/* mysterious GNU diff's invention */
-			if (len > sz)
+			if (len > sz) {
+				rec += len - sz;
 				len = sz;
+			}
 			while (0 < len && isspace((unsigned char)rec[len - 1]))
 				len--;
 			memcpy(buf, rec, len);

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-11-24  6:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-23 10:05 [PATCH] Increase length of function name buffer Andy Parkins
2006-11-23 20:53 ` Junio C Hamano
2006-11-24  6:47   ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).