|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1986 Regents of the University of California. ! 3: * All rights reserved. The Berkeley software License Agreement ! 4: * specifies the terms and conditions for redistribution. ! 5: * ! 6: * @(#)kdb_command.c 7.3 (Berkeley) 12/15/86 ! 7: */ ! 8: ! 9: #include "../kdb/defs.h" ! 10: ! 11: char *BADEQ; ! 12: char *NOMATCH; ! 13: char *BADVAR; ! 14: char *BADCOM; ! 15: ! 16: int executing; ! 17: char *lp; ! 18: ! 19: char lastc; ! 20: char eqformat[512] = "z"; ! 21: char stformat[512] = "X\"= \"^i"; ! 22: ! 23: long ditto; ! 24: int lastcom = '='; ! 25: long locval; ! 26: long locmsk; ! 27: long expv; ! 28: ! 29: /* command decoding */ ! 30: ! 31: command(buf, defcom) ! 32: char *buf, defcom; ! 33: { ! 34: register itype, ptype, modifier, regptr; ! 35: int longpr, eqcom; ! 36: char wformat[1], savc; ! 37: register long w, savdot; ! 38: char *savlp=lp; ! 39: ! 40: if (buf) { ! 41: if (*buf==EOR) ! 42: return (0); ! 43: lp=buf; ! 44: } ! 45: ! 46: do { ! 47: if (adrflg=expr(0)) { ! 48: dot=expv; ! 49: ditto=dot; ! 50: } ! 51: adrval=dot; ! 52: cntflg = (rdc() == ',' && expr(0)); ! 53: if (cntflg) ! 54: cntval=expv; ! 55: else ! 56: cntval=1, lp--; ! 57: if (eol(rdc())) { ! 58: if (!adrflg) ! 59: dot=inkdot(dotinc); ! 60: lp--; lastcom=defcom; ! 61: } else ! 62: lastcom=lastc; ! 63: switch (lastcom&STRIP) { ! 64: ! 65: case '/': ! 66: itype=DSP; ptype=DSYM; ! 67: goto trystar; ! 68: ! 69: case '=': ! 70: itype=NSP; ptype=0; ! 71: goto trypr; ! 72: ! 73: case '?': ! 74: itype=ISP; ptype=ISYM; ! 75: goto trystar; ! 76: ! 77: trystar: ! 78: if (rdc()=='*') ! 79: lastcom |= QUOTE; ! 80: else ! 81: lp--; ! 82: if (lastcom"E) { ! 83: itype |= STAR; ! 84: ptype = (DSYM+ISYM)-ptype; ! 85: } ! 86: ! 87: trypr: ! 88: longpr=0; eqcom=lastcom=='='; ! 89: switch (rdc()) { ! 90: ! 91: case 'L': ! 92: longpr=1; ! 93: case 'l': ! 94: /*search for exp*/ ! 95: if (eqcom) ! 96: error(BADEQ); ! 97: dotinc=(longpr?4:2); savdot=dot; ! 98: (void) expr(1); locval=expv; ! 99: if (expr(0)) ! 100: locmsk=expv; ! 101: else ! 102: locmsk = -1L; ! 103: if (!longpr) { ! 104: locmsk &= 0xFFFF; ! 105: locval &= 0xFFFF; ! 106: } ! 107: for (;;) { ! 108: w=get(dot,itype); ! 109: if (errflg || mkfault || ! 110: (w&locmsk)==locval) ! 111: break; ! 112: dot=inkdot(dotinc); ! 113: } ! 114: if (errflg) { ! 115: dot=savdot; ! 116: errflg=NOMATCH; ! 117: } ! 118: psymoff(dot,ptype,""); ! 119: break; ! 120: ! 121: case 'W': ! 122: longpr=1; ! 123: case 'w': ! 124: if (eqcom) ! 125: error(BADEQ); ! 126: wformat[0]=lastc; (void) expr(1); ! 127: do { ! 128: savdot=dot; ! 129: psymoff(dot,ptype,":%16t"); ! 130: (void) exform(1,wformat,itype,ptype); ! 131: errflg=0; dot=savdot; ! 132: if (longpr) ! 133: put(dot,itype,expv); ! 134: else ! 135: put(dot,itype, ! 136: itol(expv,get(dot,itype))); ! 137: savdot=dot; ! 138: printf("=%8t"); ! 139: (void) exform(1,wformat,itype,ptype); ! 140: printc(EOR); ! 141: } while (expr(0) && errflg==0); ! 142: dot=savdot; ! 143: chkerr(); ! 144: break; ! 145: ! 146: default: ! 147: lp--; ! 148: getformat(eqcom ? eqformat : stformat); ! 149: if (!eqcom) ! 150: psymoff(dot,ptype,":%16t"); ! 151: scanform(cntval, ! 152: (eqcom?eqformat:stformat),itype,ptype); ! 153: } ! 154: break; ! 155: ! 156: case '>': ! 157: lastcom=0; savc=rdc(); ! 158: if ((regptr=getreg(savc)) != -1) ! 159: *(int *)regptr = dot; ! 160: else if ((modifier=varchk(savc)) != -1) ! 161: var[modifier]=dot; ! 162: else ! 163: error(BADVAR); ! 164: break; ! 165: ! 166: case '$': ! 167: lastcom=0; ! 168: printtrace(nextchar()); ! 169: break; ! 170: ! 171: case ':': ! 172: if (executing) ! 173: break; ! 174: executing=1; subpcs(nextchar()); executing=0; ! 175: lastcom=0; ! 176: break; ! 177: ! 178: case '\0': ! 179: break; ! 180: ! 181: default: ! 182: error(BADCOM); ! 183: } ! 184: flushbuf(); ! 185: } while (rdc()==';'); ! 186: if (buf) ! 187: lp=savlp; ! 188: else ! 189: lp--; ! 190: return (adrflg && dot!=0); ! 191: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.