diff options
author | ps <ps@FreeBSD.org> | 2002-01-07 20:29:38 +0000 |
---|---|---|
committer | ps <ps@FreeBSD.org> | 2002-01-07 20:29:38 +0000 |
commit | c0c85bc41cb6c023adae56cf0a7e3495bd528cb2 (patch) | |
tree | 22ed5b4269586d3d5c21d37a27645897709341e3 /contrib/less/optfunc.c | |
parent | 5d465776b9e058088e1f29636cf7cdcb0c13eb0d (diff) | |
download | FreeBSD-src-c0c85bc41cb6c023adae56cf0a7e3495bd528cb2.zip FreeBSD-src-c0c85bc41cb6c023adae56cf0a7e3495bd528cb2.tar.gz |
Import less v371
Diffstat (limited to 'contrib/less/optfunc.c')
-rw-r--r-- | contrib/less/optfunc.c | 61 |
1 files changed, 60 insertions, 1 deletions
diff --git a/contrib/less/optfunc.c b/contrib/less/optfunc.c index e3fb861..524551c 100644 --- a/contrib/less/optfunc.c +++ b/contrib/less/optfunc.c @@ -42,6 +42,7 @@ extern char closequote; extern char *prproto[]; extern char *eqproto; extern char *hproto; +extern char *wproto; extern IFILE curr_ifile; extern char version[]; #if LOGFILE @@ -291,6 +292,7 @@ opt__P(type, s) case 'M': proto = &prproto[PR_LONG]; s++; break; case '=': proto = &eqproto; s++; break; case 'h': proto = &hproto; s++; break; + case 'w': proto = &wproto; s++; break; default: proto = &prproto[PR_SHORT]; break; } free(*proto); @@ -368,10 +370,11 @@ opt__V(type, s) any_display = 1; putstr("less "); putstr(version); - putstr("\nCopyright (C) 2000 Mark Nudelman\n\n"); + putstr("\nCopyright (C) 2001 Mark Nudelman\n\n"); putstr("less comes with NO WARRANTY, to the extent permitted by law.\n"); putstr("For information about the terms of redistribution,\n"); putstr("see the file named README in the less distribution.\n"); + putstr("Homepage: http://www.greenwoodsoftware.com/less\n"); quit(QUIT_OK); break; } @@ -461,6 +464,62 @@ opt_D(type, s) #endif /* + * Handler for the -x option. + */ + public void +opt_x(type, s) + int type; + register char *s; +{ + extern int tabstops[]; + extern int ntabstops; + extern int tabdefault; + char msg[60+(4*TABSTOP_MAX)]; + int i; + PARG p; + + switch (type) + { + case INIT: + case TOGGLE: + /* Start at 1 because tabstops[0] is always zero. */ + for (i = 1; i < TABSTOP_MAX; ) + { + int n = 0; + while (*s >= '0' && *s <= '9') + n = (10 * n) + (*s++ - '0'); + if (n > tabstops[i-1]) + tabstops[i++] = n; + if (*s++ != ',') + break; + } + if (i < 2) + return; + ntabstops = i; + tabdefault = tabstops[ntabstops-1] - tabstops[ntabstops-2]; + break; + case QUERY: + strcpy(msg, "Tab stops "); + if (ntabstops > 2) + { + for (i = 1; i < ntabstops; i++) + { + if (i > 1) + strcat(msg, ","); + sprintf(msg+strlen(msg), "%d", tabstops[i]); + } + sprintf(msg+strlen(msg), " and then "); + } + sprintf(msg+strlen(msg), "every %d spaces", + tabdefault); + p.p_string = msg; + error("%s", &p); + break; + } +} + + +/* * Handler for the -" option. */ public void |