aboutsummaryrefslogtreecommitdiff
path: root/miscutils/less.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-12-31 19:23:31 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-12-31 19:23:31 +0000
commit95b307103a60b7d023929c29952e1e6798564bef (patch)
tree78d677112a4626a51b1e1cb2c8ae2f5654509270 /miscutils/less.c
parentc519320000972421e6dbc197e504dd1f0c546c1d (diff)
downloadbusybox-w32-95b307103a60b7d023929c29952e1e6798564bef.tar.gz
busybox-w32-95b307103a60b7d023929c29952e1e6798564bef.tar.bz2
busybox-w32-95b307103a60b7d023929c29952e1e6798564bef.zip
less: interpret backspace.
less is officially declared PAGER-capable! ;) (this includes viewing of manpages)
Diffstat (limited to 'miscutils/less.c')
-rw-r--r--miscutils/less.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/miscutils/less.c b/miscutils/less.c
index 916213082..ae936c2fb 100644
--- a/miscutils/less.c
+++ b/miscutils/less.c
@@ -212,11 +212,21 @@ static void read_lines(void)
212 } 212 }
213 } 213 }
214 c = readbuf[readpos]; 214 c = readbuf[readpos];
215 /* backspace? [need this for manpage display] */
216 if (c == '\x8' && linepos) {
217 readpos++; /* eat it */
218 /* We do not consider the case of <tab><bs> */
219 /* Anyone who has that is pure evil :) */
220 linepos--;
221 *p-- = '\0';
222 continue;
223 }
215 if (c == '\t') 224 if (c == '\t')
216 linepos += (linepos^7) & 7; 225 linepos += (linepos^7) & 7;
217 linepos++; 226 linepos++;
218 if (linepos >= w) 227 if (linepos >= w)
219 break; 228 break;
229 /* ok, we will eat this char */
220 readpos++; 230 readpos++;
221 if (c == '\n') { terminated = 1; break; } 231 if (c == '\n') { terminated = 1; break; }
222 /* NUL is substituted by '\n'! */ 232 /* NUL is substituted by '\n'! */
@@ -1175,6 +1185,9 @@ int less_main(int argc, char **argv)
1175{ 1185{
1176 int keypress; 1186 int keypress;
1177 1187
1188 /* TODO: -x: do not interpret backspace, -xx: tab also */
1189 /* -xxx: newline also */
1190 /* -w N: assume width N (-xxx -w 32: hex viewer of sorts) */
1178 getopt32(argc, argv, "EMmN~"); 1191 getopt32(argc, argv, "EMmN~");
1179 argc -= optind; 1192 argc -= optind;
1180 argv += optind; 1193 argv += optind;