diff -rc gawk-2.13.orig/array.c gawk-2.13/array.c *** gawk-2.13.orig/array.c Fri May 31 17:59:43 1991 --- gawk-2.13/array.c Wed Dec 11 21:47:37 1991 *************** *** 28,34 **** --- 28,39 ---- static NODE *assoc_find P((NODE *symbol, NODE *subs, int hash1)); NODE * + #ifndef SNMP concat_exp(tree) + #else + concat_exp(tree,isnmp) + int isnmp; + #endif register NODE *tree; { register NODE *r; *************** *** 44,51 **** --- 49,66 ---- r = force_string(tree_eval(tree->lnode)); if (tree->rnode == NULL) return r; + #ifdef SNMP + if (isnmp) { + subseplen = Ndot_string -> stlen; + subsep = Ndot_string -> stptr; + } + else { + #endif subseplen = SUBSEP_node->lnode->stlen; subsep = SUBSEP_node->lnode->stptr; + #ifdef SNMP + } + #endif len = r->stlen + subseplen + 2; emalloc(str, char *, len, "concat_exp"); memcpy(str, r->stptr, r->stlen+1); *************** *** 82,87 **** --- 97,106 ---- int i; NODE *bucket, *next; + #ifdef SNMP + if (symbol -> magic) + fatal ("split into SNMP array variable not allowed"); + #endif if (symbol->var_array == 0) return; for (i = 0; i < HASHSIZE; i++) { *************** *** 131,136 **** --- 150,160 ---- register NODE *bucket; int chained = 0; + #ifdef SNMP + if (symbol -> magic) + fatal ("assoc_find: internal error"); + #endif + for (bucket = symbol->var_array[hash1]; bucket; bucket = bucket->ahnext) { if (cmp_nodes(bucket->ahname, subs) == 0) { if (chained) { /* move found to front of chain */ *************** *** 163,171 **** --- 187,204 ---- if (symbol->type == Node_param_list) symbol = stack_ptr[symbol->param_cnt]; + #ifdef SNMP + if (symbol -> magic) + return *assoc_lookup (symbol, concat_exp (subs, 1)) + != Nnull_string; + #endif if (symbol->var_array == 0) return 0; + #ifndef SNMP subs = concat_exp(subs); /* concat_exp returns a string node */ + #else + subs = concat_exp(subs,0); /* concat_exp returns a string node */ + #endif hash1 = hash(subs->stptr, subs->stlen); if (assoc_find(symbol, subs, hash1) == NULL) { free_temp(subs); *************** *** 193,198 **** --- 226,237 ---- (void) force_string(subs); hash1 = hash(subs->stptr, subs->stlen); + #ifdef SNMP + if (symbol -> magic) { + snmp_get (symbol, force_string (subs) -> stptr); + return &symbol -> var_value; + } + #endif if (symbol->var_array == 0) { /* this table really should grow * dynamically */ unsigned size; *************** *** 228,236 **** --- 267,283 ---- if (symbol->type == Node_param_list) symbol = stack_ptr[symbol->param_cnt]; + #ifdef SNMP + if (symbol -> magic) + fatal ("delete into SNMP array variable not allowed"); + #endif if (symbol->var_array == 0) return; + #ifndef SNMP subs = concat_exp(tree); /* concat_exp returns string node */ + #else + subs = concat_exp(tree,0); /* concat_exp returns string node */ + #endif hash1 = hash(subs->stptr, subs->stlen); last = NULL; *************** *** 250,259 **** --- 297,317 ---- } void + #ifndef SNMP assoc_scan(symbol, lookat) + #else + assoc_scan(symbol, lookat, instance) + NODE *instance; + #endif NODE *symbol; struct search *lookat; { + #ifdef SNMP + if (symbol -> magic) { + snmp_assoc_scan (symbol, lookat, instance); + return; + } + #endif if (!symbol->var_array) { lookat->retval = NULL; return; *************** *** 261,273 **** --- 319,346 ---- lookat->arr_ptr = symbol->var_array; lookat->arr_end = lookat->arr_ptr + HASHSIZE; /* added */ lookat->bucket = symbol->var_array[0]; + #ifndef SNMP assoc_next(lookat); + #else + assoc_next(symbol,lookat); + #endif } void + #ifndef SNMP assoc_next(lookat) + #else + assoc_next(symbol,lookat) + NODE *symbol; + #endif struct search *lookat; { + #ifdef SNMP + if (symbol -> magic) { + snmp_assoc_next (lookat, 0); + return; + } + #endif while (lookat->arr_ptr < lookat->arr_end) { if (lookat->bucket != 0) { lookat->retval = lookat->bucket->ahname; Common subdirectories: gawk-2.13.orig/atari and gawk-2.13/atari diff -rc gawk-2.13.orig/awk.h gawk-2.13/awk.h *** gawk-2.13.orig/awk.h Mon Jul 8 19:02:14 1991 --- gawk-2.13/awk.h Thu Dec 12 09:36:49 1991 *************** *** 230,235 **** --- 230,241 ---- Node_K_while, /* lnode is condtional, rnode is stuff to run */ Node_K_for, /* lnode is for_struct, rnode is stuff to run */ Node_K_arrayfor, /* lnode is for_struct, rnode is stuff to run */ + #ifdef SNMP + /* init: target + cond: instance (optional) + incr: array + */ + #endif Node_K_break, /* no subs */ Node_K_continue, /* no stuff */ Node_K_print, /* lnode is exp_list, rnode is redirect */ *************** *** 251,256 **** --- 257,265 ---- /* Variables */ /*60*/ Node_var, /* rnode is value, lnode is array stuff */ + #ifdef SNMP + /* magic is pointer to (OT) */ + #endif Node_var_array, /* array is ptr to elements, asize num of * eles */ Node_val, /* node is a value - type in flags */ *************** *** 319,324 **** --- 328,336 ---- # define CASE 1 # define CONST 2 # define FS_DFLT 4 + #ifdef SNMP + caddr_t cookie; + #endif } nodep; struct { AWKNUM fltnum; /* this is here for optimal packing of *************** *** 366,371 **** --- 378,386 ---- #define lnode sub.nodep.l.lptr #define nextp sub.nodep.l.lptr #define rnode sub.nodep.r.rptr + #ifdef SNMP + #define magic sub.nodep.cookie + #endif #define source_file sub.nodep.x.name #define source_line sub.nodep.number #define param_cnt sub.nodep.number *************** *** 414,419 **** --- 429,437 ---- NODE **arr_end; NODE *bucket; NODE *retval; + #ifdef SNMP + caddr_t snmp; + #endif }; /* for faster input, bypass stdio */ *************** *** 513,527 **** #ifndef MPROF #define getnode(n) if (nextfree) n = nextfree, nextfree = nextfree->nextp;\ else n = more_nodes() #define freenode(n) ((n)->nextp = nextfree, nextfree = (n)) #else #define getnode(n) emalloc(n, NODE *, sizeof(NODE), "getnode") #define freenode(n) free(n) #endif ! #ifdef DEBUG #define tree_eval(t) r_tree_eval(t) #else #define tree_eval(t) (_t = (t),(_t) == NULL ? Nnull_string : \ --- 531,558 ---- #ifndef MPROF + #ifndef SNMP #define getnode(n) if (nextfree) n = nextfree, nextfree = nextfree->nextp;\ else n = more_nodes() + #else + #define getnode(n) if (nextfree) n = nextfree, n->magic = NULL, nextfree = nextfree->nextp;\ + else n = more_nodes(), n->magic = NULL + #endif + #ifndef DEBUG #define freenode(n) ((n)->nextp = nextfree, nextfree = (n)) + #endif #else + #ifndef SNMP #define getnode(n) emalloc(n, NODE *, sizeof(NODE), "getnode") + #else + #define getnode(n) emalloc(n, NODE *, sizeof(NODE), "getnode"), n->magic = NULL + #endif + #ifndef DEBUG #define freenode(n) free(n) #endif + #endif ! #ifdef DEBUG #define tree_eval(t) r_tree_eval(t) #else #define tree_eval(t) (_t = (t),(_t) == NULL ? Nnull_string : \ *************** *** 610,623 **** --- 641,663 ---- extern void set_ORS(); /* array.c */ + #ifndef SNMP extern NODE *concat_exp P((NODE *tree)); + #else + extern NODE *concat_exp P((NODE *tree, int isnmp)); + #endif extern void assoc_clear P((NODE *symbol)); extern unsigned int hash P((char *s, int len)); extern int in_array P((NODE *symbol, NODE *subs)); extern NODE **assoc_lookup P((NODE *symbol, NODE *subs)); extern void do_delete P((NODE *symbol, NODE *tree)); + #ifndef SNMP extern void assoc_scan P((NODE *symbol, struct search *lookat)); extern void assoc_next P((struct search *lookat)); + #else + extern void assoc_scan P((NODE *symbol, struct search *lookat, NODE *instance)); + extern void assoc_next P((NODE *symbol, struct search *lookat)); + #endif /* awk.tab.c */ extern char *tokexpand P((void)); extern char nextc P((void)); *************** *** 780,782 **** --- 820,848 ---- #endif extern char casetable[]; /* for case-independent regexp matching */ + + + #ifdef SNMP + extern NODE *AGENT_node, + *COMMUNITY_node, + *DIAGNOSTIC_node, + *ERROR_node, + *RETRIES_node, + *TIMEOUT_node; + + extern NODE *Ndot_string; + + extern NODE *SET_node; + extern NODE *SET_inst; + + extern int snmp_enabled; + extern char *snmp_file; + + + extern int check_snmp P((NODE *r, char *name)); + extern int snmp_get P((NODE *ptr, char *instname)); + extern void snmp_set P((void)); + extern char *snmp_name P((NODE *ptr)); + extern void snmp_assoc_scan P((NODE *symbol)); + extern void snmp_assoc_next P((struct search *lookat, int done)); + #endif diff -rc gawk-2.13.orig/awk.y gawk-2.13/awk.y *** gawk-2.13.orig/awk.y Sat Jun 29 09:52:57 1991 --- gawk-2.13/awk.y Thu Dec 12 09:18:15 1991 *************** *** 333,338 **** --- 333,343 ---- { $$ = node ($3, Node_K_while, $6); } | LEX_DO opt_nls statement LEX_WHILE '(' exp r_paren opt_nls { $$ = node ($6, Node_K_do, $3); } + | LEX_FOR '(' NAME LEX_IN NAME comma exp r_paren opt_nls statement + { + $$ = node ($10, Node_K_arrayfor, make_for_loop(variable($3,1), + $7, variable($5,1))); + } | LEX_FOR '(' NAME LEX_IN NAME r_paren opt_nls statement { $$ = node ($8, Node_K_arrayfor, make_for_loop(variable($3,1), *************** *** 728,733 **** --- 733,741 ---- *do_split(), *do_system(), *do_int(), *do_close(), *do_atan2(), *do_sin(), *do_cos(), *do_rand(), *do_srand(), *do_match(), *do_tolower(), *do_toupper(), + #ifdef SNMP + *do_band (), *do_bor (), + #endif *do_sub(), *do_gsub(), *do_strftime(), *do_systime(); /* Tokentab is sorted ascii ascending order, so it can be binary searched. */ *************** *** 736,741 **** --- 744,753 ---- {"BEGIN", Node_illegal, LEX_BEGIN, 0, 0}, {"END", Node_illegal, LEX_END, 0, 0}, {"atan2", Node_builtin, LEX_BUILTIN, NOT_OLD|A(2), do_atan2}, + #ifdef SNMP + { "bit_and", Node_builtin, LEX_BUILTIN, 0, do_band}, + { "bit_or", Node_builtin, LEX_BUILTIN, 0, do_bor}, + #endif {"break", Node_K_break, LEX_BREAK, 0, 0}, {"close", Node_builtin, LEX_BUILTIN, NOT_OLD|A(1), do_close}, {"continue", Node_K_continue, LEX_CONTINUE, 0, 0}, *************** *** 1716,1722 **** --- 1728,1742 ---- env_loaded = 1; } if ((r = lookup(name)) == NULL) + #ifdef SNMP + { + #endif r = install(name, node(Nnull_string, Node_var, (NODE *) NULL)); + #ifdef SNMP + if (snmp_enabled && r) + snmp_check (r, name); + } + #endif else if (can_free) free(name); return r; diff -rc gawk-2.13.orig/builtin.c gawk-2.13/builtin.c *** gawk-2.13.orig/builtin.c Wed Jun 19 05:30:27 1991 --- gawk-2.13/builtin.c Wed Dec 11 21:58:10 1991 *************** *** 605,610 **** --- 605,648 ---- } } + #ifdef SNMP + NODE *do_band (tree) + NODE *tree; + { + unsigned long d1, + d2; + NODE *s1, + *s2; + + s1 = tree_eval (tree -> lnode); + s2 = tree_eval (tree -> rnode -> lnode); + d1 = force_number (s1); + d2 = force_number (s2); + free_temp (s1); + free_temp (s2); + + return tmp_number ((AWKNUM) ((unsigned long) (d1 & d2))); + } + + NODE *do_bor (tree) + NODE *tree; + { + unsigned long d1, + d2; + NODE *s1, + *s2; + + s1 = tree_eval (tree -> lnode); + s2 = tree_eval (tree -> rnode -> lnode); + d1 = force_number (s1); + d2 = force_number (s2); + free_temp (s1); + free_temp (s2); + + return tmp_number ((AWKNUM) ((unsigned long) (d1 | d2))); + } + #endif + NODE * do_sqrt(tree) NODE *tree; *************** *** 981,986 **** --- 1019,1029 ---- t = tmp; priv = 1; } + #ifdef SNMP + else + if (SET_node) + SET_node = NULL; + #endif text = t->stptr; textlen = t->stlen; *************** *** 1064,1069 **** --- 1107,1116 ---- if (priv) { unref(*lhs); *lhs = t; + #ifdef SNMP + if (SET_node) + snmp_set (); + #endif } if (after_assign) (*after_assign)(); Common subdirectories: gawk-2.13.orig/config and gawk-2.13/config Only in gawk-2.13: config.h diff -rc gawk-2.13.orig/eval.c gawk-2.13/eval.c *** gawk-2.13.orig/eval.c Mon Jul 8 19:08:58 1991 --- gawk-2.13/eval.c Thu Dec 12 01:16:20 1991 *************** *** 254,266 **** --- 254,278 ---- #define arrvar forloop->incr PUSH_BINDING(loop_tag_stack, loop_tag, loop_tag_valid); lhs = (volatile NODE **) get_lhs(tree->hakvar, &after_assign); + #ifdef SNMP + if (SET_node) + fatal ("attempt to use SNMP variable \"%s\" unwisely", + snmp_name (tree -> hakvar)); + #endif t = tree->arrvar; if (t->type == Node_param_list) t = stack_ptr[t->param_cnt]; stable_tree = tree; + #ifndef SNMP for (assoc_scan(t, (struct search *)&l); l.retval; assoc_next((struct search *)&l)) { + #else + for (assoc_scan(t, (struct search *)&l, + tree -> forloop -> cond); + l.retval; + assoc_next(t, (struct search *)&l)) { + #endif unref(*((NODE **) lhs)); *lhs = dupnode(l.retval); if (after_assign) *************** *** 272,277 **** --- 284,293 ---- break; case TAG_BREAK: + #ifdef SNMP + if (t -> magic) + (void) snmp_assoc_next (&l, 1); + #endif RESTORE_BINDING(loop_tag_stack, loop_tag, loop_tag_valid); return 1; default: *************** *** 361,367 **** long lx2; #endif ! #ifdef DEBUG if (tree == NULL) return Nnull_string; if (tree->type == Node_val) { --- 377,383 ---- long lx2; #endif ! #ifdef DEBUG if (tree == NULL) return Nnull_string; if (tree->type == Node_val) { *************** *** 373,381 **** return tree->var_value; } if (tree->type == Node_param_list) ! return (stack_ptr[(_t)->param_cnt])->var_value; #endif switch (tree->type) { case Node_and: return tmp_number((AWKNUM) (eval_condition(tree->lnode) && eval_condition(tree->rnode))); --- 389,405 ---- return tree->var_value; } if (tree->type == Node_param_list) ! return (stack_ptr[tree->param_cnt])->var_value; #endif switch (tree->type) { + #ifdef SNMP + case Node_var_array: + if (!tree -> magic) + break; + snmp_get (tree, (char *) NULL); + return tree -> var_value; + #endif + case Node_and: return tmp_number((AWKNUM) (eval_condition(tree->lnode) && eval_condition(tree->rnode))); *************** *** 447,452 **** --- 471,480 ---- lhs = get_lhs(tree->lnode, &after_assign); unref(*lhs); *lhs = dupnode(r); + #ifdef SNMP + if (SET_node) + snmp_set (); + #endif free_temp(r); if (after_assign) (*after_assign)(); *************** *** 841,847 **** --- 869,879 ---- */ if (arg->type == Node_param_list) arg = stack_ptr[arg->param_cnt]; + #ifndef SNMP if (arg->type == Node_var_array) + #else + if (arg -> type == Node_var_array && !arg -> magic) + #endif *r = *arg; else { n = tree_eval(arg); *************** *** 912,917 **** --- 944,954 ---- arg = stack_ptr[arg->param_cnt]; n = *sp++; if (arg->type == Node_var && n->type == Node_var_array) { + #ifdef SNMP + if (arg -> magic) + fatal ("array assignment to SNMP variable \"%s\"", + snmp_name (arg)); + #endif arg->var_array = n->var_array; arg->type = Node_var_array; } *************** *** 955,960 **** --- 992,1013 ---- switch (ptr->type) { case Node_var_array: + #ifdef SNMP + if (ptr -> magic) { + snmp_get (ptr, (char *) NULL); + + if (assign) { + if (SET_node) + fatal ("SET_node non-empty"); + SET_node = ptr; + unref (SET_inst); + SET_inst = NULL; + } + + aptr = &(ptr->var_value); + break; + } + #endif fatal("attempt to use an array in a scalar context"); case Node_var: aptr = &(ptr->var_value); *************** *** 1066,1072 **** --- 1119,1143 ---- n = ptr->lnode; if (n->type == Node_param_list) n = stack_ptr[n->param_cnt]; + #ifdef SNMP + { + NODE *subs = concat_exp (ptr -> rnode, + n -> magic ? 1 : 0); + + if (n -> magic && assign) + subs = dupnode (subs); + aptr = assoc_lookup(n, subs); + if (n -> magic && assign) { + if (SET_node) + fatal ("SET_node non-empty"); + SET_node = n; + unref (SET_inst); + SET_inst = subs; + } + } + #else aptr = assoc_lookup(n, concat_exp(ptr->rnode)); + #endif break; case Node_func: diff -rc gawk-2.13.orig/io.c gawk-2.13/io.c *** gawk-2.13.orig/io.c Tue Jun 18 11:58:47 1991 --- gawk-2.13/io.c Wed Dec 11 21:54:17 1991 *************** *** 738,743 **** --- 738,747 ---- } unref(*lhs); *lhs = make_string(s, strlen(s)); + #ifdef SNMP + if (SET_node) + snmp_set (); + #endif /* we may have to regenerate $0 here! */ if (after_assign) (*after_assign)(); diff -rc gawk-2.13.orig/main.c gawk-2.13/main.c *** gawk-2.13.orig/main.c Sat Jul 6 12:20:21 1991 --- gawk-2.13/main.c Wed Dec 11 22:56:40 1991 *************** *** 102,112 **** --- 102,121 ---- * * Note that after 2.13, c,a,e,C,D, and V go away. */ + #ifndef SNMP #ifdef DEBUG char awk_opts[] = "F:f:v:W:caeCVD"; #else char awk_opts[] = "F:f:v:W:caeCV"; #endif + #else + #ifdef DEBUG + char awk_opts[] = "F:f:v:W:caeCVDsS"; + #else + char awk_opts[] = "F:f:v:W:caeCVsS"; + #endif + extern int debug; + #endif int main(argc, argv) *************** *** 186,192 **** --- 195,211 ---- "warning: option -D will go away in the next release, use -W parsedebug\n"); gawk_option("parsedebug"); break; + + #ifdef SNMP + case 's': + debug = 1; + break; + + case 'S': + debug = 2; + break; #endif + #endif case 'c': fprintf(stderr, *************** *** 441,446 **** --- 460,473 ---- {&RLENGTH_node, "RLENGTH", Node_var, 0, 0, 0 }, {&RSTART_node, "RSTART", Node_var, 0, 0, 0 }, {&SUBSEP_node, "SUBSEP", Node_var, "\034", 0, 0 }, + #ifdef SNMP + {&AGENT_node, "AGENT", Node_var, 0, 0, 0 }, + {&COMMUNITY_node,"COMMUNITY", Node_var, "public",0, 0 }, + {&DIAGNOSTIC_node,"DIAGNOSTIC", Node_var, 0, 0, 0 }, + {&ERROR_node, "ERROR", Node_var, 0, 3.0,0 }, + {&RETRIES_node, "RETRIES", Node_var, 0, 10.0,0 }, + {&TIMEOUT_node, "TIMEOUT", Node_var, 0, 0, 0 }, + #endif {0, 0, Node_illegal, 0, 0, 0 }, }; *************** *** 449,454 **** --- 476,489 ---- { register struct varinit *vp; + #ifdef SNMP + for (vp = varinit; vp->name; vp++) + if (strcmp ("AGENT", vp -> name) == 0) { + (void) snmp_init (&vp -> strval); + break; + } + #endif + for (vp = varinit; vp->name; vp++) { *(vp->spec) = install(vp->name, node(vp->strval == 0 ? make_number(vp->numval) *************** *** 512,517 **** --- 547,556 ---- lhs = get_lhs(var, &after_assign); unref(*lhs); *lhs = it; + #ifdef SNMP + if (SET_node) + snmp_set (); + #endif if (after_assign) (*after_assign)(); *--cp = '='; /* restore original text of ARGV */