Post a Comment On: /dev/dump

"Modernizing "less""

12 Comments -

1 – 12 of 12
Comment deleted

This comment has been removed by a blog administrator.

September 7, 2014 at 4:23 PM

Blogger Marvin R. said...

Have you thought of making this a stand alone repo and put it into github? Maybe you can get it adopted by Homebrew or do packages for Linux systems (having PPA for Ubuntu in mind)? And because it breaks backwards compatibility maybe rename it also... like "less2" or something like that?

September 7, 2014 at 4:23 PM

Blogger Garrett D'Amore said...

I could pull this work out pretty easily I suppose. I'm not terribly worried about name collisions, but if someone wants me to change it ("least"?) I am happy to do so.

I've just also pushed another substantial set of fixes, which I think bring the utility into 100% compliance with XPG7/POSIX 2008. I don't think any other more utility on the planet is conformant (they all get the "s" command wrong from my testing.)

It will take a seriously dedicated effort for someone to notice that this more is "not" the same more we have had all along. Check out the repo.

September 7, 2014 at 6:35 PM

Blogger Doug Anderson said...

Could you comment on how you made these changes? Was any of it automated, even with sed/perl/editor macros? I'm hoping to apply your techniques to similar old code bases.

September 7, 2014 at 8:25 PM

Blogger jimmies rustled said...

Call it.... none.

September 7, 2014 at 11:40 PM

Blogger Amit Kulkarni said...

Please put this in a separate repo of your choice!

thanks

September 8, 2014 at 5:36 AM

Blogger Alex B. said...

I would also encourage you to release it on Github.

Did you use version control while doing the changes?

If not, please first import the original less (if it has a git repo, even better) and apply your changes to it, even if only in one commit, it will help understanding what changed.

September 8, 2014 at 7:13 AM

Blogger rdnewman said...

I've been using most (available in most repos) instead of more or less. Glad to see less is getting some attention though.

September 8, 2014 at 6:00 PM

Blogger Garrett D'Amore said...

I've posted a repo, starting with an initial import of less v458, to bitbucket:

https://bitbucket.org/gdamore/less-fork/

This has the latest changes. I've verified full POSIX compliance, and I've fixed quit a number of other bugs, including a few potential crashers.

September 9, 2014 at 8:57 PM

Blogger jbn said...

This code, much like GNU coreutils/textutils or the equivalent BSD code, is peppered with globals... even if these end up in the BSS, they inevitably (I think... and I never understood why people still write code like that) cause a page fault on the first access and they ensure that each running copy has to have a private page to have those in... There is no reason for globals to exist at all, they should be in a struct in automatic storage in main(), so that they use only a few bytes on the stack instead of an initially-zero-filled private memory page...
oh well.


It's not that important for a pager, but think of all the utilities that run constantly on a server..

September 17, 2014 at 7:05 PM

Blogger Garrett D'Amore said...

jbn:

No disagreement from me. I didn't write this code. I just improved it.

That said, a private copy of the bss page, or a page of stack -- shouldn't make much difference either way.

Typically even on a busy server there aren't more than a few copies of less running. (vi is another story!)

Now as far as the rest of the coreutils... well, bleh. Hopefully the BSD code is better, and even more so the illumos code.

Feel free to offer up diffs for improvements, btw!

September 17, 2014 at 7:10 PM

Blogger jbn said...

the difference between a page in BSS and some space on the stack is that the stack is already faulted in (a page's worth of it, at least), whereas for globals you pay the cost of at least one page (or more than one if you really have a lot of globals... large programs do this :( ), only to store a handful of int-sized variables... so to store the 20 things in main.c you pay 4K (or whatever the page size is)... on systems with many VMs/zones running, each with many processes, this adds up (although I've never bothered to measure it).

I'll take a look at the illumos code :)

September 17, 2014 at 7:21 PM