|
|
1.1 ! root 1: #include "awk.def" ! 2: #include "awk.h" ! 3: #include "stdio.h" ! 4: node *ALLOC(n) ! 5: { ! 6: register node *x; ! 7: x = (node *) malloc(sizeof(node) + (n-1)*sizeof(node *)); ! 8: if (x == NULL) ! 9: error(FATAL, "out of space in ALLOC"); ! 10: return(x); ! 11: } ! 12: node *exptostat(a) node *a; ! 13: { ! 14: a->ntype = NSTAT; ! 15: return(a); ! 16: } ! 17: node *nullstat; ! 18: node *node0(a) ! 19: { ! 20: register node *x; ! 21: x=ALLOC(0); ! 22: x->nnext = NULL; ! 23: x->nobj=a; ! 24: return(x); ! 25: } ! 26: node *node1(a,b) node *b; ! 27: { ! 28: register node *x; ! 29: x=ALLOC(1); ! 30: x->nnext = NULL; ! 31: x->nobj=a; ! 32: x->narg[0]=b; ! 33: return(x); ! 34: } ! 35: node *node2(a,b,c) node *b, *c; ! 36: { ! 37: register node *x; ! 38: x = ALLOC(2); ! 39: x->nnext = NULL; ! 40: x->nobj = a; ! 41: x->narg[0] = b; ! 42: x->narg[1] = c; ! 43: return(x); ! 44: } ! 45: node *node3(a,b,c,d) node *b, *c, *d; ! 46: { ! 47: register node *x; ! 48: x = ALLOC(3); ! 49: x->nnext = NULL; ! 50: x->nobj = a; ! 51: x->narg[0] = b; ! 52: x->narg[1] = c; ! 53: x->narg[2] = d; ! 54: return(x); ! 55: } ! 56: node *node4(a,b,c,d,e) node *b, *c, *d, *e; ! 57: { ! 58: register node *x; ! 59: x = ALLOC(4); ! 60: x->nnext = NULL; ! 61: x->nobj = a; ! 62: x->narg[0] = b; ! 63: x->narg[1] = c; ! 64: x->narg[2] = d; ! 65: x->narg[3] = e; ! 66: return(x); ! 67: } ! 68: node *stat3(a,b,c,d) node *b, *c, *d; ! 69: { ! 70: register node *x; ! 71: x = node3(a,b,c,d); ! 72: x->ntype = NSTAT; ! 73: return(x); ! 74: } ! 75: node *op2(a,b,c) node *b, *c; ! 76: { ! 77: register node *x; ! 78: x = node2(a,b,c); ! 79: x->ntype = NEXPR; ! 80: return(x); ! 81: } ! 82: node *op1(a,b) node *b; ! 83: { ! 84: register node *x; ! 85: x = node1(a,b); ! 86: x->ntype = NEXPR; ! 87: return(x); ! 88: } ! 89: node *stat1(a,b) node *b; ! 90: { ! 91: register node *x; ! 92: x = node1(a,b); ! 93: x->ntype = NSTAT; ! 94: return(x); ! 95: } ! 96: node *op3(a,b,c,d) node *b, *c, *d; ! 97: { ! 98: register node *x; ! 99: x = node3(a,b,c,d); ! 100: x->ntype = NEXPR; ! 101: return(x); ! 102: } ! 103: node *stat2(a,b,c) node *b, *c; ! 104: { ! 105: register node *x; ! 106: x = node2(a,b,c); ! 107: x->ntype = NSTAT; ! 108: return(x); ! 109: } ! 110: node *stat4(a,b,c,d,e) node *b, *c, *d, *e; ! 111: { ! 112: register node *x; ! 113: x = node4(a,b,c,d,e); ! 114: x->ntype = NSTAT; ! 115: return(x); ! 116: } ! 117: node *valtonode(a, b) cell *a; ! 118: { ! 119: register node *x; ! 120: x = node0(a); ! 121: x->ntype = NVALUE; ! 122: x->subtype = b; ! 123: return(x); ! 124: } ! 125: node *pa2stat(a,b,c) node *a, *b, *c; ! 126: { ! 127: register node *x; ! 128: x = node3(paircnt++, a, b, c); ! 129: x->ntype = NPA2; ! 130: return(x); ! 131: } ! 132: node *linkum(a,b) node *a, *b; ! 133: { ! 134: register node *c; ! 135: if(a == NULL) return(b); ! 136: else if(b == NULL) return(a); ! 137: for(c=a; c->nnext != NULL; c=c->nnext); ! 138: c->nnext = b; ! 139: return(a); ! 140: } ! 141: node *genprint() ! 142: { ! 143: register node *x; ! 144: x = stat2(PRINT,valtonode(lookup("$record", symtab, 0), CFLD), nullstat); ! 145: return(x); ! 146: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.