vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| On Mon, 22 May 2006, Kenneth R Westerback wrote: > On Mon, May 22, 2006 at 12:49:46PM +0930, Matthew Haub wrote: > > On Sun, May 21, 2006 at 11:04:14PM +0930, Matthew Haub wrote: > > > Index: src/usr.bin/less/filename.c > > > ================================================== ================= > > > RCS file: /cvs/src/usr.bin/less/filename.c,v > > > retrieving revision 1.10 > > > diff -u -r1.10 filename.c > > > --- src/usr.bin/less/filename.c 2004/08/23 17:56:20 1.10 > > > +++ src/usr.bin/less/filename.c 2006/05/21 13:21:15 > > > @@ -676,7 +676,7 @@ > > > /* > > > * Overwrite the final trailing space with a null terminator. > > > */ > > > - *--p = '\0'; > > > + gfilename[strlen(gfilename) - 1] = '\0'; > > > GLOB_LIST_DONE(list); > > > } > > > #else > > > > Hi, > > > > dlg@ says explanations are important, even for one-liners > > > > lglob() returns gfilename, which has an extra space on the end, this is > > what we really want to overwrite with a null character. This'll stop > > less from appending a trailing space to the filename you log to. > > > > Removing the *--p will stop less from segfaulting when cycling through > > auto-complete entries. Here p points to the first character of the last > > entry in the auto-complete list. There's no reason to set the character > > before it to null, it may not be allocated memory. The macro > > GLOB_LIST_DONE calls globfree() which frees any space associated with > > the list anyhow. > > > > With that explanation, looks ok to me. :-). yep, committed, thanks, -Otto > > .... Ken > > > ======================== > > Example 1, segfault: > > ======================== > > > > $ mkdir mess > > $ cd mess > > $ touch file > > $ mkdir directory > > $ ls -1F > > directory/ > > file > > $ echo hi | less > > > > now type :e./<tab><tab><tab> > > > > hi > > Examine: ./fileSegmentation fault (core dumped) > > $ > > > > ======================== > > Example 2, trailing space > > ======================== > > > > $ echo hi | less > > > > now type sout<enter>q > > > > $ ls -1F > > directory/ > > file > > out > > $ ls out > > ls: out: No such file or directory > > $ ls out\ > > out > > $ |