static char *sccsid
= "@(#)lcmd.c 3.6 83/08/25";
char *l_name
; /* name of command */
int l_lmin
; /* minimum length to check */
int l_lmax
; /* maximum length to check */
int l_amin
; /* minimum argument */
int l_amax
; /* maximum argument */
int (*l_func
)(); /* the function */
static struct lcmd lcmd
[] = {
"%", 1, 1, 0, 0, l_select
,
"buffer", 1, 0, 1, 1, l_buffer
,
"close", 1, 0, 0, -1, l_close
,
"escape", 1, 0, 1, 1, l_escape
,
"label", 1, 0, 2, 2, l_label
,
"source", 1, 0, 1, 1, l_source
,
"terse", 1, 0, 0, 1, l_terse
,
"window", 1, 0, 4, 5, l_window
,
"write", 2, 0, 2, 2, l_write
,
if ((f
= fopen(filename
, "r")) == 0)
for (lineno
= 1; fgets(buf
, sizeof buf
, f
) != 0; lineno
++)
register struct lcmd
*lp
;
for (lp
= lcmd
; lp
->l_name
; lp
++) {
if (!strncmp(*argv
, lp
->l_name
, lp
->l_lmax
? lp
->l_lmax
: len
))
if (lp
->l_amin
> argc
- 1)
error("Too few arguments.");
else if (lp
->l_amax
>= 0 && lp
->l_amax
< argc
- 1)
error("Too many arguments.");
error("%s: Unknown command.", *argv
);
register char *q
= buf
, **pp
= argv
;
char quote
= 0, escape
= 0;
for (; *p
== ' ' || *p
== '\t'; p
++)
while (*p
&& *p
!= '\n' && (*p
!= '#' || escape
|| quote
)
&& pp
< &argv
[sizeof argv
/sizeof *argv
- 1]) {
while (*p
&& *p
!= '\n') {
case '0': case '1': case '2': case '3':
case '4': case '5': case '6': case '7':
&& *p
>= '0' && *p
<= '9';)
*q
= *q
<< 3 | *p
++ - '0';
if (*p
== '"' || *p
== '\'')
else if (*p
== ' ' || *p
== '\t')
for (; *p
== ' ' || *p
== '\t'; p
++)