static char sccsid
[] = "@(#)parser2.c 3.10 %G%";
* Copyright (c) 1983 Regents of the University of California,
* All rights reserved. Redistribution permitted subject to
* the terms of the Berkeley Software License Agreement.
* name == 0 means we don't have a function name but
* want to parse the arguments anyway. flag == 0 in this case.
p_function(name
, v
, flag
)
register struct value
*v
;
register struct lcmd_tab
*c
= 0;
register struct alias
*a
= 0;
register struct lcmd_arg
*ap
; /* this arg */
struct lcmd_arg
*lp
= 0; /* list arg */
struct value av
[LCMD_NARG
+ 1];
register struct value
*vp
;
if (c
= lcmd_lookup(name
))
else if (a
= alias_lookup(name
))
p_error("%s: No such command or alias.", name
);
for (vp
= av
; vp
< &av
[LCMD_NARG
+ 1]; vp
++)
if (token
== T_COMMA
) /* null argument */
if (p_expr0(&t
, flag
) < 0)
c
!= 0 && (ap
= lp
) == 0 &&
(ap
= c
->lc_arg
+ i
)->arg_name
== 0) {
p_error("%s: Too many arguments.", name
);
tmp
= t
.v_type
== V_STR
? t
.v_str
: 0;
if (p_expr(&t
, flag
) < 0) {
p_error("%s: Bad alias syntax.", name
);
for (ap
= c
->lc_arg
, vp
= av
;
ap
!= 0 && ap
->arg_name
!= 0 &&
(*ap
->arg_name
== '\0' ||
!str_match(tmp
, ap
->arg_name
,
if (ap
== 0 || ap
->arg_name
== 0) {
p_error("%s: Unknown argument \"%s\".",
if (ap
->arg_flags
& ARG_LIST
) {
if (vp
->v_type
!= V_ERR
) {
p_error("%s: Argument %d (%s) duplicated.",
p_error("%s: Argument %d duplicated.",
} else if (t
.v_type
== V_ERR
) {
} else if ((ap
->arg_flags
&ARG_TYPE
) == ARG_NUM
&&
(ap
->arg_flags
&ARG_TYPE
) == ARG_STR
&&
p_error("%s: Argument %d (%s) type mismatch.",
p_error("%s: Argument %d type mismatch.",
else if (token
!= T_EOL
&& token
!= T_EOF
)
flag
= 0; /* look for legal follow set */
if (a
->a_flags
& A_INUSE
)
p_error("%s: Recursive alias.", a
->a_name
);
if (dolongcmd(a
->a_buf
, av
, i
) < 0)
for (vp
= av
; vp
< &av
[LCMD_NARG
]; vp
++)
for (vp
= av
; vp
< &av
[LCMD_NARG
]; vp
++)
if (p_expr(v
, flag
) < 0) {
if (flag
&& var_set(name
, v
) == 0) {