[BusyBox] [PATCH] less applet

Rob Sullivan cogito.ergo.cogito at gmail.com
Sat May 14 22:32:45 UTC 2005


Hi,
attached is the diff to include a tiny implementation of less in
Busybox. It needs a *lot* of work, and should be considered in the
beta (or even alpha) stage, but I thought I'd post this patch to see
what others make of it.
The TODO list is roughly as follows, with the most important issues at the top:

- Optimise and fix up code: currently less builds with some function
prototype warnings, and much of its code could probably be shortened.
Also, terminal handling may not work too well on terminals with
different sizes than 80x24, and more error checking could be added.

- Add regular expressions - I'm not too versed in the lore of C
regular expressions (I was brought up on Perl), so it would be useful
if someone could add regular expression support. I've added two
placeholder functions just before main() to make it easier - all
that's necessary is to match a regex against a line and add the ASCII
escape sequences for highlighted and normal text to either side of
each match in the line. The lines are supplied from the currently open
file by the placeholder functions, and the regex is also input and
compiled using regcomp by them.

- Allow horizontal scrolling - currently, this less implementation
simply wraps lines greater than the terminal's width onto the next
line, whereas the real less has horizontal scrolling capabilities.

- Add other functions incorporated into the real less - these include
the F option to act like tail -f, tags, and external shell
command/editor execution. Moreover, the entire file is currently
loaded into this tiny implementation (meaning files have a 10,000 line
limit) - the real less uses a 64kb buffer.
 

Besides all that, this less implementation should function well for
common usage. The binary stripped is currently around 12kb.

Thanks,
Rob
-------------- next part --------------
A non-text attachment was scrubbed...
Name: less.patch
Type: application/octet-stream
Size: 24293 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20050515/23f1c5ea/attachment.obj 


More information about the busybox mailing list