/* decode() - read a line from standard input and decode it */
integ
= scallf
= reflag
= 0;
proc
[0] = cmd
= args
[0] = var
[0] = '\0';
if (*p == '/' && *(p+1) == '\n') {
if (eqany(*p
, "/?")) { /* regular expression */
if (*p
== '\n' || *p
== c
) return(0);
while(*p
!= c
&& *p
!= '\n') *q
++ = *p
++;
if (*p
== '!') { /* shell escape */
for (q
= p
; *q
!= '\n'; q
++) ;
while (*p
!= '\n') { /* decode item by item */
if (number(*p
)) { /* decimal number */
error("Too many numbers");
if (varchar(*p
) || eqany(*p
, COMMANDS
)) {
/* proc, variable or command */
while (varchar(*q
) || number(*q
) || eqany(*q
,COMMANDS
))
if (*q
== '(') { /* procedure call */
error("Too many procedure calls");
if (*q
== ':') { /* procedure name */
if (*q
== '$') { /* variable name */
if ((q
-p
== 1 && eqany(*p
,COMMANDS
) &&
(proc
[0]=='\0' || *p
== 'b')) ||
integ
|| eqany(*p
, "+-"))
/* otherwise, its a variable */
error("Too many variable names");
if (cmd
== '\0') cmd
= *p
? *p
: '/';
p
++; /* otherwise ignore p */