1: static  char sccsid[] = "@(#)decode.c 4.2 8/17/82";
   2: #include "head.h"
   3: 
   4: /* decode() - read a line from standard input and decode it */
   5: 
   6: decode(p)
   7: char *p; {
   8:     register char c, *q;
   9:     register int diff;
  10:     integ = scallf = reflag = colonflag = ncolonflag = percentflag = 0;
  11:     proc[0] = cmd = args[0] = var[0] = '\0';
  12:     argsp = args;
  13: 
  14:     if (eqany(*p, "/?")) {  /* regular expression */
  15:         c = *p;
  16:         redir = (c == '/');
  17:         reflag = 1;
  18:         p++;
  19:         if (*p == '\n' || *p == c) return(0);
  20:         q = re;
  21:         while(*p != c && *p != '\n') *q++ = *p++;
  22:         *q = '\0';
  23:         return(0);
  24:     }
  25: 
  26:     if (*p == '!') { /* shell escape */
  27:         for (q = p; *q != '\n'; q++) ;
  28:         *q = '\0';
  29:         system(p+1);
  30:         return(0);
  31:     }
  32: 
  33:     if (*p == '\n') {
  34:         cmd = '\n';
  35:         return(0);
  36:     }
  37: 
  38:     if (*p == ':') {
  39:         colonflag++;
  40:     }
  41: 
  42:     while (*p != '\n') {    /* decode item by item */
  43: 
  44:         if (number(*p)) {   /* decimal number */
  45:             if (integ) {
  46:                 error("Too many numbers");
  47:                 return(1);
  48:             }
  49:             integ = readint(&p);
  50:             if (*p == ':') {
  51:                 ncolonflag++;
  52:                 p++;
  53:             }
  54:             continue;
  55:         }
  56: 
  57:         if (varchar(*p) || eqany(*p, COMMANDS)) {
  58:                     /* proc, variable or command */
  59:             if (cmd != '\0') {
  60:                 p = cpall(args, p);
  61:                 continue;
  62:             }
  63:             q = p;
  64:             while (varchar(*q) || number(*q) || eqany(*q,COMMANDS))
  65:                 q++;
  66:             if (*q == '(') {    /* procedure call */
  67:                 if (proc[0] != '\0') {
  68:                     error("Too many procedure calls");
  69:                     return(1);
  70:                 }
  71:                 scallf = 1;
  72:                 p = cpname(proc, p);
  73:                 p = cpall(args, p);
  74:                 continue;
  75:             }
  76:             if (*q == ':') {    /* procedure name */
  77:                 colonflag++;
  78:                 p = cpname(proc, p);
  79:                 continue;
  80:             }
  81:             if (*q == '$') {    /* variable name */
  82:                 p = cpname(var, p);
  83:                 continue;
  84:             }
  85:             if (((q-p == 1 && eqany(*p,COMMANDS) &&
  86:                 (proc[0]=='\0' || eqany(*p, "abcd"))) ||
  87:                 (integ && eqany(*p,COMMANDS)) ||
  88:                  eqany(*p, "+-?"))
  89:                 && !(*p=='-' && *(p+1) == '>'))
  90:                             {  /* command */
  91:                 cmd = *p++;
  92:                 if (eqany(cmd, "Macers")) {
  93:                     while(*p == ' ')
  94:                         p++;
  95:                     p = cpall(args, p);
  96:                 }
  97:                 continue;
  98:             }
  99:             /* otherwise, its a variable */
 100:             if (var[0] != '\0') {
 101:                 error("Too many variable names");
 102:                 return(1);
 103:             }
 104:             p = cpname(var, p);
 105:             if (*p == '%') {
 106:                 percentflag++;
 107:                 p++;
 108:             }
 109:             if (eqstr(var, ".?")) {
 110:                 var[1] = '\0';
 111:                 cmd = '?';
 112:             }
 113:             if (*p == '\n') {
 114:                 cmd = '/';
 115:                 continue;
 116:             }
 117:             if (cmd == '\0') cmd = *p ? *p : '/';
 118:             p++;
 119:             p = cpall(args,p);
 120:             continue;
 121:         }
 122:         p++;    /* otherwise ignore p */
 123:     }
 124:     return(0);
 125: }

Defined functions

decode defined in line 6; used 2 times

Defined variables

sccsid defined in line 1; never used
Last modified: 1982-10-04
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1218
Valid CSS Valid XHTML 1.0 Strict