Unix Technical Forum

Re: [patch] less: trailing space

This is a discussion on Re: [patch] less: trailing space within the mailing.openbsd.tech forums, part of the OpenBSD category; --> On Mon, 22 May 2006, Kenneth R Westerback wrote: > On Mon, May 22, 2006 at 12:49:46PM +0930, Matthew ...


Go Back   Unix Technical Forum > Unix Operating Systems > OpenBSD > mailing.openbsd.tech

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-18-2008, 08:38 AM
Otto Moerbeek
 
Posts: n/a
Default Re: [patch] less: trailing space

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
> > $


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 01:32 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com