tkeden1.18/004070000025250000147000000000000731700574200140555ustar00ashleydcsother00003470000356tkeden1.18/bison/004070000025250000147000000000000731677661000151775ustar00ashleydcsother00003470000356tkeden1.18/bison/CVS/004070000025250000147000000000000731677661000156325ustar00ashleydcsother00003470000356tkeden1.18/bison/CVS/Root010060000025250000147000000000360727406557400165010ustar00ashleydcsother00003470000356cssbz@127.0.0.1:/cvsroot/eden tkeden1.18/bison/CVS/Repository010060000025250000147000000000150727406557400177320ustar00ashleydcsother00003470000356tkeden/bison tkeden1.18/bison/CVS/Entries010060000025250000147000000000570727406557400171720ustar00ashleydcsother00003470000356/bison.simple/1.3/Wed Apr 11 18:03:41 2001// D tkeden1.18/bison/bison.simple010060000025250000147000000533410727524515600175310ustar00ashleydcsother00003470000356/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ /* MODIFICATION 1: fix all #line directives as they have the wrong * filename and line numbers. Note #line no = actual number + 1 * #line 3 "/usr/local/share/bison.simple" */ #line 7 "bison/bison.simple" /* END MODIFICATION 1 */ /* This file comes from bison-1.28. */ /* This is a MODIFIED version of bison's Skeleton output parser The change is such that the parser only process one token at each call to yyparse(). The token is the argument to yyparse(). This means that this parser is token driven. Example use: while (token = yylex()) { yyparse(token); } Additionally: error handling patched to show expected when there are > 5 expected during an error. [Ash, May 2001]. There are 13 patches of MODIFICATION in the Skeleton (not including this comment) */ /* Skeleton output parser for bison, Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* As a special exception, when this file is copied by Bison into a Bison output file, you may use that output file without restriction. This special exception was added by the Free Software Foundation in version 1.24 of Bison. */ /* This is the parser code that is written into each bison parser when the %semantic_parser declaration is not specified in the grammar. It was written by Richard Stallman by simplifying the hairy parser used when %semantic_parser is specified. */ #ifndef YYSTACK_USE_ALLOCA #ifdef alloca #define YYSTACK_USE_ALLOCA #else /* alloca not defined */ #ifdef __GNUC__ #define YYSTACK_USE_ALLOCA #define alloca __builtin_alloca #else /* not GNU C. */ #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386)) #define YYSTACK_USE_ALLOCA #include #else /* not sparc */ /* We think this test detects Watcom and Microsoft C. */ /* This used to test MSDOS, but that is a bad idea since that symbol is in the user namespace. */ #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__) #if 0 /* No need for malloc.h, which pollutes the namespace; instead, just don't use alloca. */ #include #endif #else /* not MSDOS, or __TURBOC__ */ #if defined(_AIX) /* I don't know what this was needed for, but it pollutes the namespace. So I turned it off. rms, 2 May 1997. */ /* #include */ #pragma alloca #define YYSTACK_USE_ALLOCA #else /* not MSDOS, or __TURBOC__, or _AIX */ #if 0 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up, and on HPUX 10. Eventually we can turn this on. */ #define YYSTACK_USE_ALLOCA #define alloca __builtin_alloca #endif /* __hpux */ #endif #endif /* not _AIX */ #endif /* not MSDOS, or __TURBOC__ */ #endif /* not sparc */ #endif /* not GNU C */ #endif /* alloca not defined */ #endif /* YYSTACK_USE_ALLOCA not defined */ #ifdef YYSTACK_USE_ALLOCA #define YYSTACK_ALLOC alloca #else #define YYSTACK_ALLOC malloc #endif /* Note: there must be only one dollar sign in this file. It is replaced by the list of actions, each action as one case of the switch. */ #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) #define YYEMPTY -2 #define YYEOF 0 #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab #define YYERROR goto yyerrlab1 /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. Once GCC version 2 has supplanted version 1, this can go. */ #define YYFAIL goto yyerrlab #define YYRECOVERING() (!!yyerrstatus) #define YYBACKUP(token, value) \ do \ if (yychar == YYEMPTY && yylen == 1) \ { yychar = (token), yylval = (value); \ yychar1 = YYTRANSLATE (yychar); \ YYPOPSTACK; \ goto yybackup; \ } \ else \ { yyerror ("syntax error: cannot back up"); YYERROR; } \ while (0) #define YYTERROR 1 #define YYERRCODE 256 #ifndef YYPURE #define YYLEX yylex() #endif #ifdef YYPURE #ifdef YYLSP_NEEDED #ifdef YYLEX_PARAM #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) #else #define YYLEX yylex(&yylval, &yylloc) #endif #else /* not YYLSP_NEEDED */ #ifdef YYLEX_PARAM #define YYLEX yylex(&yylval, YYLEX_PARAM) #else #define YYLEX yylex(&yylval) #endif #endif /* not YYLSP_NEEDED */ #endif /* If nonreentrant, generate the variables here */ #ifndef YYPURE int yychar; /* the lookahead symbol */ YYSTYPE yylval; /* the semantic value of the */ /* lookahead symbol */ #ifdef YYLSP_NEEDED YYLTYPE yylloc; /* location data for the lookahead */ /* symbol */ #endif int yynerrs; /* number of parse errors so far */ #endif /* not YYPURE */ #if YYDEBUG != 0 int yydebug; /* nonzero means print parse trace */ /* Since this is uninitialized, it does not stop multiple parsers from coexisting. */ #endif /* YYINITDEPTH indicates the initial size of the parser's stacks */ #ifndef YYINITDEPTH #define YYINITDEPTH 200 #endif /* YYMAXDEPTH is the maximum size the stacks can grow to (effective only if the built-in stack extension method is used). */ #if YYMAXDEPTH == 0 #undef YYMAXDEPTH #endif #ifndef YYMAXDEPTH #define YYMAXDEPTH 10000 #endif /* Define __yy_memcpy. Note that the size argument should be passed with type unsigned int, because that is what the non-GCC definitions require. With GCC, __builtin_memcpy takes an arg of type size_t, but it can handle unsigned int. */ #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) #else /* not GNU C or C++ */ #ifndef __cplusplus /* This is the most reliable way to avoid incompatibilities in available built-in functions on various systems. */ static void __yy_memcpy (to, from, count) char *to; char *from; unsigned int count; { register char *f = from; register char *t = to; register int i = count; while (i-- > 0) *t++ = *f++; } #else /* __cplusplus */ /* This is the most reliable way to avoid incompatibilities in available built-in functions on various systems. */ static void __yy_memcpy (char *to, char *from, unsigned int count) { register char *t = to; register char *f = from; register int i = count; while (i-- > 0) *t++ = *f++; } #endif #endif /* MODIFICATION 2: same as MODIFICATION 1 * #line 217 "/usr/local/share/bison.simple" */ #line 241 "bison/bison.simple" /* END MODIFICATION 2 */ /* The user can define YYPARSE_PARAM as the name of an argument to be passed into yyparse. The argument should have type void *. It should actually point to an object. Grammar actions can access the variable by casting it to the proper pointer type. */ #ifdef YYPARSE_PARAM #ifdef __cplusplus #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM #define YYPARSE_PARAM_DECL #else /* not __cplusplus */ #define YYPARSE_PARAM_ARG YYPARSE_PARAM #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; #endif /* not __cplusplus */ #else /* not YYPARSE_PARAM */ #define YYPARSE_PARAM_ARG #define YYPARSE_PARAM_DECL #endif /* not YYPARSE_PARAM */ /* Prevent warning if -Wstrict-prototypes. */ #ifdef __GNUC__ /* MODIFICATION 3: yyparse() takes an argument that is the lex token * #ifdef YYPARSE_PARAM * int yyparse (void *); * #else * int yyparse (void); * #endif */ int yyparse(int); /* END MODIFICATION 3 */ #endif /* MODIFICATION 4: add a variable yy_parse_init to control the initialisation of the parser and an accessor function */ static int yy_parse_init = 1; #ifdef WANT_SETYYPARSEINIT /* Added this function to allow Eden to use this bison.simple. Needs conditional compilation as we can only have one function with this name otherwise the linker moans (can't compile this into Donald, Scout etc). The name here doesn't get automatically translated by the sed or bison -p. [Ash] */ void setyyparseinit(int setto) { yy_parse_init = setto; } #endif /* END MODIFICATION 4 */ /* MODIFICATION 5: turning the local variables of yyparse() into static, global variables so that the parser can be reentered */ static int yystate; static int yyn; static short *yyssp; static YYSTYPE *yyvsp; static int yyerrstatus; /* number of tokens to shift before error messages enabled */ static int yychar1 = 0; /* lookahead token as an internal (translated) token number */ static short yyssa[YYINITDEPTH]; /* the state stack */ static YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ static short *yyss = yyssa; /* refer to the stacks thru separate pointers */ static YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ #ifdef YYLSP_NEEDED static YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ static YYLTYPE *yyls = yylsa; static YYLTYPE *yylsp; #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) #else #define YYPOPSTACK (yyvsp--, yyssp--) #endif static int yystacksize = YYINITDEPTH; static int yyfree_stacks = 0; #ifdef YYPURE static int yychar; static YYSTYPE yylval; static int yynerrs; #ifdef YYLSP_NEEDED static YYLTYPE yylloc; #endif #endif static YYSTYPE yyval; /* the variable used to return */ /* semantic values from the action */ /* routines */ static int yylen; /* END MODIFICATION 5 */ /* MODIFICATION 6: yyparse() takes an argument that is the lex token * int * yyparse(YYPARSE_PARAM_ARG) * YYPARSE_PARAM_DECL * { */ int yyparse(token) int token; { /* END MODIFICATION 6 */ /* MODIFICATION 7: deal with initialisation */ int yy_token_read = 0; if (!yy_parse_init) goto lex; yy_parse_init = 0; /* END MODIFICATION 7 */ #if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Starting parse\n"); #endif yystate = 0; yyerrstatus = 0; yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ yyssp = yyss - 1; yyvsp = yyvs; #ifdef YYLSP_NEEDED yylsp = yyls; #endif /* Push a new state, which is found in yystate . */ /* In all cases, when you get here, the value and location stacks have just been pushed. so pushing a state here evens the stacks. */ yynewstate: *++yyssp = yystate; if (yyssp >= yyss + yystacksize - 1) { /* Give user a chance to reallocate the stack */ /* Use copies of these so that the &'s don't force the real ones into memory. */ YYSTYPE *yyvs1 = yyvs; short *yyss1 = yyss; #ifdef YYLSP_NEEDED YYLTYPE *yyls1 = yyls; #endif /* Get the current used size of the three stacks, in elements. */ int size = yyssp - yyss + 1; #ifdef yyoverflow /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. */ #ifdef YYLSP_NEEDED /* This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow("parser stack overflow", &yyss1, size * sizeof (*yyssp), &yyvs1, size * sizeof (*yyvsp), &yyls1, size * sizeof (*yylsp), &yystacksize); #else yyoverflow("parser stack overflow", &yyss1, size * sizeof (*yyssp), &yyvs1, size * sizeof (*yyvsp), &yystacksize); #endif yyss = yyss1; yyvs = yyvs1; #ifdef YYLSP_NEEDED yyls = yyls1; #endif #else /* no yyoverflow */ /* Extend the stack our own way. */ if (yystacksize >= YYMAXDEPTH) { yyerror("parser stack overflow"); if (yyfree_stacks) { free (yyss); free (yyvs); #ifdef YYLSP_NEEDED free (yyls); #endif } return 2; } yystacksize *= 2; if (yystacksize > YYMAXDEPTH) yystacksize = YYMAXDEPTH; #ifndef YYSTACK_USE_ALLOCA yyfree_stacks = 1; #endif yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp)); __yy_memcpy ((char *)yyss, (char *)yyss1, size * (unsigned int) sizeof (*yyssp)); yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp)); __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * (unsigned int) sizeof (*yyvsp)); #ifdef YYLSP_NEEDED yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp)); __yy_memcpy ((char *)yyls, (char *)yyls1, size * (unsigned int) sizeof (*yylsp)); #endif #endif /* no yyoverflow */ yyssp = yyss + size - 1; yyvsp = yyvs + size - 1; #ifdef YYLSP_NEEDED yylsp = yyls + size - 1; #endif #if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Stack size increased to %d\n", yystacksize); #endif if (yyssp >= yyss + yystacksize - 1) YYABORT; } #if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Entering state %d\n", yystate); #endif goto yybackup; yybackup: /* Do appropriate processing given the current state. */ /* Read a lookahead token if we need one and don't already have one. */ /* yyresume: */ /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yyn == YYFLAG) goto yydefault; /* Not known => get a lookahead token if don't already have one. */ /* yychar is either YYEMPTY or YYEOF or a valid token in external form. */ if (yychar == YYEMPTY) { #if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Reading a token: "); #endif /* MODIFICATION 8: consume the argument token * yychar = YYLEX; */ lex: if (yy_token_read) return -1; /* token consumed */ yy_token_read = 1; yychar = token; /* END MODIFICATION 8 */ } /* Convert token to internal form (in yychar1) for indexing tables with */ if (yychar <= 0) /* This means end of input. */ { yychar1 = 0; yychar = YYEOF; /* Don't call YYLEX any more */ #if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Now at end of input.\n"); #endif } else { yychar1 = YYTRANSLATE(yychar); #if YYDEBUG != 0 if (yydebug) { fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); /* Give the individual parser a way to print the precise meaning of a token, for further debugging info. */ #ifdef YYPRINT YYPRINT (stderr, yychar, yylval); #endif fprintf (stderr, ")\n"); } #endif } yyn += yychar1; if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) goto yydefault; yyn = yytable[yyn]; /* yyn is what to do for this token type in this state. Negative => reduce, -yyn is rule number. Positive => shift, yyn is new state. New state is final state => don't bother to shift, just return success. 0, or most negative number => error. */ if (yyn < 0) { if (yyn == YYFLAG) goto yyerrlab; yyn = -yyn; goto yyreduce; } else if (yyn == 0) goto yyerrlab; if (yyn == YYFINAL) YYACCEPT; /* Shift the lookahead token. */ #if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); #endif /* Discard the token being shifted unless it is eof. */ if (yychar != YYEOF) yychar = YYEMPTY; *++yyvsp = yylval; #ifdef YYLSP_NEEDED *++yylsp = yylloc; #endif /* count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; yystate = yyn; goto yynewstate; /* Do the default action for the current state. */ yydefault: yyn = yydefact[yystate]; if (yyn == 0) goto yyerrlab; /* Do a reduction. yyn is the number of a rule to reduce with. */ yyreduce: yylen = yyr2[yyn]; if (yylen > 0) yyval = yyvsp[1-yylen]; /* implement default value of the action */ #if YYDEBUG != 0 if (yydebug) { int i; fprintf (stderr, "Reducing via rule %d (line %d), ", yyn, yyrline[yyn]); /* Print the symbols being reduced, and their result. */ for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) fprintf (stderr, "%s ", yytname[yyrhs[i]]); fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); } #endif $ /* the action file gets copied in in place of this dollarsign */ /* MODIFICATION 9: same as MODIFICATION 1 * #line 543 "/usr/local/share/bison.simple" */ #line 617 "bison/bison.simple" /* END MODIFICATION 9 */ yyvsp -= yylen; yyssp -= yylen; #ifdef YYLSP_NEEDED yylsp -= yylen; #endif #if YYDEBUG != 0 if (yydebug) { short *ssp1 = yyss - 1; fprintf (stderr, "state stack now"); while (ssp1 != yyssp) fprintf (stderr, " %d", *++ssp1); fprintf (stderr, "\n"); } #endif *++yyvsp = yyval; #ifdef YYLSP_NEEDED yylsp++; if (yylen == 0) { yylsp->first_line = yylloc.first_line; yylsp->first_column = yylloc.first_column; yylsp->last_line = (yylsp-1)->last_line; yylsp->last_column = (yylsp-1)->last_column; yylsp->text = 0; } else { yylsp->last_line = (yylsp+yylen-1)->last_line; yylsp->last_column = (yylsp+yylen-1)->last_column; } #endif /* Now "shift" the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ yyn = yyr1[yyn]; yystate = yypgoto[yyn - YYNTBASE] + *yyssp; if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else yystate = yydefgoto[yyn - YYNTBASE]; goto yynewstate; yyerrlab: /* here on detecting error */ if (! yyerrstatus) /* If not already recovering from an error, report this error. */ { ++yynerrs; #ifdef YYERROR_VERBOSE yyn = yypact[yystate]; if (yyn > YYFLAG && yyn < YYLAST) { int size = 0; char *msg; int x, count; count = 0; /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ for (x = (yyn < 0 ? -yyn : 0); x < (sizeof(yytname) / sizeof(char *)); x++) if (yycheck[x + yyn] == x) size += strlen(yytname[x]) + 15, count++; /* MODIFICATION 10: increase space for error message * msg = (char *) malloc(size + 15); */ msg = (char *) malloc(size + 100); /* END MODIFICATION 10 */ if (msg != 0) { strcpy(msg, "parse error"); /* MODIFICATION 11: print expected even when there are > 5 expected * if (count < 5) */ if (1) /* END MODIFICATION 11 */ { count = 0; for (x = (yyn < 0 ? -yyn : 0); x < (sizeof(yytname) / sizeof(char *)); x++) if (yycheck[x + yyn] == x) { /* MODIFICATION 12: indicate when there are > 5 expected but not printed */ if (count > 5) count++; else { /* END MODIFICATION 12 */ strcat(msg, count == 0 ? ", expecting `" : " or `"); strcat(msg, yytname[x]); strcat(msg, "'"); count++; /* MODIFICATION 13: indicate when there are > 5 expected but not printed * } */ } } if (count > 5) { sprintf(msg + strlen(msg), " or... (%d other possibilities)", count - 6); } /* END MODIFICATION 13 */ } yyerror(msg); free(msg); } else yyerror ("parse error; also virtual memory exceeded"); } else #endif /* YYERROR_VERBOSE */ yyerror("parse error"); } goto yyerrlab1; yyerrlab1: /* here on error raised explicitly by an action */ if (yyerrstatus == 3) { /* if just tried and failed to reuse lookahead token after an error, discard it. */ /* return failure if at end of input */ if (yychar == YYEOF) YYABORT; #if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); #endif yychar = YYEMPTY; } /* Else will try to reuse lookahead token after shifting the error token. */ yyerrstatus = 3; /* Each real token shifted decrements this */ goto yyerrhandle; yyerrdefault: /* current state does not do anything special for the error token. */ #if 0 /* This is wrong; only states that explicitly want error tokens should shift them. */ yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ if (yyn) goto yydefault; #endif yyerrpop: /* pop the current state because it cannot handle the error token */ if (yyssp == yyss) YYABORT; yyvsp--; yystate = *--yyssp; #ifdef YYLSP_NEEDED yylsp--; #endif #if YYDEBUG != 0 if (yydebug) { short *ssp1 = yyss - 1; fprintf (stderr, "Error: state stack now"); while (ssp1 != yyssp) fprintf (stderr, " %d", *++ssp1); fprintf (stderr, "\n"); } #endif yyerrhandle: yyn = yypact[yystate]; if (yyn == YYFLAG) goto yyerrdefault; yyn += YYTERROR; if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) goto yyerrdefault; yyn = yytable[yyn]; if (yyn < 0) { if (yyn == YYFLAG) goto yyerrpop; yyn = -yyn; goto yyreduce; } else if (yyn == 0) goto yyerrpop; if (yyn == YYFINAL) YYACCEPT; #if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Shifting error token, "); #endif *++yyvsp = yylval; #ifdef YYLSP_NEEDED *++yylsp = yylloc; #endif yystate = yyn; goto yynewstate; yyacceptlab: /* YYACCEPT comes here. */ if (yyfree_stacks) { free (yyss); free (yyvs); #ifdef YYLSP_NEEDED free (yyls); #endif } return 0; yyabortlab: /* YYABORT comes here. */ if (yyfree_stacks) { free (yyss); free (yyvs); #ifdef YYLSP_NEEDED free (yyls); #endif } return 1; } erflow("parser stack overflow", &yyss1, size * sizeof (*yyssp), &yyvs1, size * sizeof (*yyvsp), &yystacksize); #endif yyss = yyss1; yyvs = yyvs1; #ifdef YYLSP_NEEDED yyls = yyls1; #endif #else /* no yyoverflow */ /* Extend the stack our own way. */ if tkeden1.18/config.guess010070000025250000147000000641160727406557400164150ustar00ashleydcsother00003470000356#! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 93, 94, 95, 96, 97, 1998 Free Software Foundation, Inc. # # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Written by Per Bothner . # The master version of this file is at the FSF in /home/gd/gnu/lib. # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and # exits with 0. Otherwise, it exits with 1. # # The plan is that this can be called by configure scripts if you # don't specify an explicit system type (host/target name). # # Only a few systems have been added to this list; please add others # (but try to keep the structure clean). # # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 8/24/94.) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown trap 'rm -f dummy.c dummy.o dummy; exit 1' 1 2 15 # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in alpha:OSF1:*:*) if test $UNAME_RELEASE = "V4.0"; then UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` fi # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. cat <dummy.s .globl main .ent main main: .frame \$30,0,\$26,0 .prologue 0 .long 0x47e03d80 # implver $0 lda \$2,259 .long 0x47e20c21 # amask $2,$1 srl \$1,8,\$2 sll \$2,2,\$2 sll \$0,3,\$0 addl \$1,\$0,\$0 addl \$2,\$0,\$0 ret \$31,(\$26),1 .end main EOF ${CC-cc} dummy.s -o dummy 2>/dev/null if test "$?" = 0 ; then ./dummy case "$?" in 7) UNAME_MACHINE="alpha" ;; 15) UNAME_MACHINE="alphaev5" ;; 14) UNAME_MACHINE="alphaev56" ;; 10) UNAME_MACHINE="alphapca56" ;; 16) UNAME_MACHINE="alphaev6" ;; esac fi rm -f dummy.s dummy echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr [[A-Z]] [[a-z]]` exit 0 ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit 0 ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-cbm-sysv4 exit 0;; amiga:NetBSD:*:*) echo m68k-cbm-netbsd${UNAME_RELEASE} exit 0 ;; amiga:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit 0 ;; arc64:OpenBSD:*:*) echo mips64el-unknown-openbsd${UNAME_RELEASE} exit 0 ;; arc:OpenBSD:*:*) echo mipsel-unknown-openbsd${UNAME_RELEASE} exit 0 ;; hkmips:OpenBSD:*:*) echo mips-unknown-openbsd${UNAME_RELEASE} exit 0 ;; pmax:OpenBSD:*:*) echo mipsel-unknown-openbsd${UNAME_RELEASE} exit 0 ;; sgi:OpenBSD:*:*) echo mips-unknown-openbsd${UNAME_RELEASE} exit 0 ;; wgrisc:OpenBSD:*:*) echo mipsel-unknown-openbsd${UNAME_RELEASE} exit 0 ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit 0;; arm32:NetBSD:*:*) echo arm-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` exit 0 ;; SR2?01:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit 0;; Pyramid*:OSx*:*:*|MIS*:OSx*:*:*|MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit 0 ;; NILE:*:*:dcosx) echo pyramid-pyramid-svr4 exit 0 ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; i86pc:SunOS:5.*:*) echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit 0 ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit 0 ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit 0 ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit 0 ;; atari*:NetBSD:*:*) echo m68k-atari-netbsd${UNAME_RELEASE} exit 0 ;; atari*:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; sun3*:NetBSD:*:*) echo m68k-sun-netbsd${UNAME_RELEASE} exit 0 ;; sun3*:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mac68k:NetBSD:*:*) echo m68k-apple-netbsd${UNAME_RELEASE} exit 0 ;; mac68k:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mvme68k:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mvme88k:OpenBSD:*:*) echo m88k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit 0 ;; macppc:NetBSD:*:*) echo powerpc-apple-netbsd${UNAME_RELEASE} exit 0 ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit 0 ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit 0 ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit 0 ;; 2020:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit 0 ;; mips:*:*:UMIPS | mips:*:*:RISCos) sed 's/^ //' << EOF >dummy.c int main (argc, argv) int argc; char **argv; { #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF ${CC-cc} dummy.c -o dummy \ && ./dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ && rm dummy.c dummy && exit 0 rm -f dummy.c dummy echo mips-mips-riscos${UNAME_RELEASE} exit 0 ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit 0 ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit 0 ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit 0 ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit 0 ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 -o $UNAME_PROCESSOR = mc88110 ] ; then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx \ -o ${TARGET_BINARY_INTERFACE}x = x ] ; then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit 0 ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit 0 ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit 0 ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit 0 ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit 0 ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit 0 ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i?86:AIX:*:*) echo i386-ibm-aix exit 0 ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then sed 's/^ //' << EOF >dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0 rm -f dummy.c dummy echo rs6000-ibm-aix3.2.5 elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit 0 ;; *:AIX:*:4) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'` if /usr/sbin/lsattr -EHl ${IBM_CPU_ID} | grep POWER >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=4.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit 0 ;; *:AIX:*:*) echo rs6000-ibm-aix exit 0 ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit 0 ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC NetBSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit 0 ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit 0 ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit 0 ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit 0 ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit 0 ;; 9000/[34678]??:HP-UX:*:*) case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/6?? | 9000/7?? | 9000/80[24] | 9000/8?[13679] | 9000/892 ) sed 's/^ //' << EOF >dummy.c #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (${CC-cc} dummy.c -o dummy 2>/dev/null ) && HP_ARCH=`./dummy` rm -f dummy.c dummy esac HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit 0 ;; 3050*:HI-UX:*:*) sed 's/^ //' << EOF >dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0 rm -f dummy.c dummy echo unknown-hitachi-hiuxwe2 exit 0 ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit 0 ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit 0 ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit 0 ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit 0 ;; i?86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit 0 ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit 0 ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit 0 ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit 0 ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit 0 ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit 0 ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit 0 ;; CRAY*X-MP:*:*:*) echo xmp-cray-unicos exit 0 ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} exit 0 ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ exit 0 ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} exit 0 ;; CRAY-2:*:*:*) echo cray2-cray-unicos exit 0 ;; F300:UNIX_System_V:*:*) FUJITSU_SYS=`uname -p | tr [A-Z] [a-z] | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "f300-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit 0 ;; F301:UNIX_System_V:*:*) echo f301-fujitsu-uxpv`echo $UNAME_RELEASE | sed 's/ .*//'` exit 0 ;; hp3[0-9][05]:NetBSD:*:*) echo m68k-hp-netbsd${UNAME_RELEASE} exit 0 ;; hp300:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit 0 ;; i?86:BSD/386:*:* | *:BSD/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit 0 ;; *:FreeBSD:*:*) echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit 0 ;; *:NetBSD:*:*) echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` exit 0 ;; *:OpenBSD:*:*) echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` exit 0 ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit 0 ;; i*:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit 0 ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit 0 ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; *:GNU:*:*) echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit 0 ;; *:Linux:*:*) # uname on the ARM produces all sorts of strangeness, and we need to # filter it out. case "$UNAME_MACHINE" in arm* | sa110*) UNAME_MACHINE="arm" ;; esac # The BFD linker knows what the default object file format is, so # first see if it will tell us. ld_help_string=`ld --help 2>&1` ld_supported_emulations=`echo $ld_help_string \ | sed -ne '/supported emulations:/!d s/[ ][ ]*/ /g s/.*supported emulations: *// s/ .*// p'` case "$ld_supported_emulations" in i?86linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" ; exit 0 ;; i?86coff) echo "${UNAME_MACHINE}-pc-linux-gnucoff" ; exit 0 ;; sparclinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;; armlinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;; m68klinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;; elf32ppc) echo "powerpc-unknown-linux-gnu" ; exit 0 ;; esac if test "${UNAME_MACHINE}" = "alpha" ; then sed 's/^ //' <dummy.s .globl main .ent main main: .frame \$30,0,\$26,0 .prologue 0 .long 0x47e03d80 # implver $0 lda \$2,259 .long 0x47e20c21 # amask $2,$1 srl \$1,8,\$2 sll \$2,2,\$2 sll \$0,3,\$0 addl \$1,\$0,\$0 addl \$2,\$0,\$0 ret \$31,(\$26),1 .end main EOF LIBC="" ${CC-cc} dummy.s -o dummy 2>/dev/null if test "$?" = 0 ; then ./dummy case "$?" in 7) UNAME_MACHINE="alpha" ;; 15) UNAME_MACHINE="alphaev5" ;; 14) UNAME_MACHINE="alphaev56" ;; 10) UNAME_MACHINE="alphapca56" ;; 16) UNAME_MACHINE="alphaev6" ;; esac objdump --private-headers dummy | \ grep ld.so.1 > /dev/null if test "$?" = 0 ; then LIBC="libc1" fi fi rm -f dummy.s dummy echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} ; exit 0 elif test "${UNAME_MACHINE}" = "mips" ; then cat >dummy.c </dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0 rm -f dummy.c dummy else # Either a pre-BFD a.out linker (linux-gnuoldld) # or one that does not give us useful --help. # GCC wants to distinguish between linux-gnuoldld and linux-gnuaout. # If ld does not provide *any* "supported emulations:" # that means it is gnuoldld. echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations:" test $? != 0 && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0 case "${UNAME_MACHINE}" in i?86) VENDOR=pc; ;; *) VENDOR=unknown; ;; esac # Determine whether the default compiler is a.out or elf cat >dummy.c < main(argc, argv) int argc; char *argv[]; { #ifdef __ELF__ # ifdef __GLIBC__ # if __GLIBC__ >= 2 printf ("%s-${VENDOR}-linux-gnu\n", argv[1]); # else printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]); # endif # else printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]); # endif #else printf ("%s-${VENDOR}-linux-gnuaout\n", argv[1]); #endif return 0; } EOF ${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0 rm -f dummy.c dummy fi ;; # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions # are messed up and put the nodename in both sysname and nodename. i?86:DYNIX/ptx:4*:*) echo i386-sequent-sysv4 exit 0 ;; i?86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit 0 ;; i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*) if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_RELEASE} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE} fi exit 0 ;; i?86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit 0 ;; i?86:UnixWare:*:*) if /bin/uname -X 2>/dev/null >/dev/null ; then (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 fi echo ${UNAME_MACHINE}-unixware-${UNAME_RELEASE}-${UNAME_VERSION} exit 0 ;; pc:*:*:*) # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i386. echo i386-pc-msdosdjgpp exit 0 ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit 0 ;; paragon:*:*:*) echo i860-intel-osf1 exit 0 ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit 0 ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit 0 ;; M68*:*:R3V[567]*:*) test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; 3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && echo i486-ncr-sysv4.3${OS_REL} && exit 0 /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && echo i486-ncr-sysv4 && exit 0 ;; m68*:LynxOS:2.*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit 0 ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit 0 ;; i?86:LynxOS:2.*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit 0 ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit 0 ;; rs6000:LynxOS:2.*:* | PowerPC:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit 0 ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit 0 ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit 0 ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit 0 ;; PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit 0 ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit 0 ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit 0 ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit 0 ;; news*:NEWS-OS:*:6*) echo mips-sony-newsos6 exit 0 ;; R3000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R4000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit 0 ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit 0 ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit 0 ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit 0 ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 cat >dummy.c < # include #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix"); exit (0); #endif #if defined (hp300) && !defined (hpux) printf ("m68k-hp-bsd\n"); exit (0); #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) #if !defined (ultrix) printf ("vax-dec-bsd\n"); exit (0); #else printf ("vax-dec-ultrix\n"); exit (0); #endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF ${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy && rm dummy.c dummy && exit 0 rm -f dummy.c dummy # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit 0 ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit 0 ;; c34*) echo c34-convex-bsd exit 0 ;; c38*) echo c38-convex-bsd exit 0 ;; c4*) echo c4-convex-bsd exit 0 ;; esac fi #echo '(Unable to guess system type)' 1>&2 exit 1 ; exit 0 ;; i?86coff) echo "${UNAME_MACHINE}-pc-linux-gnucoff" ; exit 0 ;; sparclinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;; armlinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;; m68klinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;; elf32ppc) echo "powerpc-unknown-linux-gnu" ; exit 0 ;; esac if test "${UNAME_MACHINE}" = "alpha" ; then tkeden1.18/config.h.in010060000025250000147000000047260731566733000161150ustar00ashleydcsother00003470000356/* * $Id: config.h.in,v 1.4 2000/08/31 14:46:22 ashley Rel1.10 $ */ /* Define if using alloca.c. */ #undef C_ALLOCA /* Define to empty if the keyword does not work. */ #undef const /* Define to one of _getb67, GETB67, getb67 for Cray-2 and Cray-YMP systems. This function is required for alloca.c support on those systems. */ #undef CRAY_STACKSEG_END /* Define if you have alloca, as a function or macro. */ #undef HAVE_ALLOCA /* Define if you have and it should be used (not on Ultrix). */ #undef HAVE_ALLOCA_H /* Define as the return type of signal handlers (int or void). */ #undef RETSIGTYPE /* If using the C implementation of alloca, define if you know the direction of stack growth for your system; otherwise it will be automatically deduced at run-time. STACK_DIRECTION > 0 => grows toward higher addresses STACK_DIRECTION < 0 => grows toward lower addresses STACK_DIRECTION = 0 => direction of growth unknown */ #undef STACK_DIRECTION /* Define if you can safely include both and . */ #undef TIME_WITH_SYS_TIME /* Define if your declares struct tm. */ #undef TM_IN_SYS_TIME /* Define if the X Window System is missing or not being used. */ #undef X_DISPLAY_MISSING /* Define if you have the dl library (-ldl). */ #undef HAVE_LIBDL /* Define if you have the m library (-lm). */ #undef HAVE_LIBM /* Define if your C compiler has protos */ #undef CC_HAS_PROTOS /* Define if you want to enable debugging */ #undef DEBUG /* Define to be (in bytes) to what boundary doubles should be aligned */ #undef DOUBLE_ALIGNMENT /* Define if you have the curses library */ #undef HAVE_CURSES /* Define if you have the ncurses library */ #undef HAVE_NCURSES /* Define if you want to use the dcc function for disabling circular checking */ #undef NO_CHECK_CIRCULAR /* Define to be something resembling the type of the system to enable configure to stop cached results being used on the wrong system */ #undef SYSTEM_NAME /* Define if you want to enable eden parser debugging */ #undef YYDEBUG /* Define if you have the dmalloc library (-ldmalloc) */ #undef HAVE_DMALLOC /* Define if you have the GNU readline library (-lreadline) */ #undef HAVE_READLINE /* Define if you want the Sasami facilities (a notation using OpenGL graphics) to be included */ #undef WANT_SASAMI /* Define if your version of Tcl has Tcl_EvalEX */ #undef HAVE_TCL_EVALEX /* Define if you want to use Eden's IPC functions (send_msg...) */ #undef ipc tkeden1.18/config.sub010070000025250000147000000466110727406557200160560ustar00ashleydcsother00003470000356#! /bin/sh # Configuration validation subroutine script, version 1.1. # Copyright (C) 1991, 92-97, 1998 Free Software Foundation, Inc. # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software # can handle that machine. It does not imply ALL GNU software can. # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. if [ x$1 = x ] then echo Configuration name missing. 1>&2 echo "Usage: $0 CPU-MFR-OPSYS" 1>&2 echo "or $0 ALIAS" 1>&2 echo where ALIAS is a recognized configuration type. 1>&2 exit 1 fi # First pass through any local machine types. case $1 in *local*) echo $1 exit 0 ;; *) ;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in linux-gnu*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple) os= basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco5) os=sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. tahoe | i860 | m32r | m68k | m68000 | m88k | ns32k | arc | arm \ | arme[lb] | pyramid | mn10200 | mn10300 | tron | a29k \ | 580 | i960 | h8300 | hppa | hppa1.0 | hppa1.1 | hppa2.0 \ | alpha | alphaev5 | alphaev56 |alphaev6 | we32k | ns16k | clipper \ | i370 | sh | powerpc | powerpcle | 1750a | dsp16xx | pdp11 \ | mips64 | mipsel | mips64el | mips64orion | mips64orionel \ | mipstx39 | mipstx39el \ | sparc | sparclet | sparclite | sparc64 | v850) basic_machine=$basic_machine-unknown ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i[34567]86) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. vax-* | tahoe-* | i[34567]86-* | i860-* | m32r-* | m68k-* | m68000-* \ | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | arm-* | c[123]* \ | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \ | power-* | none-* | 580-* | cray2-* | h8300-* | i960-* \ | xmp-* | ymp-* | hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* \ | alpha-* | alphaev5-* | alphaev56-* |alpha-ev6-* |alphaev6-* | we32k-* | cydra-* \ | ns16k-* | pn-* | np1-* | xps100-* | clipper-* | orion-* \ | sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \ | sparc64-* | mips64-* | mipsel-* \ | mips64el-* | mips64orion-* | mips64orionel-* \ | mipstx39-* | mipstx39el-* \ | f301-*) ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-cbm ;; amigaos | amigados) basic_machine=m68k-cbm os=-amigaos ;; amigaunix | amix) basic_machine=m68k-cbm os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | ymp) basic_machine=ymp-cray os=-unicos ;; cray2) basic_machine=cray2-cray os=-unicos ;; [ctj]90-cray) basic_machine=c90-cray os=-unicos ;; crds | unos) basic_machine=m68k-crds ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k7[0-9][0-9] | hp7[0-9][0-9] | hp9k8[0-9]7 | hp8[0-9]7) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; i370-ibm* | ibm*) basic_machine=i370-ibm os=-mvs ;; # I'm not sure what "Sysv32" means. Should this be sysv3.2? i[34567]86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i[34567]86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i[34567]86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i[34567]86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; miniframe) basic_machine=m68000-convergent ;; mipsel*-linux*) basic_machine=mipsel-unknown os=-linux-gnu ;; mips*-linux*) basic_machine=mips-unknown os=-linux-gnu ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; np1) basic_machine=np1-gould ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pentium | p5 | k5 | nexen) basic_machine=i586-pc ;; pentiumpro | p6 | k6 | 6x86) basic_machine=i686-pc ;; pentiumii | pentium2) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | nexen-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | k6-* | 6x86-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-*) basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=rs6000-ibm ;; ppc) basic_machine=powerpc-unknown ;; ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; symmetry) basic_machine=i386-sequent os=-dynix ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; tower | tower-32) basic_machine=m68k-ncr ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; xmp) basic_machine=xmp-cray os=-unicos ;; xps | xps100) basic_machine=xps100-honeywell ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. mips) if [ x$os = x-linux-gnu ]; then basic_machine=mips-unknown else basic_machine=mips-mips fi ;; romp) basic_machine=romp-ibm ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sparc) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -uxpv* | -beos*) # Remember, each alternative MUST END IN *, to match a version number. ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -ctix* | -uts*) os=-sysv ;; -ns2 ) os=-nextstep2 ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -xenix) os=-xenix ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in *-acorn) os=-riscix1.2 ;; arm*-semi) os=-aout ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 # This also exists in the configure program, but was not the # default. # os=-sunos4 ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-ibm) os=-aix ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f301-fujitsu) os=-uxpv ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -aix*) vendor=ibm ;; -hpux*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs*) vendor=ibm ;; -ptx*) vendor=sequent ;; -vxsim* | -vxworks*) vendor=wrs ;; -aux*) vendor=apple ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os 86.*/86-pc/'` os=-sysv ;; i[34567]86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; tkeden1.18/configure010070000025250000147000006001310731566751200157710ustar00ashleydcsother00003470000356#! /bin/sh # From configure.in Revision: 1.18 # Check this file exists to make sure we are in the correct directory # Guess values for system-dependent variables and create Makefiles. # Generated automatically using autoconf version 2.13 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. # Defaults: ac_help= ac_default_prefix=/usr/local # Any additions from configure.in: ac_help="$ac_help --enable-debug enable debugging" ac_help="$ac_help --enable-dcc enable dcc function for disabling circular checking" ac_help="$ac_help --enable-depend enable Makefile source dependency checking" ac_help="$ac_help --enable-disable-sasami don't try to build the Sasami OpenGL notation" ac_help="$ac_help --enable-ipc enable support for Eden IPC functions (send_msg...)" ac_help="$ac_help --with-x use the X Window System" ac_help="$ac_help --with-curses-include=DIR (n)curses include files are in DIR" ac_help="$ac_help --with-curses-lib=DIR (n)curses library files are in DIR" ac_help="$ac_help --with-tcl-include=compiler options to enable location of tcl.h eg \"-I/usr/local/include\"" ac_help="$ac_help --with-tcl-lib=linker options to enable location of the tcl library eg \"-L/usr/local/lib -R/usr/local/lib -ltcl\"" ac_help="$ac_help --with-tk-include=compiler options to enable location of tk.h eg \"-I/usr/local/include\"" ac_help="$ac_help --with-tk-lib=linker options to enable location of the tk library eg \"-L/usr/local/lib -R/usr/local/lib -ltk\"" ac_help="$ac_help --with-readline-include=compiler options to enable location of GNU readline header files eg \"-I/gnu/include/readline\"" ac_help="$ac_help --with-readline-lib=linker options to enable location of the GNU readline library eg \"-L/gnu/lib -R/gnu/lib -lreadline\"" ac_help="$ac_help --with-gl-include=compiler options to enable location of GL header files eg \"-I/usr/openwin/include\"" ac_help="$ac_help --with-gl-lib=linker options to enable location of the GL library eg \"-L/usr/openwin/lib -R/usr/openwin/lib -lGL\"" ac_help="$ac_help --with-png-include=compiler options to enable location of PNG header files eg \"-I/usr/local/include\"" ac_help="$ac_help --with-png-lib=linker options to enable location of the PNG library eg \"-L/usr/local/lib -R/usr/local/lib -lpng\"" ac_help="$ac_help --with-dmalloc-include=DIR dmalloc include file is in DIR" ac_help="$ac_help --with-dmalloc-lib=DIR dmalloc lib file is in DIR" # Initialize some variables set by options. # The variables have the same names as the options, with # dashes changed to underlines. build=NONE cache_file=./config.cache exec_prefix=NONE host=NONE no_create= nonopt=NONE no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= target=NONE verbose= x_includes=NONE x_libraries=NONE bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datadir='${prefix}/share' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' libdir='${exec_prefix}/lib' includedir='${prefix}/include' oldincludedir='/usr/include' infodir='${prefix}/info' mandir='${prefix}/man' # Initialize some other variables. subdirs= MFLAGS= MAKEFLAGS= SHELL=${CONFIG_SHELL-/bin/sh} # Maximum number of lines to put in a shell here document. ac_max_here_lines=12 ac_prev= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval "$ac_prev=\$ac_option" ac_prev= continue fi case "$ac_option" in -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; *) ac_optarg= ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case "$ac_option" in -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir="$ac_optarg" ;; -build | --build | --buil | --bui | --bu) ac_prev=build ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build="$ac_optarg" ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file="$ac_optarg" ;; -datadir | --datadir | --datadi | --datad | --data | --dat | --da) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ | --da=*) datadir="$ac_optarg" ;; -disable-* | --disable-*) ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } fi ac_feature=`echo $ac_feature| sed 's/-/_/g'` eval "enable_${ac_feature}=no" ;; -enable-* | --enable-*) ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } fi ac_feature=`echo $ac_feature| sed 's/-/_/g'` case "$ac_option" in *=*) ;; *) ac_optarg=yes ;; esac eval "enable_${ac_feature}='$ac_optarg'" ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix="$ac_optarg" ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he) # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat << EOF Usage: configure [options] [host] Options: [defaults in brackets after descriptions] Configuration: --cache-file=FILE cache test results in FILE --help print this message --no-create do not create output files --quiet, --silent do not print \`checking...' messages --version print the version of autoconf that created configure Directory and file names: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [same as prefix] --bindir=DIR user executables in DIR [EPREFIX/bin] --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] --libexecdir=DIR program executables in DIR [EPREFIX/libexec] --datadir=DIR read-only architecture-independent data in DIR [PREFIX/share] --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data in DIR [PREFIX/com] --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] --libdir=DIR object code libraries in DIR [EPREFIX/lib] --includedir=DIR C header files in DIR [PREFIX/include] --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] --infodir=DIR info documentation in DIR [PREFIX/info] --mandir=DIR man documentation in DIR [PREFIX/man] --srcdir=DIR find the sources in DIR [configure dir or ..] --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names EOF cat << EOF Host type: --build=BUILD configure for building on BUILD [BUILD=HOST] --host=HOST configure for HOST [guessed] --target=TARGET configure for TARGET [TARGET=HOST] Features and packages: --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --x-includes=DIR X include files are in DIR --x-libraries=DIR X library files are in DIR EOF if test -n "$ac_help"; then echo "--enable and --with options recognized:$ac_help" fi exit 0 ;; -host | --host | --hos | --ho) ac_prev=host ;; -host=* | --host=* | --hos=* | --ho=*) host="$ac_optarg" ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir="$ac_optarg" ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir="$ac_optarg" ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir="$ac_optarg" ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir="$ac_optarg" ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst \ | --locals | --local | --loca | --loc | --lo) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* \ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) localstatedir="$ac_optarg" ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir="$ac_optarg" ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir="$ac_optarg" ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix="$ac_optarg" ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix="$ac_optarg" ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix="$ac_optarg" ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name="$ac_optarg" ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir="$ac_optarg" ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir="$ac_optarg" ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site="$ac_optarg" ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir="$ac_optarg" ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir="$ac_optarg" ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target="$ac_optarg" ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers) echo "configure generated by autoconf version 2.13" exit 0 ;; -with-* | --with-*) ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } fi ac_package=`echo $ac_package| sed 's/-/_/g'` case "$ac_option" in *=*) ;; *) ac_optarg=yes ;; esac eval "with_${ac_package}='$ac_optarg'" ;; -without-* | --without-*) ac_package=`echo $ac_option|sed -e 's/-*without-//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } fi ac_package=`echo $ac_package| sed 's/-/_/g'` eval "with_${ac_package}=no" ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes="$ac_optarg" ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries="$ac_optarg" ;; -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } ;; *) if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then echo "configure: warning: $ac_option: invalid host type" 1>&2 fi if test "x$nonopt" != xNONE; then { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } fi nonopt="$ac_option" ;; esac done if test -n "$ac_prev"; then { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } fi trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 # File descriptor usage: # 0 standard input # 1 file creation # 2 errors and warnings # 3 some systems may open it to /dev/tty # 4 used on the Kubota Titan # 6 checking for... messages and results # 5 compiler messages saved in config.log if test "$silent" = yes; then exec 6>/dev/null else exec 6>&1 fi exec 5>./config.log echo "\ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. " 1>&5 # Strip out --no-create and --no-recursion so they do not pile up. # Also quote any args containing shell metacharacters. ac_configure_args= for ac_arg do case "$ac_arg" in -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c) ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) ac_configure_args="$ac_configure_args '$ac_arg'" ;; *) ac_configure_args="$ac_configure_args $ac_arg" ;; esac done # NLS nuisances. # Only set these to C if already set. These must not be set unconditionally # because not all systems understand e.g. LANG=C (notably SCO). # Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! # Non-C LC_CTYPE values break the ctype check. if test "${LANG+set}" = set; then LANG=C; export LANG; fi if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -rf conftest* confdefs.h # AIX cpp loses on an empty file, so make sure it contains at least a newline. echo > confdefs.h # A filename unique to this package, relative to the directory that # configure is in, which we can look for to find out if srcdir is correct. ac_unique_file=Eden/main.c # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then its parent. ac_prog=$0 ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. srcdir=$ac_confdir if test ! -r $srcdir/$ac_unique_file; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r $srcdir/$ac_unique_file; then if test "$ac_srcdir_defaulted" = yes; then { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } else { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } fi fi srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` # Prefer explicitly selected file to automatically selected ones. if test -z "$CONFIG_SITE"; then if test "x$prefix" != xNONE; then CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" else CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" fi fi for ac_site_file in $CONFIG_SITE; do if test -r "$ac_site_file"; then echo "loading site script $ac_site_file" . "$ac_site_file" fi done if test -r "$cache_file"; then echo "loading cache $cache_file" . $cache_file else echo "creating cache $cache_file" > $cache_file fi ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross ac_exeext= ac_objext=o if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then ac_n= ac_c=' ' ac_t=' ' else ac_n=-n ac_c= ac_t= fi else ac_n= ac_c='\c' ac_t= fi # Sanity check ac_aux_dir= for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do if test -f $ac_dir/install-sh; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f $ac_dir/install.sh; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break fi done if test -z "$ac_aux_dir"; then { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; } fi ac_config_guess=$ac_aux_dir/config.guess ac_config_sub=$ac_aux_dir/config.sub ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. # # Check if we're accidentally using a cache from a different machine. # Derive the system name, as a check for reusing the autoconf cache. # # If we've packaged config.guess and config.sub, run that (since it does a # better job than uname). # if test -f $srcdir/config.guess ; then # Make sure we can run config.sub. if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then : else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } fi echo $ac_n "checking host system type""... $ac_c" 1>&6 echo "configure:627: checking host system type" >&5 host_alias=$host case "$host_alias" in NONE) case $nonopt in NONE) if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then : else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; } fi ;; *) host_alias=$nonopt ;; esac ;; esac host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias` host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$ac_t""$host" 1>&6 system_name="$host_os" else system_name="`(uname -s -r) 2>/dev/null`" if test -z "$system_name" ; then system_name="`(hostname) 2>/dev/null`" fi fi test -n "$system_name" && cat >> confdefs.h <&6 else cf_cv_system_name="$system_name" fi test -z "$system_name" && system_name="$cf_cv_system_name" test -n "$cf_cv_system_name" && echo "$ac_t"""Configuring for $cf_cv_system_name"" 1>&6 if test ".$system_name" != ".$cf_cv_system_name" ; then echo "$ac_t"""Cached system name does not agree with actual"" 1>&6 { echo "configure: error: "Please remove config.cache and try again."" 1>&2; exit 1; } fi # !@!@ Not sure if all of these are required # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:678: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_CC="gcc" break fi done IFS="$ac_save_ifs" fi fi CC="$ac_cv_prog_CC" if test -n "$CC"; then echo "$ac_t""$CC" 1>&6 else echo "$ac_t""no" 1>&6 fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:708: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_prog_rejected=no ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" break fi done IFS="$ac_save_ifs" if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# -gt 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift set dummy "$ac_dir/$ac_word" "$@" shift ac_cv_prog_CC="$@" fi fi fi fi CC="$ac_cv_prog_CC" if test -n "$CC"; then echo "$ac_t""$CC" 1>&6 else echo "$ac_t""no" 1>&6 fi if test -z "$CC"; then case "`uname -s`" in *win32* | *WIN32*) # Extract the first word of "cl", so it can be a program name with args. set dummy cl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:759: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_CC="cl" break fi done IFS="$ac_save_ifs" fi fi CC="$ac_cv_prog_CC" if test -n "$CC"; then echo "$ac_t""$CC" 1>&6 else echo "$ac_t""no" 1>&6 fi ;; esac fi test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 echo "configure:791: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF #line 802 "configure" #include "confdefs.h" main(){return(0);} EOF if { (eval echo configure:807: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then ac_cv_prog_cc_cross=no else ac_cv_prog_cc_cross=yes fi else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 ac_cv_prog_cc_works=no fi rm -fr conftest* ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 echo "configure:833: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 echo "configure:838: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no fi fi echo "$ac_t""$ac_cv_prog_gcc" 1>&6 if test $ac_cv_prog_gcc = yes; then GCC=yes else GCC= fi ac_test_CFLAGS="${CFLAGS+set}" ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 echo "configure:866: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else echo 'void f(){}' > conftest.c if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then ac_cv_prog_cc_g=yes else ac_cv_prog_cc_g=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 if test "$ac_test_CFLAGS" = set; then CFLAGS="$ac_save_CFLAGS" elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 echo "configure:898: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else # This must be in double quotes, not single quotes, because CPP may get # substituted into the Makefile and "${CC-cc}" will confuse make. CPP="${CC-cc} -E" # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:919: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:936: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* CPP="${CC-cc} -nologo -E" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:953: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* CPP=/lib/cpp fi rm -f conftest* fi rm -f conftest* fi rm -f conftest* ac_cv_prog_CPP="$CPP" fi CPP="$ac_cv_prog_CPP" else ac_cv_prog_CPP="$CPP" fi echo "$ac_t""$CPP" 1>&6 # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 echo "configure:989: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" for ac_dir in $PATH; do # Account for people who put trailing slashes in PATH elements. case "$ac_dir/" in /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do if test -f $ac_dir/$ac_prog; then if test $ac_prog = install && grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : else ac_cv_path_install="$ac_dir/$ac_prog -c" break 2 fi fi done ;; esac done IFS="$ac_save_IFS" fi if test "${ac_cv_path_install+set}" = set; then INSTALL="$ac_cv_path_install" else # As a last resort, use the slow shell script. We don't cache a # path for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the path is relative. INSTALL="$ac_install_sh" fi fi echo "$ac_t""$INSTALL" 1>&6 # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' # Extract the first word of "flex", so it can be a program name with args. set dummy flex; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:1044: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_LEX'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$LEX"; then ac_cv_prog_LEX="$LEX" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_LEX="flex" break fi done IFS="$ac_save_ifs" test -z "$ac_cv_prog_LEX" && ac_cv_prog_LEX="lex" fi fi LEX="$ac_cv_prog_LEX" if test -n "$LEX"; then echo "$ac_t""$LEX" 1>&6 else echo "$ac_t""no" 1>&6 fi if test -z "$LEXLIB" then case "$LEX" in flex*) ac_lib=fl ;; *) ac_lib=l ;; esac echo $ac_n "checking for yywrap in -l$ac_lib""... $ac_c" 1>&6 echo "configure:1078: checking for yywrap in -l$ac_lib" >&5 ac_lib_var=`echo $ac_lib'_'yywrap | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-l$ac_lib $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 LEXLIB="-l$ac_lib" else echo "$ac_t""no" 1>&6 fi fi echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 echo "configure:1120: checking whether ${MAKE-make} sets \${MAKE}" >&5 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftestmake <<\EOF all: @echo 'ac_maketemp="${MAKE}"' EOF # GNU make sometimes prints "make[1]: Entering...", which would confuse us. eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=` if test -n "$ac_maketemp"; then eval ac_cv_prog_make_${ac_make}_set=yes else eval ac_cv_prog_make_${ac_make}_set=no fi rm -f conftestmake fi if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then echo "$ac_t""yes" 1>&6 SET_MAKE= else echo "$ac_t""no" 1>&6 SET_MAKE="MAKE=${MAKE-make}" fi # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:1149: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_RANLIB="ranlib" break fi done IFS="$ac_save_ifs" test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":" fi fi RANLIB="$ac_cv_prog_RANLIB" if test -n "$RANLIB"; then echo "$ac_t""$RANLIB" 1>&6 else echo "$ac_t""no" 1>&6 fi # Find options to use ANSI C echo $ac_n "checking for ${CC-cc} option to accept ANSI C""... $ac_c" 1>&6 echo "configure:1180: checking for ${CC-cc} option to accept ANSI C" >&5 if eval "test \"`echo '$''{'cf_cv_ansi_cc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cf_cv_ansi_cc=no cf_save_CFLAGS="$CFLAGS" # Don't try gcc -ansi; that turns off useful extensions and # breaks some systems' header files. # AIX -qlanglvl=ansi # Ultrix and OSF/1 -std1 # HP-UX -Aa -D_HPUX_SOURCE # SVR4 -Xc # UnixWare 1.2 (cannot use -Xc, since ANSI/POSIX clashes) for cf_arg in "-DCC_HAS_PROTOS" "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE" -Xc do CFLAGS="$cf_save_CFLAGS $cf_arg" cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* cf_cv_ansi_cc="$cf_arg"; break else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -f conftest* done CFLAGS="$cf_save_CFLAGS" fi echo "$ac_t""$cf_cv_ansi_cc" 1>&6 if test "$cf_cv_ansi_cc" != "no"; then if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then CFLAGS="$CFLAGS $cf_cv_ansi_cc" else cat >> confdefs.h <<\EOF #define CC_HAS_PROTOS 1 EOF fi fi # Is the math library OK? echo $ac_n "checking for tan in -lm""... $ac_c" 1>&6 echo "configure:1243: checking for tan in -lm" >&5 ac_lib_var=`echo m'_'tan | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lm $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_lib=HAVE_LIB`echo m | sed -e 's/[^a-zA-Z0-9_]/_/g' \ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` cat >> confdefs.h <&6 { echo "configure: error: can't find math functions" 1>&2; exit 1; } fi # Tcl on Linux on PC seems to require -ldl echo $ac_n "checking for dlerror in -ldl""... $ac_c" 1>&6 echo "configure:1293: checking for dlerror in -ldl" >&5 ac_lib_var=`echo dl'_'dlerror | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-ldl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_lib=HAVE_LIB`echo dl | sed -e 's/[^a-zA-Z0-9_]/_/g' \ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` cat >> confdefs.h <&6 fi ######################################################################### # Compile time switches ######################################################################### # Check whether --enable-debug or --disable-debug was given. if test "${enable_debug+set}" = set; then enableval="$enable_debug" cat >> confdefs.h <<\EOF #define DEBUG 1 EOF cat >> confdefs.h <<\EOF #define YYDEBUG 1 EOF # parser debugging wrapped into general debug now fi # Check whether --enable-dcc or --disable-dcc was given. if test "${enable_dcc+set}" = set; then enableval="$enable_dcc" cat >> confdefs.h <<\EOF #define NO_CHECK_CIRCULAR 1 EOF fi # Check whether --enable-depend or --disable-depend was given. if test "${enable_depend+set}" = set; then enableval="$enable_depend" DEPEND_MAKEDEFS="include ../depend.mk" else DEPEND_MAKEDEFS="#include ../depend.mk" fi # Check whether --enable-disable-sasami or --disable-disable-sasami was given. if test "${enable_disable_sasami+set}" = set; then enableval="$enable_disable_sasami" echo "configure: warning: Disabling Sasami" 1>&2 aw_want_sasami="no" else aw_want_sasami="yes" cat >> confdefs.h <<\EOF #define WANT_SASAMI 1 EOF fi # Check whether --enable-ipc or --disable-ipc was given. if test "${enable_ipc+set}" = set; then enableval="$enable_ipc" cat >> confdefs.h <<\EOF #define ipc 1 EOF fi ######################################################################### # X ######################################################################### # If we find X, set shell vars x_includes and x_libraries to the # paths, otherwise set no_x=yes. # Uses ac_ vars as temps to allow command line to override cache and checks. # --without-x overrides everything else, but does not touch the cache. echo $ac_n "checking for X""... $ac_c" 1>&6 echo "configure:1424: checking for X" >&5 # Check whether --with-x or --without-x was given. if test "${with_x+set}" = set; then withval="$with_x" : fi # $have_x is `yes', `no', `disabled', or empty when we do not yet know. if test "x$with_x" = xno; then # The user explicitly disabled X. have_x=disabled else if test "x$x_includes" != xNONE && test "x$x_libraries" != xNONE; then # Both variables are already set. have_x=yes else if eval "test \"`echo '$''{'ac_cv_have_x'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else # One or both of the vars are not set, and there is no cached value. ac_x_includes=NO ac_x_libraries=NO rm -fr conftestdir if mkdir conftestdir; then cd conftestdir # Make sure to not put "make" in the Imakefile rules, since we grep it out. cat > Imakefile <<'EOF' acfindx: @echo 'ac_im_incroot="${INCROOT}"; ac_im_usrlibdir="${USRLIBDIR}"; ac_im_libdir="${LIBDIR}"' EOF if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then # GNU make sometimes prints "make[1]: Entering...", which would confuse us. eval `${MAKE-make} acfindx 2>/dev/null | grep -v make` # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR. for ac_extension in a so sl; do if test ! -f $ac_im_usrlibdir/libX11.$ac_extension && test -f $ac_im_libdir/libX11.$ac_extension; then ac_im_usrlibdir=$ac_im_libdir; break fi done # Screen out bogus values from the imake configuration. They are # bogus both because they are the default anyway, and because # using them would break gcc on systems where it needs fixed includes. case "$ac_im_incroot" in /usr/include) ;; *) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes="$ac_im_incroot" ;; esac case "$ac_im_usrlibdir" in /usr/lib | /lib) ;; *) test -d "$ac_im_usrlibdir" && ac_x_libraries="$ac_im_usrlibdir" ;; esac fi cd .. rm -fr conftestdir fi if test "$ac_x_includes" = NO; then # Guess where to find include files, by looking for this one X11 .h file. test -z "$x_direct_test_include" && x_direct_test_include=X11/Intrinsic.h # First, try using that file with no special directory specified. cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1491: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* # We can compile using X headers with no special include directory. ac_x_includes= else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Look for the header file in a standard set of common directories. # Check X11 before X11Rn because it is often a symlink to the current release. for ac_dir in \ /usr/X11/include \ /usr/X11R6/include \ /usr/X11R5/include \ /usr/X11R4/include \ \ /usr/include/X11 \ /usr/include/X11R6 \ /usr/include/X11R5 \ /usr/include/X11R4 \ \ /usr/local/X11/include \ /usr/local/X11R6/include \ /usr/local/X11R5/include \ /usr/local/X11R4/include \ \ /usr/local/include/X11 \ /usr/local/include/X11R6 \ /usr/local/include/X11R5 \ /usr/local/include/X11R4 \ \ /usr/X386/include \ /usr/x386/include \ /usr/XFree86/include/X11 \ \ /usr/include \ /usr/local/include \ /usr/unsupported/include \ /usr/athena/include \ /usr/local/x11r5/include \ /usr/lpp/Xamples/include \ \ /usr/openwin/include \ /usr/openwin/share/include \ ; \ do if test -r "$ac_dir/$x_direct_test_include"; then ac_x_includes=$ac_dir break fi done fi rm -f conftest* fi # $ac_x_includes = NO if test "$ac_x_libraries" = NO; then # Check for the libraries. test -z "$x_direct_test_library" && x_direct_test_library=Xt test -z "$x_direct_test_function" && x_direct_test_function=XtMalloc # See if we find them without any special options. # Don't add to $LIBS permanently. ac_save_LIBS="$LIBS" LIBS="-l$x_direct_test_library $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* LIBS="$ac_save_LIBS" # We can link X programs with no special library path. ac_x_libraries= else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* LIBS="$ac_save_LIBS" # First see if replacing the include by lib works. # Check X11 before X11Rn because it is often a symlink to the current release. for ac_dir in `echo "$ac_x_includes" | sed s/include/lib/` \ /usr/X11/lib \ /usr/X11R6/lib \ /usr/X11R5/lib \ /usr/X11R4/lib \ \ /usr/lib/X11 \ /usr/lib/X11R6 \ /usr/lib/X11R5 \ /usr/lib/X11R4 \ \ /usr/local/X11/lib \ /usr/local/X11R6/lib \ /usr/local/X11R5/lib \ /usr/local/X11R4/lib \ \ /usr/local/lib/X11 \ /usr/local/lib/X11R6 \ /usr/local/lib/X11R5 \ /usr/local/lib/X11R4 \ \ /usr/X386/lib \ /usr/x386/lib \ /usr/XFree86/lib/X11 \ \ /usr/lib \ /usr/local/lib \ /usr/unsupported/lib \ /usr/athena/lib \ /usr/local/x11r5/lib \ /usr/lpp/Xamples/lib \ /lib/usr/lib/X11 \ \ /usr/openwin/lib \ /usr/openwin/share/lib \ ; \ do for ac_extension in a so sl; do if test -r $ac_dir/lib${x_direct_test_library}.$ac_extension; then ac_x_libraries=$ac_dir break 2 fi done done fi rm -f conftest* fi # $ac_x_libraries = NO if test "$ac_x_includes" = NO || test "$ac_x_libraries" = NO; then # Didn't find X anywhere. Cache the known absence of X. ac_cv_have_x="have_x=no" else # Record where we found X for the cache. ac_cv_have_x="have_x=yes \ ac_x_includes=$ac_x_includes ac_x_libraries=$ac_x_libraries" fi fi fi eval "$ac_cv_have_x" fi # $with_x != no if test "$have_x" != yes; then echo "$ac_t""$have_x" 1>&6 no_x=yes else # If each of the values was on the command line, it overrides each guess. test "x$x_includes" = xNONE && x_includes=$ac_x_includes test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries # Update the cache value to reflect the command line values. ac_cv_have_x="have_x=yes \ ac_x_includes=$x_includes ac_x_libraries=$x_libraries" echo "$ac_t""libraries $x_libraries, headers $x_includes" 1>&6 fi if test "$no_x" = yes; then # Not all programs may use this symbol, but it does not hurt to define it. cat >> confdefs.h <<\EOF #define X_DISPLAY_MISSING 1 EOF X_CFLAGS= X_PRE_LIBS= X_LIBS= X_EXTRA_LIBS= else if test -n "$x_includes"; then X_CFLAGS="$X_CFLAGS -I$x_includes" fi # It would also be nice to do this for all -L options, not just this one. if test -n "$x_libraries"; then X_LIBS="$X_LIBS -L$x_libraries" # For Solaris; some versions of Sun CC require a space after -R and # others require no space. Words are not sufficient . . . . case "`(uname -sr) 2>/dev/null`" in "SunOS 5"*) echo $ac_n "checking whether -R must be followed by a space""... $ac_c" 1>&6 echo "configure:1673: checking whether -R must be followed by a space" >&5 ac_xsave_LIBS="$LIBS"; LIBS="$LIBS -R$x_libraries" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_R_nospace=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_R_nospace=no fi rm -f conftest* if test $ac_R_nospace = yes; then echo "$ac_t""no" 1>&6 X_LIBS="$X_LIBS -R$x_libraries" else LIBS="$ac_xsave_LIBS -R $x_libraries" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_R_space=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_R_space=no fi rm -f conftest* if test $ac_R_space = yes; then echo "$ac_t""yes" 1>&6 X_LIBS="$X_LIBS -R $x_libraries" else echo "$ac_t""neither works" 1>&6 fi fi LIBS="$ac_xsave_LIBS" esac fi # Check for system-dependent libraries X programs must link with. # Do this before checking for the system-independent R6 libraries # (-lICE), since we may need -lsocket or whatever for X linking. if test "$ISC" = yes; then X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl_s -linet" else # Martyn.Johnson@cl.cam.ac.uk says this is needed for Ultrix, if the X # libraries were built with DECnet support. And karl@cs.umb.edu says # the Alpha needs dnet_stub (dnet does not exist). echo $ac_n "checking for dnet_ntoa in -ldnet""... $ac_c" 1>&6 echo "configure:1738: checking for dnet_ntoa in -ldnet" >&5 ac_lib_var=`echo dnet'_'dnet_ntoa | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-ldnet $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet" else echo "$ac_t""no" 1>&6 fi if test $ac_cv_lib_dnet_dnet_ntoa = no; then echo $ac_n "checking for dnet_ntoa in -ldnet_stub""... $ac_c" 1>&6 echo "configure:1779: checking for dnet_ntoa in -ldnet_stub" >&5 ac_lib_var=`echo dnet_stub'_'dnet_ntoa | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-ldnet_stub $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub" else echo "$ac_t""no" 1>&6 fi fi # msh@cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT, # to get the SysV transport functions. # chad@anasazi.com says the Pyramis MIS-ES running DC/OSx (SVR4) # needs -lnsl. # The nsl library prevents programs from opening the X display # on Irix 5.2, according to dickey@clark.net. echo $ac_n "checking for gethostbyname""... $ac_c" 1>&6 echo "configure:1827: checking for gethostbyname" >&5 if eval "test \"`echo '$''{'ac_cv_func_gethostbyname'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char gethostbyname(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_gethostbyname) || defined (__stub___gethostbyname) choke me #else gethostbyname(); #endif ; return 0; } EOF if { (eval echo configure:1855: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_gethostbyname=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_gethostbyname=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'gethostbyname`\" = yes"; then echo "$ac_t""yes" 1>&6 : else echo "$ac_t""no" 1>&6 fi if test $ac_cv_func_gethostbyname = no; then echo $ac_n "checking for gethostbyname in -lnsl""... $ac_c" 1>&6 echo "configure:1876: checking for gethostbyname in -lnsl" >&5 ac_lib_var=`echo nsl'_'gethostbyname | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lnsl $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl" else echo "$ac_t""no" 1>&6 fi fi # lieder@skyler.mavd.honeywell.com says without -lsocket, # socket/setsockopt and other routines are undefined under SCO ODT # 2.0. But -lsocket is broken on IRIX 5.2 (and is not necessary # on later versions), says simon@lia.di.epfl.ch: it contains # gethostby* variants that don't use the nameserver (or something). # -lsocket must be given before -lnsl if both are needed. # We assume that if connect needs -lnsl, so does gethostbyname. echo $ac_n "checking for connect""... $ac_c" 1>&6 echo "configure:1925: checking for connect" >&5 if eval "test \"`echo '$''{'ac_cv_func_connect'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char connect(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_connect) || defined (__stub___connect) choke me #else connect(); #endif ; return 0; } EOF if { (eval echo configure:1953: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_connect=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_connect=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'connect`\" = yes"; then echo "$ac_t""yes" 1>&6 : else echo "$ac_t""no" 1>&6 fi if test $ac_cv_func_connect = no; then echo $ac_n "checking for connect in -lsocket""... $ac_c" 1>&6 echo "configure:1974: checking for connect in -lsocket" >&5 ac_lib_var=`echo socket'_'connect | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lsocket $X_EXTRA_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS" else echo "$ac_t""no" 1>&6 fi fi # gomez@mi.uni-erlangen.de says -lposix is necessary on A/UX. echo $ac_n "checking for remove""... $ac_c" 1>&6 echo "configure:2017: checking for remove" >&5 if eval "test \"`echo '$''{'ac_cv_func_remove'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char remove(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_remove) || defined (__stub___remove) choke me #else remove(); #endif ; return 0; } EOF if { (eval echo configure:2045: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_remove=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_remove=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'remove`\" = yes"; then echo "$ac_t""yes" 1>&6 : else echo "$ac_t""no" 1>&6 fi if test $ac_cv_func_remove = no; then echo $ac_n "checking for remove in -lposix""... $ac_c" 1>&6 echo "configure:2066: checking for remove in -lposix" >&5 ac_lib_var=`echo posix'_'remove | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lposix $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix" else echo "$ac_t""no" 1>&6 fi fi # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay. echo $ac_n "checking for shmat""... $ac_c" 1>&6 echo "configure:2109: checking for shmat" >&5 if eval "test \"`echo '$''{'ac_cv_func_shmat'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char shmat(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_shmat) || defined (__stub___shmat) choke me #else shmat(); #endif ; return 0; } EOF if { (eval echo configure:2137: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_shmat=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_shmat=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'shmat`\" = yes"; then echo "$ac_t""yes" 1>&6 : else echo "$ac_t""no" 1>&6 fi if test $ac_cv_func_shmat = no; then echo $ac_n "checking for shmat in -lipc""... $ac_c" 1>&6 echo "configure:2158: checking for shmat in -lipc" >&5 ac_lib_var=`echo ipc'_'shmat | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lipc $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc" else echo "$ac_t""no" 1>&6 fi fi fi # Check for libraries that X11R6 Xt/Xaw programs need. ac_save_LDFLAGS="$LDFLAGS" test -n "$x_libraries" && LDFLAGS="$LDFLAGS -L$x_libraries" # SM needs ICE to (dynamically) link under SunOS 4.x (so we have to # check for ICE first), but we must link in the order -lSM -lICE or # we get undefined symbols. So assume we have SM if we have ICE. # These have to be linked with before -lX11, unlike the other # libraries we check for below, so use a different variable. # --interran@uluru.Stanford.EDU, kb@cs.umb.edu. echo $ac_n "checking for IceConnectionNumber in -lICE""... $ac_c" 1>&6 echo "configure:2210: checking for IceConnectionNumber in -lICE" >&5 ac_lib_var=`echo ICE'_'IceConnectionNumber | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lICE $X_EXTRA_LIBS $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE" else echo "$ac_t""no" 1>&6 fi LDFLAGS="$ac_save_LDFLAGS" fi # Bit of a bodge but I can't think of a better way of detecting Windoz if test "$no_x" = "yes"; then # Probably Windoz AW_X_LIBS="-lGDI32 -lUSER32 -lCOMDLG32 -lKERNEL32" else AW_X_LIBS="-lXt -lX11" if test "$aw_want_sasami" = "yes"; then AW_X_LIBS="$AW_X_LIBS -lXmu -lXext" fi fi ######################################################################### # Run time linker ######################################################################### # The Solaris implementation of dynamic linking means that the run-time # linker needs to know where to locate the (dynamically linked) libraries. # This means when we are linking, for each -L option, we need to pass a # similar -R option. # Apparently some versions of Sun CC require a space after the -R, and # some no space, which seems incredibly dumb. I haven't bothered to check # for this yet though. echo $ac_n "checking whether we need -R""... $ac_c" 1>&6 echo "configure:2281: checking whether we need -R" >&5 case "`(uname -sr) 2>/dev/null`" in "SunOS 5"*) aw_need_r=yes echo "$ac_t""yes" 1>&6 ;; *) aw_need_r=no echo "$ac_t""no" 1>&6 ;; esac ######################################################################### # curses ######################################################################### # # Prefer "new" curses: ncurses. # # Examples: # bax and holst: /usr/include/ncurses/curses.h: # -I/usr/include/ncurses -L/usr/lib -L/usr/lib/ncurses -lncurses # gem: /gnu/include/ncurses.h: # -I/gnu/include -L/gnu/lib -lncurses # gem: /usr/include/curses.h: # -lcurses # # Possible include directories: /usr/include /gnu/include /usr/local/include # # One of these directories might include # ncurses/curses.h: -Iinc_dir/ncurses -Llib_dir -Llib_dir/ncurses -lncurses # ncurses.h: -Iinc_dir -Llib_dir -lcurses # curses.h: -Iinc_dir -Llib_dir -lcurses # # Everything set up already (eg in LIBS) is not an option as we want # this to apply only to ttyeden. # # Sets Example # CURSES_TYPE curses # CURSES_INCLUDE -I/usr/local/include # CURSES_LIB -lcurses # CURSES_LIB_PATH -L/usr/local/lib # HAVE_CURSES "" # # See if the user supplied some arguments # Check whether --with-curses-include or --without-curses-include was given. if test "${with_curses_include+set}" = set; then withval="$with_curses_include" aw_user_supplied_curses_include=$withval # Try and find this with the lib variable unset - the user # should really provide --with-curses-lib as well. # Three possible cases # ncurses/curses.h: -Iinc_dir/ncurses -Llib_dir -Llib_dir/ncurses -lncurses # ncurses.h: -Iinc_dir -Llib_dir -lcurses # curses.h: -Iinc_dir -Llib_dir -lcurses if test "$aw_need_r" = "yes"; then # We need the -R for runtime linking # Note this code is repeated below with -R taken away aw_curses_include_dir=$aw_user_supplied_curses_include aw_curses_header_look=ncurses/curses.h aw_curses_type=ncurses aw_curses_include=-I$aw_user_supplied_curses_include/ncurses aw_curses_lib_path="-L -L/ncurses -R -R/ncurses" if test -z "$aw_finished_curses"; then echo $ac_n "checking for ${aw_curses_include_dir}/${aw_curses_header_look}""... $ac_c" 1>&6 echo "configure:2354: checking for ${aw_curses_include_dir}/${aw_curses_header_look}" >&5 if test -f ${aw_curses_include_dir}/${aw_curses_header_look}; then echo "$ac_t""yes" 1>&6 # Temporarily add blurb to LIBS aw_save_libs=$LIBS LIBS="$aw_curses_include $aw_curses_lib_path -l${aw_curses_type} $LIBS" echo $ac_n "checking whether we can link curses using $LIBS""... $ac_c" 1>&6 echo "configure:2361: checking whether we can link curses using $LIBS" >&5 cat > conftest.$ac_ext < int main() { initscr() ; return 0; } EOF if { (eval echo configure:2370: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 aw_finished_curses="yes" CURSES_TYPE=$aw_curses_type CURSES_INCLUDE=$aw_curses_include CURSES_LIB_PATH=$aw_curses_lib_path CURSES_LIB=-l$aw_curses_type else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed. Do nothing (the search process will # just continue to another possible location). LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* else echo "$ac_t""no" 1>&6 fi fi aw_curses_include_dir=$aw_user_supplied_curses_include aw_curses_header_look=ncurses.h aw_curses_type=ncurses aw_curses_include=-I$aw_user_supplied_curses_include aw_curses_lib_path="-L -R" if test -z "$aw_finished_curses"; then echo $ac_n "checking for ${aw_curses_include_dir}/${aw_curses_header_look}""... $ac_c" 1>&6 echo "configure:2408: checking for ${aw_curses_include_dir}/${aw_curses_header_look}" >&5 if test -f ${aw_curses_include_dir}/${aw_curses_header_look}; then echo "$ac_t""yes" 1>&6 # Temporarily add blurb to LIBS aw_save_libs=$LIBS LIBS="$aw_curses_include $aw_curses_lib_path -l${aw_curses_type} $LIBS" echo $ac_n "checking whether we can link curses using $LIBS""... $ac_c" 1>&6 echo "configure:2415: checking whether we can link curses using $LIBS" >&5 cat > conftest.$ac_ext < int main() { initscr() ; return 0; } EOF if { (eval echo configure:2424: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 aw_finished_curses="yes" CURSES_TYPE=$aw_curses_type CURSES_INCLUDE=$aw_curses_include CURSES_LIB_PATH=$aw_curses_lib_path CURSES_LIB=-l$aw_curses_type else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed. Do nothing (the search process will # just continue to another possible location). LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* else echo "$ac_t""no" 1>&6 fi fi aw_curses_include_dir=$aw_user_supplied_curses_include aw_curses_header_look=curses.h aw_curses_type=curses aw_curses_include=-I$aw_user_supplied_curses_include aw_curses_lib_path="-L -R" if test -z "$aw_finished_curses"; then echo $ac_n "checking for ${aw_curses_include_dir}/${aw_curses_header_look}""... $ac_c" 1>&6 echo "configure:2462: checking for ${aw_curses_include_dir}/${aw_curses_header_look}" >&5 if test -f ${aw_curses_include_dir}/${aw_curses_header_look}; then echo "$ac_t""yes" 1>&6 # Temporarily add blurb to LIBS aw_save_libs=$LIBS LIBS="$aw_curses_include $aw_curses_lib_path -l${aw_curses_type} $LIBS" echo $ac_n "checking whether we can link curses using $LIBS""... $ac_c" 1>&6 echo "configure:2469: checking whether we can link curses using $LIBS" >&5 cat > conftest.$ac_ext < int main() { initscr() ; return 0; } EOF if { (eval echo configure:2478: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 aw_finished_curses="yes" CURSES_TYPE=$aw_curses_type CURSES_INCLUDE=$aw_curses_include CURSES_LIB_PATH=$aw_curses_lib_path CURSES_LIB=-l$aw_curses_type else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed. Do nothing (the search process will # just continue to another possible location). LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* else echo "$ac_t""no" 1>&6 fi fi else # We don't need the -R option # Note this code is repeated above with -R added aw_curses_include_dir=$aw_user_supplied_curses_include aw_curses_header_look=ncurses/curses.h aw_curses_type=ncurses aw_curses_include=-I$aw_user_supplied_curses_include/ncurses aw_curses_lib_path="-L -L/ncurses" if test -z "$aw_finished_curses"; then echo $ac_n "checking for ${aw_curses_include_dir}/${aw_curses_header_look}""... $ac_c" 1>&6 echo "configure:2519: checking for ${aw_curses_include_dir}/${aw_curses_header_look}" >&5 if test -f ${aw_curses_include_dir}/${aw_curses_header_look}; then echo "$ac_t""yes" 1>&6 # Temporarily add blurb to LIBS aw_save_libs=$LIBS LIBS="$aw_curses_include $aw_curses_lib_path -l${aw_curses_type} $LIBS" echo $ac_n "checking whether we can link curses using $LIBS""... $ac_c" 1>&6 echo "configure:2526: checking whether we can link curses using $LIBS" >&5 cat > conftest.$ac_ext < int main() { initscr() ; return 0; } EOF if { (eval echo configure:2535: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 aw_finished_curses="yes" CURSES_TYPE=$aw_curses_type CURSES_INCLUDE=$aw_curses_include CURSES_LIB_PATH=$aw_curses_lib_path CURSES_LIB=-l$aw_curses_type else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed. Do nothing (the search process will # just continue to another possible location). LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* else echo "$ac_t""no" 1>&6 fi fi aw_curses_include_dir=$aw_user_supplied_curses_include aw_curses_header_look=ncurses.h aw_curses_type=ncurses aw_curses_include=-I$aw_user_supplied_curses_include aw_curses_lib_path=-L if test -z "$aw_finished_curses"; then echo $ac_n "checking for ${aw_curses_include_dir}/${aw_curses_header_look}""... $ac_c" 1>&6 echo "configure:2573: checking for ${aw_curses_include_dir}/${aw_curses_header_look}" >&5 if test -f ${aw_curses_include_dir}/${aw_curses_header_look}; then echo "$ac_t""yes" 1>&6 # Temporarily add blurb to LIBS aw_save_libs=$LIBS LIBS="$aw_curses_include $aw_curses_lib_path -l${aw_curses_type} $LIBS" echo $ac_n "checking whether we can link curses using $LIBS""... $ac_c" 1>&6 echo "configure:2580: checking whether we can link curses using $LIBS" >&5 cat > conftest.$ac_ext < int main() { initscr() ; return 0; } EOF if { (eval echo configure:2589: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 aw_finished_curses="yes" CURSES_TYPE=$aw_curses_type CURSES_INCLUDE=$aw_curses_include CURSES_LIB_PATH=$aw_curses_lib_path CURSES_LIB=-l$aw_curses_type else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed. Do nothing (the search process will # just continue to another possible location). LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* else echo "$ac_t""no" 1>&6 fi fi aw_curses_include_dir=$aw_user_supplied_curses_include aw_curses_header_look=curses.h aw_curses_type=curses aw_curses_include=-I$aw_user_supplied_curses_include aw_curses_lib_path=-L if test -z "$aw_finished_curses"; then echo $ac_n "checking for ${aw_curses_include_dir}/${aw_curses_header_look}""... $ac_c" 1>&6 echo "configure:2627: checking for ${aw_curses_include_dir}/${aw_curses_header_look}" >&5 if test -f ${aw_curses_include_dir}/${aw_curses_header_look}; then echo "$ac_t""yes" 1>&6 # Temporarily add blurb to LIBS aw_save_libs=$LIBS LIBS="$aw_curses_include $aw_curses_lib_path -l${aw_curses_type} $LIBS" echo $ac_n "checking whether we can link curses using $LIBS""... $ac_c" 1>&6 echo "configure:2634: checking whether we can link curses using $LIBS" >&5 cat > conftest.$ac_ext < int main() { initscr() ; return 0; } EOF if { (eval echo configure:2643: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 aw_finished_curses="yes" CURSES_TYPE=$aw_curses_type CURSES_INCLUDE=$aw_curses_include CURSES_LIB_PATH=$aw_curses_lib_path CURSES_LIB=-l$aw_curses_type else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed. Do nothing (the search process will # just continue to another possible location). LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* else echo "$ac_t""no" 1>&6 fi fi fi fi # Check whether --with-curses-lib or --without-curses-lib was given. if test "${with_curses_lib+set}" = set; then withval="$with_curses_lib" aw_user_supplied_curses_lib_dir=$withval # Three possible cases # ncurses/curses.h: -Iinc_dir/ncurses -Llib_dir -Llib_dir/ncurses -lncurses # ncurses.h: -Iinc_dir -Llib_dir -lcurses # curses.h: -Iinc_dir -Llib_dir -lcurses if test "$aw_need_r" = "yes"; then # We need the -R for runtime linking # Note this code is repeated below with -R taken away aw_curses_include_dir=$aw_user_supplied_curses_include aw_curses_header_look=ncurses/curses.h aw_curses_type=ncurses aw_curses_include=-I$aw_user_supplied_curses_include/ncurses aw_curses_lib_path="-L$aw_user_supplied_curses_lib_dir -L$aw_user_supplied_curses_lib_dir/ncurses -R$aw_user_supplied_curses_lib_dir -R$aw_user_supplied_curses_lib_dir/ncurses" if test -z "$aw_finished_curses"; then echo $ac_n "checking for ${aw_curses_include_dir}/${aw_curses_header_look}""... $ac_c" 1>&6 echo "configure:2700: checking for ${aw_curses_include_dir}/${aw_curses_header_look}" >&5 if test -f ${aw_curses_include_dir}/${aw_curses_header_look}; then echo "$ac_t""yes" 1>&6 # Temporarily add blurb to LIBS aw_save_libs=$LIBS LIBS="$aw_curses_include $aw_curses_lib_path -l${aw_curses_type} $LIBS" echo $ac_n "checking whether we can link curses using $LIBS""... $ac_c" 1>&6 echo "configure:2707: checking whether we can link curses using $LIBS" >&5 cat > conftest.$ac_ext < int main() { initscr() ; return 0; } EOF if { (eval echo configure:2716: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 aw_finished_curses="yes" CURSES_TYPE=$aw_curses_type CURSES_INCLUDE=$aw_curses_include CURSES_LIB_PATH=$aw_curses_lib_path CURSES_LIB=-l$aw_curses_type else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed. Do nothing (the search process will # just continue to another possible location). LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* else echo "$ac_t""no" 1>&6 fi fi aw_curses_include_dir=$aw_user_supplied_curses_include aw_curses_header_look=ncurses.h aw_curses_type=ncurses aw_curses_include=-I$aw_user_supplied_curses_include aw_curses_lib_path="-L$aw_user_supplied_curses_lib_dir -R$aw_user_supplied_curses_lib_dir" if test -z "$aw_finished_curses"; then echo $ac_n "checking for ${aw_curses_include_dir}/${aw_curses_header_look}""... $ac_c" 1>&6 echo "configure:2754: checking for ${aw_curses_include_dir}/${aw_curses_header_look}" >&5 if test -f ${aw_curses_include_dir}/${aw_curses_header_look}; then echo "$ac_t""yes" 1>&6 # Temporarily add blurb to LIBS aw_save_libs=$LIBS LIBS="$aw_curses_include $aw_curses_lib_path -l${aw_curses_type} $LIBS" echo $ac_n "checking whether we can link curses using $LIBS""... $ac_c" 1>&6 echo "configure:2761: checking whether we can link curses using $LIBS" >&5 cat > conftest.$ac_ext < int main() { initscr() ; return 0; } EOF if { (eval echo configure:2770: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 aw_finished_curses="yes" CURSES_TYPE=$aw_curses_type CURSES_INCLUDE=$aw_curses_include CURSES_LIB_PATH=$aw_curses_lib_path CURSES_LIB=-l$aw_curses_type else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed. Do nothing (the search process will # just continue to another possible location). LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* else echo "$ac_t""no" 1>&6 fi fi aw_curses_include_dir=$aw_user_supplied_curses_include aw_curses_header_look=curses.h aw_curses_type=curses aw_curses_include=-I$aw_user_supplied_curses_include aw_curses_lib_path="-L$aw_user_supplied_curses_lib_dir -R$aw_user_supplied_curses_lib_dir" if test -z "$aw_finished_curses"; then echo $ac_n "checking for ${aw_curses_include_dir}/${aw_curses_header_look}""... $ac_c" 1>&6 echo "configure:2808: checking for ${aw_curses_include_dir}/${aw_curses_header_look}" >&5 if test -f ${aw_curses_include_dir}/${aw_curses_header_look}; then echo "$ac_t""yes" 1>&6 # Temporarily add blurb to LIBS aw_save_libs=$LIBS LIBS="$aw_curses_include $aw_curses_lib_path -l${aw_curses_type} $LIBS" echo $ac_n "checking whether we can link curses using $LIBS""... $ac_c" 1>&6 echo "configure:2815: checking whether we can link curses using $LIBS" >&5 cat > conftest.$ac_ext < int main() { initscr() ; return 0; } EOF if { (eval echo configure:2824: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 aw_finished_curses="yes" CURSES_TYPE=$aw_curses_type CURSES_INCLUDE=$aw_curses_include CURSES_LIB_PATH=$aw_curses_lib_path CURSES_LIB=-l$aw_curses_type else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed. Do nothing (the search process will # just continue to another possible location). LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* else echo "$ac_t""no" 1>&6 fi fi else # We don't need the -R option # Note this code is repeated above with -R added aw_curses_include_dir=$aw_user_supplied_curses_include aw_curses_header_look=ncurses/curses.h aw_curses_type=ncurses aw_curses_include=-I$aw_user_supplied_curses_include/ncurses aw_curses_lib_path="-L$aw_user_supplied_curses_lib_dir -L$aw_user_supplied_curses_lib_dir/ncurses" if test -z "$aw_finished_curses"; then echo $ac_n "checking for ${aw_curses_include_dir}/${aw_curses_header_look}""... $ac_c" 1>&6 echo "configure:2865: checking for ${aw_curses_include_dir}/${aw_curses_header_look}" >&5 if test -f ${aw_curses_include_dir}/${aw_curses_header_look}; then echo "$ac_t""yes" 1>&6 # Temporarily add blurb to LIBS aw_save_libs=$LIBS LIBS="$aw_curses_include $aw_curses_lib_path -l${aw_curses_type} $LIBS" echo $ac_n "checking whether we can link curses using $LIBS""... $ac_c" 1>&6 echo "configure:2872: checking whether we can link curses using $LIBS" >&5 cat > conftest.$ac_ext < int main() { initscr() ; return 0; } EOF if { (eval echo configure:2881: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 aw_finished_curses="yes" CURSES_TYPE=$aw_curses_type CURSES_INCLUDE=$aw_curses_include CURSES_LIB_PATH=$aw_curses_lib_path CURSES_LIB=-l$aw_curses_type else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed. Do nothing (the search process will # just continue to another possible location). LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* else echo "$ac_t""no" 1>&6 fi fi aw_curses_include_dir=$aw_user_supplied_curses_include aw_curses_header_look=ncurses.h aw_curses_type=ncurses aw_curses_include=-I$aw_user_supplied_curses_include aw_curses_lib_path=-L$aw_user_supplied_curses_lib_dir if test -z "$aw_finished_curses"; then echo $ac_n "checking for ${aw_curses_include_dir}/${aw_curses_header_look}""... $ac_c" 1>&6 echo "configure:2919: checking for ${aw_curses_include_dir}/${aw_curses_header_look}" >&5 if test -f ${aw_curses_include_dir}/${aw_curses_header_look}; then echo "$ac_t""yes" 1>&6 # Temporarily add blurb to LIBS aw_save_libs=$LIBS LIBS="$aw_curses_include $aw_curses_lib_path -l${aw_curses_type} $LIBS" echo $ac_n "checking whether we can link curses using $LIBS""... $ac_c" 1>&6 echo "configure:2926: checking whether we can link curses using $LIBS" >&5 cat > conftest.$ac_ext < int main() { initscr() ; return 0; } EOF if { (eval echo configure:2935: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 aw_finished_curses="yes" CURSES_TYPE=$aw_curses_type CURSES_INCLUDE=$aw_curses_include CURSES_LIB_PATH=$aw_curses_lib_path CURSES_LIB=-l$aw_curses_type else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed. Do nothing (the search process will # just continue to another possible location). LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* else echo "$ac_t""no" 1>&6 fi fi aw_curses_include_dir=$aw_user_supplied_curses_include aw_curses_header_look=curses.h aw_curses_type=curses aw_curses_include=-I$aw_user_supplied_curses_include aw_curses_lib_path=-L$aw_user_supplied_curses_lib_dir if test -z "$aw_finished_curses"; then echo $ac_n "checking for ${aw_curses_include_dir}/${aw_curses_header_look}""... $ac_c" 1>&6 echo "configure:2973: checking for ${aw_curses_include_dir}/${aw_curses_header_look}" >&5 if test -f ${aw_curses_include_dir}/${aw_curses_header_look}; then echo "$ac_t""yes" 1>&6 # Temporarily add blurb to LIBS aw_save_libs=$LIBS LIBS="$aw_curses_include $aw_curses_lib_path -l${aw_curses_type} $LIBS" echo $ac_n "checking whether we can link curses using $LIBS""... $ac_c" 1>&6 echo "configure:2980: checking whether we can link curses using $LIBS" >&5 cat > conftest.$ac_ext < int main() { initscr() ; return 0; } EOF if { (eval echo configure:2989: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 aw_finished_curses="yes" CURSES_TYPE=$aw_curses_type CURSES_INCLUDE=$aw_curses_include CURSES_LIB_PATH=$aw_curses_lib_path CURSES_LIB=-l$aw_curses_type else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed. Do nothing (the search process will # just continue to another possible location). LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* else echo "$ac_t""no" 1>&6 fi fi fi fi # Attempt to guess where it might be # Three possible cases # ncurses/curses.h: -Iinc_dir/ncurses -Llib_dir -Llib_dir/ncurses -lncurses # ncurses.h: -Iinc_dir -Llib_dir -lcurses # curses.h: -Iinc_dir -Llib_dir -lcurses if test "$aw_need_r" = "yes"; then # We need the -R for runtime linking # Note this code is repeated below with -R taken away aw_curses_include_dir=/usr/local/include aw_curses_header_look=ncurses/curses.h aw_curses_type=ncurses aw_curses_include=-I/usr/local/include/ncurses aw_curses_lib_path="-L/usr/local/lib -L/usr/local/lib/ncurses -R/usr/local/lib -R/usr/local/lib/ncurses" if test -z "$aw_finished_curses"; then echo $ac_n "checking for ${aw_curses_include_dir}/${aw_curses_header_look}""... $ac_c" 1>&6 echo "configure:3043: checking for ${aw_curses_include_dir}/${aw_curses_header_look}" >&5 if test -f ${aw_curses_include_dir}/${aw_curses_header_look}; then echo "$ac_t""yes" 1>&6 # Temporarily add blurb to LIBS aw_save_libs=$LIBS LIBS="$aw_curses_include $aw_curses_lib_path -l${aw_curses_type} $LIBS" echo $ac_n "checking whether we can link curses using $LIBS""... $ac_c" 1>&6 echo "configure:3050: checking whether we can link curses using $LIBS" >&5 cat > conftest.$ac_ext < int main() { initscr() ; return 0; } EOF if { (eval echo configure:3059: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 aw_finished_curses="yes" CURSES_TYPE=$aw_curses_type CURSES_INCLUDE=$aw_curses_include CURSES_LIB_PATH=$aw_curses_lib_path CURSES_LIB=-l$aw_curses_type else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed. Do nothing (the search process will # just continue to another possible location). LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* else echo "$ac_t""no" 1>&6 fi fi aw_curses_include_dir=/usr/local/include aw_curses_header_look=ncurses.h aw_curses_type=ncurses aw_curses_include=-I/usr/local/include aw_curses_lib_path="-L/usr/local/lib -R/usr/local/lib" if test -z "$aw_finished_curses"; then echo $ac_n "checking for ${aw_curses_include_dir}/${aw_curses_header_look}""... $ac_c" 1>&6 echo "configure:3097: checking for ${aw_curses_include_dir}/${aw_curses_header_look}" >&5 if test -f ${aw_curses_include_dir}/${aw_curses_header_look}; then echo "$ac_t""yes" 1>&6 # Temporarily add blurb to LIBS aw_save_libs=$LIBS LIBS="$aw_curses_include $aw_curses_lib_path -l${aw_curses_type} $LIBS" echo $ac_n "checking whether we can link curses using $LIBS""... $ac_c" 1>&6 echo "configure:3104: checking whether we can link curses using $LIBS" >&5 cat > conftest.$ac_ext < int main() { initscr() ; return 0; } EOF if { (eval echo configure:3113: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 aw_finished_curses="yes" CURSES_TYPE=$aw_curses_type CURSES_INCLUDE=$aw_curses_include CURSES_LIB_PATH=$aw_curses_lib_path CURSES_LIB=-l$aw_curses_type else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed. Do nothing (the search process will # just continue to another possible location). LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* else echo "$ac_t""no" 1>&6 fi fi aw_curses_include_dir=/usr/local/include aw_curses_header_look=curses.h aw_curses_type=curses aw_curses_include=-I/usr/local/include aw_curses_lib_path="-L/usr/local/lib -R/usr/local/lib" if test -z "$aw_finished_curses"; then echo $ac_n "checking for ${aw_curses_include_dir}/${aw_curses_header_look}""... $ac_c" 1>&6 echo "configure:3151: checking for ${aw_curses_include_dir}/${aw_curses_header_look}" >&5 if test -f ${aw_curses_include_dir}/${aw_curses_header_look}; then echo "$ac_t""yes" 1>&6 # Temporarily add blurb to LIBS aw_save_libs=$LIBS LIBS="$aw_curses_include $aw_curses_lib_path -l${aw_curses_type} $LIBS" echo $ac_n "checking whether we can link curses using $LIBS""... $ac_c" 1>&6 echo "configure:3158: checking whether we can link curses using $LIBS" >&5 cat > conftest.$ac_ext < int main() { initscr() ; return 0; } EOF if { (eval echo configure:3167: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 aw_finished_curses="yes" CURSES_TYPE=$aw_curses_type CURSES_INCLUDE=$aw_curses_include CURSES_LIB_PATH=$aw_curses_lib_path CURSES_LIB=-l$aw_curses_type else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed. Do nothing (the search process will # just continue to another possible location). LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* else echo "$ac_t""no" 1>&6 fi fi else # We don't need the -R option # Note this code is repeated above with -R added aw_curses_include_dir=/usr/local/include aw_curses_header_look=ncurses/curses.h aw_curses_type=ncurses aw_curses_include=-I/usr/local/include/ncurses aw_curses_lib_path="-L/usr/local/lib -L/usr/local/lib/ncurses" if test -z "$aw_finished_curses"; then echo $ac_n "checking for ${aw_curses_include_dir}/${aw_curses_header_look}""... $ac_c" 1>&6 echo "configure:3208: checking for ${aw_curses_include_dir}/${aw_curses_header_look}" >&5 if test -f ${aw_curses_include_dir}/${aw_curses_header_look}; then echo "$ac_t""yes" 1>&6 # Temporarily add blurb to LIBS aw_save_libs=$LIBS LIBS="$aw_curses_include $aw_curses_lib_path -l${aw_curses_type} $LIBS" echo $ac_n "checking whether we can link curses using $LIBS""... $ac_c" 1>&6 echo "configure:3215: checking whether we can link curses using $LIBS" >&5 cat > conftest.$ac_ext < int main() { initscr() ; return 0; } EOF if { (eval echo configure:3224: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 aw_finished_curses="yes" CURSES_TYPE=$aw_curses_type CURSES_INCLUDE=$aw_curses_include CURSES_LIB_PATH=$aw_curses_lib_path CURSES_LIB=-l$aw_curses_type else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed. Do nothing (the search process will # just continue to another possible location). LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* else echo "$ac_t""no" 1>&6 fi fi aw_curses_include_dir=/usr/local/include aw_curses_header_look=ncurses.h aw_curses_type=ncurses aw_curses_include=-I/usr/local/include aw_curses_lib_path=-L/usr/local/lib if test -z "$aw_finished_curses"; then echo $ac_n "checking for ${aw_curses_include_dir}/${aw_curses_header_look}""... $ac_c" 1>&6 echo "configure:3262: checking for ${aw_curses_include_dir}/${aw_curses_header_look}" >&5 if test -f ${aw_curses_include_dir}/${aw_curses_header_look}; then echo "$ac_t""yes" 1>&6 # Temporarily add blurb to LIBS aw_save_libs=$LIBS LIBS="$aw_curses_include $aw_curses_lib_path -l${aw_curses_type} $LIBS" echo $ac_n "checking whether we can link curses using $LIBS""... $ac_c" 1>&6 echo "configure:3269: checking whether we can link curses using $LIBS" >&5 cat > conftest.$ac_ext < int main() { initscr() ; return 0; } EOF if { (eval echo configure:3278: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 aw_finished_curses="yes" CURSES_TYPE=$aw_curses_type CURSES_INCLUDE=$aw_curses_include CURSES_LIB_PATH=$aw_curses_lib_path CURSES_LIB=-l$aw_curses_type else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed. Do nothing (the search process will # just continue to another possible location). LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* else echo "$ac_t""no" 1>&6 fi fi aw_curses_include_dir=/usr/local/include aw_curses_header_look=curses.h aw_curses_type=curses aw_curses_include=-I/usr/local/include aw_curses_lib_path=-L/usr/local/lib if test -z "$aw_finished_curses"; then echo $ac_n "checking for ${aw_curses_include_dir}/${aw_curses_header_look}""... $ac_c" 1>&6 echo "configure:3316: checking for ${aw_curses_include_dir}/${aw_curses_header_look}" >&5 if test -f ${aw_curses_include_dir}/${aw_curses_header_look}; then echo "$ac_t""yes" 1>&6 # Temporarily add blurb to LIBS aw_save_libs=$LIBS LIBS="$aw_curses_include $aw_curses_lib_path -l${aw_curses_type} $LIBS" echo $ac_n "checking whether we can link curses using $LIBS""... $ac_c" 1>&6 echo "configure:3323: checking whether we can link curses using $LIBS" >&5 cat > conftest.$ac_ext < int main() { initscr() ; return 0; } EOF if { (eval echo configure:3332: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 aw_finished_curses="yes" CURSES_TYPE=$aw_curses_type CURSES_INCLUDE=$aw_curses_include CURSES_LIB_PATH=$aw_curses_lib_path CURSES_LIB=-l$aw_curses_type else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed. Do nothing (the search process will # just continue to another possible location). LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* else echo "$ac_t""no" 1>&6 fi fi fi # Three possible cases # ncurses/curses.h: -Iinc_dir/ncurses -Llib_dir -Llib_dir/ncurses -lncurses # ncurses.h: -Iinc_dir -Llib_dir -lcurses # curses.h: -Iinc_dir -Llib_dir -lcurses if test "$aw_need_r" = "yes"; then # We need the -R for runtime linking # Note this code is repeated below with -R taken away aw_curses_include_dir=/gnu/include aw_curses_header_look=ncurses/curses.h aw_curses_type=ncurses aw_curses_include=-I/gnu/include/ncurses aw_curses_lib_path="-L/gnu/lib -L/gnu/lib/ncurses -R/gnu/lib -R/gnu/lib/ncurses" if test -z "$aw_finished_curses"; then echo $ac_n "checking for ${aw_curses_include_dir}/${aw_curses_header_look}""... $ac_c" 1>&6 echo "configure:3380: checking for ${aw_curses_include_dir}/${aw_curses_header_look}" >&5 if test -f ${aw_curses_include_dir}/${aw_curses_header_look}; then echo "$ac_t""yes" 1>&6 # Temporarily add blurb to LIBS aw_save_libs=$LIBS LIBS="$aw_curses_include $aw_curses_lib_path -l${aw_curses_type} $LIBS" echo $ac_n "checking whether we can link curses using $LIBS""... $ac_c" 1>&6 echo "configure:3387: checking whether we can link curses using $LIBS" >&5 cat > conftest.$ac_ext < int main() { initscr() ; return 0; } EOF if { (eval echo configure:3396: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 aw_finished_curses="yes" CURSES_TYPE=$aw_curses_type CURSES_INCLUDE=$aw_curses_include CURSES_LIB_PATH=$aw_curses_lib_path CURSES_LIB=-l$aw_curses_type else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed. Do nothing (the search process will # just continue to another possible location). LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* else echo "$ac_t""no" 1>&6 fi fi aw_curses_include_dir=/gnu/include aw_curses_header_look=ncurses.h aw_curses_type=ncurses aw_curses_include=-I/gnu/include aw_curses_lib_path="-L/gnu/lib -R/gnu/lib" if test -z "$aw_finished_curses"; then echo $ac_n "checking for ${aw_curses_include_dir}/${aw_curses_header_look}""... $ac_c" 1>&6 echo "configure:3434: checking for ${aw_curses_include_dir}/${aw_curses_header_look}" >&5 if test -f ${aw_curses_include_dir}/${aw_curses_header_look}; then echo "$ac_t""yes" 1>&6 # Temporarily add blurb to LIBS aw_save_libs=$LIBS LIBS="$aw_curses_include $aw_curses_lib_path -l${aw_curses_type} $LIBS" echo $ac_n "checking whether we can link curses using $LIBS""... $ac_c" 1>&6 echo "configure:3441: checking whether we can link curses using $LIBS" >&5 cat > conftest.$ac_ext < int main() { initscr() ; return 0; } EOF if { (eval echo configure:3450: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 aw_finished_curses="yes" CURSES_TYPE=$aw_curses_type CURSES_INCLUDE=$aw_curses_include CURSES_LIB_PATH=$aw_curses_lib_path CURSES_LIB=-l$aw_curses_type else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed. Do nothing (the search process will # just continue to another possible location). LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* else echo "$ac_t""no" 1>&6 fi fi aw_curses_include_dir=/gnu/include aw_curses_header_look=curses.h aw_curses_type=curses aw_curses_include=-I/gnu/include aw_curses_lib_path="-L/gnu/lib -R/gnu/lib" if test -z "$aw_finished_curses"; then echo $ac_n "checking for ${aw_curses_include_dir}/${aw_curses_header_look}""... $ac_c" 1>&6 echo "configure:3488: checking for ${aw_curses_include_dir}/${aw_curses_header_look}" >&5 if test -f ${aw_curses_include_dir}/${aw_curses_header_look}; then echo "$ac_t""yes" 1>&6 # Temporarily add blurb to LIBS aw_save_libs=$LIBS LIBS="$aw_curses_include $aw_curses_lib_path -l${aw_curses_type} $LIBS" echo $ac_n "checking whether we can link curses using $LIBS""... $ac_c" 1>&6 echo "configure:3495: checking whether we can link curses using $LIBS" >&5 cat > conftest.$ac_ext < int main() { initscr() ; return 0; } EOF if { (eval echo configure:3504: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 aw_finished_curses="yes" CURSES_TYPE=$aw_curses_type CURSES_INCLUDE=$aw_curses_include CURSES_LIB_PATH=$aw_curses_lib_path CURSES_LIB=-l$aw_curses_type else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed. Do nothing (the search process will # just continue to another possible location). LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* else echo "$ac_t""no" 1>&6 fi fi else # We don't need the -R option # Note this code is repeated above with -R added aw_curses_include_dir=/gnu/include aw_curses_header_look=ncurses/curses.h aw_curses_type=ncurses aw_curses_include=-I/gnu/include/ncurses aw_curses_lib_path="-L/gnu/lib -L/gnu/lib/ncurses" if test -z "$aw_finished_curses"; then echo $ac_n "checking for ${aw_curses_include_dir}/${aw_curses_header_look}""... $ac_c" 1>&6 echo "configure:3545: checking for ${aw_curses_include_dir}/${aw_curses_header_look}" >&5 if test -f ${aw_curses_include_dir}/${aw_curses_header_look}; then echo "$ac_t""yes" 1>&6 # Temporarily add blurb to LIBS aw_save_libs=$LIBS LIBS="$aw_curses_include $aw_curses_lib_path -l${aw_curses_type} $LIBS" echo $ac_n "checking whether we can link curses using $LIBS""... $ac_c" 1>&6 echo "configure:3552: checking whether we can link curses using $LIBS" >&5 cat > conftest.$ac_ext < int main() { initscr() ; return 0; } EOF if { (eval echo configure:3561: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 aw_finished_curses="yes" CURSES_TYPE=$aw_curses_type CURSES_INCLUDE=$aw_curses_include CURSES_LIB_PATH=$aw_curses_lib_path CURSES_LIB=-l$aw_curses_type else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed. Do nothing (the search process will # just continue to another possible location). LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* else echo "$ac_t""no" 1>&6 fi fi aw_curses_include_dir=/gnu/include aw_curses_header_look=ncurses.h aw_curses_type=ncurses aw_curses_include=-I/gnu/include aw_curses_lib_path=-L/gnu/lib if test -z "$aw_finished_curses"; then echo $ac_n "checking for ${aw_curses_include_dir}/${aw_curses_header_look}""... $ac_c" 1>&6 echo "configure:3599: checking for ${aw_curses_include_dir}/${aw_curses_header_look}" >&5 if test -f ${aw_curses_include_dir}/${aw_curses_header_look}; then echo "$ac_t""yes" 1>&6 # Temporarily add blurb to LIBS aw_save_libs=$LIBS LIBS="$aw_curses_include $aw_curses_lib_path -l${aw_curses_type} $LIBS" echo $ac_n "checking whether we can link curses using $LIBS""... $ac_c" 1>&6 echo "configure:3606: checking whether we can link curses using $LIBS" >&5 cat > conftest.$ac_ext < int main() { initscr() ; return 0; } EOF if { (eval echo configure:3615: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 aw_finished_curses="yes" CURSES_TYPE=$aw_curses_type CURSES_INCLUDE=$aw_curses_include CURSES_LIB_PATH=$aw_curses_lib_path CURSES_LIB=-l$aw_curses_type else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed. Do nothing (the search process will # just continue to another possible location). LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* else echo "$ac_t""no" 1>&6 fi fi aw_curses_include_dir=/gnu/include aw_curses_header_look=curses.h aw_curses_type=curses aw_curses_include=-I/gnu/include aw_curses_lib_path=-L/gnu/lib if test -z "$aw_finished_curses"; then echo $ac_n "checking for ${aw_curses_include_dir}/${aw_curses_header_look}""... $ac_c" 1>&6 echo "configure:3653: checking for ${aw_curses_include_dir}/${aw_curses_header_look}" >&5 if test -f ${aw_curses_include_dir}/${aw_curses_header_look}; then echo "$ac_t""yes" 1>&6 # Temporarily add blurb to LIBS aw_save_libs=$LIBS LIBS="$aw_curses_include $aw_curses_lib_path -l${aw_curses_type} $LIBS" echo $ac_n "checking whether we can link curses using $LIBS""... $ac_c" 1>&6 echo "configure:3660: checking whether we can link curses using $LIBS" >&5 cat > conftest.$ac_ext < int main() { initscr() ; return 0; } EOF if { (eval echo configure:3669: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 aw_finished_curses="yes" CURSES_TYPE=$aw_curses_type CURSES_INCLUDE=$aw_curses_include CURSES_LIB_PATH=$aw_curses_lib_path CURSES_LIB=-l$aw_curses_type else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed. Do nothing (the search process will # just continue to another possible location). LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* else echo "$ac_t""no" 1>&6 fi fi fi # Three possible cases # ncurses/curses.h: -Iinc_dir/ncurses -Llib_dir -Llib_dir/ncurses -lncurses # ncurses.h: -Iinc_dir -Llib_dir -lcurses # curses.h: -Iinc_dir -Llib_dir -lcurses if test "$aw_need_r" = "yes"; then # We need the -R for runtime linking # Note this code is repeated below with -R taken away aw_curses_include_dir=/usr/include aw_curses_header_look=ncurses/curses.h aw_curses_type=ncurses aw_curses_include=-I/usr/include/ncurses aw_curses_lib_path="-L/usr/lib -L/usr/lib/ncurses -R/usr/lib -R/usr/lib/ncurses" if test -z "$aw_finished_curses"; then echo $ac_n "checking for ${aw_curses_include_dir}/${aw_curses_header_look}""... $ac_c" 1>&6 echo "configure:3717: checking for ${aw_curses_include_dir}/${aw_curses_header_look}" >&5 if test -f ${aw_curses_include_dir}/${aw_curses_header_look}; then echo "$ac_t""yes" 1>&6 # Temporarily add blurb to LIBS aw_save_libs=$LIBS LIBS="$aw_curses_include $aw_curses_lib_path -l${aw_curses_type} $LIBS" echo $ac_n "checking whether we can link curses using $LIBS""... $ac_c" 1>&6 echo "configure:3724: checking whether we can link curses using $LIBS" >&5 cat > conftest.$ac_ext < int main() { initscr() ; return 0; } EOF if { (eval echo configure:3733: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 aw_finished_curses="yes" CURSES_TYPE=$aw_curses_type CURSES_INCLUDE=$aw_curses_include CURSES_LIB_PATH=$aw_curses_lib_path CURSES_LIB=-l$aw_curses_type else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed. Do nothing (the search process will # just continue to another possible location). LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* else echo "$ac_t""no" 1>&6 fi fi aw_curses_include_dir=/usr/include aw_curses_header_look=ncurses.h aw_curses_type=ncurses aw_curses_include=-I/usr/include aw_curses_lib_path="-L/usr/lib -R/usr/lib" if test -z "$aw_finished_curses"; then echo $ac_n "checking for ${aw_curses_include_dir}/${aw_curses_header_look}""... $ac_c" 1>&6 echo "configure:3771: checking for ${aw_curses_include_dir}/${aw_curses_header_look}" >&5 if test -f ${aw_curses_include_dir}/${aw_curses_header_look}; then echo "$ac_t""yes" 1>&6 # Temporarily add blurb to LIBS aw_save_libs=$LIBS LIBS="$aw_curses_include $aw_curses_lib_path -l${aw_curses_type} $LIBS" echo $ac_n "checking whether we can link curses using $LIBS""... $ac_c" 1>&6 echo "configure:3778: checking whether we can link curses using $LIBS" >&5 cat > conftest.$ac_ext < int main() { initscr() ; return 0; } EOF if { (eval echo configure:3787: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 aw_finished_curses="yes" CURSES_TYPE=$aw_curses_type CURSES_INCLUDE=$aw_curses_include CURSES_LIB_PATH=$aw_curses_lib_path CURSES_LIB=-l$aw_curses_type else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed. Do nothing (the search process will # just continue to another possible location). LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* else echo "$ac_t""no" 1>&6 fi fi aw_curses_include_dir=/usr/include aw_curses_header_look=curses.h aw_curses_type=curses aw_curses_include=-I/usr/include aw_curses_lib_path="-L/usr/lib -R/usr/lib" if test -z "$aw_finished_curses"; then echo $ac_n "checking for ${aw_curses_include_dir}/${aw_curses_header_look}""... $ac_c" 1>&6 echo "configure:3825: checking for ${aw_curses_include_dir}/${aw_curses_header_look}" >&5 if test -f ${aw_curses_include_dir}/${aw_curses_header_look}; then echo "$ac_t""yes" 1>&6 # Temporarily add blurb to LIBS aw_save_libs=$LIBS LIBS="$aw_curses_include $aw_curses_lib_path -l${aw_curses_type} $LIBS" echo $ac_n "checking whether we can link curses using $LIBS""... $ac_c" 1>&6 echo "configure:3832: checking whether we can link curses using $LIBS" >&5 cat > conftest.$ac_ext < int main() { initscr() ; return 0; } EOF if { (eval echo configure:3841: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 aw_finished_curses="yes" CURSES_TYPE=$aw_curses_type CURSES_INCLUDE=$aw_curses_include CURSES_LIB_PATH=$aw_curses_lib_path CURSES_LIB=-l$aw_curses_type else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed. Do nothing (the search process will # just continue to another possible location). LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* else echo "$ac_t""no" 1>&6 fi fi else # We don't need the -R option # Note this code is repeated above with -R added aw_curses_include_dir=/usr/include aw_curses_header_look=ncurses/curses.h aw_curses_type=ncurses aw_curses_include=-I/usr/include/ncurses aw_curses_lib_path="-L/usr/lib -L/usr/lib/ncurses" if test -z "$aw_finished_curses"; then echo $ac_n "checking for ${aw_curses_include_dir}/${aw_curses_header_look}""... $ac_c" 1>&6 echo "configure:3882: checking for ${aw_curses_include_dir}/${aw_curses_header_look}" >&5 if test -f ${aw_curses_include_dir}/${aw_curses_header_look}; then echo "$ac_t""yes" 1>&6 # Temporarily add blurb to LIBS aw_save_libs=$LIBS LIBS="$aw_curses_include $aw_curses_lib_path -l${aw_curses_type} $LIBS" echo $ac_n "checking whether we can link curses using $LIBS""... $ac_c" 1>&6 echo "configure:3889: checking whether we can link curses using $LIBS" >&5 cat > conftest.$ac_ext < int main() { initscr() ; return 0; } EOF if { (eval echo configure:3898: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 aw_finished_curses="yes" CURSES_TYPE=$aw_curses_type CURSES_INCLUDE=$aw_curses_include CURSES_LIB_PATH=$aw_curses_lib_path CURSES_LIB=-l$aw_curses_type else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed. Do nothing (the search process will # just continue to another possible location). LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* else echo "$ac_t""no" 1>&6 fi fi aw_curses_include_dir=/usr/include aw_curses_header_look=ncurses.h aw_curses_type=ncurses aw_curses_include=-I/usr/include aw_curses_lib_path=-L/usr/lib if test -z "$aw_finished_curses"; then echo $ac_n "checking for ${aw_curses_include_dir}/${aw_curses_header_look}""... $ac_c" 1>&6 echo "configure:3936: checking for ${aw_curses_include_dir}/${aw_curses_header_look}" >&5 if test -f ${aw_curses_include_dir}/${aw_curses_header_look}; then echo "$ac_t""yes" 1>&6 # Temporarily add blurb to LIBS aw_save_libs=$LIBS LIBS="$aw_curses_include $aw_curses_lib_path -l${aw_curses_type} $LIBS" echo $ac_n "checking whether we can link curses using $LIBS""... $ac_c" 1>&6 echo "configure:3943: checking whether we can link curses using $LIBS" >&5 cat > conftest.$ac_ext < int main() { initscr() ; return 0; } EOF if { (eval echo configure:3952: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 aw_finished_curses="yes" CURSES_TYPE=$aw_curses_type CURSES_INCLUDE=$aw_curses_include CURSES_LIB_PATH=$aw_curses_lib_path CURSES_LIB=-l$aw_curses_type else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed. Do nothing (the search process will # just continue to another possible location). LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* else echo "$ac_t""no" 1>&6 fi fi aw_curses_include_dir=/usr/include aw_curses_header_look=curses.h aw_curses_type=curses aw_curses_include=-I/usr/include aw_curses_lib_path=-L/usr/lib if test -z "$aw_finished_curses"; then echo $ac_n "checking for ${aw_curses_include_dir}/${aw_curses_header_look}""... $ac_c" 1>&6 echo "configure:3990: checking for ${aw_curses_include_dir}/${aw_curses_header_look}" >&5 if test -f ${aw_curses_include_dir}/${aw_curses_header_look}; then echo "$ac_t""yes" 1>&6 # Temporarily add blurb to LIBS aw_save_libs=$LIBS LIBS="$aw_curses_include $aw_curses_lib_path -l${aw_curses_type} $LIBS" echo $ac_n "checking whether we can link curses using $LIBS""... $ac_c" 1>&6 echo "configure:3997: checking whether we can link curses using $LIBS" >&5 cat > conftest.$ac_ext < int main() { initscr() ; return 0; } EOF if { (eval echo configure:4006: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 aw_finished_curses="yes" CURSES_TYPE=$aw_curses_type CURSES_INCLUDE=$aw_curses_include CURSES_LIB_PATH=$aw_curses_lib_path CURSES_LIB=-l$aw_curses_type else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed. Do nothing (the search process will # just continue to another possible location). LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* else echo "$ac_t""no" 1>&6 fi fi fi # Declare the type of curses found so that we can include the # appropriate header file, and include the curses object in the list # of objects to be built in the appropriate Makefiles if test "$CURSES_TYPE" = "ncurses"; then cat >> confdefs.h <<\EOF #define HAVE_NCURSES 1 EOF HAVE_CURSES="ncurses" elif test "$CURSES_TYPE" = "curses"; then cat >> confdefs.h <<\EOF #define HAVE_CURSES 1 EOF HAVE_CURSES="curses" else HAVE_CURSES="" fi # Print results echo $ac_n "checking for curses""... $ac_c" 1>&6 echo "configure:4060: checking for curses" >&5 echo "$ac_t""$CURSES_TYPE $CURSES_INCLUDE $CURSES_LIB $CURSES_LIB_PATH $CURSES_IF_ENABLED" 1>&6 ######################################################################### # tcl ######################################################################### # # Sets Example # TCL_INCLUDE -I/usr/local/include # TCL_LIB -L/usr/local/lib -ltcl # # Check whether --with-tcl-include or --without-tcl-include was given. if test "${with_tcl_include+set}" = set; then withval="$with_tcl_include" aw_user_tcl_include=$withval fi # Check whether --with-tcl-lib or --without-tcl-lib was given. if test "${with_tcl_lib+set}" = set; then withval="$with_tcl_lib" aw_user_tcl_lib=$withval fi # If the user provided both or either option, then try it first if test -n "$aw_user_tcl_include" -o -n "$aw_user_tcl_lib"; then aw_tcl_include=$aw_user_tcl_include aw_tcl_lib=$aw_user_tcl_lib if test "$aw_need_r" = "yes"; then # !@!@ This bit should really be an AC function # Note I need m4 [] quotes around this so that the brackets in the # sed expression do not get eaten aw_tcl_lib=`echo $aw_tcl_lib | sed 's/-L\([^ ]*\)/-L\1 -R\1/'` fi # If we haven't already found an answer... if test -z "$aw_finished_tcl"; then aw_save_libs=$LIBS LIBS="$aw_tcl_include $aw_tcl_lib $LIBS" echo $ac_n "checking whether we can link tcl using $LIBS""... $ac_c" 1>&6 echo "configure:4109: checking whether we can link tcl using $LIBS" >&5 cat > conftest.$ac_ext < int main() { Tcl_AsyncReady() ; return 0; } EOF if { (eval echo configure:4119: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded echo "$ac_t""yes" 1>&6 # Don't do any more tests - we have the answer aw_finished_tcl="yes" TCL_INCLUDE=$aw_tcl_include TCL_LIB=$aw_tcl_lib echo $ac_n "checking whether tcl has Tcl_EvalEx""... $ac_c" 1>&6 echo "configure:4129: checking whether tcl has Tcl_EvalEx" >&5 cat > conftest.$ac_ext < int main() { Tcl_Interp *interp; Tcl_EvalEx(interp, "", -1, 0) ; return 0; } EOF if { (eval echo configure:4141: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""yes" 1>&6 cat >> confdefs.h <<\EOF #define HAVE_TCL_EVALEX 1 EOF else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* echo "$ac_t""no" 1>&6 fi rm -f conftest* LIBS=$aw_save_libs else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed - do nothing. LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* fi fi # Else can we use tcl with just -ltcl? aw_tcl_include= aw_tcl_lib="-ltcl" if test "$aw_need_r" = "yes"; then # !@!@ This bit should really be an AC function # Note I need m4 [] quotes around this so that the brackets in the # sed expression do not get eaten aw_tcl_lib=`echo $aw_tcl_lib | sed 's/-L\([^ ]*\)/-L\1 -R\1/'` fi # If we haven't already found an answer... if test -z "$aw_finished_tcl"; then aw_save_libs=$LIBS LIBS="$aw_tcl_include $aw_tcl_lib $LIBS" echo $ac_n "checking whether we can link tcl using $LIBS""... $ac_c" 1>&6 echo "configure:4195: checking whether we can link tcl using $LIBS" >&5 cat > conftest.$ac_ext < int main() { Tcl_AsyncReady() ; return 0; } EOF if { (eval echo configure:4205: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded echo "$ac_t""yes" 1>&6 # Don't do any more tests - we have the answer aw_finished_tcl="yes" TCL_INCLUDE=$aw_tcl_include TCL_LIB=$aw_tcl_lib echo $ac_n "checking whether tcl has Tcl_EvalEx""... $ac_c" 1>&6 echo "configure:4215: checking whether tcl has Tcl_EvalEx" >&5 cat > conftest.$ac_ext < int main() { Tcl_Interp *interp; Tcl_EvalEx(interp, "", -1, 0) ; return 0; } EOF if { (eval echo configure:4227: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""yes" 1>&6 cat >> confdefs.h <<\EOF #define HAVE_TCL_EVALEX 1 EOF else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* echo "$ac_t""no" 1>&6 fi rm -f conftest* LIBS=$aw_save_libs else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed - do nothing. LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* fi # Now we're guessing... :) # This works at DCS, University of TV aw_tcl_include="-I/usr/local/include" aw_tcl_lib="-L/usr/local/lib -ltcl" if test "$aw_need_r" = "yes"; then # !@!@ This bit should really be an AC function # Note I need m4 [] quotes around this so that the brackets in the # sed expression do not get eaten aw_tcl_lib=`echo $aw_tcl_lib | sed 's/-L\([^ ]*\)/-L\1 -R\1/'` fi # If we haven't already found an answer... if test -z "$aw_finished_tcl"; then aw_save_libs=$LIBS LIBS="$aw_tcl_include $aw_tcl_lib $LIBS" echo $ac_n "checking whether we can link tcl using $LIBS""... $ac_c" 1>&6 echo "configure:4282: checking whether we can link tcl using $LIBS" >&5 cat > conftest.$ac_ext < int main() { Tcl_AsyncReady() ; return 0; } EOF if { (eval echo configure:4292: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded echo "$ac_t""yes" 1>&6 # Don't do any more tests - we have the answer aw_finished_tcl="yes" TCL_INCLUDE=$aw_tcl_include TCL_LIB=$aw_tcl_lib echo $ac_n "checking whether tcl has Tcl_EvalEx""... $ac_c" 1>&6 echo "configure:4302: checking whether tcl has Tcl_EvalEx" >&5 cat > conftest.$ac_ext < int main() { Tcl_Interp *interp; Tcl_EvalEx(interp, "", -1, 0) ; return 0; } EOF if { (eval echo configure:4314: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""yes" 1>&6 cat >> confdefs.h <<\EOF #define HAVE_TCL_EVALEX 1 EOF else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* echo "$ac_t""no" 1>&6 fi rm -f conftest* LIBS=$aw_save_libs else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed - do nothing. LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* fi # This works at ITS, University of TV aw_tcl_include= aw_tcl_lib="-L/usr/local/lib -ltcl8.0" if test "$aw_need_r" = "yes"; then # !@!@ This bit should really be an AC function # Note I need m4 [] quotes around this so that the brackets in the # sed expression do not get eaten aw_tcl_lib=`echo $aw_tcl_lib | sed 's/-L\([^ ]*\)/-L\1 -R\1/'` fi # If we haven't already found an answer... if test -z "$aw_finished_tcl"; then aw_save_libs=$LIBS LIBS="$aw_tcl_include $aw_tcl_lib $LIBS" echo $ac_n "checking whether we can link tcl using $LIBS""... $ac_c" 1>&6 echo "configure:4367: checking whether we can link tcl using $LIBS" >&5 cat > conftest.$ac_ext < int main() { Tcl_AsyncReady() ; return 0; } EOF if { (eval echo configure:4377: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded echo "$ac_t""yes" 1>&6 # Don't do any more tests - we have the answer aw_finished_tcl="yes" TCL_INCLUDE=$aw_tcl_include TCL_LIB=$aw_tcl_lib echo $ac_n "checking whether tcl has Tcl_EvalEx""... $ac_c" 1>&6 echo "configure:4387: checking whether tcl has Tcl_EvalEx" >&5 cat > conftest.$ac_ext < int main() { Tcl_Interp *interp; Tcl_EvalEx(interp, "", -1, 0) ; return 0; } EOF if { (eval echo configure:4399: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""yes" 1>&6 cat >> confdefs.h <<\EOF #define HAVE_TCL_EVALEX 1 EOF else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* echo "$ac_t""no" 1>&6 fi rm -f conftest* LIBS=$aw_save_libs else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed - do nothing. LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* fi # This works on ride, a Sparc Solaris 7 machine with packages # from sunfreeware.com aw_tcl_include= aw_tcl_lib="-L/usr/local/lib -ltcl" if test "$aw_need_r" = "yes"; then # !@!@ This bit should really be an AC function # Note I need m4 [] quotes around this so that the brackets in the # sed expression do not get eaten aw_tcl_lib=`echo $aw_tcl_lib | sed 's/-L\([^ ]*\)/-L\1 -R\1/'` fi # If we haven't already found an answer... if test -z "$aw_finished_tcl"; then aw_save_libs=$LIBS LIBS="$aw_tcl_include $aw_tcl_lib $LIBS" echo $ac_n "checking whether we can link tcl using $LIBS""... $ac_c" 1>&6 echo "configure:4453: checking whether we can link tcl using $LIBS" >&5 cat > conftest.$ac_ext < int main() { Tcl_AsyncReady() ; return 0; } EOF if { (eval echo configure:4463: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded echo "$ac_t""yes" 1>&6 # Don't do any more tests - we have the answer aw_finished_tcl="yes" TCL_INCLUDE=$aw_tcl_include TCL_LIB=$aw_tcl_lib echo $ac_n "checking whether tcl has Tcl_EvalEx""... $ac_c" 1>&6 echo "configure:4473: checking whether tcl has Tcl_EvalEx" >&5 cat > conftest.$ac_ext < int main() { Tcl_Interp *interp; Tcl_EvalEx(interp, "", -1, 0) ; return 0; } EOF if { (eval echo configure:4485: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* echo "$ac_t""yes" 1>&6 cat >> confdefs.h <<\EOF #define HAVE_TCL_EVALEX 1 EOF else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* echo "$ac_t""no" 1>&6 fi rm -f conftest* LIBS=$aw_save_libs else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed - do nothing. LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* fi # I give a warning if tcl is not found at the end of the script ######################################################################### # tk ######################################################################### # # Sets Example # TK_INCLUDE -I/usr/local/include # TK_LIB -L/usr/local/lib -ltk # # Check whether --with-tk-include or --without-tk-include was given. if test "${with_tk_include+set}" = set; then withval="$with_tk_include" aw_user_tk_include=$withval fi # Check whether --with-tk-lib or --without-tk-lib was given. if test "${with_tk_lib+set}" = set; then withval="$with_tk_lib" aw_user_tk_lib=$withval fi # If the user provided both or either option, then try it first if test -n "$aw_user_tk_include" -o -n "$aw_user_tk_lib"; then aw_tk_include=$aw_user_tk_include aw_tk_lib=$aw_user_tk_lib if test "$aw_need_r" = "yes"; then # Note I need m4 [] quotes around this so that the brackets in the # sed expression do not get eaten aw_tk_lib=`echo $aw_tk_lib | sed 's/-L\([^ ]*\)/-L\1 -R\1/'` fi # If we haven't already found an answer... if test -z "$aw_finished_tk"; then aw_save_libs=$LIBS # Also add X stuff and tcl stuff. Existing LIBS must go at the # end: -lm must come after -ltk for example. # NB don't seem to need $AW_X_LIBS and -lglPNG may cause an error LIBS="$aw_tk_include $aw_tk_lib $X_CFLAGS $X_PRE_LIBS $X_LIBS $X_EXTRA_LIBS $TCL_INCLUDE $TCL_LIB $LIBS" echo $ac_n "checking whether we can link tk using $LIBS""... $ac_c" 1>&6 echo "configure:4571: checking whether we can link tk using $LIBS" >&5 cat > conftest.$ac_ext < int main() { Tk_GetNumMainWindows(); ; return 0; } EOF if { (eval echo configure:4581: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 # Don't do any more tests - we have the answer aw_finished_tk="yes" TK_INCLUDE=$aw_tk_include TK_LIB=$aw_tk_lib else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed - do nothing. LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* fi fi # Else can we use tk with just -ltk? aw_tk_include= aw_tk_lib="-ltk" if test "$aw_need_r" = "yes"; then # Note I need m4 [] quotes around this so that the brackets in the # sed expression do not get eaten aw_tk_lib=`echo $aw_tk_lib | sed 's/-L\([^ ]*\)/-L\1 -R\1/'` fi # If we haven't already found an answer... if test -z "$aw_finished_tk"; then aw_save_libs=$LIBS # Also add X stuff and tcl stuff. Existing LIBS must go at the # end: -lm must come after -ltk for example. # NB don't seem to need $AW_X_LIBS and -lglPNG may cause an error LIBS="$aw_tk_include $aw_tk_lib $X_CFLAGS $X_PRE_LIBS $X_LIBS $X_EXTRA_LIBS $TCL_INCLUDE $TCL_LIB $LIBS" echo $ac_n "checking whether we can link tk using $LIBS""... $ac_c" 1>&6 echo "configure:4627: checking whether we can link tk using $LIBS" >&5 cat > conftest.$ac_ext < int main() { Tk_GetNumMainWindows(); ; return 0; } EOF if { (eval echo configure:4637: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 # Don't do any more tests - we have the answer aw_finished_tk="yes" TK_INCLUDE=$aw_tk_include TK_LIB=$aw_tk_lib else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed - do nothing. LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* fi # Now we're guessing... :) # This works at DCS, University of TV aw_tk_include="-I/usr/local/include" aw_tk_lib="-L/usr/local/lib -ltk" if test "$aw_need_r" = "yes"; then # Note I need m4 [] quotes around this so that the brackets in the # sed expression do not get eaten aw_tk_lib=`echo $aw_tk_lib | sed 's/-L\([^ ]*\)/-L\1 -R\1/'` fi # If we haven't already found an answer... if test -z "$aw_finished_tk"; then aw_save_libs=$LIBS # Also add X stuff and tcl stuff. Existing LIBS must go at the # end: -lm must come after -ltk for example. # NB don't seem to need $AW_X_LIBS and -lglPNG may cause an error LIBS="$aw_tk_include $aw_tk_lib $X_CFLAGS $X_PRE_LIBS $X_LIBS $X_EXTRA_LIBS $TCL_INCLUDE $TCL_LIB $LIBS" echo $ac_n "checking whether we can link tk using $LIBS""... $ac_c" 1>&6 echo "configure:4684: checking whether we can link tk using $LIBS" >&5 cat > conftest.$ac_ext < int main() { Tk_GetNumMainWindows(); ; return 0; } EOF if { (eval echo configure:4694: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 # Don't do any more tests - we have the answer aw_finished_tk="yes" TK_INCLUDE=$aw_tk_include TK_LIB=$aw_tk_lib else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed - do nothing. LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* fi # This works at ITS, University of TV aw_tk_include= aw_tk_lib="-L/usr/local/lib -ltk8.0" if test "$aw_need_r" = "yes"; then # Note I need m4 [] quotes around this so that the brackets in the # sed expression do not get eaten aw_tk_lib=`echo $aw_tk_lib | sed 's/-L\([^ ]*\)/-L\1 -R\1/'` fi # If we haven't already found an answer... if test -z "$aw_finished_tk"; then aw_save_libs=$LIBS # Also add X stuff and tcl stuff. Existing LIBS must go at the # end: -lm must come after -ltk for example. # NB don't seem to need $AW_X_LIBS and -lglPNG may cause an error LIBS="$aw_tk_include $aw_tk_lib $X_CFLAGS $X_PRE_LIBS $X_LIBS $X_EXTRA_LIBS $TCL_INCLUDE $TCL_LIB $LIBS" echo $ac_n "checking whether we can link tk using $LIBS""... $ac_c" 1>&6 echo "configure:4739: checking whether we can link tk using $LIBS" >&5 cat > conftest.$ac_ext < int main() { Tk_GetNumMainWindows(); ; return 0; } EOF if { (eval echo configure:4749: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 # Don't do any more tests - we have the answer aw_finished_tk="yes" TK_INCLUDE=$aw_tk_include TK_LIB=$aw_tk_lib else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed - do nothing. LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* fi # This works on ride, a Sparc Solaris 7 machine with packages from # sunfreeware.com aw_tk_include= aw_tk_lib="-L/usr/local/lib -ltk8.2" if test "$aw_need_r" = "yes"; then # Note I need m4 [] quotes around this so that the brackets in the # sed expression do not get eaten aw_tk_lib=`echo $aw_tk_lib | sed 's/-L\([^ ]*\)/-L\1 -R\1/'` fi # If we haven't already found an answer... if test -z "$aw_finished_tk"; then aw_save_libs=$LIBS # Also add X stuff and tcl stuff. Existing LIBS must go at the # end: -lm must come after -ltk for example. # NB don't seem to need $AW_X_LIBS and -lglPNG may cause an error LIBS="$aw_tk_include $aw_tk_lib $X_CFLAGS $X_PRE_LIBS $X_LIBS $X_EXTRA_LIBS $TCL_INCLUDE $TCL_LIB $LIBS" echo $ac_n "checking whether we can link tk using $LIBS""... $ac_c" 1>&6 echo "configure:4795: checking whether we can link tk using $LIBS" >&5 cat > conftest.$ac_ext < int main() { Tk_GetNumMainWindows(); ; return 0; } EOF if { (eval echo configure:4805: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 # Don't do any more tests - we have the answer aw_finished_tk="yes" TK_INCLUDE=$aw_tk_include TK_LIB=$aw_tk_lib else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed - do nothing. LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* fi # I give a warning if tk is not found at the end of the script ######################################################################### # Readline ######################################################################### # # Sets Example # READLINE_INCLUDE -I/gnu/include/readline # READLINE_LIB -L/gnu/lib -R/gnu/lib -lreadline # # Check whether --with-readline-include or --without-readline-include was given. if test "${with_readline_include+set}" = set; then withval="$with_readline_include" aw_user_readline_include=$withval fi # Check whether --with-readline-lib or --without-readline-lib was given. if test "${with_readline_lib+set}" = set; then withval="$with_readline_lib" aw_user_readline_lib=$withval fi # If the user provided both or either option, then try it first if test -n "$aw_user_readline_include" -o -n "$aw_user_readline_lib"; then aw_readline_include=$aw_user_readline_include aw_readline_lib=$aw_user_readline_lib if test "$aw_need_r" = "yes"; then # Note I need m4 [] quotes around this so that the brackets in the # sed expression do not get eaten aw_readline_lib=`echo $aw_readline_lib | sed 's/-L\([^ ]*\)/-L\1 -R\1/'` fi # If we haven't already found an answer... if test -z "$aw_finished_readline"; then aw_save_libs=$LIBS # Need curses as well as the supplied settings LIBS="$aw_readline_include $aw_readline_lib $CURSES_INCLUDE $CURSES_LIB_PATH $CURSES_LIB $LIBS" echo $ac_n "checking whether we can link readline using $LIBS""... $ac_c" 1>&6 echo "configure:4879: checking whether we can link readline using $LIBS" >&5 cat > conftest.$ac_ext < #include #include int main() { readline("test"); ; return 0; } EOF if { (eval echo configure:4893: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 # Don't do any more tests - we have the answer aw_finished_readline="yes" READLINE_INCLUDE=$aw_readline_include READLINE_LIB=$aw_readline_lib else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed - do nothing. LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* fi fi # Else can we use readline with just -lreadline? aw_readline_include= aw_readline_lib="-lreadline" if test "$aw_need_r" = "yes"; then # Note I need m4 [] quotes around this so that the brackets in the # sed expression do not get eaten aw_readline_lib=`echo $aw_readline_lib | sed 's/-L\([^ ]*\)/-L\1 -R\1/'` fi # If we haven't already found an answer... if test -z "$aw_finished_readline"; then aw_save_libs=$LIBS # Need curses as well as the supplied settings LIBS="$aw_readline_include $aw_readline_lib $CURSES_INCLUDE $CURSES_LIB_PATH $CURSES_LIB $LIBS" echo $ac_n "checking whether we can link readline using $LIBS""... $ac_c" 1>&6 echo "configure:4938: checking whether we can link readline using $LIBS" >&5 cat > conftest.$ac_ext < #include #include int main() { readline("test"); ; return 0; } EOF if { (eval echo configure:4952: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 # Don't do any more tests - we have the answer aw_finished_readline="yes" READLINE_INCLUDE=$aw_readline_include READLINE_LIB=$aw_readline_lib else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed - do nothing. LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* fi # Now we're guessing... :) # This works on cygwin aw_readline_include="-I/usr/include/readline" aw_readline_lib="-L/usr/lib -lreadline" if test "$aw_need_r" = "yes"; then # Note I need m4 [] quotes around this so that the brackets in the # sed expression do not get eaten aw_readline_lib=`echo $aw_readline_lib | sed 's/-L\([^ ]*\)/-L\1 -R\1/'` fi # If we haven't already found an answer... if test -z "$aw_finished_readline"; then aw_save_libs=$LIBS # Need curses as well as the supplied settings LIBS="$aw_readline_include $aw_readline_lib $CURSES_INCLUDE $CURSES_LIB_PATH $CURSES_LIB $LIBS" echo $ac_n "checking whether we can link readline using $LIBS""... $ac_c" 1>&6 echo "configure:4998: checking whether we can link readline using $LIBS" >&5 cat > conftest.$ac_ext < #include #include int main() { readline("test"); ; return 0; } EOF if { (eval echo configure:5012: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 # Don't do any more tests - we have the answer aw_finished_readline="yes" READLINE_INCLUDE=$aw_readline_include READLINE_LIB=$aw_readline_lib else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed - do nothing. LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* fi # This works at DCS, University of TV aw_readline_include="-I/gnu/include/readline -I/gnu/include" aw_readline_lib="-L/gnu/lib -R/gnu/lib -lreadline" if test "$aw_need_r" = "yes"; then # Note I need m4 [] quotes around this so that the brackets in the # sed expression do not get eaten aw_readline_lib=`echo $aw_readline_lib | sed 's/-L\([^ ]*\)/-L\1 -R\1/'` fi # If we haven't already found an answer... if test -z "$aw_finished_readline"; then aw_save_libs=$LIBS # Need curses as well as the supplied settings LIBS="$aw_readline_include $aw_readline_lib $CURSES_INCLUDE $CURSES_LIB_PATH $CURSES_LIB $LIBS" echo $ac_n "checking whether we can link readline using $LIBS""... $ac_c" 1>&6 echo "configure:5056: checking whether we can link readline using $LIBS" >&5 cat > conftest.$ac_ext < #include #include int main() { readline("test"); ; return 0; } EOF if { (eval echo configure:5070: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 # Don't do any more tests - we have the answer aw_finished_readline="yes" READLINE_INCLUDE=$aw_readline_include READLINE_LIB=$aw_readline_lib else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed - do nothing. LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* fi # This works on a newly installed Solaris 7 machine with standard GNU install aw_readline_include="-I/usr/local/include/readline" aw_readline_lib="-L/usr/local/lib -R/usr/local/lib -lreadline" if test "$aw_need_r" = "yes"; then # Note I need m4 [] quotes around this so that the brackets in the # sed expression do not get eaten aw_readline_lib=`echo $aw_readline_lib | sed 's/-L\([^ ]*\)/-L\1 -R\1/'` fi # If we haven't already found an answer... if test -z "$aw_finished_readline"; then aw_save_libs=$LIBS # Need curses as well as the supplied settings LIBS="$aw_readline_include $aw_readline_lib $CURSES_INCLUDE $CURSES_LIB_PATH $CURSES_LIB $LIBS" echo $ac_n "checking whether we can link readline using $LIBS""... $ac_c" 1>&6 echo "configure:5114: checking whether we can link readline using $LIBS" >&5 cat > conftest.$ac_ext < #include #include int main() { readline("test"); ; return 0; } EOF if { (eval echo configure:5128: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 # Don't do any more tests - we have the answer aw_finished_readline="yes" READLINE_INCLUDE=$aw_readline_include READLINE_LIB=$aw_readline_lib else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed - do nothing. LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* fi # If we found an answer, then we HAVE_READLINE if test -n "$aw_finished_readline"; then cat >> confdefs.h <<\EOF #define HAVE_READLINE 1 EOF fi ######################################################################### # OpenGL ######################################################################### # # Sets Example # OPENGL_INCLUDE -I/usr/openwin/include # OPENGL_LIB -L/usr/openwin/lib -R/usr/openwin/lib -lGL # Check whether --with-gl-include or --without-gl-include was given. if test "${with_gl_include+set}" = set; then withval="$with_gl_include" aw_user_gl_include=$withval fi # Check whether --with-gl-lib or --without-gl-lib was given. if test "${with_gl_lib+set}" = set; then withval="$with_gl_lib" aw_user_gl_lib=$withval fi if test "$aw_want_sasami" = "yes"; then # We want to build Sasami - so figure out OpenGL # If the user provided both or either option, then try it first if test -n "$aw_user_gl_include" -o -n "$aw_user_gl_lib"; then aw_gl_include=$aw_user_gl_include aw_gl_lib=$aw_user_gl_lib if test "$aw_need_r" = "yes"; then # Note I need m4 [] quotes around this so that the brackets in the # sed expression do not get eaten aw_gl_lib=`echo $aw_gl_lib | sed 's/-L\([^ ]*\)/-L\1 -R\1/'` fi # If we haven't already found an answer... if test -z "$aw_finished_gl"; then aw_save_libs=$LIBS LIBS="$aw_gl_include $aw_gl_lib" echo $ac_n "checking whether we can link GL using $LIBS""... $ac_c" 1>&6 echo "configure:5211: checking whether we can link GL using $LIBS" >&5 # !@!@ should put a test for the Solaris GL implementation in here, # because I can't get it to use the correct colormap on 8-bit GFX # hardware: the workaround is to use Mesa instead cat > conftest.$ac_ext < int main() { glLoadIdentity(); ; return 0; } EOF if { (eval echo configure:5226: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 # Don't do any more tests - we have the answer aw_finished_gl="yes" OPENGL_INCLUDE=$aw_gl_include OPENGL_LIB=$aw_gl_lib else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed - do nothing. LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* fi fi # Else can we use GL with just -lGL? aw_gl_include= aw_gl_lib="-lGL" if test "$aw_need_r" = "yes"; then # Note I need m4 [] quotes around this so that the brackets in the # sed expression do not get eaten aw_gl_lib=`echo $aw_gl_lib | sed 's/-L\([^ ]*\)/-L\1 -R\1/'` fi # If we haven't already found an answer... if test -z "$aw_finished_gl"; then aw_save_libs=$LIBS LIBS="$aw_gl_include $aw_gl_lib" echo $ac_n "checking whether we can link GL using $LIBS""... $ac_c" 1>&6 echo "configure:5270: checking whether we can link GL using $LIBS" >&5 # !@!@ should put a test for the Solaris GL implementation in here, # because I can't get it to use the correct colormap on 8-bit GFX # hardware: the workaround is to use Mesa instead cat > conftest.$ac_ext < int main() { glLoadIdentity(); ; return 0; } EOF if { (eval echo configure:5285: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 # Don't do any more tests - we have the answer aw_finished_gl="yes" OPENGL_INCLUDE=$aw_gl_include OPENGL_LIB=$aw_gl_lib else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed - do nothing. LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* fi else OPENGL_INCLUDE="" OPENGL_LIB="" fi ######################################################################### # PNG library ######################################################################### # # Sets Example # PNG_INCLUDE -I/usr/local/include # PNG_LIB -L/usr/local/lib -R/usr/local/lib -lpng # Check whether --with-png-include or --without-png-include was given. if test "${with_png_include+set}" = set; then withval="$with_png_include" aw_user_png_include=$withval fi # Check whether --with-png-lib or --without-png-lib was given. if test "${with_png_lib+set}" = set; then withval="$with_png_lib" aw_user_png_lib=$withval fi if test "$aw_want_sasami" = "yes"; then # We want to build Sasami - so figure out PNG # If the user provided both or either option, then try it first if test -n "$aw_user_png_include" -o -n "$aw_user_png_lib"; then aw_png_include=$aw_user_png_include aw_png_lib=$aw_user_png_lib if test "$aw_need_r" = "yes"; then # Note I need m4 [] quotes around this so that the brackets in the # sed expression do not get eaten aw_png_lib=`echo $aw_png_lib | sed 's/-L\([^ ]*\)/-L\1 -R\1/'` fi # If we haven't already found an answer... if test -z "$aw_finished_png"; then aw_save_libs=$LIBS # -lpng needs -lm LIBS="$aw_png_include $aw_png_lib -lm" echo $ac_n "checking whether we can link png using $LIBS""... $ac_c" 1>&6 echo "configure:5365: checking whether we can link png using $LIBS" >&5 cat > conftest.$ac_ext < int main() { png_structp png; png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); ; return 0; } EOF if { (eval echo configure:5380: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 # Don't do any more tests - we have the answer aw_finished_png="yes" PNG_INCLUDE=$aw_png_include PNG_LIB=$aw_png_lib else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed - do nothing. LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* fi fi # Else can we use PNG with just -lpng? aw_png_include= aw_png_lib="-lpng" if test "$aw_need_r" = "yes"; then # Note I need m4 [] quotes around this so that the brackets in the # sed expression do not get eaten aw_png_lib=`echo $aw_png_lib | sed 's/-L\([^ ]*\)/-L\1 -R\1/'` fi # If we haven't already found an answer... if test -z "$aw_finished_png"; then aw_save_libs=$LIBS # -lpng needs -lm LIBS="$aw_png_include $aw_png_lib -lm" echo $ac_n "checking whether we can link png using $LIBS""... $ac_c" 1>&6 echo "configure:5425: checking whether we can link png using $LIBS" >&5 cat > conftest.$ac_ext < int main() { png_structp png; png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); ; return 0; } EOF if { (eval echo configure:5440: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 # Don't do any more tests - we have the answer aw_finished_png="yes" PNG_INCLUDE=$aw_png_include PNG_LIB=$aw_png_lib else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed - do nothing. LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* fi # Try this... aw_png_include="-I/usr/local/include" aw_png_lib="-L/usr/local/lib -lpng" if test "$aw_need_r" = "yes"; then # Note I need m4 [] quotes around this so that the brackets in the # sed expression do not get eaten aw_png_lib=`echo $aw_png_lib | sed 's/-L\([^ ]*\)/-L\1 -R\1/'` fi # If we haven't already found an answer... if test -z "$aw_finished_png"; then aw_save_libs=$LIBS # -lpng needs -lm LIBS="$aw_png_include $aw_png_lib -lm" echo $ac_n "checking whether we can link png using $LIBS""... $ac_c" 1>&6 echo "configure:5484: checking whether we can link png using $LIBS" >&5 cat > conftest.$ac_ext < int main() { png_structp png; png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); ; return 0; } EOF if { (eval echo configure:5499: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* # Link succeeded LIBS=$aw_save_libs echo "$ac_t""yes" 1>&6 # Don't do any more tests - we have the answer aw_finished_png="yes" PNG_INCLUDE=$aw_png_include PNG_LIB=$aw_png_lib else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* # Link failed - do nothing. LIBS=$aw_save_libs echo "$ac_t""no" 1>&6 fi rm -f conftest* fi else PNG_INCLUDE="" PNG_LIB="" fi ######################################################################### # Memory alignment ######################################################################### # I could use the gcc __alignof__ function, but then this would # restrict us to using gcc only. So we attempt to detect the alignment # required instead. echo $ac_n "checking how doubles should be aligned""... $ac_c" 1>&6 echo "configure:5541: checking how doubles should be aligned" >&5 if test "$cross_compiling" = yes; then # We are cross compiling so can't run the test, so we # assume the worst. cat >> confdefs.h <<\EOF #define DOUBLE_ALIGNMENT sizeof(double) EOF echo "$ac_t""sizeof(double) byte boundaries" 1>&6 else cat > conftest.$ac_ext < struct foo { union align { double d; long l; void *p; } u; char c; }; int main() { struct foo f[2]; FILE *fp; int n; if ((fp = fopen("conftestalignoutput", "w")) == NULL) exit(1); if( 2*sizeof(union align) != sizeof(f) ) { n = fprintf(fp, "%ld\n", (long)(sizeof(struct foo) - sizeof(union align))); } else { n = fprintf(fp, "%ld\n", (long)sizeof(union align)); } /* If fprintf didn't complete successfully, exit code 1 */ if (n < 0) exit(1); if (fclose(fp) != 0) exit(1); /* All OK - exit code 0 */ exit(0); } EOF if { (eval echo configure:5593: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then # The code compiled, linked, executed and had exit code 0, # so we can read the alignment value written to the temporary # file. aw_alignment=`cat conftestalignoutput` cat >> confdefs.h <&6 else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -fr conftest* # The test failed in some way, so assume the worst. cat >> confdefs.h <<\EOF #define DOUBLE_ALIGNMENT sizeof(double) EOF echo "$ac_t""sizeof(double) byte boundaries" 1>&6 fi rm -fr conftest* fi ######################################################################### # dmalloc (tool for checking for memory leaks etc) ######################################################################### # I'm trusting the user to get this right, so no checks are done to see # if the arguments provided are correct. If they want to run it with a # memory debugger, they should know what they are doing... I hope. DMALLOC_INCLUDE= DMALLOC_LIB= # Check whether --with-dmalloc-include or --without-dmalloc-include was given. if test "${with_dmalloc_include+set}" = set; then withval="$with_dmalloc_include" cat >> confdefs.h <<\EOF #define HAVE_DMALLOC 1 EOF DMALLOC_INCLUDE=-I$withval fi # Check whether --with-dmalloc-lib or --without-dmalloc-lib was given. if test "${with_dmalloc_lib+set}" = set; then withval="$with_dmalloc_lib" cat >> confdefs.h <<\EOF #define HAVE_DMALLOC 1 EOF DMALLOC_LIB="-L$withval -ldmalloc" fi ######################################################################### # Other bits ######################################################################### # Do we have ANSI C header files? Declares STDC_HEADERS if we do. Also # (undocumented) sets $ac_cv_header_stdc to "yes". # Check other headers and stop if we can't find them # Might define HAVE_MALLOC_H ac_safe=`echo "malloc.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for malloc.h""... $ac_c" 1>&6 echo "configure:5672: checking for malloc.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:5682: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 : else echo "$ac_t""no" 1>&6 { echo "configure: error: can't find malloc.h" 1>&2; exit 1; } fi # Might define HAVE_SYS_TIME_H ac_safe=`echo "sys/time.h" | sed 'y%./+-%__p_%'` echo $ac_n "checking for sys/time.h""... $ac_c" 1>&6 echo "configure:5707: checking for sys/time.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:5717: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 : else echo "$ac_t""no" 1>&6 { echo "configure: error: can't find sys/time.h" 1>&2; exit 1; } fi # Define const to be empty if the compiler does not support it echo $ac_n "checking for working const""... $ac_c" 1>&6 echo "configure:5742: checking for working const" >&5 if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; } ; return 0; } EOF if { (eval echo configure:5796: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_const=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_c_const=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_c_const" 1>&6 if test $ac_cv_c_const = no; then cat >> confdefs.h <<\EOF #define const EOF fi # Deal with problems due to two header files time.h and sys/time.h # Might define TIME_WITH_SYS_TIME echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6 echo "configure:5820: checking whether time.h and sys/time.h may both be included" >&5 if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include #include int main() { struct tm *tp; ; return 0; } EOF if { (eval echo configure:5834: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_header_time=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_header_time=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_header_time" 1>&6 if test $ac_cv_header_time = yes; then cat >> confdefs.h <<\EOF #define TIME_WITH_SYS_TIME 1 EOF fi # Might define TM_IN_SYS_TIME, "which means that including sys/time.h # had better define struct tm." (from Autoconf manual - huh?). echo $ac_n "checking whether struct tm is in sys/time.h or time.h""... $ac_c" 1>&6 echo "configure:5858: checking whether struct tm is in sys/time.h or time.h" >&5 if eval "test \"`echo '$''{'ac_cv_struct_tm'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include int main() { struct tm *tp; tp->tm_sec; ; return 0; } EOF if { (eval echo configure:5871: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_struct_tm=time.h else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_struct_tm=sys/time.h fi rm -f conftest* fi echo "$ac_t""$ac_cv_struct_tm" 1>&6 if test $ac_cv_struct_tm = sys/time.h; then cat >> confdefs.h <<\EOF #define TM_IN_SYS_TIME 1 EOF fi # Check for how to get alloca. Might defined HAVE_ALLOCA_H, HAVE_ALLOCA, # ALLOCA, C_ALLOCA... # The Ultrix 4.2 mips builtin alloca declared by alloca.h only works # for constant arguments. Useless! echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6 echo "configure:5897: checking for working alloca.h" >&5 if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < int main() { char *p = alloca(2 * sizeof(int)); ; return 0; } EOF if { (eval echo configure:5909: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_header_alloca_h=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_header_alloca_h=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_header_alloca_h" 1>&6 if test $ac_cv_header_alloca_h = yes; then cat >> confdefs.h <<\EOF #define HAVE_ALLOCA_H 1 EOF fi echo $ac_n "checking for alloca""... $ac_c" 1>&6 echo "configure:5930: checking for alloca" >&5 if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < # define alloca _alloca # else # if HAVE_ALLOCA_H # include # else # ifdef _AIX #pragma alloca # else # ifndef alloca /* predefined by HP cc +Olibcalls */ char *alloca (); # endif # endif # endif # endif #endif int main() { char *p = (char *) alloca(1); ; return 0; } EOF if { (eval echo configure:5963: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* ac_cv_func_alloca_works=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_func_alloca_works=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_func_alloca_works" 1>&6 if test $ac_cv_func_alloca_works = yes; then cat >> confdefs.h <<\EOF #define HAVE_ALLOCA 1 EOF fi if test $ac_cv_func_alloca_works = no; then # The SVR3 libPW and SVR4 libucb both contain incompatible functions # that cause trouble. Some versions do not even contain alloca or # contain a buggy version. If you still want to use their alloca, # use ar to extract alloca.o from them instead of compiling alloca.c. ALLOCA=alloca.${ac_objext} cat >> confdefs.h <<\EOF #define C_ALLOCA 1 EOF echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6 echo "configure:5995: checking whether alloca needs Cray hooks" >&5 if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <&5 | egrep "webecray" >/dev/null 2>&1; then rm -rf conftest* ac_cv_os_cray=yes else rm -rf conftest* ac_cv_os_cray=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_os_cray" 1>&6 if test $ac_cv_os_cray = yes; then for ac_func in _getb67 GETB67 getb67; do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:6025: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else $ac_func(); #endif ; return 0; } EOF if { (eval echo configure:6053: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 cat >> confdefs.h <&6 fi done fi echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6 echo "configure:6080: checking stack direction for C alloca" >&5 if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test "$cross_compiling" = yes; then ac_cv_c_stack_direction=0 else cat > conftest.$ac_ext < addr) ? 1 : -1; } main () { exit (find_stack_direction() < 0); } EOF if { (eval echo configure:6107: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_c_stack_direction=1 else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -fr conftest* ac_cv_c_stack_direction=-1 fi rm -fr conftest* fi fi echo "$ac_t""$ac_cv_c_stack_direction" 1>&6 cat >> confdefs.h <&6 echo "configure:6131: checking return type of signal handlers" >&5 if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include #ifdef signal #undef signal #endif #ifdef __cplusplus extern "C" void (*signal (int, void (*)(int)))(int); #else void (*signal ()) (); #endif int main() { int i; ; return 0; } EOF if { (eval echo configure:6153: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_type_signal=void else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_type_signal=int fi rm -f conftest* fi echo "$ac_t""$ac_cv_type_signal" 1>&6 cat >> confdefs.h <&6 echo "configure:6174: checking for gettimeofday" >&5 if eval "test \"`echo '$''{'ac_cv_func_gettimeofday'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char gettimeofday(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_gettimeofday) || defined (__stub___gettimeofday) choke me #else gettimeofday(); #endif ; return 0; } EOF if { (eval echo configure:6202: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_gettimeofday=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_gettimeofday=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'gettimeofday`\" = yes"; then echo "$ac_t""yes" 1>&6 : else echo "$ac_t""no" 1>&6 { echo "configure: error: don't have gettimeofday" 1>&2; exit 1; } fi echo $ac_n "checking for putenv""... $ac_c" 1>&6 echo "configure:6223: checking for putenv" >&5 if eval "test \"`echo '$''{'ac_cv_func_putenv'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char putenv(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_putenv) || defined (__stub___putenv) choke me #else putenv(); #endif ; return 0; } EOF if { (eval echo configure:6251: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_putenv=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_putenv=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'putenv`\" = yes"; then echo "$ac_t""yes" 1>&6 : else echo "$ac_t""no" 1>&6 { echo "configure: error: don't have putenv" 1>&2; exit 1; } fi echo $ac_n "checking for select""... $ac_c" 1>&6 echo "configure:6272: checking for select" >&5 if eval "test \"`echo '$''{'ac_cv_func_select'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char select(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_select) || defined (__stub___select) choke me #else select(); #endif ; return 0; } EOF if { (eval echo configure:6300: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_select=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_select=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'select`\" = yes"; then echo "$ac_t""yes" 1>&6 : else echo "$ac_t""no" 1>&6 { echo "configure: error: don't have select" 1>&2; exit 1; } fi echo $ac_n "checking for strdup""... $ac_c" 1>&6 echo "configure:6321: checking for strdup" >&5 if eval "test \"`echo '$''{'ac_cv_func_strdup'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char strdup(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_strdup) || defined (__stub___strdup) choke me #else strdup(); #endif ; return 0; } EOF if { (eval echo configure:6349: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_strdup=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_strdup=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'strdup`\" = yes"; then echo "$ac_t""yes" 1>&6 : else echo "$ac_t""no" 1>&6 { echo "configure: error: don't have strdup" 1>&2; exit 1; } fi ######################################################################### # Create the Makefiles ######################################################################### # Substitute the following variables in the Makefiles # Done - write the output Makefiles trap '' 1 2 15 cat > confcache <<\EOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs. It is not useful on other systems. # If it contains results you don't want to keep, you may remove or edit it. # # By default, configure uses ./config.cache as the cache file, # creating it if it does not exist already. You can give configure # the --cache-file=FILE option to use a different cache file; that is # what configure does when it calls configure scripts in # subdirectories, so they share the cache. # Giving --cache-file=/dev/null disables caching, for debugging configure. # config.status only pays attention to the cache file if you give it the # --recheck option to rerun configure. # EOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, don't put newlines in cache variables' values. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. (set) 2>&1 | case `(ac_space=' '; set | grep ac_space) 2>&1` in *ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote substitution # turns \\\\ into \\, and sed turns \\ into \). sed -n \ -e "s/'/'\\\\''/g" \ -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" ;; *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' ;; esac >> confcache if cmp -s $cache_file confcache; then : else if test -w $cache_file; then echo "updating cache $cache_file" cat confcache > $cache_file else echo "not updating unwritable cache $cache_file" fi fi rm -f confcache trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' # Any assignment to VPATH causes Sun make to only execute # the first set of double-colon rules, so remove it if not needed. # If there is a colon in the path, we need to keep it. if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' fi trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 DEFS=-DHAVE_CONFIG_H # Without the "./", some shells look in PATH for config.status. : ${CONFIG_STATUS=./config.status} echo creating $CONFIG_STATUS rm -f $CONFIG_STATUS cat > $CONFIG_STATUS </dev/null | sed 1q`: # # $0 $ac_configure_args # # Compiler output produced by configure, useful for debugging # configure, is in ./config.log if it exists. ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" for ac_option do case "\$ac_option" in -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; -version | --version | --versio | --versi | --vers | --ver | --ve | --v) echo "$CONFIG_STATUS generated by autoconf version 2.13" exit 0 ;; -help | --help | --hel | --he | --h) echo "\$ac_cs_usage"; exit 0 ;; *) echo "\$ac_cs_usage"; exit 1 ;; esac done ac_given_srcdir=$srcdir ac_given_INSTALL="$INSTALL" trap 'rm -fr `echo "generic.mk Misc/Makefile Eden/Makefile EX/Makefile Scout/Makefile Makefile Donald/Makefile LSD/Makefile Sasami/Makefile config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 EOF cat >> $CONFIG_STATUS < conftest.subs <<\\CEOF $ac_vpsub $extrasub s%@SHELL@%$SHELL%g s%@CFLAGS@%$CFLAGS%g s%@CPPFLAGS@%$CPPFLAGS%g s%@CXXFLAGS@%$CXXFLAGS%g s%@FFLAGS@%$FFLAGS%g s%@DEFS@%$DEFS%g s%@LDFLAGS@%$LDFLAGS%g s%@LIBS@%$LIBS%g s%@exec_prefix@%$exec_prefix%g s%@prefix@%$prefix%g s%@program_transform_name@%$program_transform_name%g s%@bindir@%$bindir%g s%@sbindir@%$sbindir%g s%@libexecdir@%$libexecdir%g s%@datadir@%$datadir%g s%@sysconfdir@%$sysconfdir%g s%@sharedstatedir@%$sharedstatedir%g s%@localstatedir@%$localstatedir%g s%@libdir@%$libdir%g s%@includedir@%$includedir%g s%@oldincludedir@%$oldincludedir%g s%@infodir@%$infodir%g s%@mandir@%$mandir%g s%@host@%$host%g s%@host_alias@%$host_alias%g s%@host_cpu@%$host_cpu%g s%@host_vendor@%$host_vendor%g s%@host_os@%$host_os%g s%@CC@%$CC%g s%@CPP@%$CPP%g s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g s%@INSTALL_DATA@%$INSTALL_DATA%g s%@LEX@%$LEX%g s%@LEXLIB@%$LEXLIB%g s%@SET_MAKE@%$SET_MAKE%g s%@RANLIB@%$RANLIB%g s%@X_CFLAGS@%$X_CFLAGS%g s%@X_PRE_LIBS@%$X_PRE_LIBS%g s%@X_LIBS@%$X_LIBS%g s%@X_EXTRA_LIBS@%$X_EXTRA_LIBS%g s%@ALLOCA@%$ALLOCA%g s%@AW_X_LIBS@%$AW_X_LIBS%g s%@CURSES_TYPE@%$CURSES_TYPE%g s%@CURSES_INCLUDE@%$CURSES_INCLUDE%g s%@CURSES_LIB@%$CURSES_LIB%g s%@CURSES_LIB_PATH@%$CURSES_LIB_PATH%g s%@TCL_INCLUDE@%$TCL_INCLUDE%g s%@TCL_LIB@%$TCL_LIB%g s%@TK_INCLUDE@%$TK_INCLUDE%g s%@TK_LIB@%$TK_LIB%g s%@DMALLOC_INCLUDE@%$DMALLOC_INCLUDE%g s%@DMALLOC_LIB@%$DMALLOC_LIB%g s%@READLINE_INCLUDE@%$READLINE_INCLUDE%g s%@READLINE_LIB@%$READLINE_LIB%g s%@OPENGL_INCLUDE@%$OPENGL_INCLUDE%g s%@OPENGL_LIB@%$OPENGL_LIB%g s%@PNG_INCLUDE@%$PNG_INCLUDE%g s%@PNG_LIB@%$PNG_LIB%g s%@DEPEND_MAKEDEFS@%$DEPEND_MAKEDEFS%g CEOF EOF cat >> $CONFIG_STATUS <<\EOF # Split the substitutions into bite-sized pieces for seds with # small command number limits, like on Digital OSF/1 and HP-UX. ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. ac_file=1 # Number of current file. ac_beg=1 # First line for current file. ac_end=$ac_max_sed_cmds # Line after last line for current file. ac_more_lines=: ac_sed_cmds="" while $ac_more_lines; do if test $ac_beg -gt 1; then sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file else sed "${ac_end}q" conftest.subs > conftest.s$ac_file fi if test ! -s conftest.s$ac_file; then ac_more_lines=false rm -f conftest.s$ac_file else if test -z "$ac_sed_cmds"; then ac_sed_cmds="sed -f conftest.s$ac_file" else ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" fi ac_file=`expr $ac_file + 1` ac_beg=$ac_end ac_end=`expr $ac_end + $ac_max_sed_cmds` fi done if test -z "$ac_sed_cmds"; then ac_sed_cmds=cat fi EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case "$ac_file" in *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; *) ac_file_in="${ac_file}.in" ;; esac # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. # Remove last slash and all that follows it. Not all systems have dirname. ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then # The file is in a subdirectory. test ! -d "$ac_dir" && mkdir "$ac_dir" ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" # A "../" for each directory in $ac_dir_suffix. ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` else ac_dir_suffix= ac_dots= fi case "$ac_given_srcdir" in .) srcdir=. if test -z "$ac_dots"; then top_srcdir=. else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; *) # Relative path. srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" top_srcdir="$ac_dots$ac_given_srcdir" ;; esac case "$ac_given_INSTALL" in [/$]*) INSTALL="$ac_given_INSTALL" ;; *) INSTALL="$ac_dots$ac_given_INSTALL" ;; esac echo creating "$ac_file" rm -f "$ac_file" configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." case "$ac_file" in *Makefile*) ac_comsub="1i\\ # $configure_input" ;; *) ac_comsub= ;; esac ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` sed -e "$ac_comsub s%@configure_input@%$configure_input%g s%@srcdir@%$srcdir%g s%@top_srcdir@%$top_srcdir%g s%@INSTALL@%$INSTALL%g " $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file fi; done rm -f conftest.s* # These sed commands are passed to sed as "A NAME B NAME C VALUE D", where # NAME is the cpp macro being defined and VALUE is the value it is being given. # # ac_d sets the value in "#define NAME VALUE" lines. ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)' ac_dB='\([ ][ ]*\)[^ ]*%\1#\2' ac_dC='\3' ac_dD='%g' # ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE". ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' ac_uB='\([ ]\)%\1#\2define\3' ac_uC=' ' ac_uD='\4%g' # ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE". ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' ac_eB='$%\1#\2define\3' ac_eC=' ' ac_eD='%g' if test "${CONFIG_HEADERS+set}" != set; then EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF fi for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case "$ac_file" in *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; *) ac_file_in="${ac_file}.in" ;; esac echo creating $ac_file rm -f conftest.frag conftest.in conftest.out ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` cat $ac_file_inputs > conftest.in EOF # Transform confdefs.h into a sed script conftest.vals that substitutes # the proper values into config.h.in to produce config.h. And first: # Protect against being on the right side of a sed subst in config.status. # Protect against being in an unquoted here document in config.status. rm -f conftest.vals cat > conftest.hdr <<\EOF s/[\\&%]/\\&/g s%[\\$`]%\\&%g s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp s%ac_d%ac_u%gp s%ac_u%ac_e%gp EOF sed -n -f conftest.hdr confdefs.h > conftest.vals rm -f conftest.hdr # This sed command replaces #undef with comments. This is necessary, for # example, in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. cat >> conftest.vals <<\EOF s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */% EOF # Break up conftest.vals because some shells have a limit on # the size of here documents, and old seds have small limits too. rm -f conftest.tail while : do ac_lines=`grep -c . conftest.vals` # grep -c gives empty output for an empty file on some AIX systems. if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi # Write a limited-size here document to conftest.frag. echo ' cat > conftest.frag <> $CONFIG_STATUS sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS echo 'CEOF sed -f conftest.frag conftest.in > conftest.out rm -f conftest.in mv conftest.out conftest.in ' >> $CONFIG_STATUS sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail rm -f conftest.vals mv conftest.tail conftest.vals done rm -f conftest.vals cat >> $CONFIG_STATUS <<\EOF rm -f conftest.frag conftest.h echo "/* $ac_file. Generated automatically by configure. */" > conftest.h cat conftest.in >> conftest.h rm -f conftest.in if cmp -s $ac_file conftest.h 2>/dev/null; then echo "$ac_file is unchanged" rm -f conftest.h else # Remove last slash and all that follows it. Not all systems have dirname. ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then # The file is in a subdirectory. test ! -d "$ac_dir" && mkdir "$ac_dir" fi rm -f $ac_file mv conftest.h $ac_file fi fi; done EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF exit 0 EOF chmod +x $CONFIG_STATUS rm -fr confdefs* $ac_clean_files test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 # Give warnings if test -z "$aw_want_sasami"; then echo "configure: warning: Cannot build Sasami - only possible on Windoz presently" 1>&2 fi if test -z "$aw_finished_tcl"; then echo "configure: warning: Could not locate tcl - can probably only build ttyeden" 1>&2 fi if test -z "$aw_finished_tk"; then echo "configure: warning: Could not locate tk - can probably only build ttyeden" 1>&2 fi if test -z "$aw_finished_readline"; then echo "configure: warning: Could not locate readline - ttyeden will not have line editing" 1>&2 fi if test -z "$HAVE_CURSES"; then echo "configure: warning: Could not locate curses - probably cannot build ttyeden" 1>&2 fi if test -z "$aw_finished_gl"; then echo "configure: warning: Could not locate GL - probably cannot build Sasami" 1>&2 fi if test -z "$aw_finished_png"; then echo "configure: warning: Could not locate PNG - probably cannot build Sasami" 1>&2 fi echo "configure: warning: Type 'make' for further instructions" 1>&2 utoconf version 2.13" exit 0 ;; -help | --help | --hel | --he | --h) echo "\$ac_cs_usage"; exit 0 ;; *) echo "\$ac_cs_usage"; exit 1 ;; esac done ac_given_srcdir=$srcdir ac_given_INSTALL="$INSTALL" trap 'rm -fr `echo "generic.mk Misc/Makefile Eden/Makefile EX/Makefile Scout/Makefile Makefile Donald/Makefile LSD/Makefile Sasami/Makefile config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 EOF cat >> $tkeden1.18/configure.in010060000025250000147000000661760731566750600164170ustar00ashleydcsother00003470000356dnl dnl Process this file with autoconf to produce a configure script. dnl dnl Autoconf setup for {tk|tty|dtk}eden dnl dnl Ashley Ward (ashley@dcs.warwick.ac.uk) June 1999 dnl dnl $Id: configure.in,v 1.18 2001/04/02 14:40:02 cssbz Exp $ dnl dnl ##################################################################### dnl Initial setup dnl ##################################################################### dnl Write this revision information to the created configure script AC_REVISION($Revision: 1.18 $) # Check this file exists to make sure we are in the correct directory AC_INIT(Eden/main.c) dnl C preprocessor symbols get written to this file AC_CONFIG_HEADER(config.h) dnl ##################################################################### dnl Functions for use later on dnl ##################################################################### AC_DEFUN([CF_CHECK_CACHE], [ # # Check if we're accidentally using a cache from a different machine. # Derive the system name, as a check for reusing the autoconf cache. # # If we've packaged config.guess and config.sub, run that (since it does a # better job than uname). # if test -f $srcdir/config.guess ; then AC_CANONICAL_HOST system_name="$host_os" else system_name="`(uname -s -r) 2>/dev/null`" if test -z "$system_name" ; then system_name="`(hostname) 2>/dev/null`" fi fi test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name") AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"]) test -z "$system_name" && system_name="$cf_cv_system_name" test -n "$cf_cv_system_name" && AC_MSG_RESULT("Configuring for $cf_cv_system_name") if test ".$system_name" != ".$cf_cv_system_name" ; then AC_MSG_RESULT("Cached system name does not agree with actual") AC_ERROR("Please remove config.cache and try again.") fi ])dnl AC_DEFUN([CF_ANSI_CC_CHECK], [ AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C) AC_CACHE_VAL(cf_cv_ansi_cc,[ cf_cv_ansi_cc=no cf_save_CFLAGS="$CFLAGS" # Don't try gcc -ansi; that turns off useful extensions and # breaks some systems' header files. # AIX -qlanglvl=ansi # Ultrix and OSF/1 -std1 # HP-UX -Aa -D_HPUX_SOURCE # SVR4 -Xc # UnixWare 1.2 (cannot use -Xc, since ANSI/POSIX clashes) for cf_arg in "-DCC_HAS_PROTOS" "" -qlanglvl=ansi -std1 "-Aa -D_HPUX_SOURCE" -Xc do CFLAGS="$cf_save_CFLAGS $cf_arg" AC_TRY_COMPILE( [ #ifndef CC_HAS_PROTOS #if !defined(__STDC__) || __STDC__ != 1 choke me #endif #endif ],[ int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);};], [cf_cv_ansi_cc="$cf_arg"; break]) done CFLAGS="$cf_save_CFLAGS" ]) AC_MSG_RESULT($cf_cv_ansi_cc) if test "$cf_cv_ansi_cc" != "no"; then if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then CFLAGS="$CFLAGS $cf_cv_ansi_cc" else AC_DEFINE(CC_HAS_PROTOS) fi fi ])dnl dnl ##################################################################### dnl End functions - carry on with the work dnl ##################################################################### # Sanity check CF_CHECK_CACHE # !@!@ Not sure if all of these are required AC_PROG_CC AC_PROG_CPP AC_PROG_INSTALL dnl Sets LEX and LEXLIB, to, eg flex and -lfl AC_PROG_LEX dnl Does make set ${MAKE}? Defines @SET_MAKE@ AC_PROG_MAKE_SET dnl Sets RANLIB output variable to 'ranlib' or ':' if it is not found AC_PROG_RANLIB # Find options to use ANSI C CF_ANSI_CC_CHECK # Is the math library OK? AC_CHECK_LIB(m, tan,, AC_MSG_ERROR(can't find math functions)) # Tcl on Linux on PC seems to require -ldl AC_CHECK_LIB(dl, dlerror) ######################################################################### # Compile time switches ######################################################################### AC_ARG_ENABLE(debug, [ --enable-debug enable debugging], [ AC_DEFINE(DEBUG) AC_DEFINE(YYDEBUG) # parser debugging wrapped into general debug now ]) AC_ARG_ENABLE(dcc, [ --enable-dcc enable dcc function for disabling circular checking], [ AC_DEFINE(NO_CHECK_CIRCULAR) ]) AC_ARG_ENABLE(depend, [ --enable-depend enable Makefile source dependency checking], [ DEPEND_MAKEDEFS="include ../depend.mk" ], [ DEPEND_MAKEDEFS="#include ../depend.mk" ]) AC_ARG_ENABLE(disable-sasami, [ --enable-disable-sasami don't try to build the Sasami OpenGL notation], [ AC_MSG_WARN(Disabling Sasami) aw_want_sasami="no" ], [ aw_want_sasami="yes" AC_DEFINE(WANT_SASAMI) ]) AC_ARG_ENABLE(ipc, [ --enable-ipc enable support for Eden IPC functions (send_msg...)], [ AC_DEFINE(ipc) ]) ######################################################################### # X ######################################################################### dnl Sets $X_CFLAGS, $X_LIBS, $X_EXTRA_LIBS, $X_PRE_LIBS AC_PATH_XTRA # Bit of a bodge but I can't think of a better way of detecting Windoz if test "$no_x" = "yes"; then # Probably Windoz AW_X_LIBS="-lGDI32 -lUSER32 -lCOMDLG32 -lKERNEL32" else AW_X_LIBS="-lXt -lX11" if test "$aw_want_sasami" = "yes"; then AW_X_LIBS="$AW_X_LIBS -lXmu -lXext" fi fi ######################################################################### # Run time linker ######################################################################### # The Solaris implementation of dynamic linking means that the run-time # linker needs to know where to locate the (dynamically linked) libraries. # This means when we are linking, for each -L option, we need to pass a # similar -R option. # Apparently some versions of Sun CC require a space after the -R, and # some no space, which seems incredibly dumb. I haven't bothered to check # for this yet though. dnl See the stuff in the AC_PATH_XTRA macro for how to implement a test dnl for this. I can't be bothered at the moment because in order to do it dnl properly it looks like I need to choose a functioning library to test. dnl (And possibly even *run* the test, not just link it to test completely dnl that -R works: note that -R on linux is for something else! Duh!). dnl See /gnu/share/autoconf/acspecific.m4 for AC_PATH_XTRA. AC_MSG_CHECKING(whether we need -R) case "`(uname -sr) 2>/dev/null`" in "SunOS 5"*) aw_need_r=yes AC_MSG_RESULT(yes) ;; *) aw_need_r=no AC_MSG_RESULT(no) ;; esac ######################################################################### # curses ######################################################################### # # Prefer "new" curses: ncurses. # # Examples: # bax and holst: /usr/include/ncurses/curses.h: # -I/usr/include/ncurses -L/usr/lib -L/usr/lib/ncurses -lncurses # gem: /gnu/include/ncurses.h: # -I/gnu/include -L/gnu/lib -lncurses # gem: /usr/include/curses.h: # -lcurses # # Possible include directories: /usr/include /gnu/include /usr/local/include # # One of these directories might include # ncurses/curses.h: -Iinc_dir/ncurses -Llib_dir -Llib_dir/ncurses -lncurses # ncurses.h: -Iinc_dir -Llib_dir -lcurses # curses.h: -Iinc_dir -Llib_dir -lcurses # # Everything set up already (eg in LIBS) is not an option as we want # this to apply only to ttyeden. # # Sets Example # CURSES_TYPE curses # CURSES_INCLUDE -I/usr/local/include # CURSES_LIB -lcurses # CURSES_LIB_PATH -L/usr/local/lib # HAVE_CURSES "" # dnl AW_LIB_CURSES2 dnl Don't call this directly - use AW_LIB_CURSES dnl Parameters: dnl $1 include directory to try dnl $2 header filename to look for dnl $3 CURSES_TYPE: curses or ncurses, used for the header file to include dnl $4 CURSES_INCLUDE if it works dnl $5 CURSES_LIB_PATH if it works AC_DEFUN([AW_LIB_CURSES2], [ aw_curses_include_dir=$1 aw_curses_header_look=$2 aw_curses_type=$3 aw_curses_include=$4 aw_curses_lib_path=$5 if test -z "$aw_finished_curses"; then AC_MSG_CHECKING(for ${aw_curses_include_dir}/${aw_curses_header_look}) if test -f ${aw_curses_include_dir}/${aw_curses_header_look}; then AC_MSG_RESULT(yes) # Temporarily add blurb to LIBS aw_save_libs=$LIBS LIBS="$aw_curses_include $aw_curses_lib_path -l${aw_curses_type} $LIBS" AC_MSG_CHECKING(whether we can link curses using $LIBS) AC_TRY_LINK( [#include ], [initscr()], [ # Link succeeded LIBS=$aw_save_libs AC_MSG_RESULT(yes) aw_finished_curses="yes" CURSES_TYPE=$aw_curses_type CURSES_INCLUDE=$aw_curses_include CURSES_LIB_PATH=$aw_curses_lib_path CURSES_LIB=-l$aw_curses_type ], [ # Link failed. Do nothing (the search process will # just continue to another possible location). LIBS=$aw_save_libs AC_MSG_RESULT(no) ] ) else AC_MSG_RESULT(no) fi fi ]) dnl AW_LIB_CURSES dnl $1 include directory to try dnl $2 corresponding lib directory AC_DEFUN([AW_LIB_CURSES], [ # Three possible cases # ncurses/curses.h: -Iinc_dir/ncurses -Llib_dir -Llib_dir/ncurses -lncurses # ncurses.h: -Iinc_dir -Llib_dir -lcurses # curses.h: -Iinc_dir -Llib_dir -lcurses if test "$aw_need_r" = "yes"; then # We need the -R for runtime linking # Note this code is repeated below with -R taken away AW_LIB_CURSES2($1, ncurses/curses.h, ncurses, -I$1/ncurses, "-L$2 -L$2/ncurses -R$2 -R$2/ncurses") AW_LIB_CURSES2($1, ncurses.h, ncurses, -I$1, "-L$2 -R$2") AW_LIB_CURSES2($1, curses.h, curses, -I$1, "-L$2 -R$2") else # We don't need the -R option # Note this code is repeated above with -R added AW_LIB_CURSES2($1, ncurses/curses.h, ncurses, -I$1/ncurses, "-L$2 -L$2/ncurses") AW_LIB_CURSES2($1, ncurses.h, ncurses, -I$1, -L$2) AW_LIB_CURSES2($1, curses.h, curses, -I$1, -L$2) fi ]) # See if the user supplied some arguments AC_ARG_WITH(curses-include, [ --with-curses-include=DIR (n)curses include files are in DIR], [ aw_user_supplied_curses_include=$withval # Try and find this with the lib variable unset - the user # should really provide --with-curses-lib as well. AW_LIB_CURSES($aw_user_supplied_curses_include,) ] ) AC_ARG_WITH(curses-lib, [ --with-curses-lib=DIR (n)curses library files are in DIR], [ aw_user_supplied_curses_lib_dir=$withval AW_LIB_CURSES($aw_user_supplied_curses_include, $aw_user_supplied_curses_lib_dir) ] ) # Attempt to guess where it might be AW_LIB_CURSES(/usr/local/include, /usr/local/lib) AW_LIB_CURSES(/gnu/include, /gnu/lib) AW_LIB_CURSES(/usr/include, /usr/lib) # Declare the type of curses found so that we can include the # appropriate header file, and include the curses object in the list # of objects to be built in the appropriate Makefiles if test "$CURSES_TYPE" = "ncurses"; then AC_DEFINE(HAVE_NCURSES) HAVE_CURSES="ncurses" elif test "$CURSES_TYPE" = "curses"; then AC_DEFINE(HAVE_CURSES) HAVE_CURSES="curses" else HAVE_CURSES="" fi # Print results AC_MSG_CHECKING(for curses) AC_MSG_RESULT([$CURSES_TYPE $CURSES_INCLUDE $CURSES_LIB $CURSES_LIB_PATH $CURSES_IF_ENABLED]) ######################################################################### # tcl ######################################################################### # # Sets Example # TCL_INCLUDE -I/usr/local/include # TCL_LIB -L/usr/local/lib -ltcl # AC_DEFUN([AW_CHECK_TCL], [ aw_tcl_include=$1 aw_tcl_lib=$2 if test "$aw_need_r" = "yes"; then # !@!@ This bit should really be an AC function # Note I need m4 [] quotes around this so that the brackets in the # sed expression do not get eaten aw_tcl_lib=[`echo $aw_tcl_lib | sed 's/-L\([^ ]*\)/-L\1 -R\1/'`] fi # If we haven't already found an answer... if test -z "$aw_finished_tcl"; then aw_save_libs=$LIBS LIBS="$aw_tcl_include $aw_tcl_lib $LIBS" AC_MSG_CHECKING(whether we can link tcl using $LIBS) AC_TRY_LINK( [#include ], [Tcl_AsyncReady()], [ # Link succeeded AC_MSG_RESULT(yes) # Don't do any more tests - we have the answer aw_finished_tcl="yes" TCL_INCLUDE=$aw_tcl_include TCL_LIB=$aw_tcl_lib AC_MSG_CHECKING(whether tcl has Tcl_EvalEx) AC_TRY_LINK( [#include ], [ Tcl_Interp *interp; Tcl_EvalEx(interp, "", -1, 0) ], [ AC_MSG_RESULT(yes) AC_DEFINE(HAVE_TCL_EVALEX) ], [ AC_MSG_RESULT(no) ] ) LIBS=$aw_save_libs ], [ # Link failed - do nothing. LIBS=$aw_save_libs AC_MSG_RESULT(no) ] ) fi ]) AC_ARG_WITH(tcl-include, [ --with-tcl-include=compiler options to enable location of tcl.h eg \"-I/usr/local/include\"], [aw_user_tcl_include=$withval] ) AC_ARG_WITH(tcl-lib, [ --with-tcl-lib=linker options to enable location of the tcl library eg \"-L/usr/local/lib -R/usr/local/lib -ltcl\"], [aw_user_tcl_lib=$withval] ) # If the user provided both or either option, then try it first if test -n "$aw_user_tcl_include" -o -n "$aw_user_tcl_lib"; then AW_CHECK_TCL($aw_user_tcl_include, $aw_user_tcl_lib) fi # Else can we use tcl with just -ltcl? AW_CHECK_TCL(, "-ltcl") # Now we're guessing... :) # This works at DCS, University of TV AW_CHECK_TCL("-I/usr/local/include", "-L/usr/local/lib -ltcl") # This works at ITS, University of TV AW_CHECK_TCL(, "-L/usr/local/lib -ltcl8.0") # This works on ride, a Sparc Solaris 7 machine with packages # from sunfreeware.com AW_CHECK_TCL(, "-L/usr/local/lib -ltcl") # I give a warning if tcl is not found at the end of the script ######################################################################### # tk ######################################################################### # # Sets Example # TK_INCLUDE -I/usr/local/include # TK_LIB -L/usr/local/lib -ltk # AC_DEFUN([AW_CHECK_TK], [ aw_tk_include=$1 aw_tk_lib=$2 if test "$aw_need_r" = "yes"; then # Note I need m4 [] quotes around this so that the brackets in the # sed expression do not get eaten aw_tk_lib=[`echo $aw_tk_lib | sed 's/-L\([^ ]*\)/-L\1 -R\1/'`] fi # If we haven't already found an answer... if test -z "$aw_finished_tk"; then aw_save_libs=$LIBS # Also add X stuff and tcl stuff. Existing LIBS must go at the # end: -lm must come after -ltk for example. # NB don't seem to need $AW_X_LIBS and -lglPNG may cause an error LIBS="$aw_tk_include $aw_tk_lib $X_CFLAGS $X_PRE_LIBS $X_LIBS $X_EXTRA_LIBS $TCL_INCLUDE $TCL_LIB $LIBS" AC_MSG_CHECKING(whether we can link tk using $LIBS) AC_TRY_LINK( [#include ], [Tk_GetNumMainWindows();], [ # Link succeeded LIBS=$aw_save_libs AC_MSG_RESULT(yes) # Don't do any more tests - we have the answer aw_finished_tk="yes" TK_INCLUDE=$aw_tk_include TK_LIB=$aw_tk_lib ], [ # Link failed - do nothing. LIBS=$aw_save_libs AC_MSG_RESULT(no) ] ) fi ]) AC_ARG_WITH(tk-include, [ --with-tk-include=compiler options to enable location of tk.h eg \"-I/usr/local/include\"], [aw_user_tk_include=$withval] ) AC_ARG_WITH(tk-lib, [ --with-tk-lib=linker options to enable location of the tk library eg \"-L/usr/local/lib -R/usr/local/lib -ltk\"], [aw_user_tk_lib=$withval] ) # If the user provided both or either option, then try it first if test -n "$aw_user_tk_include" -o -n "$aw_user_tk_lib"; then AW_CHECK_TK($aw_user_tk_include, $aw_user_tk_lib) fi # Else can we use tk with just -ltk? AW_CHECK_TK(, "-ltk") # Now we're guessing... :) # This works at DCS, University of TV AW_CHECK_TK("-I/usr/local/include", "-L/usr/local/lib -ltk") # This works at ITS, University of TV AW_CHECK_TK(, "-L/usr/local/lib -ltk8.0") # This works on ride, a Sparc Solaris 7 machine with packages from # sunfreeware.com AW_CHECK_TK(, "-L/usr/local/lib -ltk8.2") # I give a warning if tk is not found at the end of the script ######################################################################### # Readline ######################################################################### # # Sets Example # READLINE_INCLUDE -I/gnu/include/readline # READLINE_LIB -L/gnu/lib -R/gnu/lib -lreadline # AC_DEFUN([AW_CHECK_READLINE], [ aw_readline_include=$1 aw_readline_lib=$2 if test "$aw_need_r" = "yes"; then # Note I need m4 [] quotes around this so that the brackets in the # sed expression do not get eaten aw_readline_lib=[`echo $aw_readline_lib | sed 's/-L\([^ ]*\)/-L\1 -R\1/'`] fi # If we haven't already found an answer... if test -z "$aw_finished_readline"; then aw_save_libs=$LIBS # Need curses as well as the supplied settings LIBS="$aw_readline_include $aw_readline_lib $CURSES_INCLUDE $CURSES_LIB_PATH $CURSES_LIB $LIBS" AC_MSG_CHECKING(whether we can link readline using $LIBS) AC_TRY_LINK( [ #include #include #include ], [readline("test");], [ # Link succeeded LIBS=$aw_save_libs AC_MSG_RESULT(yes) # Don't do any more tests - we have the answer aw_finished_readline="yes" READLINE_INCLUDE=$aw_readline_include READLINE_LIB=$aw_readline_lib ], [ # Link failed - do nothing. LIBS=$aw_save_libs AC_MSG_RESULT(no) ] ) fi ] ) AC_ARG_WITH(readline-include, [ --with-readline-include=compiler options to enable location of GNU readline header files eg \"-I/gnu/include/readline\"], [aw_user_readline_include=$withval] ) AC_ARG_WITH(readline-lib, [ --with-readline-lib=linker options to enable location of the GNU readline library eg \"-L/gnu/lib -R/gnu/lib -lreadline\"], [aw_user_readline_lib=$withval] ) # If the user provided both or either option, then try it first if test -n "$aw_user_readline_include" -o -n "$aw_user_readline_lib"; then AW_CHECK_READLINE($aw_user_readline_include, $aw_user_readline_lib) fi # Else can we use readline with just -lreadline? AW_CHECK_READLINE(, "-lreadline") # Now we're guessing... :) # This works on cygwin AW_CHECK_READLINE("-I/usr/include/readline", "-L/usr/lib -lreadline") # This works at DCS, University of TV AW_CHECK_READLINE("-I/gnu/include/readline -I/gnu/include", "-L/gnu/lib -R/gnu/lib -lreadline") # This works on a newly installed Solaris 7 machine with standard GNU install AW_CHECK_READLINE("-I/usr/local/include/readline", "-L/usr/local/lib -R/usr/local/lib -lreadline") # If we found an answer, then we HAVE_READLINE if test -n "$aw_finished_readline"; then AC_DEFINE(HAVE_READLINE) fi ######################################################################### # OpenGL ######################################################################### # # Sets Example # OPENGL_INCLUDE -I/usr/openwin/include # OPENGL_LIB -L/usr/openwin/lib -R/usr/openwin/lib -lGL AC_DEFUN([AW_CHECK_GL], [ aw_gl_include=$1 aw_gl_lib=$2 if test "$aw_need_r" = "yes"; then # Note I need m4 [] quotes around this so that the brackets in the # sed expression do not get eaten aw_gl_lib=[`echo $aw_gl_lib | sed 's/-L\([^ ]*\)/-L\1 -R\1/'`] fi # If we haven't already found an answer... if test -z "$aw_finished_gl"; then aw_save_libs=$LIBS LIBS="$aw_gl_include $aw_gl_lib" AC_MSG_CHECKING(whether we can link GL using $LIBS) # !@!@ should put a test for the Solaris GL implementation in here, # because I can't get it to use the correct colormap on 8-bit GFX # hardware: the workaround is to use Mesa instead AC_TRY_LINK( [ #include ], [glLoadIdentity();], [ # Link succeeded LIBS=$aw_save_libs AC_MSG_RESULT(yes) # Don't do any more tests - we have the answer aw_finished_gl="yes" OPENGL_INCLUDE=$aw_gl_include OPENGL_LIB=$aw_gl_lib ], [ # Link failed - do nothing. LIBS=$aw_save_libs AC_MSG_RESULT(no) ] ) fi ] ) AC_ARG_WITH(gl-include, [ --with-gl-include=compiler options to enable location of GL header files eg \"-I/usr/openwin/include\"], [aw_user_gl_include=$withval] ) AC_ARG_WITH(gl-lib, [ --with-gl-lib=linker options to enable location of the GL library eg \"-L/usr/openwin/lib -R/usr/openwin/lib -lGL\"], [aw_user_gl_lib=$withval] ) if test "$aw_want_sasami" = "yes"; then # We want to build Sasami - so figure out OpenGL # If the user provided both or either option, then try it first if test -n "$aw_user_gl_include" -o -n "$aw_user_gl_lib"; then AW_CHECK_GL($aw_user_gl_include, $aw_user_gl_lib) fi # Else can we use GL with just -lGL? AW_CHECK_GL(, "-lGL") else OPENGL_INCLUDE="" OPENGL_LIB="" fi ######################################################################### # PNG library ######################################################################### # # Sets Example # PNG_INCLUDE -I/usr/local/include # PNG_LIB -L/usr/local/lib -R/usr/local/lib -lpng AC_DEFUN([AW_CHECK_PNG], [ aw_png_include=$1 aw_png_lib=$2 if test "$aw_need_r" = "yes"; then # Note I need m4 [] quotes around this so that the brackets in the # sed expression do not get eaten aw_png_lib=[`echo $aw_png_lib | sed 's/-L\([^ ]*\)/-L\1 -R\1/'`] fi # If we haven't already found an answer... if test -z "$aw_finished_png"; then aw_save_libs=$LIBS # -lpng needs -lm LIBS="$aw_png_include $aw_png_lib -lm" AC_MSG_CHECKING(whether we can link png using $LIBS) AC_TRY_LINK( [ #include ], [ png_structp png; png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); ], [ # Link succeeded LIBS=$aw_save_libs AC_MSG_RESULT(yes) # Don't do any more tests - we have the answer aw_finished_png="yes" PNG_INCLUDE=$aw_png_include PNG_LIB=$aw_png_lib ], [ # Link failed - do nothing. LIBS=$aw_save_libs AC_MSG_RESULT(no) ] ) fi ] ) AC_ARG_WITH(png-include, [ --with-png-include=compiler options to enable location of PNG header files eg \"-I/usr/local/include\"], [aw_user_png_include=$withval] ) AC_ARG_WITH(png-lib, [ --with-png-lib=linker options to enable location of the PNG library eg \"-L/usr/local/lib -R/usr/local/lib -lpng\"], [aw_user_png_lib=$withval] ) if test "$aw_want_sasami" = "yes"; then # We want to build Sasami - so figure out PNG # If the user provided both or either option, then try it first if test -n "$aw_user_png_include" -o -n "$aw_user_png_lib"; then AW_CHECK_PNG($aw_user_png_include, $aw_user_png_lib) fi # Else can we use PNG with just -lpng? AW_CHECK_PNG(, "-lpng") # Try this... AW_CHECK_PNG("-I/usr/local/include", "-L/usr/local/lib -lpng") else PNG_INCLUDE="" PNG_LIB="" fi ######################################################################### # Memory alignment ######################################################################### # I could use the gcc __alignof__ function, but then this would # restrict us to using gcc only. So we attempt to detect the alignment # required instead. AC_MSG_CHECKING(how doubles should be aligned) AC_TRY_RUN( [ #include struct foo { union align { double d; long l; void *p; } u; char c; }; int main() { struct foo f[2]; FILE *fp; int n; if ((fp = fopen("conftestalignoutput", "w")) == NULL) exit(1); if( 2*sizeof(union align) != sizeof(f) ) { n = fprintf(fp, "%ld\n", (long)(sizeof(struct foo) - sizeof(union align))); } else { n = fprintf(fp, "%ld\n", (long)sizeof(union align)); } /* If fprintf didn't complete successfully, exit code 1 */ if (n < 0) exit(1); if (fclose(fp) != 0) exit(1); /* All OK - exit code 0 */ exit(0); } ], [ # The code compiled, linked, executed and had exit code 0, # so we can read the alignment value written to the temporary # file. aw_alignment=`cat conftestalignoutput` AC_DEFINE_UNQUOTED(DOUBLE_ALIGNMENT, $aw_alignment) AC_MSG_RESULT($aw_alignment byte boundaries) ], [ # The test failed in some way, so assume the worst. AC_DEFINE(DOUBLE_ALIGNMENT, sizeof(double)) AC_MSG_RESULT([sizeof(double) byte boundaries]) ], [ # We are cross compiling so can't run the test, so we # assume the worst. AC_DEFINE(DOUBLE_ALIGNMENT, sizeof(double)) AC_MSG_RESULT([sizeof(double) byte boundaries]) ] ) ######################################################################### # dmalloc (tool for checking for memory leaks etc) ######################################################################### # I'm trusting the user to get this right, so no checks are done to see # if the arguments provided are correct. If they want to run it with a # memory debugger, they should know what they are doing... I hope. DMALLOC_INCLUDE= DMALLOC_LIB= AC_ARG_WITH(dmalloc-include, [ --with-dmalloc-include=DIR dmalloc include file is in DIR], [ AC_DEFINE(HAVE_DMALLOC) DMALLOC_INCLUDE=-I$withval ] ) AC_ARG_WITH(dmalloc-lib, [ --with-dmalloc-lib=DIR dmalloc lib file is in DIR], [ AC_DEFINE(HAVE_DMALLOC) DMALLOC_LIB="-L$withval -ldmalloc" ] ) ######################################################################### # Other bits ######################################################################### # Do we have ANSI C header files? Declares STDC_HEADERS if we do. Also # (undocumented) sets $ac_cv_header_stdc to "yes". dnl AC_HEADER_STDC dnl if test "$ac_cv_header_stdc" != "yes"; then dnl AC_MSG_ERROR(we don't have ANSI C header files) dnl fi # Check other headers and stop if we can't find them # Might define HAVE_MALLOC_H AC_CHECK_HEADER(malloc.h,, AC_MSG_ERROR(can't find malloc.h)) # Might define HAVE_SYS_TIME_H AC_CHECK_HEADER(sys/time.h,, AC_MSG_ERROR(can't find sys/time.h)) # Define const to be empty if the compiler does not support it AC_C_CONST # Deal with problems due to two header files time.h and sys/time.h # Might define TIME_WITH_SYS_TIME AC_HEADER_TIME # Might define TM_IN_SYS_TIME, "which means that including sys/time.h # had better define struct tm." (from Autoconf manual - huh?). AC_STRUCT_TM # Check for how to get alloca. Might defined HAVE_ALLOCA_H, HAVE_ALLOCA, # ALLOCA, C_ALLOCA... AC_FUNC_ALLOCA # Find out what a signal handler should return AC_TYPE_SIGNAL # Check other functions and stop if we can't find them AC_CHECK_FUNC(gettimeofday,, AC_MSG_ERROR(don't have gettimeofday)) AC_CHECK_FUNC(putenv,, AC_MSG_ERROR(don't have putenv)) AC_CHECK_FUNC(select,, AC_MSG_ERROR(don't have select)) AC_CHECK_FUNC(strdup,, AC_MSG_ERROR(don't have strdup)) ######################################################################### # Create the Makefiles ######################################################################### # Substitute the following variables in the Makefiles AC_SUBST(AW_X_LIBS) AC_SUBST(CURSES_TYPE) AC_SUBST(CURSES_INCLUDE) AC_SUBST(CURSES_LIB) AC_SUBST(CURSES_LIB_PATH) AC_SUBST(TCL_INCLUDE) AC_SUBST(TCL_LIB) AC_SUBST(TK_INCLUDE) AC_SUBST(TK_LIB) AC_SUBST(DMALLOC_INCLUDE) AC_SUBST(DMALLOC_LIB) AC_SUBST(READLINE_INCLUDE) AC_SUBST(READLINE_LIB) AC_SUBST(OPENGL_INCLUDE) AC_SUBST(OPENGL_LIB) AC_SUBST(PNG_INCLUDE) AC_SUBST(PNG_LIB) AC_SUBST(DEPEND_MAKEDEFS) # Done - write the output Makefiles AC_OUTPUT(generic.mk Misc/Makefile Eden/Makefile EX/Makefile Scout/Makefile Makefile Donald/Makefile LSD/Makefile Sasami/Makefile) # Give warnings if test -z "$aw_want_sasami"; then AC_MSG_WARN(Cannot build Sasami - only possible on Windoz presently) fi if test -z "$aw_finished_tcl"; then AC_MSG_WARN(Could not locate tcl - can probably only build ttyeden) fi if test -z "$aw_finished_tk"; then AC_MSG_WARN(Could not locate tk - can probably only build ttyeden) fi if test -z "$aw_finished_readline"; then AC_MSG_WARN(Could not locate readline - ttyeden will not have line editing) fi if test -z "$HAVE_CURSES"; then AC_MSG_WARN(Could not locate curses - probably cannot build ttyeden) fi if test -z "$aw_finished_gl"; then AC_MSG_WARN(Could not locate GL - probably cannot build Sasami) fi if test -z "$aw_finished_png"; then AC_MSG_WARN(Could not locate PNG - probably cannot build Sasami) fi AC_MSG_WARN(Type 'make' for further instructions) en AW_CHECK_READLINE($aw_user_readline_include, $aw_user_readline_lib) fi # Else can we use readline with just -lreadline? AW_CHECK_READLINE(, "-lreadline") # Now we're guessing... :) # This works on cygwin AW_CHECK_READLINE("-I/usr/include/readline", "-L/usr/lib -lreadline") # This works at DCS, University of TV AW_CHECK_READLINE("-I/gnu/include/readline -I/gnu/include", "tkeden1.18/cscope010070000025250000147000000027010730323656400152570ustar00ashleydcsother00003470000356#!/bin/sh # # cscope # # $Id: cscope,v 1.5 1999/11/05 15:35:27 ashley Rel1.10 $ # # Ashley Ward, April 1999 # # Call cscope (a program by Sun - sort of an intelligent front end to # grep) with the right sort of settings for tkeden. # # This is of course, only of some use on a Sun platform which has the cscope # tool installed :) # # Name of temporary file to use - uses the PID of this shell to make the # name unique. TEMPFILE=/var/tmp/cscope.ash.$$ # Create the temporary file. Actually a little bit of shell so we can call # emacsclient with the correct arguments (can't set EDITOR to # 'emacsclient someargs' unfortunately). Note need to escape the $* # (which means all arguments passed to this shell). The sleep is so that # we have time to see any error messages. cat > $TEMPFILE < s="l[2]"; 2:> l=[1,3]; 3:> writeln(`s`); @ o One undefined item should not stop the entire screen from being updated. o symboltable()# fails when the table gets large - error running out of heap? Could make heap a dynamic array, I suppose... o Fix undefined problems: need more eager operators. o Get rid of "program too big" error: make prog a more dynamic array that is realloc'd when this error would have occurred o Donald 'pi' token - is it used? Meurig was trying to '%donald; real pi'. o Port Sasami to Unix o A 'warnings' window instead of the error messages appearing in the history. Visual warning to the user when something has appeared there. Warnings for "you have declared a symbol with a name similar to another", "this is now @" etc along with error messages (which would prob. be in a different colour). Sometimes it is appropriate to warn a user that they are creating a new symbol (eg when /using/ a model), when building - probably not. o a minor version number to represent changes to the Tcl / Eden library stuff? o change each sprintf to snprintf and include the buffer size to attempt to stop all these buffer overruns. o Radio button for the notation in the input window? o Make long variable names possible (apparently >20 chars fails, especially in Scout) o ttyeden readline: get it to complete from the symbol table. o "Freeze" the state function - want the equivalent of SQLs COMMIT or ROLLBACK. o A "save script" function for ttyeden: could rapidly prototype using the new readline interface, but cannot save. o guessLibLocation should read search a predetermined path to find a configuration file which determines the lib files location. o dtkeden should have the server / client name in the history window title o 'find' symbols facility should be better: need to be able to find definitions and usages separately. Need to be able to find 'is' separately from values. o Navigation around the view definitions interface is awful. o A function to 'forget' a set of definitions in the correct order? Perhaps by redefining all to @, then removing. Perhaps it should interactively prompt to make sure that we don't accidently remove definitions we would like to keep: a kind of 'rm -i' prompt. Perhaps it could print some information about whether it managed it or not. Perhaps we need an argument to tell it to be interactive or not. o Redesign into a one-window interface? Then have multiple input windows, one for each notation? o Inconsistency: textbox and text windows in scout with the same number of vertical lines are different sizes. o Inconsistency: use outlinecolor for circles outline, color for lines outline. o Inconsistency: use div in donald, / in eden. o Inconsistency: use semicolons in eden, not in donald o Inconsistency: don't declare in eden, declare in donald. o Inconsistency: last element of a scout window doesn't have a comma, the others do. o Inconsistency: PI in eden, pi in donald o Inconsistency: scout references its windows from the top left and donald from the bottom left o If any element in the screen is @, the whole screen is not displayed (apparently). Improve this to give a warning if something in the screen is @. o '?insert', '?append' fails. This is because the parser expects '?', lvalue and keywords such as insert and append are not lvalues. Need to figure out how to get the parser to accept these types. o Test new Eden bison.simple with eden < file, read file, piped input (via a translator)... o Link translators (eg eddi) to tkeden via pipes (tkeden pipe function?) and multiple Tcl windows o wouldBlock: change to getcWouldBlock and put in rl_getc_wouldblock logic o Check "additional possibilities" sum in bison.simple - does it give the right answer? o View -> Eden definitions: an option to sort and indent according to definition level? (This could be used to quickly find the basic model parameters). o Make a documentation package: cron job to nightly tar and gzip the HTML Eden, Scout, Donald documentation (post-SSI processing: wget? need version numbers or stamp package with the date: make the package each night and see if it has changed). o Change colour of interrupt button when it might be necessary to press it (when a RunSet is being processed?) o Make it possible to extend the stack when overflow occurs by implementing a non-contiguous stack. Need to ensure that nothing attempts to walk the stack to be able to do this tho'. o Make it possible to extend the heap when overflow occurs. (Example problem: see OASYSPermutations/gen_table.e). Perhaps allocate memory with malloc when heap overflows. o Highlight Eden / Donald / Scout keywords in the input window as they are entered using the Tcl text tag facility? o Extend debug() to take combinations of categories to filter debugging output, now that I've introduced CALSTK etc. o In the View Definitions window, use tags to highlight references to other variables - click and they are displayed. Add a back and forward button as per web browser. Or perhaps write an export to HTML feature and link with a web browser? (Perhaps use EMHTTP - press Reload on the web browser and it'll reload the page of definitions). o An incremental search facility on Ctrl-S, like emacs? o Use a more decent File -> Include widget: try FileSelectBox from Tix (but these widgets are megawidgets which probably required [incr Tcl] and [incr Tk] - the OO extensions to Tcl/Tk). o Take a look at TkTable - a spreadsheet / table widget: could we improve the View Definition windows with this? o Change the mouse cursor when tkeden is busy (see example from Tk FAQ #4.3 How do I change the Tk cursor?). o A +/- button in View Eden Definitions to expand / contract display of agents (eg AGENT system should probably be contracted most of the time). o Put an error message pane underneath the input window (+ make it possible to resize it?) o Separate error stream into another Tcl window. o configure.in: can we cache more? o Option to update "View Eden Definitions" continuously (actually, on every RunSet switch). o Link Prev, Next Tcl history with the history as stored on file (a bit like the shell). o Wrap Sasami window in Scout o Feed mouse placement in Sasami window to Eden (perhaps in terms of a list of polygons that the mouse is currently over - Benjohn describes a technique involving turning the OpenGL renderer into a special mode, and rendering a window one pixel in size). o " %scout" - make ex.c ignore leading spaces / tabs o Readline currently seems to tab complete from the files in the current directory. Change it to complete from Eden keywords and identifiers. o Clear up #includes: should only use <> for system libraries (so that .d files don't show them) o Inp_Dev_Save might be an unnecessary hack: perhaps Inp_Dev should be volatile? o When opening the Scout window, if there is any content outside, make it bigger. o Provide a command line argument which lets you pass a string to be passed as input before anything else is read. o Get Scout/print.c printdef to use the constants array etc o Fix Scout so that on View Scout or Scout ? query, the correct value of sensitive is shown o Input window: an Undo function (particularly wrt paste / insert) o Improve Scout / Donald unhelpful "parse error" o Chris Brown's changes o Fix tcl("reinit"); o Un-hack the dashed line stuff using the Dash patch in Tcl / Tk 8.3.3... o Add a File->cd o "a=1; while (1) { a++; }" causes tkeden to hang: not even the Interrupt button works (but Ctrl-C does) - is it possible to make the event from the Interrupt button be processed straight away (despite Tcl update not having been called - perhaps via some sort of error mechanism?) but leave the other events until Eden is ready, as before? o Sasami: remove the globTogl hack o Recode all references to interp->result (see Tcl_SetResult(3)) o Add some syntax to allow removal of triggers: ~>![] ? (if ![] is valid syntax elsewhere)... o Resize viewport: if viewport size has not changed, don't do anything. o A View Sasami Definitions window for completeness o Can we rework Sasami's numeric IDs into symbolic ones for ease of tracing...? o Replace the multiple Save options with Save and Save As options, with radio buttons to turn off saving of various notations in the dialogue box. o Don't create required windows (eg History) until it is actually required to speed initial startup? o Windows: Try and get the executable to use the Scriptics-provided DLLs (so can use Tcl 8.3 with the dash patch etc)? Perhaps look at using the tcl-stub stuff...? o Sasami: [Ben] Smooth vertex normals based on face normals and face adjacency o [Ben] Speed controller example shows some display corruption o [Ben] Note : Enormous (40 units+) polygons screw up lighting. OpenGL driver bug? (Addition) Not necessarily bug. Maybe something to do with oblique specular angles on large polys looking wrong (despite being "right" in a mathematical sense). Imagine a poly large enough that the vertices on both sides had specular hilights and then interpolate across... o Install a non-debugging version for DCS for performance?? o Rework Misc functions in the style of random if they are declared in system header files o Change Scout int_tree assertion to a more helpful error, or modify the Scout parser to only allow integer values. o Find should beep when search proceeds beyond the end or beginning of the document. o Finish Help -> About Donald, Scout, Sasami o Help -> About LSD o Add "found: UNKNOWN" (or whatever) to bison error message as well as "expecting..." o Remember the state of file type selection between File -> Opens etc o File -> Restart ! o Find in the Quick Reference Guide windows... o Can we get the OK button in the Quick Reference Guide windows to take up less space? o DFfont is read by Donald at Donald startup, but Donald lacks dependency in this area and it's difficult to convince it to re-render the statechart with a new font (for example), whereas Scout seems to be better implemented here. o Un-hack the Scout integer / real implementation (give Scout true integers and true reals). o Remove "VB-like" features completely. o A rename symbol procedure, mainly for use in debugging (when we want to move an existing procedure out of the way to subsitute another but keep the original) o Query ? operator now shows sp->master, but this pretty much always seems to say "input". Can we change sp->master or get information from elsewhere that would make this more useful? Need to look at the calls to pushMasterStack() and what that actually does. Perhaps push the stack trace so far: "input window:proc p:action q"? o Do 'Previous' after error & move cursor to position of error (making interaction with tkeden somewhat like interaction with a debugger) o Save definitions should not save the ones belonging to 'system'. o Sort out a way of tagging files to show version when on SF o Try and sort out Chris and mouse dragging finally o Understand and document checkRunSet in main.c. o Add my "cheat sheet" to Eden (Donald, Scout...?) quick reference... o %scout causes a few system definitions to be entered under agent 'input' o Check into CVS again: cvs remove disp.c disp.h win32ex.c win32ex.h DOCUMENTATION ============= o "History of tkeden" - email sy **o Find out rules of source redistribution (from Roy?) **o Who wrote the Eden handbook? Put it on the cover **o README file: no longer have exp2, exp10, log2 functions. configure options. Also redo INSTALL file. o Scout: screen should be defined as screen=; etc rather than screen=thing&thing2;, perhaps. **o Document this new Motion sensitive thing. Note that it may not appear in the history window... **o Line breaks in Donald \ o xoutput and all that stuff? o tkeden web page: explain variants, link to documentation and example models? Perhaps Andy McDowell's documentation? **o -n option to ttyeden. And -i option?? o dtkeden port numbers = actual port numbers + 9000 or something o Document the generated files in the source - what depends on what? o dtkeden options must be given in a certain order **o Document -v, -u options o Document how to use with dmalloc o ~> operator. Gets overwritten when defining things in the list. o Can pull off the View menu and make it a permenant window instead o Donald ! operator and function calls... func!(args), not func(args)! o Are back-ticks (``) documented? Isn't there something about various problems when used on the RHS? o FAQ: "what happens during errors in Eden" - stack discarded? (so any? input is forgotten)... "stack inconsistent" error o Donald openshape vs shape. What? Also attributes of shapes are not copied across...? **o Document ttyeden readline functionality: use emacs-style (or vi-style) keys to edit and retrieve history. Can configure with .inputrc. o Document reserved words somewhere... o Document keyshorts in input window - copy the material from the Tcl text(n) man page. others do. o Inconsistency: PI in eden, pi in donald o Inconsistency: scout references its windows from the top left and donald from the bottom left o If any element in the screen is @, the whole screen is not displayed (apparently). Improve this to give a warning if something in the screen is @. o '?insert', '?append' fails. This is because the parser expects '?', lvalue and keywords such as insert and append are not lvalues. Need to figure out how to get thetkeden1.18/Docs/README.TXT010060000025250000147000000034120730543231200162740ustar00ashleydcsother00003470000356 README.TXT This is the Eden Empirical Modelling tool distribution. For more information, see http://www.dcs.warwick.ac.uk/modelling/. WARRANTY Note this software is supplied with NO FORM OF WARRANTY whatsoever: you /will/ discover problems, and unfortunately the students and staff at TV University will probably not have the time to help you. Sorry. Having said that, we hope it works for you and you find it interesting - best of luck! EDEN VARIANTS This source code can currently build three variants of Eden: tkeden (this has a graphical user interface provided by Tcl/Tk, hence the name, and is the variant most people usually use), dtkeden (tkeden plus some distributed features which are only of use if you intend to run multiple communicating tkedens) and ttyeden (a version with only a command line interface which provides only the Eden notation). NOTATIONS tkeden and dtkeden provide multiple notations. Eden is a definitive notation with a C-like syntax, which is used to implement the other, more domain-specific notations. Donald is a definitive notation for line drawing. Scout is a definitive notation for window layout. Sasami is a definitive notation for 3D graphics (which currently only works under Windows). LSD is a notation for specifying access to Eden observables in dtkeden. "DOCUMENTATION" README.TXT is this file INSTALL.TXT gives instructions on compiling and installing the software COPYING.TXT and GPL.TXT are the license agreement TODO is a long list of bugs to fix and improvements to make CHANGE.LOG is the history of changes to the software MAKING.A.RELEASE is a checklist for the maintainer GLPNG_LICENSE.TXT describes the copyright on the GLpng source included here TOGL_LICENSE.TXT describes the copyright on the Togl source included here tkeden1.18/Docs/MAKING.A.RELEASE010060000025250000147000000013520727406556600171100ustar00ashleydcsother00003470000356 MAKING A RELEASE - CHECKLIST: ============================= o Increment the version number in version.h if necessary o Change name of lib directory, and symlink the older name to it if necessary o Update version number in Windows/run.bat o find . -name '*~' -print -exec rm {} \; o autoconf o make reallyclean o lsrw; lsrw */* (ensure no temporary output files are left, and everything is checked in) o ./configure o make dtkeden (to ensure the generated sources exist) o make maintainerclean o chgrp -R em * o Update Docs/CHANGE.LOG o make setrcsstate o cd ..; tar cvf tkeden.1.3.tar tkeden gzip tkeden.1.3.tar (update the version number, of course!) o If installing a version, you have linked without a debugging memory library? tkeden1.18/Docs/INSTALL.TXT010060000025250000147000000205510731214667600164650ustar00ashleydcsother00003470000356-*-text-*- REQUIREMENTS ============ Eden depends upon other pieces of software for some of its functionality. Build requirements ------------------ To be able to build Eden, you might need some of these open-source packages. The version numbers are for your rough guidance only: these versions seemed to work for me, and earlier versions may as well. ncurses 4.2: if you want ttyeden to be able to move the cursor around the screen etc - say you want to run the text editor model. If the configure script can't find a version of curses ("new" curses - ncurses - is preferred but most systems will probably have a suitable version already), then ttyeden /should/ still build (ie it might not but that is a bug!). readline 4.1: if you want line editing facilities in ttyeden. If it can't, it /should/ still build. gzip 1.3: to decompress the package in the first place. make 3.78.1: but your system probably has a make already, which will probably do (although you may need GNU make if you plan to do some development with Eden - see below). tk 8.2.1 and tcl 8.2.1: if you want tkeden. libpng 1.0.12 (which itself requires zlib 1.1.3): if you want the Sasami OpenGL notation. Mesa 3.4.2: if you want Sasami OpenGL to use the correct colours on a Solaris machine with a cheap graphics card. There is a bug somewhere (Sasami, Togl, Tk, X, OpenGL?) which causes Eden to use the wrong visual and colormap when running using Solaris 8 X and OpenGL on a machine with an 8-bit (old, low end) graphics card. The easiest way to solve this problem currently seems to be to link Eden using Mesa (which is most simply described as an open-source OpenGL). gcc 2.8.1: to compile it - duh. I /think/ it compiles OK with the Sun cc as well. The usual UNIX system things: sed, ar, install (mentioned in the Makefiles but not yet used), grep and awk (if running the more obscure distribution tasks). Development tools ----------------- If you want to change or debug Eden code, these might be useful. The version numbers are for your rough guidance only: these versions seemed to work for me, and earlier versions may as well. autoconf 2.13: if you want to make a change to configure.in and rebuild the configure script. autoconf needs m4 to be installed - I used m4 1.4. bison 1.28: (the GNU parser generator - a yacc replacement). Needed if you want to make changes to the notations Eden, Donald etc. If the distribution package has been built correctly, the generated files should be there already, so you should only need bison if you are developing. If you are using a different version of bison, you /may/ need to re-do bison/bison.simple from the bison.simple supplied with your bison (although I'm not sure how important this is - I've been using the wrong version for a while with no apparent ill effects). The modifications are marked and are quite simple. dmalloc: if you want to debug nasty memory problems cvs: if you want to check in or out changes to the central SourceForge code repository. Development notes: - If you are making substantial changes to the code, I'd suggest that you use the automatic Makefile source code dependency checking to make sure that the necessary source is recompiled when things are changed. Follow this process to set up the dependency information: ./configure --enable-debug --enable-depend gmake generate gmake depend I've specified gmake here as GNU make is probably required for this (Solaris make gives "Unexpected end of line seen" after encountering the ifeq GNU extension I've used, and it doesn't seem to interpret the source.c source.d: deps rule appropriately). - If you want to compile non-optimised (for easy single-stepping using a debugger), I'd recommend that you set the environment variable CFLAGS to "-g -O0" and then re-make everything. Windows ------- The port to the Windows platform uses cygwin. Run-time requirements --------------------- tkeden uses various pnm image utilities (eg 'pnmscale') to do image manipulation for Scout. tkeden expects to find these utilities in the PATH. They are not required if your model does not use image scaling etc. BUILDING EDEN ============= These instructions describe how to build an Eden variant on a UNIX-flavour machine (eg Solaris, Linux...). Cygwin (which provides some UNIX-like facilities for Windows) is used to build Eden on Windows, and so the procedure there is similar, but different in some aspects. Hopefully some documentation for the Windows build will be written at some point. Gunzip and untar your distribution, using something like: gunzip tkeden.1.11.tar.gz tar xvf tkeden.1.11.tar Change directory to within the tkeden directory you just untarred: cd tkeden Hopefully your distribution will have a `configure' shell script. If you've downloaded the source straight from CVS, however, you probably won't have one. If you don't, generate `configure' and the Makefiles from the various `.in' (`configure.in', `Makefile.in'...) files by running: autoconf Automatically probe your setup for the information we need to compile `tkeden' by running: ./configure At the end of the probing, if you see errors such as configure: warning: Could not locate tk - can probably only build ttyeden then examine `config.log' to see the tests that were run and the errors that were encountered. The `configure' script should figure out all that we need. Unfortunately, even though this may sound simple, it is actually a rather nasty and complex job, as machine configurations can vary widely. Depending upon your setup, you may need to tell the `configure' script how to use other pieces of software. If `configure' still moans, you might need to solve the problem with something like: ./configure --with-tk-include="-I/usr/local/include" \ --with-tk-lib="-L/usr/local/lib -R/usr/local/lib -ltk8.2" (I've broken the line for readability). See the available options by using ./configure --help If you figure out what needs to be done to compile the software on your particular platform, if you are able, please modify configure.in and change the master copy of the source with CVS, or email me at ashley@dcs.warwick.ac.uk, giving me the details of what you needed to do, and I'll attempt to fix things so that you and others will not need to do this in the future. Choose the sort of Eden you wish to build: - `ttyeden' is the terminal based, non-graphical version, - `tkeden' is the `standard' version and - `dtkeden' is the one with distributed modelling facilities. I expect most people will choose to build `tkeden'. The following instructions show how to build `tkeden': simply substitute one of the other target names if you want to build another variant. To compile tkeden, type make tkeden Hopefully you will now have a tkeden binary in your directory. I'd recommend trying this simple test to see if the binary will print out the usage information: ./tkeden -u If that worked OK, try and run it normally with ./tkeden -l ./lib-tkeden (the -l argument tells tkeden where to find some start-up files --- some older documentation may refer to the `$PUBLIC' environment variable, which used to be used to provide this information). After you've started `tkeden', I'd suggest checking the `Help -> About tkeden' menu to check that you are running the right version (and not a `tkeden' elsewhere on your PATH). Careful: you must (unfortunately) use make clean before compiling a different variant (eg compiling dtkeden after having just done tkeden). This is due to the extensive use of the C preprocessor in merging the different sources together - if you can figure out a better scheme, please implement it! :) Installing: with `tkeden' and `dtkeden', you can put the binary anywhere as long as it is provided with the -l argument when it is invoked to tell it where the start-up library files are. I'd suggest writing a wrapper shell script if you want to install it `properly'. There is no requirement to do this, of course --- you can just leave the binary where you found it after compilation. `ttyeden' doesn't require the -l argument, so you should be able to put it anywhere on your PATH with no problems. If you want to save some disc space, you can strip the binaries (eg `strip tkeden'), but I'd only recommend doing this if you anticipate never using a debugger on the code. If it all works fine for you --- congratulations, and have fun. Ash, March 2001 tkeden1.18/Docs/GPL.TXT010060000025250000147000000431310727406556600160050ustar00ashleydcsother00003470000356 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. ge; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to itkeden1.18/Docs/CVS/004070000025250000147000000000000731677661000154105ustar00ashleydcsother00003470000356tkeden1.18/Docs/CVS/Root010060000025250000147000000000360727406557000162530ustar00ashleydcsother00003470000356cssbz@127.0.0.1:/cvsroot/eden tkeden1.18/Docs/CVS/Repository010060000025250000147000000000140727406557000175030ustar00ashleydcsother00003470000356tkeden/Docs tkeden1.18/Docs/CVS/Entries010060000025250000147000000004560727406557000167470ustar00ashleydcsother00003470000356/CHANGE.LOG/1.6/Wed Apr 11 17:52:50 2001// /COPYING.TXT/1.4/Wed Apr 11 17:52:50 2001// /GPL.TXT/1.1/Wed Apr 11 17:53:05 2001// /INSTALL.TXT/1.1/Wed Apr 11 17:53:10 2001// /MAKING.A.RELEASE/1.6/Wed Apr 11 17:53:10 2001// /README.TXT/1.1/Wed Apr 11 17:53:10 2001// /TODO/1.1/Wed Apr 11 17:53:15 2001// D tkeden1.18/Docs/CHANGE.LOG010060000025250000147000000001050731214637000162260ustar00ashleydcsother00003470000356 Eden CHANGE.LOG =============== See the file lib-tkeden/CHANGE.LOG tkeden1.18/Docs/COPYING.TXT010060000025250000147000000002420731214643000164460ustar00ashleydcsother00003470000356Eden: the Evaluator of DEfinitive Notations Copyright (c) 1995-2001 The University of TV. All rights reserved. Please see the file lib-tkeden/credits.txt tkeden1.18/Docs/LICENSE_GLPNG.TXT010060000025250000147000000025670730543223000173610ustar00ashleydcsother00003470000356-*-text-*- PNG loader library for OpenGL v1.45 (10/7/2000) By Ben Wyatt: ben@wyatt100.freeserve.co.uk Note: this is a cut-down (by Ashley Ward) version of GLpng to fit it neatly into the Eden distribution. The original, with more documentation and examples etc can be downloaded from http://www.wyatt100.freeserve.co.uk/download.htm. This is a library for OpenGL to load PNG graphics files as an OpenGL texture as easily as possible. It also has a number of options for generating the alpha channel and mipmaps. It is implemented using modified versions of the LibPNG 1.0.2 and ZLib 1.1.3 libraries. This software is provided 'as-is', without any express or implied warranty. In no event will the author be held liable for any damages arising from the use of this software. Permission is hereby granted to use, copy, modify, and distribute this source code, or portions hereof, for any purpose, without fee, subject to the following restrictions: o The origin of this source code must not be misrepresented. You must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. o Altered versions must be plainly marked as such and must not be misrepresented as being the original source. o This notice must not be removed or altered from any source distribution. tkeden1.18/Docs/LICENSE_TOGL.TXT010060000025250000147000000027050730543216200172550ustar00ashleydcsother00003470000356This software is copyrighted by Brian Paul (brian@mesa3d.org) and Benjamin Bederson (bederson@cs.umd.edu). The following terms apply to all files associated with the software unless explicitly disclaimed in individual files. The authors hereby grant permission to use, copy, modify, distribute, and license this software and its documentation for any purpose, provided that existing copyright notices are retained in all copies and that this notice is included verbatim in any distributions. No written agreement, license, or royalty fee is required for any of the authorized uses. Modifications to this software may be copyrighted by their authors and need not follow the licensing terms described here, provided that the new terms are clearly indicated on the first page of each file where they apply. IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. tkeden1.18/Donald/004070000025250000147000000000000731700574200152565ustar00ashleydcsother00003470000356tkeden1.18/Donald/utility.c010060000025250000147000000012040731247322000171140ustar00ashleydcsother00003470000356/* * $Id: utility.c,v 1.7 1999/11/16 21:20:40 ashley Rel1.10 $ */ static char rcsid[] = "$Id: utility.c,v 1.7 1999/11/16 21:20:40 ashley Rel1.10 $"; #include "../config.h" #include "error.h" #include "../Eden/emalloc.h" #ifdef HAVE_DMALLOC #include #endif /*------------------------------------------------------------+--------+ | getmem | +--------*/ void * getmem(int size) { /* get memory of size */ void *ptr; if (!(ptr = emalloc(size))) don_err(OutOfMemory, 0); return ptr; } tkeden1.18/Donald/tree.h010060000025250000147000000032250727406556200163770ustar00ashleydcsother00003470000356/* * $Id: tree.h,v 1.4 1999/11/16 21:20:40 ashley Rel1.10 $ */ struct node4 { int type; int op; struct node4 *left; struct node4 *right; struct node4 *mid; struct node4 *extra; }; struct node3 { int type; int op; struct node4 *left; struct node4 *right; struct node4 *mid; }; struct node2 { int type; int op; struct node4 *left; struct node4 *right; }; struct node1 { int type; int op; struct node4 *left; }; struct node0 { int type; int op; union { int i; double r; char *s; } d; }; typedef struct node4 node4; typedef struct node3 node3; typedef struct node2 node2; typedef struct node1 node1; typedef struct node0 node0; typedef node4 *tree; extern tree dtree0(), dtree1(), dtree2(), dtree3(), dtree4(); #define EMPTYTREE (tree)0 #define Ivalue(expr) ((node0*)expr)->d.i #define Rvalue(expr) ((node0*)expr)->d.r #define Cvalue(expr) ((node0*)expr)->d.s #define Bvalue(expr) ((node0*)expr)->d.i #define Lexpr expr->left #define Mexpr expr->mid #define Rexpr expr->right #define Xexpr expr->extra #define Ltype Lexpr->type #define Mtype Mexpr->type #define Rtype Rexpr->type #define Xtype Xexpr->type #define Etype expr->type #define check_left() count_expr(Lexpr) #define check_right() count_expr(Rexpr) #define check_mid() count_expr(Mexpr) #define check_extra() count_expr(Xexpr) tkeden1.18/Donald/tree.c010060000025250000147000000607140731247311400163650ustar00ashleydcsother00003470000356/* * $Id: tree.c,v 1.10 1999/11/16 21:20:40 ashley Rel1.10 $ */ static char rcsid[] = "$Id: tree.c,v 1.10 1999/11/16 21:20:40 ashley Rel1.10 $"; #include #include #include #include #include "../config.h" #include "tree.h" #include "symbol.h" #include "error.h" #include "oper.h" #include "parser.h" #include "../EX/script.h" #include "../Eden/emalloc.h" #ifdef HAVE_DMALLOC #include #endif extern Tcl_Interp *interp; extern void *getmem(int); extern char *map_token_to_name(int); extern char *expr_to_eden_name(tree); extern symbol *look_up_tree(tree); extern symbol *look_up(char *); extern char *eden_full_name(char *); extern Script *dd_script; static char temp[256]; static int stage = 1; /* controlling the translation process */ static char *defname; /* name of the variable to be defined */ static tree *TreeList; /* list of pointers to the image expressions */ static int treeListSize = 0; static int TopTreeList = 0; static char tempname[80]; /* name of a temp. image variable */ static int inPrintTree = 0; #define lastchar(s) s[strlen(s)-1] /* function prototypes */ void initbuf(int); void extendbuf(int); int is_shape(tree); int is_openshape(tree); int is_graph(tree); static void appendTreeList(tree); tree dtree4(int, tree, tree, tree, tree); tree dtree3(int, tree, tree, tree); tree dtree2(int, tree, tree); tree dtree1(int, tree); tree dtree0(int); int nary(int); void freeTree(tree); tree copyTree(tree); static void dump_str(char *); void dumpdtree(tree); void print_tree(tree expr); void Define(tree expr1, tree expr2); void DefineFunc(int FX, tree expr); #ifdef DISTRIB static int DonaldExprOracleCheck(tree); #endif /* DISTRIB */ static int dumpbufsize = 0; char *dumpbuf = 0; void initbuf(int size) { if (dumpbuf == 0) { dumpbuf = (char *) emalloc(size); dumpbufsize = size; } else if (size > dumpbufsize) { dumpbuf = (char *) erealloc(dumpbuf, size); dumpbufsize = size; } *dumpbuf = '\0'; } void extendbuf(int size) { if (dumpbuf == 0) { dumpbuf = (char *) emalloc(size); dumpbufsize = size; } else if (size > dumpbufsize) { dumpbuf = (char *) erealloc(dumpbuf, size); dumpbufsize = size; } } int is_shape(tree expr) { return expr->type == SHAPE; } int is_openshape(tree expr) { return expr->type == OPENSHAPE; } int is_graph(tree expr) { return expr->type == GRAPH; } static void appendTreeList(tree t) { if (treeListSize == 0) { treeListSize = 4; TreeList = (tree *) emalloc(sizeof(tree) * treeListSize); } else if (TopTreeList == treeListSize) { treeListSize += 4; TreeList = (tree *) erealloc(TreeList, sizeof(tree) * treeListSize); } TreeList[TopTreeList++] = t; } #define clearTreeList() (TopTreeList = 0) /*-------------------------+----------------------------------------+ | dtree0, dtree1, dtree2, dtree3, dtree4 | +----------------------------------------*/ /*----- creat a new tree -----*/ tree dtree4(int op, tree l, tree m, tree r, tree x) /* parallel, left, mid, right and extra children */ { tree ptr; ptr = (tree) getmem(sizeof(node4)); ptr->type = UNDEFINED; ptr->op = op; ptr->left = l; ptr->right = r; ptr->mid = m; ptr->extra = x; return ptr; } tree dtree3(int op, tree l, tree m, tree r) /* if...then...else/rot(,,)/etc. */ /* left, mid and right children */ { tree ptr; ptr = (tree) getmem(sizeof(node3)); ptr->type = UNDEFINED; ptr->op = op; ptr->left = l; ptr->right = r; ptr->mid = m; return ptr; } tree dtree2(int op, tree l, tree r) /* operator: + - * / etc. */ /* left and right children */ { tree ptr; ptr = (tree) getmem(sizeof(node2)); ptr->type = UNDEFINED; ptr->op = op; ptr->left = l; ptr->right = r; return ptr; } tree dtree1(int op, tree l) /* id, inumber, etc. */ /* left child */ { tree ptr; ptr = (tree) getmem(sizeof(node1)); ptr->type = UNDEFINED; ptr->op = op; ptr->left = l; return ptr; } tree dtree0(int op) /* inf */ { tree ptr; ptr = (tree) getmem(sizeof(node0)); ptr->type = UNDEFINED; ptr->op = op; return ptr; } /*---------------------------------------------------+---------+ | trans[] | +---------*/ static struct trans trans[] = TRANSLAT; /*--------------------------------------------+----------------+ | match_operator | +----------------*/ #define match_operator(op, s) \ (s = trans[(int)op].op_str, trans[(int)op].order) /*----------------------------------------------------+--------+ | orig[] | +--------*/ static struct trans orig[] = ORIGINAL; /*---------------------------------------+---------------------+ | match_orig_operator | +---------------------*/ #define match_orig_operator(op, s) \ (s = orig[(int)op].op_str, orig[(int)op].order) int nary(int opcode) { switch (trans[opcode].order) { case OP_IMPOSE: case OP_GSPEC: case UNARY: return 1; case BINARY: case INFIX: case OP_GSPECLIST: return 2; case OP_IF: case OP_MONITOR: case TRIARY: return 3; case QUADARY: return 4; default: return 0; } } /*--------------------------------------------------+----------+ | freeTree | +----------*/ /*----- free the memory of a tree -----*/ void freeTree(tree expr) { char *op_string; /* dummy */ switch (match_operator(expr->op, op_string)) { case OP_ID: case OP_EDEN: if (Lexpr) free(Lexpr); case OP_BOOL: case OP_CSTRING: case OP_RNUMBER: case OP_INUMBER: case CONSTANT: break; case QUADARY: freeTree(Xexpr); /* quadary */ case OP_IF: case OP_MONITOR: case TRIARY: freeTree(Mexpr); /* tri-ary */ case OP_SLASH: case INFIX: case BINARY: freeTree(Rexpr); /* binary */ case OP_IMPOSE: case UNARY: case OP_GLOBAL: freeTree(Lexpr); /* unary */ break; case OP_GSPECLIST: if (Lexpr) { freeTree(Lexpr); freeTree(Rexpr); } break; case OP_GSPEC: if (Lexpr) freeTree(Lexpr); break; case OP_IMGFUNC: case OP_FUNC: if (Lexpr) free(Lexpr); if (Rexpr) freeTree(Rexpr); break; default: don_err(Impossible, "free_tree"); break; } free(expr); /* free itself */ } #define Value(x) ((node0*)x)->d /*--------------------------------------------------+----------+ | copyTree | +----------*/ /*----- copy a tree -----*/ tree copyTree(tree expr) { tree t; char *op_string; /* dummy */ if (expr == 0) return 0; switch (match_operator(expr->op, op_string)) { case OP_ID: case OP_EDEN: t = dtree1(expr->op, (tree) (Lexpr ? strdup((char *) Lexpr) : 0)); t->type = expr->type; break; case OP_BOOL: case OP_CSTRING: case OP_RNUMBER: case OP_INUMBER: case CONSTANT: t = dtree0(expr->op); t->type = expr->type; Value(t) = Value(expr); break; case QUADARY: /* quadary */ t = dtree4(expr->op, copyTree(Lexpr), copyTree(Mexpr), copyTree(Rexpr), copyTree(expr->extra)); t->type = expr->type; break; case OP_IF: case OP_MONITOR: case TRIARY: /* tri-ary */ t = dtree3(expr->op, copyTree(Lexpr), copyTree(Mexpr), copyTree(Rexpr)); t->type = expr->type; break; case INFIX: case BINARY: /* binary */ case OP_SLASH: case OP_GSPECLIST: t = dtree2(expr->op, copyTree(Lexpr), copyTree(Rexpr)); t->type = expr->type; break; case OP_IMPOSE: case OP_GLOBAL: case UNARY: /* unary */ t = dtree1(expr->op, copyTree(Lexpr)); t->type = expr->type; break; case OP_GSPEC: t = dtree2(expr->op, copyTree(Lexpr), Rexpr); t->type = expr->type; break; case OP_IMGFUNC: case OP_FUNC: t = dtree2(expr->op, (tree) strdup((char *) Lexpr), copyTree(Rexpr)); t->type = expr->type; break; default: don_err(Impossible, "copyTree"); break; } return t; } /*-------------------------------------------------+-----------+ | dumpdtree | +-----------*/ static char Comma[] = ", "; static char Rparen[] = ")"; static void dump_str(char *s) { if ((int) strlen(dumpbuf) + (int) strlen(s) >= dumpbufsize) extendbuf(dumpbufsize + 2048); strcat(dumpbuf, s); } void dumpdtree(tree expr) { int order; char *op_string; char *s, *t; static glevel = 0; if (expr == EMPTYTREE) return; switch (expr->op) { case OP_EDEN: dump_str((char *) Lexpr); dump_str("!"); return; case OP_ID: dump_str(Lexpr ? (char *) Lexpr : "~"); return; case OP_SLASH: dumpdtree(Lexpr); dump_str("/"); dumpdtree(Rexpr); return; case OP_GLOBAL: dump_str("/"); dumpdtree(Lexpr); return; case OP_INUMBER: /* integer number */ sprintf(temp, "%d", Ivalue(expr)); dump_str(temp); return; case OP_RNUMBER: /* real number */ sprintf(temp, "%f", Rvalue(expr)); dump_str(temp); return; case OP_CSTRING: /* character string */ for (s = Cvalue(expr); *s != '\0'; s++) { t = dumpbuf + strlen(dumpbuf); switch (*s) { case '\\': *t++ = '\\'; *t++ = '\\'; *t = '\0'; break; case '"': *t++ = '\\'; *t++ = '"'; *t = '\0'; break; default: *t++ = *s; *t = '\0'; break; } } return; case OP_BOOL: /* boolean value */ sprintf(temp, Bvalue(expr) ? "true" : "false"); dump_str(temp); return; case OP_IMPOSE: /* impose variable */ dump_str("impose "); dumpdtree(Lexpr); return; case OP_IF: /* if .. then .. else .. */ dump_str("if "); dumpdtree(Mexpr); dump_str(" then "); dumpdtree(Lexpr); dump_str(" else "); dumpdtree(Rexpr); return; case OP_MONITOR: dump_str("("); dumpdtree(Mexpr); dump_str(") ? "); dumpdtree(Lexpr); dump_str(" : "); dumpdtree(Rexpr); return; case OP_CART: dump_str("{"); dumpdtree(Lexpr); dump_str(Comma); dumpdtree(Rexpr); dump_str("}"); return; case OP_POLAR: dump_str("{"); dumpdtree(Lexpr); dump_str(" @ "); dumpdtree(Rexpr); dump_str("}"); return; case OP_LINE: if (inPrintTree) dump_str("["); else dump_str("\\["); dumpdtree(Lexpr); dump_str(Comma); dumpdtree(Rexpr); dump_str("]"); return; case OP_ARC: if (inPrintTree) dump_str("["); else dump_str("\\["); dumpdtree(Lexpr); dump_str(Comma); dumpdtree(Mexpr); dump_str(Comma); dumpdtree(Rexpr); dump_str("]"); return; case OP_GSPECLIST: if (Lexpr == 0) { if (inPrintTree) dump_str("[]"); else dump_str("\\[]"); return; } if (glevel == 0) { if (inPrintTree) dump_str("["); else dump_str("\\["); glevel++; dumpdtree(Lexpr); dump_str(";\n\t"); dumpdtree(Rexpr); glevel--; dump_str("]"); } else { dumpdtree(Lexpr); dump_str(";\n\t"); dumpdtree(Rexpr); } return; case OP_GSPEC: if (glevel == 0) { if (inPrintTree) dump_str("["); else dump_str("\\["); glevel++; dump_str(map_token_to_name((int) expr->right)); dump_str(":"); if (Lexpr) dumpdtree(Lexpr); glevel--; dump_str("]"); } else { dump_str(map_token_to_name((int) expr->right)); dump_str(":"); if (Lexpr) dumpdtree(Lexpr); } return; case OP_I: case OP_XI: case OP_FI: case OP_I_1: case OP_XI_1: case OP_FI_1: if (inPrintTree) order = match_operator(expr->op, op_string); else order = match_orig_operator(expr->op, op_string); /* order is not used */ dump_str(op_string); return; case OP_IMGFUNC: dump_str("I!"); dump_str((char *) Lexpr); dump_str("("); dumpdtree(Rexpr); dump_str(")"); return; case OP_FUNC: dump_str((char *) Lexpr); dump_str("!("); dumpdtree(Rexpr); dump_str(")"); return; } /* otherwise, node is operator */ switch (order = match_orig_operator(expr->op, op_string)) { case CONSTANT: dump_str(op_string); return; case UNARY: /* unary operator */ dump_str(op_string); dumpdtree(Lexpr); if (lastchar(op_string) == '(') dump_str(Rparen); return; case POSTFIX: /* unary operator */ dumpdtree(Lexpr); dump_str(op_string); return; case BINARY: /* binary operator */ dump_str(op_string); dumpdtree(Lexpr); dump_str(Comma); dumpdtree(Rexpr); dump_str(Rparen); return; case INFIX: dumpdtree(Lexpr); dump_str(op_string); dumpdtree(Rexpr); return; case TRIARY: /* 3-ary */ dump_str(op_string); dumpdtree(Lexpr); dump_str(Comma); dumpdtree(Mexpr); dump_str(Comma); dumpdtree(Rexpr); dump_str(Rparen); return; case QUADARY: /* 4-ary */ dump_str(op_string); dumpdtree(Lexpr); dump_str(Comma); dumpdtree(Mexpr); dump_str(Comma); dumpdtree(Rexpr); dump_str(Comma); dumpdtree(Xexpr); dump_str(Rparen); return; default: fprintf(stderr, "%d", order); don_err(Impossible, "dumpdtree"); } } /*------------------------------------------------+------------+ | print_tree | +------------*/ #define print_comma() appendEden(", ", dd_script) #define print_rparen() appendEden(")", dd_script) void print_tree(tree expr) { int order; char *op_string; static glevel = 0; if (expr == EMPTYTREE) return; switch (expr->op) { case OP_ID: case OP_SLASH: case OP_GLOBAL: appendEden(expr_to_eden_name(expr), dd_script); return; case OP_INUMBER: /* integer number */ sprintf(temp, "%d", Ivalue(expr)); appendEden(temp, dd_script); return; case OP_RNUMBER: /* real number */ sprintf(temp, "%f", Rvalue(expr)); appendEden(temp, dd_script); return; case OP_EDEN: case OP_CSTRING: /* character string */ appendEden(Cvalue(expr), dd_script); return; case OP_BOOL: /* boolean value */ sprintf(temp, Bvalue(expr) ? "TRUE" : "FALSE"); appendEden(temp, dd_script); return; case OP_IMPOSE: /* impose variable */ appendEden(" impose ", dd_script); print_tree(Lexpr); return; case OP_IF: /* if .. then .. else .. */ case OP_MONITOR: appendEden("(", dd_script); print_tree(Mexpr); appendEden(") ? ", dd_script); print_tree(Lexpr); appendEden(" : ", dd_script); print_tree(Rexpr); return; case OP_GSPECLIST: if (Lexpr == 0) { appendEden("[]", dd_script); return; } if (glevel == 0) { appendEden("[", dd_script); glevel++; print_tree(Lexpr); appendEden(", ", dd_script); print_tree(Rexpr); --glevel; appendEden("]", dd_script); } else { print_tree(Lexpr); appendEden(", ", dd_script); print_tree(Rexpr); } return; case OP_GSPEC: if (glevel == 0) { appendEden("[", dd_script); glevel++; appendEden("\"", dd_script); appendEden(map_token_to_name((int) expr->right), dd_script); appendEden("\", \"", dd_script); if (Lexpr) { initbuf(2048); inPrintTree++; dumpdtree(Lexpr); inPrintTree--; appendEden(dumpbuf, dd_script); } appendEden("\"", dd_script); --glevel; appendEden("]", dd_script); } else { appendEden("\"", dd_script); appendEden(map_token_to_name((int) expr->right), dd_script); appendEden("\", \"", dd_script); if (Lexpr) { initbuf(2048); inPrintTree++; dumpdtree(Lexpr); inPrintTree--; appendEden(dumpbuf, dd_script); } appendEden("\"", dd_script); } return; case OP_IMGFUNC: if (stage == 1) { /* replace the function with a variable */ appendTreeList(expr); sprintf(tempname, "%s_temp%d", defname, TopTreeList); appendEden(tempname, dd_script); return; } /* stage 2 - actually translate the image function */ stage = 1; /* suppress expanding image sub-expressions */ appendEden((char *) Lexpr, dd_script); appendEden("(\"", dd_script); appendEden(tempname, dd_script); appendEden("\", ", dd_script); print_tree(Rexpr); appendEden(")", dd_script); return; case OP_FUNC: appendEden((char *) Lexpr, dd_script); appendEden("(", dd_script); print_tree(Rexpr); appendEden(")", dd_script); return; case OP_LABEL: appendEden(Ltype == IMAGE ? "image(" : "label(", dd_script); print_tree(Lexpr); print_comma(); print_tree(Rexpr); print_rparen(); return; } /* otherwise, node is operator */ switch (order = match_operator(expr->op, op_string)) { case CONSTANT: appendEden(op_string, dd_script); return; case UNARY: /* unary operator */ appendEden(op_string, dd_script); print_tree(Lexpr); if (lastchar(op_string) == '(') print_rparen(); return; case BINARY: /* binary operator */ appendEden(op_string, dd_script); print_tree(Lexpr); print_comma(); print_tree(Rexpr); print_rparen(); return; case INFIX: print_tree(Lexpr); appendEden(op_string, dd_script); print_tree(Rexpr); return; case TRIARY: /* 3-ary */ appendEden(op_string, dd_script); print_tree(Lexpr); print_comma(); print_tree(Mexpr); print_comma(); print_tree(Rexpr); print_rparen(); return; case QUADARY: /* 4-ary */ appendEden(op_string, dd_script); print_tree(Lexpr); print_comma(); print_tree(Mexpr); print_comma(); print_tree(Rexpr); print_comma(); print_tree(Xexpr); print_rparen(); return; default: fprintf(stderr, "%d", order); don_err(Impossible, "print_tree"); } } /*-----------------------------------------------------+--------+ | Define | +--------*/ void Define(tree expr1, tree expr2) { symbol *sym; int start, top, i; #ifdef DISTRIB extern int handle_check1(char *); extern void propagateDonaldDef(char *, char *); extern int withinHandle; #endif /* DISTRIB */ if (expr1 != EMPTYTREE) { switch (expr1->op) { case OP_ID: case OP_SLASH: case OP_GLOBAL: /* DISTRIB: need to check expr1 for handle & expr2 for oracle, and then propagate to others who are allowed to know. */ /* translate */ defname = strdup(expr_to_eden_name(expr1)); #ifdef DISTRIB if (!handle_check1(defname)) return; /* not be allowed to change --sun */ if (!DonaldExprOracleCheck(expr2)) return; /* some variables are not allowed to be observed --sun */ #endif /* DISTRIB */ stage = 1; /* to control the translation process translate image function as a temporary variable */ if (is_shape(expr1) && is_openshape(expr2)) { appendEden(defname, dd_script); appendEden(" is open2shape(", dd_script); print_tree(expr2); appendEden(");\n", dd_script); } else if (expr1->type == expr2->type) { appendEden(defname, dd_script); appendEden(" is ", dd_script); print_tree(expr2); appendEden(";\n", dd_script); } else don_err(IdExprUnmatch, 0); top = 0; do { start = top + 1; top = TopTreeList; for (i = TopTreeList; i >= start; --i) { stage = 2; /* to control the translation process; truly transate the image functions; stage may reset to 1 if the expr contains image subexpressions */ sprintf(tempname, "%s_temp%d", defname, i); appendEden(tempname, dd_script); appendEden(" is ", dd_script); print_tree(TreeList[i - 1]); appendEden(";\n", dd_script); } } while (top != TopTreeList); /* if there are image subexpr */ clearTreeList(); /* update symbol table entry */ sym = look_up_tree(expr1); sym->defn.t = copyTree(expr2); sym->master = topMasterStack(); #ifdef DISTRIB initbuf(2048); /* send DonaldDefinition to others --sun */ dump_str("%donald\n"); sprintf(temp, "%s = ", sym->name); dump_str(temp); inPrintTree++; dumpdtree(sym->defn.t); inPrintTree--; dump_str("\n%eden\n"); /* propagateAgency1(sym->name, dumpbuf); */ if (withinHandle) propagateDonaldDef(eden_full_name(sym->name), dumpbuf); /* appendEden("propagate(\"", dd_script); appendEden(eden_full_name(sym->name), dd_script); appendEden("\", \"", dd_script); appendEden(dumpbuf, dd_script); appendEden("\");\n", dd_script); */ #endif /* DISTRIB */ free(defname); break; case OP_COMMA: Define(expr1->left, expr2->left); Define(expr1->right, expr2->right); break; default: don_err(Impossible, "define"); break; } } } /*-------------------------------------------------+------------+ | DefineFunc | +------------*/ void DefineFunc(int FX, tree expr) /* FX = FI or XI */ { symbol *sym; if (Etype != REAL && Etype != ANY) don_err(IdExprUnmatch, 0); sym = look_up(FX == FI ? "f" : "x"); sym->defn.t = copyTree(expr); sym->master = topMasterStack(); appendEden(eden_full_name(FX == FI ? "_fi_" : "_xi_"), dd_script); appendEden(" = \"", dd_script); initbuf(2048); inPrintTree++; dumpdtree(expr); inPrintTree--; appendEden(dumpbuf, dd_script); appendEden("\";\n", dd_script); } #ifdef DISTRIB static int DonaldExprOracle; /* for agency --sun */ void checkDonaldExprOracle(tree expr) { extern int oracle_check1(char *); int order; char *op_string; static glevel = 0; char *exprName; if (expr == EMPTYTREE) return; switch (expr->op) { case OP_ID: case OP_SLASH: case OP_GLOBAL: exprName = strdup(expr_to_eden_name(expr)); if (!oracle_check1(exprName)) DonaldExprOracle = 0; return; case OP_INUMBER: /* integer number */ case OP_RNUMBER: /* real number */ case OP_EDEN: case OP_CSTRING: /* character string */ case OP_BOOL: /* boolean value */ return; case OP_IMPOSE: /* impose variable */ checkDonaldExprOracle(Lexpr); return; case OP_IF: /* if .. then .. else .. */ case OP_MONITOR: checkDonaldExprOracle(Mexpr); checkDonaldExprOracle(Lexpr); checkDonaldExprOracle(Rexpr); return; case OP_GSPECLIST: if (Lexpr == 0) { return; } if (glevel == 0) { glevel++; checkDonaldExprOracle(Lexpr); checkDonaldExprOracle(Rexpr); --glevel; } else { checkDonaldExprOracle(Lexpr); checkDonaldExprOracle(Rexpr); } return; case OP_GSPEC: if (glevel == 0) { glevel++; if (Lexpr) { checkDonaldExprOracle(Lexpr); } --glevel; } else { if (Lexpr) { checkDonaldExprOracle(Lexpr); } } return; case OP_IMGFUNC: if (stage == 1) { /* replace the function with a variable */ return; } /* stage 2 - actually translate the image function */ stage = 1; /* suppress expanding image sub-expressions */ checkDonaldExprOracle(Rexpr); return; case OP_FUNC: checkDonaldExprOracle(Rexpr); return; case OP_CART: case OP_POLAR: case OP_LINE: case OP_LABEL: checkDonaldExprOracle(Lexpr); checkDonaldExprOracle(Rexpr); return; case OP_ARC: checkDonaldExprOracle(Lexpr); checkDonaldExprOracle(Mexpr); checkDonaldExprOracle(Rexpr); return; } /* otherwise, node is operator */ switch (order = match_operator(expr->op, op_string)) { case CONSTANT: return; case UNARY: /* unary operator */ checkDonaldExprOracle(Lexpr); return; case BINARY: /* binary operator */ checkDonaldExprOracle(Lexpr); checkDonaldExprOracle(Rexpr); return; case INFIX: checkDonaldExprOracle(Lexpr); checkDonaldExprOracle(Rexpr); return; case TRIARY: /* 3-ary */ checkDonaldExprOracle(Lexpr); checkDonaldExprOracle(Mexpr); checkDonaldExprOracle(Rexpr); return; case QUADARY: /* 4-ary */ checkDonaldExprOracle(Lexpr); checkDonaldExprOracle(Mexpr); checkDonaldExprOracle(Rexpr); checkDonaldExprOracle(Xexpr); return; default: fprintf(stderr, "%d", order); don_err(Impossible, "print_tree"); } } static int DonaldExprOracleCheck(tree expr) { DonaldExprOracle = 1; checkDonaldExprOracle(expr); return DonaldExprOracle; } #endif /* DISTRIB */ */ appendEden(" impose ", dd_script); print_tree(tkeden1.18/Donald/symbol.h010060000025250000147000000012210727406556200167370ustar00ashleydcsother00003470000356/* * $Id: symbol.h,v 1.4 1999/11/16 21:20:40 ashley Rel1.10 $ */ struct symbol { char *name; /* symbol name */ char *viewport; /* symbol viewport */ char *master; /* who change this symbol last */ union { tree t; /* symbol definition */ char *f; /* graph function name */ } defn; /* symbol definition */ int type; /* symbol type */ struct symbol *derived; /* sub-directory */ struct symbol *next; /* next symbol entry */ }; typedef struct symbol symbol; extern symbol *SymbolTable; #define UNDEFINED 0 #define SymEnd (symbol*)0 extern char *topMasterStack(); tkeden1.18/Donald/symbol.c010060000025250000147000001027100731247305000167230ustar00ashleydcsother00003470000356/* * $Id: symbol.c,v 1.12 1999/11/16 21:20:40 ashley Rel1.10 $ */ /* This handles the encoding of Donald definitions in Eden [Ash, with Sun] */ static char rcsid[] = "$Id: symbol.c,v 1.12 1999/11/16 21:20:40 ashley Rel1.10 $"; #include #include #include #include #include "../config.h" #include "error.h" #include "tree.h" #include "symbol.h" #include "oper.h" #include "parser.h" #include "../EX/script.h" #include "../Eden/emalloc.h" #ifdef HAVE_DMALLOC #include #endif extern Tcl_Interp *interp; extern void *getmem(int); extern char *map_token_to_name(int); #ifdef DISTRIB extern void propagateDonaldDef(char *, char *); extern int handle_check1(char *); extern int withinHandle; #endif /* DISTRIB */ /* Code for debugging appendEden(char *s, Script *d) { appendEden(s, d); printf("%s", s); } */ Script *dd_script; static char temp[256]; /* maximum number of openshapes */ #define MAXCONTEXT 128 int _changed = 0; /* to prevent multiple redefinition of _ on e.g. int i,j */ static symbol *GlobalSymbols = SymEnd; static struct c { symbol *sym; symbol **table; } context[MAXCONTEXT] = { { SymEnd, &GlobalSymbols }, { 0, 0 } }; /* to do with monitor, now obsolete struct d { char *name; struct d *next; } *MonTable = (struct d *) 0; */ #define PARENT 0 #define SymbolTable *context[indx].table static struct c NORMAL = {SymEnd}; static int indx = 0; /* always points at the toppest context */ static int backindx = 0; /* always points at the toppest backcontext */ static struct c backcontext[MAXCONTEXT]; /* contains what change of context should takes when resume_context() */ char viewport_name[64]; /* function prototypes */ void change_prompt(void); void change_context(symbol *); void resume_context(void); int reset_context(void); void backup_context(void); void restore_context(void); static void change_scope2(tree); void change_scope(tree); void resume_scope(void); symbol *symbol_search(char *); symbol *context_search(char *); symbol *new_symbol(char *); void free_symbol(symbol *); symbol *look_up(char *); symbol *look_up_tree(tree); symbol *look_prev(char *); void declare_openshape(void); void declare_action(char *, char *, char *); void eden_delete(symbol *, char *); void eden_declare(char *, int, char *); void Declare(int, tree); void DeclareGraph(tree); void Delete(tree); void print_symbol_table(int, symbol *); void print_all_symbols(void); char *donald_full_name(char *); char *eden_full_name(char *); char *expr_to_donald_name(tree); char *expr_to_eden_name(tree); #ifdef DISTRIB int isGraph = 0; /* variables of graph do not be propagated, because we don't understand how the Donald graph function works! [Ash, with Sun] */ #endif /* DISTRIB */ static int isGraphAttr(char *); static void indent(int); static void insert_nl(void); static void dumpDonaldDeclaration(int, symbol *, int); static void dumpDonaldDefinition(int, symbol *); int dumpdonald(void); /*---------------------------------------------+---------------+ | change_prompt | +---------------*/ void change_prompt(void) { /* set dd_prompt to the current context */ extern char *dd_prompt; char *s; char *t; int i; int len; int prompt_len; prompt_len = strlen(dd_prompt); for (len = 0, i = 1; i <= indx; i++, len += strlen(t)) { t = context[i].sym->name; } if (prompt_len < len + 3 + indx) { dd_prompt = (char *) erealloc(dd_prompt, prompt_len + len + 3 + indx); } s = dd_prompt; strcpy(s, "["); s += 1; for (i = 1; i <= indx; i++) { t = context[i].sym->name; len = strlen(t); *s++ = '/'; strcpy(s, t); s += len; } if (indx) strcpy(s, "]"); else strcpy(s, "/]"); } /*--------------------------------------------+----------------+ | change_context | +----------------*/ void change_context(symbol * sym) { /* change context to sym */ if (sym == SymEnd) { /* ~ */ if (backindx > MAXCONTEXT) don_err(StackOverflow, "context "); backcontext[backindx++] = context[indx]; if (indx == 0) don_err(StackUnderflow, "context "); else --indx; } else { if (backindx > MAXCONTEXT) don_err(StackOverflow, "context "); backcontext[backindx++] = NORMAL; if (indx++ >= MAXCONTEXT) don_err(StackOverflow, "context "); context[indx].sym = sym; context[indx].table = &sym->derived; } } /*--------------------------------------------+----------------+ | resume_context | +----------------*/ void resume_context(void) { struct c cnt; if (backindx <= 0) don_err(StackUnderflow, "context "); cnt = backcontext[--backindx]; if (cnt.sym == SymEnd) { if (indx == 0) don_err(StackUnderflow, "context "); else --indx; } else { if (indx++ >= MAXCONTEXT) don_err(StackOverflow, "context "); context[indx] = cnt; } } /*---------------------------------------------+---------------+ | reset_context | +---------------*/ int reset_context(void) { /* cd root */ int ix = indx; indx = 0; /* root */ backindx = 0; return ix; } static int MaxBackupContext = 0; static int backupContextSize = 0; static struct c *backupContext = 0; static int MaxBackupIndx = 0; static int backupIndxSize = 0; static int *backupIndx = 0; /*--------------------------------------------+----------------+ | backup_context | +----------------*/ void backup_context(void) { int i; if (backupContext == 0) { backupContext = (struct c *) emalloc(sizeof(struct c) * (backindx + indx + 1)); MaxBackupContext = backindx + indx + 1; } else if (MaxBackupContext < backupContextSize + backindx + indx + 1) { backupContext = (struct c *) erealloc(backupContext, sizeof(struct c) * (backupContextSize + backindx + indx + 1)); MaxBackupContext = backupContextSize + backindx + indx + 1; } if (backupIndx == 0) { backupIndx = (int *) emalloc(sizeof(int) * 2); MaxBackupIndx = 2; } else if (MaxBackupIndx < backupIndxSize + 2) { backupIndx = (int *) erealloc(backupIndx, sizeof(int) * (backupIndxSize + 2)); MaxBackupIndx = backupIndxSize + 2; } for (i = 0; i <= indx; i++) backupContext[backupContextSize + i] = context[i]; backupIndx[backupIndxSize++] = indx; for (i = 0; i < backindx; i++) backupContext[backupContextSize + indx + 1 + i] = backcontext[i]; backupIndx[backupIndxSize++] = backindx; backupContextSize += indx + 1 + backindx; } /*-------------------------------------------+-----------------+ | restore_context | +-----------------*/ void restore_context(void) { int i; for (i = (backindx = backupIndx[--backupIndxSize]) - 1; i >= 0; --i) backcontext[i] = backupContext[--backupContextSize]; for (i = (indx = backupIndx[--backupIndxSize]); i >= 0; --i) context[i] = backupContext[--backupContextSize]; } /*---------------------------------------------+---------------+ | change_scope2 | +---------------*/ /* actually change the scope, called by change_scope */ static void change_scope2(tree expr) { /* int ix = indx; */ switch (expr->op) { case OP_ID: change_context(context_search((char *) Lexpr)); break; case OP_SLASH: change_context(context_search((char *) Lexpr->left)); change_scope2(Rexpr); break; case OP_GLOBAL: reset_context(); change_scope2(Lexpr); break; default: restore_context(); don_err(Impossible, "change_scope"); } } /*----------------------------------------------+--------------+ | change_scope | +--------------*/ void change_scope(tree expr) { backup_context(); change_scope2(expr); } /*----------------------------------------------+--------------+ | resume_scope | +--------------*/ void resume_scope(void) { restore_context(); } /*---------------------------------------------+---------------+ | symbol_search | +---------------*/ symbol * symbol_search(char *name) { symbol *sym; if (!(sym = look_up(name))) don_err(UndeclareID, donald_full_name(name)); return sym; } /*--------------------------------------------+----------------+ | context_search | +----------------*/ symbol * context_search(char *name) { symbol *sym; if (name == PARENT) return SymEnd; if (!(sym = look_up(name))) don_err(UndeclareID, donald_full_name(name)); if (sym->type != OPENSHAPE && sym->type != GRAPH) don_err(NotOpenshapeOrGraph, donald_full_name(name)); return sym; } /*------------------------------------------------+------------+ | new_symbol | +------------*/ symbol * new_symbol(char *name) { /* creat a new symbol in current context */ symbol *sym; /* Make sure it is new */ sym = (symbol *) getmem(sizeof(symbol)); sym->name = name; sym->type = UNDEFINED; /* not defined */ sym->defn.t = 0; /* not defined */ sym->master = topMasterStack(); sym->derived = SymEnd; sym->next = SymbolTable; return SymbolTable = sym; } /*-----------------------------------------------+-------------+ | free_symbol | +-------------*/ void free_symbol(symbol * sym) { /* free the storage occupied by sym */ extern void freeTree(tree); if (sym->name) free(sym->name); if (sym->viewport) free(sym->viewport); if (sym->defn.t && sym->type != GRAPH) freeTree(sym->defn.t); free(sym); } /* to do with monitor, now obsolete |*------------------------------------------------+------------+ | mon_symbol | +------------*| void mon_symbol(char *name) |* creat a new symbol in current context *| { struct d *d; |* Make sure it is new *| d = (struct d *) getmem(sizeof(struct d)); d->name = name; d->next = MonTable; MonTable = d; } */ /*---------------------------------------------------+---------+ | look_up | +---------*/ symbol * look_up(char *name) { /* look up the symbol in current context */ symbol *sym; for (sym = SymbolTable; sym != SymEnd; sym = sym->next) { if (strcmp(sym->name, name) == 0) break; /* found */ } return sym; /* sym == SymEnd if not found */ } /*----------------------------------------------+--------------+ | look_up_tree | +--------------*/ symbol * look_up_tree(tree expr) { /* look up the symbol in current context */ symbol *sym; int count; if (expr->op == OP_GLOBAL) { backup_context(); reset_context(); sym = look_up_tree(Lexpr); restore_context(); return sym; } for (count = 0; expr->op == OP_SLASH; count++, expr = Rexpr) change_context(context_search((char *) Lexpr->left)); /* Now, expr->op should be OP_ID */ for (sym = SymbolTable; sym != SymEnd; sym = sym->next) { if (Lexpr && strcmp(sym->name, (char *) Lexpr) == 0) break; /* found */ } while (count--) resume_context(); return sym; /* sym == SymEnd if not found */ } /*---------------------------------------------------+-----------+ | look_prev | +-----------*/ symbol * look_prev(char *name) { /* look up the symbol before name in current context */ symbol *sym, *sym_prev; sym_prev = SymEnd; for (sym = SymbolTable; sym != SymEnd; sym = sym->next) { if (strcmp(sym->name, name) == 0) break; /* found */ sym_prev = sym; } return sym_prev; /* sym == SymEnd if not found */ } static char x_default_graph[] = "SetGraph(\"%s\",\"%s\"); %s_viewport = \"%s\";\n"; #define declare_graph(id, did, vp) \ sprintf(temp, x_default_graph, id, did, id, vp);\ appendEden(temp, dd_script); /*------------------------------------------+-------------------+ | declare_openshape | +-------------------*/ /* sym is [ OPENSHAPE, sym/a, sym/b, ... ] */ void declare_openshape(void) { symbol *s; /*----- print the context name -----*/ /* indx == 0 --> root */ sprintf(temp, "%s is [ OPENSHAPE", indx ? eden_full_name(0) : "_"); appendEden(temp, dd_script); s = indx ? context[indx].sym->derived : *context[0].table; for (; s != SymEnd; s = s->next) { if (strcmp(s->name, "x") == 0) { /* printf("xi = %s", s->name); */ sprintf(temp, ", &%s", eden_full_name("_xi_")); } else if (strcmp(s->name, "f") == 0) { /* printf("fi = %s", s->name); */ sprintf(temp, ", &%s", eden_full_name("_fi_")); } else { /* printf("wwi = %s", s->name); */ sprintf(temp, ", &%s", eden_full_name(s->name)); } appendEden(temp, dd_script); } appendEden(" ];\n", dd_script); } /*-----------------------------------------------+--------------+ | eden_declare | +--------------*/ static char x_default_attr[] = "A%s = NullStr;\n"; static char x_draw_act[] = "proc P%s:%s, A%s, %s\n{\n\t%s(%s, &%s, &A%s);\n}\n"; #define declare_attribute(id) \ sprintf(temp, x_default_attr, id);\ appendEden(temp, dd_script); void declare_action(char *id, char *proc_name, char *vp) /* viewport name */ { if (!*vp) { strcpy(viewport_name, "DoNaLD"); vp = "DoNaLD"; appendEden("InitDoNaLDViewport();\n", dd_script); } sprintf(temp, x_draw_act, id, id, id, vp, proc_name, vp, id, id); appendEden(temp, dd_script); } static char x_delete_attr[] = "A%s = @; forget(\"A%s\");\n"; static char x_delete_act[] = "forget(\"P%s\");\ndd_delete(&%s,&%s,&A%s);\n"; static char x_delete_openshape[] = "%s = @; forget(\"%s\");\n"; static char x_delete_graph[] = "forget(\"P%s\");\n"; #define delete_attribute(id) \ sprintf(temp, x_delete_attr, id, id);\ appendEden(temp, dd_script); #define delete_action(id, vp) \ sprintf(temp, x_delete_act, id, id, vp, id);\ appendEden(temp, dd_script); #define delete_openshape(id) \ sprintf(temp, x_delete_openshape, id, id);\ appendEden(temp, dd_script); #define delete_graph(id) \ sprintf(temp, x_delete_graph, id);\ appendEden(temp, dd_script); void eden_delete(symbol * sym, char *vp) /* vp - viewport name */ { symbol *s; char *id = eden_full_name(sym->name); switch (sym->type) { case POINT: case LINE: case ARC: case CIRCLE: case RECTANGLE: case ELLIPSE: case LABEL: case SHAPE: delete_action(id, vp); delete_attribute(id); break; case GRAPH: delete_graph(id); case OPENSHAPE: change_context(sym); s = indx ? context[indx].sym->derived : *context[0].table; for (; s != SymEnd; s = s->next) { eden_delete(s, vp); SymbolTable = s->next; free_symbol(s); } resume_context(); delete_openshape(eden_full_name(sym->name)); break; case VIEWPORT: break; } _changed++; } void eden_declare(char *id, int type, char *vp) /* vp - viewport name */ { /* printf("eden_declare %s %i %s \n ", id, type, vp); */ switch (type) { case POINT: declare_attribute(id); declare_action(id, "plot_point", vp); break; case LINE: declare_attribute(id); declare_action(id, "plot_line", vp); break; case ARC: declare_attribute(id); declare_action(id, "plot_arc", vp); break; case CIRCLE: declare_attribute(id); declare_action(id, "plot_circle", vp); break; case RECTANGLE: declare_attribute(id); declare_action(id, "plot_rectangle", vp); break; case ELLIPSE: declare_attribute(id); declare_action(id, "plot_ellipse", vp); break; case LABEL: declare_attribute(id); declare_action(id, "plot_label", vp); break; case SHAPE: declare_attribute(id); declare_action(id, "plot_shape", vp); break; #ifdef DISTRIB /* case INT: case REAL: case BOOLEAN: case MYCHAR: sprintf(temp, "%s = @;\n", id); appendEden(temp, dd_script); break; */ /* this block will cause declaration becomes definition. In other words, variable's value will be changed and affect other variables due to dependency */ #endif /* DISTRIB */ case OPENSHAPE: case GRAPH: break; case VIEWPORT: #ifdef DISTRIB if (handle_check1((char *) id)) { /* declare is allowed */ if (!*viewport_name && !strcmp((char *) id, "DoNaLD")) { appendEden("InitDoNaLDViewport();\n", dd_script); } strcpy(viewport_name, (char *) id); if (withinHandle > 0) { /* excluding Within clause */ sprintf(temp, "%%donald\nviewport %s\n%%eden\n", (char *) id); propagateDonaldDef((char *) id, temp); } } #else if (!*viewport_name && !strcmp((char *) id, "DoNaLD")) { appendEden("InitDoNaLDViewport();\n", dd_script); } strcpy(viewport_name, (char *) id); #endif /* DISTRIB */ break; } _changed++; } /*---------------------------------------------------+---------+ | Declare | +---------*/ void Declare(int type, tree expr) { /* declare variables, only to Donald not to Eden */ /* type - type of variable */ /* expr - identifier expr(-list) */ symbol *sym; int dc; /* degree of changes */ if (expr != EMPTYTREE) { switch (expr->op) { case OP_ID: #ifdef DISTRIB if (handle_check1(eden_full_name((char *) Lexpr))) { /* declare is allowed */ #endif /* DISTRIB */ sym = look_up((char *) Lexpr); if (sym == SymEnd) { sym = new_symbol((char *) Lexpr); } else if (sym->type != type) { don_err(RedeclareID, donald_full_name((char *) Lexpr)); } sym->type = type; /* can redeclare the same variable to a new viewport only if it is of the same type */ eden_declare(eden_full_name((char *) Lexpr), type, viewport_name); sym->viewport = strdup(viewport_name); #ifdef DISTRIB if (sym != SymEnd && withinHandle > 0 && !isGraph) { /* send donaldDeclaration to others, but not graph */ sprintf(temp, "%%donald\n%s %s\n%%eden\n", map_token_to_name(sym->type), sym->name); propagateDonaldDef(eden_full_name(sym->name), temp); } } #endif /* DISTRIB */ break; case OP_SLASH: change_context(context_search((char *) Lexpr->left)); dc = _changed; Declare(type, Rexpr); if (_changed > dc) { declare_openshape(); /* take special care on context change */ _changed = dc; } resume_context(); break; case OP_GLOBAL: backup_context(); reset_context(); dc = _changed; Declare(type, Lexpr); if (_changed > dc) { declare_openshape(); /* take special care on context change */ _changed = dc; } restore_context(); break; case OP_COMMA: Declare(type, Lexpr); Declare(type, Rexpr); break; default: don_err(IdListExpect, 0); break; } } } /*----------------------------------------------+--------------+ | DeclareGraph | +--------------*/ void DeclareGraph(tree expr) { /* declare variables */ /* identifier expr(-list) */ symbol *sym; int dc; /* degree of changes */ tree t; if (expr != EMPTYTREE) { switch (expr->op) { case OP_ID: #ifdef DISTRIB if (handle_check1(eden_full_name((char *) Lexpr))) { /* declare is allowed */ #endif /* DISTRIB */ sym = look_up((char *) Lexpr); if (sym == SymEnd) { sym = new_symbol((char *) Lexpr); } else if (sym->type != GRAPH) { don_err(RedeclareID, donald_full_name((char *) Lexpr)); } sym->type = GRAPH; /* can redeclare the same variable to a new viewport only if it is of the same type */ declare_graph(eden_full_name((char *) Lexpr), donald_full_name((char *) Lexpr), (*viewport_name == '\0') ? "DoNaLD" : viewport_name); sym->viewport = strdup(viewport_name); #ifdef DISTRIB if (sym != SymEnd && withinHandle > 0) { /* send donaldDeclaration to others */ sprintf(temp, "%%donald\n%s %s\n%%eden\n", map_token_to_name(sym->type), sym->name); propagateDonaldDef(eden_full_name(sym->name), temp); } #endif /* DISTRIB */ /* sym->defn.f = f; */ /* declare variables of graph */ #ifdef DISTRIB /* these variable should not be propagated */ isGraph = 1; #endif /* DISTRIB */ change_context(sym); t = dtree1(OP_ID, (tree) "nSegment"); Declare(INT, t); t->left = (tree) "x"; Declare(REAL, t); t->left = (tree) "f"; Declare(REAL, t); t->left = (tree) "node"; Declare(GSPEC, t); t->left = (tree) "segment"; Declare(GSPEC, t); t->left = (tree) "viewport"; Declare(MYCHAR, t); free(t); resume_context(); #ifdef DISTRIB isGraph = 0; } #endif /* DISTRIB */ break; case OP_SLASH: change_context(context_search((char *) Lexpr->left)); dc = _changed; DeclareGraph(Rexpr); if (_changed > dc) { declare_openshape(); /* take special care on context change */ _changed = dc; } resume_context(); break; case OP_GLOBAL: backup_context(); reset_context(); dc = _changed; DeclareGraph(Lexpr); if (_changed > dc) { declare_openshape(); /* take special care on context change */ _changed = dc; } restore_context(); break; case OP_COMMA: DeclareGraph(Lexpr); DeclareGraph(Rexpr); break; default: don_err(IdListExpect, 0); break; } } } /* to do with monitor, now obsolete |*---------------------------------------------------+----------+ | declare2 | +----------*| void declare2(int type, tree expr) |* declare variables *| |* type - type of variable *| |* expr - identifier expr(-list) *| { symbol *sym; if (expr != EMPTYTREE) { switch (expr->op) { case OP_ID: if (!look_up(Lexpr)) { sym = new_symbol(Lexpr); sym->type = type; eden_declare(eden_full_name(Lexpr), type); mon_symbol(Lexpr); mon_declare(); } break; case OP_SLASH: change_context(context_search(Lexpr->left)); Declare(type, Rexpr); resume_context(); break; case OP_GLOBAL: backup_context(); reset_context(); Declare(type, Lexpr); restore_context(); break; case OP_COMMA: Declare(type, Lexpr); Declare(type, Rexpr); break; default: don_err(IdListExpect, 0); break; } } } */ /*---------------------------------------------------+--------+ | Delete | +--------*/ void Delete(tree expr) { /* Delete variables */ /* expr - identifier expr(-list) */ symbol *sym, *sym_prev; int dc; /* degree of changes */ if (expr != EMPTYTREE) { switch (expr->op) { case OP_ID: if ((sym = look_up((char *) Lexpr)) == 0) don_err(UndeclareID, donald_full_name((char *) Lexpr)); eden_delete(sym, viewport_name); sym_prev = look_prev((char *) Lexpr); if (sym_prev == SymEnd) SymbolTable = sym->next; else sym_prev->next = sym->next; free_symbol(sym); break; case OP_SLASH: change_context(context_search((char *) Lexpr->left)); dc = _changed; Delete(Rexpr); if (_changed > dc) { declare_openshape(); /* take special care on context change */ _changed = dc; } resume_context(); break; case OP_GLOBAL: backup_context(); reset_context(); Delete(Lexpr); restore_context(); break; case OP_COMMA: Delete(Lexpr); Delete(Rexpr); break; default: don_err(IdListExpect, 0); break; } } } /* to do with monitor, now obsolete |*------------------------------------------+-------------------+ | mon_declare | +-------------------*| |* sym is [ OPENSHAPE, sym/a, sym/b, ... ] *| void mon_declare(void) { struct d *s; |*----- print the context name -----*| |* indx == 0 --> root *| appendEden("_monmesg is [ ", dd_script); for (s = MonTable; s != (struct d *) 0; s = s->next) { if (s->next == NULL) sprintf(temp, " &_%s", s->name); else sprintf(temp, " &_%s,", s->name); appendEden(temp, dd_script); } appendEden(" ];\n", dd_script); } */ /*-----------------------------------------+--------------------+ | print_symbol_table | +--------------------*/ void print_symbol_table(int level, symbol * symtab) { symbol *sym; int i; for (sym = symtab; sym != SymEnd; sym = sym->next) { for (i = level; i; --i) fprintf(stderr, "| "); fprintf(stderr, "%s %d\n", sym->name, sym->type); if (sym->type == OPENSHAPE || sym->type == GRAPH) print_symbol_table(level + 1, sym->derived); } } /*------------------------------------------+-------------------+ | print_all_symbols | +-------------------*/ void print_all_symbols(void) { fprintf(stderr, "Symbol Table :-\n"); print_symbol_table(0, *context[0].table); fprintf(stderr, "Symbol Table End.\n"); } /*-------------------------------------------+------------------+ | donald_full_name | +------------------*/ char * donald_full_name(char *id) { static char name[256]; char *s = name; char *t; int i; int len; int id_len; id_len = id ? strlen(id) + 2 : 1; *s++ = '/'; for (i = 1; i <= indx; i++) { t = context[i].sym->name; len = strlen(t); if (&name[256] - s < id_len + len) don_err(Unclassified, "variable name too long"); strcpy(s, t); s += len; *s++ = '/'; } strcpy(s, id); return name; } /*---------------------------------------------+----------------+ | eden_full_name | +----------------*/ char * eden_full_name(char *id) { static char name[256]; char *s = name; char *t; int i; int len; int id_len; /* if (id == 0) ==> context name */ id_len = id ? strlen(id) + 2 : 0; for (i = 1; i <= indx; i++) { t = context[i].sym->name; /* printf("eden name %s %i", t, i); */ len = strlen(t); if (&name[256] - s < id_len + len) don_err(Unclassified, "variable name too long"); *s++ = '_'; #ifdef DISTRIB /* if (i==1 && !inPrefix) { len = strlen(t) -strlen(agentName); strncat(s, t, len); } else */ #endif /* DISTRIB */ strcpy(s, t); s += len; } if (id) { *s++ = '_'; strcpy(s, id); } return name; } /*----------------------------------------+---------------------+ | expr_to_donald_name | +---------------------*/ static char expr_name[256]; char * expr_to_donald_name(tree expr) /* turn an id-expr into a string */ { /* assume expr was checked */ *expr_name = '\0'; if (expr->op == OP_GLOBAL) { strcat(expr_name, "/"); expr = Lexpr; } for (; expr->op == OP_SLASH; expr = Rexpr) { strcat(expr_name, Lexpr->left ? (char *) Lexpr->left : "~"); strcat(expr_name, "/"); } strcat(expr_name, (char *) Lexpr); return expr_name; } /*------------------------------------------+-------------------+ | expr_to_eden_name | +-------------------*/ /* not very sophisticated, can't handle global id with ~ */ char * expr_to_eden_name(tree expr) /* turn an id-expr into a string */ { /* assume expr was checked */ tree e; int count; char *name; if (expr->op == OP_GLOBAL) { backup_context(); reset_context(); name = expr_to_eden_name(Lexpr); restore_context(); return name; } for (count = 0, e = expr; e->op == OP_SLASH; count++, e = e->right) change_context(context_search((char *) e->left->left)); /* Now, e->op should be OP_ID */ name = eden_full_name((char *) e->left); while (count--) resume_context(); return name; } /*-------------------------------------------------+------------+ | dumpdonald | +------------*/ static int isGraphAttr(char *name) { return !(strcmp(name, "nSegment") && strcmp(name, "f") && strcmp(name, "x") && strcmp(name, "node") && strcmp(name, "segment") && strcmp(name, "viewport")); } static void indent(int level) { while (level--) Tcl_EvalEC(interp, ".donald.t.text insert end { }"); } static void insert_nl(void) { Tcl_EvalEC(interp, ".donald.t.text insert end {\n}"); } static char *lastmaster; static char *lastvp; static int lasttype, neednl; static void dumpDonaldDeclaration(int level, symbol * symtab, int isGraph) { symbol *sym; extern char *map_token_to_name(int); for (sym = symtab; sym != SymEnd; sym = sym->next) { if (isGraph && isGraphAttr(sym->name)) continue; if (*sym->viewport == '\0') sym->viewport = strdup("DoNaLD"); if ((lastvp == 0 || strcmp(lastvp, sym->viewport)) && !(lastvp == 0 && strcmp("DoNaLD", sym->viewport) == 0)) { lasttype = 0; if (neednl) { insert_nl(); indent(level); } Tcl_VarEval(interp, ".donald.t.text insert end {viewport ", sym->viewport, "\n} viewport", 0); neednl = 0; lastvp = sym->viewport; } if (lasttype == sym->type && sym->type != GRAPH) { Tcl_VarEval(interp, ".donald.t.text insert end {, ", sym->name, "}", 0); neednl = 1; } else { if (neednl) { insert_nl(); neednl = 0; } indent(level); Tcl_VarEval(interp, ".donald.t.text insert end {", map_token_to_name(sym->type), " ", sym->name, "}", 0); neednl = 1; lasttype = sym->type; } if (sym->type == OPENSHAPE || sym->type == GRAPH) { insert_nl(); indent(level); neednl = 0; lasttype = 0; Tcl_VarEval(interp, ".donald.t.text insert end \"within ", sym->name, " {\\n\"", 0); dumpDonaldDeclaration(level + 1, sym->derived, sym->type == GRAPH); if (neednl) insert_nl(); indent(level); Tcl_EvalEC(interp, ".donald.t.text insert end \"}\\n\""); neednl = 0; lasttype = 0; } } } static void dumpDonaldDefinition(int level, symbol * symtab) { symbol *sym; extern char *dumpbuf; extern void initbuf(int); extern void dumpdtree(tree); for (sym = symtab; sym != SymEnd; sym = sym->next) { if (lastmaster == 0 || strcmp(lastmaster, sym->master)) { Tcl_VarEval(interp, ".donald.t.text insert end {AGENT ", sym->master, "\n} master", 0); lastmaster = sym->master; } if (sym->type == OPENSHAPE || sym->type == GRAPH) { indent(level); Tcl_VarEval(interp, ".donald.t.text insert end \"within ", sym->name, " {\\n\"", 0); dumpDonaldDefinition(level + 1, sym->derived); indent(level); Tcl_EvalEC(interp, ".donald.t.text insert end \"}\\n\""); } else if (sym->defn.t) { indent(level); Tcl_VarEval(interp, ".donald.t.text insert end {", sym->name, " = }", 0); initbuf(2048); /* initialize dumpbuf */ dumpdtree(sym->defn.t); Tcl_VarEval(interp, ".donald.t.text insert end \"", dumpbuf, "\"", 0); insert_nl(); } } } int dumpdonald(void) { Tcl_EvalEC(interp, "cleanup donald"); Tcl_EvalEC(interp, ".donald.t.text config -state normal"); /* dump type declarations */ lastvp = 0; lasttype = 0; neednl = 0; dumpDonaldDeclaration(0, GlobalSymbols, 0); if (neednl) insert_nl(); insert_nl(); /* dump variable definitions */ lastmaster = 0; dumpDonaldDefinition(0, GlobalSymbols); Tcl_EvalEC(interp, ".donald.t.text mark set insert 1.0"); Tcl_EvalEC(interp, ".donald.t.text see insert"); Tcl_EvalEC(interp, ".donald.t.text config -state disabled"); return TCL_OK; } case OP_SLASH: change_context(context_search(Lexpr-tkeden1.18/Donald/parser.y010060000025250000147000000434130731441570200167460ustar00ashleydcsother00003470000356%{ /* * $Id: parser.y,v 1.13 1999/11/16 21:20:40 ashley Rel1.10 $ */ /* This is from the Autoconf manual. Note the pragma directive is indented so that pre-ANSI C compilers will ignore it. [Ash] */ /* AIX requires this to be the first thing in the file */ #ifdef __GNUC__ # define alloca __builtin_alloca #else # if HAVE_ALLOCA_H # include # else # ifdef _AIX #pragma alloca # else # ifndef alloca /* predefined by HP cc +Olibcalls */ char *alloca (); # endif # endif # endif #endif static char rcsid[] = "$Id: parser.y,v 1.13 1999/11/16 21:20:40 ashley Rel1.10 $"; #include "../config.h" #include #include #include #include "tree.h" #include "symbol.h" #include "error.h" #include "../Eden/error.h" #include "oper.h" #include "../EX/script.h" #include "../Eden/emalloc.h" #ifdef HAVE_DMALLOC #include #endif #define YYERROR_VERBOSE 1 #ifdef DEBUG extern int Debug; #define display(a) if (Debug & 16) fprintf(stderr, a) #define display2(a,i) if (Debug & 16) fprintf(stderr, a, i) #endif #ifndef DEBUG #define display(a) /* nothing */ #define display2(a,i) /* nothing */ #endif #define ERROR -1 extern Script *dd_script; extern int _changed; extern void eden_declare(char *, int, char *); extern void declare_openshape(void); extern void Declare(int, tree); extern void DeclareGraph(tree); extern void Define(tree, tree); extern void DefineFunc(int, tree); extern void Delete(tree); extern int reset_context(void); extern void change_scope(tree); extern void resume_scope(void); extern int count_id(tree); extern int count_expr(tree); extern void freeTree(tree); extern void yyerror(char *); extern char *expr_to_donald_name(tree); extern char *expr_to_eden_name(tree); extern char *eden_full_name(char *); static char *withinName; static char temp[256]; extern int dd_appAgentName; #ifdef DISTRIB extern void propagateDonaldDef(char *, char *); /* for agency --sun */ extern int handle_check1(char *); int withinHandle=1; #endif /* DISTRIB */ %} %union { char *s; /* identifier, etc */ int i; /* integer value */ double r; /* floating point value */ tree t; /* expression tree */ } %token INF PI %token I XI FI I_1 XI_1 FI_1 %token IMAGE %token MYCHAR %token REAL %token INT BOOLEAN POINT LABEL GSPEC GSPECLIST ANY %token LINE CIRCLE ELLIPSE SHAPE OPENSHAPE ARC RECTANGLE %token GRAPH OF %token VIEWPORT %token DELETE %token WITHIN %token IF THEN ELSE %token ID IMGFUNC %token CSTRING %token BOOL %token INUMBER %token RNUMBER %token ITOS RTOS %token TRUNC FLOAT %token SQRT SIN COS TAN ASIN ACOS ATAN LOG EXP RANDOM %token ROT SCALE TRANS %token INTERSECT %token PARALLEL PERPEND DISTANCE %token MIDPOINT PT_BETWN_PTS %token COLINEAR INTERSECTS SEPARATES INCLUDES INCIDENT %token DISTLARGER DISTSMALLER /* %token DRAW %token MONITOR IMPOSE %token ALIAS AS %token FOR IN RANGE */ %token QUERY %type type_name func1 func2 func3 %type expr expr_list identifier local_identifier id local_id %type graph_spec graph_spec_list /* %type within_id %type defn_monitor defn_impose */ %left SEMICOLON %left COLON %right EQUALS %left COMMA /* %nonassoc DOTDOT */ %left ELSE %left OR %left AND %right NOT %left EQ_EQ NOT_EQ %left GT GT_EQ LT LT_EQ %left SLASH_SLASH %nonassoc ATSIGN %left PLUS MINUS %left STAR PERCENT DIV MOD %left TILDE TILDE_SLASH %left DOTX DOTY DOTARG DOTRAD %left DOT1 DOT2 %right UMINUS %left SLASH %nonassoc LID %nonassoc AMPERSAND HASH VERTBAR NEWLINE %nonassoc LPAREN RPAREN LBRACK RBRACK %nonassoc LCURLY RCURLY LANGLE RANGLE %expect 11 %% /*----- grammar -----*/ program_list: /* nothing */ | program_list stmt { dd_script->ready = 1; } | program_list error { yyerrok; } ; stmt: VIEWPORT ID { eden_declare($2, VIEWPORT, $2); } | declaration { if (_changed) { declare_openshape(); _changed = 0; } #ifdef DEBUG if (Debug & 16) print_all_symbols(); #endif } | definition | { appendEden("%+eden\n", dd_script); } evaluation { appendEden("%-eden\n", dd_script); } | within_clause { #ifdef DISTRIB withinHandle = 1; #endif /* DISTRIB */ } | delete { if (_changed) { declare_openshape(); _changed = 0; } } | NEWLINE /* null statement */ /* | defn_monitor { if (_changed) { declare_openshape(); _changed = 0; } } | defn_impose { if (_changed) { declare_openshape(); _changed = 0; } } | draw | alias | inside */ ; delete: DELETE expr_list NEWLINE { Delete($2); } ; /* draw: DRAW NEWLINE { draw_gfx(0); } | DRAW identifier NEWLINE { count_id($2); draw_gfx($2); free($2); } ; */ within_id: WITHIN identifier { #ifdef DISTRIB withinName = strdup(expr_to_eden_name($2)); /* within door {} - this finds 'door' */ if (handle_check1(withinName)) { /* The current agent is allowed to change the contents of the variable 'withinName' */ dd_appAgentName--; /* we don't need to prepend the agent name any more */ withinHandle = 1; sprintf(temp, "%%donald\nwithin %s {\n%%eden\n", expr_to_donald_name($2)); propagateDonaldDef(withinName, temp); change_scope($2); freeTree($2); /* propagateAgency1(withinName, temp); */ } else { withinHandle = 0; } #else dd_appAgentName--; change_scope($2); freeTree($2); #endif /* DISTRIB */ } ; within_clause: within_id stmt { #ifdef DISTRIB if (withinHandle) { resume_scope(); propagateDonaldDef(withinName, "%donald\n}\n%eden\n"); }; withinHandle = 1; dd_appAgentName++; #else dd_appAgentName++; resume_scope(); #endif } | within_id NEWLINE LCURLY stmt_list RCURLY { #ifdef DISTRIB if (withinHandle) { resume_scope(); propagateDonaldDef(withinName, "%donald\n}\n%eden\n"); }; withinHandle = 1; dd_appAgentName++; #else dd_appAgentName++; resume_scope(); #endif } | within_id LCURLY stmt_list RCURLY { #ifdef DISTRIB if (withinHandle) { resume_scope(); propagateDonaldDef(withinName, "%donald\n}\n%eden\n"); } withinHandle = 1; dd_appAgentName++; #else dd_appAgentName++; resume_scope(); #endif } ; stmt_list: stmt { dd_script->ready = 1; } | stmt_list stmt { dd_script->ready = 1; } ; declaration: type_name expr_list NEWLINE { #ifdef DISTRIB if (withinHandle) { Declare($1, $2); } else { freeTree($2); } #else Declare($1, $2); #endif /* DISTRIB */ } | GRAPH expr_list { DeclareGraph($2); } ; /* defn_monitor: MONITOR expr EQUALS expr COMMA expr COMMA expr NEWLINE { int no_id; tree mon_exp; mon_exp = dtree3(OP_MONITOR, $6, $4, $8); declare2(MONITOR, $2); if ((no_id = count_id($2)) == ERROR) don_err(IdListExpect, 0); if (no_id != count_expr(mon_exp)) don_err(IdExprUnmatch, 0); if (no_id > 1) appendEden("autocalc = OFF;\n", dd_script); Define($2, mon_exp); freeTree(mon_exp); if (no_id > 1) appendEden("autocalc = ON;\n", dd_script); } ; defn_impose: IMPOSE expr_list EQUALS expr NEWLINE { int no_id; tree imp_exp; imp_exp = dtree1(OP_IMPOSE, $4); declare2(IMPOSE, $2); if ((no_id = count_id($2)) == ERROR) don_err(IdListExpect, 0); if (no_id != count_expr(imp_exp)) don_err(IdExprUnmatch, 0); if (no_id > 1) appendEden("autocalc = OFF;\n", dd_script); Define($2, imp_exp); freeTree(imp_exp); if (no_id > 1) appendEden("autocalc = ON;\n", dd_script); } ; */ type_name: INT { $$ = INT; } | REAL { $$ = REAL; } | MYCHAR { $$ = MYCHAR; } | BOOLEAN { $$ = BOOLEAN; } | POINT { $$ = POINT; } | LINE { $$ = LINE; } | ARC { $$ = ARC; } | CIRCLE { $$ = CIRCLE; } | ELLIPSE { $$ = ELLIPSE; } | LABEL { $$ = LABEL; } | SHAPE { $$ = SHAPE; } | OPENSHAPE { $$ = OPENSHAPE; } | IMAGE { $$ = IMAGE; } | RECTANGLE { $$ = RECTANGLE; } ; definition: expr_list EQUALS expr_list NEWLINE { #ifdef DISTRIB if (withinHandle) { #endif /* DISTRIB */ int no_id; tree t1 = $1; tree t3 = $3; if ((no_id = count_id(t1)) == ERROR) don_err(IdListExpect, 0); if (no_id != count_expr(t3)) don_err(IdExprUnmatch, 0); if (no_id > 1) appendEden("autocalc = OFF;\n", dd_script); if (t3->type == ANY) t3->type = t1->type; Define(t1, t3); freeTree(t1); freeTree(t3); if (no_id > 1) appendEden("autocalc = ON;\n", dd_script); #ifdef DISTRIB } else { freeTree($1); freeTree($3); } #endif /* DISTRIB */ } | XI EQUALS expr NEWLINE { count_expr($3); DefineFunc(XI, $3); freeTree($3); } | FI EQUALS expr NEWLINE { count_expr($3); DefineFunc(FI, $3); freeTree($3); } ; evaluation: QUERY NEWLINE { appendEden($1, dd_script); appendEden("\n", dd_script); free($1); } | evaluation QUERY NEWLINE { appendEden($2, dd_script); appendEden("\n", dd_script); free($2); } ; expr_list: expr | expr_list COMMA expr { $$ = dtree2(OP_COMMA, $1, $3); } /* | range | range COMMA expr_list { display("range,expr_list\n"); } */ ; /* alias: ALIAS expr_list AS expr_list ; inside: ENTER expr DO stmt_list EXIT ; range: iterator { display("iterator\n"); } | subrange { display("subrange\n"); } | expr LBRACK STAR RBRACK | expr LCURLY STAR RCURLY | expr SLASH STAR | expr HASH STAR | expr AMPERSAND STAR ; iterator: LANGLE FOR type_name IN expr_list RANGE expr RANGLE ; subrange: expr DOTDOT expr { display("expr..expr "); } ; range_list: type_name ID | range_list COMMA type_name ID IN range ; */ expr: /* constants */ INF { $$ = dtree0(OP_INF); } | PI { $$ = dtree0(OP_PI); $$->type = REAL; Rvalue($$) = 3.141593; } | INUMBER { $$ = dtree0(OP_INUMBER); $$->type = INT; Ivalue($$) = $1; } | RNUMBER { $$ = dtree0(OP_RNUMBER); $$->type = REAL; Rvalue($$) = $1; display2("rnumber(%lf) ", $1); } | CSTRING { $$ = dtree0(OP_CSTRING); $$->type = MYCHAR; Cvalue($$) = $1; display2("cstring(%s) ", $1); } | BOOL { $$ = dtree0(OP_BOOL); $$->type = BOOLEAN; Bvalue($$) = $1; } /* graph related variables */ | I { $$ = dtree0(OP_I); $$->type = INT; } | XI { $$ = dtree0(OP_XI); $$->type = REAL; } | FI { $$ = dtree0(OP_FI); $$->type = REAL; } | I_1 { $$ = dtree0(OP_I_1); $$->type = INT; } | XI_1 { $$ = dtree0(OP_XI_1); $$->type = REAL; } | FI_1 { $$ = dtree0(OP_FI_1); $$->type = REAL; } /* graph spec */ | LBRACK graph_spec_list RBRACK { $$ = $2; } | LBRACK NEWLINE graph_spec_list RBRACK { $$ = $3; } /* variable */ | identifier %prec LID /* eden variable */ | ID NOT { $$ = dtree2(OP_EDEN, $1); } /* ( expr ) */ | LPAREN expr RPAREN { $$ = dtree1(OP_PAREN, $2); } /* constructors */ | LCURLY expr COMMA expr RCURLY { $$ = dtree2(OP_CART, $2, $4); } | LCURLY expr ATSIGN expr RCURLY { $$ = dtree2(OP_POLAR, $2, $4); } | LBRACK expr COMMA expr RBRACK { $$ = dtree2(OP_LINE, $2, $4); } | LBRACK expr COMMA expr COMMA expr RBRACK { $$ = dtree3(OP_ARC, $2, $4, $6); } | CIRCLE LPAREN expr COMMA expr RPAREN { $$ = dtree2(OP_CIRCLE, $3, $5); } | RECTANGLE LPAREN expr COMMA expr RPAREN { $$ = dtree2(OP_RECTANGLE, $3, $5); } | ELLIPSE LPAREN expr COMMA expr COMMA expr RPAREN { $$ = dtree3(OP_ELLIPSE, $3, $5, $7); } | LABEL LPAREN expr COMMA expr RPAREN { $$ = dtree2(OP_LABEL, $3, $5); } /* arithmetic expressions */ | expr PLUS expr { $$ = dtree2(OP_PLUS, $1, $3); } | expr MINUS expr { $$ = dtree2(OP_MINUS, $1, $3); } | expr STAR expr { $$ = dtree2(OP_MULT, $1, $3); } | expr MOD expr { $$ = dtree2(OP_MOD, $1, $3); } | expr DIV expr { $$ = dtree2(OP_DIV, $1, $3); } | MINUS expr %prec UMINUS { $$ = dtree1(OP_UMINUS, $2); } /* logic expressions */ /* | TILDE expr { $$ = dtree1(OP_TILDE, $2); } */ | NOT expr { $$ = dtree1(OP_NOT, $2); } | expr AND expr { $$ = dtree2(OP_AND, $1, $3); } | expr OR expr { $$ = dtree2(OP_OR, $1, $3); } | expr EQ_EQ expr { $$ = dtree2(OP_EQ_EQ, $1, $3); } | expr NOT_EQ expr { $$ = dtree2(OP_NOT_EQ, $1, $3); } | expr LT expr { $$ = dtree2(OP_LT, $1, $3); } | expr LT_EQ expr { $$ = dtree2(OP_LT_EQ, $1, $3); } | expr GT expr { $$ = dtree2(OP_GT, $1, $3); } | expr GT_EQ expr { $$ = dtree2(OP_GT_EQ, $1, $3); } /* string expressions */ | expr SLASH_SLASH expr { $$ = dtree2(OP_SLASH_SLASH, $1, $3); } | ITOS LPAREN expr RPAREN { $$ = dtree1(OP_ITOS, $3); } | RTOS LPAREN expr COMMA expr RPAREN { $$ = dtree2(OP_RTOS, $3, $5); } /* selectors */ | expr DOTX { $$ = dtree1(OP_DOTX, $1); } | expr DOTY { $$ = dtree1(OP_DOTY, $1); } | expr DOT1 { $$ = dtree1(OP_DOT1, $1); } | expr DOT2 { $$ = dtree1(OP_DOT2, $1); } | expr DOTRAD { $$ = dtree1(OP_DOTRAD, $1); } | expr DOTARG { $$ = dtree1(OP_DOTARG, $1); } /* functions */ | ID NOT LPAREN RPAREN { $$ = dtree2(OP_FUNC, $1, 0); } | ID NOT LPAREN expr_list RPAREN { $$ = dtree2(OP_FUNC, $1, $4); } | IMGFUNC LPAREN RPAREN { $$ = dtree2(OP_IMGFUNC, $1, 0); } | IMGFUNC LPAREN expr_list RPAREN { $$ = dtree2(OP_IMGFUNC, $1, $3); } | func1 LPAREN expr RPAREN { $$ = dtree1($1, $3); } | func2 LPAREN expr COMMA expr RPAREN { $$ = dtree2($1, $3, $5); } | func3 LPAREN expr COMMA expr COMMA expr RPAREN { $$ = dtree3($1, $3, $5, $7); } | PARALLEL LPAREN expr COMMA expr COMMA expr COMMA expr RPAREN { $$ = dtree4(OP_PARALLEL, $3, $5, $7, $9); } /* conditional expression */ | IF expr THEN expr ELSE expr %prec ELSE { $$ = dtree3(OP_IF, $4, $2, $6); } /* | VERTBAR expr VERTBAR */ ; func1: SQRT { $$ = OP_SQRT; } | SIN { $$ = OP_SIN; } | COS { $$ = OP_COS; } | TAN { $$ = OP_TAN; } | ASIN { $$ = OP_ASIN; } | ACOS { $$ = OP_ACOS; } | ATAN { $$ = OP_ATAN; } | LOG { $$ = OP_LOG; } | EXP { $$ = OP_EXP; } | TRUNC { $$ = OP_TRUNC; } | FLOAT { $$ = OP_FLOAT; } | MIDPOINT { $$ = OP_MIDPOINT; } | RANDOM { $$ = OP_RANDOM; } ; func2: INTERSECT { $$ = OP_INTERSECT; } | PERPEND { $$ = OP_PERPEND; } | DISTANCE { $$ = OP_DISTANCE; } | SCALE { $$ = OP_SCALE; } | INTERSECTS { $$ = OP_INTERSECTS; } | INCLUDES { $$ = OP_INCLUDES; } | INCIDENT { $$ = OP_INCIDENT; } ; func3: ROT { $$ = OP_ROT; } | TRANS { $$ = OP_TRANS; } | PT_BETWN_PTS { $$ = OP_PT_BETWN_PTS; } | COLINEAR { $$ = OP_COLINEAR; } | SEPARATES { $$ = OP_SEPARATES; } | DISTLARGER { $$ = OP_DISTLARGER; } | DISTSMALLER { $$ = OP_DISTSMALLER; } ; identifier: local_identifier | SLASH local_identifier { $$ = dtree2(OP_GLOBAL, $2); } ; local_identifier: local_id SLASH local_identifier { $$ = dtree2(OP_SLASH, $1, $3); } | TILDE_SLASH local_identifier { $$ = dtree2(OP_SLASH, dtree1(OP_ID, 0), $2); dd_appAgentName--; } | local_id ; local_id: id %prec LID ; id: ID { $$ = dtree1(OP_ID, $1); } ; graph_spec_list: /* nothing */ { $$ = dtree2(OP_GSPECLIST, 0, 0); } | graph_spec | graph_spec_list SEMICOLON graph_spec { $$ = dtree2(OP_GSPECLIST, $1, $3); } | graph_spec_list SEMICOLON NEWLINE graph_spec { $$ = dtree2(OP_GSPECLIST, $1, $4); } ; graph_spec: type_name COLON { $$ = dtree2(OP_GSPEC, 0, (tree)$1); } | type_name COLON expr { $$ = dtree2(OP_GSPEC, $3, (tree)$1); } | type_name COLON NEWLINE { $$ = dtree2(OP_GSPEC, 0, (tree)$1); } | type_name COLON expr NEWLINE { $$ = dtree2(OP_GSPEC, $3, (tree)$1); } ; %% void yyerror(char *s) { don_err(Unclassified, s); } static char *errorstring[] = {ERRORSTRINGS}; /*---------------------------------------------------+---------+ | don_err | +---------*/ #include extern Tcl_Interp *interp; void don_err(enum errorcodes error_code, char *s) { extern void yyrestart(void); extern int yy_parse_init; char errStr[80]; Tcl_DString err, message; yyrestart(); /* reset lexical analyzer */ yy_parse_init = 1; /* reset bison */ deleteScript(dd_script); Tcl_EvalEC(interp, "appendHist {/*** }"); Tcl_DStringInit(&err); Tcl_DStringInit(&message); Tcl_DStringAppend(&message, "DoNaLD: ", -1); sprintf(errStr, errorstring[(int) error_code], s); Tcl_DStringAppend(&message, errStr, -1); Tcl_DStringAppendElement(&err, "appendHist"); Tcl_DStringAppendElement(&err, message.string); Tcl_EvalEC(interp, err.string); Tcl_DStringFree(&err); Tcl_DStringFree(&message); if (reset_context() > 0) Tcl_EvalEC(interp, "appendHist {\nDoNaLD: warning: reset context}"); Tcl_EvalEC(interp, "appendHist { ***/\n}"); error2("DoNaLD translator error", ""); } #ifdef DISTRIB /* This is a sort of drop-in replacement for appendEden, but with distribution [Ash, with Sun] */ void propagateDonaldDef(char *name, char *s) { extern void appendEden(char *, Script *); appendEden("propagate(\"", dd_script); appendEden(name, dd_script); appendEden("\", \"", dd_script); appendEden(s, dd_script); appendEden("\");\n", dd_script); } #endif /* DISTRIB */ ; tree imp_exp; imp_exp = dtree1(OP_IMPOSE, $4); declare2(IMPOSE, $2); if ((no_id = count_id($2)) == ERROR) don_err(IdListExpect, 0); if (no_id != count_expr(imp_exp)) don_err(IdExprUnmatch, 0); tkeden1.18/Donald/oper.h010060000025250000147000000307360727406556400164160ustar00ashleydcsother00003470000356/* * $Id: oper.h,v 1.6 1999/11/16 21:20:40 ashley Rel1.10 $ */ /*----- operator code -----*/ #define OP_INF 0 #define OP_ASSIGN 1 #define OP_PLUS 2 #define OP_MINUS 3 #define OP_MULT 4 #define OP_MOD 5 #define OP_DIV 6 #define OP_UMINUS 7 #define OP_TILDE 8 #define OP_DOTX 9 #define OP_DOTY 10 #define OP_DOT1 11 #define OP_DOT2 12 #define OP_DOTRAD 13 #define OP_DOTARG 14 #define OP_CART 15 #define OP_POLAR 16 #define OP_LINE 17 #define OP_ROT 18 #define OP_SCALE 19 #define OP_SLASH 20 #define OP_ID 21 #define OP_INUMBER 22 #define OP_COMMA 23 #define OP_PAREN 24 #define OP_IF 25 #define OP_VECT_ADD 26 #define OP_VECT_SUB 27 #define OP_SCALAR_MULT 28 #define OP_SCALAR_DIV 29 #define OP_SCALAR_MOD 30 #define OP_COS 31 #define OP_SIN 32 #define OP_RNUMBER 33 #define OP_INTERSECT 34 #define OP_PARALLEL 35 #define OP_PERPEND 36 #define OP_CIRCLE 37 #define OP_AND 38 #define OP_OR 39 #define OP_NOT 40 #define OP_BOOL 41 #define OP_PT_BETWN_PTS 42 #define OP_COLINEAR 43 #define OP_INTERSECTS 44 #define OP_SEPARATES 45 #define OP_INCLUDES 46 #define OP_DISTLARGER 47 #define OP_DISTSMALLER 48 #define OP_LABEL 49 #define OP_MONITOR 50 #define OP_IMPOSE 51 #define OP_CSTRING 52 #define OP_DISTANCE 53 #define OP_MIDPOINT 54 #define OP_EQ_EQ 55 #define OP_NOT_EQ 56 #define OP_GT 57 #define OP_GT_EQ 58 #define OP_LT 59 #define OP_LT_EQ 60 #define OP_SQRT 61 #define OP_TAN 62 #define OP_ASIN 63 #define OP_ACOS 64 #define OP_ATAN 65 #define OP_LOG 66 #define OP_EXP 67 #define OP_TRUNC 68 #define OP_FLOAT 69 #define OP_INCIDENT 70 #define OP_TRANS 71 #define OP_ELLIPSE 72 #define OP_RANDOM 73 #define OP_ARC 74 #define OP_PI 75 #define OP_SLASH_SLASH 76 #define OP_ITOS 77 #define OP_RTOS 78 #define OP_I 79 #define OP_XI 80 #define OP_FI 81 #define OP_I_1 82 #define OP_XI_1 83 #define OP_FI_1 84 #define OP_GSPECLIST 85 #define OP_GSPEC 86 #define OP_GLOBAL 87 #define OP_FUNC 88 #define OP_EDEN 89 #define OP_IMGFUNC 90 #define OP_RECTANGLE 91 #define UNARY -1 #define BINARY -2 #define TRIARY -3 #define QUADARY -4 #define INFIX -5 #define POSTFIX -6 #define CONSTANT -7 struct trans { int order; char *op_str; } ; #define TRANSLAT \ { \ /* OP_INF */ { CONSTANT, "[ INF ]" }, \ /* OP_ASSIGN */ { INFIX, " = " }, \ /* OP_PLUS */ { INFIX, " + " }, \ /* OP_MINUS */ { INFIX, " - " }, \ /* OP_MULT */ { INFIX, " * " }, \ /* OP_MOD */ { INFIX, " % " }, \ /* OP_DIV */ { INFIX, " / " }, \ /* OP_UMINUS */ { UNARY, "- " }, \ /* OP_TILDE */ { UNARY, 0 }, \ /* OP_DOTX */ { UNARY, "dotx(" }, \ /* OP_DOTY */ { UNARY, "doty(" }, \ /* OP_DOT1 */ { UNARY, "dot1(" }, \ /* OP_DOT2 */ { UNARY, "dot2(" }, \ /* OP_DOTRAD */ { UNARY, "dotrad(" }, \ /* OP_DOTARG */ { UNARY, "dotarg(" }, \ /* OP_CART */ { BINARY, "cart(" }, \ /* OP_POLAR */ { BINARY, "polar(" }, \ /* OP_LINE */ { BINARY, "line(" }, \ /* OP_ROT */ { TRIARY, "rot(" }, \ /* OP_SCALE */ { BINARY, "scale(" }, \ /* OP_SLASH */ { OP_SLASH, "" }, \ /* OP_ID */ { OP_ID, 0 }, \ /* OP_INUMBER*/ { OP_INUMBER , 0 }, \ /* OP_COMMA */ { INFIX, ", " }, \ /* OP_PAREN */ { UNARY, "(" }, \ /* OP_IF */ { OP_IF, 0 }, \ /* OP_VECT_ADD */ { BINARY, "vector_add(" }, \ /* OP_VECT_SUB */ { BINARY, "vector_sub(" }, \ /* OP_SCALAR_MULT */ { BINARY, "scalar_mult(" }, \ /* OP_SCALAR_DIV */ { BINARY, "scalar_div(" }, \ /* OP_SCALAR_MOD */ { BINARY, "scalar_mod(" }, \ /* OP_COSINE */ { UNARY, "cos(" }, \ /* OP_SINE */ { UNARY, "sin(" }, \ /* OP_RNUMBER */ { OP_RNUMBER, 0 }, \ /* OP_INTERSECT */ { BINARY, "intersect(" }, \ /* OP_PARALLEL */ { QUADARY, "parallel(" }, \ /* OP_PERPEND */ { BINARY, "perpend(" }, \ /* OP_CIRCLE */ { BINARY, "circle(" }, \ /* OP_AND */ { INFIX, " && " }, \ /* OP_OR */ { INFIX, " || " }, \ /* OP_NOT */ { UNARY, "! " }, \ /* OP_BOOL */ { OP_BOOL, 0 }, \ /* OP_PT_BETWN_PTS */ { TRIARY, "between(" }, \ /* OP_COLINEAR */ { TRIARY, "colinear(" }, \ /* OP_INTERSECTS */ { BINARY, "intersects(" }, \ /* OP_SEPARATES */ { TRIARY, "separates(" }, \ /* OP_INCLUDES */ { BINARY, "includes(" }, \ /* OP_DISTLARGER */ { TRIARY, "distlarger(" }, \ /* OP_DISTSMALLER */ { TRIARY, "distsmaller(" }, \ /* OP_LABEL */ { BINARY, "label(" }, \ /* OP_MONITOR */ { OP_MONITOR, 0 }, \ /* OP_IMPOSE */ { OP_IMPOSE, 0 }, \ /* OP_CSTRING */ { OP_CSTRING, 0 }, \ /*OP_DISTANCE */ { BINARY, "dist(" }, \ /* OP_MIDPOINT */ { UNARY, "midpoint(" }, \ /* OP_EQ_EQ */ { INFIX, " == " }, \ /* OP_NOT_EQ */ { INFIX, " != " }, \ /* OP_GT */ { INFIX, " > " }, \ /* OP_GT_EQ */ { INFIX, " >= " }, \ /* OP_LT */ { INFIX, " < " }, \ /* OP_LT_EQ */ { INFIX, " <= " }, \ /* OP_SQRT */ { UNARY, "sqrt(" }, \ /* OP_TAN */ { UNARY, "tan(" }, \ /* OP_ASIN */ { UNARY, "asin(" }, \ /* OP_ACOS */ { UNARY, "acos(" }, \ /* OP_ATAN */ { UNARY, "atan(" }, \ /* OP_LOG */ { UNARY, "log(" }, \ /* OP_EXP */ { UNARY, "exp(" }, \ /* OP_TRUNC */ { UNARY, "int(" }, \ /* OP_FLOAT */ { UNARY, "float(" }, \ /* OP_INCIDENT */ { BINARY, "incident(" }, \ /* OP_TRANS */ { TRIARY, "trans(" }, \ /* OP_ELLIPSE */ { TRIARY, "ellipse(" }, \ /* OP_RANDOM */ { UNARY, "DD_random(" }, \ /* OP_ARC */ { TRIARY, "arc(" }, \ /* OP_PI */ { CONSTANT, "PI" }, \ /* OP_SLASH_SLASH */ { INFIX, " // " }, \ /* OP_ITOS */ { UNARY, "str(" }, \ /* OP_RTOS */ { BINARY, "rtos(" }, \ /* OP_I */ { CONSTANT, "?1" }, \ /* OP_XI */ { CONSTANT, "?2" }, \ /* OP_FI */ { CONSTANT, "?3" }, \ /* OP_I_1 */ { CONSTANT, "?4" }, \ /* OP_XI_1 */ { CONSTANT, "?5" }, \ /* OP_FI_1 */ { CONSTANT, "?6" }, \ /* OP_GSPECLIST */{ OP_GSPECLIST, 0 }, \ /* OP_GSPEC */ { OP_GSPEC, 0 }, \ /* OP_GLOBAL */ { OP_GLOBAL, "" }, \ /* OP_FUNC */ { OP_FUNC, 0 }, \ /* OP_EDEN */ { OP_EDEN, 0 }, \ /* OP_IMGFUNC */ { OP_IMGFUNC, 0 }, \ /* OP_RECTANGLE */ { BINARY, "rectangle(" } \ } #define ORIGINAL \ { \ /* OP_INF */ { OP_INF, "inf" }, \ /* OP_ASSIGN */ { INFIX, " = " }, \ /* OP_PLUS */ { INFIX, " + " }, \ /* OP_MINUS */ { INFIX, " - " }, \ /* OP_MULT */ { INFIX, " * " }, \ /* OP_MOD */ { INFIX, " mod " }, \ /* OP_DIV */ { INFIX, " div " }, \ /* OP_UMINUS */ { UNARY, "-" }, \ /* OP_TILDE */ { UNARY, "~" }, \ /* OP_DOTX */ { POSTFIX, ".x" }, \ /* OP_DOTY */ { POSTFIX, ".y" }, \ /* OP_DOT1 */ { POSTFIX, ".1" }, \ /* OP_DOT2 */ { POSTFIX, ".2" }, \ /* OP_DOTRAD */ { POSTFIX, ".rad" }, \ /* OP_DOTARG */ { POSTFIX, ".arg" }, \ /* OP_CART */ { OP_CART, 0 }, \ /* OP_POLAR */ { OP_POLAR, 0 }, \ /* OP_LINE */ { OP_LINE, 0 }, \ /* OP_ROT */ { TRIARY, "rot(" }, \ /* OP_SCALE */ { BINARY, "scale(" }, \ /* OP_SLASH */ { OP_SLASH, "/" }, \ /* OP_ID */ { OP_ID, 0 }, \ /* OP_INUMBER*/ { OP_INUMBER , 0 }, \ /* OP_COMMA */ { INFIX, ", " }, \ /* OP_PAREN */ { UNARY, "(" }, \ /* OP_IF */ { OP_IF, 0 }, \ /* OP_VECT_ADD */ { INFIX, " + " }, \ /* OP_VECT_SUB */ { INFIX, " - " }, \ /* OP_SCALAR_MULT */ { INFIX, " * " }, \ /* OP_SCALAR_DIV */ { INFIX, " div " }, \ /* OP_SCALAR_MOD */ { BINARY, " mod " }, \ /* OP_COSINE */ { UNARY, "cos(" }, \ /* OP_SINE */ { UNARY, "sin(" }, \ /* OP_RNUMBER */ { OP_RNUMBER, 0 }, \ /* OP_INTERSECT */ { BINARY, "intersect(" }, \ /* OP_PARALLEL */ { QUADARY, "parallel(" }, \ /* OP_PERPEND */ { BINARY, "perpend(" }, \ /* OP_CIRCLE */ { BINARY, "circle(" }, \ /* OP_AND */ { INFIX, " && " }, \ /* OP_OR */ { INFIX, " || " }, \ /* OP_NOT */ { UNARY, "!" }, \ /* OP_BOOL */ { OP_BOOL, 0 }, \ /* OP_PT_BETWN_PTS */ { TRIARY, "pt_betwn_pts(" }, \ /* OP_COLINEAR */ { TRIARY, "colinear(" }, \ /* OP_INTERSECTS */ { BINARY, "intersects(" }, \ /* OP_SEPARATES */ { TRIARY, "separates(" }, \ /* OP_INCLUDES */ { BINARY, "includes(" }, \ /* OP_DISTLARGER */ { TRIARY, "distlarger(" }, \ /* OP_DISTSMALLER */ { TRIARY, "distsmaller(" }, \ /* OP_LABEL */ { BINARY, "label(" }, \ /* OP_MONITOR */ { OP_MONITOR, 0 }, \ /* OP_IMPOSE */ { OP_IMPOSE, 0 }, \ /* OP_CSTRING */ { OP_CSTRING, 0 }, \ /*OP_DISTANCE */ { BINARY, "dist(" }, \ /* OP_MIDPOINT */ { UNARY, "midpoint(" }, \ /* OP_EQ_EQ */ { INFIX, " == " }, \ /* OP_NOT_EQ */ { INFIX, " != " }, \ /* OP_GT */ { INFIX, " > " }, \ /* OP_GT_EQ */ { INFIX, " >= " }, \ /* OP_LT */ { INFIX, " < " }, \ /* OP_LT_EQ */ { INFIX, " <= " }, \ /* OP_SQRT */ { UNARY, "sqrt(" }, \ /* OP_TAN */ { UNARY, "tan(" }, \ /* OP_ASIN */ { UNARY, "asin(" }, \ /* OP_ACOS */ { UNARY, "acos(" }, \ /* OP_ATAN */ { UNARY, "atan(" }, \ /* OP_LOG */ { UNARY, "log(" }, \ /* OP_EXP */ { UNARY, "exp(" }, \ /* OP_TRUNC */ { UNARY, "trunc(" }, \ /* OP_FLOAT */ { UNARY, "float(" }, \ /* OP_INCIDENT */ { BINARY, "incident(" }, \ /* OP_TRANS */ { TRIARY, "trans(" }, \ /* OP_ELLIPSE */ { TRIARY, "ellipse(" }, \ /* OP_RANDOM */ { UNARY, "rand(" }, \ /* OP_ARC */ { OP_ARC, 0 }, \ /* OP_PI */ { CONSTANT, "pi" }, \ /* OP_SLASH_SLASH */ { INFIX, " // " }, \ /* OP_ITOS */ { UNARY, "itos(" }, \ /* OP_RTOS */ { BINARY, "rtos(" }, \ /* OP_I */ { CONSTANT, "" }, \ /* OP_XI */ { CONSTANT, "x" }, \ /* OP_FI */ { CONSTANT, "f" }, \ /* OP_I_1 */ { CONSTANT, "" }, \ /* OP_XI_1 */ { CONSTANT, "x" }, \ /* OP_FI_1 */ { CONSTANT, "f" }, \ /* OP_GSPECLIST */{ OP_GSPECLIST, ";\n\t" }, \ /* OP_GSPEC */ { OP_GSPEC, " : " }, \ /* OP_GLOBAL */ { OP_GLOBAL, "" }, \ /* OP_FUNC */ { OP_FUNC, 0 }, \ /* OP_EDEN */ { OP_EDEN, 0 }, \ /* OP_IMGFUNC */ { OP_IMGFUNC, 0 }, \ /* OP_RECTANGLE */ { BINARY, "rectangle(" } \ } * OP_DOTARG */ { UNARY, "dotkeden1.18/Donald/Makefile.in010060000025250000147000000005210730546002400173130ustar00ashleydcsother00003470000356# # $Id: Makefile.in,v 1.12 1999/11/08 21:22:55 ashley Rel1.10 $ # # Need to find the original lexer source... where oh where? LEXER_SOURCE = lex.c NOTATION_PREFIX = dd_ PARSER_SOURCE = parser.y PARSER_OUT = parser.c PARSER_HEADERS_OUT = parser.h SOURCES = check.c symbol.c tree.c utility.c LIB = libdonald.a include ../generic.mk tkeden1.18/Donald/lex.c010060000025250000147000000367230731247327400162300ustar00ashleydcsother00003470000356/* * $Id: lex.c,v 1.16 1999/11/16 21:20:40 ashley Rel1.10 $ */ static char rcsid[] = "$Id: lex.c,v 1.16 1999/11/16 21:20:40 ashley Rel1.10 $"; #include #include #include #include #include "../config.h" #include "tree.h" #include "parser.h" #include "../Eden/eden.h" #include "../Eden/emalloc.h" #ifdef HAVE_DMALLOC #include #endif extern void yyparse(int); extern char agentName[128]; /* for distributed tkEden --sun */ extern int appAgentName; extern int append_NoAgentName; extern char *libLocation; char *dd_prompt; enum { _S_, _A_, _D_, _DDOT_, _DE_, _DED_, _DES_, _DESD_, _DOT_, _DOT1_, _DOT2_, _DA_, _DAR_, _DR_, _DRA_, _QUOTE_, _QUERY_, _BSLASH_, _HASH_, _AND_, _OR_, _EQ_, _NOT_, _LT_, _GT_, _SLASH_, _B_, _BI_, _BISP_, _BI__, _BI_1_, _BI_1SP_, _I_, _X_, _F_, _II_, _IN_, _INA_, _TILDE_ }; static char *yytext = 0; static bufsize = 256; static yyleng = 0; static state = _S_; /* start state */ static gtarget; /* which graph token seeking? */ static int isOpenshape=0; /* for distributed --sun */ static int curlyCount=0; int dd_appAgentName=1; static int DonaldAppAgentName=1; /* function prototypes */ int map_name_to_token(char *); void yyrestart(void); char * map_token_to_name(int); void yylex(int); void init_donald(void); static void save(int); static void action_A(void); static int tokenize(int); #define clearbuf() yytext[yyleng=0] = '\0' void yyrestart(void) { clearbuf(); state = _S_; } #define NUMTOKEN 62 struct { char *name; int token; } translation[NUMTOKEN] = { { "acos" , ACOS }, /* { "alias" , ALIAS }, */ { "and" , AND }, { "arc" , ARC }, /* { "as" , AS }, */ { "asin" , ASIN }, { "atan" , ATAN }, { "boolean" , BOOLEAN }, { "char" , MYCHAR }, { "circle" , CIRCLE }, { "colinear" , COLINEAR }, { "cos" , COS }, { "delete" , DELETE }, { "dist" , DISTANCE }, { "distlarger" , DISTLARGER }, { "distsmaller" , DISTSMALLER }, { "div" , DIV }, /* { "draw" , DRAW }, */ { "ellipse" , ELLIPSE }, { "else" , ELSE }, { "exp" , EXP }, { "false" , BOOL }, { "float" , FLOAT }, /* { "for" , FOR }, */ { "graph" , GRAPH }, { "if" , IF }, { "image" , IMAGE }, /* { "impose" , IMPOSE }, */ /* { "in" , IN }, */ { "incident" , INCIDENT }, { "includes" , INCLUDES }, { "inf" , INF }, { "int" , INT }, { "intersect" , INTERSECT }, { "intersects" , INTERSECTS }, { "itos" , ITOS }, { "label" , LABEL }, { "line" , LINE }, { "log" , LOG }, { "midpoint" , MIDPOINT }, { "mod" , MOD }, /* { "monitor" , MONITOR }, */ { "not" , NOT }, { "of" , OF }, { "openshape" , OPENSHAPE }, { "or" , OR }, { "parallel" , PARALLEL }, { "perpend" , PERPEND }, { "pi" , PI }, { "point" , POINT }, { "pt_betwn_pts", PT_BETWN_PTS }, { "rand" , RANDOM }, /* { "range" , RANGE }, */ { "real" , REAL }, { "rectangle" , RECTANGLE }, { "rot" , ROT }, { "rtos" , RTOS }, { "scale" , SCALE }, { "separates" , SEPARATES }, { "shape" , SHAPE }, { "sin" , SIN }, { "sqrt" , SQRT }, { "tan" , TAN }, { "then" , THEN }, { "trans" , TRANS }, { "true" , BOOL }, { "trunc" , TRUNC }, { "viewport" , VIEWPORT }, { "within" , WITHIN }, { 0, 0 } }; int map_name_to_token(char *name) { int i, start, end, cmp; start = 0; end = NUMTOKEN - 1; for (i = (NUMTOKEN - 1) >> 1; start <= i && i <= end; i = (start + end) >> 1) { if (translation[i].name == 0) return 0; cmp = strcmp(name, translation[i].name); if (cmp == 0) return translation[i].token; else if (cmp > 0) start = i + 1; else /* cmp < 0 */ end = i - 1; } return 0; } char * map_token_to_name(int token) { int i; for (i = 0; i < NUMTOKEN; i++) if (translation[i].token == token) return translation[i].name; return 0; } static void save(int c) { if (yyleng == bufsize - 1) { bufsize *= 2; yytext = (char *) erealloc(yytext, bufsize * sizeof(int)); } yytext[yyleng++] = c; yytext[yyleng] = '\0'; } static void action_A(void) { int token; char new_yytext[256]; /* for distributed tkEden --sun */ extern int inPrefix; if ((token = map_name_to_token(yytext)) == 0) { /* Virtual agents */ if (*agentName != 0 && dd_appAgentName >0 && appAgentName > 0 && append_NoAgentName >0 && DonaldAppAgentName >0 ) { new_yytext[0] = '\0'; if (inPrefix) strcpy(new_yytext, agentName); else strcpy(new_yytext, yytext); strcat(new_yytext, "_"); if (inPrefix) strcat(new_yytext, yytext); else strcat(new_yytext, agentName); strcpy(yytext, new_yytext); /* printf("new_yytext = %s\n", new_yytext); */ } yylval.s = strdup(yytext); yyparse(ID); } else { /* it is a token */ if (token == BOOL) yylval.i = (strcmp(yytext, "true") == 0); if (token == WITHIN && *agentName != 0 && append_NoAgentName > 0) { /* printf("within \n"); */ isOpenshape = 1; curlyCount = 0; } yyparse(token); } DonaldAppAgentName = 1; } static int tokenize(int c) { switch (c) { case '!': return NOT; case ',': return COMMA; case '+': return PLUS; case '-': return MINUS; case '*': return STAR; case '/': return SLASH; case '%': return PERCENT; case '=': return EQUALS; case '&': return AMPERSAND; case '|': return VERTBAR; case ':': return COLON; case ';': return SEMICOLON; case '~': DonaldAppAgentName = 0; return TILDE; case '@': return ATSIGN; case '(': return LPAREN; case ')': return RPAREN; case '<': return LT; case '>': return GT; case '[': return LBRACK; case ']': return RBRACK; case '{': return LCURLY; case '}': return RCURLY; default: return c; } } void yylex(int c) { switch (state) { case _S_: switch (c) { case ' ': case '\t': state = _S_; break; case '\n': yyparse(NEWLINE); state = _S_; break; case '.': save(c); state = _DOT_; break; case '?': state = _QUERY_; break; case '"': save(c); state = _QUOTE_; break; case '\\': state = _BSLASH_; break; case '#': state = _HASH_; break; case '&': state = _AND_; break; case '|': state = _OR_; break; case '=': state = _EQ_; break; case '!': state = _NOT_; break; case '<': gtarget = _I_; state = _B_; break; case '>': state = _GT_; break; case '/': state = _SLASH_; break; case 'f': gtarget = _F_; state = _F_; save(c); break; case 'x': gtarget = _X_; state = _X_; save(c); break; case 'I': state = _II_; break; case '~': state = _TILDE_; break; default: if (isalpha(c) || c == '_') { save(c); state = _A_; } else if (isdigit(c)) { save(c); state = _D_; } else { yyparse(tokenize(c)); state = _S_; } break; } break; case _A_: if (isalnum(c) || c == '_') { save(c); state = _A_; } else { action_A(); clearbuf(); state = _S_; yylex(c); } break; case _D_: if (isdigit(c)) { save(c); state = _D_; } else if (c == '.') { save(c); state = _DDOT_; } else if (c == 'E' || c == 'e') { save(c); state = _DE_; } else { yylval.i = atoi(yytext); yyparse(INUMBER); clearbuf(); state = _S_; yylex(c); } break; case _DDOT_: if (isdigit(c)) { save(c); state = _DDOT_; } else if (c == '.') { yylval.r = atof(yytext); yyparse(RNUMBER); clearbuf(); state = _S_; yylex(c); } else if (c == 'E' || c == 'e') { save(c); state = _DE_; } else { yylval.r = atof(yytext); yyparse(RNUMBER); clearbuf(); state = _S_; yylex(c); } break; case _DE_: if (isdigit(c)) { save(c); state = _DED_; } else if (c == '+' || c == '-') { save(c); state = _DES_; } else { yylval.r = atof(yytext); yyparse(RNUMBER); clearbuf(); state = _S_; yylex(c); } break; case _DED_: case _DESD_: if (isdigit(c)) { save(c); state = _DED_; } else { yylval.r = atof(yytext); yyparse(RNUMBER); clearbuf(); state = _S_; yylex(c); } break; case _DES_: if (isdigit(c)) { save(c); state = _DESD_; } else { int E, S; yylval.r = atof(yytext); yyparse(RNUMBER); E = yytext[yyleng-2]; S = yytext[yyleng-1]; clearbuf(); state = _S_; yylex(E); yylex(S); yylex(c); } break; case _DOT_: if (c == 'x') { yyparse(DOTX); clearbuf(); state = _S_; } else if (c == 'y') { yyparse(DOTY); clearbuf(); state = _S_; } else if (c == '1') { save(c); state = _DOT1_; } else if (c == '2') { save(c); state = _DOT2_; } else if (c == 'a') { save(c); state = _DA_; } else if (c == 'r') { save(c); state = _DR_; } else if (isdigit(c)) { save(c); state = _DDOT_; } else { yyparse('.'); clearbuf(); state = _S_; yylex(c); } break; case _DOT1_: if (isdigit(c)) { state = _DDOT_; yylex(c); } else { yyparse(DOT1); clearbuf(); state = _S_; yylex(c); } break; case _DOT2_: if (isdigit(c)) { state = _DDOT_; yylex(c); } else { yyparse(DOT2); clearbuf(); state = _S_; yylex(c); } break; case _DA_: if (c == 'r') { save(c); state = _DAR_; } else { yyparse('.'); clearbuf(); state = _S_; yylex('a'); yylex(c); } break; case _DAR_: if (c == 'g') { yyparse(DOTARG); clearbuf(); state = _S_; } else { yyparse('.'); clearbuf(); state = _S_; yylex('a'); yylex('r'); yylex(c); } break; case _DR_: if (c == 'a') { save(c); state = _DRA_; } else { yyparse('.'); clearbuf(); state = _S_; yylex('r'); yylex(c); } break; case _DRA_: if (c == 'd') { yyparse(DOTRAD); clearbuf(); state = _S_; } else { yyparse('.'); clearbuf(); state = _S_; yylex('r'); yylex('a'); yylex(c); } break; case _QUOTE_: if (c == '"') { save(c); yylval.s = strdup(yytext); yyparse(CSTRING); clearbuf(); state = _S_; } else if (c == '\n') { save('"'); yylval.s = strdup(yytext); yyparse(CSTRING); clearbuf(); state = _S_; } else { save(c); state = _QUOTE_; } break; case _QUERY_: if (c == '\n') { yylval.s = strdup(yytext); yyparse(QUERY); yyparse(NEWLINE); clearbuf(); state = _S_; } else { save(c); state = _QUERY_; } break; case _BSLASH_: if (c == '\n') { state = _S_; } else { yyparse('\\'); state = _S_; yylex(c); } break; case _HASH_: if (c == '\n') { yyparse(NEWLINE); state = _S_; } else { state = _HASH_; } break; case _AND_: if (c == '&') { yyparse(AND); state = _S_; } else { yyparse(AMPERSAND); state = _S_; yylex(c); } break; case _OR_: if (c == '|') { yyparse(OR); state = _S_; } else { yyparse(VERTBAR); state = _S_; yylex(c); } break; case _EQ_: if (c == '=') { yyparse(EQ_EQ); state = _S_; } else { yyparse(EQUALS); state = _S_; yylex(c); } break; case _NOT_: if (c == '=') { yyparse(NOT_EQ); state = _S_; } else { yyparse(NOT); state = _S_; yylex(c); } break; case _LT_: if (c == '=') { yyparse(LT_EQ); state = _S_; } else { yyparse(LT); state = _S_; yylex(c); } break; case _GT_: if (c == '=') { yyparse(GT_EQ); state = _S_; } else { yyparse(GT); state = _S_; yylex(c); } break; case _SLASH_: if (c == '/') { yyparse(SLASH_SLASH); state = _S_; } else { yyparse(SLASH); state = _S_; DonaldAppAgentName = 0; yylex(c); } break; case _TILDE_: if (c == '/') { DonaldAppAgentName = 1; dd_appAgentName++; yyparse(TILDE_SLASH); state = _S_; } else { DonaldAppAgentName = 0; state = _S_; yylex(c); } break; case _F_: if (c == ' ' || c == '\t') { state = _F_; } else if (c == '<') { state = _B_; } else { state = _A_; yylex(c); } break; case _X_: if (c == ' ' || c == '\t') { state = _X_; } else if (c == '<') { state = _B_; } else { state = _A_; yylex(c); } break; case _B_: if (c == ' ' || c == '\t') { state = _B_; } else if (c == 'i') { state = _BI_; } else { switch (gtarget) { case _F_: case _X_: state = _A_; yylex('<'); yylex(c); break; default: state = _LT_; yylex(c); break; } } break; case _BI_: case _BISP_: if (c == ' ' || c == '\t') { state = _BISP_; } else if (c == '-') { state = _BI__; } else if (c == '>') { switch (gtarget) { case _F_: yyparse(FI); break; case _X_: yyparse(XI); break; case _I_: yyparse(I); break; } clearbuf(); state = _S_; } else { switch (gtarget) { case _F_: case _X_: state = _A_; yylex('<'); yylex('i'); if (state == _BISP_) yylex(' '); yylex(c); break; default: state = _LT_; yylex('i'); if (state == _BISP_) yylex(' '); yylex(c); break; } } break; case _BI__: if (c == ' ' || c == '\t') { state = _BI__; } else if (c == '1') { state = _BI_1_; } else { switch (gtarget) { case _F_: case _X_: state = _A_; yylex('<'); yylex('i'); yylex('-'); yylex(c); break; default: state = _LT_; yylex('i'); yylex('-'); yylex(c); break; } } break; case _BI_1_: case _BI_1SP_: if (c == ' ' || c == '\t') { state = _BI_1SP_; } else if (c == '>') { switch (gtarget) { case _F_: yyparse(FI_1); break; case _X_: yyparse(XI_1); break; case _I_: yyparse(I_1); break; } clearbuf(); state = _S_; } else { switch (gtarget) { case _F_: case _X_: state = _A_; yylex('<'); yylex('i'); yylex('-'); yylex('1'); if (state == _BI_1SP_) yylex(' '); yylex(c); break; default: state = _LT_; yylex('i'); yylex('-'); yylex('1'); if (state == _BI_1SP_) yylex(' '); yylex(c); break; } } break; case _II_: if (c == '!') { state = _IN_; } else { state = _A_; yylex('I'); yylex(c); } break; case _IN_: if (isalpha(c)) { save(c); state = _INA_; } else { state = _S_; yylex('I'); yylex('!'); yylex(c); } break; case _INA_: if (isalpha(c)) { save(c); state = _INA_; } else { yylval.s = strdup(yytext); yyparse(IMGFUNC); clearbuf(); state = _S_; yylex(c); } break; } } #define FILE_DEV 1 void init_donald(void) { char *name = "/donald.init.e"; char fullname[255]; FILE *initFile; extern char *progname; extern char viewport_name[]; extern int run(short, void *, char *); char *envcontents; if (yytext == 0) { yytext = (char *) emalloc(bufsize * sizeof(int)); }; *viewport_name = '\0'; dd_prompt = (char *)malloc(4); strcpy(dd_prompt, "[/]"); strcpy(fullname, libLocation); strcat(fullname, name); if ((initFile = fopen(fullname, "r")) == 0) { fprintf(stderr, "%s: can't open %s\n", progname, fullname); exit(1); } run(FILE_DEV, initFile, name); } E; case '@': return ATSIGN; case '(':tkeden1.18/Donald/error.h010060000025250000147000000023510727406556400165720ustar00ashleydcsother00003470000356/* * $Id: error.h,v 1.6 1999/11/16 21:20:40 ashley Rel1.10 $ */ /*----- error code definitions -----*/ enum errorcodes { Unclassified , Impossible , SyntaxError , OutOfMemory , UndefinedID , IdListExpect , IdExprUnmatch , RedeclareID , UndeclareID , StackOverflow , StackUnderflow , NotOpenshapeOrGraph , TypeMismatch , FuncExpect } ; #define ERRORSTRINGS \ "%s" ,\ "impossible error occurs in %s" ,\ "syntax error" ,\ "out of memory" ,\ "undefined id: %s" ,\ "id list expected" ,\ "id list and expr list unmatched" ,\ "redeclared identifier: %s" ,\ "undeclared identifier: %s" ,\ "%sstack overflow" ,\ "%sstack underflow" ,\ "not openshape or graph: %s" ,\ "type mismatched" ,\ "%s is not declared as a function" extern void don_err(enum errorcodes, char *); tkeden1.18/Donald/CVS/004070000025250000147000000000000731677661000157215ustar00ashleydcsother00003470000356tkeden1.18/Donald/CVS/Root010060000025250000147000000000360727406556400165670ustar00ashleydcsother00003470000356cssbz@127.0.0.1:/cvsroot/eden tkeden1.18/Donald/CVS/Repository010060000025250000147000000000160727406556400200210ustar00ashleydcsother00003470000356tkeden/Donald tkeden1.18/Donald/CVS/Entries010060000025250000147000000007030727406556400172560ustar00ashleydcsother00003470000356/Makefile.in/1.12/Wed Apr 11 17:53:20 2001// /check.c/1.8/Wed Apr 11 17:53:25 2001// /error.h/1.6/Wed Apr 11 17:53:25 2001// /lex.c/1.16/Wed Apr 11 17:53:36 2001// /oper.h/1.6/Wed Apr 11 17:53:54 2001// /parser.y/1.13/Wed Apr 11 17:54:06 2001// /symbol.c/1.12/Wed Apr 11 17:54:44 2001// /symbol.h/1.4/Wed Apr 11 17:54:44 2001// /tree.c/1.10/Wed Apr 11 17:55:09 2001// /tree.h/1.4/Wed Apr 11 17:55:09 2001// /utility.c/1.7/Wed Apr 11 17:55:13 2001// D tkeden1.18/Donald/check.c010060000025250000147000000307750731367012200165060ustar00ashleydcsother00003470000356/* * $Id: check.c,v 1.8 1999/11/16 21:20:40 ashley Rel1.10 $ */ static char rcsid[] = "$Id: check.c,v 1.8 1999/11/16 21:20:40 ashley Rel1.10 $"; #include "../config.h" #include "error.h" #include "oper.h" #include "tree.h" #include "symbol.h" #include "parser.h" #define ERROR -1 extern void change_context(symbol *); extern void resume_context(void); extern int reset_context(void); extern void backup_context(void); extern void restore_context(void); extern int nary(int); /*function prototypes */ int count_id(tree); int count_expr(tree); static void TypeClash(void); static void check_id(tree); static void check_children_type(tree); static int semantic_1(tree, int, int); static int semantic_2(tree, int, int, int); static int semantic_3(tree, int, int, int, int); static int semantic_4(tree, int, int, int, int, int); static void TypeClash(void) { don_err(TypeMismatch, 0); } /*--------------------------------------------------+----------+ | check_id | +----------*/ static void check_id(tree expr) { /* Is variable declared ? */ /* id-expr is assumed */ char *id; symbol *sym; symbol *look_up(char *); char *donald_full_name(char *); switch (expr->op) { case OP_ID: id = (char *) Lexpr; if (id == 0) don_err(Unclassified, "illegal use of `~'"); if ((sym = look_up(id)) == SymEnd) don_err(UndeclareID, donald_full_name(id)); Etype = sym->type; break; case OP_SLASH: id = (char *) Lexpr->left; if (id) { if ((sym = look_up(id)) == SymEnd) don_err(UndeclareID, donald_full_name(id)); if (sym->type != OPENSHAPE && sym->type != GRAPH) don_err(NotOpenshapeOrGraph, donald_full_name(id)); change_context(sym); } else { /* id == ~ */ change_context(SymEnd); } check_id(Rexpr); Etype = Rtype; resume_context(); break; case OP_GLOBAL: backup_context(); reset_context(); check_id(Lexpr); Etype = Ltype; restore_context(); break; case OP_EDEN: Etype = ANY; break; default: don_err(Impossible, "check.c"); break; } } /*--------------------------------------------------+----------+ | count_id | +----------*/ int count_id(tree expr) { /* return no. of id in an id-list */ int lcount, rcount; if (expr == EMPTYTREE) return 0; switch (expr->op) { case OP_ID: case OP_SLASH: case OP_GLOBAL: check_id(expr); case OP_EDEN: return 1; case OP_COMMA: lcount = count_id(Lexpr); rcount = count_id(Rexpr); return (lcount == ERROR) || (rcount == ERROR) ? ERROR : lcount + rcount; default: return ERROR; } } /*------------+------------------------------------------------+ | semantic_1, semantic_2, semantic_3, semantic_4 | +------------------------------------------------*/ /* check expression types: ** E = result data type (if ok) ** L = left expr data type expected ** M = middle expr data type expected ** R = right expr data type expected ** X = extra expr data type expected ** return 0 if ok ** 1 if not match */ static int semantic_1(tree expr, int E, int L) { return (Ltype != L && Ltype != ANY) || ((Etype = E), 0); } static int semantic_2(tree expr, int E, int L, int R) { return (Ltype != L && Ltype != ANY) || (Rtype != R && Rtype != ANY) || ((Etype = E), 0); } static int semantic_3(tree expr, int E, int L, int M, int R) { return (Ltype != L && Ltype != ANY) || (Mtype != M && Mtype != ANY) || (Rtype != R && Rtype != ANY) || ((Etype = E), 0); } static int semantic_4(tree expr, int E, int L, int M, int R, int X) { return (Ltype != L && Ltype != ANY) || (Mtype != M && Mtype != ANY) || (Rtype != R && Rtype != ANY) || (Xtype != X && Xtype != ANY) || ((Etype = E), 0); } /*------------------------------------------------+------------+ | count_expr | +------------*/ int count_expr(tree expr) { /* return no. of expr in an expr-list */ if (expr == EMPTYTREE) return 0; check_children_type(expr); switch (expr->op) { case OP_COMMA: return count_expr(Lexpr) + count_expr(Rexpr); case OP_INF: Etype = INT; break; case OP_PLUS: case OP_MINUS: if (semantic_2(expr, Ltype, Ltype, Ltype) && semantic_2(expr, REAL, REAL, INT) && semantic_2(expr, REAL, INT, REAL)) TypeClash(); else if (Etype == POINT) { switch (expr->op) { case OP_PLUS: expr->op = OP_VECT_ADD; break; case OP_MINUS: expr->op = OP_VECT_SUB; break; } } break; case OP_MULT: case OP_DIV: if (semantic_2(expr, INT, INT, INT) && semantic_2(expr, REAL, INT, REAL) && semantic_2(expr, REAL, REAL, INT) && semantic_2(expr, REAL, REAL, REAL) && semantic_2(expr, POINT, POINT, INT) && semantic_2(expr, POINT, POINT, REAL)) TypeClash(); else { if (Ltype == POINT) { Etype = POINT; } else if (Ltype == REAL || Rtype == REAL) { Etype = REAL; } if (Etype == POINT) { switch (expr->op) { case OP_MULT: expr->op = OP_SCALAR_MULT; break; case OP_DIV: expr->op = OP_SCALAR_DIV; break; } } } break; case OP_MOD: if (semantic_2(expr, Ltype, Ltype, INT)) TypeClash(); else if (Etype == POINT) expr->op = OP_SCALAR_MOD; else if (Etype != INT) TypeClash(); break; case OP_UMINUS: case OP_RANDOM: if (semantic_1(expr, INT, INT) && semantic_1(expr, REAL, REAL)) TypeClash(); break; case OP_TRUNC: if (semantic_1(expr, INT, REAL)) TypeClash(); break; case OP_FLOAT: if (semantic_1(expr, REAL, INT)) TypeClash(); break; case OP_SQRT: case OP_SIN: case OP_COS: case OP_TAN: case OP_ASIN: case OP_ACOS: case OP_ATAN: case OP_LOG: case OP_EXP: if (semantic_1(expr, REAL, INT)) { if (semantic_1(expr, REAL, REAL)) TypeClash(); } else /* cast the argument to floating point */ expr->left = dtree1(OP_FLOAT, expr->left); break; case OP_DOTX: case OP_DOTY: if (semantic_1(expr, POINT, POINT)) TypeClash(); break; case OP_DOTRAD: case OP_DOTARG: if (semantic_1(expr, REAL, POINT) && /* can be INT */ semantic_1(expr, REAL, ARC)) TypeClash(); break; case OP_DOT1: case OP_DOT2: if (semantic_1(expr, REAL, POINT) && /* can be INT */ semantic_1(expr, POINT, LINE) && semantic_1(expr, POINT, ARC)) TypeClash(); break; case OP_CART: case OP_POLAR: if (semantic_2(expr, POINT, INT, INT) && semantic_2(expr, POINT, REAL, REAL) && semantic_2(expr, POINT, INT, REAL) && semantic_2(expr, POINT, REAL, INT)) TypeClash(); break; case OP_LINE: if (semantic_2(expr, LINE, POINT, POINT)) TypeClash(); break; case OP_ARC: if (semantic_3(expr, ARC, POINT, POINT, REAL) && semantic_3(expr, ARC, POINT, POINT, INT)) TypeClash(); break; case OP_CIRCLE: if (semantic_2(expr, CIRCLE, POINT, REAL) && semantic_2(expr, CIRCLE, POINT, INT)) TypeClash(); break; case OP_ELLIPSE: if (semantic_3(expr, ELLIPSE, POINT, POINT, POINT) && semantic_3(expr, ELLIPSE, POINT, POINT, POINT)) TypeClash(); break; case OP_RECTANGLE: if (semantic_2(expr, RECTANGLE, POINT, POINT)) TypeClash(); break; case OP_LABEL: if (semantic_2(expr, LABEL, MYCHAR, POINT) && semantic_2(expr, LABEL, IMAGE, POINT)) TypeClash(); break; case OP_IF: if (semantic_3(expr, Ltype, Ltype, BOOLEAN, Ltype)) TypeClash(); break; case OP_SLASH_SLASH: if (semantic_2(expr, MYCHAR, MYCHAR, MYCHAR)) TypeClash(); break; case OP_ITOS: if (semantic_1(expr, MYCHAR, INT)) TypeClash(); break; case OP_RTOS: if (semantic_2(expr, MYCHAR, REAL, MYCHAR)) TypeClash(); break; /* case OP_MONITOR: if (semantic_3(expr, MONITOR, MYCHAR, BOOLEAN, MYCHAR)) TypeClash(); break; case OP_IMPOSE: if (semantic_1(expr, IMPOSE, BOOLEAN)) TypeClash(); break; */ case OP_INTERSECT: if (semantic_2(expr, POINT, LINE, LINE)) TypeClash(); break; case OP_PARALLEL: if (semantic_4(expr, LINE, LINE, POINT, INT, INT) && semantic_4(expr, LINE, LINE, POINT, REAL, REAL) && semantic_4(expr, LINE, LINE, POINT, INT, REAL) && semantic_4(expr, LINE, LINE, POINT, REAL, INT)) TypeClash(); break; case OP_PERPEND: if (semantic_2(expr, LINE, POINT, LINE)) TypeClash(); break; case OP_DISTANCE: if (semantic_2(expr, REAL, POINT, POINT) && semantic_2(expr, REAL, LINE, LINE)) TypeClash(); break; case OP_MIDPOINT: if (semantic_1(expr, POINT, LINE)) TypeClash(); break; case OP_TRANS: switch (Ltype) { case SHAPE: case OPENSHAPE: if (semantic_3(expr, SHAPE, Ltype, INT, INT) && semantic_3(expr, SHAPE, Ltype, INT, REAL) && semantic_3(expr, SHAPE, Ltype, REAL, INT) && semantic_3(expr, SHAPE, Ltype, REAL, REAL)) TypeClash(); break; case INT: case REAL: TypeClash(); break; default: if (semantic_3(expr, Ltype, Ltype, INT, INT) && semantic_3(expr, Ltype, Ltype, INT, REAL) && semantic_3(expr, Ltype, Ltype, REAL, INT) && semantic_3(expr, Ltype, Ltype, REAL, REAL)) TypeClash(); break; } break; case OP_ROT: switch (Ltype) { case SHAPE: case OPENSHAPE: if (semantic_3(expr, SHAPE, Ltype, POINT, INT) && semantic_3(expr, SHAPE, Ltype, POINT, REAL)) TypeClash(); break; case INT: case REAL: TypeClash(); break; default: if (semantic_3(expr, Ltype, Ltype, POINT, INT) && semantic_3(expr, Ltype, Ltype, POINT, REAL)) TypeClash(); break; } break; case OP_SCALE: switch (Ltype) { case SHAPE: case OPENSHAPE: if (semantic_2(expr, SHAPE, Ltype, INT) && semantic_2(expr, SHAPE, Ltype, REAL)) TypeClash(); break; default: if (semantic_2(expr, Ltype, Ltype, INT) && semantic_2(expr, Ltype, Ltype, REAL)) TypeClash(); break; } break; case OP_PAREN: Etype = Ltype; break; case OP_ID: case OP_SLASH: case OP_GLOBAL: check_id(expr); break; case OP_AND: case OP_OR: if (semantic_2(expr, BOOLEAN, BOOLEAN, BOOLEAN)) TypeClash(); break; case OP_NOT: if (semantic_1(expr, BOOLEAN, BOOLEAN)) TypeClash(); break; case OP_EQ_EQ: case OP_NOT_EQ: case OP_LT: case OP_LT_EQ: case OP_GT: case OP_GT_EQ: if (semantic_2(expr, BOOLEAN, INT, INT) && semantic_2(expr, BOOLEAN, REAL, REAL) && semantic_2(expr, BOOLEAN, INT, REAL) && semantic_2(expr, BOOLEAN, REAL, INT)) TypeClash(); break; case OP_COLINEAR: case OP_PT_BETWN_PTS: if (semantic_3(expr, BOOLEAN, POINT, POINT, POINT)) TypeClash(); break; case OP_INTERSECTS: if (semantic_2(expr, BOOLEAN, LINE, LINE)) TypeClash(); break; case OP_SEPARATES: if (semantic_3(expr, BOOLEAN, LINE, POINT, POINT)) TypeClash(); break; case OP_INCLUDES: if (semantic_2(expr, BOOLEAN, CIRCLE, POINT)) TypeClash(); break; case OP_INCIDENT: if (semantic_2(expr, BOOLEAN, LINE, POINT) && semantic_2(expr, BOOLEAN, CIRCLE, POINT)) TypeClash(); break; case OP_DISTLARGER: case OP_DISTSMALLER: if (semantic_3(expr, BOOLEAN, POINT, POINT, INT) && semantic_3(expr, BOOLEAN, POINT, POINT, REAL) && semantic_3(expr, BOOLEAN, LINE, POINT, INT) && semantic_3(expr, BOOLEAN, LINE, POINT, REAL)) TypeClash(); break; case OP_I: Etype = INT; break; case OP_XI: Etype = REAL; break; case OP_FI: Etype = REAL; break; case OP_I_1: Etype = INT; break; case OP_XI_1: Etype = REAL; break; case OP_FI_1: Etype = REAL; break; case OP_GSPECLIST: if (Lexpr == 0) Etype = GSPEC; else if (semantic_2(expr, GSPEC, GSPEC, GSPEC)) TypeClash(); break; case OP_GSPEC: if (Lexpr == 0) Etype = GSPEC; else if ((Ltype != (int) Rexpr) || ((Etype = GSPEC), 0)) TypeClash(); break; case OP_IMGFUNC: count_expr(Rexpr); Etype = IMAGE; break; case OP_FUNC: count_expr(Rexpr); case OP_EDEN: Etype = ANY; break; } return 1; /* default */ } static void check_children_type(tree expr) { if (expr->type != UNDEFINED)/* already checked */ return; switch (nary(expr->op)) { case 4: count_expr(expr->extra); case 3: count_expr(expr->mid); case 2: count_expr(expr->right); case 1: count_expr(expr->left); } } tkeden1.18/Donald/parser.c010060000025250000147000002654030731441570600167310ustar00ashleydcsother00003470000356 /* A Bison parser, made from parser.y by GNU Bison version 1.28 */ #define YYBISON 1 /* Identify Bison output. */ #define yyparse dd_parse #define yylex dd_lex #define yyerror dd_error #define yylval dd_lval #define yychar dd_char #define yydebug dd_debug #define yynerrs dd_nerrs #define INF 257 #define PI 258 #define I 259 #define XI 260 #define FI 261 #define I_1 262 #define XI_1 263 #define FI_1 264 #define IMAGE 265 #define MYCHAR 266 #define REAL 267 #define INT 268 #define BOOLEAN 269 #define POINT 270 #define LABEL 271 #define GSPEC 272 #define GSPECLIST 273 #define ANY 274 #define LINE 275 #define CIRCLE 276 #define ELLIPSE 277 #define SHAPE 278 #define OPENSHAPE 279 #define ARC 280 #define RECTANGLE 281 #define GRAPH 282 #define OF 283 #define VIEWPORT 284 #define DELETE 285 #define WITHIN 286 #define IF 287 #define THEN 288 #define ELSE 289 #define ID 290 #define IMGFUNC 291 #define CSTRING 292 #define BOOL 293 #define INUMBER 294 #define RNUMBER 295 #define ITOS 296 #define RTOS 297 #define TRUNC 298 #define FLOAT 299 #define SQRT 300 #define SIN 301 #define COS 302 #define TAN 303 #define ASIN 304 #define ACOS 305 #define ATAN 306 #define LOG 307 #define EXP 308 #define RANDOM 309 #define ROT 310 #define SCALE 311 #define TRANS 312 #define INTERSECT 313 #define PARALLEL 314 #define PERPEND 315 #define DISTANCE 316 #define MIDPOINT 317 #define PT_BETWN_PTS 318 #define COLINEAR 319 #define INTERSECTS 320 #define SEPARATES 321 #define INCLUDES 322 #define INCIDENT 323 #define DISTLARGER 324 #define DISTSMALLER 325 #define QUERY 326 #define SEMICOLON 327 #define COLON 328 #define EQUALS 329 #define COMMA 330 #define OR 331 #define AND 332 #define NOT 333 #define EQ_EQ 334 #define NOT_EQ 335 #define GT 336 #define GT_EQ 337 #define LT 338 #define LT_EQ 339 #define SLASH_SLASH 340 #define ATSIGN 341 #define PLUS 342 #define MINUS 343 #define STAR 344 #define PERCENT 345 #define DIV 346 #define MOD 347 #define TILDE 348 #define TILDE_SLASH 349 #define DOTX 350 #define DOTY 351 #define DOTARG 352 #define DOTRAD 353 #define DOT1 354 #define DOT2 355 #define UMINUS 356 #define SLASH 357 #define LID 358 #define AMPERSAND 359 #define HASH 360 #define VERTBAR 361 #define NEWLINE 362 #define LPAREN 363 #define RPAREN 364 #define LBRACK 365 #define RBRACK 366 #define LCURLY 367 #define RCURLY 368 #define LANGLE 369 #define RANGLE 370 #line 1 "parser.y" /* * $Id: parser.y,v 1.13 1999/11/16 21:20:40 ashley Rel1.10 $ */ /* This is from the Autoconf manual. Note the pragma directive is indented so that pre-ANSI C compilers will ignore it. [Ash] */ /* AIX requires this to be the first thing in the file */ #ifdef __GNUC__ # define alloca __builtin_alloca #else # if HAVE_ALLOCA_H # include # else # ifdef _AIX #pragma alloca # else # ifndef alloca /* predefined by HP cc +Olibcalls */ char *alloca (); # endif # endif # endif #endif static char rcsid[] = "$Id: parser.y,v 1.13 1999/11/16 21:20:40 ashley Rel1.10 $"; #include "../config.h" #include #include #include #include "tree.h" #include "symbol.h" #include "error.h" #include "../Eden/error.h" #include "oper.h" #include "../EX/script.h" #include "../Eden/emalloc.h" #ifdef HAVE_DMALLOC #include #endif #define YYERROR_VERBOSE 1 #ifdef DEBUG extern int Debug; #define display(a) if (Debug & 16) fprintf(stderr, a) #define display2(a,i) if (Debug & 16) fprintf(stderr, a, i) #endif #ifndef DEBUG #define display(a) /* nothing */ #define display2(a,i) /* nothing */ #endif #define ERROR -1 extern Script *dd_script; extern int _changed; extern void eden_declare(char *, int, char *); extern void declare_openshape(void); extern void Declare(int, tree); extern void DeclareGraph(tree); extern void Define(tree, tree); extern void DefineFunc(int, tree); extern void Delete(tree); extern int reset_context(void); extern void change_scope(tree); extern void resume_scope(void); extern int count_id(tree); extern int count_expr(tree); extern void freeTree(tree); extern void yyerror(char *); extern char *expr_to_donald_name(tree); extern char *expr_to_eden_name(tree); extern char *eden_full_name(char *); static char *withinName; static char temp[256]; extern int dd_appAgentName; #ifdef DISTRIB extern void propagateDonaldDef(char *, char *); /* for agency --sun */ extern int handle_check1(char *); int withinHandle=1; #endif /* DISTRIB */ #line 89 "parser.y" typedef union { char *s; /* identifier, etc */ int i; /* integer value */ double r; /* floating point value */ tree t; /* expression tree */ } YYSTYPE; #include #ifndef __cplusplus #ifndef __STDC__ #define const #endif #endif #define YYFINAL 276 #define YYFLAG -32768 #define YYNTBASE 117 #define YYTRANSLATE(x) ((unsigned)(x) <= 370 ? yytranslate[x] : 139) static const char yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116 }; #if YYDEBUG != 0 static const short yyprhs[] = { 0, 0, 1, 4, 7, 10, 12, 14, 15, 18, 20, 22, 24, 28, 31, 34, 40, 45, 47, 50, 54, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 90, 95, 100, 103, 107, 109, 113, 115, 117, 119, 121, 123, 125, 127, 129, 131, 133, 135, 137, 141, 146, 148, 151, 155, 161, 167, 173, 181, 188, 195, 204, 211, 215, 219, 223, 227, 231, 234, 237, 241, 245, 249, 253, 257, 261, 265, 269, 273, 278, 285, 288, 291, 294, 297, 300, 303, 308, 314, 318, 323, 328, 335, 344, 355, 362, 364, 366, 368, 370, 372, 374, 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, 396, 398, 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, 421, 425, 428, 430, 432, 434, 435, 437, 441, 446, 449, 453, 457 }; static const short yyrhs[] = { -1, 117, 118, 0, 117, 1, 0, 30, 36, 0, 124, 0, 126, 0, 0, 119, 127, 0, 122, 0, 120, 0, 108, 0, 31, 128, 108, 0, 32, 133, 0, 121, 118, 0, 121, 108, 113, 123, 114, 0, 121, 113, 123, 114, 0, 118, 0, 123, 118, 0, 125, 128, 108, 0, 28, 128, 0, 14, 0, 13, 0, 12, 0, 15, 0, 16, 0, 21, 0, 26, 0, 22, 0, 23, 0, 17, 0, 24, 0, 25, 0, 11, 0, 27, 0, 128, 75, 128, 108, 0, 6, 75, 129, 108, 0, 7, 75, 129, 108, 0, 72, 108, 0, 127, 72, 108, 0, 129, 0, 128, 76, 129, 0, 3, 0, 4, 0, 40, 0, 41, 0, 38, 0, 39, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 111, 137, 112, 0, 111, 108, 137, 112, 0, 133, 0, 36, 79, 0, 109, 129, 110, 0, 113, 129, 76, 129, 114, 0, 113, 129, 87, 129, 114, 0, 111, 129, 76, 129, 112, 0, 111, 129, 76, 129, 76, 129, 112, 0, 22, 109, 129, 76, 129, 110, 0, 27, 109, 129, 76, 129, 110, 0, 23, 109, 129, 76, 129, 76, 129, 110, 0, 17, 109, 129, 76, 129, 110, 0, 129, 88, 129, 0, 129, 89, 129, 0, 129, 90, 129, 0, 129, 93, 129, 0, 129, 92, 129, 0, 89, 129, 0, 79, 129, 0, 129, 78, 129, 0, 129, 77, 129, 0, 129, 80, 129, 0, 129, 81, 129, 0, 129, 84, 129, 0, 129, 85, 129, 0, 129, 82, 129, 0, 129, 83, 129, 0, 129, 86, 129, 0, 42, 109, 129, 110, 0, 43, 109, 129, 76, 129, 110, 0, 129, 96, 0, 129, 97, 0, 129, 100, 0, 129, 101, 0, 129, 99, 0, 129, 98, 0, 36, 79, 109, 110, 0, 36, 79, 109, 128, 110, 0, 37, 109, 110, 0, 37, 109, 128, 110, 0, 130, 109, 129, 110, 0, 131, 109, 129, 76, 129, 110, 0, 132, 109, 129, 76, 129, 76, 129, 110, 0, 60, 109, 129, 76, 129, 76, 129, 76, 129, 110, 0, 33, 129, 34, 129, 35, 129, 0, 46, 0, 47, 0, 48, 0, 49, 0, 50, 0, 51, 0, 52, 0, 53, 0, 54, 0, 44, 0, 45, 0, 63, 0, 55, 0, 59, 0, 61, 0, 62, 0, 57, 0, 66, 0, 68, 0, 69, 0, 56, 0, 58, 0, 64, 0, 65, 0, 67, 0, 70, 0, 71, 0, 134, 0, 103, 134, 0, 135, 103, 134, 0, 95, 134, 0, 135, 0, 136, 0, 36, 0, 0, 138, 0, 137, 73, 138, 0, 137, 73, 108, 138, 0, 125, 74, 0, 125, 74, 129, 0, 125, 74, 108, 0, 125, 74, 129, 108, 0 }; #endif #if YYDEBUG != 0 static const short yyrline[] = { 0, 168, 170, 171, 174, 176, 185, 186, 187, 188, 193, 199, 219, 231, 259, 274, 288, 303, 305, 308, 320, 368, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 385, 415, 421, 429, 435, 442, 444, 482, 485, 489, 494, 500, 506, 511, 512, 513, 514, 515, 516, 518, 520, 523, 525, 527, 529, 531, 533, 535, 537, 539, 541, 543, 546, 547, 548, 549, 550, 551, 557, 558, 559, 560, 561, 562, 563, 564, 565, 567, 568, 570, 573, 574, 575, 576, 577, 578, 580, 582, 584, 586, 588, 590, 592, 594, 598, 605, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 621, 623, 624, 625, 626, 627, 628, 631, 633, 634, 635, 636, 637, 638, 641, 643, 647, 650, 655, 658, 662, 665, 667, 668, 670, 674, 676, 677, 678 }; #endif #if YYDEBUG != 0 || defined (YYERROR_VERBOSE) static const char * const yytname[] = { "$","error","$undefined.","INF","PI", "I","XI","FI","I_1","XI_1","FI_1","IMAGE","MYCHAR","REAL","INT","BOOLEAN","POINT", "LABEL","GSPEC","GSPECLIST","ANY","LINE","CIRCLE","ELLIPSE","SHAPE","OPENSHAPE", "ARC","RECTANGLE","GRAPH","OF","VIEWPORT","DELETE","WITHIN","IF","THEN","ELSE", "ID","IMGFUNC","CSTRING","BOOL","INUMBER","RNUMBER","ITOS","RTOS","TRUNC","FLOAT", "SQRT","SIN","COS","TAN","ASIN","ACOS","ATAN","LOG","EXP","RANDOM","ROT","SCALE", "TRANS","INTERSECT","PARALLEL","PERPEND","DISTANCE","MIDPOINT","PT_BETWN_PTS", "COLINEAR","INTERSECTS","SEPARATES","INCLUDES","INCIDENT","DISTLARGER","DISTSMALLER", "QUERY","SEMICOLON","COLON","EQUALS","COMMA","OR","AND","NOT","EQ_EQ","NOT_EQ", "GT","GT_EQ","LT","LT_EQ","SLASH_SLASH","ATSIGN","PLUS","MINUS","STAR","PERCENT", "DIV","MOD","TILDE","TILDE_SLASH","DOTX","DOTY","DOTARG","DOTRAD","DOT1","DOT2", "UMINUS","SLASH","LID","AMPERSAND","HASH","VERTBAR","NEWLINE","LPAREN","RPAREN", "LBRACK","RBRACK","LCURLY","RCURLY","LANGLE","RANGLE","program_list","stmt", "@1","delete","within_id","within_clause","stmt_list","declaration","type_name", "definition","evaluation","expr_list","expr","func1","func2","func3","identifier", "local_identifier","local_id","id","graph_spec_list","graph_spec", NULL }; #endif static const short yyr1[] = { 0, 117, 117, 117, 118, 118, 118, 119, 118, 118, 118, 118, 120, 121, 122, 122, 122, 123, 123, 124, 124, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 125, 126, 126, 126, 127, 127, 128, 128, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 130, 131, 131, 131, 131, 131, 131, 131, 132, 132, 132, 132, 132, 132, 132, 133, 133, 134, 134, 134, 135, 136, 137, 137, 137, 137, 138, 138, 138, 138 }; static const short yyr2[] = { 0, 0, 2, 2, 2, 1, 1, 0, 2, 1, 1, 1, 3, 2, 2, 5, 4, 1, 2, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 4, 4, 2, 3, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 4, 1, 2, 3, 5, 5, 5, 7, 6, 6, 8, 6, 3, 3, 3, 3, 3, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 6, 2, 2, 2, 2, 2, 2, 4, 5, 3, 4, 4, 6, 8, 10, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 2, 1, 1, 1, 0, 1, 3, 4, 2, 3, 3, 4 }; static const short yydefact[] = { 1, 0, 3, 42, 43, 48, 49, 50, 51, 52, 53, 33, 23, 22, 21, 24, 25, 30, 26, 28, 29, 31, 32, 27, 34, 0, 0, 0, 0, 0, 133, 0, 46, 47, 44, 45, 0, 0, 109, 110, 100, 101, 102, 103, 104, 105, 106, 107, 108, 112, 120, 116, 121, 113, 0, 114, 115, 111, 122, 123, 117, 124, 118, 119, 125, 126, 0, 0, 0, 0, 11, 0, 134, 0, 2, 0, 10, 7, 9, 5, 0, 6, 0, 40, 0, 0, 0, 56, 127, 131, 132, 0, 0, 0, 0, 0, 0, 49, 50, 0, 0, 0, 0, 20, 4, 0, 133, 13, 0, 57, 0, 0, 0, 0, 73, 72, 130, 128, 0, 134, 0, 0, 0, 135, 0, 0, 8, 11, 7, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 85, 86, 90, 89, 87, 88, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 93, 0, 0, 0, 0, 58, 30, 28, 29, 34, 0, 138, 0, 0, 54, 0, 0, 38, 0, 7, 17, 7, 40, 19, 0, 41, 75, 74, 76, 77, 80, 81, 78, 79, 82, 67, 68, 69, 71, 70, 0, 0, 0, 129, 36, 37, 0, 0, 0, 0, 0, 91, 0, 94, 83, 0, 0, 55, 140, 139, 0, 0, 136, 0, 0, 39, 7, 16, 18, 35, 95, 0, 0, 0, 0, 0, 0, 0, 92, 0, 0, 141, 0, 61, 137, 59, 60, 15, 0, 0, 66, 63, 0, 64, 99, 84, 0, 0, 96, 0, 0, 0, 62, 0, 65, 0, 97, 0, 98, 0, 0 }; static const short yydefgoto[] = { 1, 186, 75, 76, 77, 78, 187, 79, 80, 81, 126, 82, 83, 84, 85, 86, 87, 88, 89, 90, 122, 123 }; static const short yypact[] = {-32768, 240,-32768,-32768,-32768,-32768, -49, -48,-32768,-32768,-32768, -32768,-32768,-32768,-32768,-32768,-32768, -81,-32768, -73, -56, -32768,-32768,-32768, -55, 1241, 4, 1241, -27, 1241, -30, -54,-32768,-32768,-32768,-32768, -53, -52,-32768,-32768,-32768, -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -32768,-32768,-32768, -50,-32768,-32768,-32768,-32768,-32768,-32768, -32768,-32768,-32768,-32768,-32768, 1241, 1241, -26, -26,-32768, 1241, 797, 1241,-32768, -21,-32768, 575,-32768,-32768, 1241, -32768, -63, 2199, -38, -37, -36,-32768,-32768, -43,-32768, 1241, 1241, 1241, 1241, 1241, 1241,-32768,-32768, -81, -73, -56, -55, -15,-32768, -62,-32768,-32768, 1279, -35, 908, 1241, 1241, 1241, 2245,-32768,-32768,-32768, 1408, 8, 1, 1862, -67,-32768, 1836, -28, 6, -34, 686,-32768, -60, 1241, 1241, 1241, 1241, 1241, 1241, 1241, 1241, 1241, 1241, 1241, 1241, 1241, 1241, 1241, 1241,-32768,-32768,-32768,-32768, -32768,-32768, 1241, 1241, 1241, -26, 1749, 1778, 1888, 1914, 1940, 1966,-32768, 1241, 1019,-32768, -71, 1439, 1992, 2018, -32768,-32768,-32768,-32768,-32768, -65, 1130, 1241, 116,-32768, 1241, 1241,-32768, -22, 686,-32768, 351, 1836,-32768, -58, 2199, 2223, 2245, 2265, 2265, 2281, 2281, 2281, 2281, 106, -5, -5, 217, 217, 217, 1470, 2044, 2070,-32768,-32768, -32768, 1241, 1241, 1241, 1241, 1304,-32768, -69,-32768,-32768, 1241, 1241,-32768,-32768, 1807, 1383, 8,-32768, 1329, 1356, -32768, 463,-32768,-32768,-32768,-32768, 1241, 1241, 1501, 1532, 2096, 1563, 1241,-32768, 1594, 2122,-32768, 1241,-32768,-32768, -32768,-32768,-32768, 1625, 2148,-32768,-32768, 1241,-32768, 2199, -32768, 1241, 79,-32768, 1241, 1656, 2174,-32768, 1687,-32768, 1241,-32768, 1718,-32768, 81,-32768 }; static const short yypgoto[] = {-32768, 0,-32768,-32768,-32768,-32768, -96,-32768, -61,-32768,-32768, -10, -29,-32768,-32768,-32768, 69, -66,-32768,-32768, -18, -175 }; #define YYLAST 2382 static const short yytable[] = { 108, 74, 116, 117, 228, 132, 179, 132, 179, 106, 106, 120, 131, 132, 132, 103, 132, 105, 132, 11, 12, 13, 14, 15, 16, 172, 91, 92, 93, 18, 173, 174, 21, 22, 23, 175, 94, 114, 115, 219, 104, 244, 118, 121, 124, 180, 163, 223, 189, 109, 235, 125, 250, 95, 96, 110, 111, 112, 120, 113, 156, 132, 157, 158, 159, 160, 161, 162, 68, 68, 130, 153, 154, 155, 165, 177, 69, 129, 184, 185, 183, 276, 168, 169, 170, 144, 231, 145, 146, 232, 209, 147, 148, 149, 150, 151, 152, 107, 0, 188, 167, 176, 0, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 120, 0, 0, 190, 0, 0, 206, 207, 208, 11, 12, 13, 14, 15, 16, 172, 0, 216, 0, 18, 173, 174, 21, 22, 23, 175, 0, 0, 0, 0, 225, 226, 0, 0, 229, 230, 0, 218, 133, 134, 0, 135, 136, 137, 138, 139, 140, 141, 120, 142, 143, 144, 0, 145, 146, 0, 0, 147, 148, 149, 150, 151, 152, 0, 0, 239, 240, 241, 242, 234, 0, 0, 0, 268, 245, 246, 142, 143, 144, 0, 145, 146, 0, 0, 147, 148, 149, 150, 151, 152, 254, 255, 0, 0, 0, 0, 260, 0, 0, 0, 0, 263, 0, 0, 0, 0, 227, 0, 0, 0, 0, 266, 0, 0, 234, 267, 0, 0, 269, 0, 0, 0, 275, 2, 273, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 0, 0, 18, 19, 20, 21, 22, 23, 24, 25, 0, 26, 27, 28, 29, 0, 0, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, -7, 147, 148, 149, 150, 151, 152, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 69, 0, 0, 0, 0, 70, 71, 0, 72, 0, 73, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 0, 0, 18, 19, 20, 21, 22, 23, 24, 25, 0, 26, 27, 28, 29, 0, 0, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 0, 0, 0, 0, 0, 0, 0, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 69, 0, 0, 0, 0, 70, 71, 0, 72, 0, 73, 233, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 0, 0, 18, 19, 20, 21, 22, 23, 24, 25, 0, 26, 27, 28, 29, 0, 0, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 0, 0, 0, 0, 0, 0, 0, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 69, 0, 0, 0, 0, 70, 71, 0, 72, 0, 73, 253, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 0, 0, 18, 19, 20, 21, 22, 23, 24, 25, 0, 26, 27, 28, 29, 0, 0, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 0, 0, 0, 0, 0, 0, 0, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 69, 0, 0, 0, 0, 127, 71, 0, 72, 0, 128, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 0, 0, 18, 19, 20, 21, 22, 23, 24, 25, 0, 26, 27, 28, 29, 0, 0, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 0, 0, 0, 0, 0, 0, 0, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 69, 0, 0, 0, 0, 70, 71, 0, 72, 0, 73, 3, 4, 5, 97, 98, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0, 0, 0, 18, 19, 20, 21, 22, 23, 24, 0, 0, 0, 0, 0, 29, 0, 0, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 0, 0, 0, 0, 0, 0, 0, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 69, 0, 0, 0, 0, 119, 71, 0, 72, 0, 73, 3, 4, 5, 97, 98, 8, 9, 10, 0, 0, 0, 0, 0, 0, 99, 0, 0, 0, 0, 100, 101, 0, 0, 0, 102, 0, 0, 0, 0, 0, 29, 0, 0, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 0, 0, 0, 0, 0, 0, 0, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 69, 0, 0, 0, 0, 0, 71, 166, 72, 0, 73, 3, 4, 5, 97, 98, 8, 9, 10, 0, 0, 0, 0, 0, 0, 99, 0, 0, 0, 0, 100, 101, 0, 0, 0, 102, 0, 0, 0, 0, 0, 29, 0, 0, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 0, 0, 0, 0, 0, 0, 0, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 69, 0, 0, 0, 0, 0, 71, 217, 72, 0, 73, 3, 4, 5, 97, 98, 8, 9, 10, 0, 0, 0, 0, 0, 0, 99, 0, 0, 0, 0, 100, 101, 0, 0, 0, 102, 0, 0, 0, 0, 0, 29, 0, 0, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 0, 0, 0, 0, 0, 0, 0, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 69, 0, 0, 0, 0, 224, 71, 0, 72, 0, 73, 3, 4, 5, 97, 98, 8, 9, 10, 0, 0, 0, 0, 0, 0, 99, 0, 0, 0, 0, 100, 101, 0, 0, 0, 102, 0, 0, 0, 0, 0, 29, 0, 0, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 164, 0, 0, 0, 0, 0, 0, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 0, 68, 0, 0, 243, 0, 0, 0, 0, 69, 0, 0, 0, 0, 0, 71, 0, 72, 0, 73, 0, 133, 134, 0, 135, 136, 137, 138, 139, 140, 141, 0, 142, 143, 144, 0, 145, 146, 0, 0, 147, 148, 149, 150, 151, 152, 133, 134, 0, 135, 136, 137, 138, 139, 140, 141, 0, 142, 143, 144, 0, 145, 146, 0, 0, 147, 148, 149, 150, 151, 152, 133, 134, 0, 135, 136, 137, 138, 139, 140, 141, 0, 142, 143, 144, 0, 145, 146, 0, 0, 147, 148, 149, 150, 151, 152, 0, 0, 133, 134, 0, 135, 136, 137, 138, 139, 140, 141, 251, 142, 143, 144, 0, 145, 146, 0, 0, 147, 148, 149, 150, 151, 152, 0, 248, 133, 134, 0, 135, 136, 137, 138, 139, 140, 141, 252, 142, 143, 144, 0, 145, 146, 0, 0, 147, 148, 149, 150, 151, 152, 133, 134, 0, 135, 136, 137, 138, 139, 140, 141, 249, 142, 143, 144, 0, 145, 146, 0, 0, 147, 148, 149, 150, 151, 152, 0, 0, 0, 0, 0, 0, 133, 134, 171, 135, 136, 137, 138, 139, 140, 141, 0, 142, 143, 144, 0, 145, 146, 0, 0, 147, 148, 149, 150, 151, 152, 0, 0, 0, 0, 0, 0, 133, 134, 220, 135, 136, 137, 138, 139, 140, 141, 0, 142, 143, 144, 0, 145, 146, 0, 0, 147, 148, 149, 150, 151, 152, 0, 0, 0, 0, 0, 0, 133, 134, 236, 135, 136, 137, 138, 139, 140, 141, 0, 142, 143, 144, 0, 145, 146, 0, 0, 147, 148, 149, 150, 151, 152, 0, 0, 0, 0, 0, 0, 133, 134, 256, 135, 136, 137, 138, 139, 140, 141, 0, 142, 143, 144, 0, 145, 146, 0, 0, 147, 148, 149, 150, 151, 152, 0, 0, 0, 0, 0, 0, 133, 134, 257, 135, 136, 137, 138, 139, 140, 141, 0, 142, 143, 144, 0, 145, 146, 0, 0, 147, 148, 149, 150, 151, 152, 0, 0, 0, 0, 0, 0, 133, 134, 259, 135, 136, 137, 138, 139, 140, 141, 0, 142, 143, 144, 0, 145, 146, 0, 0, 147, 148, 149, 150, 151, 152, 0, 0, 0, 0, 0, 0, 133, 134, 261, 135, 136, 137, 138, 139, 140, 141, 0, 142, 143, 144, 0, 145, 146, 0, 0, 147, 148, 149, 150, 151, 152, 0, 0, 0, 0, 0, 0, 133, 134, 264, 135, 136, 137, 138, 139, 140, 141, 0, 142, 143, 144, 0, 145, 146, 0, 0, 147, 148, 149, 150, 151, 152, 0, 0, 0, 0, 0, 0, 133, 134, 270, 135, 136, 137, 138, 139, 140, 141, 0, 142, 143, 144, 0, 145, 146, 0, 0, 147, 148, 149, 150, 151, 152, 0, 0, 0, 0, 0, 0, 133, 134, 272, 135, 136, 137, 138, 139, 140, 141, 0, 142, 143, 144, 0, 145, 146, 0, 0, 147, 148, 149, 150, 151, 152, 0, 0, 0, 0, 0, 0, 133, 134, 274, 135, 136, 137, 138, 139, 140, 141, 0, 142, 143, 144, 0, 145, 146, 0, 0, 147, 148, 149, 150, 151, 152, 0, 0, 0, 0, 133, 134, 210, 135, 136, 137, 138, 139, 140, 141, 0, 142, 143, 144, 0, 145, 146, 0, 0, 147, 148, 149, 150, 151, 152, 0, 0, 0, 0, 133, 134, 211, 135, 136, 137, 138, 139, 140, 141, 0, 142, 143, 144, 0, 145, 146, 0, 0, 147, 148, 149, 150, 151, 152, 0, 0, 0, 181, 133, 134, 247, 135, 136, 137, 138, 139, 140, 141, 182, 142, 143, 144, 0, 145, 146, 0, 0, 147, 148, 149, 150, 151, 152, 178, 133, 134, 0, 135, 136, 137, 138, 139, 140, 141, 0, 142, 143, 144, 0, 145, 146, 0, 0, 147, 148, 149, 150, 151, 152, 212, 133, 134, 0, 135, 136, 137, 138, 139, 140, 141, 0, 142, 143, 144, 0, 145, 146, 0, 0, 147, 148, 149, 150, 151, 152, 213, 133, 134, 0, 135, 136, 137, 138, 139, 140, 141, 0, 142, 143, 144, 0, 145, 146, 0, 0, 147, 148, 149, 150, 151, 152, 214, 133, 134, 0, 135, 136, 137, 138, 139, 140, 141, 0, 142, 143, 144, 0, 145, 146, 0, 0, 147, 148, 149, 150, 151, 152, 215, 133, 134, 0, 135, 136, 137, 138, 139, 140, 141, 0, 142, 143, 144, 0, 145, 146, 0, 0, 147, 148, 149, 150, 151, 152, 221, 133, 134, 0, 135, 136, 137, 138, 139, 140, 141, 0, 142, 143, 144, 0, 145, 146, 0, 0, 147, 148, 149, 150, 151, 152, 222, 133, 134, 0, 135, 136, 137, 138, 139, 140, 141, 0, 142, 143, 144, 0, 145, 146, 0, 0, 147, 148, 149, 150, 151, 152, 237, 133, 134, 0, 135, 136, 137, 138, 139, 140, 141, 0, 142, 143, 144, 0, 145, 146, 0, 0, 147, 148, 149, 150, 151, 152, 238, 133, 134, 0, 135, 136, 137, 138, 139, 140, 141, 0, 142, 143, 144, 0, 145, 146, 0, 0, 147, 148, 149, 150, 151, 152, 258, 133, 134, 0, 135, 136, 137, 138, 139, 140, 141, 0, 142, 143, 144, 0, 145, 146, 0, 0, 147, 148, 149, 150, 151, 152, 262, 133, 134, 0, 135, 136, 137, 138, 139, 140, 141, 0, 142, 143, 144, 0, 145, 146, 0, 0, 147, 148, 149, 150, 151, 152, 265, 133, 134, 0, 135, 136, 137, 138, 139, 140, 141, 0, 142, 143, 144, 0, 145, 146, 0, 0, 147, 148, 149, 150, 151, 152, 271, 133, 134, 0, 135, 136, 137, 138, 139, 140, 141, 0, 142, 143, 144, 0, 145, 146, 0, 0, 147, 148, 149, 150, 151, 152, 133, 134, 0, 135, 136, 137, 138, 139, 140, 141, 0, 142, 143, 144, 0, 145, 146, 0, 0, 147, 148, 149, 150, 151, 152, 134, 0, 135, 136, 137, 138, 139, 140, 141, 0, 142, 143, 144, 0, 145, 146, 0, 0, 147, 148, 149, 150, 151, 152, 135, 136, 137, 138, 139, 140, 141, 0, 142, 143, 144, 0, 145, 146, 0, 0, 147, 148, 149, 150, 151, 152, 137, 138, 139, 140, 141, 0, 142, 143, 144, 0, 145, 146, 0, 0, 147, 148, 149, 150, 151, 152, 141, 0, 142, 143, 144, 0, 145, 146, 0, 0, 147, 148, 149, 150, 151, 152 }; static const short yycheck[] = { 29, 1, 68, 69, 179, 76, 73, 76, 73, 36, 36, 72, 75, 76, 76, 25, 76, 27, 76, 11, 12, 13, 14, 15, 16, 17, 75, 75, 109, 21, 22, 23, 24, 25, 26, 27, 109, 66, 67, 110, 36, 110, 71, 72, 73, 112, 108, 112, 108, 79, 108, 72, 227, 109, 109, 109, 109, 109, 119, 109, 103, 76, 91, 92, 93, 94, 95, 96, 95, 95, 80, 109, 109, 109, 109, 74, 103, 77, 72, 113, 108, 0, 111, 112, 113, 90, 108, 92, 93, 185, 156, 96, 97, 98, 99, 100, 101, 28, -1, 128, 110, 119, -1, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 179, -1, -1, 131, -1, -1, 153, 154, 155, 11, 12, 13, 14, 15, 16, 17, -1, 164, -1, 21, 22, 23, 24, 25, 26, 27, -1, -1, -1, -1, 177, 178, -1, -1, 181, 182, -1, 165, 77, 78, -1, 80, 81, 82, 83, 84, 85, 86, 227, 88, 89, 90, -1, 92, 93, -1, -1, 96, 97, 98, 99, 100, 101, -1, -1, 212, 213, 214, 215, 187, -1, -1, -1, 112, 221, 222, 88, 89, 90, -1, 92, 93, -1, -1, 96, 97, 98, 99, 100, 101, 237, 238, -1, -1, -1, -1, 243, -1, -1, -1, -1, 248, -1, -1, -1, -1, 108, -1, -1, -1, -1, 258, -1, -1, 232, 262, -1, -1, 265, -1, -1, -1, 0, 1, 271, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, -1, -1, -1, 21, 22, 23, 24, 25, 26, 27, 28, -1, 30, 31, 32, 33, -1, -1, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 96, 97, 98, 99, 100, 101, 79, -1, -1, -1, -1, -1, -1, -1, -1, -1, 89, -1, -1, -1, -1, -1, 95, -1, -1, -1, -1, -1, -1, -1, 103, -1, -1, -1, -1, 108, 109, -1, 111, -1, 113, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, -1, -1, -1, 21, 22, 23, 24, 25, 26, 27, 28, -1, 30, 31, 32, 33, -1, -1, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, -1, -1, -1, -1, -1, -1, -1, 79, -1, -1, -1, -1, -1, -1, -1, -1, -1, 89, -1, -1, -1, -1, -1, 95, -1, -1, -1, -1, -1, -1, -1, 103, -1, -1, -1, -1, 108, 109, -1, 111, -1, 113, 114, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, -1, -1, -1, 21, 22, 23, 24, 25, 26, 27, 28, -1, 30, 31, 32, 33, -1, -1, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, -1, -1, -1, -1, -1, -1, -1, 79, -1, -1, -1, -1, -1, -1, -1, -1, -1, 89, -1, -1, -1, -1, -1, 95, -1, -1, -1, -1, -1, -1, -1, 103, -1, -1, -1, -1, 108, 109, -1, 111, -1, 113, 114, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, -1, -1, -1, 21, 22, 23, 24, 25, 26, 27, 28, -1, 30, 31, 32, 33, -1, -1, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, -1, -1, -1, -1, -1, -1, -1, 79, -1, -1, -1, -1, -1, -1, -1, -1, -1, 89, -1, -1, -1, -1, -1, 95, -1, -1, -1, -1, -1, -1, -1, 103, -1, -1, -1, -1, 108, 109, -1, 111, -1, 113, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, -1, -1, -1, 21, 22, 23, 24, 25, 26, 27, 28, -1, 30, 31, 32, 33, -1, -1, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, -1, -1, -1, -1, -1, -1, -1, 79, -1, -1, -1, -1, -1, -1, -1, -1, -1, 89, -1, -1, -1, -1, -1, 95, -1, -1, -1, -1, -1, -1, -1, 103, -1, -1, -1, -1, 108, 109, -1, 111, -1, 113, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, -1, -1, -1, 21, 22, 23, 24, 25, 26, 27, -1, -1, -1, -1, -1, 33, -1, -1, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, -1, -1, -1, -1, -1, -1, -1, 79, -1, -1, -1, -1, -1, -1, -1, -1, -1, 89, -1, -1, -1, -1, -1, 95, -1, -1, -1, -1, -1, -1, -1, 103, -1, -1, -1, -1, 108, 109, -1, 111, -1, 113, 3, 4, 5, 6, 7, 8, 9, 10, -1, -1, -1, -1, -1, -1, 17, -1, -1, -1, -1, 22, 23, -1, -1, -1, 27, -1, -1, -1, -1, -1, 33, -1, -1, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, -1, -1, -1, -1, -1, -1, -1, 79, -1, -1, -1, -1, -1, -1, -1, -1, -1, 89, -1, -1, -1, -1, -1, 95, -1, -1, -1, -1, -1, -1, -1, 103, -1, -1, -1, -1, -1, 109, 110, 111, -1, 113, 3, 4, 5, 6, 7, 8, 9, 10, -1, -1, -1, -1, -1, -1, 17, -1, -1, -1, -1, 22, 23, -1, -1, -1, 27, -1, -1, -1, -1, -1, 33, -1, -1, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, -1, -1, -1, -1, -1, -1, -1, 79, -1, -1, -1, -1, -1, -1, -1, -1, -1, 89, -1, -1, -1, -1, -1, 95, -1, -1, -1, -1, -1, -1, -1, 103, -1, -1, -1, -1, -1, 109, 110, 111, -1, 113, 3, 4, 5, 6, 7, 8, 9, 10, -1, -1, -1, -1, -1, -1, 17, -1, -1, -1, -1, 22, 23, -1, -1, -1, 27, -1, -1, -1, -1, -1, 33, -1, -1, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, -1, -1, -1, -1, -1, -1, -1, 79, -1, -1, -1, -1, -1, -1, -1, -1, -1, 89, -1, -1, -1, -1, -1, 95, -1, -1, -1, -1, -1, -1, -1, 103, -1, -1, -1, -1, 108, 109, -1, 111, -1, 113, 3, 4, 5, 6, 7, 8, 9, 10, -1, -1, -1, -1, -1, -1, 17, -1, -1, -1, -1, 22, 23, -1, -1, -1, 27, -1, -1, -1, -1, -1, 33, -1, -1, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 34, -1, -1, -1, -1, -1, -1, 79, -1, -1, -1, -1, -1, -1, -1, -1, -1, 89, -1, -1, -1, -1, -1, 95, -1, -1, 35, -1, -1, -1, -1, 103, -1, -1, -1, -1, -1, 109, -1, 111, -1, 113, -1, 77, 78, -1, 80, 81, 82, 83, 84, 85, 86, -1, 88, 89, 90, -1, 92, 93, -1, -1, 96, 97, 98, 99, 100, 101, 77, 78, -1, 80, 81, 82, 83, 84, 85, 86, -1, 88, 89, 90, -1, 92, 93, -1, -1, 96, 97, 98, 99, 100, 101, 77, 78, -1, 80, 81, 82, 83, 84, 85, 86, -1, 88, 89, 90, -1, 92, 93, -1, -1, 96, 97, 98, 99, 100, 101, -1, -1, 77, 78, -1, 80, 81, 82, 83, 84, 85, 86, 114, 88, 89, 90, -1, 92, 93, -1, -1, 96, 97, 98, 99, 100, 101, -1, 76, 77, 78, -1, 80, 81, 82, 83, 84, 85, 86, 114, 88, 89, 90, -1, 92, 93, -1, -1, 96, 97, 98, 99, 100, 101, 77, 78, -1, 80, 81, 82, 83, 84, 85, 86, 112, 88, 89, 90, -1, 92, 93, -1, -1, 96, 97, 98, 99, 100, 101, -1, -1, -1, -1, -1, -1, 77, 78, 110, 80, 81, 82, 83, 84, 85, 86, -1, 88, 89, 90, -1, 92, 93, -1, -1, 96, 97, 98, 99, 100, 101, -1, -1, -1, -1, -1, -1, 77, 78, 110, 80, 81, 82, 83, 84, 85, 86, -1, 88, 89, 90, -1, 92, 93, -1, -1, 96, 97, 98, 99, 100, 101, -1, -1, -1, -1, -1, -1, 77, 78, 110, 80, 81, 82, 83, 84, 85, 86, -1, 88, 89, 90, -1, 92, 93, -1, -1, 96, 97, 98, 99, 100, 101, -1, -1, -1, -1, -1, -1, 77, 78, 110, 80, 81, 82, 83, 84, 85, 86, -1, 88, 89, 90, -1, 92, 93, -1, -1, 96, 97, 98, 99, 100, 101, -1, -1, -1, -1, -1, -1, 77, 78, 110, 80, 81, 82, 83, 84, 85, 86, -1, 88, 89, 90, -1, 92, 93, -1, -1, 96, 97, 98, 99, 100, 101, -1, -1, -1, -1, -1, -1, 77, 78, 110, 80, 81, 82, 83, 84, 85, 86, -1, 88, 89, 90, -1, 92, 93, -1, -1, 96, 97, 98, 99, 100, 101, -1, -1, -1, -1, -1, -1, 77, 78, 110, 80, 81, 82, 83, 84, 85, 86, -1, 88, 89, 90, -1, 92, 93, -1, -1, 96, 97, 98, 99, 100, 101, -1, -1, -1, -1, -1, -1, 77, 78, 110, 80, 81, 82, 83, 84, 85, 86, -1, 88, 89, 90, -1, 92, 93, -1, -1, 96, 97, 98, 99, 100, 101, -1, -1, -1, -1, -1, -1, 77, 78, 110, 80, 81, 82, 83, 84, 85, 86, -1, 88, 89, 90, -1, 92, 93, -1, -1, 96, 97, 98, 99, 100, 101, -1, -1, -1, -1, -1, -1, 77, 78, 110, 80, 81, 82, 83, 84, 85, 86, -1, 88, 89, 90, -1, 92, 93, -1, -1, 96, 97, 98, 99, 100, 101, -1, -1, -1, -1, -1, -1, 77, 78, 110, 80, 81, 82, 83, 84, 85, 86, -1, 88, 89, 90, -1, 92, 93, -1, -1, 96, 97, 98, 99, 100, 101, -1, -1, -1, -1, 77, 78, 108, 80, 81, 82, 83, 84, 85, 86, -1, 88, 89, 90, -1, 92, 93, -1, -1, 96, 97, 98, 99, 100, 101, -1, -1, -1, -1, 77, 78, 108, 80, 81, 82, 83, 84, 85, 86, -1, 88, 89, 90, -1, 92, 93, -1, -1, 96, 97, 98, 99, 100, 101, -1, -1, -1, 76, 77, 78, 108, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, -1, 92, 93, -1, -1, 96, 97, 98, 99, 100, 101, 76, 77, 78, -1, 80, 81, 82, 83, 84, 85, 86, -1, 88, 89, 90, -1, 92, 93, -1, -1, 96, 97, 98, 99, 100, 101, 76, 77, 78, -1, 80, 81, 82, 83, 84, 85, 86, -1, 88, 89, 90, -1, 92, 93, -1, -1, 96, 97, 98, 99, 100, 101, 76, 77, 78, -1, 80, 81, 82, 83, 84, 85, 86, -1, 88, 89, 90, -1, 92, 93, -1, -1, 96, 97, 98, 99, 100, 101, 76, 77, 78, -1, 80, 81, 82, 83, 84, 85, 86, -1, 88, 89, 90, -1, 92, 93, -1, -1, 96, 97, 98, 99, 100, 101, 76, 77, 78, -1, 80, 81, 82, 83, 84, 85, 86, -1, 88, 89, 90, -1, 92, 93, -1, -1, 96, 97, 98, 99, 100, 101, 76, 77, 78, -1, 80, 81, 82, 83, 84, 85, 86, -1, 88, 89, 90, -1, 92, 93, -1, -1, 96, 97, 98, 99, 100, 101, 76, 77, 78, -1, 80, 81, 82, 83, 84, 85, 86, -1, 88, 89, 90, -1, 92, 93, -1, -1, 96, 97, 98, 99, 100, 101, 76, 77, 78, -1, 80, 81, 82, 83, 84, 85, 86, -1, 88, 89, 90, -1, 92, 93, -1, -1, 96, 97, 98, 99, 100, 101, 76, 77, 78, -1, 80, 81, 82, 83, 84, 85, 86, -1, 88, 89, 90, -1, 92, 93, -1, -1, 96, 97, 98, 99, 100, 101, 76, 77, 78, -1, 80, 81, 82, 83, 84, 85, 86, -1, 88, 89, 90, -1, 92, 93, -1, -1, 96, 97, 98, 99, 100, 101, 76, 77, 78, -1, 80, 81, 82, 83, 84, 85, 86, -1, 88, 89, 90, -1, 92, 93, -1, -1, 96, 97, 98, 99, 100, 101, 76, 77, 78, -1, 80, 81, 82, 83, 84, 85, 86, -1, 88, 89, 90, -1, 92, 93, -1, -1, 96, 97, 98, 99, 100, 101, 76, 77, 78, -1, 80, 81, 82, 83, 84, 85, 86, -1, 88, 89, 90, -1, 92, 93, -1, -1, 96, 97, 98, 99, 100, 101, 77, 78, -1, 80, 81, 82, 83, 84, 85, 86, -1, 88, 89, 90, -1, 92, 93, -1, -1, 96, 97, 98, 99, 100, 101, 78, -1, 80, 81, 82, 83, 84, 85, 86, -1, 88, 89, 90, -1, 92, 93, -1, -1, 96, 97, 98, 99, 100, 101, 80, 81, 82, 83, 84, 85, 86, -1, 88, 89, 90, -1, 92, 93, -1, -1, 96, 97, 98, 99, 100, 101, 82, 83, 84, 85, 86, -1, 88, 89, 90, -1, 92, 93, -1, -1, 96, 97, 98, 99, 100, 101, 86, -1, 88, 89, 90, -1, 92, 93, -1, -1, 96, 97, 98, 99, 100, 101 }; /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ /* MODIFICATION 1: fix all #line directives as they have the wrong * filename and line numbers. Note #line no = actual number + 1 * #line 3 "/usr/local/share/bison.simple" */ #line 7 "bison/bison.simple" /* END MODIFICATION 1 */ /* This file comes from bison-1.28. */ /* This is a MODIFIED version of bison's Skeleton output parser The change is such that the parser only process one token at each call to yyparse(). The token is the argument to yyparse(). This means that this parser is token driven. Example use: while (token = yylex()) { yyparse(token); } Additionally: error handling patched to show expected when there are > 5 expected during an error. [Ash, May 2001]. There are 13 patches of MODIFICATION in the Skeleton (not including this comment) */ /* Skeleton output parser for bison, Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* As a special exception, when this file is copied by Bison into a Bison output file, you may use that output file without restriction. This special exception was added by the Free Software Foundation in version 1.24 of Bison. */ /* This is the parser code that is written into each bison parser when the %semantic_parser declaration is not specified in the grammar. It was written by Richard Stallman by simplifying the hairy parser used when %semantic_parser is specified. */ #ifndef YYSTACK_USE_ALLOCA #ifdef alloca #define YYSTACK_USE_ALLOCA #else /* alloca not defined */ #ifdef __GNUC__ #define YYSTACK_USE_ALLOCA #define alloca __builtin_alloca #else /* not GNU C. */ #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386)) #define YYSTACK_USE_ALLOCA #include #else /* not sparc */ /* We think this test detects Watcom and Microsoft C. */ /* This used to test MSDOS, but that is a bad idea since that symbol is in the user namespace. */ #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__) #if 0 /* No need for malloc.h, which pollutes the namespace; instead, just don't use alloca. */ #include #endif #else /* not MSDOS, or __TURBOC__ */ #if defined(_AIX) /* I don't know what this was needed for, but it pollutes the namespace. So I turned it off. rms, 2 May 1997. */ /* #include */ #pragma alloca #define YYSTACK_USE_ALLOCA #else /* not MSDOS, or __TURBOC__, or _AIX */ #if 0 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up, and on HPUX 10. Eventually we can turn this on. */ #define YYSTACK_USE_ALLOCA #define alloca __builtin_alloca #endif /* __hpux */ #endif #endif /* not _AIX */ #endif /* not MSDOS, or __TURBOC__ */ #endif /* not sparc */ #endif /* not GNU C */ #endif /* alloca not defined */ #endif /* YYSTACK_USE_ALLOCA not defined */ #ifdef YYSTACK_USE_ALLOCA #define YYSTACK_ALLOC alloca #else #define YYSTACK_ALLOC malloc #endif /* Note: there must be only one dollar sign in this file. It is replaced by the list of actions, each action as one case of the switch. */ #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) #define YYEMPTY -2 #define YYEOF 0 #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab #define YYERROR goto yyerrlab1 /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. Once GCC version 2 has supplanted version 1, this can go. */ #define YYFAIL goto yyerrlab #define YYRECOVERING() (!!yyerrstatus) #define YYBACKUP(token, value) \ do \ if (yychar == YYEMPTY && yylen == 1) \ { yychar = (token), yylval = (value); \ yychar1 = YYTRANSLATE (yychar); \ YYPOPSTACK; \ goto yybackup; \ } \ else \ { yyerror ("syntax error: cannot back up"); YYERROR; } \ while (0) #define YYTERROR 1 #define YYERRCODE 256 #ifndef YYPURE #define YYLEX yylex() #endif #ifdef YYPURE #ifdef YYLSP_NEEDED #ifdef YYLEX_PARAM #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) #else #define YYLEX yylex(&yylval, &yylloc) #endif #else /* not YYLSP_NEEDED */ #ifdef YYLEX_PARAM #define YYLEX yylex(&yylval, YYLEX_PARAM) #else #define YYLEX yylex(&yylval) #endif #endif /* not YYLSP_NEEDED */ #endif /* If nonreentrant, generate the variables here */ #ifndef YYPURE int yychar; /* the lookahead symbol */ YYSTYPE yylval; /* the semantic value of the */ /* lookahead symbol */ #ifdef YYLSP_NEEDED YYLTYPE yylloc; /* location data for the lookahead */ /* symbol */ #endif int yynerrs; /* number of parse errors so far */ #endif /* not YYPURE */ #if YYDEBUG != 0 int yydebug; /* nonzero means print parse trace */ /* Since this is uninitialized, it does not stop multiple parsers from coexisting. */ #endif /* YYINITDEPTH indicates the initial size of the parser's stacks */ #ifndef YYINITDEPTH #define YYINITDEPTH 200 #endif /* YYMAXDEPTH is the maximum size the stacks can grow to (effective only if the built-in stack extension method is used). */ #if YYMAXDEPTH == 0 #undef YYMAXDEPTH #endif #ifndef YYMAXDEPTH #define YYMAXDEPTH 10000 #endif /* Define __yy_memcpy. Note that the size argument should be passed with type unsigned int, because that is what the non-GCC definitions require. With GCC, __builtin_memcpy takes an arg of type size_t, but it can handle unsigned int. */ #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) #else /* not GNU C or C++ */ #ifndef __cplusplus /* This is the most reliable way to avoid incompatibilities in available built-in functions on various systems. */ static void __yy_memcpy (to, from, count) char *to; char *from; unsigned int count; { register char *f = from; register char *t = to; register int i = count; while (i-- > 0) *t++ = *f++; } #else /* __cplusplus */ /* This is the most reliable way to avoid incompatibilities in available built-in functions on various systems. */ static void __yy_memcpy (char *to, char *from, unsigned int count) { register char *t = to; register char *f = from; register int i = count; while (i-- > 0) *t++ = *f++; } #endif #endif /* MODIFICATION 2: same as MODIFICATION 1 * #line 217 "/usr/local/share/bison.simple" */ #line 241 "bison/bison.simple" /* END MODIFICATION 2 */ /* The user can define YYPARSE_PARAM as the name of an argument to be passed into yyparse. The argument should have type void *. It should actually point to an object. Grammar actions can access the variable by casting it to the proper pointer type. */ #ifdef YYPARSE_PARAM #ifdef __cplusplus #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM #define YYPARSE_PARAM_DECL #else /* not __cplusplus */ #define YYPARSE_PARAM_ARG YYPARSE_PARAM #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; #endif /* not __cplusplus */ #else /* not YYPARSE_PARAM */ #define YYPARSE_PARAM_ARG #define YYPARSE_PARAM_DECL #endif /* not YYPARSE_PARAM */ /* Prevent warning if -Wstrict-prototypes. */ #ifdef __GNUC__ /* MODIFICATION 3: yyparse() takes an argument that is the lex token * #ifdef YYPARSE_PARAM * int yyparse (void *); * #else * int yyparse (void); * #endif */ int yyparse(int); /* END MODIFICATION 3 */ #endif /* MODIFICATION 4: add a variable yy_parse_init to control the initialisation of the parser and an accessor function */ static int yy_parse_init = 1; #ifdef WANT_SETYYPARSEINIT /* Added this function to allow Eden to use this bison.simple. Needs conditional compilation as we can only have one function with this name otherwise the linker moans (can't compile this into Donald, Scout etc). The name here doesn't get automatically translated by the sed or bison -p. [Ash] */ void setyyparseinit(int setto) { yy_parse_init = setto; } #endif /* END MODIFICATION 4 */ /* MODIFICATION 5: turning the local variables of yyparse() into static, global variables so that the parser can be reentered */ static int yystate; static int yyn; static short *yyssp; static YYSTYPE *yyvsp; static int yyerrstatus; /* number of tokens to shift before error messages enabled */ static int yychar1 = 0; /* lookahead token as an internal (translated) token number */ static short yyssa[YYINITDEPTH]; /* the state stack */ static YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ static short *yyss = yyssa; /* refer to the stacks thru separate pointers */ static YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ #ifdef YYLSP_NEEDED static YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ static YYLTYPE *yyls = yylsa; static YYLTYPE *yylsp; #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) #else #define YYPOPSTACK (yyvsp--, yyssp--) #endif static int yystacksize = YYINITDEPTH; static int yyfree_stacks = 0; #ifdef YYPURE static int yychar; static YYSTYPE yylval; static int yynerrs; #ifdef YYLSP_NEEDED static YYLTYPE yylloc; #endif #endif static YYSTYPE yyval; /* the variable used to return */ /* semantic values from the action */ /* routines */ static int yylen; /* END MODIFICATION 5 */ /* MODIFICATION 6: yyparse() takes an argument that is the lex token * int * yyparse(YYPARSE_PARAM_ARG) * YYPARSE_PARAM_DECL * { */ int yyparse(token) int token; { /* END MODIFICATION 6 */ /* MODIFICATION 7: deal with initialisation */ int yy_token_read = 0; if (!yy_parse_init) goto lex; yy_parse_init = 0; /* END MODIFICATION 7 */ #if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Starting parse\n"); #endif yystate = 0; yyerrstatus = 0; yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ yyssp = yyss - 1; yyvsp = yyvs; #ifdef YYLSP_NEEDED yylsp = yyls; #endif /* Push a new state, which is found in yystate . */ /* In all cases, when you get here, the value and location stacks have just been pushed. so pushing a state here evens the stacks. */ yynewstate: *++yyssp = yystate; if (yyssp >= yyss + yystacksize - 1) { /* Give user a chance to reallocate the stack */ /* Use copies of these so that the &'s don't force the real ones into memory. */ YYSTYPE *yyvs1 = yyvs; short *yyss1 = yyss; #ifdef YYLSP_NEEDED YYLTYPE *yyls1 = yyls; #endif /* Get the current used size of the three stacks, in elements. */ int size = yyssp - yyss + 1; #ifdef yyoverflow /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. */ #ifdef YYLSP_NEEDED /* This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow("parser stack overflow", &yyss1, size * sizeof (*yyssp), &yyvs1, size * sizeof (*yyvsp), &yyls1, size * sizeof (*yylsp), &yystacksize); #else yyoverflow("parser stack overflow", &yyss1, size * sizeof (*yyssp), &yyvs1, size * sizeof (*yyvsp), &yystacksize); #endif yyss = yyss1; yyvs = yyvs1; #ifdef YYLSP_NEEDED yyls = yyls1; #endif #else /* no yyoverflow */ /* Extend the stack our own way. */ if (yystacksize >= YYMAXDEPTH) { yyerror("parser stack overflow"); if (yyfree_stacks) { free (yyss); free (yyvs); #ifdef YYLSP_NEEDED free (yyls); #endif } return 2; } yystacksize *= 2; if (yystacksize > YYMAXDEPTH) yystacksize = YYMAXDEPTH; #ifndef YYSTACK_USE_ALLOCA yyfree_stacks = 1; #endif yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp)); __yy_memcpy ((char *)yyss, (char *)yyss1, size * (unsigned int) sizeof (*yyssp)); yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp)); __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * (unsigned int) sizeof (*yyvsp)); #ifdef YYLSP_NEEDED yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp)); __yy_memcpy ((char *)yyls, (char *)yyls1, size * (unsigned int) sizeof (*yylsp)); #endif #endif /* no yyoverflow */ yyssp = yyss + size - 1; yyvsp = yyvs + size - 1; #ifdef YYLSP_NEEDED yylsp = yyls + size - 1; #endif #if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Stack size increased to %d\n", yystacksize); #endif if (yyssp >= yyss + yystacksize - 1) YYABORT; } #if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Entering state %d\n", yystate); #endif goto yybackup; yybackup: /* Do appropriate processing given the current state. */ /* Read a lookahead token if we need one and don't already have one. */ /* yyresume: */ /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yyn == YYFLAG) goto yydefault; /* Not known => get a lookahead token if don't already have one. */ /* yychar is either YYEMPTY or YYEOF or a valid token in external form. */ if (yychar == YYEMPTY) { #if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Reading a token: "); #endif /* MODIFICATION 8: consume the argument token * yychar = YYLEX; */ lex: if (yy_token_read) return -1; /* token consumed */ yy_token_read = 1; yychar = token; /* END MODIFICATION 8 */ } /* Convert token to internal form (in yychar1) for indexing tables with */ if (yychar <= 0) /* This means end of input. */ { yychar1 = 0; yychar = YYEOF; /* Don't call YYLEX any more */ #if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Now at end of input.\n"); #endif } else { yychar1 = YYTRANSLATE(yychar); #if YYDEBUG != 0 if (yydebug) { fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); /* Give the individual parser a way to print the precise meaning of a token, for further debugging info. */ #ifdef YYPRINT YYPRINT (stderr, yychar, yylval); #endif fprintf (stderr, ")\n"); } #endif } yyn += yychar1; if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) goto yydefault; yyn = yytable[yyn]; /* yyn is what to do for this token type in this state. Negative => reduce, -yyn is rule number. Positive => shift, yyn is new state. New state is final state => don't bother to shift, just return success. 0, or most negative number => error. */ if (yyn < 0) { if (yyn == YYFLAG) goto yyerrlab; yyn = -yyn; goto yyreduce; } else if (yyn == 0) goto yyerrlab; if (yyn == YYFINAL) YYACCEPT; /* Shift the lookahead token. */ #if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); #endif /* Discard the token being shifted unless it is eof. */ if (yychar != YYEOF) yychar = YYEMPTY; *++yyvsp = yylval; #ifdef YYLSP_NEEDED *++yylsp = yylloc; #endif /* count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; yystate = yyn; goto yynewstate; /* Do the default action for the current state. */ yydefault: yyn = yydefact[yystate]; if (yyn == 0) goto yyerrlab; /* Do a reduction. yyn is the number of a rule to reduce with. */ yyreduce: yylen = yyr2[yyn]; if (yylen > 0) yyval = yyvsp[1-yylen]; /* implement default value of the action */ #if YYDEBUG != 0 if (yydebug) { int i; fprintf (stderr, "Reducing via rule %d (line %d), ", yyn, yyrline[yyn]); /* Print the symbols being reduced, and their result. */ for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) fprintf (stderr, "%s ", yytname[yyrhs[i]]); fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); } #endif switch (yyn) { case 2: #line 170 "parser.y" { dd_script->ready = 1; ; break;} case 3: #line 171 "parser.y" { yyerrok; ; break;} case 4: #line 175 "parser.y" { eden_declare(yyvsp[0].s, VIEWPORT, yyvsp[0].s); ; break;} case 5: #line 176 "parser.y" { if (_changed) { declare_openshape(); _changed = 0; } #ifdef DEBUG if (Debug & 16) print_all_symbols(); #endif ; break;} case 7: #line 186 "parser.y" { appendEden("%+eden\n", dd_script); ; break;} case 8: #line 187 "parser.y" { appendEden("%-eden\n", dd_script); ; break;} case 9: #line 188 "parser.y" { #ifdef DISTRIB withinHandle = 1; #endif /* DISTRIB */ ; break;} case 10: #line 193 "parser.y" { if (_changed) { declare_openshape(); _changed = 0; } ; break;} case 12: #line 220 "parser.y" { Delete(yyvsp[-1].t); ; break;} case 13: #line 233 "parser.y" { #ifdef DISTRIB withinName = strdup(expr_to_eden_name(yyvsp[0].t)); /* within door {} - this finds 'door' */ if (handle_check1(withinName)) { /* The current agent is allowed to change the contents of the variable 'withinName' */ dd_appAgentName--; /* we don't need to prepend the agent name any more */ withinHandle = 1; sprintf(temp, "%%donald\nwithin %s {\n%%eden\n", expr_to_donald_name(yyvsp[0].t)); propagateDonaldDef(withinName, temp); change_scope(yyvsp[0].t); freeTree(yyvsp[0].t); /* propagateAgency1(withinName, temp); */ } else { withinHandle = 0; } #else dd_appAgentName--; change_scope(yyvsp[0].t); freeTree(yyvsp[0].t); #endif /* DISTRIB */ ; break;} case 14: #line 260 "parser.y" { #ifdef DISTRIB if (withinHandle) { resume_scope(); propagateDonaldDef(withinName, "%donald\n}\n%eden\n"); }; withinHandle = 1; dd_appAgentName++; #else dd_appAgentName++; resume_scope(); #endif ; break;} case 15: #line 274 "parser.y" { #ifdef DISTRIB if (withinHandle) { resume_scope(); propagateDonaldDef(withinName, "%donald\n}\n%eden\n"); }; withinHandle = 1; dd_appAgentName++; #else dd_appAgentName++; resume_scope(); #endif ; break;} case 16: #line 288 "parser.y" { #ifdef DISTRIB if (withinHandle) { resume_scope(); propagateDonaldDef(withinName, "%donald\n}\n%eden\n"); } withinHandle = 1; dd_appAgentName++; #else dd_appAgentName++; resume_scope(); #endif ; break;} case 17: #line 304 "parser.y" { dd_script->ready = 1; ; break;} case 18: #line 305 "parser.y" { dd_script->ready = 1; ; break;} case 19: #line 309 "parser.y" { #ifdef DISTRIB if (withinHandle) { Declare(yyvsp[-2].i, yyvsp[-1].t); } else { freeTree(yyvsp[-1].t); } #else Declare(yyvsp[-2].i, yyvsp[-1].t); #endif /* DISTRIB */ ; break;} case 20: #line 320 "parser.y" { DeclareGraph(yyvsp[0].t); ; break;} case 21: #line 369 "parser.y" { yyval.i = INT; ; break;} case 22: #line 370 "parser.y" { yyval.i = REAL; ; break;} case 23: #line 371 "parser.y" { yyval.i = MYCHAR; ; break;} case 24: #line 372 "parser.y" { yyval.i = BOOLEAN; ; break;} case 25: #line 373 "parser.y" { yyval.i = POINT; ; break;} case 26: #line 374 "parser.y" { yyval.i = LINE; ; break;} case 27: #line 375 "parser.y" { yyval.i = ARC; ; break;} case 28: #line 376 "parser.y" { yyval.i = CIRCLE; ; break;} case 29: #line 377 "parser.y" { yyval.i = ELLIPSE; ; break;} case 30: #line 378 "parser.y" { yyval.i = LABEL; ; break;} case 31: #line 379 "parser.y" { yyval.i = SHAPE; ; break;} case 32: #line 380 "parser.y" { yyval.i = OPENSHAPE; ; break;} case 33: #line 381 "parser.y" { yyval.i = IMAGE; ; break;} case 34: #line 382 "parser.y" { yyval.i = RECTANGLE; ; break;} case 35: #line 387 "parser.y" { #ifdef DISTRIB if (withinHandle) { #endif /* DISTRIB */ int no_id; tree t1 = yyvsp[-3].t; tree t3 = yyvsp[-1].t; if ((no_id = count_id(t1)) == ERROR) don_err(IdListExpect, 0); if (no_id != count_expr(t3)) don_err(IdExprUnmatch, 0); if (no_id > 1) appendEden("autocalc = OFF;\n", dd_script); if (t3->type == ANY) t3->type = t1->type; Define(t1, t3); freeTree(t1); freeTree(t3); if (no_id > 1) appendEden("autocalc = ON;\n", dd_script); #ifdef DISTRIB } else { freeTree(yyvsp[-3].t); freeTree(yyvsp[-1].t); } #endif /* DISTRIB */ ; break;} case 36: #line 416 "parser.y" { count_expr(yyvsp[-1].t); DefineFunc(XI, yyvsp[-1].t); freeTree(yyvsp[-1].t); ; break;} case 37: #line 422 "parser.y" { count_expr(yyvsp[-1].t); DefineFunc(FI, yyvsp[-1].t); freeTree(yyvsp[-1].t); ; break;} case 38: #line 430 "parser.y" { appendEden(yyvsp[-1].s, dd_script); appendEden("\n", dd_script); free(yyvsp[-1].s); ; break;} case 39: #line 435 "parser.y" { appendEden(yyvsp[-1].s, dd_script); appendEden("\n", dd_script); free(yyvsp[-1].s); ; break;} case 41: #line 444 "parser.y" { yyval.t = dtree2(OP_COMMA, yyvsp[-2].t, yyvsp[0].t); ; break;} case 42: #line 484 "parser.y" { yyval.t = dtree0(OP_INF); ; break;} case 43: #line 485 "parser.y" { yyval.t = dtree0(OP_PI); yyval.t->type = REAL; Rvalue(yyval.t) = 3.141593; ; break;} case 44: #line 489 "parser.y" { yyval.t = dtree0(OP_INUMBER); yyval.t->type = INT; Ivalue(yyval.t) = yyvsp[0].i; ; break;} case 45: #line 494 "parser.y" { yyval.t = dtree0(OP_RNUMBER); yyval.t->type = REAL; Rvalue(yyval.t) = yyvsp[0].r; display2("rnumber(%lf) ", yyvsp[0].r); ; break;} case 46: #line 500 "parser.y" { yyval.t = dtree0(OP_CSTRING); yyval.t->type = MYCHAR; Cvalue(yyval.t) = yyvsp[0].s; display2("cstring(%s) ", yyvsp[0].s); ; break;} case 47: #line 506 "parser.y" { yyval.t = dtree0(OP_BOOL); yyval.t->type = BOOLEAN; Bvalue(yyval.t) = yyvsp[0].i; ; break;} case 48: #line 511 "parser.y" { yyval.t = dtree0(OP_I); yyval.t->type = INT; ; break;} case 49: #line 512 "parser.y" { yyval.t = dtree0(OP_XI); yyval.t->type = REAL; ; break;} case 50: #line 513 "parser.y" { yyval.t = dtree0(OP_FI); yyval.t->type = REAL; ; break;} case 51: #line 514 "parser.y" { yyval.t = dtree0(OP_I_1); yyval.t->type = INT; ; break;} case 52: #line 515 "parser.y" { yyval.t = dtree0(OP_XI_1); yyval.t->type = REAL; ; break;} case 53: #line 516 "parser.y" { yyval.t = dtree0(OP_FI_1); yyval.t->type = REAL; ; break;} case 54: #line 519 "parser.y" { yyval.t = yyvsp[-1].t; ; break;} case 55: #line 521 "parser.y" { yyval.t = yyvsp[-1].t; ; break;} case 57: #line 525 "parser.y" { yyval.t = dtree2(OP_EDEN, yyvsp[-1].s); ; break;} case 58: #line 527 "parser.y" { yyval.t = dtree1(OP_PAREN, yyvsp[-1].t); ; break;} case 59: #line 530 "parser.y" { yyval.t = dtree2(OP_CART, yyvsp[-3].t, yyvsp[-1].t); ; break;} case 60: #line 532 "parser.y" { yyval.t = dtree2(OP_POLAR, yyvsp[-3].t, yyvsp[-1].t); ; break;} case 61: #line 534 "parser.y" { yyval.t = dtree2(OP_LINE, yyvsp[-3].t, yyvsp[-1].t); ; break;} case 62: #line 536 "parser.y" { yyval.t = dtree3(OP_ARC, yyvsp[-5].t, yyvsp[-3].t, yyvsp[-1].t); ; break;} case 63: #line 538 "parser.y" { yyval.t = dtree2(OP_CIRCLE, yyvsp[-3].t, yyvsp[-1].t); ; break;} case 64: #line 540 "parser.y" { yyval.t = dtree2(OP_RECTANGLE, yyvsp[-3].t, yyvsp[-1].t); ; break;} case 65: #line 542 "parser.y" { yyval.t = dtree3(OP_ELLIPSE, yyvsp[-5].t, yyvsp[-3].t, yyvsp[-1].t); ; break;} case 66: #line 544 "parser.y" { yyval.t = dtree2(OP_LABEL, yyvsp[-3].t, yyvsp[-1].t); ; break;} case 67: #line 546 "parser.y" { yyval.t = dtree2(OP_PLUS, yyvsp[-2].t, yyvsp[0].t); ; break;} case 68: #line 547 "parser.y" { yyval.t = dtree2(OP_MINUS, yyvsp[-2].t, yyvsp[0].t); ; break;} case 69: #line 548 "parser.y" { yyval.t = dtree2(OP_MULT, yyvsp[-2].t, yyvsp[0].t); ; break;} case 70: #line 549 "parser.y" { yyval.t = dtree2(OP_MOD, yyvsp[-2].t, yyvsp[0].t); ; break;} case 71: #line 550 "parser.y" { yyval.t = dtree2(OP_DIV, yyvsp[-2].t, yyvsp[0].t); ; break;} case 72: #line 552 "parser.y" { yyval.t = dtree1(OP_UMINUS, yyvsp[0].t); ; break;} case 73: #line 557 "parser.y" { yyval.t = dtree1(OP_NOT, yyvsp[0].t); ; break;} case 74: #line 558 "parser.y" { yyval.t = dtree2(OP_AND, yyvsp[-2].t, yyvsp[0].t); ; break;} case 75: #line 559 "parser.y" { yyval.t = dtree2(OP_OR, yyvsp[-2].t, yyvsp[0].t); ; break;} case 76: #line 560 "parser.y" { yyval.t = dtree2(OP_EQ_EQ, yyvsp[-2].t, yyvsp[0].t); ; break;} case 77: #line 561 "parser.y" { yyval.t = dtree2(OP_NOT_EQ, yyvsp[-2].t, yyvsp[0].t); ; break;} case 78: #line 562 "parser.y" { yyval.t = dtree2(OP_LT, yyvsp[-2].t, yyvsp[0].t); ; break;} case 79: #line 563 "parser.y" { yyval.t = dtree2(OP_LT_EQ, yyvsp[-2].t, yyvsp[0].t); ; break;} case 80: #line 564 "parser.y" { yyval.t = dtree2(OP_GT, yyvsp[-2].t, yyvsp[0].t); ; break;} case 81: #line 565 "parser.y" { yyval.t = dtree2(OP_GT_EQ, yyvsp[-2].t, yyvsp[0].t); ; break;} case 82: #line 567 "parser.y" { yyval.t = dtree2(OP_SLASH_SLASH, yyvsp[-2].t, yyvsp[0].t); ; break;} case 83: #line 569 "parser.y" { yyval.t = dtree1(OP_ITOS, yyvsp[-1].t); ; break;} case 84: #line 571 "parser.y" { yyval.t = dtree2(OP_RTOS, yyvsp[-3].t, yyvsp[-1].t); ; break;} case 85: #line 573 "parser.y" { yyval.t = dtree1(OP_DOTX, yyvsp[-1].t); ; break;} case 86: #line 574 "parser.y" { yyval.t = dtree1(OP_DOTY, yyvsp[-1].t); ; break;} case 87: #line 575 "parser.y" { yyval.t = dtree1(OP_DOT1, yyvsp[-1].t); ; break;} case 88: #line 576 "parser.y" { yyval.t = dtree1(OP_DOT2, yyvsp[-1].t); ; break;} case 89: #line 577 "parser.y" { yyval.t = dtree1(OP_DOTRAD, yyvsp[-1].t); ; break;} case 90: #line 578 "parser.y" { yyval.t = dtree1(OP_DOTARG, yyvsp[-1].t); ; break;} case 91: #line 581 "parser.y" { yyval.t = dtree2(OP_FUNC, yyvsp[-3].s, 0); ; break;} case 92: #line 583 "parser.y" { yyval.t = dtree2(OP_FUNC, yyvsp[-4].s, yyvsp[-1].t); ; break;} case 93: #line 585 "parser.y" { yyval.t = dtree2(OP_IMGFUNC, yyvsp[-2].s, 0); ; break;} case 94: #line 587 "parser.y" { yyval.t = dtree2(OP_IMGFUNC, yyvsp[-3].s, yyvsp[-1].t); ; break;} case 95: #line 589 "parser.y" { yyval.t = dtree1(yyvsp[-3].i, yyvsp[-1].t); ; break;} case 96: #line 591 "parser.y" { yyval.t = dtree2(yyvsp[-5].i, yyvsp[-3].t, yyvsp[-1].t); ; break;} case 97: #line 593 "parser.y" { yyval.t = dtree3(yyvsp[-7].i, yyvsp[-5].t, yyvsp[-3].t, yyvsp[-1].t); ; break;} case 98: #line 596 "parser.y" { yyval.t = dtree4(OP_PARALLEL, yyvsp[-7].t, yyvsp[-5].t, yyvsp[-3].t, yyvsp[-1].t); ; break;} case 99: #line 599 "parser.y" { yyval.t = dtree3(OP_IF, yyvsp[-2].t, yyvsp[-4].t, yyvsp[0].t); ; break;} case 100: #line 606 "parser.y" { yyval.i = OP_SQRT; ; break;} case 101: #line 607 "parser.y" { yyval.i = OP_SIN; ; break;} case 102: #line 608 "parser.y" { yyval.i = OP_COS; ; break;} case 103: #line 609 "parser.y" { yyval.i = OP_TAN; ; break;} case 104: #line 610 "parser.y" { yyval.i = OP_ASIN; ; break;} case 105: #line 611 "parser.y" { yyval.i = OP_ACOS; ; break;} case 106: #line 612 "parser.y" { yyval.i = OP_ATAN; ; break;} case 107: #line 613 "parser.y" { yyval.i = OP_LOG; ; break;} case 108: #line 614 "parser.y" { yyval.i = OP_EXP; ; break;} case 109: #line 615 "parser.y" { yyval.i = OP_TRUNC; ; break;} case 110: #line 616 "parser.y" { yyval.i = OP_FLOAT; ; break;} case 111: #line 617 "parser.y" { yyval.i = OP_MIDPOINT; ; break;} case 112: #line 618 "parser.y" { yyval.i = OP_RANDOM; ; break;} case 113: #line 622 "parser.y" { yyval.i = OP_INTERSECT; ; break;} case 114: #line 623 "parser.y" { yyval.i = OP_PERPEND; ; break;} case 115: #line 624 "parser.y" { yyval.i = OP_DISTANCE; ; break;} case 116: #line 625 "parser.y" { yyval.i = OP_SCALE; ; break;} case 117: #line 626 "parser.y" { yyval.i = OP_INTERSECTS; ; break;} case 118: #line 627 "parser.y" { yyval.i = OP_INCLUDES; ; break;} case 119: #line 628 "parser.y" { yyval.i = OP_INCIDENT; ; break;} case 120: #line 632 "parser.y" { yyval.i = OP_ROT; ; break;} case 121: #line 633 "parser.y" { yyval.i = OP_TRANS; ; break;} case 122: #line 634 "parser.y" { yyval.i = OP_PT_BETWN_PTS; ; break;} case 123: #line 635 "parser.y" { yyval.i = OP_COLINEAR; ; break;} case 124: #line 636 "parser.y" { yyval.i = OP_SEPARATES; ; break;} case 125: #line 637 "parser.y" { yyval.i = OP_DISTLARGER; ; break;} case 126: #line 638 "parser.y" { yyval.i = OP_DISTSMALLER; ; break;} case 128: #line 644 "parser.y" { yyval.t = dtree2(OP_GLOBAL, yyvsp[0].t); ; break;} case 129: #line 649 "parser.y" { yyval.t = dtree2(OP_SLASH, yyvsp[-2].t, yyvsp[0].t); ; break;} case 130: #line 651 "parser.y" { yyval.t = dtree2(OP_SLASH, dtree1(OP_ID, 0), yyvsp[0].t); dd_appAgentName--; ; break;} case 133: #line 662 "parser.y" { yyval.t = dtree1(OP_ID, yyvsp[0].s); ; break;} case 134: #line 666 "parser.y" { yyval.t = dtree2(OP_GSPECLIST, 0, 0); ; break;} case 136: #line 669 "parser.y" { yyval.t = dtree2(OP_GSPECLIST, yyvsp[-2].t, yyvsp[0].t); ; break;} case 137: #line 671 "parser.y" { yyval.t = dtree2(OP_GSPECLIST, yyvsp[-3].t, yyvsp[0].t); ; break;} case 138: #line 675 "parser.y" { yyval.t = dtree2(OP_GSPEC, 0, (tree)yyvsp[-1].i); ; break;} case 139: #line 676 "parser.y" { yyval.t = dtree2(OP_GSPEC, yyvsp[0].t, (tree)yyvsp[-2].i); ; break;} case 140: #line 677 "parser.y" { yyval.t = dtree2(OP_GSPEC, 0, (tree)yyvsp[-2].i); ; break;} case 141: #line 678 "parser.y" { yyval.t = dtree2(OP_GSPEC, yyvsp[-1].t, (tree)yyvsp[-3].i); ; break;} } /* the action file gets copied in in place of this dollarsign */ /* MODIFICATION 9: same as MODIFICATION 1 * #line 543 "/usr/local/share/bison.simple" */ #line 617 "bison/bison.simple" /* END MODIFICATION 9 */ yyvsp -= yylen; yyssp -= yylen; #ifdef YYLSP_NEEDED yylsp -= yylen; #endif #if YYDEBUG != 0 if (yydebug) { short *ssp1 = yyss - 1; fprintf (stderr, "state stack now"); while (ssp1 != yyssp) fprintf (stderr, " %d", *++ssp1); fprintf (stderr, "\n"); } #endif *++yyvsp = yyval; #ifdef YYLSP_NEEDED yylsp++; if (yylen == 0) { yylsp->first_line = yylloc.first_line; yylsp->first_column = yylloc.first_column; yylsp->last_line = (yylsp-1)->last_line; yylsp->last_column = (yylsp-1)->last_column; yylsp->text = 0; } else { yylsp->last_line = (yylsp+yylen-1)->last_line; yylsp->last_column = (yylsp+yylen-1)->last_column; } #endif /* Now "shift" the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ yyn = yyr1[yyn]; yystate = yypgoto[yyn - YYNTBASE] + *yyssp; if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else yystate = yydefgoto[yyn - YYNTBASE]; goto yynewstate; yyerrlab: /* here on detecting error */ if (! yyerrstatus) /* If not already recovering from an error, report this error. */ { ++yynerrs; #ifdef YYERROR_VERBOSE yyn = yypact[yystate]; if (yyn > YYFLAG && yyn < YYLAST) { int size = 0; char *msg; int x, count; count = 0; /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ for (x = (yyn < 0 ? -yyn : 0); x < (sizeof(yytname) / sizeof(char *)); x++) if (yycheck[x + yyn] == x) size += strlen(yytname[x]) + 15, count++; /* MODIFICATION 10: increase space for error message * msg = (char *) malloc(size + 15); */ msg = (char *) malloc(size + 100); /* END MODIFICATION 10 */ if (msg != 0) { strcpy(msg, "parse error"); /* MODIFICATION 11: print expected even when there are > 5 expected * if (count < 5) */ if (1) /* END MODIFICATION 11 */ { count = 0; for (x = (yyn < 0 ? -yyn : 0); x < (sizeof(yytname) / sizeof(char *)); x++) if (yycheck[x + yyn] == x) { /* MODIFICATION 12: indicate when there are > 5 expected but not printed */ if (count > 5) count++; else { /* END MODIFICATION 12 */ strcat(msg, count == 0 ? ", expecting `" : " or `"); strcat(msg, yytname[x]); strcat(msg, "'"); count++; /* MODIFICATION 13: indicate when there are > 5 expected but not printed * } */ } } if (count > 5) { sprintf(msg + strlen(msg), " or... (%d other possibilities)", count - 6); } /* END MODIFICATION 13 */ } yyerror(msg); free(msg); } else yyerror ("parse error; also virtual memory exceeded"); } else #endif /* YYERROR_VERBOSE */ yyerror("parse error"); } goto yyerrlab1; yyerrlab1: /* here on error raised explicitly by an action */ if (yyerrstatus == 3) { /* if just tried and failed to reuse lookahead token after an error, discard it. */ /* return failure if at end of input */ if (yychar == YYEOF) YYABORT; #if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); #endif yychar = YYEMPTY; } /* Else will try to reuse lookahead token after shifting the error token. */ yyerrstatus = 3; /* Each real token shifted decrements this */ goto yyerrhandle; yyerrdefault: /* current state does not do anything special for the error token. */ #if 0 /* This is wrong; only states that explicitly want error tokens should shift them. */ yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ if (yyn) goto yydefault; #endif yyerrpop: /* pop the current state because it cannot handle the error token */ if (yyssp == yyss) YYABORT; yyvsp--; yystate = *--yyssp; #ifdef YYLSP_NEEDED yylsp--; #endif #if YYDEBUG != 0 if (yydebug) { short *ssp1 = yyss - 1; fprintf (stderr, "Error: state stack now"); while (ssp1 != yyssp) fprintf (stderr, " %d", *++ssp1); fprintf (stderr, "\n"); } #endif yyerrhandle: yyn = yypact[yystate]; if (yyn == YYFLAG) goto yyerrdefault; yyn += YYTERROR; if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) goto yyerrdefault; yyn = yytable[yyn]; if (yyn < 0) { if (yyn == YYFLAG) goto yyerrpop; yyn = -yyn; goto yyreduce; } else if (yyn == 0) goto yyerrpop; if (yyn == YYFINAL) YYACCEPT; #if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Shifting error token, "); #endif *++yyvsp = yylval; #ifdef YYLSP_NEEDED *++yylsp = yylloc; #endif yystate = yyn; goto yynewstate; yyacceptlab: /* YYACCEPT comes here. */ if (yyfree_stacks) { free (yyss); free (yyvs); #ifdef YYLSP_NEEDED free (yyls); #endif } return 0; yyabortlab: /* YYABORT comes here. */ if (yyfree_stacks) { free (yyss); free (yyvs); #ifdef YYLSP_NEEDED free (yyls); #endif } return 1; } #line 680 "parser.y" void yyerror(char *s) { don_err(Unclassified, s); } static char *errorstring[] = {ERRORSTRINGS}; /*---------------------------------------------------+---------+ | don_err | +---------*/ #include extern Tcl_Interp *interp; void don_err(enum errorcodes error_code, char *s) { extern void yyrestart(void); extern int yy_parse_init; char errStr[80]; Tcl_DString err, message; yyrestart(); /* reset lexical analyzer */ yy_parse_init = 1; /* reset bison */ deleteScript(dd_script); Tcl_EvalEC(interp, "appendHist {/*** }"); Tcl_DStringInit(&err); Tcl_DStringInit(&message); Tcl_DStringAppend(&message, "DoNaLD: ", -1); sprintf(errStr, errorstring[(int) error_code], s); Tcl_DStringAppend(&message, errStr, -1); Tcl_DStringAppendElement(&err, "appendHist"); Tcl_DStringAppendElement(&err, message.string); Tcl_EvalEC(interp, err.string); Tcl_DStringFree(&err); Tcl_DStringFree(&message); if (reset_context() > 0) Tcl_EvalEC(interp, "appendHist {\nDoNaLD: warning: reset context}"); Tcl_EvalEC(interp, "appendHist { ***/\n}"); error2("DoNaLD translator error", ""); } #ifdef DISTRIB /* This is a sort of drop-in replacement for appendEden, but with distribution [Ash, with Sun] */ void propagateDonaldDef(char *name, char *s) { extern void appendEden(char *, Script *); appendEden("propagate(\"", dd_script); appendEden(name, dd_script); appendEden("\", \"", dd_script); appendEden(s, dd_script); appendEden("\");\n", dd_script); } #endif /* DISTRIB */ 596 "parser.y" { yyval.t = dtree4(OP_PARALLEL, yyvsp[-7].t, yyvsp[-5].t, yyvsp[-3].t, yyvsp[-1].t); ; break;} case 99: #line 599 "parser.y" { yyval.t = dtree3(OP_IF, yyvsp[-2].t, yyvsp[-4].t, yyvsp[0].t); ; break;} case 100: #line 606 "parser.y"tkeden1.18/Donald/parser.h010060000025250000147000000044020731441570600167240ustar00ashleydcsother00003470000356typedef union { char *s; /* identifier, etc */ int i; /* integer value */ double r; /* floating point value */ tree t; /* expression tree */ } YYSTYPE; #define INF 257 #define PI 258 #define I 259 #define XI 260 #define FI 261 #define I_1 262 #define XI_1 263 #define FI_1 264 #define IMAGE 265 #define MYCHAR 266 #define REAL 267 #define INT 268 #define BOOLEAN 269 #define POINT 270 #define LABEL 271 #define GSPEC 272 #define GSPECLIST 273 #define ANY 274 #define LINE 275 #define CIRCLE 276 #define ELLIPSE 277 #define SHAPE 278 #define OPENSHAPE 279 #define ARC 280 #define RECTANGLE 281 #define GRAPH 282 #define OF 283 #define VIEWPORT 284 #define DELETE 285 #define WITHIN 286 #define IF 287 #define THEN 288 #define ELSE 289 #define ID 290 #define IMGFUNC 291 #define CSTRING 292 #define BOOL 293 #define INUMBER 294 #define RNUMBER 295 #define ITOS 296 #define RTOS 297 #define TRUNC 298 #define FLOAT 299 #define SQRT 300 #define SIN 301 #define COS 302 #define TAN 303 #define ASIN 304 #define ACOS 305 #define ATAN 306 #define LOG 307 #define EXP 308 #define RANDOM 309 #define ROT 310 #define SCALE 311 #define TRANS 312 #define INTERSECT 313 #define PARALLEL 314 #define PERPEND 315 #define DISTANCE 316 #define MIDPOINT 317 #define PT_BETWN_PTS 318 #define COLINEAR 319 #define INTERSECTS 320 #define SEPARATES 321 #define INCLUDES 322 #define INCIDENT 323 #define DISTLARGER 324 #define DISTSMALLER 325 #define QUERY 326 #define SEMICOLON 327 #define COLON 328 #define EQUALS 329 #define COMMA 330 #define OR 331 #define AND 332 #define NOT 333 #define EQ_EQ 334 #define NOT_EQ 335 #define GT 336 #define GT_EQ 337 #define LT 338 #define LT_EQ 339 #define SLASH_SLASH 340 #define ATSIGN 341 #define PLUS 342 #define MINUS 343 #define STAR 344 #define PERCENT 345 #define DIV 346 #define MOD 347 #define TILDE 348 #define TILDE_SLASH 349 #define DOTX 350 #define DOTY 351 #define DOTARG 352 #define DOTRAD 353 #define DOT1 354 #define DOT2 355 #define UMINUS 356 #define SLASH 357 #define LID 358 #define AMPERSAND 359 #define HASH 360 #define VERTBAR 361 #define NEWLINE 362 #define LPAREN 363 #define RPAREN 364 #define LBRACK 365 #define RBRACK 366 #define LCURLY 367 #define RCURLY 368 #define LANGLE 369 #define RANGLE 370 extern YYSTYPE dd_lval; tkeden1.18/Donald/dd_lex.c010060000025250000147000000372050731247327600166750ustar00ashleydcsother00003470000356/* * $Id: lex.c,v 1.16 1999/11/16 21:20:40 ashley Rel1.10 $ */ static char rcsid[] = "$Id: lex.c,v 1.16 1999/11/16 21:20:40 ashley Rel1.10 $"; #include #include #include #include #include "../config.h" #include "tree.h" #include "parser.h" #include "../Eden/eden.h" #include "../Eden/emalloc.h" #ifdef HAVE_DMALLOC #include #endif extern void dd_parse(int); extern char agentName[128]; /* for distributed tkEden --sun */ extern int appAgentName; extern int append_NoAgentName; extern char *libLocation; char *dd_prompt; enum { _S_, _A_, _D_, _DDOT_, _DE_, _DED_, _DES_, _DESD_, _DOT_, _DOT1_, _DOT2_, _DA_, _DAR_, _DR_, _DRA_, _QUOTE_, _QUERY_, _BSLASH_, _HASH_, _AND_, _OR_, _EQ_, _NOT_, _LT_, _GT_, _SLASH_, _B_, _BI_, _BISP_, _BI__, _BI_1_, _BI_1SP_, _I_, _X_, _F_, _II_, _IN_, _INA_, _TILDE_ }; static char *dd_text = 0; static bufsize = 256; static dd_leng = 0; static state = _S_; /* start state */ static gtarget; /* which graph token seeking? */ static int isOpenshape=0; /* for distributed --sun */ static int curlyCount=0; int dd_appAgentName=1; static int DonaldAppAgentName=1; /* function prototypes */ int map_name_to_token(char *); void dd_restart(void); char * map_token_to_name(int); void dd_lex(int); void init_donald(void); static void save(int); static void action_A(void); static int tokenize(int); #define clearbuf() dd_text[dd_leng=0] = '\0' void dd_restart(void) { clearbuf(); state = _S_; } #define NUMTOKEN 62 struct { char *name; int token; } translation[NUMTOKEN] = { { "acos" , ACOS }, /* { "alias" , ALIAS }, */ { "and" , AND }, { "arc" , ARC }, /* { "as" , AS }, */ { "asin" , ASIN }, { "atan" , ATAN }, { "boolean" , BOOLEAN }, { "char" , MYCHAR }, { "circle" , CIRCLE }, { "colinear" , COLINEAR }, { "cos" , COS }, { "delete" , DELETE }, { "dist" , DISTANCE }, { "distlarger" , DISTLARGER }, { "distsmaller" , DISTSMALLER }, { "div" , DIV }, /* { "draw" , DRAW }, */ { "ellipse" , ELLIPSE }, { "else" , ELSE }, { "exp" , EXP }, { "false" , BOOL }, { "float" , FLOAT }, /* { "for" , FOR }, */ { "graph" , GRAPH }, { "if" , IF }, { "image" , IMAGE }, /* { "impose" , IMPOSE }, */ /* { "in" , IN }, */ { "incident" , INCIDENT }, { "includes" , INCLUDES }, { "inf" , INF }, { "int" , INT }, { "intersect" , INTERSECT }, { "intersects" , INTERSECTS }, { "itos" , ITOS }, { "label" , LABEL }, { "line" , LINE }, { "log" , LOG }, { "midpoint" , MIDPOINT }, { "mod" , MOD }, /* { "monitor" , MONITOR }, */ { "not" , NOT }, { "of" , OF }, { "openshape" , OPENSHAPE }, { "or" , OR }, { "parallel" , PARALLEL }, { "perpend" , PERPEND }, { "pi" , PI }, { "point" , POINT }, { "pt_betwn_pts", PT_BETWN_PTS }, { "rand" , RANDOM }, /* { "range" , RANGE }, */ { "real" , REAL }, { "rectangle" , RECTANGLE }, { "rot" , ROT }, { "rtos" , RTOS }, { "scale" , SCALE }, { "separates" , SEPARATES }, { "shape" , SHAPE }, { "sin" , SIN }, { "sqrt" , SQRT }, { "tan" , TAN }, { "then" , THEN }, { "trans" , TRANS }, { "true" , BOOL }, { "trunc" , TRUNC }, { "viewport" , VIEWPORT }, { "within" , WITHIN }, { 0, 0 } }; int map_name_to_token(char *name) { int i, start, end, cmp; start = 0; end = NUMTOKEN - 1; for (i = (NUMTOKEN - 1) >> 1; start <= i && i <= end; i = (start + end) >> 1) { if (translation[i].name == 0) return 0; cmp = strcmp(name, translation[i].name); if (cmp == 0) return translation[i].token; else if (cmp > 0) start = i + 1; else /* cmp < 0 */ end = i - 1; } return 0; } char * map_token_to_name(int token) { int i; for (i = 0; i < NUMTOKEN; i++) if (translation[i].token == token) return translation[i].name; return 0; } static void save(int c) { if (dd_leng == bufsize - 1) { bufsize *= 2; dd_text = (char *) erealloc(dd_text, bufsize * sizeof(int)); } dd_text[dd_leng++] = c; dd_text[dd_leng] = '\0'; } static void action_A(void) { int token; char new_dd_text[256]; /* for distributed tkEden --sun */ extern int inPrefix; if ((token = map_name_to_token(dd_text)) == 0) { /* Virtual agents */ if (*agentName != 0 && dd_appAgentName >0 && appAgentName > 0 && append_NoAgentName >0 && DonaldAppAgentName >0 ) { new_dd_text[0] = '\0'; if (inPrefix) strcpy(new_dd_text, agentName); else strcpy(new_dd_text, dd_text); strcat(new_dd_text, "_"); if (inPrefix) strcat(new_dd_text, dd_text); else strcat(new_dd_text, agentName); strcpy(dd_text, new_dd_text); /* printf("new_dd_text = %s\n", new_dd_text); */ } dd_lval.s = strdup(dd_text); dd_parse(ID); } else { /* it is a token */ if (token == BOOL) dd_lval.i = (strcmp(dd_text, "true") == 0); if (token == WITHIN && *agentName != 0 && append_NoAgentName > 0) { /* printf("within \n"); */ isOpenshape = 1; curlyCount = 0; } dd_parse(token); } DonaldAppAgentName = 1; } static int tokenize(int c) { switch (c) { case '!': return NOT; case ',': return COMMA; case '+': return PLUS; case '-': return MINUS; case '*': return STAR; case '/': return SLASH; case '%': return PERCENT; case '=': return EQUALS; case '&': return AMPERSAND; case '|': return VERTBAR; case ':': return COLON; case ';': return SEMICOLON; case '~': DonaldAppAgentName = 0; return TILDE; case '@': return ATSIGN; case '(': return LPAREN; case ')': return RPAREN; case '<': return LT; case '>': return GT; case '[': return LBRACK; case ']': return RBRACK; case '{': return LCURLY; case '}': return RCURLY; default: return c; } } void dd_lex(int c) { switch (state) { case _S_: switch (c) { case ' ': case '\t': state = _S_; break; case '\n': dd_parse(NEWLINE); state = _S_; break; case '.': save(c); state = _DOT_; break; case '?': state = _QUERY_; break; case '"': save(c); state = _QUOTE_; break; case '\\': state = _BSLASH_; break; case '#': state = _HASH_; break; case '&': state = _AND_; break; case '|': state = _OR_; break; case '=': state = _EQ_; break; case '!': state = _NOT_; break; case '<': gtarget = _I_; state = _B_; break; case '>': state = _GT_; break; case '/': state = _SLASH_; break; case 'f': gtarget = _F_; state = _F_; save(c); break; case 'x': gtarget = _X_; state = _X_; save(c); break; case 'I': state = _II_; break; case '~': state = _TILDE_; break; default: if (isalpha(c) || c == '_') { save(c); state = _A_; } else if (isdigit(c)) { save(c); state = _D_; } else { dd_parse(tokenize(c)); state = _S_; } break; } break; case _A_: if (isalnum(c) || c == '_') { save(c); state = _A_; } else { action_A(); clearbuf(); state = _S_; dd_lex(c); } break; case _D_: if (isdigit(c)) { save(c); state = _D_; } else if (c == '.') { save(c); state = _DDOT_; } else if (c == 'E' || c == 'e') { save(c); state = _DE_; } else { dd_lval.i = atoi(dd_text); dd_parse(INUMBER); clearbuf(); state = _S_; dd_lex(c); } break; case _DDOT_: if (isdigit(c)) { save(c); state = _DDOT_; } else if (c == '.') { dd_lval.r = atof(dd_text); dd_parse(RNUMBER); clearbuf(); state = _S_; dd_lex(c); } else if (c == 'E' || c == 'e') { save(c); state = _DE_; } else { dd_lval.r = atof(dd_text); dd_parse(RNUMBER); clearbuf(); state = _S_; dd_lex(c); } break; case _DE_: if (isdigit(c)) { save(c); state = _DED_; } else if (c == '+' || c == '-') { save(c); state = _DES_; } else { dd_lval.r = atof(dd_text); dd_parse(RNUMBER); clearbuf(); state = _S_; dd_lex(c); } break; case _DED_: case _DESD_: if (isdigit(c)) { save(c); state = _DED_; } else { dd_lval.r = atof(dd_text); dd_parse(RNUMBER); clearbuf(); state = _S_; dd_lex(c); } break; case _DES_: if (isdigit(c)) { save(c); state = _DESD_; } else { int E, S; dd_lval.r = atof(dd_text); dd_parse(RNUMBER); E = dd_text[dd_leng-2]; S = dd_text[dd_leng-1]; clearbuf(); state = _S_; dd_lex(E); dd_lex(S); dd_lex(c); } break; case _DOT_: if (c == 'x') { dd_parse(DOTX); clearbuf(); state = _S_; } else if (c == 'y') { dd_parse(DOTY); clearbuf(); state = _S_; } else if (c == '1') { save(c); state = _DOT1_; } else if (c == '2') { save(c); state = _DOT2_; } else if (c == 'a') { save(c); state = _DA_; } else if (c == 'r') { save(c); state = _DR_; } else if (isdigit(c)) { save(c); state = _DDOT_; } else { dd_parse('.'); clearbuf(); state = _S_; dd_lex(c); } break; case _DOT1_: if (isdigit(c)) { state = _DDOT_; dd_lex(c); } else { dd_parse(DOT1); clearbuf(); state = _S_; dd_lex(c); } break; case _DOT2_: if (isdigit(c)) { state = _DDOT_; dd_lex(c); } else { dd_parse(DOT2); clearbuf(); state = _S_; dd_lex(c); } break; case _DA_: if (c == 'r') { save(c); state = _DAR_; } else { dd_parse('.'); clearbuf(); state = _S_; dd_lex('a'); dd_lex(c); } break; case _DAR_: if (c == 'g') { dd_parse(DOTARG); clearbuf(); state = _S_; } else { dd_parse('.'); clearbuf(); state = _S_; dd_lex('a'); dd_lex('r'); dd_lex(c); } break; case _DR_: if (c == 'a') { save(c); state = _DRA_; } else { dd_parse('.'); clearbuf(); state = _S_; dd_lex('r'); dd_lex(c); } break; case _DRA_: if (c == 'd') { dd_parse(DOTRAD); clearbuf(); state = _S_; } else { dd_parse('.'); clearbuf(); state = _S_; dd_lex('r'); dd_lex('a'); dd_lex(c); } break; case _QUOTE_: if (c == '"') { save(c); dd_lval.s = strdup(dd_text); dd_parse(CSTRING); clearbuf(); state = _S_; } else if (c == '\n') { save('"'); dd_lval.s = strdup(dd_text); dd_parse(CSTRING); clearbuf(); state = _S_; } else { save(c); state = _QUOTE_; } break; case _QUERY_: if (c == '\n') { dd_lval.s = strdup(dd_text); dd_parse(QUERY); dd_parse(NEWLINE); clearbuf(); state = _S_; } else { save(c); state = _QUERY_; } break; case _BSLASH_: if (c == '\n') { state = _S_; } else { dd_parse('\\'); state = _S_; dd_lex(c); } break; case _HASH_: if (c == '\n') { dd_parse(NEWLINE); state = _S_; } else { state = _HASH_; } break; case _AND_: if (c == '&') { dd_parse(AND); state = _S_; } else { dd_parse(AMPERSAND); state = _S_; dd_lex(c); } break; case _OR_: if (c == '|') { dd_parse(OR); state = _S_; } else { dd_parse(VERTBAR); state = _S_; dd_lex(c); } break; case _EQ_: if (c == '=') { dd_parse(EQ_EQ); state = _S_; } else { dd_parse(EQUALS); state = _S_; dd_lex(c); } break; case _NOT_: if (c == '=') { dd_parse(NOT_EQ); state = _S_; } else { dd_parse(NOT); state = _S_; dd_lex(c); } break; case _LT_: if (c == '=') { dd_parse(LT_EQ); state = _S_; } else { dd_parse(LT); state = _S_; dd_lex(c); } break; case _GT_: if (c == '=') { dd_parse(GT_EQ); state = _S_; } else { dd_parse(GT); state = _S_; dd_lex(c); } break; case _SLASH_: if (c == '/') { dd_parse(SLASH_SLASH); state = _S_; } else { dd_parse(SLASH); state = _S_; DonaldAppAgentName = 0; dd_lex(c); } break; case _TILDE_: if (c == '/') { DonaldAppAgentName = 1; dd_appAgentName++; dd_parse(TILDE_SLASH); state = _S_; } else { DonaldAppAgentName = 0; state = _S_; dd_lex(c); } break; case _F_: if (c == ' ' || c == '\t') { state = _F_; } else if (c == '<') { state = _B_; } else { state = _A_; dd_lex(c); } break; case _X_: if (c == ' ' || c == '\t') { state = _X_; } else if (c == '<') { state = _B_; } else { state = _A_; dd_lex(c); } break; case _B_: if (c == ' ' || c == '\t') { state = _B_; } else if (c == 'i') { state = _BI_; } else { switch (gtarget) { case _F_: case _X_: state = _A_; dd_lex('<'); dd_lex(c); break; default: state = _LT_; dd_lex(c); break; } } break; case _BI_: case _BISP_: if (c == ' ' || c == '\t') { state = _BISP_; } else if (c == '-') { state = _BI__; } else if (c == '>') { switch (gtarget) { case _F_: dd_parse(FI); break; case _X_: dd_parse(XI); break; case _I_: dd_parse(I); break; } clearbuf(); state = _S_; } else { switch (gtarget) { case _F_: case _X_: state = _A_; dd_lex('<'); dd_lex('i'); if (state == _BISP_) dd_lex(' '); dd_lex(c); break; default: state = _LT_; dd_lex('i'); if (state == _BISP_) dd_lex(' '); dd_lex(c); break; } } break; case _BI__: if (c == ' ' || c == '\t') { state = _BI__; } else if (c == '1') { state = _BI_1_; } else { switch (gtarget) { case _F_: case _X_: state = _A_; dd_lex('<'); dd_lex('i'); dd_lex('-'); dd_lex(c); break; default: state = _LT_; dd_lex('i'); dd_lex('-'); dd_lex(c); break; } } break; case _BI_1_: case _BI_1SP_: if (c == ' ' || c == '\t') { state = _BI_1SP_; } else if (c == '>') { switch (gtarget) { case _F_: dd_parse(FI_1); break; case _X_: dd_parse(XI_1); break; case _I_: dd_parse(I_1); break; } clearbuf(); state = _S_; } else { switch (gtarget) { case _F_: case _X_: state = _A_; dd_lex('<'); dd_lex('i'); dd_lex('-'); dd_lex('1'); if (state == _BI_1SP_) dd_lex(' '); dd_lex(c); break; default: state = _LT_; dd_lex('i'); dd_lex('-'); dd_lex('1'); if (state == _BI_1SP_) dd_lex(' '); dd_lex(c); break; } } break; case _II_: if (c == '!') { state = _IN_; } else { state = _A_; dd_lex('I'); dd_lex(c); } break; case _IN_: if (isalpha(c)) { save(c); state = _INA_; } else { state = _S_; dd_lex('I'); dd_lex('!'); dd_lex(c); } break; case _INA_: if (isalpha(c)) { save(c); state = _INA_; } else { dd_lval.s = strdup(dd_text); dd_parse(IMGFUNC); clearbuf(); state = _S_; dd_lex(c); } break; } } #define FILE_DEV 1 void init_donald(void) { char *name = "/donald.init.e"; char fullname[255]; FILE *initFile; extern char *progname; extern char viewport_name[]; extern int run(short, void *, char *); char *envcontents; if (dd_text == 0) { dd_text = (char *) emalloc(bufsize * sizeof(int)); }; *viewport_name = '\0'; dd_prompt = (char *)malloc(4); strcpy(dd_prompt, "[/]"); strcpy(fullname, libLocation); strcat(fullname, name); if ((initFile = fopen(fullname, "r")) == 0) { fprintf(stderr, "%s: can't open %s\n", progname, fullname); exit(1); } run(FILE_DEV, initFile, name); } tkeden1.18/Eden/004070000025250000147000000000000731700574300147315ustar00ashleydcsother00003470000356tkeden1.18/Eden/yacc.y010060000025250000147000000367730731245741000160560ustar00ashleydcsother00003470000356%{ /* * $Id: yacc.y,v 1.14 2001/04/04 19:38:34 cssbz Exp $ */ /* This is from the Autoconf manual. Note the pragma directive is indented so that pre-ANSI C compilers will ignore it. [Ash] */ /* AIX requires this to be the first thing in the file */ #ifdef __GNUC__ # define alloca __builtin_alloca #else # if HAVE_ALLOCA_H # include # else # ifdef _AIX #pragma alloca # else # ifndef alloca /* predefined by HP cc +Olibcalls */ char *alloca (); # endif # endif # endif #endif static char rcsid[] = "$Id: yacc.y,v 1.14 2001/04/04 19:38:34 cssbz Exp $"; #include "../config.h" #include #include "eden.h" #include "emalloc.h" #ifdef HAVE_DMALLOC #include #endif #define YYERROR_VERBOSE 1 #define WANT_SETYYPARSEINIT #define code2(c1,c2) code(c1); code(c2) #define code3(c1,c2,c3) code(c1); code(c2); code(c3) #define fromto(F,T) (F)[1] = (Inst)((T)-((F)+2)) extern char *textptr, textcode[]; extern symptr_QUEUE break_q, cont_q; extern void patch(Inst *, Inst *, symptr_QUEUE *); extern void dispatch(Inst *, symptr_QUEUE *); #define dispatch_break() dispatch(progp, &break_q); code2(jmp, 0) #define dispatch_continue() dispatch(progp, &cont_q); code2(jmp, 0) #define patch_break(mark,p) patch(mark, p, &break_q) #define patch_continue(mark,p) patch(mark, p, &cont_q) #define rts (Inst) 0 typedef struct { Inst *location; Datum *dp; } Garbage; typedef struct { Inst *start; Inst *end; } UsefulGarbage; static int MAXGARBAGE = 0; static int MAXUSABLE = 0; static Garbage *garbage; static UsefulGarbage *usable; static int nGarbage = 0; static int nUsable = 0; static int garbageLevel = 0; extern int inEVAL; extern int *autocalc; /* Garbage seems to be a structure describing which information on the stack can be thrown away. But see also the Usable structure :) */ void markGarbage(location, dp) Inst *location; Datum *dp; { if (MAXGARBAGE == 0) { garbage = (Garbage *) emalloc(sizeof(Garbage) * 64); MAXGARBAGE = 64; } if (nGarbage == MAXGARBAGE) { MAXGARBAGE += 64; garbage = (Garbage *) erealloc(garbage, sizeof(Garbage) * MAXGARBAGE); } garbage[nGarbage].location = location; garbage[nGarbage].dp = dp; nGarbage++; } /* Usable describes information on the stack that must be kept. Usable overrides Garbage - see Garbage above :) */ void unmarkGarbage(start, end) Inst *start; Inst *end; { if (MAXUSABLE == 0) { usable = (UsefulGarbage *) emalloc(sizeof(UsefulGarbage) * 4); MAXUSABLE = 4; } if (nUsable == MAXUSABLE) { MAXUSABLE += 4; usable = (UsefulGarbage *) erealloc(usable, sizeof(UsefulGarbage) * MAXUSABLE); } usable[nUsable].start = start; usable[nUsable].end = end; nUsable++; } void incGarbageLevel(void) { garbageLevel++; } void decGarbageLevel(void) { --garbageLevel; } void clearGarbage(void) { int i, j, save; if (--garbageLevel == 0) { for (i = 0; i < nGarbage; i++) { save = 0; /* nonzero ('true') if we should keep this information */ for (j = 0; j < nUsable; j++) { if (garbage[i].location >= usable[j].start && garbage[i].location <= usable[j].end) { /* this garbage is within this usable section, so we should keep it */ save = 1; break; } } if (!save) { /* don't save the info - free it up */ freedatum(*garbage[i].dp); free(garbage[i].dp); } } nGarbage = nUsable = 0; } } void defnonly(char *s) { /* warn if illegal definition */ if (!indef) error2(s, "used outside definition"); } extern void addentry(Datum *, Inst *); extern Inst *code(/* Inst */); extern Inst *code_related_by(symptr); extern Inst *code_related_by_runtimelhs(); extern Inst *code_definition(int, symptr, Inst *, Inst *, Int, char *); extern Inst *code_definition_runtimelhs(int, Inst *, Inst *, Int, char *); extern Inst *code_eval(Inst *, Inst *); extern void execute(Inst *); /* can be used to execute pc at end with (rts) */ extern void codeswitch(struct t *); extern void insert_level_marker(int), delete_local_level(int); extern void push_text(char *, int); %} %union { Datum *dp; /* constants */ symptr sym; /* symbol table ptr */ Inst *inst; /* machine instruction */ Int narg; /* number of arguments */ Inst fun; /* binop */ struct t *sw; /* switch */ char *tbegin; /* beginning of text */ } %token UNDEF %token REAL %token INTEGER %token MYCHAR %token STRING %token LIST %token CONSTANT %token VAR %token FORMULA %token BLTIN LIB RLIB %token FUNC PROC PMAC %token FUNCTION %token PROCEDURE %token PROCMACRO %token AUTO PARA %token LOCAL %token BREAK CONTINUE %token SWITCH CASE DEFAULT %token DO FOR WHILE IF ELSE %token SHIFT APPEND INSERT DELETE RETURN %token ARG %type id identifier %type lvalue primary secondary %type asgnop %type lazy_and lazy_or colon %type expr %type expr1 expr2 end_expr2 expr3 end_expr3 %type switch %type cases %type stmt compound %type asgn stmtlist %type then else begin %type action def_end %type is def_begin evaluate %type defn declare_formula declare_action declare_relation %type declare_local local_list %type refer_opt id_list id_list_opt %type arglist argument_list %nonassoc IS TILDE_GT %left ',' %right '=' PLUS_EQ MINUS_EQ %right '?' %left OR LAZY_OR %left AND LAZY_AND %left BITAND BITOR %left EQ_EQ NOT_EQ %left '>' GT_EQ '<' LT_EQ %left '+' '-' SLASH_SLASH %left '*' '/' '%' %nonassoc NEGATE NOT '!' PLUS_PLUS MINUS_MINUS '#' '&' ASTERISK EVAL %expect 6 %% program: /* nothing */ | stmt { code2(freeheap, rts); textptr = textcode; return 1; } | error { yyerrok; } ; lvalue: id { $$ = code2(addr, $1); } | LOCAL { defnonly("local variable"); $$ = code2(localaddr, $1); } | '$' { defnonly("$"); $$ = code2(localaddr, (Inst)0); } | ARG { defnonly("$"); $$ = code2(localaddr, (Inst)0); code3(pushint, (Inst)$1, indexcalc); } | lvalue '[' expr ']' { code(indexcalc); } | '*' primary %prec ASTERISK { $$ = $2; } | '*' '&' lvalue { $$ = $3; } | '`' expr '`' { $$ = $2; code(lookup_address); /* Patrick added some code here in yacc.y 1.8 which evaluated this address at parse time. I think this may have been an attempt to fix the problems of referential dependency, but it doesn't work, so removed again. [Ash] */ } | '(' lvalue ')' { $$ = $2; } ; asgn: lvalue asgnop expr %prec '=' { code($2); } | PLUS_PLUS lvalue { code(pre_inc); $$ = $2; } | lvalue PLUS_PLUS { code(post_inc); } | MINUS_MINUS lvalue { code(pre_dec); $$ = $2; } | lvalue MINUS_MINUS { code(post_dec); } ; asgnop: '=' { $$ = assign; } | PLUS_EQ { $$ = inc_asgn; } | MINUS_EQ { $$ = dec_asgn; } ; primary: lvalue { code(getvalue); } | secondary | '(' expr ')' { $$ = $2; } ; secondary: primary '(' arglist ')' { code3(makelist, $3, eval); } | secondary '[' expr ']' { code(sel); } ; stmt: defn | expr ';' { code2(popd, freeheap); } | RETURN ';' { defnonly("return"); $$ = code2(pushUNDEF, rts); } | RETURN expr ';' { defnonly("return"); $$ = $2; code(rts); } | SHIFT ';' { defnonly("shift"); $$ = code3(localaddr, 0, shift); } | SHIFT lvalue ';' { $$ = $2; code(shift); } | APPEND lvalue ',' expr ';' { $$ = $2; code2(append, freeheap); } | INSERT lvalue ',' expr ',' expr ';' { $$ = $2; code2(insert, freeheap); } | DELETE lvalue ',' expr ';' { $$ = $2; code2(delete, freeheap); } | CASE CONSTANT ':' { if (inswitch) addentry($2, progp); else error("'case' used outside switch"); $$ = progp; } | DEFAULT ':' { if (inswitch) addentry(0, progp); else error("'default' used outside switch"); $$ = progp; } | BREAK ';' { if (!inloop && !inswitch) error("'break' used outside loop/switch"); $$ = progp; dispatch_break(); } | CONTINUE ';' { if (!inloop) error("'continue' used outside loop"); $$ = progp; dispatch_continue(); } | switch expr cases stmt { dispatch_break(); fromto($3, progp); code(switchcode); codeswitch($1); patch_break($2, progp); $$ = $2; --inswitch; } | for expr1 expr2 end_expr2 expr3 end_expr3 stmt { Inst * p = code(jmp); code($5 - (p + 2)); fromto($4, $7); if ($3 != $4 - 2) fromto($4-2, progp); fromto($6, $3); patch_continue($2, $5); patch_break($2, progp); $$ = $2; --inloop; } | do stmt WHILE '(' expr ')' ';' { Inst * p = code(jpt); code($2 - (p + 2)); patch_continue($2, $5); patch_break($2, progp); $$ = $2; --inloop; } | while '(' expr ')' then stmt { Inst * p = code(jmp); code($3 - (p + 2)); fromto($5, progp); patch_continue($3, $3); patch_break($3, progp); $$ = $3; --inloop; } | IF '(' expr ')' then stmt { fromto($5, progp); $$ = $3; } | IF '(' expr ')' then stmt else stmt { fromto($5, $8); fromto($7, progp); $$ = $3; } | compound | ';' { $$ = progp; } ; while: WHILE { inloop++; dispatch(progp, &cont_q); dispatch(progp, &break_q); } ; do: DO { inloop++; dispatch(progp, &cont_q); dispatch(progp, &break_q); } ; for: FOR '(' { inloop++; dispatch(progp, &cont_q); dispatch(progp, &break_q); } ; expr1: ';' { $$ = progp; } | expr ';' { code(popd); } ; expr2: ';' { $$ = code2(jmp, 0); } | expr ';' { code2(jpnt, 0); } ; end_expr2: /* nothing */ { $$ = code2(jmp, 0); } ; expr3: ')' { $$ = code2(jmp, 0); } | expr ')' { code3(popd, jmp, 0); } ; end_expr3: /* nothing */ { $$ = code2(jmp, 0); } ; then: /* nothing */ { $$ = code2(jpnt, 0); } ; else: ELSE { $$ = code2(jmp, 0); } ; compound: '{' stmtlist '}' { $$ = $2; } ; stmtlist: /* nothing */ { $$ = progp; } | stmtlist stmt { /*fprintf(stderr, "rd inprocmacro=%d\n", inprocmacro);*/ if (inprocmacro) code(eager); } ; switch: SWITCH '(' { $$ = entry_ptr; inswitch++; dispatch(progp, &break_q); } ; cases: ')' { $$ = code2(jmp, 0); } ; begin: /* nothing */ { $$ = progp; } ; id: identifier { if (informula && !inEVAL) addID($1); } | BLTIN | LIB | RLIB ; identifier: VAR | FORMULA | FUNCTION | PROCEDURE | PROCMACRO ; expr: CONSTANT { markGarbage(progp, $1); $$ = code2(constpush, (Inst)$1); } | asgn { if (informula) error("assignment used inside formula"); } | primary /* already coded in primary */ | '&' lvalue %prec NEGATE { $$ = $2; } | '[' begin arglist ']' { code2(makelist, (Inst)$3); $$ = $2; } | expr '+' expr { code(add); } | expr '-' expr { code(sub); } | expr '*' expr { code(mul); } | expr '/' expr { code(divide); } | expr '%' expr { code(mod); } | expr SLASH_SLASH expr { code(concat); } | expr '>' expr { code(gt); } | expr GT_EQ expr { code(ge); } | expr '<' expr { code(lt); } | expr LT_EQ expr { code(le); } | expr EQ_EQ expr { code(eq); } | expr NOT_EQ expr { code(ne); } | '?' { code(noupdate); } lvalue %prec NEGATE { $$ = $3; code(query); code(resetupdate); } | '-' expr %prec NEGATE { $$ = $2; code(negate); } | expr '#' { code(listsize); } | '!' expr { $$ = $2; code(lazy_not); } | NOT expr { $$ = $2; code(not); } | expr '?' then expr colon expr { fromto($3, $6); fromto($5, progp); } | expr AND expr { code(and); } | expr OR expr { code(or); } | expr lazy_and expr %prec LAZY_AND { fromto($2, progp); code(cnv_2_bool); } | expr lazy_or expr %prec LAZY_OR { fromto($2, progp); code(cnv_2_bool); } | expr BITAND expr { code(bitand); } | expr BITOR expr { code(bitor); } | evaluate '(' expr ')' { code(rts); unmarkGarbage($3, progp); $$ = code_eval($3, progp); inEVAL = 0; } ; evaluate: EVAL { inEVAL = 1; } colon: ':' { $$ = code2(jmp, 0); } ; lazy_and: LAZY_AND { code(ddup); $$ = code2(jpnt, 0); code(popd); } ; lazy_or: LAZY_OR { code(ddup); $$ = code2(jpnf, 0); code(popd); } ; defn: declare_formula | declare_action | declare_relation ; declare_relation: identifier tilde_gt '[' id_list_opt ']' ';' { $$ = code_related_by($1); } /* related_by_runtimelhs by [Ash] */ | '`' expr '`' { $$ = $2; code(lookup_address); } tilde_gt '[' id_list_opt ']' ';' { $$ = code_related_by_runtimelhs(); } ; tilde_gt: TILDE_GT { addID((symptr) 0); } ; declare_formula: identifier is expr ';' { informula = 0; code(rts); unmarkGarbage($3, progp); $$ = code_definition( FORMULA, $1, $3, progp, 0, $2); } | '`' expr '`' { code(lookup_address); } /* --sun */ is expr ';' { informula = 0; code(rts); unmarkGarbage($6, progp); $$ = code_definition_runtimelhs( FORMULA, $6, progp, 0, $5); } ; is: IS { $$ = textptr; informula = 1; addID((symptr) 0); } ; declare_action: action identifier { inprocmacro = ($1 == 2); /*fprintf(stderr, "inprocmacro=%d\n", inprocmacro);*/ addID((symptr) 0); } refer_opt def_begin declare_para declare_local stmtlist def_end { code2(pushUNDEF, rts); unmarkGarbage($8, progp); $$ = code_definition( ($1 ? (($1 == 1) ? FUNCTION : PROCMACRO) : PROCEDURE), $2, $8, progp, $7, $5 ); delete_local_level($9); inprocmacro = 0; } ; action: FUNC { $$ = 1; } | PROC { $$ = 0; } | PMAC { $$ = 2; } ; def_begin: '{' { static char c = '{'; if (indef) $$ = textptr - 1; else { $$ = textptr; push_text(&c,1); } insert_level_marker(++indef); } ; def_end: '}' { $$ = indef--; } ; /* optional refer_opt: ie nothing, or a refer [Ash] */ refer_opt: /* nothing */ { $$ = 0; } | ':' id_list { $$ = $2; } ; /* optional id_list: ie nothing, or an id_list [Ash] */ id_list_opt: /* nothing */ { $$ = 0; } | id_list ; id_list: identifier { $$ = 1; addID($1); } | id_list ',' identifier { $$ = $1 + 1; addID($3); } ; declare_para: /* nothing */ | PARA { inpara = 1; } local_list ';' { inpara = 0; } ; declare_local: /* nothing */ { $$ = 0; } | declare_local AUTO { inauto = 1; } local_list ';' { inauto = 0; $$ = $1 + $4; } ; local_list: LOCAL { $$ = 1; } | local_list ',' LOCAL { $$ = $1 + 1; } ; arglist: /* nothing */ { $$ = 0; } | argument_list ; argument_list: expr { $$ = 1; } | argument_list ',' expr { $$ = $1 + 1; } ; %% /*----------------------- end of grammar --------------------------*/ luatetkeden1.18/Eden/type.c010060000025250000147000000150600731245736000160600ustar00ashleydcsother00003470000356/* * $Id: type.c,v 1.17 1999/11/16 21:20:40 ashley Rel1.10 $ */ static char rcsid[] = "$Id: type.c,v 1.17 1999/11/16 21:20:40 ashley Rel1.10 $"; /*** * TYPE CONVERSION FUNCTIONS * ***/ #include #include #include "../config.h" #include "eden.h" #include "builtin.h" #include "yacc.h" #include "emalloc.h" #ifdef HAVE_DMALLOC #include #endif void t_str1(Datum); extern Datum newhdat(Datum); static struct { short type; char *name; } datatype[] = { { UNDEF, "@" }, { REAL, "float" }, { INTEGER, "int" }, { MYCHAR, "char" }, { STRING, "string" }, { LIST, "list" }, { FORMULA, "formula" }, { FUNCTION, "func" }, { PROCEDURE, "proc" }, { PROCMACRO, "procmacro" }, { BLTIN, "builtin" }, { LIB, "C-func" }, { RLIB, "Real-func" }, { VAR, "var" }, { 0, "???" } }; Datum ctos(Datum d) { /* convert char to string */ if (ischar(d)) { /* only if Datum is char */ char *s; s = (char *) getheap(2);/* put the string on heap */ *s = d.u.i; s[1] = '\0'; d.u.s = s; d.type = STRING; } if (!isstr(d)) error("string needed"); return d; } int typeno(char *typename) { int i; for (i = 0; datatype[i].type; i++) { if (strcmp(typename, datatype[i].name) == 0) break; } if (datatype[i].type == 0) error("unknown data type"); return datatype[i].type; } char * typename(int type) { int i; for (i = 0; datatype[i].type; i++) { if (type == datatype[i].type) break; } return datatype[i].name; } /* type(data): type of datum in the form of a string */ void t_type(void) { /* data type name */ Datum d; short type; int i; if (paracount == 0) usage("s = type(expr);"); type = para(1).type; if (type & ADDRESSMASK) { dpush(d, STRING, "pointer"); } else { for (i = 0; datatype[i].type; i++) { if (type == datatype[i].type) break; } dpush(d, STRING, datatype[i].name); } } /* int(data): convert datum to an integer */ void t_int(void) { Datum d; if (paracount == 0) usage("i = int(expr);"); d = para(1); if (is_symbol(d)) { d.u.i = d.u.v.x; } else { switch (d.type) { case REAL: d.u.i = d.u.r; case INTEGER: case MYCHAR: break; case STRING: d.u.i = atoi(d.u.s); break; default: pushUNDEF(); /* return @ */ return; } } d.type = INTEGER; push(d); } /* float(data): builtin function convert datum to an integer */ void t_float(void) { Datum d; if (paracount == 0) usage("f = float(expr);"); d = para(1); if (is_symbol(d)) { d.u.r = d.u.v.x; } else { switch (d.type) { case INTEGER: case MYCHAR: d.u.r = d.u.i; case REAL: break; case STRING: d.u.r = atof(d.u.s); break; default: pushUNDEF(); /* return @ */ return; } } d.type = REAL; push(d); } /* char(datum): builtin function convert datum to a character */ void t_char(void) { /* convert to char */ Datum d; if (paracount == 0) usage("c = char(expr);"); d = para(1); switch (d.type) { case REAL: d.u.i = d.u.r; case INTEGER: case MYCHAR: break; case STRING: /* the 1st char of string */ d.u.i = *d.u.s & 0377; /* '\0' if s == "" */ break; default: pushUNDEF(); /* return @ */ return; } d.type = MYCHAR; push(d); } /* str(datum): builtin function convert datum to a string */ void t_str(void) { Datum d; if (paracount == 0) usage("c = str(expr);"); d = para(1); t_str1(d); } /* separating t_str to two subs. the latter can be used by other programs --sun */ void t_str1(Datum d) { /* Static buffer, used for type conversions likely to result in a small resulting string [Ash] */ char buf[1024]; /* Dynamic buffer, used when creating a string from a list [Ash] */ char *dynbuf; int dynbuflen; /* dynamic buffer length [Ash] */ int i; Datum d1; if (is_symbol(d)) { sprintf(buf, "&%s", symbol_of(d)->name); } else if (is_local(d)) { sprintf(buf, "%d", d.u.v.x); } else { switch (d.type) { case STRING: push(d); return; case LIST: /* Patrick added a list -> string conversion function [Ash] */ /* All of the code in this file is similar to the print() function in builtin.c, which performs the task for writeln() and so on. However, print does not need to store the result anywhere, simply write it out. [Ash] */ /* Initial size and allocation units of dynbuf [Ash] */ #define STR_DYNBUF_LEN_UNITS 1028 dynbuf = (char *) emalloc(STR_DYNBUF_LEN_UNITS); dynbuflen = STR_DYNBUF_LEN_UNITS; *dynbuf=0; strcat(dynbuf, "["); /* For each item in the list... [Ash] */ for (i = 1; i <= d.u.a[0].u.i; i++) { t_str1(d.u.a[i]); /* Convert that item to a string [Ash] */ d1 = pop(); /* If dynbuf is not big enough, expand it [Ash] */ if (strlen(dynbuf) > (dynbuflen - 10)) { dynbuflen += STR_DYNBUF_LEN_UNITS; dynbuf = erealloc(dynbuf, dynbuflen); } strcat(dynbuf, d1.u.s); if (i < d.u.a[0].u.i) strcat(dynbuf, ","); } strcat(dynbuf, "]"); d.type = STRING; d.u.s = dynbuf; d = newhdat(d); /* copy it to the heap */ push(d); free(dynbuf); return; case UNDEF: buf[0] = '@'; buf[1] = '\0'; break; case REAL: sprintf(buf, "%f", d.u.r); break; case INTEGER: sprintf(buf, "%d", d.u.i); break; case MYCHAR: buf[0] = d.u.i; buf[1] = '\0'; break; default: pushUNDEF(); /* return @ */ return; } } d.type = STRING; d.u.s = buf; d = newhdat(d); /* copy it to the heap */ push(d); } /*---- _type_convert(datum, typename): builtin function convert datum to type specified by typename. ! ! ! DANGER --- MAY CAUSE CLASH IF NOT CAREFUL ! ! ! no type checking. no memory allocation. extremely dangerous to convert into string or list. ----*/ void t_super(void) { /* super type convertion */ Datum d; Datum t; char *s; int i; extern void muststr(Datum); if (paracount < 2) usage("data = _type_convert(data, \"type\");"); d = para(1); t = para(2); muststr(t); s = t.u.s; for (i = 0; datatype[i].type; i++) { if (strcmp(s, datatype[i].name) == 0) break; } d.type = datatype[i].type; push(d); } tkeden1.18/Eden/symptr.q.h010060000025250000147000000026410731245610400166750ustar00ashleydcsother00003470000356/* * $Id: symptr.q.h,v 1.4 1999/11/16 21:20:40 ashley Rel1.10 $ */ #include "global.q.h" #ifndef _SYMPTR_Q_H struct symptr_queue { struct symptr_queue *prev; struct symptr_queue *next; symptr obj; }; typedef struct symptr_queue symptr_QUEUE; typedef symptr_QUEUE *symptr_ATOM; extern symptr_QUEUE *SEARCH_symptr(symptr_QUEUE *, symptr, int); extern void DELETE_symptr_ATOM(symptr_QUEUE *, symptr_ATOM); #ifndef NEW_symptr #define NEW_symptr(OBJ) OBJ #endif #ifndef FREE_symptr #define FREE_symptr(OBJ) /* do nothing */ #endif #ifndef EQUAL_symptr #define EQUAL_symptr(A,B) ((A)==(B)) #endif #define DESTROY_symptr_ATOM(A) \ { \ FREE_symptr((A)->obj); \ free(A); \ } #define DELETE_NTH_symptr(Q,OBJ,n) DELETE_symptr_ATOM(Q,SEARCH_symptr(Q,OBJ,n)) #define DELETE_FIRST_symptr(Q,OBJ) DELETE_symptr_ATOM(Q,SEARCH_symptr(Q,OBJ,1)) #define DELETE_FRONT_symptr(Q) DELETE_symptr_ATOM(Q,FRONT(Q)) #define DELETE_LAST_symptr(Q) DELETE_symptr_ATOM(Q,LAST(Q)) #define CLEAR_symptr_Q(Q) \ while (!Q_EMPTY(Q)) DELETE_symptr_ATOM(Q,(Q)->next) #define APPEND_symptr_Q(Q,OBJ) \ { \ symptr_ATOM A; \ ALLOC_ATOM(A); \ A->obj = NEW_symptr(OBJ); \ APPEND_Q(Q,A); \ } #define CONCAT_symptr_Q(Qdst, Qsrc) \ { \ symptr_QUEUE *P; \ FOREACH (P, Qsrc) APPEND_symptr_Q(Qdst, P->obj); \ } /* This finds the first occurrance of OBJ in Q [Ash] */ #define IN_symptr_Q(Q,OBJ) SEARCH_symptr(Q,OBJ,1) #define _SYMPTR_Q_H #endif tkeden1.18/Eden/symptr.q.c010060000025250000147000000022630731245731400166740ustar00ashleydcsother00003470000356/* * $Id: symptr.q.c,v 1.7 1999/11/16 21:20:40 ashley Rel1.10 $ */ static char rcsid3[] = "$Id: symptr.q.c,v 1.7 1999/11/16 21:20:40 ashley Rel1.10 $"; #include "../config.h" #include "symptr.q.h" /* This function has highly concealed semantics. Note particularly the &&: the expression with side-effect on the RHS will only be executed if the LHS is true. The function appears to iterate through the given queue until the nth occurrance of obj, then returns a new queue pointer to that point. [Ash] */ /* return the position of the n-th object in a symptr queue [sy or edward] */ symptr_QUEUE * SEARCH_symptr(symptr_QUEUE * Q, symptr obj, int n) { symptr_QUEUE *P; FOREACH(P, Q) { if (EQUAL_symptr(obj, P->obj) && !--n) return P; } return (symptr_QUEUE *) 0; /* NOT FOUND */ } void DELETE_symptr_ATOM(symptr_QUEUE * Q, symptr_ATOM A) { if (A && A != Q) { A->prev->next = A->next; A->next->prev = A->prev; DESTROY_symptr_ATOM(A); } } void MOVE_symptr_Q(symptr_QUEUE * Qsrc, symptr_QUEUE * Qdst) { if (!Q_EMPTY(Qsrc)) { (Qdst->prev->next = Qsrc->next)->prev = Qdst->prev; (Qsrc->prev->next = Qdst)->prev = Qsrc->prev; CLEAN_Q(Qsrc); } } tkeden1.18/Eden/symbol.c010060000025250000147000000207060731245763200164110ustar00ashleydcsother00003470000356/* * $Id: symbol.c,v 1.10 1999/11/16 21:20:40 ashley Rel1.10 $ */ static char rcsid[] = "$Id: symbol.c,v 1.10 1999/11/16 21:20:40 ashley Rel1.10 $"; /* * SYMBOL TABLE: INSTALL AND LOOK-UP * */ #include #include #include "../config.h" #include "eden.h" #include "yacc.h" #include "symptr.q.c" /* some of the code is used by other modules */ #include "hash.h" #include "notation.h" #ifdef DISTRIB #include "agency.q.c" #endif /* DISTRIB */ #include "emalloc.h" #ifdef HAVE_DMALLOC #include #endif #ifdef DISTRIB void add_agent_Q(agent_QUEUE *, char *); agent_ATOM search_agent_Q(agent_QUEUE *, char *); void delete_agent_Q(agent_QUEUE *, char *, char *); #endif /* DISTRIB */ /*-------------------------------------------------------------------- SYMBOL HASH TABLE --------------------------------------------------------------------*/ /* HASHSIZE is defined in "hash.h": must be power of 2 minus 1 */ int hashindex(char *s) { int i = 0; while (*s) i ^= *s++; return i & HASHSIZE; } symptr hashtable[HASHSIZE + 1] = {(symptr) 0}; /* init to nulls */ symptr lookup(char *s) { /* FIND SYMBOL OF NAME S */ /* 0 = NOT FOUND, ELSE = SYMBOL POINTER */ symptr sp; for (sp = hashtable[hashindex(s)]; sp != (symptr) 0; sp = sp->next) if (strcmp(sp->name, s) == 0) return sp; return 0; /* 0 ==> not found */ } symptr install(char *s, int st, int t, int i) /* INTERNAL: INSTALL A SYMBOL IN SYMBOL TABLE */ /* s = symbol name */ /* st = symbol type */ /* t = initial data type */ /* i = initial data value */ { extern symptr hashtable[]; int indx; symptr sp; extern topEntryStack(void); extern char *topMasterStack(void); extern char agentName[128]; extern notationType currentNotation; extern int builtin_ft_check(char *); extern int append_agentName; extern int append_NoAgentName; #ifdef DISTRIB extern Int *EveryOneAllowed; extern char *everyone; #endif /* DISTRIB */ sp = (symptr) emalloc(sizeof(symbol)); sp->name = emalloc(strlen(s) + 1); /* +1 for '\0' */ strcpy(sp->name, s); sp->stype = st; sp->inst = (Inst *) 0; sp->nauto = 0; sp->changed = TRUE; sp->text = (char *) 0; sp->d.type = t; if (t == UNDEF) { sp->d.u.sym = sp; /* put a reference to the symbol in the UNDEF Datum so that name details etc can be found in the event of an error (in eval(), say) [Ash] */ } else { sp->d.u.i = i; } CLEAN_Q(&sp->targets); CLEAN_Q(&sp->sources); #ifdef DISTRIB CLEAN_Q(&sp->OracleOf); CLEAN_Q(&sp->HandleOf); CLEAN_Q(&sp->StateOf); /* if (*agentName!=0 && builtin_ft_check(s) ==0 && currentNotation != LSD && append_NoAgentName > 0 && append_agentName > 0 ) { add_agent_Q(&sp->HandleOf, agentName); add_agent_Q(&sp->OracleOf, agentName); } depends on design decision. if agent owns default rights? --sun */ /*add_agent_Q(&sp->HandleOf, "wmb"); delete_agent_Q(&sp->HandleOf, "sun"); add_agent_Q(&sp->HandleOf, "wmb"); -- for test */ #endif /* DISTRIB */ sp->Qloc = 0; sp->marked = 0; sp->entry = topEntryStack(); sp->master = topMasterStack(); #ifdef DISTRIB if (streq(sp->name, "EveryOneAllowed") || *EveryOneAllowed) { if (streq(topMasterStack(), "system") && !streq(sp->name, "screen") && !streq(sp->name, "DoNaLDdefaultWin") && !streq(sp->name, "DoNaLD")) { add_agent_Q(&sp->HandleOf, "SYSTEM"); add_agent_Q(&sp->OracleOf, "SYSTEM"); add_agent_Q(&sp->StateOf, "SYSTEM"); } else { add_agent_Q(&sp->HandleOf, everyone); add_agent_Q(&sp->OracleOf, everyone); add_agent_Q(&sp->StateOf, everyone); } } #endif /* DISTRIB */ sp->next = hashtable[indx = hashindex(s)]; /* put at front of list */ hashtable[indx] = sp; return sp; } #ifdef DISTRIB /* Add a new global variable to the symbol table, with an initially undefined value. This is needed so that other modules (ie LSD) don't need to know the value of UNDEF (#including yacc.h leads to conflicts with YYSTYPE). [by Ash] */ symptr installGlobalUndef(char *name) { return install(name, VAR, UNDEF, 0); } void add_agent_Q(agent_QUEUE * AQ, char *name) { agent_ATOM AA; extern char *everyone; if(AA = search_agent_Q(AQ, everyone)) DELETE_agent_ATOM(AQ, AA); if (!(AA = search_agent_Q(AQ, name))) { AA = emalloc(sizeof(agent_QUEUE)); AA->obj.name = emalloc(strlen(name)+1); strcpy(AA->obj.name, name); AA->prev = (agent_QUEUE *) 0; AA->next = (agent_QUEUE *) 0; INSERT_Q(AQ, AA); } } agent_ATOM search_agent_Q(agent_QUEUE * AQ, char *name) { agent_ATOM Q; FOREACH(Q, AQ) { if (Q->obj.name == (char *) 0) break; if (streq(Q->obj.name, name)) return Q ; } return (agent_ATOM) 0; } void delete_agent_Q(agent_QUEUE * AQ, char *name, char *ObsName) { agent_ATOM Q; symptr sp; extern char *everyone; Q=search_agent_Q(AQ, name); if (Q) DELETE_agent_ATOM(AQ, Q); if (sp = lookup(ObsName)) { if (Q_EMPTY(AQ) && search_agent_Q(&sp->StateOf, everyone)) add_agent_Q(AQ, everyone); } } #endif /* DISTRIB */ /*-------------------------------------------------------------------- LOCAL VARIABLE LOOK UP --------------------------------------------------------------------*/ struct entry { char *name; short level; short num; }; typedef struct entry entry; #define streq(X,Y) (strcmp(X,Y)==0) #define EQUAL_entry(A,B) streq(A.name,B.name) #define FREE_entry(A) if(A.name)free(A.name) #include "entry.q.c" static entry_QUEUE LocalVarList = EMPTYQUEUE(LocalVarList); /* * look up the position of local variable * 0 = not in LocalVarList */ entry_ATOM search_local(char *name) { entry_ATOM A; FOREACH(A, &LocalVarList) { if (A->obj.name == (char *) 0) break; /* printf("search %s %s %i %i\n", A->obj.name, name, A->obj.level, A->obj.num); */ if (streq(A->obj.name, name)) /* match */ return A; } return (entry_ATOM) 0; } /* * add a local variable to the list * return the entry of the list */ entry_ATOM add_local_variable(char *name) { entry_ATOM E; entry_ATOM F; F = FRONT(&LocalVarList); E = emalloc(sizeof(entry_QUEUE)); E->obj.name = emalloc(strlen(name) + 1); strcpy(E->obj.name, name); E->obj.level = indef; if (inpara) { E->obj.num = F->obj.num - 1; } else { /* inauto */ if (F->obj.num < 0) E->obj.num = 1; else E->obj.num = F->obj.num + 1; } E->prev = (entry_QUEUE *) 0; E->next = (entry_QUEUE *) 0; INSERT_Q(&LocalVarList, E); return FRONT(&LocalVarList); } /* * insert a level marker */ void insert_level_marker(int level) { entry E; E.name = (char *) 0; E.level = level; E.num = 0; INSERT_entry_Q(&LocalVarList, E); } /* * initialist the LocalVarList */ void init_LocalVarList(void) { CLEAN_Q(&LocalVarList); insert_level_marker(0); } /* delete all entry not smaller than the level */ void delete_local_level(int level) { entry_ATOM E; entry_QUEUE *Q = &LocalVarList; for (E = FRONT(Q); E->obj.level >= level; E = FRONT(Q)) DELETE_FRONT_entry(Q); } void printlocal(void) { entry_ATOM E; FOREACH(E, &LocalVarList) printf("%s %d %d\n", E->obj.name ? E->obj.name : "*", E->obj.level, E->obj.num); } int local_declare(char *name) { entry_ATOM E; if (search_local(name)) error2("redeclare local variable:", name); E = add_local_variable(name); return E->obj.num; } int lookup_local(char *name) { entry_ATOM E; if ((E = search_local(name))) { if (E->obj.level != indef) error2("local variable is not in this level:", name); return E->obj.num; } else return 0; } symptr_QUEUE break_q = EMPTYQUEUE(break_q); symptr_QUEUE cont_q = EMPTYQUEUE(cont_q); void dispatch(Inst * p, symptr_QUEUE * Q) { APPEND_symptr_Q(Q, (symptr) p); } void patch(Inst * mark, Inst * p, symptr_QUEUE * Q) { symptr_ATOM A; Inst *ip; while ((A = LAST(Q))) { ip = (Inst *) A->obj; DELETE_symptr_ATOM(Q, A); if (ip == mark) return; ip[1] = (Inst) (p - (ip + 2)); } /* should not get here */ error("compiler error while patching code"); } tkeden1.18/Eden/screen.q.h010060000025250000147000000014420731247275200166230ustar00ashleydcsother00003470000356/* * $Id: screen.q.h,v 1.2 1999/11/16 21:20:40 ashley Rel1.10 $ */ #include "global.q.h" typedef struct intQ { struct intQ *prev; struct intQ *next; int obj; } intQ; typedef struct { int ref; int nbox; } winfo; typedef struct ScoutScreen { char *name; Datum oScreen; winfo *oWinInfo; int MaxRef; intQ *Refer; } ScoutScreen; typedef struct ScoutScreenQ { struct ScoutScreenQ *prev; struct ScoutScreenQ *next; ScoutScreen obj; } ScoutScreenQ; typedef ScoutScreenQ *ScoutScreen_ATOM; #ifndef NEW_ScoutScreen #define NEW_ScoutScreen(OBJ) OBJ #endif #define INSERT_ScoutScreen_Q(Q,OBJ) \ { \ ScoutScreen_ATOM A; \ ALLOC_ATOM(A); \ A->obj = NEW_ScoutScreen(OBJ); \ INSERT_Q(Q,A); \ } tkeden1.18/Eden/screen.q.c010060000025250000147000000017000731566613400166150ustar00ashleydcsother00003470000356/* * $Id: screen.q.c,v 1.5 1999/11/16 21:20:40 ashley Rel1.10 $ */ static char rcsid2[] = "$Id: screen.q.c,v 1.5 1999/11/16 21:20:40 ashley Rel1.10 $"; void init_ScoutScreenList(void) { CLEAN_Q(&ScoutScreenList); } ScoutScreen_ATOM search_ScoutScreenQ(char *name) { ScoutScreen_ATOM A; FOREACH(A, &ScoutScreenList) { if (A->obj.name == (char *) 0) break; if (streq(A->obj.name, name)) /* match */ return A; } return (ScoutScreen_ATOM) 0; } ScoutScreen_ATOM add_ScoutScreen(char *name) { ScoutScreen E; ScoutScreen_ATOM F; makearr(0); /* used to make a null datum --sun */ F = FRONT(&ScoutScreenList); E.name = emalloc(strlen(name) + 1); strcpy(E.name, name); E.oScreen = newdatum(pop()); E.oWinInfo = 0; E.MaxRef = 1; E.Refer = (intQ *) emalloc(sizeof(intQ)); CLEAN_Q(E.Refer); INSERT_ScoutScreen_Q(&ScoutScreenList, E); return FRONT(&ScoutScreenList); } tkeden1.18/Eden/runset.h010060000025250000147000000011010727406555000164160ustar00ashleydcsother00003470000356/* * $Id: runset.h,v 1.4 1999/11/16 21:20:40 ashley Rel1.10 $ */ typedef struct Action { char *s; char *master; struct Action *next; } Action; typedef struct RunSet { int nitems; struct Action *head; struct Action *tail; } RunSet; extern void initRunSet(RunSet *); extern void clearRunSet(RunSet *); extern Action getAction(RunSet *); extern void rmAction(RunSet *); extern void addAction(RunSet *, char *, char *); #ifdef DEBUG extern void printRunSet(RunSet *); #endif extern void queue(char *, char *); tkeden1.18/Eden/runset.c010060000025250000147000000031300731245753200164130ustar00ashleydcsother00003470000356/* * $Id: runset.c,v 1.7 1999/11/16 21:20:40 ashley Rel1.10 $ */ static char rcsid[] = "$Id: runset.c,v 1.7 1999/11/16 21:20:40 ashley Rel1.10 $"; #include #include #include "../config.h" #include "runset.h" #include "eden.h" #include "emalloc.h" #ifdef HAVE_DMALLOC #include #endif void initRunSet(RunSet * rs) { rs->nitems = 0; rs->head = rs->tail = (Action *) emalloc(sizeof(Action)); rs->tail->s = 0; rs->tail->master = 0; rs->tail->next = 0; } void clearRunSet(RunSet * rs) { while (rs->nitems) rmAction(rs); } Action getAction(RunSet * rs) { Action *ptr = rs->head->next; Action a; a.s = ptr->s; a.master = ptr->master; rs->head->next = rs->head->next->next; free(ptr); rs->nitems--; if (rs->nitems == 0) rs->tail = rs->head; return a; } void rmAction(RunSet * rs) { Action *ptr = rs->head->next; free(ptr->s); rs->head->next = rs->head->next->next; free(ptr); rs->nitems--; if (rs->nitems == 0) rs->tail = rs->head; } void addAction(RunSet * rs, char *s, char *master) { rs->tail->next = (Action *) malloc(sizeof(Action)); rs->tail = rs->tail->next; rs->tail->s = strdup(s); rs->tail->master = master; rs->tail->next = 0; rs->nitems++; } #ifdef DEBUG /* for debugging purpose */ #include void printRunSet(RunSet * rs) { Action *ptr; fprintf(stderr, "*** Current RunSet\n"); for (ptr = rs->head->next; ptr; ptr = ptr->next) { fprintf(stderr, "%s\n", ptr->s); } fprintf(stderr, "*** End RunSet\n"); } #endif tkeden1.18/Eden/refer.c010060000025250000147000000210430731245720600161770ustar00ashleydcsother00003470000356/* * $Id: refer.c,v 1.7 1999/11/16 21:20:40 ashley Rel1.10 $ */ static char rcsid[] = "$Id: refer.c,v 1.7 1999/11/16 21:20:40 ashley Rel1.10 $"; /**** * REFERENCE LIST MAINTAINER * ****/ #include #include "../config.h" #include "eden.h" #include "yacc.h" #include "emalloc.h" #ifdef HAVE_DMALLOC #include #endif symptr_QUEUE IDlist = EMPTYQUEUE(IDlist); symptr_QUEUE *lastNullInIDlist = &IDlist; Int *autocalc; #ifdef DEBUG #define DEBUGPRINT(X,Y) if (Debug&1) { fprintf(stderr, X, Y); } #else #define DEBUGPRINT(X,Y) #endif #ifdef DEBUG void printlist(symptr_QUEUE * Q) { /* INTERNAL: PRINT A DEPENDENCY LIST */ /* USED FOR DEBUGGING ONLY */ register symptr_ATOM P; FOREACH(P, Q) fprintf(stderr, " %s", P->obj ? P->obj->name : "*"); printf("\n"); } #endif /* DEBUG */ void addID(symptr id) { /* INTERNAL: ADD AN IDENTIFIER USED BY PARSER */ /* Original code here was: if (!id || !IN_symptr_Q(&IDlist, id)) APPEND_symptr_Q(&IDlist, id); When all the macros are expanded, this looks like: if (!id || !SEARCH_symptr(&IDlist, id, 1)) { symptr_ATOM A; A = emalloc(sizeof(*A)); A->obj = NEW_symptr(id); ((A)->prev=((A)->next=(&IDlist))->prev)->next=(A); (&IDlist)->prev=(A); } ... which implements the following: append the id to the IDlist, unless it is non-zero and we already have an occurrance of it in the list. (Ie we can have multiple nulls within the list, but no multiple occurrances of actual ids). Notice the OR used in the if, not an AND: id==0, idinQ -> T || F -> T (append) id==0, !idinQ -> T || T -> T (append) id!=0, idinQ -> F || F -> F (don't append) id!=0, !idinQ -> F || T -> T (append) ('clever' but highly confusing code as it is searching for one significant case which might be better done using an AND). This 'clever' coding is unfortunately incorrect. addID / IDlist is actually used by the parser to maintain lists of identifiers for three separate purposes: within 'is' formulae definitions, within proc/func/procmacro action definitions, and within ~> related_by definitions. It appears (as the code documentation is lacking) that the removal of multiple occurrances of ids is intended to stop multiple triggering (eg proc p : a, a... or p is a+a leading to [a,a] triggers). However, we are now discovering that these three purposes are not separate: when an 'is' formula redefinition is made within a triggered action, the removal of multiple occurrances of ids can cause a problem. What I believe this function should really implement is a queue of ids which are unique between nulls. Eg b * a b * b is allowed, but b * a b b * b is not. [Ash] */ if (id == (symptr)0) { /* A null (list terminator): add it */ APPEND_symptr_Q(&IDlist, id); lastNullInIDlist = LAST(&IDlist); DEBUGPRINT("addID: id=* ", 0); } else { /* An id: add it only if it is unique since the last null */ symptr_QUEUE *P; int n = 0; P = FRONT(lastNullInIDlist); while (P && ((P->obj) != (symptr)0) && (P != &IDlist)) { if (EQUAL_symptr(id, P->obj)) n++; P = NEXT(lastNullInIDlist, P); } if (n < 1) { /* This is an id which we haven't seen since the last null */ APPEND_symptr_Q(&IDlist, id); DEBUGPRINT("addID: id=%s ", id->name); #ifdef DEBUG } else { /* We've seen this id more than once */ DEBUGPRINT("addID: not adding id=%s ", id->name); #endif } } #ifdef DEBUG if (Debug&1) { fprintf(stderr, "IDlist now"); printlist(&IDlist); } #endif } void clear_IDlist(void) { CLEAR_symptr_Q(&IDlist); lastNullInIDlist = &IDlist; } /* save_IDlist: this seems to work through the items added by addID to IDlist, saving them in newly malloc'd memory (well, the first item is newly malloc'd), re-linking them as we go, stopping when we find a queued item whose obj is null. A pointer to the new queue is returned. This is used by functions in code.c which code redefinitions (is formulae and proc/func/procmacro actions) and the related_by operator ~>. [Ash] */ symptr_QUEUE * save_IDlist(void) { register symptr_ATOM A; register symptr_QUEUE *P, *Q; P = &IDlist; Q = (symptr_QUEUE *) emalloc(sizeof(symptr_QUEUE)); CLEAN_Q(Q); while ((A = LAST(P))) { DELETE_ATOM(P, A); if (A->obj == (symptr) 0) { DESTROY_symptr_ATOM(A); break; } INSERT_Q(Q, A); } lastNullInIDlist = &IDlist; return Q; } /* refer_to(): pass this a symbol and its sources. This seems to update information in sp and the Q with the information that sp has Q has its sources. [Ash] */ void refer_to(symptr sp, symptr_QUEUE * Q) { /* INTERNAL: APPEND SYMBOL TO SOURCES */ register symptr_ATOM Symbol; register symptr_QUEUE *SourceTargets, *Sources; /* I don't understand this code at all well, so my explanatory comments may be totally wrong :( [Ash] */ #ifdef DEBUG if (Debug&1) { fprintf(stderr, "refer_to: sp=%s, Q=", sp->name); printlist(Q); } #endif /* Find the symbol's existing list of sources */ Sources = &sp->sources; /* Remove any existing target pointers to this symbol */ FOREACH(Symbol, Sources) { SourceTargets = &Symbol->obj->targets; DELETE_FIRST_symptr(SourceTargets, sp); } /* Now remove any existing list of sources from this symbol */ CLEAR_symptr_Q(Sources); /* Add the sources passed here (Q) as a parameter to this symbol (sp) */ FOREACH(Symbol, Q) { APPEND_symptr_Q(Sources, Symbol->obj); } /* Make the target pointers of the sources passed here (Q) point to this symbol (sp) */ FOREACH(Symbol, Sources) { SourceTargets = &Symbol->obj->targets; APPEND_symptr_Q(SourceTargets, sp); } } void refer_by(symptr sp, symptr_QUEUE * Q) { /* INTERNAL: APPEND SYMBOL TO TARGETS */ register symptr id; register symptr_ATOM Symbol; register symptr_QUEUE *Targets, *Sources; FOREACH(Symbol, Q) { id = Symbol->obj; Sources = &id->sources; DELETE_FIRST_symptr(Sources, sp); APPEND_symptr_Q(Sources, sp); Targets = &sp->targets; DELETE_FIRST_symptr(Targets, id); APPEND_symptr_Q(Targets, id); } } /* checkok1 is used by checkok below [Ash] */ int checkok1(symptr sp, symptr_QUEUE * Q) { /* INTERNAL: IF SYMBOL IN THE LIST ? */ /* TRUE = 1 = NOT IN THE LIST */ /* FALSE = 0 = ALREADY EXISTED */ register symptr id; register symptr_ATOM P; FOREACH(P, Q) { id = P->obj; if (id->marked) continue; id->marked = 1; if (id == sp) return FALSE; if (!checkok1(sp, &id->sources)) return FALSE; } return TRUE; } /* checkok2 is used by checkok below [Ash] */ int checkok2(symptr sp, symptr_QUEUE * Q) { /* INTERNAL: IF SYMBOL IN THE LIST ? */ /* TRUE = 1 = NOT IN THE LIST */ /* FALSE = 0 = ALREADY EXISTED */ register symptr id; register symptr_ATOM P; FOREACH(P, Q) { id = P->obj; if (!id->marked) continue; id->marked = 0; if (id == sp) return FALSE; if (!checkok2(sp, &id->sources)) return FALSE; } return TRUE; } /* checkok() checks for an attempt to introduce a cyclic definition. It checks that the sp (the symbol we are about to introduce) is not referenced by any items in Q (the sources of the symbol we are about to introduce), or any of Q's sources. Looks like it uses a kind of mark/sweep algorithm: mark each object as we look at it. If we've seen it before, ignore it, else check it and all its sources for equality with sp. When we've found a result one way or the other, do the search again, removing the marks we made along the way. [Ash] */ int checkok(symptr sp, symptr_QUEUE * Q) { /* INTERNAL: IF SYMBOL IN THE LIST ? */ /* TRUE = 1 = NOT IN THE LIST */ /* FALSE = 0 = ALREADY EXISTED */ int result = checkok1(sp, Q); checkok2(sp, Q); /* clear the markings by checkok1() */ return result; } /* ready() is used during evaluation. It checks the sources of a symbol to see if they are marked as having been changed (in which case the symbol cannot be evaluated yet). [Ash] */ int ready(symptr sp) { /* INTERNAL: CHECK CHILDREN OF SYMBOL */ /* TRUE = ALL CHILDREN ARE UP-TO-DATE */ register symptr_ATOM P; register symptr_QUEUE *Q; Q = &sp->sources; FOREACH(P, Q) { if (P->obj->changed) return FALSE; } return TRUE; } GPRINT("addID: id=* ", 0); } else { /* An id: add it only if it is unique since the last null */ symptr_QUEUE *P; int n = 0; P = FRONT(lastNullInIDlist); while (P && ((P->obj) != (symptr)0) && (P != &IDlist)) { if (EQUAL_symptr(id, P->obj)) n++; P = NEXT(lastNullInIDlist, P); } if (n < 1) { /* This is an id which we haven't seen since the last null */ APPEND_symptr_Q(&IDlist, id); DEBUGPRINT("addID: id=%s ", idtkeden1.18/Eden/notation.h010060000025250000147000000005610727406555000167420ustar00ashleydcsother00003470000356/* * $Id: notation.h,v 1.7 2000/08/31 14:49:18 ashley Rel1.10 $ */ typedef enum { INTERNAL, EDEN, SCOUT, DONALD, ARCA #ifdef WANT_SASAMI , SASAMI #endif /* WANT_SASAMI */ #ifdef DISTRIB ,LSD #endif } notationType; extern notationType currentNotation; void changeNotation(notationType); void setprompt(void); void evaluate(char *, char *); tkeden1.18/Eden/Makefile.in010060000025250000147000000004520730547032200167720ustar00ashleydcsother00003470000356# # $Id: Makefile.in,v 1.11 1999/12/23 21:24:12 ashley Rel1.10 $ # PARSER_SOURCE = yacc.y PARSER_OUT = yacc.c PARSER_HEADERS_OUT = yacc.h SOURCES = builtin.c code.c eval.c heap.c global.q.c lex.c lib.c machine.c \ main.c refer.c runset.c symbol.c type.c LIB = libeden.a include ../generic.mk tkeden1.18/Eden/main.c010060000025250000147000001075030731646235400160320ustar00ashleydcsother00003470000356/* * $Id: main.c,v 1.43 2001/04/04 19:38:00 cssbz Exp $ */ static char rcsid[] = "$Id: main.c,v 1.43 2001/04/04 19:38:00 cssbz Exp $"; #ifndef __WIN32__ # if defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__) # define __WIN32__ # endif #endif #include "../config.h" #include #include #include #include #include #include #include #include #include #include /* for getcwd() and gethostname() for DISTRIB [Ash] */ #include /* for PATH_MAX */ #ifdef DISTRIB #include /* for MAXHOSTNAMELEN on Solaris [Ash] */ #include /* for MAXHOSTNAMELEN on Linux [Ash] */ #endif #include "../version.h" #include "emalloc.h" #ifdef HAVE_DMALLOC #include #endif /* From Autoconf manual [Ash] */ # if TIME_WITH_SYS_TIME # include # include # else # if HAVE_SYS_TIME_H # include # else # include # endif # endif #include "eden.h" #include "yacc.h" #include "builtin.h" #include "runset.h" #include "../Misc/custom.h" #ifndef TTYEDEN #include /* Tcl caches environment variables: so we must use Tcl's versions of the getenv and putenv functions [Ash] */ /* Tcl 8.2.0 Makefile implies don't use the Tcl getenv [Ash] */ #define putenv Tcl_PutEnv #define setenv TclSetEnv #define unsetenv TclUnsetEnv #include extern Tcl_Interp *interp; extern void EXinitTcl(void); char *libLocation; /* Location of Eden and Tcl library files - this replaces the use of the PUBLIC environment variable [Ash] */ int libLocationAllocd = 0; /* whether space has been allocated for libLocation yet or not [Ash] */ #endif char *progname; jmp_buf start; char **gargv; /* global argument list */ int gargc; Int *autocalc; Int *eden_error_index_range; /* enable / disable errors on encountering list or string references that are out of range [Ash] */ Int *eden_notice_undef_reference; /* enable / disable warning notices when making references to variables that are undefined [Ash] */ int interrupted = 0; #ifdef DISTRIB int socketPort = 9000; /* for distributed Tkeden --sun */ char hostName[MAXHOSTNAMELEN]; char *hostNamePtr = 0; char *everyone = "EVERYONE"; Int *synchronize; /* connecting with Tcl/Tk to handle synchronized communication */ Int *EveryOneAllowed; /* to handle agency of an observable with a positive way, i.e. allowing every agent has agency when no listed name, or a negative way, i.e. allowing every agent has no agency when no listed name. */ Int *higherPriority; /* to handle execusively running a runset without any new running runset, i.e. all actions in queue will not be put into runset before current runset is finished --sun. Patrick confesses to this not working very well, which is why it is left undocumented ;) [Ash, with Patrick] */ Int *propagateType; /* to handle scripts' distributed propagation */ int isServer = 1; #endif /* DISTRIB */ #include "input_device.h" struct input_device *Inp_Dev = Input_Devices; struct input_device *Inp_Dev_Save = 0; /* work around bug in gcc - see below [Ash] */ /* function prototypes */ #ifdef TTYEDEN char *prompt1 = ":> "; /* Usual prompt [Ash] */ char *prompt2 = "+> "; /* Prompt used when the input line is not yet complete (eg no semi-colon yet) [Ash] */ char *prompt; int interactive = TRUE; /* ttyeden: print prompts or not [Ash] */ int preprinted = FALSE; int nlstts = TRUE; /* newline status? [Ash] */ /* nlstatus: update nlstts from Inp_Dev [Ash] */ void nlstatus(void) { nlstts = Inp_Dev->newline; } void print_prompt(void) { #if !defined(HAVE_READLINE) if (interactive) fprintf(stderr, "%d%s", Inp_Dev->lineno + 1, prompt); #endif } #else /* not TTYEDEN */ int eden_interrupt_handler(ClientData, Tcl_Interp *, int, char *[]); #endif int wouldBlock(void) { fd_set fdset; int fd = fileno((FILE *) (Inp_Dev->ptr)); struct timeval timeout; timeout.tv_sec = timeout.tv_usec = 0; FD_ZERO(&fdset); FD_SET(fd, &fdset); return select(FD_SETSIZE, &fdset, 0, 0, &timeout) <= 0; } int run(short, void *, char *); void pushEntryStack(int); void popEntryStack(void); void clearEntryStack(void); int topEntryStack(void); void pushMasterStack(char *); void popMasterStack(void); void clearMasterStack(void); char *topMasterStack(void); void warning(char *, char *); void yyerror(char *); void init(void); void terminate(int); void run_init(Inst *); void user_trace(void); #ifdef TTYEDEN void checkRunSet(void); #else void checkRunSet(ClientData); #endif void queue(char *, char *); int main(int, char *[]); /* change type from void to int due to gcc 2.8.1 */ static int entryStackSize = 0; static int TopEntryStack = 0; static int *EntryStack; void pushEntryStack(int m) { if (entryStackSize == 0) { entryStackSize = 16; EntryStack = (int *) emalloc(sizeof(int) * entryStackSize); } else if (TopEntryStack == entryStackSize) { entryStackSize += 16; EntryStack = (int *) erealloc(EntryStack, sizeof(int) * entryStackSize); } EntryStack[TopEntryStack++] = m; } void popEntryStack(void) { if (--TopEntryStack < 0) TopEntryStack = 0; } void clearEntryStack(void) { TopEntryStack = 0; pushEntryStack(0); } int topEntryStack(void) { return EntryStack[TopEntryStack - 1]; } static int masterStackSize = 0; static int TopMasterStack = 0; static char **MasterStack; void pushMasterStack(char *m) { if (masterStackSize == 0) { /* agent names can be maximum 16 chars in length [Ash] */ masterStackSize = 16; MasterStack = (char **) emalloc(sizeof(char *) * masterStackSize); } else if (TopMasterStack == masterStackSize) { masterStackSize += 16; MasterStack = (char **) erealloc(MasterStack, sizeof(char *) * masterStackSize); } MasterStack[TopMasterStack++] = m; } /* !@!@ I think popMasterStack and clearMasterStack should free the associated memory [Ash] */ void popMasterStack(void) { if (--TopMasterStack < 0) TopMasterStack = 0; } void clearMasterStack(void) { TopMasterStack = 0; } char * topMasterStack(void) { return MasterStack[TopMasterStack - 1]; } #ifdef DEBUG #define DEBUGPRINT(s,i) if (Debug & 1) fprintf(stderr,s,i); #else #define DEBUGPRINT(s,i) #endif static time_t lastBeepTime = 0; static void setTimer(time_t * t) { time(t); } static char timedEventsEnabled(time_t * t) { return (time(NULL) > (*t + 3)); } #ifndef TTYEDEN #define msgHeader() Tcl_Eval(interp, "appendHist {/*** }") static void historyRaiseAndBeep(void) { Tcl_Eval(interp, "set showhist 1"); Tcl_Eval(interp, "show hist 1"); Tcl_Eval(interp, "raise .hist"); /* Stop rapid beeping: only beep if we haven't done so for a while [Ash] */ if (timedEventsEnabled(&lastBeepTime)) { Tcl_Eval(interp, "bell"); setTimer(&lastBeepTime); } Tcl_Eval(interp, "update"); } static void msgTrailer(void) { Tcl_Eval(interp, "appendHist { ***/\n}"); historyRaiseAndBeep(); } void msgContent(char *s, char *t, int newline) { Tcl_DString err, message; Tcl_DStringInit(&err); Tcl_DStringInit(&message); Tcl_DStringAppend(&message, s, -1); if (t) Tcl_DStringAppend(&message, t, -1); if (newline) Tcl_DStringAppend(&message, "\n", -1); Tcl_DStringAppendElement(&err, "appendHist"); Tcl_DStringAppendElement(&err, message.string); Tcl_Eval(interp, err.string); Tcl_DStringFree(&err); Tcl_DStringFree(&message); } /* printf style msgContent */ void msgContentf(char *fmt, ...) { char errorsbuf[MAXBUF]; /* to hold the individual line causing the error */ va_list argp; va_start(argp, fmt); vsnprintf(errorsbuf, sizeof(errorsbuf), fmt, argp); va_end(argp); msgContent(errorsbuf, "", 0); /* no \n: can add that in fmt if necessary */ } #endif /* not TTYEDEN */ #ifdef TTYEDEN /* printf style msgContent */ void msgContentf(char *fmt, ...) { va_list argp; va_start(argp, fmt); vfprintf(stderr, fmt, argp); va_end(argp); } #endif /* TTYEDEN */ void noticef(char *fmt, ...) { va_list argp; char errorsbuf[MAXBUF]; #ifdef TTYEDEN fprintf(stderr, "%s: notice: ", progname); va_start(argp, fmt); vfprintf(stderr, fmt, argp); va_end(argp); if (fp != Inp_Dev->frame) { fprintf(stderr, " in %s%s", fp->master ? "action " : "", fp->master ? fp->master : fp->sp->name); } fprintf(stderr, "\n"); #else msgHeader(); va_start(argp, fmt); vsnprintf(errorsbuf, sizeof(errorsbuf), fmt, argp); va_end(argp); msgContentf("notice: %s", errorsbuf); if (fp != Inp_Dev->frame) { msgContentf(" in %s%s", fp->master ? "action " : "", fp->master ? fp->master : fp->sp->name); } msgContentf("\n"); historyRaiseAndBeep(); printf("%s: notice: %s\n", progname, errorsbuf); #endif } void warning(char *s, char *t) { /* print warning message */ #ifdef TTYEDEN fprintf(stderr, "%s: warning: %s%s\n", progname, s ? s : "", t ? t : ""); #else msgHeader(); /* msgContent(progname, ": ", 0); */ msgContentf("warning: %s%s\n", s, t); msgTrailer(); fprintf(stderr, "%s: warning: %s%s\n", progname, s ? s : "", t ? t : ""); #endif } /* Print error message and skip the rest of the input. Call this with printf style arguments */ void errorf(char *fmt, ...) { extern void ret_call(void); extern void reset_pseudo_machine_status(void); extern void reset_compiler_status(void); extern void freeheap(void); extern void flushRestOfLine(void); extern int nextc; int ntmp, i; char *stmp, *stmpout; char errorsbuf[MAXBUF]; /* to hold the individual line causing the error */ va_list argp; #ifdef TTYEDEN fprintf(stderr, "%s: error: ", progname); va_start(argp, fmt); vfprintf(stderr, fmt, argp); va_end(argp); #else /* must make our own copy of the error first (especially in the case of errors from Tcl_EvalEC, where a call to msgHeader here would overwrite the error information) [Ash] */ va_start(argp, fmt); vsnprintf(errorsbuf, sizeof(errorsbuf), fmt, argp); va_end(argp); /* careful: we can't use Tcl_EvalEC as if the error was generated there, it would cause re-entrancy [Ash] */ msgHeader(); msgContentf("error: %s", errorsbuf); #endif /* slurp the rest of the line into Inp_Dev->linebuf so it shows in the error message */ flushRestOfLine(); if (Inp_Dev != Input_Devices) { /* show error messages */ /* while (fp != Inp_Dev->frame) { */ while (fp > Inp_Dev->frame) { /* free the memory for frame */ if (fp->master) { /* fp->sp->name == fp->master */ msgContentf(" called by action %s\n"); } else { if (fp->sp) { msgContentf(" called by %s\n", fp->sp->name); } } ret_call(); } #ifdef TTYEDEN if (Inp_Dev->type == FILE_DEV) { if (Inp_Dev->name) fprintf(stderr, " while executing file %s", Inp_Dev->name); else fprintf(stderr, " while executing stdin"); } else { fprintf(stderr, " while executing string"); } fprintf(stderr, " near line %d, char %d:\n", Inp_Dev->lineno, Inp_Dev->charno-1); fprintf(stderr, "%s\n", Inp_Dev->linebuf); for (i = 2; i < Inp_Dev->charno; i++) fprintf(stderr, " "); fprintf(stderr, "^\n"); #else /* not TTYEDEN */ if (Inp_Dev->type == FILE_DEV) { msgContent(" while executing file ", Inp_Dev->name, 0); } else { msgContentf(" while executing string"); } msgContentf(" near line %d, char %d:\n", Inp_Dev->lineno, Inp_Dev->charno); msgContentf("%s\n", Inp_Dev->linebuf); for (i = 2; i < Inp_Dev->charno; i++) msgContentf(" "); msgContentf("^\n"); #endif switch (Inp_Dev->type) { case FILE_DEV: /* flush rest of file */ fseek((FILE *) Inp_Dev->ptr, 0L, 2); break; case STRING_DEV: /* empty the string */ *Inp_Dev->ptr = '\0'; break; } nextc = 0; /* EOF */ Inp_Dev->charno = 0; Inp_Dev->linebuf[0] = '\0'; freeheap(); } reset_pseudo_machine_status(); /* except the frames */ reset_compiler_status(); #ifdef TTYEDEN prompt = prompt1; #else msgTrailer(); #endif /* Work around bug in gcc - see this being used in run [Ash] */ Inp_Dev_Save = Inp_Dev; /* Jump to resume. The execution will jump to the last matching call to setjmp (either to the last setjmp(start) or setjmp(Inp_Dev->begin), depending on the value of Inp_Dev), as if it is a return from that call. setjmp returns the last parameter given here, 1. [Ash] */ longjmp((Inp_Dev == Input_Devices ? start : Inp_Dev->begin), 1); } void yyerror(char *s) { /* report compile-time error */ error(s); } #ifndef TTYEDEN /* This is the implementation for the new Tcl "interrupt" command, which is called when the Interrupt button is pressed... [Ash] */ int eden_interrupt_handler(ClientData clientData, Tcl_Interp * interp, int argc, char *argv[]) { interrupted = 1; fprintf(stderr, "%s: interrupt button pressed\n", progname); return TCL_OK; } #endif static time_t lastControlCTime = 0; RETSIGTYPE Control_C(int sig) { /* Two interrupts within three seconds cause the normal behaviour [Ash] */ if (timedEventsEnabled(&lastControlCTime)) { signal(SIGINT, Control_C); setTimer(&lastControlCTime); } else { raise(SIGINT); } interrupted = 1; /* don't use Tcl to give the error message as it might be in a non-re-entrable state (seem to have this problem particularly in Sasami) [Ash] */ fprintf(stderr, "%s: interrupted using control-c: press again within three seconds to quit\n", progname); } static RunSet RS1, RS2; static RunSet *RS; #ifdef TTYEDEN void checkRunSet(void) #else void checkRunSet(ClientData clientData) #endif { Action a; #ifndef TTYEDEN extern void setprompt(void); Tcl_CancelIdleCall(checkRunSet, 0); #endif if (interrupted) { warning("interrupted: clearing both RunSets (current queue and todo)", ""); clearRunSet(&RS1); clearRunSet(&RS2); interrupted = 0; } if (RS->nitems > 0) { /* I guess that run() may put items into the RunSet, so this while loop is necessary [Ash] */ while (RS->nitems > 0) { a = getAction(RS); pushMasterStack(a.master); run(STRING_DEV, a.s, 0); popMasterStack(); free(a.s); } #ifndef TTYEDEN setprompt(); Tcl_DoWhenIdle(checkRunSet, 0); #endif } else { #ifndef TTYEDEN /* normally tk will wait till idle to update, but Eden will check the runset when idle, so the screen will not be updated. So update explicitly here */ Tcl_EvalEC(interp, "update"); #endif /* Swap RunSets */ RS = (RS == &RS1) ? &RS2 : &RS1; #ifdef DEBUG if ((Debug & 2) && RS->nitems > 0) printRunSet(RS); #endif /* DEBUG */ #ifndef TTYEDEN if (RS->nitems > 0) Tcl_DoWhenIdle(checkRunSet, 0); #endif } } /* Add a line of script (cmd) to the active RunSet RS. master is the name of the agent responsible (eg "input", "interface"...). [Ash] */ void queue(char *cmd, char *master) { /* printf("QUEUE %s EOQ \n", cmd); */ addAction((RS == &RS1) ? &RS2 : &RS1, cmd, master); #ifndef TTYEDEN Tcl_DoWhenIdle(checkRunSet, 0); #endif } void init(void) { /* INITIALIZATION */ /* init builtin function, variables, etc */ void install_custom_variables(void); register int i; register symptr s; /* install builtin C library functions */ for (i = 0; blibtbl[i].name; i++) { s = install(blibtbl[i].name, BLTIN, BLTIN, 0); s->inst = (Inst *) blibtbl[i].func; s->d.type = BLTIN; s->d.u.sym = s; } /* install integer C library functions */ for (i = 0; ilibtbl[i].name; i++) { s = install(ilibtbl[i].name, LIB, LIB, 0); s->inst = (Inst *) ilibtbl[i].func; s->d.type = LIB; s->d.u.sym = s; } /* install real (floating-point) C library functions */ for (i = 0; rlibtbl[i].name; i++) { s = install(rlibtbl[i].name, RLIB, RLIB, 0); s->inst = (Inst *) rlibtbl[i].func; s->d.type = RLIB; s->d.u.sym = s; } install_custom_variables(); /* custom-built */ } void terminate(int code) { exit(code); } void run_init(Inst * pc) { /* init before running */ progp = pc; reset_entry_tbl(); reset_compiler_flags(); #ifdef TTYEDEN prompt = prompt1; #endif } int run(short type, void *ptr, char *name) { /* RUN A PROGRAM */ /* type - SOURCE TYPE: FILE_DEV/STRING_DEV (note stdin is a file [Ash])*/ /* ptr - FILE POINTER / STRING_DEV */ /* name - FILE NAME (IF ANY) */ /* EXECUTE UNTIL EOF OR ERROR OCCURRED */ char errorflag = FALSE; Inst *savepc = progp; int token; extern int nextc; extern void init_lex(void), execute(Inst *); extern void incGarbageLevel(void), decGarbageLevel(void); extern void clearGarbage(void); #ifdef DEBUG #define INITPTRSTUFFLEN 30 /* for printing out the initial part of ptr in debugging output [Ash] */ char initPtrStuff[INITPTRSTUFFLEN+1]; #endif /* It is good to use our custom bison.simple if we can. Eden doesn't apparently seem to need to token-at-a-time parsing (indeed, I've had to modify things to make Eden work with this style of parser), but I'm hoping that this might solve the problems we've had recently with user input being locked out on occasion. We also benefit from my modification to bison.simple which prints out information after a parse error, even if there are many possibilities to show. I've made my modifications here a conditional compile as I'm not sure I've got it right! [Ash] */ #define USE_CUSTOM_BISON_SIMPLE 1 #ifdef USE_CUSTOM_BISON_SIMPLE extern int yyparse(int); extern int yylex(void); extern void setyyparseinit(int); int parseret; #else extern int yyparse(void); #endif Inp_Dev++; Inp_Dev->frame = fp; Inp_Dev->name = name; switch (Inp_Dev->type = type) { case FILE_DEV: Inp_Dev->ptr = ptr; Inp_Dev->sptr = Inp_Dev->sbuf; break; case STRING_DEV: Inp_Dev->sptr = (char *) emalloc(strlen(ptr) + 1); strcpy(Inp_Dev->sptr, ptr); Inp_Dev->ptr = Inp_Dev->sptr; break; } Inp_Dev->newline = TRUE; #ifdef TTYEDEN nlstatus(); #endif Inp_Dev->lineno = 0; Inp_Dev->charno = 0; Inp_Dev->linebuf[0] = '\0'; Inp_Dev->lastc = nextc; #ifdef DEBUG if (Debug&1) { if (type == STRING_DEV) { char *p; int n; for (p = ptr, n = 0; isprint(*p) && n<(INITPTRSTUFFLEN-3); p++, n++) initPtrStuff[n] = *p; initPtrStuff[n] = '\0'; if ((n == INITPTRSTUFFLEN-3) || (*p != '\0')) strcat(initPtrStuff, "..."); } fprintf(stderr, "MCSTAT run: %s %s%s%s Inp_Dev level: %d\n", type == FILE_DEV ? "FILE_DEV" : "STRING_DEV", name ? name : "", name ? " " : "", type == STRING_DEV ? initPtrStuff : "", Inp_Dev - Input_Devices); } #endif /* A matching call of longjmp(Inp_Dev->begin, val) will cause execution to jump to here. errorflag will be set to the val passed above. (K+R C, second edition, page 254). [Ash] */ errorflag = setjmp(Inp_Dev->begin); init_lex(); /* reads in one character. However I think UNIX blocks until a complete line has been read in the case of ttyeden [Ash] */ run_init(savepc); incGarbageLevel(); #ifdef TTYEDEN /* There seems to be a strange bug in gcc. Under some (quite normal) circumstances, when compiled with -O2, gcc seems to optimise away Inp_Dev, leaving it = 0 at this point after the longjmp to the setjmp above. Unfortunately gdb seems to lie about this - the value of 0 can only be seen by observing the Seg fault that results and by manually inserting printfs below. Working around it by setting it back to what it was before the longjmp here. [Ash] */ //fprintf(stderr, "Inp_Dev = %d\n", Inp_Dev); if (errorflag) Inp_Dev = Inp_Dev_Save; /* work around bug in gcc [Ash] */ //fprintf(stderr, "Inp_Dev = %d\n", Inp_Dev); if (Inp_Dev->newline && Inp_Dev->type == FILE_DEV && (FILE *) Inp_Dev->ptr == stdin && !preprinted) { preprinted = TRUE; print_prompt(); } #endif #ifdef USE_CUSTOM_BISON_SIMPLE while (!interrupted) { setyyparseinit(1); /* re-initialise the parser */ while (!interrupted) { token = yylex(); DEBUGPRINT("PARSER yylex() returned %d\n", token); if (!token) goto postexec; /* same effect as interrupted, but no other effects */ parseret = yyparse(token); DEBUGPRINT("PARSER yyparse() returned %d\n", parseret); if (parseret >= 0) break; } if (interrupted) break; #else while (!interrupted && yyparse()) { #endif execute(savepc); run_init(savepc); clearGarbage(); incGarbageLevel(); #ifdef TTYEDEN if (Inp_Dev->newline && Inp_Dev->type == FILE_DEV && (FILE *) Inp_Dev->ptr == stdin && !preprinted) { preprinted = TRUE; print_prompt(); } if (Inp_Dev->type == FILE_DEV && (FILE *) Inp_Dev->ptr == stdin) do { checkRunSet(); clearGarbage(); incGarbageLevel(); } while (RS->nitems > 0 && wouldBlock()); #endif } postexec: decGarbageLevel(); /* finished, remove the device */ nextc = Inp_Dev->lastc; switch (Inp_Dev->type) { case FILE_DEV: /* close the file, but not stdin */ if ((FILE *) Inp_Dev->ptr != stdin) fclose((FILE *) Inp_Dev->ptr); break; case STRING_DEV: free(Inp_Dev->sptr); break; } --Inp_Dev; /* remove device */ progp = savepc; freeheap(); DEBUGPRINT("MCSTAT run end: Inp_Dev level: %d\n", Inp_Dev - Input_Devices); return errorflag; /* return error flag */ } void user_trace(void) { /* EDEN function */ Frame *p; fprintf(stderr, "\n"); for (p = &frame[1]; p <= fp; p++) fprintf(stderr, p == fp ? "%s\n" : "%s->", p->sp->name); } #ifndef TTYEDEN void setLibLocation(char *location) { char *toPutEnv; char *cwd; if (libLocationAllocd) free(libLocation); libLocation = emalloc(255); libLocationAllocd++; #ifndef __WIN32__ if (location[0] != '/') { /* Location specified as a relative path, so make it absolute by prepending the current working directory */ if ((cwd = getcwd(NULL, PATH_MAX)) == NULL) { perror("Failed to get current working directory"); exit(2); } strcpy(libLocation, cwd); free(cwd); strcat(libLocation, "/"); strcat(libLocation, location); } else { strcpy(libLocation, location); } #else strcpy(libLocation, location); #endif /* Assign the result to an environment variable as well (so it can be used by Tcl) */ toPutEnv = emalloc(255); *toPutEnv = '\0'; strcat(toPutEnv, "TKEDEN_LIB="); strcat(toPutEnv, libLocation); putenv(toPutEnv); /* It appears we must not now free(toPutEnv) [Ash] */ } #endif /* TTYEDEN */ #ifndef streq #define streq(s1,s2) (strcmp(s1,s2)==0) #endif #ifdef DISTRIB void printUsage() { /* DISTRIB */ fprintf(stderr, "Usage: %s [-s|-a] -c -h {-l} {-v|-u} {-e }|{} {-e }|{}...\n", progname); fprintf(stderr, " -s invoke as the server (\"superagent\") -a invoke as a client (\"agent\") -c channel number: 0,1,2,3, ..., 99 -h hostname of the machine running the dtkeden server (only required if running as a client [-a]) -l name of the directory containing the library files -v output version information and exit -u output this usage information and exit -e execute 'code' if file is '-', standard input will be read See %s for more information\n", TKEDEN_WEB_SITE); } #elif defined TTYEDEN void printUsage() { /* TTYEDEN */ fprintf(stderr, "Usage: %s {-l} {-v|-u} {-n|-i} {{-n|-i} }...\n", progname); fprintf(stderr, " -n non-interactive mode (don't print prompts) -i interactive mode (do print prompts) -v output version information and exit -u output this usage information and exit -e execute 'code' if file is '-', standard input will be read See %s for more information\n", TKEDEN_WEB_SITE); } #else /* probably TKEDEN */ void printUsage() { /* TKEDEN */ fprintf(stderr, "Usage: %s {-l} {-v|-u} {-e }|{} {-e }|{}...\n", progname); fprintf(stderr, " -l name of the directory containing the library files -v output version information and exit -u output this usage information and exit -e execute 'code' if file is '-', standard input will be read See %s for more information\n", TKEDEN_WEB_SITE); } #endif /* probably TKEDEN */ /* Print the version number and exit (probably requested to do so via a command line option) [Ash] */ void printVersion(void) { fprintf(stderr, "%s: %s version %s\n", progname, TKEDEN_VARIANT, TKEDEN_VERSION); #ifndef TTYEDEN fprintf(stderr, "Lib directory is %s\n", libLocation ? libLocation : "unknown"); #endif #ifdef DISTRIB fprintf(stderr, "hostName is %s\n", hostName ? hostName : "unknown"); #endif fprintf(stderr, "Use the -u option for information on usage of command options\n"); fprintf(stderr, "See %s for more information\n", TKEDEN_WEB_SITE); exit(0); } #ifdef DISTRIB /* Figure out the name of this host. This is used particularly by a dtkeden client to figure out which host to contact as the server. Note this setting may well be overridden by the user specifying a -h option. [Ash] */ void setHostName(void) { if (gethostname(hostName, MAXHOSTNAMELEN)) { fprintf(stderr, "%s: gethostname failed\n", progname); exit(1); } hostNamePtr = hostName; } #endif #if defined(__WIN32__) && !defined(TTYEDEN) RETSIGTYPE confirmSig(int sig) { signal(sig, SIG_DFL); fprintf(stderr, "Signal %d received - press return to continue\n", sig); getchar(); raise(sig); } #endif /* Create system Eden func and procs. Can't read these from an eden.init.e (say) file as we want these definitions in ttyeden as well, which doesn't require the libLocation setting. [Ash] */ void init_eden(void) { char initStr[] = " func cwd { return _eden_internal_cwd(); } proc cd { _eden_internal_cd($1); touch(&cwd); } dirname is _eden_internal_dirname; basename is _eden_internal_basename; "; run(STRING_DEV, initStr, 0); } int main(int argc, char *argv[]) { /* MAIN PROGRAM */ /* Options processing [Ash] */ char op; /* stores one option returned at a time from getopt [Ash] */ int argerr = 0; /* whether there has been an error during option processing [Ash] */ int usedArg = 1; /* the arguments processed so far - so we can figure out later on how many filenames are on the command line [Ash] */ extern char *optarg; /* getopt sets this when it comes across an option with an argument [Ash] */ extern int optind; /* this is an index into argv set by getopt [Ash] */ extern void initcode(void), init_LocalVarList(void); FILE *filein; char *name; symptr s; #ifdef DISTRIB extern void init_LSDagentList(void); #endif /* DISTRIB */ #ifndef TTYEDEN extern void EXinit(void); extern void init_donald(void), init_scout(void); #ifdef __WIN32__ extern cygwin_conv_to_full_win32_path(const char *path, char *win32_path); char *cwd; char *cwdwin32style; char *toPutEnv; char *passToSetLibLocation; #endif #ifdef WANT_SASAMI extern void sa_init_sasami(); #endif /* WANT_SASAMI */ #endif /* not TTYEDEN */ char edenCmd[PATH_MAX + 100]; #if defined(__WIN32__) && !defined(TTYEDEN) /* Try and give the user a chance to see any fatal error messages before tkeden quits and the DOS stdout/stderr window disappears [Ash] */ signal(SIGHUP, confirmSig); signal(SIGINT, confirmSig); signal(SIGQUIT, confirmSig); signal(SIGILL, confirmSig); signal(SIGKILL, confirmSig); signal(SIGBUS, confirmSig); signal(SIGSEGV, confirmSig); signal(SIGTERM, confirmSig); #endif progname = argv[0]; #ifndef TTYEDEN #ifdef __WIN32__ /* Let's try and derive the info required from the current working directory, on Windows only [Ash] */ if ((cwd = getcwd(NULL, PATH_MAX)) == NULL) { perror("Failed to get current working directory"); exit(2); } cwdwin32style = emalloc(PATH_MAX); cygwin_conv_to_full_win32_path(cwd, cwdwin32style); free(cwd); toPutEnv = emalloc(255); *toPutEnv = '\0'; /* This works manually... strcat(toPutEnv, "TCL_LIBRARY=c:\\cygwin\\usr\\share\\tcl8.0"); */ strcat(toPutEnv, "TCL_LIBRARY="); strcat(toPutEnv, cwdwin32style); strcat(toPutEnv, "\\share\\tcl8.0"); putenv(toPutEnv); /* I think we can't free(toPutEnv) now */ passToSetLibLocation = emalloc(255); *passToSetLibLocation = '\0'; /* This works manually... strcat(passToSetLibLocation, "c:\\cygwin\\home\\default\\tkeden1.15\\lib-tkeden"); */ strcat(passToSetLibLocation, cwdwin32style); strcat(passToSetLibLocation, "\\lib-tkeden"); setLibLocation(passToSetLibLocation); free(passToSetLibLocation); #endif /* __WIN32__ */ #endif /* TTYEDEN */ #ifndef TTYEDEN /* If we don't do this, on cygwin we get an error from Tcl_Init "couldn't stat "": no such file or directory" [Ash] */ Tcl_FindExecutable(progname); /* This is required by Tcl 8.2.0, otherwise the Tcl_PutEnv in setLibLocation falls over due to an uninitialised Tcl encoding system. The initialisation of Tcl probably calls TclInitEncodingSubsystem();, which is required. [Ash] */ EXinitTcl(); #endif /* TTYEDEN */ #ifdef DISTRIB setHostName(); #endif /* DISTRIB */ #ifdef DISTRIB /* a : in the getopt opt-string means that the preceding option has an argument [Ash] */ while ((op = getopt(argc, argv, "sac:h:vul:e")) != EOF) { #elif defined(TTYEDEN) while ((op = getopt(argc, argv, "vunie")) != EOF) { #else /* probably tkeden */ while ((op = getopt(argc, argv, "vul:e")) != EOF) { #endif /* -e, -n, -i must come after the other options which are processed by getopt (ie they represent the start of the filename list...) [Ash] */ if ((op == 'e') || (op == 'n') || (op == 'i')) { optind--; /* we want the filename reading while loop below to process this argument */ break; } switch (op) { #ifdef DISTRIB case 's': isServer = 1; usedArg++; break; case 'a': isServer = 0; usedArg++; break; case 'c': socketPort = socketPort + atoi(optarg); usedArg += 2; break; case 'h': strcpy(hostName, optarg); usedArg += 2; break; #endif case 'u': printUsage(); exit(0); #ifndef TTYEDEN case 'l': setLibLocation(optarg); usedArg += 2; break; #endif case 'v': /* this case should occur after all the option reading above, so that their effect can be seen in the -v output */ printVersion(); /* does not return */ case '?': argerr++; break; } if (argerr) { printUsage(); exit(-1); } } #ifndef TTYEDEN if (!libLocationAllocd) { fprintf(stderr, "%s: Could not find library files location (try using the -l argument)\n", progname); exit(-1); } #endif /* TTYEDEN */ #ifdef DISTRIB if (socketPort > 9099) { /* The user enters a number from 0-99, but actually we use a socket number from 9000 upwards :) [Ash, with Patrick] */ fprintf(stderr, "Channel number must be less than 100\n"); printUsage(); exit(-1); } #endif #ifdef TTYEDEN prompt = prompt1; #endif setbuf(stdout, 0); clearEntryStack(); clearMasterStack(); pushMasterStack("system"); #ifdef DISTRIB (s = install("EveryOneAllowed", VAR, INTEGER, 1))->changed = FALSE; EveryOneAllowed = &s->d.u.i; #endif /* DISTRIB */ (s = install("autocalc", VAR, INTEGER, 1))->changed = FALSE; autocalc = &s->d.u.i; (s = install("eden_error_index_range", VAR, INTEGER, 1))->changed = FALSE; eden_error_index_range = &s->d.u.i; (s = install("eden_notice_undef_reference", VAR, INTEGER, 0))->changed = FALSE; eden_notice_undef_reference = &s->d.u.i; #ifdef DISTRIB (s = install("synchronize", VAR, INTEGER, 0))->changed = FALSE; synchronize = &s->d.u.i; (s = install("higherPriority", VAR, INTEGER, 0))->changed = FALSE; higherPriority = &s->d.u.i; (s = install("propagateType", VAR, INTEGER, 1))->changed = FALSE; propagateType = &s->d.u.i; #endif /* DISTRIB */ initRunSet(&RS1); initRunSet(&RS2); RS = &RS1; #ifndef TTYEDEN EXinit(); #endif signal(SIGINT, Control_C); init(); initcode(); init_LocalVarList(); #ifdef DISTRIB init_LSDagentList(); /* initial LSDagentList --sun */ #endif /* DISTRIB */ init_eden(); #ifndef TTYEDEN init_donald(); init_scout(); #ifdef WANT_SASAMI sa_init_sasami(); #endif /* WANT_SASAMI */ #endif popMasterStack(); pushMasterStack("initialisation"); /* Figure out where the end of the options (and start of the filename list) is [Ash] */ gargc = argc - usedArg; gargv = argv + optind; setjmp(start); /* set resume point */ while (gargc-- > 0) { /* Recall that argv is an array of pointers to the already-separated command arguments [Ash] */ name = *gargv++; if (streq(name, "-")) { /* - is shorthand for stdin */ run(FILE_DEV, stdin, name); continue; } #ifdef TTYEDEN if (streq(name, "-n")) { interactive = FALSE; continue; } if (streq(name, "-i")) { interactive = TRUE; continue; } #endif if (streq(name, "-e")) { /* Execute the following argument as a string [Ash] */ char *argIn, *argProcessed, *inp, *outp, c; argIn = *gargv++; gargc--; /* we've consumed another argument, eArg */ /* translate "\n" to newline */ argProcessed = emalloc(strlen(argIn) + 1); inp = argIn; outp = argProcessed; do { c = *inp++; if ((c == '\\') && (*inp == 'n')) { inp++; *outp++ = '\n'; } else { *outp++ = c; } } while (c != '\0'); run(STRING_DEV, argProcessed, 0); free(argProcessed); continue; } if (*name == '-') { /* First character is -, but it isn't one of the above options, so print a message and carry on */ fprintf(stderr, "%s: unknown argument %s\n", progname, name); continue; } /* else a filename */ if ((filein = fopen(name, "r"))) { /* cd into the directory containing the file, to give any Eden include(...) procedures a chance [Ash] */ sprintf(edenCmd, "%%eden\ncd(dirname(\"%s\"));", name); run(STRING_DEV, edenCmd, 0); run(FILE_DEV, filein, name); continue; } else { fprintf(stderr, "%s: can't open %s\n", progname, name); } } popMasterStack(); #ifdef TTYEDEN pushMasterStack("input"); setjmp(start); /* set resume point */ run(FILE_DEV, stdin, "stdin"); popMasterStack(); #else Tcl_DoWhenIdle(checkRunSet, 0); setjmp(start); /* set resume point */ Tk_MainLoop(); #endif /* TTYEDEN */ terminate(0); } fprintf(stderr, "Use the -u option for information on usage of command options\n"); fprintf(stderr, "See %s for more information\n", TKEDEN_WEB_SITE); exit(0); } #ifdef DISTRIB /* tkeden1.18/Eden/machine.h010060000025250000147000000004220727455501400165060ustar00ashleydcsother00003470000356/* * $Id: machine.h,v 1.3 1999/11/16 21:20:40 ashley Rel1.10 $ */ extern void mustint(Datum, char *); extern void mustchar(Datum, char *); extern void muststr(Datum, char *); extern void mustlist(Datum, char *); extern void mustaddr(Datum, char *); extern int datacmp(); tkeden1.18/Eden/machine.c010060000025250000147000001147350731245706400165150ustar00ashleydcsother00003470000356/* * $Id: machine.c,v 1.16 2001/04/04 19:37:44 cssbz Exp $ */ static char rcsid[] = "$Id: machine.c,v 1.16 2001/04/04 19:37:44 cssbz Exp $"; /**** * * * This files contains most of the implementation of * * most of the pseduo-machine codes. * * * ****/ #include #include #include #include "../config.h" #include "eden.h" #include "yacc.h" #include "emalloc.h" #ifdef HAVE_DMALLOC #include #endif extern int topEntryStack(void); extern char *topMasterStack(void); extern Datum ctos(Datum); extern int appAgentName; extern char *typename(); #ifdef DISTRIB extern int handle_check(symptr); /* for agency --sun */ extern void propagate_agency(symptr); #endif /* DISTRIB */ void makearr(Int); #ifdef DEBUG #define DEBUGPRINT(s,t) {if(Debug&1)fprintf(stderr,s,t);} #else #define DEBUGPRINT(s,t) #endif #define dpush(x, y, z) x.u.i=(Int)(z); x.type = y; push(x); #define CheckRange(n,low,up) if(nup)out_of_range_error(n,low,up) /* pop_address used to be (more confusingly) called get_address [Ash] */ #define pop_address(addr,where) addr=pop();mustaddr(addr,where) #define is_string(d) (d.type == MYCHAR || d.type==STRING) #define is_list(d) (d.type == LIST) #define sametype(d1, d2) ((d1.type == d2.type) || (isnum(d1) && isnum(d2))) #define address(sp) { Datum d; d.type = SYMBOL | DPTR; \ d.u.v.x = (Int) &(sp->d); d.u.v.y = (Int) sp; push(d); } #ifdef DISTRIB #define ChangeSym(addr) if (is_symbol(addr)) {\ if (appAgentName > 0) propagate_agency(symbol_of(addr));\ change(symbol_of(addr), FALSE);\ symbol_of(addr)->entry = topEntryStack();\ symbol_of(addr)->master = topMasterStack();\ } #else #define ChangeSym(addr) if (is_symbol(addr)) {\ change(symbol_of(addr), FALSE);\ symbol_of(addr)->entry = topEntryStack();\ symbol_of(addr)->master = topMasterStack();\ } #endif /* DISTRIB */ void freedatum(Datum d) { /* free the content of the datum, not the datum itself */ int i; switch (d.type) { case STRING: if (d.u.s) free(d.u.s); /* free the string */ break; case LIST: for (i = 1; i <= d.u.a->u.i; i++) freedatum(d.u.a[i]);/* free each item */ free(d.u.a); /* free the list */ break; } } Datum newdatum(Datum d) { /* use malloc to duplicate a datum */ char *s; Datum *a; int i; switch (d.type) { case STRING: /* copy the content of a string */ if (d.u.s) { /* a precaution of NULL */ s = (char *) emalloc(strlen(d.u.s) + 1); d.u.s = (char *) strcpy(s, d.u.s); } /* an error ? */ break; case LIST: /* copy the content of a list */ a = (Datum *) emalloc((d.u.a->u.i + 1) * sizeof(Datum)); for (i = 0; i <= d.u.a->u.i; i++) a[i] = newdatum(d.u.a[i]); d.u.a = a; break; } return d; } Datum newhdat(Datum d) { /* ("new *heap* datum" [Ash]) similiar to newdatum, but use heap to allocate space instead */ char *s; Datum *a; int i; switch (d.type) { case STRING: if (d.u.s) { s = (char *) getheap(strlen(d.u.s) + 1); d.u.s = (char *) strcpy(s, d.u.s); } else s = d.u.s; /* if null [Ash] */ break; case LIST: a = (Datum *) getheap((d.u.a->u.i + 1) * sizeof(Datum)); for (i = 0; i <= d.u.a->u.i; i++) { a[i] = newhdat(d.u.a[i]); } d.u.a = a; break; } return d; } void out_of_range_error(int i, int low, int up) { errorf("index out of range (%d is outside the range %d...%d)", i, low, up); } void mustint(Datum d, char *where) { if (d.type != INTEGER && d.type != MYCHAR) errorf("type clash: expecting %s (in %s, got %s)", typename(INTEGER), where, typename(d.type)); } void mustchar(Datum d, char *where) { if (d.type != INTEGER && d.type != MYCHAR) errorf("type clash: expecting %s (in %s, got %s)", typename(MYCHAR), where, typename(d.type)); } void muststr(Datum d, char *where) { if (d.type != STRING) errorf("type clash: expecting %s (in %s, got %s)", typename(STRING), where, typename(d.type)); } void mustlist(Datum d, char * where) { if (d.type != LIST) errorf("type clash: expecting %s (in %s, got %s)", typename(LIST), where, typename(d.type)); } void mustaddr(Datum d, char *where) { if (!is_address(d)) errorf("type clash: expecting reference to variable (in %s, got %s)", where, typename(d.type)); } void address_error(char *where) { errorf("type clash: expecting reference to variable (in %s)", where); } int get2num(Datum * dp1, Datum * dp2) { /* get 2 integer from stack */ *dp2 = pop(); *dp1 = pop(); switch (dp1->type) { case MYCHAR: dp1->type = INTEGER; case INTEGER: case REAL: break; case UNDEF: return UNDEF; /* undefined value */ default: errorf("type clash: number type required (got %s)", typename(dp1->type)); } switch (dp2->type) { case MYCHAR: dp1->type = INTEGER; case INTEGER: case REAL: break; case UNDEF: return UNDEF; /* undefined value */ default: errorf("type clash: number type required (got %s)", typename(dp2->type)); } if (dp1->type != REAL && dp2->type == REAL) { /* convert d1 to real */ dp1->type = REAL; dp1->u.r = dp1->u.i; return REAL; } if (dp1->type == REAL && dp2->type != REAL) { /* convert d2 to real */ dp2->type = REAL; dp2->u.r = dp2->u.i; return REAL; } return dp1->type; } void add(void) { /* operator + */ Datum d1, d2; DEBUGPRINT("VMOPER|DATSTK add\n", 0); switch (get2num(&d1, &d2)) { case INTEGER: d1.u.i += d2.u.i; break; case REAL: d1.u.r += d2.u.r; break; default: pushUNDEF(); return; } push(d1); } void sub(void) { /* operator - */ Datum d1, d2; DEBUGPRINT("VMOPER|DATSTK sub\n", 0); switch (get2num(&d1, &d2)) { case INTEGER: d1.u.i -= d2.u.i; break; case REAL: d1.u.r -= d2.u.r; break; default: pushUNDEF(); return; } push(d1); } void mul(void) { /* operator * */ Datum d1, d2; DEBUGPRINT("VMOPER|DATSTK mul\n", 0); switch (get2num(&d1, &d2)) { case INTEGER: d1.u.i *= d2.u.i; break; case REAL: d1.u.r *= d2.u.r; break; default: pushUNDEF(); return; } push(d1); } void divide(void) { /* operator / */ Datum d1, d2; DEBUGPRINT("VMOPER|DATSTK divide\n", 0); switch (get2num(&d1, &d2)) { case INTEGER: if (d2.u.i == 0) errorf("division by zero (trying to calculate %d/0)", d1.u.i); d1.u.i /= d2.u.i; break; case REAL: if (d2.u.r == 0.0) errorf("division by zero (trying to calculate %f/0)", d1.u.r); d1.u.r /= d2.u.r; break; default: pushUNDEF(); return; } push(d1); } void mod(void) { /* operator % */ Datum d1, d2; DEBUGPRINT("VMOPER|DATSTK mod\n", 0); switch (get2num(&d1, &d2)) { case INTEGER: if (d2.u.i == 0) errorf("division by zero (trying to calculate %d%%0)", d1.u.i); d1.u.i %= d2.u.i; break; case REAL: errorf("operand of % have incompatible types (%s and %s)", typename(d1.type), typename(d2.type)); break; default: pushUNDEF(); return; } push(d1); } void negate(void) { /* unary minus - */ Datum d; DEBUGPRINT("VMOPER|DATSTK negate\n", 0); d = pop(); switch (d.type) { case MYCHAR: d.type = INTEGER; case INTEGER: d.u.i = -d.u.i; break; case REAL: d.u.r = -d.u.r; break; case UNDEF: pushUNDEF(); return; default: errorf("type clash on negation: number type required (got %s)", typename(d.type)); return; } push(d); } void lazy_not(void) { /* logical lazy not */ Datum d; DEBUGPRINT("VMOPER|DATSTK lazy_not\n", 0); d = pop(); if (!isint(d) && !isundef(d)) errorf("type clash: lazy not: expecting %s (got %s)", typename(INTEGER), typename(d.type)); switch (d.type) { case MYCHAR: d.type = INTEGER; case INTEGER: d.u.i = !d.u.i; break; case REAL: default: d.type = INTEGER; d.u.i = !d.u.r; break; } push(d); } void not(void) { /* logical not */ Datum d; DEBUGPRINT("VMOPER|DATSTK not\n", 0); d = pop(); if (!isint(d) && !isundef(d)) errorf("type clash: logical not: expecting %s (got %s)", typename(INTEGER), typename(d.type)); switch (d.type) { case MYCHAR: d.type = INTEGER; case INTEGER: d.u.i = !d.u.i; break; case REAL: d.type = INTEGER; d.u.i = !d.u.r; break; default: pushUNDEF(); return; } push(d); } void concat(void) { /* string/list concat opeator // */ Datum d1, d2; int len; char *s; int i, size1, size2; /* extern void print(Datum); */ DEBUGPRINT("VMOPER|DATSTK concat\n", 0); d2 = pop(); d1 = pop(); /* printf("d2 "); print(d2); printf("d1 "); print(d1); */ if (isundef(d1) || isundef(d2)) pushUNDEF(); else if (is_string(d1) && is_string(d2)) { d1 = ctos(d1); d2 = ctos(d2); len = strlen(d1.u.s) + strlen(d2.u.s); s = (char *) getheap(len + 1); d1.u.s = (char *) strcat(strcpy(s, d1.u.s), d2.u.s); push(d1); } else if (is_list(d1) && is_list(d2)) { size1 = d1.u.a->u.i; size2 = d2.u.a->u.i; for (i = 1; i <= size1; i++) push(d1.u.a[i]); for (i = 1; i <= size2; i++) push(d2.u.a[i]); makearr(size1 + size2); } else errorf("type clash on concatenation: expecting strings or lists (got %s and %s)", typename(d1.type), typename(d2.type)); } void jmp(void) { /* unconditional jump */ Int i = (Int) (*pc++); DEBUGPRINT("VMOPER|DATSTK jmp\n", 0); pc += i; } void jpt(void) { /* jump on true */ Int i = (Int) (*pc++); Datum d; DEBUGPRINT("VMOPER|DATSTK jpt\n", 0); d = pop(); if (isundef(d)) { return; } else { mustint(d, "jpt (loop construct)"); if (d.u.i) pc += i; } } void jpf(void) { /* jump on false */ Int i = (Int) (*pc++); Datum d; DEBUGPRINT("VMOPER|DATSTK jpf\n", 0); d = pop(); if (isundef(d)) { return; } else { mustint(d, "jpf (loop construct)"); if (!d.u.i) pc += i; } } void jpnt(void) { /* jump on not true, i.e. on false or @ */ Int i = (Int) (*pc++); Datum d; DEBUGPRINT("VMOPER|DATSTK jpnt\n", 0); d = pop(); if (isundef(d)) { pc += i; } else { mustint(d, "jpnt (loop construct)"); if (!d.u.i) pc += i; } } void jpnf(void) { /* jump on not false, i.e. on true or @ */ Int i = (Int) (*pc++); Datum d; DEBUGPRINT("VMOPER|DATSTK jpnf\n", 0); d = pop(); if (isundef(d)) { pc += i; } else { mustint(d, "jpnf (loop construct)"); if (d.u.i) pc += i; } } void and(void) { /* eager, logical and */ Datum d1, d2; DEBUGPRINT("VMOPER|DATSTK and\n", 0); switch (get2num(&d1, &d2)) { case INTEGER: d1.u.i = d1.u.i && d2.u.i; break; case REAL: errorf("type clash: eager logical and: expecting %s (got %s and %s)", typename(INTEGER), typename(d1.type), typename(d2.type)); default: pushUNDEF(); return; } push(d1); } void or(void) { /* eager, logical or */ Datum d1, d2; DEBUGPRINT("VMOPER|DATSTK or\n", 0); switch (get2num(&d1, &d2)) { case INTEGER: d1.u.i = d1.u.i || d2.u.i; break; case REAL: errorf("type clash: eager logical or: expecting %s (got %s and %s)", typename(INTEGER), typename(d1.type), typename(d2.type)); default: pushUNDEF(); return; } push(d1); } /* bitwise and [Ash] */ void bitand(void) { Datum d1, d2; DEBUGPRINT("VMOPER|DATSTK bitand\n", 0); switch (get2num(&d1, &d2)) { case INTEGER: d1.u.i = d1.u.i & d2.u.i; break; case REAL: errorf("type clash: bitwise and: expecting %s (got %s and %s)", typename(INTEGER), typename(d1.type), typename(d2.type)); default: pushUNDEF(); return; } push(d1); } /* bitwise or [Ash] */ void bitor(void) { Datum d1, d2; DEBUGPRINT("VMOPER|DATSTK bitor\n", 0); switch (get2num(&d1, &d2)) { case INTEGER: d1.u.i = d1.u.i | d2.u.i; break; case REAL: errorf("type clash: bitwise or: expecting %s (got %s and %s)", typename(INTEGER), typename(d1.type), typename(d2.type)); default: pushUNDEF(); return; } push(d1); } void ddup(void) { /* duplicate datum */ Datum d; DEBUGPRINT("VMOPER|DATSTK ddup\n", 0); d = top_of_stack; push(d); /* since "push: is a macro, it is saver to copy top-of-stack in variables first. */ } void popd(void) { /* pop a datum off stack */ Datum dummy; DEBUGPRINT("VMOPER|DATSTK popd\n", 0); dummy = pop(); /* the compiler don't like we just do the macro pop(), so we assign it to a dummy variable. */ } void pushUNDEF(void) { /* push @ on stack */ DEBUGPRINT("VMOPER|DATSTK pushUNDEF\n", 0); push(UndefDatum); } void pushint(void) { /* interpret next instruction as an integer and push it onto stack */ Datum d; DEBUGPRINT("VMOPER|DATSTK pushint\n", 0); d.type = INTEGER; d.u.i = (Int) * pc++; push(d); } void constpush(void) { /* push a constant */ DEBUGPRINT("VMOPER|DATSTK constpush\n", 0); /* the constant is pointed to by the rest of the code*/ push(*((Datum *) (*pc))); /* Note that using push with an expression with side-effect is dangerous if DEBUG [Ash] */ pc++; } / datacmp() is called by all comparison operators / int datacmp(d1, d2) /* internal function */ Datum d1, d2; /* compare two data */ { /* return 0 = equal, +ve = greater than */ int i; /* -ve = less than */ double r; if (sametype(d1, d2)) { if (d1.type != REAL && d2.type == REAL) { /* convert d1 to real */ d1.type = REAL; d1.u.r = d1.u.i; } else if (d1.type == REAL && d2.type != REAL) { /* convert d2 to real */ d2.type = REAL; d2.u.r = d2.u.i; } switch (d1.type) { case UNDEF: return 0; case REAL: return (r = d1.u.r - d2.u.r) ? (r > 0.0 ? 1 : -1) : 0; case STRING: return strcmp(d1.u.s, d2.u.s); case LIST: if (d1.u.a->u.i != d2.u.a->u.i) return 1; /* not equal */ for (i = 1; i <= d1.u.a->u.i; i++) if (datacmp(d1.u.a[i], d2.u.a[i])) return 1; /* not equal */ return 0; /* equal */ default: return (d1.u.i - d2.u.i); } } else { return 1; /* not equal */ } } void cnv_2_bool(void) { /* convert an integer to boolean value */ DEBUGPRINT("VMOPER|DATSTK cnv_2_bool\n", 0); switch (top_of_stack.type) { case INTEGER: case MYCHAR: top_of_stack.type = INTEGER; top_of_stack.u.i = top_of_stack.u.i != 0; break; case UNDEF: break; default: errorf("type clash: convert integer to bool: expecting %s (got %s)", typename(INTEGER), typename(top_of_stack.type)); break; } } void gt(void) { /* > */ Datum d1, d2, d; DEBUGPRINT("VMOPER|DATSTK gt\n", 0); d2 = pop(); d1 = pop(); if (sametype(d1, d2)) { if (d1.type != UNDEF && d1.type != LIST) { dpush(d, INTEGER, datacmp(d1, d2) > 0); return; } } pushUNDEF(); } void lt(void) { /* < */ Datum d1, d2, d; DEBUGPRINT("VMOPER|DATSTK lt\n", 0); d2 = pop(); d1 = pop(); if (sametype(d1, d2)) { if (d1.type != UNDEF && d1.type != LIST) { dpush(d, INTEGER, datacmp(d1, d2) < 0); return; } } pushUNDEF(); } void ge(void) { /* >= */ Datum d1, d2, d; DEBUGPRINT("VMOPER|DATSTK ge\n", 0); d2 = pop(); d1 = pop(); if (sametype(d1, d2)) { if (d1.type != UNDEF && d1.type != LIST) { dpush(d, INTEGER, datacmp(d1, d2) >= 0); return; } } pushUNDEF(); } void le(void) { /* <= */ Datum d1, d2, d; DEBUGPRINT("VMOPER|DATSTK le\n", 0); d2 = pop(); d1 = pop(); if (sametype(d1, d2)) { if (d1.type != UNDEF && d1.type != LIST) { dpush(d, INTEGER, datacmp(d1, d2) <= 0); return; } } pushUNDEF(); } void eq(void) { /* == */ Datum d1, d2; DEBUGPRINT("VMOPER|DATSTK eq\n", 0); d2 = pop(); d1 = pop(); d1.u.i = datacmp(d1, d2) == 0; d1.type = INTEGER; push(d1); } void ne(void) { /* != */ Datum d1, d2; DEBUGPRINT("VMOPER|DATSTK ne\n", 0); d2 = pop(); d1 = pop(); d1.u.i = datacmp(d1, d2) != 0; d1.type = INTEGER; push(d1); } /*- * Switch is implement by a jump table. Table entries are of the form: * * where * is a pointer pointing to the actual constant datum, and * is the relative offset to code entry. * If is a null ptr, then it is the default case. * If the switch statement has no default case, the must * point to the next statement (i.e. = 2). * See codeswitch() in file code.c for encoding the switch statement. -*/ void switchcode(void) { /* switch statement code */ Datum d; DEBUGPRINT("VMOPER|DATSTK|VMREAD|VMEXEC switchcode\n", 0); d = pop(); /* value */ for (; *pc && datacmp(d, *(Datum *) (*pc)); pc += 2); pc += (Int) pc[1]; /* do a relative jump */ } void definition(void) { /* put defn/func/action in symbol table */ symptr sp; symptr_QUEUE *splist; Inst *prog_begin, *prog_end; Int type; Int nauto; char *text; int checkok(symptr, symptr_QUEUE *); void change_sources(symptr, symptr_QUEUE *); #ifdef NO_CHECK_CIRCULAR extern int NCC; #endif /* NO_CHECK_CIRCULAR */ type = (Int) (*pc++); sp = (symptr) (*pc++); splist = (symptr_QUEUE *) (*pc++); prog_begin = (Inst *) (*pc++); prog_end = (Inst *) (*pc++); nauto = (Int) (*pc++); text = (char *) (*pc++); #ifdef NO_CHECK_CIRCULAR if (!NCC) #endif /* NO_CHECK_CIRCULAR */ if (!checkok(sp, splist)) { error2(sp->name, ": CYCLIC DEF : ABORTED"); } /* If the symbol is already installed and has not changed, don't install it again (I think) [Ash] */ if (prog_begin != sp->inst) { /*- if (sp->inst && !indef) { free(sp->inst); DEBUGPRINT("** definition: free %s %d\n", sp->name); } -*/ sp->nauto = nauto; sp->inst = prog_begin; sp->stype = type; sp->d.type = type; sp->d.u.sym = sp; sp->text = text; sp->entry = topEntryStack(); sp->master = topMasterStack(); change_sources(sp, splist); } DEBUGPRINT("VMOPER|VMREAD|DEFNET definition %s\n", sp->name); } /* definition_runtimelhs appears to have been added by Patrick to be used in the "`expr` is expr;" case. It used to (less meaningfully) be called definition1. [Ash] */ void definition_runtimelhs(void) { /* put defn/func/action in symbol table */ symptr sp; symptr_QUEUE *splist; Inst *prog_begin, *prog_end; Int type; Int nauto; char *text; int checkok(symptr, symptr_QUEUE *); void change_sources(symptr, symptr_QUEUE *); Datum addr; #ifdef NO_CHECK_CIRCULAR extern int NCC; #endif /* NO_CHECK_CIRCULAR */ /* For "`expr1` is expr2;", the parser codes opcodes which create the result of expr1 on the stack, followed by lookup_address. This pops the string off the stack, looks up that name as a reference into the symbol table, then pops back the address of that variable (creating it if it doesn't exist). Now the following finds the symbol to be redefined. [Ash] */ pop_address(addr, "definition_runtimelhs (adding definition)"); sp = symbol_of(addr); type = (Int) (*pc++); splist = (symptr_QUEUE *) (*pc++); prog_begin = (Inst *) (*pc++); prog_end = (Inst *) (*pc++); nauto = (Int) (*pc++); text = (char *) (*pc++); #ifdef NO_CHECK_CIRCULAR if (!NCC) #endif /* NO_CHECK_CIRCULAR */ if (!checkok(sp, splist)) { error2(sp->name, ": CYCLIC DEF : ABORTED"); } /* If the symbol is already installed and has not changed, don't install it again (I think) [Ash] */ if (prog_begin != sp->inst) { /*- if (sp->inst && !indef) { free(sp->inst); DEBUGPRINT("** free %s %d\n", sp->name); } -*/ sp->nauto = nauto; sp->inst = prog_begin; sp->stype = type; sp->d.type = type; sp->d.u.sym = sp; sp->text = text; sp->entry = topEntryStack(); sp->master = topMasterStack(); change_sources(sp, splist); } DEBUGPRINT("VMOPER|VMREAD|DEFNET definition_runtimelhs %s\n", sp->name); } /** * RUN-TIME CODES OF ASSIGNMENT AND INCREMENT OPERATORS * **/ static void need_rwv(Datum addr, char *message) { /* check if lvalue a RWV ? */ if (!(is_local(addr) || (is_symbol(addr) && symbol_of(addr)->stype == VAR))) error2(message, "not read/write variable"); } /* This only seems to be called by assign() [Ash] */ static void cnv_formula_to_rwv(Datum addr) { /* if sym is a formula, convert to rwv */ extern void change_sources(symptr, symptr_QUEUE *); symptr sp; static symptr_QUEUE NullList = EMPTYQUEUE(NullList); if (is_symbol(addr) && (sp = symbol_of(addr))->stype == FORMULA) { /*- free(sp->inst); -*//* remove the code */ sp->inst = (Inst *) 0; sp->nauto = 0; sp->stype = VAR; /* free(sp->text); */ sp->text = (char *) 0; change_sources(sp, &NullList); } } void assign(void) { /* lvalue = expression */ Datum d, addr, tmp; #ifdef DISTRIB symptr sp; #endif /* DISTRIB */ DEBUGPRINT("VMOPER|DATSTK|SYMTBL assign\n", 0); d = pop(); /* value */ addr = pop(); /* address */ mustaddr(addr, "="); #ifdef DISTRIB if (is_symbol(addr)) sp = symbol_of(addr); /* for agency --sun */ else sp=0; #endif /* DISTRIB */ #ifdef DISTRIB if (handle_check(sp)) { #endif cnv_formula_to_rwv(addr); /* original code --sun */ need_rwv(addr, "'=':"); switch (address_type(addr)) { case DPTR: tmp = newdatum(d); freedatum(*dptr(addr)); *dptr(addr) = tmp; break; case CPTR: mustchar(d, "="); *cptr(addr) = d.u.i; break; default: address_error("="); break; } push(d); ChangeSym(addr); #ifdef DISTRIB } else { pushUNDEF(); } #endif } void inc_asgn(void) { /* lvalue += expression */ Datum d, addr; #ifdef DISTRIB symptr sp; #endif /* DISTRIB */ DEBUGPRINT("VMOPER|DATSTK|SYMTBL inc_asgn\n", 0); mustint(d = pop(), "+="); /* value */ addr = pop(); /* address */ mustaddr(addr, "+="); #ifdef DISTRIB if (is_symbol(addr)) sp = symbol_of(addr); /* for agency --sun */ else sp=0; #endif /* DISTRIB */ #ifdef DISTRIB if (handle_check(sp)) { #endif need_rwv(addr, "'+=':"); /* original code --sun */ switch (address_type(addr)) { case DPTR: mustint(*dptr(addr), "+="); /* += only works on integers - could be fixed [Ash] */ dptr(addr)->u.i += d.u.i; break; case CPTR: mustchar(d, "+="); *cptr(addr) += d.u.i; break; default: address_error("+="); break; } push(d); ChangeSym(addr); #ifdef DISTRIB } else { pushUNDEF(); } #endif } void dec_asgn(void) { /* lvalue -= expression */ Datum d, addr; #ifdef DISTRIB symptr sp; #endif /* DISTRIB */ DEBUGPRINT("VMOPER|DATSTK|SYMTBL dec_asgn\n", 0); mustint(d = pop(), "-="); /* value */ addr = pop(); /* address */ mustaddr(addr, "-="); #ifdef DISTRIB if (is_symbol(addr)) sp = symbol_of(addr); /* for agency --sun */ else sp=0; #endif /* DISTRIB */ #ifdef DISTRIB if (handle_check(sp)) { #endif need_rwv(addr, "'-=':"); /* original code --sun */ switch (address_type(addr)) { case DPTR: mustint(*dptr(addr), "-="); /* -= only works on integers - could be fixed [Ash] */ dptr(addr)->u.i -= d.u.i; break; case CPTR: mustchar(d, "-="); *cptr(addr) -= d.u.i; break; default: address_error("-="); break; } push(d); ChangeSym(addr); #ifdef DISTRIB } else { pushUNDEF(); } #endif } void pre_inc(void) { /* ++lvalue */ Datum d, addr; #ifdef DISTRIB symptr sp; #endif /* DISTRIB */ DEBUGPRINT("VMOPER|DATSTK|SYMTBL pre_inc\n", 0); addr = pop(); /* address */ mustaddr(addr, "++ (pre-inc)"); #ifdef DISTRIB if (is_symbol(addr)) sp = symbol_of(addr); /* for agency --sun */ else sp=0; #endif /* DISTRIB */ #ifdef DISTRIB if (handle_check(sp)) { #endif need_rwv(addr, "'++':"); /* original code --sun */ switch (address_type(addr)) { case DPTR: mustint(*dptr(addr), "++ (pre-inc)"); (dptr(addr)->u.i)++; push(*dptr(addr)); break; case CPTR: (*cptr(addr))++; dpush(d, MYCHAR, *cptr(addr)); break; default: address_error("++ (pre-inc)"); break; } ChangeSym(addr); #ifdef DISTRIB } else { pushUNDEF(); } #endif } void post_inc(void) { /* lvalue++ */ Datum d, addr; #ifdef DISTRIB symptr sp; #endif /* DISTRIB */ DEBUGPRINT("VMOPER|DATSTK|SYMTBL post_inc\n", 0); addr = pop(); /* address */ mustaddr(addr, "++ (post-inc)"); #ifdef DISTRIB if (is_symbol(addr)) sp = symbol_of(addr); /* for agency --sun */ else sp=0; #endif /* DISTRIB */ #ifdef DISTRIB if (handle_check(sp)) { #endif need_rwv(addr, "'++':"); /* original code --sun */ switch (address_type(addr)) { case DPTR: mustint(*dptr(addr), "++ (post-inc)"); push(*dptr(addr)); (dptr(addr)->u.i)++; break; case CPTR: dpush(d, MYCHAR, *cptr(addr)); (*cptr(addr))++; break; default: address_error("++ (post-inc)"); break; } ChangeSym(addr); #ifdef DISTRIB } else { pushUNDEF(); } #endif } void pre_dec(void) { /* --lvalue */ Datum d, addr; #ifdef DISTRIB symptr sp; #endif /* DISTRIB */ DEBUGPRINT("VMOPER|DATSTK|SYMTBL pre_dec\n", 0); addr = pop(); /* address */ mustaddr(addr, "-- (pre-dec)"); #ifdef DISTRIB if (is_symbol(addr)) sp = symbol_of(addr); /* for agency --sun */ else sp=0; #endif /* DISTRIB */ #ifdef DISTRIB if (handle_check(sp)) { #endif need_rwv(addr, "'--':"); /* original code --sun */ switch (address_type(addr)) { case DPTR: mustint(*dptr(addr), "-- (pre-dec)"); --(dptr(addr)->u.i); push(*dptr(addr)); break; case CPTR: --(*cptr(addr)); dpush(d, MYCHAR, *cptr(addr)); break; default: address_error("-- (pre-dec)"); break; } ChangeSym(addr); #ifdef DISTRIB } else { pushUNDEF(); } #endif } void post_dec(void) { /* lvalue-- */ Datum d, addr; #ifdef DISTRIB symptr sp; #endif /* DISTRIB */ DEBUGPRINT("VMOPER|DATSTK|SYMTBL post_dec\n", 0); addr = pop(); /* address */ mustaddr(addr, "-- (post-dec)"); #ifdef DISTRIB if (is_symbol(addr)) sp = symbol_of(addr); /* for agency --sun */ else sp=0; #endif /* DISTRIB */ #ifdef DISTRIB if (handle_check(sp)) { #endif need_rwv(addr, "'--':"); /* original code --sun */ switch (address_type(addr)) { case DPTR: mustint(*dptr(addr), "-- (post-dec)"); push(*dptr(addr)); --(dptr(addr)->u.i); break; case CPTR: dpush(d, MYCHAR, *cptr(addr)); --(*cptr(addr)); break; default: address_error("-- (post-dec)"); break; } ChangeSym(addr); #ifdef DISTRIB } else { pushUNDEF(); } #endif } static int UPDATE = 1; void noupdate(void) { DEBUGPRINT("VMOPER|MCSTAT noupdate\n", 0); UPDATE = 0; } void resetupdate(void) { DEBUGPRINT("VMOPER|MCSTAT resetupdate\n", 0); UPDATE = 1; } void update(symptr sp) { /* force the evaluation/execution of defn/action */ extern void execute(Inst *); DEBUGPRINT("MCSTAT|VMEXEC|SYMTBL update\n", 0); if (UPDATE) { execute(sp->inst); /* eval/exec defn/action */ freedatum(sp->d); /* free the old value */ sp->d = newdatum(pop());/* store the new value in data register */ change(sp, FALSE); /* update the flag */ } } void addr(void) { /* push addr of data */ symptr sp; sp = (symptr) (*pc++); DEBUGPRINT("VMOPER|VMREAD|DATSTK addr: %s\n", sp->name); if (sp->stype == FORMULA && sp->changed) { update(sp); } address(sp); /* address() will do the push */ } /*- Take a variable name from stack, and look up from symbol table. Put the address onto stack. If symbol not found, create it. -*/ void lookup_address(void) { Datum d; symptr sp; extern char agentName[128]; /* for distributed Tkeden --sun */ extern int appAgentName, inEVAL, inPrefix; char newStr[128], *tempStr; extern void addID(symptr); d = pop(); /* Cope with `@`, for example [Ash] */ if (d.type == UNDEF) { pushUNDEF(); return; } muststr(d, "lookup_address"); /* variable id name */ /* printf("oldString = %s %s %i\n", d.u.s, agentName, appAgentName); */ newStr[0] = '\0'; if (*agentName !=0 && appAgentName >0 && strncmp(d.u.s, "~", 1) && !inEVAL) { /* for distributed --sun */ tempStr = d.u.s; if (!strncmp(d.u.s, "_", 1)) { strcat(newStr, "_"); tempStr++; } if (inPrefix) strcpy(newStr, agentName); else strcpy(newStr, tempStr); strcat(newStr, "_"); if (inPrefix) strcat(newStr, tempStr); else strcat(newStr, agentName); } else { if (!strncmp(d.u.s, "~", 1)) d.u.s++; strcpy(newStr, d.u.s); } /* original sy code --use d.u.s but not newStr */ /* printf("newString = %s", newStr); */ sp = lookup(newStr); /* look up for name */ /* install it in symbol table if not there */ if (sp == NULL) { sp = install(newStr, VAR, UNDEF, 0); } DEBUGPRINT("VMOPER|DATSTK|SYMTBL lookup_address: %s\n", sp->name); if (sp->stype == FORMULA && sp->changed) { update(sp); } address(sp); /* put the address of sp onto stack */ if (informula && !inEVAL) addID(sp); /* put sp into IDlist for dependency: bugfix! --sun */ } void localaddr(void) { /* push the address of a local variable */ Datum d; Int n; n = (Int) * pc++; DEBUGPRINT("VMOPER|VMREAD|DATSTK localaddr: %d\n", n); d.type = LOCALV | DPTR; d.u.v.x = (Int) & fp->stackp[n]; d.u.v.y = n; push(d); /* push the address on stack */ } void indexcalc(void) { /* compute the address of the i-th item/char of a list/string */ Datum addr, *dp, index; Int i; extern Int *eden_error_index_range; DEBUGPRINT("VMOPER|DATSTK indexcalc\n", 0); mustint(index = pop(), "indexing into list/string"); /* index */ i = index.u.i; pop_address(addr, "indexing into list/string"); if (address_type(addr) == DPTR) { dp = dptr(addr); switch (dp->type) { case LIST: /*CheckRange(i, 1, dp->u.a->u.i);*/ if (i < 1 || i > dp->u.a->u.i) { if (*eden_error_index_range) out_of_range_error(i, 1, dp->u.a->u.i); else { pushUNDEF(); return; } } addr.type = (addr.type & ADDRESSMASK) | DPTR; addr.u.v.x = (Int) & (dp->u.a[i]); break; case STRING: /*CheckRange(i, 1, (int) strlen(dp->u.s));*/ if (i < 1 || i > strlen(dp->u.s)) { if (*eden_error_index_range) out_of_range_error(i, 1, strlen(dp->u.s)); else { pushUNDEF(); return; } } --i; addr.type = (addr.type & ADDRESSMASK) | CPTR; addr.u.v.x = (Int) & (dp->u.s[i]); break; default: errorf("index error: list or string required (got %s, when trying to find %dth item)", typename(dp->type), i); /* it isn't a list/string */ break; } } else { errorf("index error: data isn't a list or string (when trying to find %dth item)", i); } push(addr); } void makelist(void) { /* create a list */ DEBUGPRINT("VMOPER|VMREAD makelist\n", 0); makearr((Int) * pc++); /* the rest of instruction indicates the no. of items (on the stack) */ } /* makearr moves n items off the stack. It copies them to the heap, * and links them together to form a list. Item number 0 in the list * is an INTEGER, containing the number of items in the list. [Ash] */ void makearr(Int n) { /* create a list */ /* n - no. of items (on the stack) */ Datum arr, d; DEBUGPRINT("HEAPAL|DATSTK makearr(%d)\n", n); arr.type = LIST; /* allocate memory on the heap */ arr.u.a = (Datum *) getheap((n + 1) * sizeof(Datum)); arr.u.a->type = INTEGER; /* the 0-th item stores the no. of items */ arr.u.a->u.i = n; while (n > 0) { /* printf("ASH: makearr: n=%d\n", n); */ d = pop(); /* printf("ASH: makearr: done pop, &arr.u.a[n]=0x%x &d=0x%x\n", &arr.u.a[n], &d); */ /* I've replaced this code: arr.u.a[n--] = d; with the memcpy version below as I've had problems with it and "Advanced C programming by example" (John Perry) suggests this on page 25 [Ash] */ memcpy(&arr.u.a[n], &d, sizeof(d)); n--; } push(arr); /* return the list */ } void getvalue(void) { /* eval */ Datum d, addr; symptr sp; extern Int *autocalc; extern int ready(); extern Int *eden_notice_undef_reference; #ifdef DISTRIB extern int oracle_check(symptr); #endif /* DISTRIB */ DEBUGPRINT("VMOPER|DATSTK getvalue\n", 0); /* Originally pop_address(addr);... I'm attempting to make `@` work... [Ash] */ addr=pop(); if (addr.type == UNDEF) { pushUNDEF(); return; } mustaddr(addr, "getvalue"); sp = symbol_of(addr); #ifdef DISTRIB if (is_symbol(addr)) { /* for agency --sun */ if (!oracle_check(sp)) { pushUNDEF(); return; } } #endif /* DISTRIB */ if (*autocalc && is_symbol(addr) && sp->stype == FORMULA && sp->changed && ready(sp)) { update(sp); } if (is_symbol(addr) && sp->d.type == UNDEF && *eden_notice_undef_reference) { noticef("reference to undefined variable %s (turn these notices off with eden_notice_undef_reference=0;)", sp->name); } switch (address_type(addr)) { case DPTR: push(*dptr(addr)); break; case CPTR: dpush(d, MYCHAR, *cptr(addr) & 0xFF); break; default: address_error("getvalue"); break; } } void sel(void) { /* return an item of a list or string */ Datum index, dat; Int i; DEBUGPRINT("VMOPER|DATSTK sel\n", 0); mustint(index = pop(), "indexing into list/string"); i = index.u.i; dat = pop(); switch (dat.type) { case LIST: CheckRange(i, 1, dat.u.a->u.i); push(dat.u.a[i]); break; case STRING: --i; CheckRange(i, 0, (int) strlen(dat.u.s)); dpush(dat, MYCHAR, dat.u.s[i] & 0xFF); break; default: errorf("index error: list or string required (got %s, when trying to find %dth item)", typename(dat.type), i); } } void listsize(void) { /* return the current size of list */ Datum d; DEBUGPRINT("VMOPER|DATSTK listsize\n", 0); d = pop(); switch (d.type) { case MYCHAR: dpush(d, INTEGER, 1); break; case STRING: dpush(d, INTEGER, strlen(d.u.s)); break; case LIST: push(d.u.a[0]); break; default: pushUNDEF(); break; } } void shift(void) { Datum addr, *dp; Int i; DEBUGPRINT("VMOPER|DATSTK|SYMTBL shift\n", 0); pop_address(addr, "shift"); mustlist(*(dp = dptr(addr)), "shift"); if (dp->u.a->u.i > 0) { freedatum(dp->u.a[1]); for (i = 1; i < dp->u.a->u.i; i++) dp->u.a[i] = dp->u.a[i + 1]; --(dp->u.a->u.i); ChangeSym(addr); } else error("zero sized list found in 'shift'"); } void append(void) { Datum addr, *dp; Datum d, *a; DEBUGPRINT("VMOPER|DATSTK|SYMTBL append\n", 0); d = pop(); /* value */ pop_address(addr, "append"); mustlist(*(dp = dptr(addr)), "append"); a = (Datum *) erealloc(dp->u.a, (dp->u.a->u.i + 2) * sizeof(Datum)); a[++a->u.i] = newdatum(d); dp->u.a = a; ChangeSym(addr); } void insert(void) { Datum addr, *dp; Datum d, p, *a; Int i, pos; DEBUGPRINT("VMOPER|DATSTK|SYMTBL insert\n", 0); d = pop(); /* value */ mustint(p = pop(), "insert"); /* position */ pos = p.u.i; pop_address(addr, "insert"); mustlist(*(dp = dptr(addr)), "insert"); CheckRange(pos, 1, dp->u.a->u.i + 1); a = (Datum *) erealloc(dp->u.a, (dp->u.a->u.i + 2) * sizeof(Datum)); for (i = a->u.i; i >= pos; --i) /* move backward */ a[i + 1] = a[i]; a[pos] = newdatum(d); /* insert */ ++a->u.i; dp->u.a = a; ChangeSym(addr); } void delete(void) { Datum addr, *dp; Datum p, *a; Int i, pos; DEBUGPRINT("VMOPER|DATSTK|SYMTBL delete\n", 0); mustint(p = pop(), "delete"); /* position */ pos = p.u.i; pop_address(addr, "delete"); mustlist(*(dp = dptr(addr)), "delete"); CheckRange(pos, 1, dp->u.a->u.i); a = dp->u.a; freedatum(a[pos]); /* delete */ for (i = pos + 1; i <= a->u.i; i++) /* move forward */ a[i - 1] = a[i]; --a->u.i; dp->u.a = a; ChangeSym(addr); } void query(void) { Datum addr; symptr sp; symptr_QUEUE *P, *Q; extern void print(Datum, FILE *); DEBUGPRINT("VMOPER|DATSTK query\n", 0); pop_address(addr, "query (?)"); sp = symbol_of(addr); if (sp == (symptr)0) { /* addr.u.v.y did not point to the containing symbol of the Datum, so just print the Datum. [Ash] */ print(addr, stdout); printf("\n"); } else { switch (sp->stype) { case FORMULA: printf("%s is%s ", sp->name, sp->text); printf("/* current value of %s is ", sp->name); print(sp->d, stdout); printf(" */\n"); break; case FUNCTION: case PROCMACRO: case PROCEDURE: printf("%s %s", sp->stype == FUNCTION ? "func" : (sp->stype == PROCMACRO ? "procmacro" : "proc"), sp->name); Q = &sp->sources; for (P = FRONT(Q); P; P = NEXT(Q, P)) { printf("%c %s", P == Q->next ? ':' : ',', P->obj->name); } printf(" "); if (sp->text) printf("%s\n", sp->text); break; default: printf("%s=", sp->name); print(sp->d, stdout); /* print datum: in builtin.c */ printf("\n"); break; } printf("%s ~> [", sp->name); Q = &sp->targets; for (P = FRONT(Q); P; P = NEXT(Q, P)) { printf(P == Q->next ? "%s" : ", %s", P->obj->name); } printf("]; /* %s last changed by %s */\n", sp->name, sp->master); } pushUNDEF(); } ess(void) { Datum d; tkeden1.18/Eden/lib.c010060000025250000147000000047250731245702200156460ustar00ashleydcsother00003470000356/* * $Id: lib.c,v 1.5 1999/11/16 21:20:40 ashley Rel1.10 $ */ static char rcsid[] = "$Id: lib.c,v 1.5 1999/11/16 21:20:40 ashley Rel1.10 $"; #include "../config.h" #include "eden.h" #include "builtin.h" #include "yacc.h" /* * call_lib --- C library interface * * It is a useful interface to include the C library routines into the * language. * * Weak points: * * (1) Only the first 10 arguments can be passed. * * (2) The interface cannot deal with list (cause the different internal * representation of data structures). * * (3) All the values returned by library routines are integers. * Programmers must explicitly write the type convertion codes. See * type.c for the type-convertion functions. * * (4) The interface can handle ``true'' functions, NOT macros. * */ #define P(i) para(i) #define PARSIZE 10 #define PushInteger(data) {Datum d;d.type=INTEGER;d.u.i=(Int)data;push(d);} #define PushReal(data) {Datum d;d.type=REAL;d.u.r=(double)data;push(d);} /***/ void call_lib(Inst inst) { int i, j; int A[PARSIZE]; Int result; for (i = 1, j = 0; i <= paracount && j < PARSIZE; i++) { if (is_address(P(i))) A[j++] = (Int) & (((Datum *) P(i).u.v.x)->u.i); else switch (P(i).type) { case INTEGER: case MYCHAR: case STRING: A[j++] = P(i).u.i; break; case REAL: A[j++] = P(i).u.v.x; A[j++] = P(i).u.v.y; break; default: errorf("illegally typed parameter passed to C-lib function (got %s for parameter no %d)", typename(P(i).type), i); break; } } result = ((int (*) ()) inst) (A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[8], A[9]); PushInteger(result); } void call_float(Inst inst) { int i, j; int A[PARSIZE]; double result; for (i = 1, j = 0; i <= paracount && j < PARSIZE; i++) { /* All the functions that return real values seem to require real values for their parameters, so I've taken out everything except REAL handling. [Ash] */ switch (P(i).type) { case REAL: A[j++] = P(i).u.v.x; A[j++] = P(i).u.v.y; break; default: errorf("illegally typed parameter passed to C-lib function: expecting %s (got %s for parameter no %d)", typename(REAL), typename(P(i).type), i); break; } } result = ((double (*) ()) inst) (A[0], A[1], A[2], A[3], A[4], A[5], A[6], A[7], A[8], A[9]); PushReal(result); } tkeden1.18/Eden/lex.c010060000025250000147000000677750731640375000157110ustar00ashleydcsother00003470000356/* * $Id: lex.c,v 1.22 2000/08/31 14:48:52 ashley Rel1.10 $ */ static char rcsid[] = "$Id: lex.c,v 1.22 2000/08/31 14:48:52 ashley Rel1.10 $"; #include #include #include #include #include #include #include "../config.h" #include "eden.h" #include "yacc.h" #ifdef TTYEDEN #include #include #include #else #include #include "../EX/script.h" #include "notation.h" #endif #include "input_device.h" #include "emalloc.h" #ifdef HAVE_DMALLOC #include #endif #define MAXTEXTLEN 4096 /* change from 1024 --sun */ static int bof; int nextc = ' '; char yytext[MAXTEXTLEN]; int yyleng = 0; extern YYSTYPE yylval; #ifdef TTYEDEN extern char *prompt, *prompt1, *prompt2; #else /* not TTYEDEN */ extern Tcl_Interp *interp; #endif extern void pushEntryStack(int); extern void popEntryStack(void); extern void push_text(char *, int); int inEVAL = 0; /* For VAs [Ash] */ char agentName[128]; char agentType[3]; int appAgentName = 1; int append_agentName = 1; int append_NoAgentName = 1; int inPrefix = 1; /* function prototypes */ Datum *makedatum(int, uDatum); void init_lex(void); int yylex(void); int peek(void); int keyin(void); static void append_char(int); static int buffer_overflow(void); static int keyword_token(char *); static int number_token(void); static int id_token(void); static int multi_symbol_token(void); static void skip_comment(void); static void skip_hash_comment(void); static void backslash(char *); /* These for VA [Ash] */ int builtin_ft_check(char *); static char new_yytext[MAXTEXTLEN]; /* for distributed tkeden -- sun */ static void getAgentName(void); #ifdef DISTRIB static int setHighPrior = 0; /* Setting a higher priority (which doesn't work very well) - see the Tcl/Eden variable higherPriority in main.c [Ash] */ #endif /* DISTRIB */ /* app_char(c): put c into the yytext buffer and complain if it overflows [Ash] */ #define app_char(c) (yyleng>=MAXTEXTLEN?buffer_overflow():(yytext[yyleng++]=c)) /* input(): update nlstts from Inp_Dev, then basically set nextc=getc() [Ash] */ #ifdef TTYEDEN extern void nlstatus(void); #define input() (nlstatus(),app_char(nextc),nextc=keyin()) #else #define input() (app_char(nextc),nextc=keyin()) #endif /* TTYEDEN */ #define safe_input() (append_char(nextc),nextc=keyin()) #define unput(c) (pop_char(),ungetkey(c)) #define pop_char() --yyleng #define last_char yytext[yyleng-1] #define end_text1() yytext[yyleng]='\0' #define end_text() {accept_text(yytext,yyleng);yytext[yyleng]='\0';} #define clear_text() yyleng=0 #define accept_text(Text,Leng) if((indef||informula) && !inEVAL) push_text(Text,Leng) #define RETURN_TOKEN(T) {end_text(); return T;} Datum * makedatum(int type, uDatum value) { /* MAKE A NEW DATUM FOR CONSTANTS */ Datum *p; p = (Datum *) emalloc(sizeof(Datum)); p->type = type; p->u = value; return p; } static void append_char(int c) { if (yyleng >= MAXTEXTLEN - 1) { end_text(); clear_text(); } yytext[yyleng++] = c; } static int buffer_overflow(void) { error("input buffer overflow"); return 1; /* would not reach */ } /* init_lex: read in one character [Ash] */ void init_lex(void) { bof = 1; input(); } static int keyword_token(char *name) { /* Is name a keyword ? 0 = no; lexeme = yes) */ static struct keyword_table { /* Keywords */ char *name; int kval; } keywords[] = { #include "keyword.h" { 0, 0 } }; int i; for (i = 0; keywords[i].name; i++) { if (strcmp(name, keywords[i].name) == 0) return keywords[i].kval; } return 0; } /* When prefixing names with the agent name, we need to check whether a function to be prefixed is a built-in function or not. Built-in functions like writeln, propagate etc should not be prefixed with an agent name eg SUN, but user-defined functions should be prefixed. [Ash, with Patrick] */ int builtin_ft_check(char *name) /* --sun */ { /* Is name a builtin function ? 0 = no; 1 = yes) */ static struct builtinF_table { /* builtin or predefined functions */ char *name; } builtinFs[] = { #include "builtinf.h" { 0 } }; int i; for (i = 0; builtinFs[i].name; i++) { if (strcmp(name, builtinFs[i].name) == 0) return 1; } return 0; } static int number_token(void) { int i; double r; int m, n, e, is_float; char *format; int is_hex; uDatum u; is_float = m = n = e = FALSE; while (isdigit(nextc)) { input(); m = TRUE; } if (nextc == '.') { input(); is_float = TRUE; } while (isdigit(nextc)) { input(); n = TRUE; } if (is_float && !m && !n) /* a single dot */ return '.'; if (nextc == 'E' || nextc == 'e') { input(); is_float = TRUE; if (nextc == '+' || nextc == '-') input(); while (isdigit(nextc)) { input(); e = TRUE; } if (!e) error("Floating-point format error"); } if (is_float) { /* floating point */ end_text(); sscanf(yytext, "%lf", &r); u.r = r; yylval.dp = makedatum(REAL, u); return CONSTANT; } else if (*yytext == '0') {/* octal or hexdecimal */ is_hex = nextc == 'x' || nextc == 'X'; format = is_hex ? "%x" : "%o"; if (is_hex) { do { input(); /* read the 'x' */ } while (isxdigit(nextc)); } end_text(); sscanf((is_hex ? yytext + 2 : yytext), format, &i); u.i = i; yylval.dp = makedatum(INTEGER, u); return CONSTANT; } else { /* decimal */ end_text(); u.i = atoi(yytext); yylval.dp = makedatum(INTEGER, u); return CONSTANT; } } static int id_token(void) { extern symptr lookup(char *); extern symptr install(char *, int, int, int); extern int local_declare(char *); extern int lookup_local(char *); int i; symptr sp; char *tempyytext; while (isalnum(nextc) || nextc == '_') { input(); } end_text1(); /* printf("yytext %s", yytext); */ if ((i = keyword_token(yytext))) { /* keyword ? */ if (i==EVAL) inEVAL = 1; end_text(); return i; /* return the lexeme */ } if (inauto || inpara) { /* declaring local variables ? */ end_text(); yylval.narg = local_declare(yytext); return LOCAL; } else { /* in statements */ if ((i = lookup_local(yytext))) { /* local variable ? */ end_text(); if (i < 0) { /* it is an argument */ yylval.narg = -i; return ARG; } else { /* it is a local variable */ yylval.narg = i; return LOCAL; } } else { if (builtin_ft_check(yytext) == 0) { /* Don't append (pre or post) an agent name if: 1) if a built-in function, 2) if we're in the general context (no >> syntax etc used), 3) the definitions are from a Scout window definition, 4) similarly, if the definitions are from a Donald 'within' definition, 5) if the name already has a ~ prefix [Ash, with Patrick] */ /* printf("yytext1 = %s %s %i %i %i\n", yytext, agentName, appAgentName, append_agentName, append_NoAgentName); */ if (*agentName != 0 && appAgentName > 0 && append_agentName > 0 && append_NoAgentName > 0) { tempyytext = yytext; new_yytext[0] = '\0'; if (yytext[0] == '_' && inPrefix) { strcat(new_yytext, "_"); tempyytext++; } if (inPrefix) strcat(new_yytext, agentName); else strcat(new_yytext, tempyytext); strcat(new_yytext, "_"); if (inPrefix) strcat(new_yytext, tempyytext); else strcat(new_yytext, agentName); strcpy(yytext, new_yytext); yyleng = strlen(yytext); /* printf("agentName = %s \n", agentName); */ /* printf("yytext = %s \n", yytext); */ } } end_text(); if ((sp = lookup(yytext)) == 0) { /* must be global */ sp = install(yytext, VAR, UNDEF, 0); /* printf("new_yytext = %s", yytext); */ } #ifdef DISTRIB if (!strcmp(sp->name, "higherPriority")) setHighPrior=1; #endif /* DISTRIB */ yylval.sym = sp; return sp->stype; } } } static int multi_symbol_token(void) { static struct { char c1, c2; int token; } *tab, table[] = { { '+', '=', PLUS_EQ }, { '+', '+', PLUS_PLUS }, { '-', '=', MINUS_EQ }, { '-', '-', MINUS_MINUS }, { '/', '/', SLASH_SLASH }, { '=', '=', EQ_EQ }, { '!', '=', NOT_EQ }, { '~', '>', TILDE_GT }, { '>', '=', GT_EQ }, { '<', '=', LT_EQ }, { '&', '&', LAZY_AND }, { '|', '|', LAZY_OR }, { 0, 0, 0 } }; for (tab = table; tab->c1; tab++) { if (*yytext == tab->c1 && nextc == tab->c2) { input(); RETURN_TOKEN(tab->token); } } RETURN_TOKEN(*yytext); } static void skip_comment(void) { safe_input(); /* '/' has already skipped, skip '*' */ for (;;) { switch (nextc) { case '*': safe_input(); /* '*' */ if (nextc == '/') { safe_input(); /* skip '/' */ return; } break; case '/': safe_input(); /* skip '/' */ if (nextc == '*') { skip_comment(); } break; case 0: /* EOF */ error("unexpected end-of-file in comment"); return; default: safe_input(); } } } static int scoutScreenInitOpened = 0; /* Open the scout screen, but only if we haven't done it before */ void scoutScreenInitOpen(void) { /* Stop a second %scout reopening screen if the user closed it, and also stop re-entry into this function [Ash] */ if (scoutScreenInitOpened) return; scoutScreenInitOpened = 1; makearr(0); call(lookup("scoutScreenInitOpen"), pop(), 0); } static void skip_hash_comment(void) { #ifndef TTYEDEN char *s; Script *script; extern Script *st_script, *dd_script; extern int run(short, void *, char *); extern void dd_lex(int), st_lex(int); #ifdef WANT_SASAMI extern Script *sa_script; extern void sa_input(char); #endif /* WANT_SASAMI */ #ifdef DISTRIB extern void lsd_lex(int); #endif /* DISTRIB */ #endif /* not TTYEDEN */ int start = yyleng; safe_input(); /* skip '%' */ for (;;) { #ifndef TTYEDEN s = yytext + start; #endif /* not TTYEDEN */ switch (nextc) { case '\n': #ifndef TTYEDEN /* DoNaLD -------------------------------------------- */ if (strncmp(s, "%donald", 7) == 0) { changeNotation(DONALD); dd_script = script = newScript(); for (nextc = peek(); nextc != '\0'; nextc = peek()) { if (Inp_Dev->newline && (nextc == '%' || nextc == '>' || nextc == '<')) { if (nextc == '>' || nextc == '<') { input(); getAgentName(); } else { nextc = '\n'; if (script->text[0] != '\0') { appAgentName--; /* printf("from donald 1"); */ pushEntryStack(DONALD); run(STRING_DEV, script->text, 0); popEntryStack(); appAgentName++; } deleteScript(script); return; } /* end if (nextc == '>' || nextc == '<') */ } /* end if (Inp_Dev->newline...) */ else { dd_lex(keyin()); if (script->ready) { if (script->text[0] != '\0') { appAgentName--; /* printf("from donald 2"); */ pushEntryStack(DONALD); run(STRING_DEV, script->text, 0); dd_script = script; popEntryStack(); /* printf("from donald 3"); */ appAgentName++; } resetScript(script); } /* end if (script->ready) */ } /* end if (Inp_Dev->newline...) (two versions) */ } /* end for (nextc = peek()...) */ keyin(); /* read the null character */ dd_lex('\n'); /* treat end-of-file as end-of-line */ if (script->text[0] != '\0') { appAgentName--; pushEntryStack(DONALD); run(STRING_DEV, script->text, 0); popEntryStack(); /* printf("from donald 4"); */ appAgentName++; } deleteScript(script); } /* end if (strncmp(s, "%donald", 7) == 0) */ /* SCOUT -------------------------------------------- */ else if (strncmp(s, "%scout", 6) == 0) { /* is SCOUT */ scoutScreenInitOpen(); changeNotation(SCOUT); st_script = script = newScript(); for (nextc = peek(); nextc != '\0'; nextc = peek()) { if (Inp_Dev->newline && (nextc == '%' || nextc == '>' || nextc == '<')) { if (nextc == '>' || nextc == '<') { input(); getAgentName(); } else { nextc = '\n'; if (script->text[0] != '\0') { appAgentName--; /* printf("from scout 1"); */ pushEntryStack(SCOUT); run(STRING_DEV, script->text, 0); popEntryStack(); appAgentName++; } deleteScript(script); return; } } /* end if (Inp_Dev->newline...) */ else { st_lex(keyin()); if (script->ready) { if (script->text[0] != '\0') { appAgentName--; /* printf("from scout 2 %s\n", script->text); */ pushEntryStack(SCOUT); run(STRING_DEV, script->text, 0); st_script = script; popEntryStack(); appAgentName++; } resetScript(script); } } } /* end for (nextc = peek();... */ keyin(); /* read the null character */ st_lex('\n'); /* treat end-of-file as end-of-line */ if (script->text[0] != '\0') { appAgentName--; pushEntryStack(SCOUT); run(STRING_DEV, script->text, 0); popEntryStack(); appAgentName++; } deleteScript(script); } /* end if (strncmp(s, "%scout", 6)... */ #ifdef WANT_SASAMI /* Sasami -------------------------------------------- */ else if (strncmp(s, "%sasami", 7) == 0) { changeNotation(SASAMI); sa_script = script = newScript(); for (nextc = peek(); nextc != '\0'; nextc = peek()) { if (Inp_Dev->newline && (nextc == '%' || nextc == '>' || nextc == '<')) { // This is a %, > or < statement and shouldn't be passed to Sasami if (nextc == '>' || nextc == '<') { input(); getAgentName(); } else { nextc = '\n'; if (script->text[0] != '\0') { appAgentName--; /* printf("from sasami 1"); */ pushEntryStack(SASAMI); run(STRING_DEV, script->text, 0); popEntryStack(); appAgentName++; } deleteScript(script); return; } } else { // This must be something worth sending to Sasami sa_input(keyin()); // Now run the EDEN script that Sasami's produced (if there is one) if (script->ready) { if (script->text[0] != '\0') { appAgentName--; /* printf("from sasami 2"); */ pushEntryStack(SASAMI); run(STRING_DEV, script->text, 0); sa_script = script; popEntryStack(); /* printf("from sasami 3"); */ appAgentName++; } resetScript(script); } } } // OK - finished with the input, so send an EOL to make sure that // the parser runs the last input line, and exit. keyin(); /* read the null character */ sa_input('\n'); /* treat end-of-file as end-of-line */ if (script->text[0] != '\0') { appAgentName--; pushEntryStack(SASAMI); run(STRING_DEV, script->text, 0); popEntryStack(); /* printf("from sasami 4"); */ appAgentName++; } deleteScript(script); } /* end if (strncmp(s, "%sasami", 7) == 0) */ #endif /* WANT_SASAMI */ #ifdef DISTRIB /* LSD -------------------------------------------- */ else if (strncmp(s, "%lsd", 4) == 0) { changeNotation(LSD); for (nextc = peek(); nextc != '\0'; nextc = peek()) { if (Inp_Dev->newline && (nextc == '%' || nextc == '>' || nextc == '<')) { if (nextc == '>' || nextc == '<') { input(); getAgentName(); } else { nextc = '\n'; return; } } else { lsd_lex(keyin()); } } keyin(); /* read the null character */ lsd_lex('\n'); /* treat end-of-file as end-of-line */ } /* end if (strncmp(s, "%lsd", 4)... */ #endif /* DISTRIB */ /* Push entry -------------------------------------------- */ else if (s[1] == '+') { /* appAgentName=0; */ if (strncmp(s + 2, "donald", 6) == 0) { /* is DoNaLD */ pushEntryStack(DONALD); } else if (strncmp(s + 2, "scout", 5) == 0) { /* is SCOUT */ pushEntryStack(SCOUT); } else if (strncmp(s + 2, "eden", 4) == 0) { /* is EDEN */ pushEntryStack(EDEN); #ifdef WANT_SASAMI } else if (strncmp(s + 2, "sasami", 6) == 0) { /* is Sasami */ pushEntryStack(SASAMI); #endif /* WANT_SASAMI */ } } /* end if (s[1] == '+') */ /* Pop entry -------------------------------------------- */ else if (s[1] == '-') { if (strncmp(s + 2, "donald", 6) == 0 /* is DoNaLD */ || strncmp(s + 2, "scout", 5) == 0 /* is SCOUT */ #ifdef WANT_SASAMI || strncmp(s + 2, "sasami", 6) == 0 /* is Sasami */ #endif || strncmp(s + 2, "eden", 4) == 0) { /* is EDEN */ popEntryStack(); /* appAgentName=1; */ } } /* end if (s[1] == '-') */ /* Eden -------------------------------------------- */ else { changeNotation(EDEN); } #endif /* end not TTYEDEN */ return; case 0: /* EOF */ #ifndef TTYEDEN if (strncmp(s, "%donald", 7) == 0) { /* is DoNaLD */ changeNotation(DONALD); } else if (strncmp(s, "%scout", 6) == 0) { /* is SCOUT */ changeNotation(SCOUT); #ifdef WANT_SASAMI } else if (strncmp(s, "%sasami", 7) == 0) { /* is Sasami */ changeNotation(SASAMI); #endif /* WANT_SASAMI */ } else { /* is EDEN */ changeNotation(EDEN); } #endif return; default: safe_input(); } } } static void backslash(char *text) { /* interpret backslashs in a string */ int i, n; char *s = text; static char transtab[] = "b\bf\fn\nr\rt\t"; while (*s) { if (*s == '\\') { s++; if (isdigit(*s)) { for (n = 3, i = 0; n && isdigit(*s); --n, s++) i = (i << 3) | (*s - '0'); *text++ = i; } else if (islower(*s) && strchr(transtab, *s)) *text++ = strchr(transtab, *s++)[1]; else *text++ = *s++; } else { *text++ = *s++; } } *text = '\0'; } int yylex(void) { char *s; uDatum u; #ifdef DISTRIB extern Int *higherPriority; #endif /* DISTRIB */ /* initial for a token */ clear_text(); if (bof) { bof = 0; if (nextc == '%') { /* comment line */ skip_hash_comment();/* return next token */ end_text(); clear_text(); } /* printf("bof \n"); */ if (nextc == '>' || nextc == '<') getAgentName(); } restart: while (isspace(nextc) && nextc != '\n') /* skip blanks */ input(); if (nextc == '\n') { input(); if (nextc == '%') { /* comment line */ skip_hash_comment();/* return next token */ end_text(); clear_text(); } /* printf("restart\n"); */ if (nextc == '>' || nextc == '<') getAgentName(); goto restart; } end_text(); clear_text(); if (nextc == 0) { /* EOF */ #ifdef DISTRIB if (setHighPrior) { *higherPriority=0; setHighPrior = 0; } #endif return 0; /* don't do input() so next token is EOF */ } #ifdef TTYEDEN prompt = prompt2; #endif if (isdigit(nextc) || nextc == '.') /* a number or a dot */ return number_token(); if (isalpha(nextc) || nextc == '_') /* a keyword or an identifier */ { append_agentName = 1; return id_token(); } if (nextc == '\'') { while (input(), nextc != '\'') { if (nextc == '\\') input(); else if (nextc == 0) error("unexpected end-of-file in character constant"); } input(); /* read the quote */ /* mustn't alter the following two lines */ end_text(); /* accept the text */ last_char = '\0'; /* delete the last quote */ backslash(yytext + 1); /* resolve the backslashs */ if (yytext[2]) /* more than one char */ error("single char expected"); u.i = yytext[1]; yylval.dp = makedatum(MYCHAR, u); return CONSTANT; } if (nextc == '\"') { while (input(), nextc != '\"') { if (nextc == '\\') input(); else if (nextc == 0) error("unexpected end-of-file in string constant"); } input(); /* read the quote */ /* mustn't alter the following two lines */ end_text(); /* accept the text */ last_char = '\0'; /* delete the last quote */ backslash(yytext + 1); /* resolve the backslashs */ s = (char *) emalloc(strlen(yytext)); strcpy(s, yytext + 1); u.s = s; yylval.dp = makedatum(STRING, u); return CONSTANT; } input(); /* accept the char, must be the 1st char */ switch (*yytext) { /* the 1st char */ case '@': yylval.dp = makedatum(UNDEF, u); /* bug fix Ash + Carters */ RETURN_TOKEN(CONSTANT); break; case '~': /* for agency --sun */ if (isalpha(nextc) || nextc == '_') { clear_text(); append_agentName = 0; return id_token(); } break; case '$': while (isdigit(nextc)) input(); if (yyleng == 1) RETURN_TOKEN('$'); yylval.narg = atoi(yytext + 1); RETURN_TOKEN(ARG); case '/': if (nextc == '*') { /* nested comment */ skip_comment(); /* return next token */ end_text(); clear_text(); goto restart; } break; } return (multi_symbol_token()); } int peek(void) { /* READ A CHAR FROM INPUT DEVICE */ int c; FILE *filein; switch (Inp_Dev->type) { case FILE_DEV: if (Inp_Dev->sptr > Inp_Dev->sbuf) c = *--(Inp_Dev->sptr); else { filein = (FILE *) Inp_Dev->ptr; ungetc(c = getc(filein), filein); if (c == EOF) c = 0; } break; case STRING_DEV: c = *(Inp_Dev->ptr); break; } return c; } #if defined(TTYEDEN) && defined(HAVE_READLINE) /* rl_gets is taken straight from the readline info manual [Ash] */ static char *line_read = (char *)NULL; /* Read a string, and return a pointer to it. Returns NULL on EOF. */ char * rl_gets () { char *fullPrompt; extern int interactive; /* If the buffer has already been allocated, return the memory to the free pool. */ if (line_read) { free (line_read); line_read = (char *)NULL; } /* Get a line from the user. */ if (interactive) { fullPrompt = emalloc(10); sprintf(fullPrompt, "%d%s", Inp_Dev->lineno + 1, prompt); line_read = readline(fullPrompt); free(fullPrompt); } else { line_read = readline(""); } /* If the line has any text in it, save it on the history. */ if (line_read && *line_read) add_history (line_read); return (line_read); } /* Simulate a call to getc(stdin), but actually call rl_gets whenever necessary to use readline instead. Like getc(stdin), EOF is returned if Ctrl-D is pressed, and \n is returned at the end of each line. [Ash] */ static int getc_require_new_readline = 1; static char *getc_ptr = (char *)NULL; int rl_getc_wrapper() { if (getc_require_new_readline) { getc_ptr = rl_gets(); } if (getc_ptr == (char *)NULL) return EOF; if (*getc_ptr == '\0') { getc_require_new_readline = 1; *getc_ptr = '\n'; } else getc_require_new_readline = 0; return *getc_ptr++; } int rl_getc_wouldBlock() { if (getc_ptr == (char *)NULL) return 0; if (*getc_ptr == '\0') return 1; else return 0; } #endif /* TTYEDEN && HAVE_READLINE */ int keyin(void) { /* READ A CHAR FROM INPUT DEVICE */ int c; FILE *filein; #ifdef TTYEDEN extern int preprinted; extern void print_prompt(void); #endif switch (Inp_Dev->type) { case FILE_DEV: /* There was some code here that formed a special value for c if Inp_Dev->sptr > Inp_Dev->sbuf, but I don't see how that would ever be reached. [Ash] */ assert(Inp_Dev->sptr <= Inp_Dev->sbuf); filein = (FILE *) Inp_Dev->ptr; #ifdef TTYEDEN if (Inp_Dev->newline && filein == stdin) if (preprinted) preprinted = FALSE; else print_prompt(); #ifdef HAVE_READLINE if (filein == stdin) c = rl_getc_wrapper(); else #endif /* HAVE_READLINE */ c = getc(filein); #else /* not TTYEDEN */ c = getc(filein); #endif if (c == EOF) c = 0; break; case STRING_DEV: c = *(Inp_Dev->ptr)++; break; } if (Inp_Dev->newline) { /* this is a /character after/ newline */ Inp_Dev->lineno++; Inp_Dev->charno = 0; } Inp_Dev->linebuf[Inp_Dev->charno++] = c; Inp_Dev->linebuf[Inp_Dev->charno] = '\0'; /* keep the string terminated */ Inp_Dev->newline = (c == '\n'); return c; } /* Read the rest of the line into linebuf so we can print it all in an error condition [Ash] */ void flushRestOfLine(void) { FILE *filein; int c = 'a'; int endoflinecharno; extern int wouldBlock(void); endoflinecharno = Inp_Dev->charno; if (Inp_Dev->newline) { Inp_Dev->linebuf[endoflinecharno-1] = '\0'; /* clear the unwanted \n */ return; /* already have the complete line */ } /* This case can occur if tkeden is interrupted with ctrl-c */ if (!(Inp_Dev->ptr)) return; /* This wouldBlock stuff might be invalidated by the above newline logic, I'm not sure. I'll leave it in anyway. [Ash] */ if (Inp_Dev->type == FILE_DEV) { filein = (FILE *) Inp_Dev->ptr; /* if the whole line has already been read in, then doing a getc() would cause a block */ if (filein == stdin) { #if defined(TTYEDEN) && defined(HAVE_READLINE) if (rl_getc_wouldBlock()) return; #else if (wouldBlock()) return; #endif } } while (isprint(c) && (endoflinecharno < MAXBUF)) { switch (Inp_Dev->type) { case FILE_DEV: #ifdef TTYEDEN #ifdef HAVE_READLINE if (filein == stdin) c = rl_getc_wrapper(); else #endif /* HAVE_READLINE */ c = getc(filein); #else c = getc(filein); #endif break; case STRING_DEV: c = *(Inp_Dev->ptr)++; break; } Inp_Dev->linebuf[endoflinecharno++] = c; } /* Last character read was invalid */ Inp_Dev->linebuf[endoflinecharno-1] = '\0'; } /* For VA [Ash, with Patrick] */ static void getAgentName(void) { extern symptr lookup(char *); symptr sp; char secondC, firstC; *agentType = '\0'; if ((firstC = nextc) == '>') inPrefix = 1; else inPrefix = 0; agentType[0] = firstC; input(); /* skip second '>' */ secondC = nextc; agentType[1] = secondC; agentType[2] = '\0'; input(); clear_text(); while (isalnum(nextc) || nextc == '_') input(); end_text1(); *agentName = '\0'; /* printf("secondc = %c \n", secondC); */ if (yytext[0] == '\0') { #ifndef TTYEDEN /* Show the agent name on the interface [Ash] */ Tcl_VarEval(interp, ".agentName config -text {}", 0); #endif clear_text(); return; } if (secondC=='>' || secondC=='~') { /* printf("getagentName = %s \n", yytext); */ strcpy(agentName, yytext); #ifndef TTYEDEN Tcl_VarEval(interp, ".agentName config -text {current agent: ", agentName, "}", 0); #endif /*strcat(agentName, "_");*/ clear_text(); if (secondC=='~') append_NoAgentName = 0; else append_NoAgentName = 1; return; } if (secondC=='<') { append_NoAgentName = 1; if ((sp = lookup(yytext)) == 0) { #ifndef TTYEDEN Tcl_VarEval(interp, ".agentName config -text {}", 0); #endif clear_text(); return; } else { switch(sp->d.type) { case INTEGER: sprintf(agentName, "%d", sp->d.u.i); break; case MYCHAR: sprintf(agentName, "%c", sp->d.u.i); break; case STRING: sprintf(agentName, "%s", sp->d.u.s); break; default: error2("expecting string, char or integer for virtual agent", sp->name); } /* printf("getagentName = %s \n", sp->d.u.s); */ /* strcpy(agentName, sp->d.u.s); */ #ifndef TTYEDEN Tcl_VarEval(interp, ".agentName config -text {current agent: ", agentName, "}", 0); #endif /*strcat(agentName, "_");*/ clear_text(); return; } } } tkeden1.18/Eden/keyword.h010060000025250000147000000012410730673753400165730ustar00ashleydcsother00003470000356/* * $Id: keyword.h,v 1.4 1999/11/16 21:20:40 ashley Rel1.10 $ * * keyword translation table * */ { "auto", AUTO }, { "para", PARA }, { "return", RETURN }, { "break", BREAK }, { "continue", CONTINUE}, { "if", IF }, { "else", ELSE }, { "do", DO }, { "while", WHILE }, { "for", FOR }, { "switch", SWITCH }, { "case", CASE }, { "default", DEFAULT }, { "shift", SHIFT }, { "append", APPEND }, { "insert", INSERT }, { "delete", DELETE }, { "func", FUNC }, { "proc", PROC }, { "procmacro", PMAC /* PROCMACRO is the type */ }, { "is", IS }, { "and", AND }, { "or", OR }, { "not", NOT }, { "eval", EVAL }, { "bitand", BITAND }, { "bitor", BITOR }, tkeden1.18/Eden/inst.h010060000025250000147000000037520730674005400160640ustar00ashleydcsother00003470000356/* * $Id: inst.h,v 1.7 1999/11/16 21:20:40 ashley Rel1.10 $ */ /* This file defines C functions that can be used as Eden VM opcodes: ie function pointers to them can be coded into the prog array and they can be invoked by execute() or from somewhere else by a function pointer dereference. This file gets included from eden.h, when INCLUDE should be set to 'H' for Header, and from code.c if DEBUG is defined, for use in the disAss function, when INCLUDE should be set to 'T' to Table. [Ash] */ #if INCLUDE == 'H' #define INSTFUNC(name)extern void name(void); #elif INCLUDE == 'T' #ifdef __STDC__ #define INSTFUNC(name){#name, name}, #else /* not __STDC__... */ #define INSTFUNC(name){"name", name}, #endif #else #error Wrong value for preprocessor INCLUDE #endif /* These opcodes are defined in machine.c */ INSTFUNC(add) INSTFUNC(sub) INSTFUNC(mul) INSTFUNC(divide) INSTFUNC(mod) INSTFUNC(negate) INSTFUNC(lazy_not) INSTFUNC(not) INSTFUNC(concat) INSTFUNC(jmp) INSTFUNC(jpt) INSTFUNC(jpf) INSTFUNC(jpnt) INSTFUNC(jpnf) INSTFUNC(and) INSTFUNC(or) INSTFUNC(ddup) INSTFUNC(popd) INSTFUNC(pushUNDEF) INSTFUNC(pushint) INSTFUNC(constpush) INSTFUNC(cnv_2_bool) INSTFUNC(gt) INSTFUNC(lt) INSTFUNC(ge) INSTFUNC(le) INSTFUNC(eq) INSTFUNC(ne) INSTFUNC(switchcode) INSTFUNC(definition) INSTFUNC(definition_runtimelhs) INSTFUNC(assign) INSTFUNC(inc_asgn) INSTFUNC(dec_asgn) INSTFUNC(pre_inc) INSTFUNC(post_inc) INSTFUNC(pre_dec) INSTFUNC(post_dec) INSTFUNC(noupdate) INSTFUNC(resetupdate) INSTFUNC(addr) INSTFUNC(lookup_address) INSTFUNC(localaddr) INSTFUNC(indexcalc) INSTFUNC(makelist) INSTFUNC(getvalue) INSTFUNC(sel) INSTFUNC(listsize) INSTFUNC(shift) INSTFUNC(append) INSTFUNC(insert) INSTFUNC(delete) INSTFUNC(query) INSTFUNC(bitand) INSTFUNC(bitor) /* ... end machine.c */ /* this is defined in eval.c */ INSTFUNC(eager) /* this is defined in heap.c */ INSTFUNC(freeheap) /* these are defined in code.c */ INSTFUNC(eval) INSTFUNC(related_by_code) INSTFUNC(related_by_code_runtimelhs) #undef INSTFUNC tkeden1.18/Eden/input_device.h010060000025250000147000000020250727477250200175640ustar00ashleydcsother00003470000356/* * $Id: input_device.h,v 1.4 1999/11/16 21:20:40 ashley Rel1.10 $ */ #define MAXBUF 256 struct input_device { /* INPUT DEVICE */ char *name; /* FILE NAME */ short type; /* DEVICE TYPE: FILE / STRING */ char *ptr; /* FILE-PTR / MYCHAR-PTR */ char sbuf[MAXBUF]; /* I/O BUFFER (seems unused for files [Ash])*/ char *sptr; /* BUFFER PTR */ char newline; /* NEWLINE READ ? */ int lineno; /* LINE NUMBER */ int charno; /* CHARACTER NUMBER (FOR ERROR MESSAGES) [Ash] */ int lastc; /* THE FORWARD MYCHAR OF LAST DEVICE */ char linebuf[MAXBUF];/* BUFFER TO HOLD THE CURRENT LINE (FOR ERROR MESSAGES) [Ash] */ Frame *frame; /* FRAME */ jmp_buf begin; /* RESUME POINT WHEN ERROR OCCURRED */ } Input_Devices[16]; /* 15 LEVELS OF INPUT */ extern struct input_device *Inp_Dev; tkeden1.18/Eden/heap.c010060000025250000147000000042020731245645000160070ustar00ashleydcsother00003470000356/* * $Id: heap.c,v 1.9 1999/11/16 21:20:40 ashley Rel1.10 $ */ static char rcsid[] = "$Id: heap.c,v 1.9 1999/11/16 21:20:40 ashley Rel1.10 $"; /*** * HEAP MEMORY MANAGER * ***/ #include "../config.h" #include "eden.h" #include #ifdef DEBUG #define DEBUGPRINT(s,t) {if(Debug&1)fprintf(stderr,s,t);} #else #define DEBUGPRINT(s,t) #endif char heap[HEAPSIZE]; char *hptr; /* function prototypes */ char *getheap(int); void freeheap(void); #define heap_overflow(p) ((p)>=&heap[HEAPSIZE]) /* Note that freeheap must be called before getheap is ever called, or else hptr will be uninitialised. [Ash] */ char * getheap(int size) { /* allocate memory from heap */ char *p; DEBUGPRINT("HEAPAL getheap(%d)\n", size); /* printf("ASH: getheap(%d). hptr currently=0x%x\n", size, hptr); */ if (heap_overflow(hptr + size)) error("heap overflow"); p = hptr; hptr = hptr + size; /* printf("ASH: hptr now=0x%x\n", hptr); */ /* Ensure the pointer is correctly aligned, so that the next allocated block does not cause an unaligned access when the data is accessed [Ash] */ if (((int) hptr & (DOUBLE_ALIGNMENT-1)) != 0) { hptr += DOUBLE_ALIGNMENT - ((int) hptr & (DOUBLE_ALIGNMENT-1)); /* printf("ASH: Corrected hptr=0x%x\n", hptr); */ } /* * sy's old version: * * #ifdef __GNUC__ * GCC requires double values on 8-byte boundaries on a Sparc * hptr += ((((int) hptr & 7) == 0) ? 0 : 8 - ((int) hptr & 7)); * #else * 4-byte boundaries alignment is enough for CC * hptr += ((((int) hptr & 3) == 0) ? 0 : 4 - ((int) hptr & 3)); * #endif */ return p; } void freeheap(void) { /* free heap by resetting the heap ptr */ DEBUGPRINT("VMOPER|HEAPAL freeheap ", 0); DEBUGPRINT("start hptr=0x%x ", hptr); if (fp == frame) hptr = heap; else hptr = fp->hptr; if (((int) hptr & (DOUBLE_ALIGNMENT-1)) != 0) { hptr += DOUBLE_ALIGNMENT - ((int) hptr & (DOUBLE_ALIGNMENT-1)); } DEBUGPRINT("end hptr=0x%x\n", hptr); } tkeden1.18/Eden/hash.h010060000025250000147000000001670727406555400160400ustar00ashleydcsother00003470000356/* * $Id: hash.h,v 1.3 1999/11/16 21:20:40 ashley Rel1.10 $ */ #define HASHSIZE 127 /* 1 smaller than power of 2 */ tkeden1.18/Eden/global.q.h010060000025250000147000000024100731245606600166000ustar00ashleydcsother00003470000356/* * $Id: global.q.h,v 1.6 1999/11/16 15:38:42 ashley Rel1.10 $ */ #ifndef _GLOBAL_Q_H #include "emalloc.h" struct eden_queue { struct eden_queue *prev; struct eden_queue *next; void *obj; /* dummy */ }; typedef struct eden_queue QUEUE; /* This is how this seems to be organised: - items are added to the head of the queue - the head of the queue can be found at *(Q->next) - the end of the queue is detected by (A->next) == Q [Ash] */ #define EMPTYQUEUE(Q) {&Q, &Q} #define CLEAN_Q(Q) ((Q)->prev=(Q)->next=(Q)) #define Q_EMPTY(Q) ((Q)->next==(Q)) #define DELETE_ATOM(Q,A) \ (((A)->prev->next=(A)->next)->prev=(A)->prev,(A)->prev=(A)->next=0) #define INSERT_ATOM(Q,A) \ ((((A)->prev=((A)->next=(Q))->prev)->next=(A)),(Q)->prev=(A)) #define APPEND_ATOM(Q,A) \ ((((A)->next=((A)->prev=(Q))->next)->prev=(A)),(Q)->next=(A)) #define APPEND_Q(Q,A) INSERT_ATOM(Q,A) #define INSERT_Q(Q,A) APPEND_ATOM(Q,A) #define NEXT(Q,A) ((Q)==(A)->next?0:(A)->next) #define PREV(Q,A) ((Q)==(A)->prev?0:(A)->prev) #define FRONT(Q) NEXT(Q,Q) #define LAST(Q) PREV(Q,Q) #define ALLOC_ATOM(A) (A=emalloc(sizeof(*A))) #define FOREACH(A,Q) for(A=FRONT(Q);A;A=NEXT(Q,A)) extern int Q_LEN(QUEUE *); extern QUEUE *WHERE_IS(QUEUE *, int); #define _GLOBAL_Q_H #endif tkeden1.18/Eden/global.q.c010060000025250000147000000010330731245670000165660ustar00ashleydcsother00003470000356/* * $Id: global.q.c,v 1.7 1999/11/16 21:20:40 ashley Rel1.10 $ */ static char rcsid2[] = "$Id: global.q.c,v 1.7 1999/11/16 21:20:40 ashley Rel1.10 $"; #include "../config.h" #include "global.q.h" /* function prototypes */ int Q_LEN(QUEUE *); QUEUE *WHERE_IS(QUEUE *, int); int Q_LEN(QUEUE * Q) { int count = 0; QUEUE *P; FOREACH(P, Q) count++; return count; } QUEUE * WHERE_IS(QUEUE * Q, int n) { QUEUE *P; for (P = FRONT(Q); P && --n; P = NEXT(Q, P)); return P; } tkeden1.18/Eden/eval.c010060000025250000147000000165200731245665200160330ustar00ashleydcsother00003470000356/* * $Id: eval.c,v 1.9 1999/11/16 21:20:40 ashley Rel1.10 $ */ static char rcsid[] = "$Id: eval.c,v 1.9 1999/11/16 21:20:40 ashley Rel1.10 $"; #include #include "../config.h" #include "eden.h" #include "yacc.h" #ifdef DEBUG #define DEBUGPRINT(s,t) if (Debug&1)fprintf(stderr,s,t); #define DEBUGPRINT2(s,t,u) if (Debug&1)fprintf(stderr,s,t,u); #else #define DEBUGPRINT(s,t) #define DEBUGPRINT2(s,t,u) #endif /* for debugging only */ #define print_action_list() {\ extern void action_list();\ action_list();\ print(pop(),stderr);\ printf("\n");\ } #define address(sp) { Datum d; d.type = SYMBOL | DPTR; d.u.v.x = (Int) &sp->d; d.u.v.y = (Int) sp; push(d); } symptr_QUEUE formula_queue = EMPTYQUEUE(formula_queue); symptr_QUEUE action_queue = EMPTYQUEUE(action_queue); /* function prototypes */ static void schedule(symptr); void schedule_parents_of(symptr); void resetLock(void); void eval_formula_queue(void); void invoke_action_queue(void); void eager(void); void change(symptr, int); void mark_changed(symptr); void formula_list(void); void action_list(void); void reset_eval(void); static void schedule(symptr sp) { register symptr_ATOM P; register symptr_QUEUE *Q; #ifdef DISTRIB extern Int *synchronize; #endif /* DISTRIB */ switch (sp->stype) { case FORMULA: DEBUGPRINT("FQUEUE schedule %s\n", sp->name); Q = &formula_queue; break; case BLTIN: case PROCEDURE: case FUNCTION: case PROCMACRO: DEBUGPRINT("AQUEUE schedule %s\n", sp->name); Q = &action_queue; break; default: /* If VAR, for example */ DEBUGPRINT2("schedule: not scheduling %s %s\n", typename(sp->stype), sp->name); return; /* don't queue up */ } /* if (P = SEARCH_symptr(Q, sp, 1)) { */ #ifdef DISTRIB if ((P = sp->Qloc) && !*synchronize) { /* This may raise a problem in a distributed or synchronized environment, because some information will be missed. For example, if we want to make a train move smoothly, we need to show every slight move. But this reschedule may make previous movements disappear. So we take synchronization into account --sun */ #else if ((P = sp->Qloc)) { #endif /* not DISTRIB */ /* Already there --> reschedule */ DELETE_ATOM(Q, P); APPEND_Q(Q, P); } else { /* Not there --> put it at the end */ switch (sp->stype) { case FORMULA: APPEND_symptr_Q(Q, sp); sp->Qloc = Q->prev; break; case BLTIN: case PROCEDURE: case PROCMACRO: case FUNCTION: /* if it's an action */ if (!Q_EMPTY(&sp->sources)) { APPEND_symptr_Q(Q, sp); sp->Qloc = Q->prev; } break; } } } /*----------------------------------------------** ** queue up all formulae and actions ** ** which depends on v ** **----------------------------------------------*/ void schedule_parents_of(symptr v) { /* builtin function */ register symptr_ATOM P; register symptr_QUEUE *Q; Q = &v->targets; FOREACH(P, Q) { mark_changed(P->obj); schedule(P->obj); } } static int lock = FALSE; /* prevent nested eval & invoke of formula and action */ /* resetLock status after error */ void resetLock(void) { DEBUGPRINT("MCSTAT resetLock\n", 0); lock = FALSE; } / evaluate all formulae in the formula queue / void eval_formula_queue(void) { /* internal */ extern void update(symptr); extern int ready(symptr); register symptr_QUEUE *Q; register symptr sp; #ifdef DISTRIB extern int triggeredAction; #endif /* DISTRIB */ if (lock) return; lock = TRUE; Q = &formula_queue; DEBUGPRINT("MCSTAT|FQUEUE|SYMTBL|AQUEUE eval_formula_queue\n", 0); while (!Q_EMPTY(Q)) { sp = FRONT(Q)->obj; DELETE_FRONT_symptr(Q); sp->Qloc = 0; if (sp->changed) { if (ready(sp)) { DEBUGPRINT("eval_formula_queue: formula %s changed and ready: evaluating it\n", sp->name); /* evaluate the formula */ #ifdef DISTRIB triggeredAction = 1; #endif /* DISTRIB */ update(sp); #ifdef DISTRIB triggeredAction = 0; #endif /* DISTRIB */ } else { DEBUGPRINT("eval_formula_queue: formula %s not ready: not evaluating it\n", sp->name); } } else { DEBUGPRINT("eval_formula_queue: formula %s not changed: not evaluating it\n", sp->name); } } lock = FALSE; if (!Q_EMPTY(&action_queue)) invoke_action_queue(); } / invoke all actions in the action queue / void invoke_action_queue(void) { /* internal */ extern void call(symptr, Datum, char *); extern int ready(symptr); register symptr_QUEUE *Q; register symptr sp; Datum d; if (lock) return; lock = TRUE; Q = &action_queue; DEBUGPRINT("MCSTAT|AQUEUE|DATSTK|FQUEUE invoke_action_queue\n", 0); while (!Q_EMPTY(Q)) { sp = FRONT(Q)->obj; DELETE_FRONT_symptr(Q); sp->Qloc = 0; if (ready(sp)) { DEBUGPRINT("invoke_action_queue: invoke action %s\n", sp->name); makearr(0); d = pop(); /* creat null arguments */ call(sp, d, sp->name); /* invoke action */ popd(); /* drop the value returned */ /* eval_formula_queue(); */ } else { DEBUGPRINT("invoke_action_queue: action %s not invoked\n", sp->name); } } lock = FALSE; if (!Q_EMPTY(&formula_queue)) eval_formula_queue(); } /* eager(): force formula and action queue to evaluate (unless autocalc off) */ #ifndef TTYEDEN #include extern Tcl_Interp *interp; #endif void eager(void) { /* builtin C function */ int lockvalue; DEBUGPRINT("VMOPER|MCSTAT|FQUEUE eager\n", 0); lockvalue = lock; lock = FALSE; eval_formula_queue(); lock = lockvalue; #ifndef TTYEDEN Tcl_EvalEC(interp, "update"); #endif } /* change(): put `sp' in schedule and if `autocalc' is enabled evaluate it */ void change(symptr sp, int flag) { extern Int *autocalc; register Inst *savepc; DEBUGPRINT2("SYMTBL|FQUEUE|VMEXEC change %s->changed = %d)\n", sp->name, flag); sp->changed = flag; schedule(sp); schedule_parents_of(sp); if (*autocalc) { savepc = pc; eval_formula_queue(); /* invoke_action_queue(); */ pc = savepc; } } void mark_changed(symptr sp) { register symptr_QUEUE *P, *Q; DEBUGPRINT("SYMTBL mark_changed(%s)\n", sp->name); if (!sp->changed) { /* not already marked */ sp->changed = TRUE; Q = &sp->targets; FOREACH(P, Q) mark_changed(P->obj); } } /* convert formula-queue to a list of pointers */ void formula_list(void) { /* builtin function */ register int count; register symptr_ATOM P; register symptr_QUEUE *Q; count = 0; Q = &formula_queue; FOREACH(P, Q) { address(P->obj); count++; } makearr(count); } /* convert action-queue to a list of pointers */ void action_list(void) { /* builtin function */ register symptr_ATOM P; register symptr_QUEUE *Q; register int count; count = 0; Q = &action_queue; FOREACH(P, Q) { address(P->obj); count++; } makearr(count); } void reset_eval(void) { register symptr_ATOM P; register symptr_QUEUE *Q; DEBUGPRINT("MCSTAT|FQUEUE|AQUEUE reset_eval\n", 0); lock = FALSE; Q = &formula_queue; FOREACH(P, Q) { P->obj->Qloc = 0; } CLEAR_symptr_Q(&formula_queue); Q = &action_queue; FOREACH(P, Q) { P->obj->Qloc = 0; } CLEAR_symptr_Q(&action_queue); } tkeden1.18/Eden/entry.q.h010060000025250000147000000027570731245767400165250ustar00ashleydcsother00003470000356/* * $Id: entry.q.h,v 1.5 1999/11/16 21:20:40 ashley Rel1.10 $ */ #include "global.q.h" #ifndef _ENTRY_Q_H struct entry_queue { struct entry_queue *prev; struct entry_queue *next; entry obj; }; typedef struct entry_queue entry_QUEUE; typedef entry_QUEUE *entry_ATOM; extern entry_QUEUE *SEARCH_entry(entry_QUEUE *, entry, int); extern void DELETE_entry_ATOM(entry_QUEUE *, entry_ATOM); extern void MOVE_entry_Q(entry_QUEUE *, entry_QUEUE *); #ifndef NEW_entry #define NEW_entry(OBJ) OBJ #endif #ifndef FREE_entry #define FREE_entry(OBJ) /* do nothing */ #endif #ifndef EQUAL_entry #define EQUAL_entry(A,B) ((A)==(B)) #endif #define DESTROY_entry_ATOM(A) \ { \ FREE_entry((A)->obj); \ free(A); \ } #define DELETE_NTH_entry(Q,OBJ,n) DELETE_entry_ATOM(Q,SEARCH_entry(Q,OBJ,n)) #define DELETE_FIRST_entry(Q,OBJ) DELETE_entry_ATOM(Q,SEARCH_entry(Q,OBJ,1)) #define DELETE_FRONT_entry(Q) DELETE_entry_ATOM(Q,FRONT(Q)) #define DELETE_LAST_entry(Q) DELETE_entry_ATOM(Q,LAST(Q)) #define CLEAR_entry_Q(Q) \ while (!Q_EMPTY(Q)) DELETE_entry_ATOM(Q,(Q)->next) #define APPEND_entry_Q(Q,OBJ) \ { \ entry_ATOM A; \ ALLOC_ATOM(A); \ A->obj = NEW_entry(OBJ); \ APPEND_Q(Q,A); \ } #define INSERT_entry_Q(Q,OBJ) \ { \ entry_ATOM A; \ ALLOC_ATOM(A); \ A->obj = NEW_entry(OBJ); \ INSERT_Q(Q,A); \ } #define CONCAT_entry_Q(Qdst, Qsrc) \ { \ entry_QUEUE *P; \ FOREACH (P, Qsrc) APPEND_entry_Q(Qdst, P->obj); \ } #define IN_entry_Q(Q,OBJ) SEARCH_entry(Q,OBJ,1) #define _ENTRY_Q_H #endif tkeden1.18/Eden/entry.q.c010060000025250000147000000020250731245662600165000ustar00ashleydcsother00003470000356/* * $Id: entry.q.c,v 1.9 1999/11/16 21:20:40 ashley Rel1.10 $ */ static char rcsid4[] = "$Id: entry.q.c,v 1.9 1999/11/16 21:20:40 ashley Rel1.10 $"; #include "../config.h" #include "entry.q.h" /* function prototypes */ entry_QUEUE *SEARCH_entry(entry_QUEUE *, entry, int); void DELETE_entry_ATOM(entry_QUEUE *, entry_ATOM); void MOVE_entry_Q(entry_QUEUE *, entry_QUEUE *); /* return the position of the n-th object in a entry queue */ entry_QUEUE * SEARCH_entry(entry_QUEUE * Q, entry obj, int n) { entry_QUEUE *P; FOREACH(P, Q) { if (EQUAL_entry(obj, P->obj) && !--n) return P; } return (entry_QUEUE *) 0; /* NOT FOUND */ } void DELETE_entry_ATOM(entry_QUEUE * Q, entry_ATOM A) { if (A && A != Q) { A->prev->next = A->next; A->next->prev = A->prev; DESTROY_entry_ATOM(A); } } void MOVE_entry_Q(entry_QUEUE * Qsrc, entry_QUEUE * Qdst) { if (!Q_EMPTY(Qsrc)) { (Qdst->prev->next = Qsrc->next)->prev = Qdst->prev; (Qsrc->prev->next = Qdst)->prev = Qsrc->prev; CLEAN_Q(Qsrc); } } tkeden1.18/Eden/emalloc.h010060000025250000147000000010300727434241600165120ustar00ashleydcsother00003470000356/* * $Id: emalloc.h,v 1.2 1999/11/16 21:20:40 ashley Rel1.10 $ */ /* Error checking malloc functions - rewritten as macros so that we can tell where the memory leaks are using dmalloc [Ash] */ #include #include "error.h" void *emalloc_p; #define emalloc(n) ((emalloc_p = malloc(n)) ? \ emalloc_p \ : \ (error("out of memory"), (void *)NULL) \ ) void *erealloc_p; #define erealloc(ptr, size) ((erealloc_p = realloc(ptr, size)) ? \ erealloc_p \ : \ (error("system error: erealloc"), (void *)NULL) \ ) .2 1999/11/16 21:20:40 ashley Rel1.10 $ */ /* Error checking malloc functions - rewritten as macros so that we can tell where the memory leaks are using dmalloc [Ash] */ #include #include "error.h" void *emalloc_p; #define emalloc(n) ((emalloc_p = malloc(n)) ? \ emalloc_p \ : \ (error("out of memory"), (void *)NULL) \ ) void *erealloc_p; #define erealloc(ptr, size) ((erealloc_p = realloc(ptr, size)) ? \ erealloc_p \ : \ (error("system error: erealloctkeden1.18/Eden/eden.h010060000025250000147000000125060731566072600160260ustar00ashleydcsother00003470000356/* * $Id: eden.h,v 1.12 2001/03/12 18:29:08 cssbz Exp $ */ #ifdef NO_CHECK_CIRCULAR extern int NCC; #endif /* NO_CHECK_CIRCULAR */ #ifdef DEBUG extern int Debug; #endif /* DEBUG */ #ifndef FALSE #define FALSE (0) #endif #ifndef TRUE #define TRUE (1) #endif typedef int Int; /* pointer compatible integer */ typedef void (*Inst) (); typedef struct symbol *symptr; typedef struct Datum Datum; typedef union uDatum uDatum; #include "symptr.q.h" #ifdef DISTRIB /* For the three item agency list [Ash, with Patrick] */ #include "agency.q.h" #endif /* DISTRIB */ typedef struct symbol { char *name; /* variable name */ short stype; /* symbol type */ Inst *inst; /* instruction entry */ unsigned nauto; /* no. of local variables */ char *text; /* original text of definition, if any */ struct Datum { short type; /* data type */ union uDatum { double r; int i; /* integer/char */ char *s; /* string */ Datum *a; /* list */ symptr sym; /* symbol pointer */ struct { int x; int y; } v; } u; } d; symptr_QUEUE sources, targets; symptr_ATOM Qloc; /* location in action_queue / formula_queue */ char marked:1; /* flag */ char changed:1; /* flag */ char entry:6; /* 0 = INTERNAL, 1 = EDEN, 2 = DoNaLD, 3 = Scout, 4 = ARCA */ char *master; /* who change this symbol */ #ifdef DISTRIB agent_QUEUE OracleOf, HandleOf, StateOf; /* agency of all agents in this symbol(observable) --sun */ #endif /* DISTRIB */ symptr next; /* to link to another */ } symbol; /* bylist & tolist: for backward compatibility */ #define bylist targets #define tolist sources symptr install(char *, int, int, int); symptr lookup(char *); #include "error.h" extern Datum UndefDatum; extern Inst *progp, *progbase, prog[]; extern union compiler_flags { struct { unsigned define_level:8; unsigned loop_level:8; unsigned switch_level:8; unsigned formula:1; unsigned local_declare:1; unsigned arg_declare:1; unsigned procmacro:1; } s; int all; /* an int is 32 bit */ } compiler_flag; extern struct t { Datum *dp; Inst *ip; } *entry_ptr, entry_tbl[]; #define reset_entry_tbl() (entry_ptr=entry_tbl) #define reset_compiler_flags() (compiler_flag.all = 0) #define indef compiler_flag.s.define_level #define informula compiler_flag.s.formula #define inauto compiler_flag.s.local_declare #define inpara compiler_flag.s.arg_declare #define inloop compiler_flag.s.loop_level #define inswitch compiler_flag.s.switch_level #define inprocmacro compiler_flag.s.procmacro extern Datum newdatum(Datum); extern Datum newhdat(Datum); extern void freedatum(Datum); #define INCLUDE 'H' #include "inst.h" #undef INCLUDE /*----- typecheck.h -----*/ #define ADDRESSMASK 0xF000 #define SYMBOL 0x1000 #define LOCALV 0x2000 #define POINTERTYPE 0x0FFF #define DPTR 0x0001 #define CPTR 0x0002 #define isundef(d) (d.type == UNDEF) #define ischar(d) (d.type == MYCHAR) #define isstr(d) (d.type == STRING) #define isint(d) (d.type == INTEGER) #define isnum(d) (d.type==REAL||d.type==INTEGER||d.type==MYCHAR) #define is_address(d) (d.type & ADDRESSMASK) #define is_symbol(d) (is_address(d)==SYMBOL) #define is_local(d) (is_address(d)==LOCALV) #define address_type(d) (d.type & POINTERTYPE) #define dptr(d) ((Datum*)d.u.v.x) #define cptr(d) ((char *)d.u.s) #define symbol_of(d) ((symptr)d.u.v.y) #define local(d) (d.u.v.y) /*----- code.h -----*/ #define NSTACK 1024 extern Datum stack[]; /* the stack */ extern Datum *stackp; /* next free spot on stack */ #define top_of_stack stackp[-1] /* top of stack */ #define reset_stack() (stackp=stack) extern Datum stack_underflow_err(void); extern void stack_overflow_err(void); #ifdef DEBUG #include void push(Datum); Datum pop(void); #else /* not DEBUG */ #define push(d) \ if (stackp>=&stack[NSTACK]) stack_overflow_err(); else *stackp++ = d #define pop() \ (stackp==stack? stack_underflow_err() : *--stackp) #endif /* DEBUG */ #define NPROG 5000 extern Inst prog[]; /* the machine */ extern Inst *progp; /* next free spot for code generation */ extern Inst *pc; /* program counter during execurtion */ typedef struct Frame { /* proc/func call stack frame */ symptr sp; /* symbol table entry */ Inst *retpc; /* where to resume after return */ Datum *stackp; /* the stack to be resume */ char *hptr; /* heap pointer */ char *master; /* master of the call */ } Frame; #define NFRAME 100 extern Frame frame[]; extern Frame *fp; /* frame pointer */ #define reset_frames() (fp=frame) /* INPUT DEVICE TYPES */ #define STRING_DEV 0 #define FILE_DEV 1 /*----- refer -----*/ #define NID 100 extern symptr_QUEUE IDlist; extern void addID(symptr); /*----- heap -----*/ #define HEAPSIZE 0x200000 /* change from 0x100000 for classroom --sun */ extern char *hptr, heap[]; extern char *getheap(int); extern void freeheap(void); /*----- eval -----*/ extern void reset_eval(void); extern void mark_changed(symptr); extern void change(symptr, int); tkeden1.18/Eden/CVS/004070000025250000147000000000000731677661000153735ustar00ashleydcsother00003470000356tkeden1.18/Eden/CVS/Root010060000025250000147000000000360727406555600162420ustar00ashleydcsother00003470000356cssbz@127.0.0.1:/cvsroot/eden tkeden1.18/Eden/CVS/Repository010060000025250000147000000000140727406555600174720ustar00ashleydcsother00003470000356tkeden/Eden tkeden1.18/Eden/CVS/Entries010060000025250000147000000027340727406555600167370ustar00ashleydcsother00003470000356/Makefile.in/1.11/Wed Apr 11 17:55:39 2001// /agency.q.c/1.5/Wed Apr 11 17:55:47 2001// /agency.q.h/1.2/Wed Apr 11 17:55:47 2001// /builtin.c/1.38/Wed Apr 11 17:56:54 2001// /builtin.h/1.9/Wed Apr 11 17:56:59 2001// /builtinf.h/1.2/Wed Apr 11 17:56:59 2001// /code.c/1.19/Wed Apr 11 17:57:09 2001// /custom.h/1.3/Wed Apr 11 17:57:09 2001// /eden.h/1.12/Wed Apr 11 17:57:16 2001// /emalloc.h/1.2/Wed Apr 11 17:57:16 2001// /entry.q.c/1.9/Wed Apr 11 17:57:16 2001// /entry.q.h/1.5/Wed Apr 11 17:57:16 2001// /eval.c/1.9/Wed Apr 11 17:57:21 2001// /global.q.c/1.7/Wed Apr 11 17:57:21 2001// /global.q.h/1.6/Wed Apr 11 17:57:21 2001// /hash.h/1.3/Wed Apr 11 17:57:21 2001// /heap.c/1.9/Wed Apr 11 17:57:21 2001// /input_device.h/1.4/Wed Apr 11 17:57:21 2001// /inst.h/1.7/Wed Apr 11 17:57:21 2001// /keyword.h/1.4/Wed Apr 11 17:57:21 2001// /lex.c/1.22/Wed Apr 11 17:57:45 2001// /lib.c/1.5/Wed Apr 11 17:57:45 2001// /machine.c/1.16/Wed Apr 11 17:58:17 2001// /machine.h/1.3/Wed Apr 11 17:58:17 2001// /main.c/1.43/Wed Apr 11 17:58:43 2001// /notation.h/1.7/Wed Apr 11 17:58:43 2001// /refer.c/1.7/Wed Apr 11 17:58:47 2001// /runset.c/1.7/Wed Apr 11 17:58:47 2001// /runset.h/1.4/Wed Apr 11 17:58:47 2001// /screen.q.c/1.5/Wed Apr 11 17:58:56 2001// /screen.q.h/1.2/Wed Apr 11 17:58:56 2001// /symbol.c/1.10/Wed Apr 11 17:58:59 2001// /symptr.q.c/1.7/Wed Apr 11 17:59:04 2001// /symptr.q.h/1.4/Wed Apr 11 17:59:04 2001// /type.c/1.17/Wed Apr 11 17:59:09 2001// /yacc.y/1.14/Wed Apr 11 17:59:28 2001// D tkeden1.18/Eden/custom.h010060000025250000147000000005210727406555600164230ustar00ashleydcsother00003470000356/* * $Id: custom.h,v 1.3 1999/11/16 21:20:40 ashley Rel1.10 $ */ struct ILIBTBL { /* C LIB FUNCTIONS */ string name; int (*func) (); }; struct RLIBTBL { /* FLOATING POINT C LIB FUNCTIONS */ string name; double (*func) (); }; extern struct ILIBTBL ilibtbl[]; extern struct RLIBTBL rlibtbl[]; tkeden1.18/Eden/code.c010060000025250000147000000466440731245660400160250ustar00ashleydcsother00003470000356/* * $Id: code.c,v 1.19 2001/03/12 18:29:08 cssbz Exp $ */ static char rcsid[] = "$Id: code.c,v 1.19 2001/03/12 18:29:08 cssbz Exp $"; #include #include #include "../config.h" #include "eden.h" #include "yacc.h" #include "notation.h" #include "emalloc.h" #ifdef HAVE_DMALLOC #include #endif #ifdef DEBUG #define DEBUGPRINT(X,Y,Z) if(Debug&1){fprintf(stderr,X,Y,Z);} #else #define DEBUGPRINT(X,Y,Z) #endif Datum UndefDatum = {UNDEF}; Datum stack[NSTACK]; /* the stack */ Datum *stackp; /* next free spot on stack */ Inst prog[NPROG]; /* the machine */ Inst *progp = prog; /* next free spot for code generation */ Inst *pc; /* program counter during execurtion */ union compiler_flags compiler_flag; Frame frame[NFRAME]; Frame *fp; /* frame pointer */ #define MAXENTRY 200 struct t entry_tbl[MAXENTRY];/* case entry table */ struct t *entry_ptr; /* function prototypes */ void reset_compiler_status(void); void reset_pseudo_machine_status(void); void initcode(void); void stack_overflow_err(void); Datum stack_underflow_err(void); void execute(Inst *); void ret_call(void); void call(symptr, Datum, char *); void eval(void); void change_targets(symptr, symptr_QUEUE *); void change_sources(symptr, symptr_QUEUE *); void related_by_code(void); Inst *code(Inst); void codeswitch(struct t *); void addentry(Datum *, Inst *); Inst *saveprog(Inst *, Inst *); void push_text(char *, int); char *savetext(char *); Inst *code_related_by(symptr); Inst *code_related_by_runtimelhs(); Inst *code_definition(int, symptr, Inst *, Inst *, Int, char *); Inst *code_definition_runtimelhs(int, Inst *, Inst *, Int, char *); Inst *code_eval(Inst *, Inst *); void evalDatum(Datum); #ifdef DISTRIB int handle_check(symptr); /* for agency --sun */ int oracle_check(symptr); int handle_check1(char *); int oracle_check1(char *); /* Say we have two definitions, 1) a is b+c, 2) x is y+a. Say agent SUN has a handle on a, but not on x. Strictly SUN should be allowed to change (1), but the change should not propagate to (2) - but this would cause inconsistency and so is not implemented in dtkeden. Instead we turn off all handle checking when performing triggeredActions [Ash, with Patrick] */ int triggeredAction = 0; #endif /* DISTRIB */ /* SUBROUTINE INITIALIZE THE RUN-TIME STATUS */ #define reset_prog_ptr() (progp=prog) void reset_compiler_status(void) { extern void clear_IDlist(void); reset_prog_ptr(); clear_IDlist(); reset_entry_tbl(); reset_compiler_flags(); } void reset_pseudo_machine_status(void) { freeheap(); /* make sure hptr is properly aligned */ reset_stack(); reset_eval(); } void initcode(void) { reset_frames(); reset_pseudo_machine_status(); reset_compiler_status(); } void stack_overflow_err(void) { error("stack overflow"); } Datum stack_underflow_err(void) { error("stack underflow"); return UndefDatum; /* dummy */ } #ifdef DEBUG /* Normally, push and pop are macros. With debugging, however, I want to be sure that side effect won't be a problem etc, so I'm rewriting them as functions. [Ash] */ inline void push(Datum d) { if (stackp>=&stack[NSTACK]) stack_overflow_err(); else { if (Debug&1) { fprintf(stderr, "DATSTK push "); print(d, stderr); fprintf(stderr, " (datum at 0x%x, pushed to DATSTK %d)\n", &d, stackp - stack); } *stackp++ = d; } } inline Datum pop(void) { Datum d; if (stackp == stack) d = stack_underflow_err(); else { d = *--stackp; if (Debug&1) { fprintf(stderr, "DATSTK pop "); print(d, stderr); fprintf(stderr, " (DATSTK now %d)\n", stackp - stack); } } return d; } #endif /* DEBUG */ #ifdef DEBUG struct INSTTBL { char *name; void (*func) (); }; struct INSTTBL insttbl[] = { #define INCLUDE 'T' #include "inst.h" #undef INCLUDE {0, 0} }; /* Disassemble: convert a VM opcode into its symbolic name [Ash] */ char * disAss(Inst d) { int i; static char addr[30]; /* should be big enough */ for (i = 0; insttbl[i].name; i++) if (d == insttbl[i].func) return insttbl[i].name; /* Not found */ sprintf(addr, "0x%x (%d)", d, d); return addr; } #endif /* DEBUG */ /* RUN-TIME CODE EVALUATE FUNCTION ID(...) WHERE ID = BLTIN, LIB, FUNCTION OR PROCEDURE. */ /* also can used to execute a heap of Inst which ents at (rts) --sun */ void execute(Inst * p) { Inst *resume_point; extern int interrupted; DEBUGPRINT("VMEXEC|VMREAD execute(0x%x) (to start, %d items on DATSTK)\n", p, stackp - stack); resume_point = pc; pc = p; while (*pc && !interrupted) { DEBUGPRINT("VMEXEC|VMREAD execute: next is pc=0x%x, *pc=%s\n", pc, disAss(*pc)); (*(*pc++)) (); } pc = resume_point; DEBUGPRINT("VMEXEC execute end execute(0x%x) (now %d items on DATSTK)\n", p, stackp - stack); } void ret_call(void) { extern void popMasterStack(void), popEntryStack(void); int i; DEBUGPRINT("CALSTK|DATSTK ret_call\n", 0, 0); if (fp->sp) { switch (fp->sp->stype) { case FUNCTION: case PROCMACRO: case PROCEDURE: i = fp->sp->nauto; if (stackp != &fp->stackp[i + 1]) { noticef("stack pointer was inconsistent on returning from %s %s (discarding %d Datums from stack)", typename(fp->sp->stype), fp->sp->name, stackp - &fp->stackp[i + 1]); } while (i >= 0) freedatum(fp->stackp[i--]); break; } } if (fp->master) popMasterStack(); popEntryStack(); pc = fp->retpc; stackp = fp->stackp; --fp; } void call(symptr sp, Datum args, char *master) { extern void pushEntryStack(int), pushMasterStack(char *); extern void call_lib(Inst), call_float(Inst); int i; Datum d; extern int appAgentName; if (fp++ >= &frame[NFRAME - 1]) { fp--; /* error handling will try to print out info from current frame */ errorf("call to %s %s nested too deeply", typename(sp->stype), sp->name); } DEBUGPRINT("CALSTK|DATSTK call %s: frame level %d\n", sp->name, fp - frame); /* appAgentName--; */ /* This statement may cause AgentName can't be prefixed */ fp->sp = sp; fp->retpc = pc; fp->stackp = stackp; fp->hptr = hptr; pushEntryStack(INTERNAL); fp->master = master; if (master) pushMasterStack(master); /* !@!@ perhaps sp->name here? [Ash] */ switch (sp->stype) { case FUNCTION: case PROCMACRO: case PROCEDURE: push(newdatum(args)); /* put the arguments back */ i = sp->nauto; /* creat local variables */ while (i--) pushUNDEF(); execute(sp->inst); break; case BLTIN: push(args); /* don't copy the whole structure ! */ ((Inst) sp->inst) (); break; case LIB: push(args); /* don't copy the whole structure ! */ call_lib((Inst) sp->inst); /* call the lib interface */ break; case RLIB: /* floating point C-function */ push(args); call_float((Inst) sp->inst); break; default: errorf("func/proc/procmacro '%s' needed", sp->name); break; } d = newhdat(pop()); /* preserve function return value */ ret_call(); push(d); /* appAgentName++; */ /* same as above problem --sun */ DEBUGPRINT("CALSTK end call %s (level %d)\n", sp->name, fp - frame); } void eval(void) { Datum args; Datum lvalue; DEBUGPRINT("VMOPER|CALSTK eval\n", 0, 0); args = pop(); /* arguments (a list) */ lvalue = pop(); /* lvalue */ switch (lvalue.type) { case BLTIN: case LIB: case RLIB: case FUNCTION: case PROCMACRO: case PROCEDURE: /* This works in this case... fprintf(stderr, "eval %s\n", lvalue.u.sym->name); [Ash] */ call(lvalue.u.sym, args, 0); break; default: errorf("func/proc/procmacro '%s' needed", lvalue.u.sym->name); break; } } /* SUBROUTINE add a symbol to by_list then change the related objects */ void change_targets(symptr sp, symptr_QUEUE * splist) { void refer_by(symptr, symptr_QUEUE *); symptr_QUEUE *A; DEBUGPRINT("SYMTBL|DEFNET change_targets %s\n", sp->name, 0); refer_by(sp, splist); FOREACH(A, splist) { change(A->obj, FALSE /* A->obj->changed */ ); } } /* SUBROUTINE add a symbol to the to_list of formula, function/procedure then change the related objects */ void change_sources(symptr sp, symptr_QUEUE * splist) { void refer_to(symptr, symptr_QUEUE *); extern int appAgentName; #ifdef DISTRIB extern void propagate_agency(symptr); /* for agency --sun */ #endif /* DISTRIB */ DEBUGPRINT("SYMTBL|DEFNET change_sources %s\n", sp->name, 0); switch (sp->stype) { case VAR: case FORMULA: refer_to(sp, splist); change(sp, TRUE); break; case FUNCTION: case PROCMACRO: case PROCEDURE: refer_to(sp, splist); change(sp, !Q_EMPTY(splist)); break; default: error("internal error: change_sources()"); } #ifdef DISTRIB if (appAgentName > 0) propagate_agency(sp); #endif /* DISTRIB */ } /* RUN-TIME CODE check a symbol whether is cyclic defined if ok then add it to the by_list */ void related_by_code(void) { extern int checkok(symptr, symptr_QUEUE *); symptr sp; symptr_QUEUE *splist; #ifdef NO_CHECK_CIRCULAR extern int NCC; #endif /* NO_CHECK_CIRCULAR */ DEBUGPRINT("VMOPER|VMREAD|SYMTBL|DEFNET related_by_code\n", 0, 0); sp = (symptr) (*pc++); splist = (symptr_QUEUE *) (*pc++); #ifdef NO_CHECK_CIRCULAR if (!NCC) #endif /* NO_CHECK_CIRCULAR */ if (!checkok(sp, splist)) error2(sp->name, ": CYCLIC DEFINITION: ABORTED"); change_targets(sp, splist); } /* RUN-TIME CODE check a symbol whether is cyclic defined if ok then add it to the by_list */ void related_by_code_runtimelhs(void) { extern int checkok(symptr, symptr_QUEUE *); symptr sp; symptr_QUEUE *splist; Datum addr; #ifdef NO_CHECK_CIRCULAR extern int NCC; #endif /* NO_CHECK_CIRCULAR */ DEBUGPRINT("VMREAD|SYMTBL|DEFNET related_by_code_runtimelhs\n", 0, 0); addr = pop(); mustaddr(addr, "related_by_code_runtimelhs"); sp = symbol_of(addr); splist = (symptr_QUEUE *) (*pc++); #ifdef NO_CHECK_CIRCULAR if (!NCC) #endif /* NO_CHECK_CIRCULAR */ if (!checkok(sp, splist)) error2(sp->name, ": CYCLIC DEFINITION: ABORTED"); change_targets(sp, splist); } /* ENCODER install one instruction or operand */ Inst * code(Inst f) { Inst *oprogp = progp; DEBUGPRINT("VMWRIT code %s to location progp=0x%x\n", disAss(f), progp); if (progp >= &prog[NPROG]) error("program too big"); *progp++ = f; return oprogp; } /* RUN-TIME CODE actual execution code of formula/function/procedure definition */ void codeswitch(struct t * tbl) { Inst *ip, *defp = (Inst *) 0; struct t *t = tbl; DEBUGPRINT("VRWRIT codeswitch\n", 0, 0); for (; tbl != entry_ptr; tbl++) { if (tbl->dp) { ip = code((Inst) tbl->dp); code((Inst) (tbl->ip - ip)); } else defp = tbl->ip; } entry_ptr = t; /* reset */ ip = code((Inst) 0); if (defp) code((Inst) (defp - ip)); else code((Inst) 2); /* there is no default case */ } /* ENCODER encode ``CASE'' or ``DEFAULT'' entry */ void addentry(Datum * dp, Inst * ip) { if (entry_ptr < &entry_tbl[MAXENTRY]) { entry_ptr->dp = dp; entry_ptr->ip = ip; entry_ptr++; } else error("no. of 'case' overflow"); } Inst * saveprog(Inst * p_begin, Inst * p_end) /* save a piece of program code at a permanent place */ { int size; Inst *p; Inst *q; size = ((char *) p_end) - ((char *) p_begin); p = (Inst *) emalloc(size); /* copy from p_begin to p_end into p (use q as an iterator) [Ash] */ for (q = p; p_begin != p_end;) *q++ = *p_begin++; return p; } #define LARGE_TEXT 0x20000 char textcode[LARGE_TEXT]; /* INPUT TEXT BUFFER */ char *textptr = textcode; /* end position of text buffer */ void push_text(char *text, int len) /* push some text on textcode */ /* len - number of char */ { /* orginal text is temp. stored */ if (textptr + len >= &textcode[LARGE_TEXT]) error("text buffer overflow"); strncpy(textptr, text, len); textptr += len; } char * savetext(char *text) { /* save text buffer permanently */ /* text - start position of text buffer */ char *s; *textptr = '\0'; /* force a null */ s = (char *) emalloc((textptr - text) + 1); return strcpy(s, text); } /* ENCODER encode the definition commands sequences */ /* This is used by the parser for "identifier is expr ';' [Ash]" */ Inst * code_definition(int type, symptr id, Inst * prog_start, Inst * prog_end, Int nauto, char *text) { Inst *p_begin, *p_end; Inst *oprogp; symptr_QUEUE *splist, *save_IDlist(void); #ifdef DISTRIB if (!handle_check(id)) { /* for agency --sun */ splist = save_IDlist(); /* I get the feeling this should clear the IDlist instead of saving it: when will splist be freed? [Ash] */ return progp; } #endif /* DISTRIB */ p_begin = saveprog(prog_start, prog_end); /* save prog_start to prog_end in a permanent place [Ash] */ p_end = p_begin + (prog_end - prog_start); oprogp = progp = prog_start; splist = save_IDlist(); code((Inst) definition); code((Inst) type); code((Inst) id); code((Inst) splist); code((Inst) p_begin); code((Inst) p_end); code((Inst) nauto); code((Inst) savetext(text)); return oprogp; } /* This is used by the parser for "'`'expr'`' is expr ';'", and so id is not passed in or saved. Note the first thing coded is definition_runtimelhs. Other than this, it is the same as code_definition above. This used to (less usefully) be called code_definition1. [Ash] */ Inst * code_definition_runtimelhs(int type, Inst * prog_start, Inst * prog_end, Int nauto, char *text) { Inst *p_begin, *p_end; Inst *oprogp; symptr_QUEUE *splist, *save_IDlist(void); p_begin = saveprog(prog_start, prog_end); p_end = p_begin + (prog_end - prog_start); oprogp = progp = prog_start; splist = save_IDlist(); code((Inst) definition_runtimelhs); /* note the change from code_definition */ code((Inst) type); code((Inst) splist); code((Inst) p_begin); code((Inst) p_end); code((Inst) nauto); code((Inst) savetext(text)); return oprogp; } /* This is used to implement eval(expr). expr is evaluated now (at code time) and is coded as a constant value. I think this was implemented by Patrick. It was originally called code_definition2, which seems a silly name as an eval has no persistent definition sense about it. [Ash] */ Inst * code_eval(Inst * prog_start, Inst * prog_end) { Inst *p_begin, *p_end; Inst *oprogp; Datum *dp, d; char *s; int i; /* extern void print(Datum); */ code((Inst) 0); execute(prog_start); unmarkGarbage(prog_start, progp); /* the next line is used to give up these codes from prog_start to prog_end --sun */ oprogp = progp = prog_start; /* t_str1(pop()); */ d = pop(); dp = (Datum *) emalloc(sizeof(Datum)); dp->type = d.type; switch (d.type) { case STRING: s = (char *) emalloc(strlen(d.u.s) + 1); dp->u.s = (char *) strcpy(s, d.u.s); break; case INTEGER: dp->u.i = d.u.i; break; case REAL: dp->u.r = d.u.r; break; case MYCHAR: dp->u.i = d.u.i; break; case UNDEF: dp->u.i = d.u.i; break; case LIST: /* need more codes --sun */ dp->u.a[0].u.i = d.u.a[0].u.i; for (i = 1; i <= d.u.a[0].u.i; i++) { dp->u.a[i] = d.u.a[i]; } break; default: error("EVAL error : unsuitable usage of eval syntax"); } evalDatum(d); markGarbage(progp, dp); code((Inst) constpush); code((Inst) dp); return oprogp; } /* ENCODER code the ``id ~> [...]'' command */ Inst * code_related_by(symptr sp) { extern symptr_QUEUE *save_IDlist(void); symptr_QUEUE *splist; Inst *ip; splist = save_IDlist(); ip = code((Inst) related_by_code); code((Inst) sp); code((Inst) splist); return ip; } Inst * code_related_by_runtimelhs() { extern symptr_QUEUE *save_IDlist(void); symptr_QUEUE *splist; Inst *ip; splist = save_IDlist(); ip = code((Inst) related_by_code_runtimelhs); code((Inst) splist); return ip; } #ifdef DISTRIB /* SUBROUTE check agency of a symbol --sun */ /* ------------------------------------------------------------------------ */ int handle_check(symptr sp) { extern char agentName[128]; extern char *everyone; if (sp==0) return 1; if (*agentName ==0) return 1; /* mean own */ if (triggeredAction) return 1; /* means it is a triggered action */ /* if (Q_EMPTY(&sp->HandleOf)) return 1; using evryone to allow everyone's agency */ if (search_agent_Q(&sp->HandleOf, everyone)) return 1; if (search_agent_Q(&sp->HandleOf, "SYSTEM")) return 1; if (search_agent_Q(&sp->HandleOf, agentName)) { /*printf("handleOK %s", sp->name);*/ return 1; } /* printf("HandleNo %s %s", agentName, sp->name);*/ return 0; } int handle_check1(char *name) { extern symptr lookup(char *); return handle_check(lookup(name)); } int oracle_check(symptr sp) { extern char agentName[128]; extern char *everyone; if (sp==0) return 1; if (*agentName ==0) return 1; /* means own */ if (triggeredAction) return 1; /* means it is a triggered action */ /* if (Q_EMPTY(&sp->OracleOf)) return 1; using everyone to allow everyone's agency */ if (search_agent_Q(&sp->OracleOf, everyone)) return 1; if (search_agent_Q(&sp->OracleOf, "SYSTEM")) return 1; if (search_agent_Q(&sp->OracleOf, agentName)) { /* printf("OracleOK %s", sp->name); */ return 1; } /* printf("OracleNo %s %s", agentName, sp->name); */ return 0; } int oracle_check1(char *name) { extern symptr lookup(char *); return oracle_check(lookup(name)); } #endif /* DISTRIB */ void evalDatum(Datum d) { char s2[80]; int i; switch (d.type) { case STRING: push_text("\"", 1); push_text(d.u.s, strlen(d.u.s)); push_text("\"", 1); break; case INTEGER: sprintf(s2, "%d", d.u.i); push_text(s2, strlen(s2)); break; case REAL: sprintf(s2, "%f", d.u.r); push_text(s2, strlen(s2)); break; case MYCHAR: push_text("'", 1); sprintf(s2, "%c", d.u.i); push_text(s2, 1); push_text("'", 1); break; case UNDEF: push_text("@", 1); break; case LIST: push_text("[", 1); for (i = 1; i <= d.u.a[0].u.i; i++) { evalDatum(d.u.a[i]); if (i < d.u.a[0].u.i) push_text(",", 1); } push_text("]", 1); break; default: error("EVAL error : unsuitable usage of eval syntax"); } } NO_CHECK_CIRCULAR */ DEBUGPRINT("VMOPER|VMREAD|SYMTBL|DEFNET related_by_code\n", 0, 0);tkeden1.18/Eden/builtinf.h010060000025250000147000000045750731640320000167150ustar00ashleydcsother00003470000356/* * $Id: builtinf.h,v 1.2 1999/11/16 21:20:40 ashley Rel1.10 $ * * builtin or predefined function table * */ /* builtin function table */ { "autocalc" }, { "exit" }, { "execute" }, { "include" }, { "eager" }, { "include_file" }, { "_eden_internal_cwd" }, { "_eden_internal_cd" }, { "_eden_internal_dirname" }, { "_eden_internal_basename" }, { "apply" }, { "substr" }, { "strcat" }, { "sublist" }, { "listcat" }, { "type" }, { "int" }, { "float" }, { "char" }, { "str" }, { "_type_convert" }, { "write" }, { "writeln" }, { "sendClient" }, { "sendServer" }, { "propagate" }, { "addAgency" }, { "removeAgency" }, { "checkAgency" }, { "FALSE" }, { "TRUE" }, { "ON" }, { "OFF" }, { "MOTION" }, { "ENTER" }, { "LEAVE" }, { "propagateType" }, { "EveryOneAllowed" }, { "synchronize" }, { "higherPriority" }, { "queryObs" }, { "renewObs" }, { "array" }, { "nameof" }, { "formula_list" }, { "action_list" }, { "symbols" }, { "symboldetail" }, { "symboltable" }, { "forget" }, { "pack" }, { "error" }, { "get_msgq" }, { "send_msg" }, { "receive_msg" }, { "remove_msgq" }, { "error_no" }, { "backgnd" }, { "pipe" }, { "getenv" }, { "putenv" }, { "printhash" }, { "touch" }, { "gettime" }, { "time" }, { "ftime" }, { "feof" }, { "getchar" }, { "fgetc" }, { "gets" }, { "fgets" }, { "ungetc" }, { "scanf" }, { "fscanf" }, { "sscanf" }, #ifdef NO_CHECK_CIRCULAR { "dcc" }, #endif NO_CHECK_CIRCULAR #ifdef DEBUG { "debug" }, #endif DEBUG #ifndef TTYEDEN { "Disp2PS" }, { "StringRemain" }, { "tcl" }, { "DisplayScreen" }, { "OpenDisplay" }, { "PlotShape" }, { "DoNaLDdefaultWin" }, #endif { "todo" }, /* for Donald */ { "cart" }, { "CART" }, { "label" }, { "trans" }, { "line" }, { "circle" }, { "rectangle" }, { "arc" }, { "PI" }, { "str" }, { "int" }, { "float" }, { "intersect" }, { "parallel" }, { "perpend" }, { "between" }, { "colinear" }, { "intersects" }, { "separates" }, { "includes" }, { "distlarger" }, { "distsmaller" }, { "dist" }, { "midpoint" }, { "sqrt" }, { "cos" }, { "sin" }, { "tan" }, { "asin" }, { "acos" }, { "atan" }, { "log" }, { "exp" }, { "incident" }, { "ellipse" }, { "DD_random" }, { "rtos" }, { "dotx" }, { "doty" }, { "dot1" }, { "dot2" }, { "dotrad" }, { "dotarg" }, { "polar" }, { "rot" }, { "scale" }, { "vector_add" }, { "vector_sub" }, { "pt_add" }, { "pt_subtract" }, { "scalar_mult" }, { "scalar_div" }, { "scalar_mod" }, /* for adm */ { "sysClock" }, tkeden1.18/Eden/builtin.h010060000025250000147000000111630731620536400165510ustar00ashleydcsother00003470000356/* * $Id: builtin.h,v 1.9 2000/10/11 18:07:27 ashley Rel1.10 $ */ /* Adding a new built-in function to Eden: - declare it here in builtin.h - declare it in builtinf.h */ #if INCLUDE != 'T' #define paracount fp->stackp->u.a[0].u.i #define para(n) fp->stackp->u.a[n] #define dpush(x,y,z) x.type=y; x.u.i=(Int)(z); push(x) struct BLIBTBL { char *name; void (*func)(); }; extern struct BLIBTBL blibtbl[]; extern void usage(); #endif /*---------------------------------------------------------*/ #if INCLUDE == 'T' #define BIND(name,func) {name,func}, #else #define BIND(name,func) extern void func(); #endif /*---------------------------------------------------------*/ BIND( "exit", b_exit ) BIND( "execute", exec_string ) BIND( "include", exec_file ) BIND( "include_file", exec_file ) BIND( "_eden_internal_cwd", _eden_internal_cwd ) BIND( "_eden_internal_cd", _eden_internal_cd ) BIND( "_eden_internal_dirname", _eden_internal_dirname ) BIND( "_eden_internal_basename", _eden_internal_basename ) BIND( "apply", apply ) BIND( "substr", substr ) BIND( "strcat", scat ) BIND( "sublist", sublist ) BIND( "listcat", lcat ) BIND( "type", t_type ) BIND( "int", t_int ) BIND( "float", t_float ) BIND( "char", t_char ) BIND( "str", t_str ) BIND( "_type_convert", t_super ) BIND( "write", b_write ) BIND( "writeln", writeln ) BIND( "array", array ) BIND( "nameof", nameof ) BIND( "formula_list", formula_list ) BIND( "action_list", action_list ) BIND( "symbols", symbols ) BIND( "symboldetail", symboldetail ) BIND( "symboltext", symboltext ) BIND( "symboltable", symtbl2list ) BIND( "forget", forget ) BIND( "pack", pack ) BIND( "error", user_error ) BIND( "get_msgq", get_msgq ) BIND( "send_msg", send_message ) BIND( "receive_msg", receive_message ) BIND( "remove_msgq", remove_msgq ) BIND( "error_no", error_no ) BIND( "backgnd", backgnd ) BIND( "pipe", pipe_process ) BIND( "getenv", get_environ ) BIND( "putenv", put_environ ) BIND( "printhash", printhash ) BIND( "touch", touch ) BIND( "gettime", gettime ) BIND( "time", inttime ) BIND( "ftime", finetime ) BIND( "feof", f_eof ) BIND( "getchar", get_char ) #ifdef WANT_KBHIT BIND( "kbhit", kbhit ) #endif /* WANT_KBHIT */ BIND( "fgetc", fget_char ) BIND( "gets", get_string ) BIND( "fgets", fget_string ) BIND( "ungetc", unget_char ) BIND( "scanf", scan_f ) BIND( "fscanf", fscan_f ) BIND( "sscanf", sscan_f ) #ifdef DISTRIB BIND( "sendServer", sendServer ) BIND( "sendClient", sendClient ) BIND( "propagate", propagate ) BIND( "addAgency", addAgency ) BIND( "removeAgency", removeAgency ) BIND( "checkAgency", checkAgency ) BIND( "queryObs", queryObs ) BIND( "renewObs", renewObs ) #endif /* DISTRIB */ #ifdef NO_CHECK_CIRCULAR BIND( "dcc", dcc ) #endif NO_CHECK_CIRCULAR #ifdef DEBUG BIND( "debug", debug ) #endif DEBUG #ifndef TTYEDEN BIND( "Disp2PS", E_Disp2PS ) BIND( "StringRemain", E_StringRemain ) BIND( "tcl", E_tcl ) BIND( "DisplayScreen", DisplayScreen ) BIND( "PlotShape", PlotShape ) #endif BIND( "todo", todo ) #if defined(WANT_SASAMI) && !defined(TTYEDEN) /* Sasami functions */ BIND("sasami_vertex",ed_sasami_vertex) BIND("sasami_set_bgcolour",ed_sasami_set_bgcolour) BIND("sasami_poly_geom_vertex",ed_sasami_poly_geom_vertex) BIND("sasami_poly_tex_vertex",ed_sasami_poly_tex_vertex) BIND("sasami_poly_colour",ed_sasami_poly_colour) BIND("sasami_poly_material",ed_sasami_poly_material) BIND("sasami_object_poly",ed_sasami_object_poly) BIND("sasami_object_pos",ed_sasami_object_pos) BIND("sasami_object_rot",ed_sasami_object_rot) BIND("sasami_object_scale",ed_sasami_object_scale) BIND("sasami_object_visible",ed_sasami_object_visible) BIND("sasami_viewport",ed_sasami_viewport) BIND("sasami_setshowaxes",ed_sasami_setshowaxes) BIND("sasami_material_ambient",ed_sasami_material_ambient) BIND("sasami_material_diffuse",ed_sasami_material_diffuse) BIND("sasami_material_specular",ed_sasami_material_specular) BIND("sasami_material_texture",ed_sasami_material_texture) BIND("sasami_light_pos",ed_sasami_light_pos) BIND("sasami_light_ambient",ed_sasami_light_ambient) BIND("sasami_light_diffuse",ed_sasami_light_diffuse) BIND("sasami_light_specular",ed_sasami_light_specular) BIND("sasami_light_enabled",ed_sasami_light_enabled) BIND("sasami_light_attenuation",ed_sasami_light_attenuation) BIND("sasami_light_directional",ed_sasami_light_directional) #endif /* defined(WANT_SASAMI) && !defined(TTYEDEN) */ #undef BIND - declare it here in builtin.h - declare it in builtinf.h */ #if INCLUDE != 'T' #define paracount fp->stackp->u.a[0].u.i #define para(n) fp->stackp->u.a[n] #define dpush(x,y,z) x.type=y; x.u.i=(Int)(z); push(x) struct BLIBTBL { char *name; void (*func)(); }; extern struct BLIBTBL blibtbl[]; extern void usage(); #endif /*-----------------------------------------------------tkeden1.18/Eden/builtin.c010060000025250000147000002524420731620531600165500ustar00ashleydcsother00003470000356/* * $Id: builtin.c,v 1.38 2000/10/11 18:07:17 ashley Rel1.10 $ */ static char rcsid[] = "$Id: builtin.c,v 1.38 2000/10/11 18:07:17 ashley Rel1.10 $"; /** * SOME BUILTIN FUNCTIONS * **/ #include #include #include #include #include "../config.h" #include "eden.h" #include "machine.h" #include "builtin.h" #include "yacc.h" #include "symptr.q.h" #include "hash.h" #include "notation.h" /* I never managed to get kbhit to do what I want it to do: ie pipe commands into tkeden via stdin, probably with a notation translator on the pipe somewhere, like in The Old Days. As it causes problems on Windoz (filio.h doesn't exist) it is commented out like this. [Ash] */ #ifdef WANT_KBHIT #include #include #include #endif #ifdef ipc #include #include #endif #include #include /* for PATH_MAX */ #include #ifndef TTYEDEN #include /* Tcl caches environment variables: so we must use Tcl's versions of the getenv and putenv functions [Ash] */ /* Tcl 8.2.0 Makefile implies don't use the Tcl getenv [Ash] */ #define putenv Tcl_PutEnv #define setenv TclSetEnv #define unsetenv TclUnsetEnv #include extern Tcl_Interp *interp; #endif #include "emalloc.h" #ifdef HAVE_DMALLOC #include #endif extern void call(symptr, Datum, char *); extern char *topMasterStack(void); extern int topEntryStack(void); extern int appAgentName; /* VA [Ash] */ extern char *typename(); #ifdef DISTRIB void tkdefine1(symptr); /* for propagation --sun */ void propagate_agency(symptr); void propagateAgency(symptr, char *); void propagateAgency1(char *, char *); void SendServer(char *, char *); void SendClient(char *, char *); void SendotherClients(char *, char *); #endif /* DISTRIB */ #ifndef streq #define streq(X,Y) (strcmp(X,Y)==0) #endif struct BLIBTBL blibtbl[] = { #define INCLUDE 'T' #include "builtin.h" #undef INCLUDE {0, 0} }; void usage(char *s) { /* internal subroutine */ error2("usage: ", s); } #ifdef NO_CHECK_CIRCULAR int NCC = 0; /* 1 for disable circular check */ void dcc(void) { /* NCC mode on/off */ extern int NCC; if (paracount > 0) { mustint(para(1), "dcc()"); NCC = para(1).u.i; } else NCC = 1; pushUNDEF(); } #endif #ifdef DEBUG int Debug = 0; /* 1 for debugging */ extern int yydebug; extern int st_debug; void debug(void) { /* debug modes on/off: 1: various 2: RunSet debugging 4: Eden parser debugging (=yydebug) 8: Sasami 16: Donald 32: Scout parser debugging (=st_debug) ... add these debug values together to find the argument to give to the debug() function. [Ash] */ extern int Debug; if (paracount > 0) { mustint(para(1), "debug()"); Debug = para(1).u.i; yydebug = Debug & 4; #ifndef TTYEDEN st_debug = Debug & 32; #endif } else Debug = 1; pushUNDEF(); } #endif /* From Autoconf manual [Ash] */ #if TIME_WITH_SYS_TIME # include # include #else # if HAVE_SYS_TIME_H # include # else # include # endif #endif #ifdef __CYGWIN__ extern void cygwin_split_path(const char *, char *, char *); #else #include #endif void _eden_internal_dirname(void) { char *result, *myHeap; Datum d; #ifdef __CYGWIN__ char *basename; #endif if (paracount != 1) { usage("string _eden_internal_dirname(string)"); } else { muststr(para(1), "_eden_internal_dirname"); #ifdef __CYGWIN__ result = emalloc(PATH_MAX); basename = emalloc(PATH_MAX); cygwin_split_path(para(1).u.s, result, basename); #else /* not CYGWIN */ result = dirname(para(1).u.s); #endif myHeap = getheap(strlen(result) + 1); strcpy(myHeap, result); dpush(d, STRING, myHeap); #ifdef __CYGWIN__ free(result); free(basename); #endif } } void _eden_internal_basename(void) { char *result, *myHeap; Datum d; #ifdef __CYGWIN__ char *dirname; #endif if (paracount != 1) { usage("string _eden_internal_dirname(string)"); } else { muststr(para(1), "_eden_internal_dirname"); #ifdef __CYGWIN__ dirname = emalloc(PATH_MAX); result = emalloc(PATH_MAX); cygwin_split_path(para(1).u.s, dirname, result); #else /* not CYGWIN */ result = basename(para(1).u.s); #endif myHeap = getheap(strlen(result) + 1); strcpy(myHeap, result); dpush(d, STRING, myHeap); #ifdef __CYGWIN__ free(result); free(dirname); #endif } } void _eden_internal_cwd(void) { char *cwd; Datum d; char *myHeap; if (paracount != 0) { usage("string eden_internal_cwd()"); } if ((cwd = getcwd(NULL, PATH_MAX)) == NULL) { errorf("failed to get cwd"); } else { myHeap = getheap(strlen(cwd) + 1); strcpy(myHeap, cwd); dpush(d, STRING, myHeap); free(cwd); } } void _eden_internal_cd(void) { if (paracount == 1) { muststr(para(1), "_eden_internal_cd"); if (chdir(para(1).u.s)) { errorf("failed to cd into '%s': %s", para(1).u.s, strerror(errno)); } } else { usage("void _eden_internal_cd(string)"); } } /* local time */ void gettime(void) { Datum sec, min, hour, mday, mon, year, wday; struct tm *clock; time_t tloc; time(&tloc); clock = localtime(&tloc); dpush(sec, INTEGER, clock->tm_sec); dpush(min, INTEGER, clock->tm_min); dpush(hour, INTEGER, clock->tm_hour); dpush(mday, INTEGER, clock->tm_mday); dpush(mon, INTEGER, clock->tm_mon + 1); dpush(year, INTEGER, clock->tm_year); dpush(wday, INTEGER, clock->tm_wday); makearr(7); } /* time elapsed since Jan 1, 1970 in seconds */ void inttime(void) { Datum seconds; time_t tloc; dpush(seconds, INTEGER, time(&tloc)); } /* time elapsed since Jan 1, 1970 in milli-seconds */ void finetime(void) { Datum seconds, milli; struct timeval tloc; struct timezone tzone; gettimeofday(&tloc, &tzone); dpush(seconds, INTEGER, tloc.tv_sec); dpush(milli, INTEGER, tloc.tv_usec / 1000); makearr(2); } void f_eof(void) { Datum d; FILE *stream; if (paracount > 0) { mustint(para(1), "feof()"); stream = (FILE *) para(1).u.i; dpush(d, INTEGER, feof(stream)); } else usage("int feof(stream)"); } void get_char(void) { Datum d; dpush(d, INTEGER, getchar()); } #ifdef WANT_KBHIT /* So we can tell whether calling one of the getc functions will block. This version from a news article by floyd@ptialaska.net, which gives details of a POSIX kbhit function... [Ash] */ #define CMIN 1 #ifdef CTIME #undef CTIME #endif #define CTIME 1 void kbhit(void) { Datum d; int cnt = 0; int error; static struct termios Otty, Ntty; tcgetattr(0, &Otty); Ntty = Otty; Ntty.c_iflag = 0; /* input mode */ Ntty.c_oflag = 0; /* output mode */ Ntty.c_lflag &= ~ICANON; /* raw mode */ Ntty.c_cc[VMIN] = CMIN; /* minimum time to wait */ Ntty.c_cc[VTIME] = CTIME; /* minimum char's to wait for */ if (0 == (error = tcsetattr(0, TCSANOW, &Ntty))) { struct timeval tv; error += ioctl(0, FIONREAD, &cnt); error += tcsetattr(0, TCSANOW, &Otty); tv.tv_sec = 0; tv.tv_usec = 100; /* a slight time delay is required for tight loops */ select(1, NULL, NULL, NULL, &tv); } dpush(d, INTEGER, (error == 0 ? cnt : -1 )); } #endif /* WANT_KBHIT */ void fget_char(void) { Datum d; FILE *stream; if (paracount > 0) { mustint(para(1), "fget_char()"); stream = (FILE *) para(1).u.i; dpush(d, INTEGER, fgetc(stream)); } else usage("int fgetc(stream)"); } #define MAXSTRLEN 256 void get_string(void) { Datum d; char *status; char *t; char *s = (char *) malloc(MAXSTRLEN); int slength; if (paracount > 0) { usage("string gets()"); } status = fgets(s, MAXSTRLEN, stdin); /* Remove the \n that is added by fgets() (thus keeping gets() semantics) [Ash] */ slength = strlen(s); if (slength > 0) { s[strlen(s)-1] = '\0'; } if (status) { t = getheap(strlen(s) + 1); strcpy(t, s); dpush(d, STRING, t); } else pushUNDEF(); free(s); } void fget_string(void) { Datum d; int n; FILE *stream; char *status; char *t; char *s; if (paracount > 0) { mustint(para(1), "fget_string()"); n = para(1).u.i; mustint(para(2), "fget_string()"); stream = (FILE *) para(2).u.i; s = (char *) malloc(n); status = fgets(s, n, stream); if (status) { t = getheap(strlen(s) + 1); strcpy(t, s); dpush(d, STRING, t); } else pushUNDEF(); free(s); } else usage("string fgets(n, stream)"); } void unget_char(void) { int c; FILE *stream; if (paracount > 0) { mustint(para(1), "unget_char()"); c = para(1).u.i; mustint(para(2), "unget_char()"); stream = (FILE *) para(2).u.i; ungetc(c, stream); } else usage("void ungetc(c, stream)"); } void scan_f(void) { Datum d; void *arg[9]; int i; char *format; if (paracount > 10) usage("scanf can handle at most 9 variables"); else if (paracount > 0) { muststr(para(1), "scanf()"); for (i = paracount; i > 1; --i) mustaddr(para(i), "scanf()"); format = para(1).u.s; for (i = paracount; i > 1; --i) if (para(i).u.a->type == STRING) arg[i - 2] = (void *) (para(i).u.a->u.i); else arg[i - 2] = (void *) &(para(i).u.a->u); i = scanf(format, arg[0], arg[1], arg[2], arg[3], arg[4], arg[5], arg[6], arg[7], arg[8]); } else usage("int scanf(format [, pointer ... ])"); dpush(d, INTEGER, i); } void fscan_f(void) { Datum d; void *arg[9]; int i; FILE *stream; char *format; if (paracount > 11) usage("fscanf can handle at most 9 variables"); else if (paracount > 0) { mustint(para(1), "fscanf()"); muststr(para(2), "fscanf()"); for (i = paracount; i > 2; --i) mustaddr(para(i), "fscanf()"); stream = (FILE *) para(1).u.i; format = para(2).u.s; for (i = paracount; i > 2; --i) if (para(i).u.a->type == STRING) arg[i - 3] = (void *) para(i).u.a->u.i; else arg[i - 3] = (void *) &(para(i).u.a->u); i = fscanf(stream, format, arg[0], arg[1], arg[2], arg[3], arg[4], arg[5], arg[6], arg[7], arg[8]); } else usage("int fscanf(stream, format [, pointer ... ])"); dpush(d, INTEGER, i); } void sscan_f(void) { Datum d; void *arg[9]; int i; char *str; char *format; if (paracount > 11) usage("sscanf can handle at most 9 variables"); else if (paracount > 0) { muststr(para(1), "sscanf()"); muststr(para(2), "sscanf()"); for (i = paracount; i > 2; --i) mustaddr(para(i), "sscanf()"); str = para(1).u.s; format = para(2).u.s; for (i = paracount; i > 2; --i) if (para(i).u.a->type == STRING) arg[i - 3] = (void *) para(i).u.a->u.i; else arg[i - 3] = (void *) &(para(i).u.a->u); i = sscanf(str, format, arg[0], arg[1], arg[2], arg[3], arg[4], arg[5], arg[6], arg[7], arg[8]); } else usage("int sscanf(string, format [, pointer ... ])"); dpush(d, INTEGER, i); } void substr(void) { /* sub-string function */ Datum d; int from, to, len, i; char *s, *t, *str; Datum ctos(Datum); if (paracount >= 3) { para(1) = ctos(para(1)); str = para(1).u.s; /* the string */ len = strlen(str); /* the strlen */ mustint(para(2), "substr()"); /* from */ mustint(para(3), "substr()"); /* to */ from = para(2).u.i - 1; to = para(3).u.i - 1; if (from < 0) error("substr: index out of range (from < 0)"); i = (from <= to) ? (to - from + 1) : 0; for (t = s = getheap(i + 1); from <= to; from++) *t++ = (from < len) ? str[from] : ' '; *t = '\0'; } else usage("substr(s, from, to)"); dpush(d, STRING, s); } void sublist(void) { Datum *a; int i, listlen, from, to; if (paracount >= 3) { mustlist(para(1), "sublist()"); mustint(para(2), "sublist()"); mustint(para(3), "sublist()"); a = para(1).u.a; listlen = a[0].u.i; from = para(2).u.i; to = para(3).u.i; if (from < 1) error("sublist: index out of range (from < 1)"); for (i = from; i <= to; i++) push(i <= listlen ? a[i] : UndefDatum); makearr(from <= to ? to - from + 1 : 0); } else usage("sublist(L, from, to)"); } void print(Datum d, FILE *f) { /* internal function: print datum */ int i; if (is_symbol(d)) { fprintf(f,"&%s", symbol_of(d)->name); } else if (is_local(d)) { fprintf(f,"(local variable #%d, location 0x%x, value ", local(d), d.u.v.x); switch (address_type(d)) { case DPTR: print(*dptr(d), f); break; case CPTR: fprintf(f,"%s", cptr(d)); break; default: fprintf(f,"oops - internal error - unknown type of pointer"); } fprintf(f,")"); } else { switch (d.type) { case REAL: fprintf(f,"%g", d.u.r); break; case INTEGER: fprintf(f,"%d", d.u.i); break; case MYCHAR: fprintf(f,"%c", d.u.i); break; case STRING: if (d.u.s) fprintf(f,"%s", d.u.s); break; case LIST: fprintf(f,"["); for (i = 1; i <= d.u.a[0].u.i; i++) { print(d.u.a[i], f); if (i < d.u.a[0].u.i) fprintf(f,","); } fprintf(f,"]"); break; case VAR: fprintf(f,"(%s is variable)", d.u.sym->name); break; case BLTIN: fprintf(f,"(%s is built-in function)", d.u.sym->name); break; case LIB: fprintf(f,"(%s is int-valued C function)", d.u.sym->name); break; case RLIB: fprintf(f,"(%s is real-valued C function)", d.u.sym->name); break; case FORMULA: fprintf(f,"@"); /* fprintf(f,"(%s is formula)", d.u.sym->name); */ break; case FUNCTION: fprintf(f,"(%s is user-defined function)", d.u.sym->name); break; case PROCEDURE: fprintf(f,"(%s is user-defined procedure)", d.u.sym->name); break; case PROCMACRO: fprintf(f,"(%s is user-defined procmacro)", d.u.sym->name); break; case UNDEF: fprintf(f,"@"); break; default: fprintf(f,"(type=%d, val=%d)", d.type, d.u.i); break; } } } void writeln(void) { /* pascal-like writeln */ b_write(); printf("\n"); } void b_write(void) { /* pascal-like write */ int i; for (i = 1; i <= paracount; i++) print(para(i), stdout); pushUNDEF(); } void nameof(void) { /* built-in function: symbol name of a pointer */ Datum d, addr; char *s, *name; if (paracount != 1) usage("s = nameof(&var);"); addr = para(1); if (!is_symbol(addr)) errorf("nameof(): address needed (got %s)", typename(addr.type)); name = symbol_of(addr)->name; s = getheap(strlen(name) + 1); strcpy(s, name); dpush(d, STRING, s); } void scat(void) { /* string concatenation */ Datum d; int i; int len; char *s; Datum ctos(Datum); len = 0; for (i = 1; i <= paracount; i++) { para(i) = ctos(para(i)); len += strlen(para(i).u.s); } s = getheap(len + 1); for (i = 1, *s = '\0'; i <= paracount; i++) strcat(s, para(i).u.s); dpush(d, STRING, s); } void lcat(void) { int i, j, total, listlen; Datum *a; total = 0; for (i = 1; i <= paracount; i++) { mustlist(para(i), "lcat()"); a = para(i).u.a; total += (listlen = a[0].u.i); for (j = 1; j <= listlen; j++) push(a[j]); } makearr(total); } void b_exit(void) { /* builtin: exit the interpreter */ extern void terminate(int); terminate(paracount > 0 && isint(para(1)) ? para(1).u.i : 0); pushUNDEF(); } void exec_string(void) { /* builtin: execute a string as a program */ int result; Datum d; #ifndef TTYEDEN notationType n; #endif void pushEntryStack(int); void popEntryStack(void); int run(short, void *, char *); if (paracount == 0) usage("execute(string_expr);"); muststr(para(1), "execute()"); pushEntryStack(EDEN); #ifndef TTYEDEN n = currentNotation; #endif result = run(STRING_DEV, para(1).u.s, 0); #ifndef TTYEDEN changeNotation(n); #endif popEntryStack(); dpush(d, INTEGER, result); } void exec_file(void) { /* builtin: execute a file as a program */ FILE *filein; char *name; Datum d; int result; void pushEntryStack(int); void popEntryStack(void); int run(short, void *, char *); int i; if (paracount == 0) usage("include(filename[, filename...]);"); for (i = 1; i <= paracount; i++) { muststr(para(i), "include()"); name = para(i).u.s; if ((filein = fopen(name, "r"))) { pushEntryStack(EDEN); result = run(FILE_DEV, filein, name); /* ``run'' will close the file */ popEntryStack(); } else { error2("can't read file ", name); } } dpush(d, INTEGER, result); } /* call a function with a list as its argument */ void apply(void) { if (paracount >= 2) { switch (para(1).type) { case FUNCTION: case PROCEDURE: case PROCMACRO: case BLTIN: case LIB: case RLIB: if (para(2).type == LIST) call(para(1).u.sym, para(2), 0); break; default: usage("apply(function, list);"); break; } } else usage("apply(function, list);"); } static void pushlist(symptr_QUEUE * Q) { int count; Datum d; symptr_ATOM A; count = 0; FOREACH(A, Q) { dpush(d, STRING, A->obj->name); count++; } makearr(count); } #ifdef DISTRIB /* Only used for oracle, handle, state: the three item agent list [Ash] */ static void pushlist1(agent_QUEUE * Q) { int count; Datum d; agent_ATOM A; count = 0; FOREACH(A, Q) { dpush(d, STRING, A->obj.name); count++; } makearr(count); } #endif /* DISTRIB */ void symboldetail(void) { extern symptr hashtable[]; extern int hashindex(char *); extern char *typename(); symptr sp; Datum d; char *name; int i; if (paracount < 1) usage("symboldetail(symbol);"); if (!is_symbol(para(1)) && para(1).type != STRING) errorf("symboldetail(): address or symbol name needed (got %s)", typename(para(1).type)); if (is_symbol(para(1))) { /* If we've been passed a pointer, then just look it up [Ash] */ sp = symbol_of(para(1)); } else { /* If we've been passed a string, find the symbol [Ash] */ name = para(1).u.s; i = hashindex(name); for (sp = hashtable[i]; sp != (symptr) 0; sp = sp->next) if (strcmp(sp->name, name) == 0) { break; } if (sp == 0) error2("symboldetail(): no such variable ", name); } #ifdef DISTRIB /* if (!oracle_check(sp)) error2("no Oracle privilege on observable ", name);*/ /* --sun */ #endif /* DISTRIB */ /* sp is a pointer to the symbol we want to examine [Ash] */ dpush(d, STRING, sp->name); dpush(d, STRING, typename(sp->stype)); if (sp->text) { dpush(d, STRING, sp->text); } else { dpush(d, STRING, ""); } pushlist(&sp->targets); pushlist(&sp->sources); #ifdef DISTRIB pushlist1(&sp->OracleOf); pushlist1(&sp->HandleOf); pushlist1(&sp->StateOf); makearr(8); #else makearr(5); #endif /* DISTRIB */ } /* symboldetail creates a load of stuff on the stack in the Chris Roe case when there are lots of targets and sources around, so this function simply returns what Chris needs: the text that was used to define this symbol originally. Basically this is the same as symboldetail(summat)[3], but this version will not run out of stack space if you call it with a symbol with lots of targets and sources. [Ash, 8/3/2000] */ void symboltext(void) { extern symptr hashtable[]; extern int hashindex(char *); extern char *typename(); symptr sp; Datum d; char *name; int i; if (paracount < 1) usage("symboltext(symbol);"); if (!is_symbol(para(1)) && para(1).type != STRING) errorf("symboltext(): address or symbol name needed (got %s)", typename(para(1).type)); if (is_symbol(para(1))) { /* If we've been passed a pointer, then just look it up [Ash] */ sp = symbol_of(para(1)); } else { /* If we've been passed a string, find the symbol [Ash] */ name = para(1).u.s; i = hashindex(name); for (sp = hashtable[i]; sp != (symptr) 0; sp = sp->next) if (strcmp(sp->name, name) == 0) { break; } if (sp == 0) error2("symboltext(): no such variable ", name); } #ifdef DISTRIB /* if (!oracle_check(sp)) error2("no Oracle privilege on observable ", name);*/ /* --sun */ #endif /* DISTRIB */ /* sp is a pointer to the symbol we want to examine [Ash] */ if (sp->text) { dpush(d, STRING, sp->text); } else { dpush(d, STRING, ""); } } void symbols(void) { extern symptr hashtable[]; extern int typeno(); symptr sp; Datum d; Datum *p; Int count; Int i; Int any, pointer, type; if (paracount < 1 || para(1).type != STRING) usage("symbols(type);"); any = (strcmp(para(1).u.s, "any") == 0); pointer = (strcmp(para(1).u.s, "pointer") == 0); if (!any && !pointer) { type = typeno(para(1).u.s); } count = 0; for (i = 0; i <= HASHSIZE; i++) for (sp = hashtable[i]; sp != (symptr) 0; sp = sp->next) { if (any || type == sp->stype || (pointer && is_address(sp->d)) || type == sp->d.type) count++; } p = (Datum *) getheap((count + 1) * sizeof(Datum)); p[0].type = INTEGER; p[0].u.i = count; count = 1; for (i = 0; i <= HASHSIZE; i++) { for (sp = hashtable[i]; sp != (symptr) 0; sp = sp->next) { if (any || type == sp->stype || (pointer && is_address(sp->d)) || type == sp->d.type) { dpush(d, STRING, sp->name); p[count++] = pop(); } } } d.type = LIST; d.u.a = p; push(d); } /* transform the internal symbol table into a list */ void symtbl2list(void) { extern symptr hashtable[]; extern char *typename(int); symptr sp; Datum d; Datum *p; Int count; Int i; count = 0; for (i = 0; i <= HASHSIZE; i++) for (sp = hashtable[i]; sp != (symptr) 0; sp = sp->next) count++; p = (Datum *) getheap((count + 1) * sizeof(Datum)); p[0].type = INTEGER; p[0].u.i = count; count = 1; for (i = 0; i <= HASHSIZE; i++) { for (sp = hashtable[i]; sp != (symptr) 0; sp = sp->next) { dpush(d, STRING, sp->name); dpush(d, STRING, typename(sp->stype)); if (sp->text) { dpush(d, STRING, sp->text); } else { dpush(d, STRING, ""); } pushlist(&sp->targets); pushlist(&sp->sources); makearr(5); p[count++] = pop(); } } d.type = LIST; d.u.a = p; push(d); } void printhash(void) { /* for debugging */ extern symptr hashtable[]; symptr sp; int i; for (i = 0; i <= HASHSIZE; i++) { printf("%d ----------------------\n", i); for (sp = hashtable[i]; sp != (symptr) 0; sp = sp->next) { printf("%s\n", sp->name); } } pushUNDEF(); } #ifndef TTYEDEN static char defn[4096]; void tkdefineDatum(Datum d, char *s) { int i; char *t; if (is_symbol(d)) { sprintf(s, "&%s", symbol_of(d)->name); s += strlen(s); } else if (is_local(d)) { sprintf(s, "(local variable #%d, ", local(d)); s += strlen(s); sprintf(s, address_type(d) == DPTR ? "data pointer: %d)" : "char pointer: %d)", d.u.v.x); s += strlen(s); } else { switch (d.type) { case REAL: sprintf(s, "%g", d.u.r); s += strlen(s); break; case INTEGER: sprintf(s, "%d", d.u.i); s += strlen(s); break; case MYCHAR: sprintf(s, "'%c'", d.u.i); s += strlen(s); break; case STRING: if (d.u.s) { *s++ = '"'; for (t = d.u.s; *t != '\0'; t++) { switch (*t) { case '\\': *s++ = '\\'; *s++ = '\\'; break; case '"': *s++ = '\\'; *s++ = '"'; break; default: *s++ = *t; break; } } *s++ = '"'; *s++ = '\0'; } break; case LIST: sprintf(s, "["); s++; for (i = 1; i <= d.u.a[0].u.i; i++) { tkdefineDatum(d.u.a[i], s); s += strlen(s); if (i < d.u.a[0].u.i) { sprintf(s, ","); s++; } } sprintf(s, "]"); s++; break; case VAR: sprintf(s, "(%s is variable)", d.u.sym->name); s += strlen(s); break; case BLTIN: sprintf(s, "(%s is built-in function)", d.u.sym->name); s += strlen(s); break; case LIB: case RLIB: sprintf(s, "(%s is C function)", d.u.sym->name); s += strlen(s); break; case FORMULA: sprintf(s, "(%s is formula)", d.u.sym->name); s += strlen(s); break; case FUNCTION: sprintf(s, "(%s is user-defined function)", d.u.sym->name); s += strlen(s); break; case PROCEDURE: sprintf(s, "(%s is user-defined procedure)", d.u.sym->name); s += strlen(s); break; case PROCMACRO: sprintf(s, "(%s is user-defined procmacro)", d.u.sym->name); s += strlen(s); break; case UNDEF: sprintf(s, "@"); s++; break; default: sprintf(s, "(type=%d, val=%d)", d.type, d.u.i); break; } } } void tkdefine(symptr sp) { Tcl_DString command, message; if (*sp->name == '\0') return; /* why are there such cases? */ Tcl_DStringInit(&command); Tcl_DStringInit(&message); Tcl_DStringAppend(&command, "edenDefn ", -1); Tcl_DStringAppendElement(&command, sp->name); Tcl_DStringAppendElement(&message, sp->entry == INTERNAL ? "internal" : sp->entry == ARCA ? "arca" : sp->entry == SCOUT ? "scout" : sp->entry == DONALD ? "donald" : "eden"); Tcl_DStringAppendElement(&message, sp->master); Tcl_DStringAppendElement(&command, message.string); Tcl_DStringFree(&message); switch (sp->stype) { case FORMULA: Tcl_DStringAppend(&message, sp->name, -1); Tcl_DStringAppend(&message, " is", -1); Tcl_DStringAppend(&message, sp->text, -1); Tcl_DStringAppend(&message, "\n", -1); break; case FUNCTION: case PROCMACRO: case PROCEDURE:{ symptr_QUEUE *P, *Q; char *s = defn; Q = &sp->sources; for (P = FRONT(Q); P; P = NEXT(Q, P)) { sprintf(s, "%s %s", P == Q->next ? " :" : ",", P->obj->name); s += strlen(s); } *s++ = ' '; *s = '\0'; } Tcl_DStringAppend(&message, sp->stype == FUNCTION ? "func " : (sp->stype == PROCMACRO ? "procmacro " : "proc "), -1); Tcl_DStringAppend(&message, sp->name, -1); Tcl_DStringAppend(&message, defn, -1); if (sp->text) { Tcl_DStringAppend(&message, sp->text, -1); Tcl_DStringAppend(&message, "\n", -1); } break; default: tkdefineDatum(sp->d, defn); Tcl_DStringAppend(&message, sp->name, -1); Tcl_DStringAppend(&message, " = ", -1); Tcl_DStringAppend(&message, defn, -1); Tcl_DStringAppend(&message, ";\n", -1); break; } Tcl_DStringAppendElement(&command, message.string); if (Tcl_Eval(interp, command.string) != TCL_OK) { Tcl_DStringFree(&command); Tcl_DStringFree(&message); error2("Tcl errorInfo (from tkdefine): ", Tcl_GetVar(interp, "errorInfo", 0)); } Tcl_DStringFree(&command); Tcl_DStringFree(&message); } #ifdef DISTRIB void tkdefine1(symptr sp) { extern void push_text(char *, int); if (*sp->name == '\0') return; /* why are there such cases? */ push_text("%eden\n", 6); switch (sp->stype) { case FORMULA: push_text(sp->name, strlen(sp->name)); push_text(" is ", 4); push_text(sp->text, strlen(sp->text)); push_text("\n", 1); break; case FUNCTION: case PROCMACRO: case PROCEDURE: { symptr_QUEUE *P, *Q; char *s = defn; Q = &sp->sources; for (P = FRONT(Q); P; P = NEXT(Q, P)) { sprintf(s, "%s %s", P == Q->next ? " :" : ",", P->obj->name); s += strlen(s); } *s++ = ' '; *s = '\0'; } switch (sp->stype) { case FUNCTION: push_text("func ", 5); case PROCEDURE: push_text("proc ", 5); case PROCMACRO: push_text("procmacro ", 10); } push_text(sp->name, strlen(sp->name)); push_text(defn, strlen(defn)); if (sp->text) push_text(sp->text, strlen(sp->text)); push_text("\n", 1); break; default: tkdefineDatum(sp->d, defn); push_text(sp->name, strlen(sp->name)); push_text(" = ", 3); push_text(defn, strlen(defn)); push_text(";\n", 2); break; } push_text("\0", 1); } #endif /* DISTRIB */ int isUserDefined(symptr sp) { switch (sp->stype) { case FORMULA: case FUNCTION: case PROCMACRO: case PROCEDURE: return 1; default: switch (sp->d.type) { case REAL: case INTEGER: case MYCHAR: case STRING: case LIST: case VAR: return 1; case UNDEF: if (sp->changed == FALSE) return 1; } } return 0; } int isNotYetDefined(symptr sp) { switch (sp->stype) { case FORMULA: case FUNCTION: case PROCMACRO: case PROCEDURE: return 0; default: switch (sp->d.type) { case UNDEF: if (sp->changed) return 1; } } return 0; } /* AcceptTable holds a string representing a Tcl list containing the numerical indices of all the elements in the View Options listbox (ie agent names) that the user has selected. [Ash] */ static char *AcceptTable = 0; /* assuming this is enough to hold a large number of agent names */ #define ACCEPTTABLESIZE 2048 static void buildAcceptTable(void) { char *indices, *s; if (AcceptTable) free(AcceptTable); Tcl_Eval(interp, "winfo exists .view.left.list"); if (strcmp(interp->result, "0")) { /* window exists */ Tcl_EvalEC(interp, ".view.left.list curselection"); indices = strdup(Tcl_GetStringResult(interp)); /* find elements from listbox that correspond to the indices we have */ AcceptTable = emalloc(ACCEPTTABLESIZE); AcceptTable[0] = '\0'; s = strtok(indices, " "); while (s) { Tcl_VarEval(interp, ".view.left.list get ", s, 0); strncat(AcceptTable, interp->result, ACCEPTTABLESIZE); strncat(AcceptTable, " ", ACCEPTTABLESIZE); s = strtok(0, " "); } free(indices); } else { /* window does not exist */ AcceptTable = 0; } } /* Return 1 if the given agent name was selected for query by the user [Ash] */ static int acceptable(char *name) { char *s1, *s; if (!AcceptTable) return 1; s1 = strdup(AcceptTable); s = strtok(s1, " "); while (s) { if (strcmp(s, name) == 0) { free(s1); return 1; } s = strtok(0, " "); } free(s1); return 0; } static int symcmp( /* symptr *, symptr * */ ); /* qsort doesn't like full prototype */ /* print the internal symbol table into a Tk text Window */ int dumpeden(ClientData clientData, Tcl_Interp * interp, int argc, char *argv[]) { extern char *hptr; char *saveHeapPtr; extern symptr hashtable[]; symptr sp; symptr *p; symptr *pptr; Int count; Int i; char entry, show_not_yet_defined; char *lastMaster = ""; if (argc != 3) { Tcl_AppendResult(interp, "wrong # args: should be \"", "dumpeden notation-option show-not-yet-define\"", 0); return TCL_ERROR; } entry = atoi(argv[1]); show_not_yet_defined = atoi(argv[2]); /* Setting the fourth bit in the first argument causes dumpeden to use the same options as last time [Ash] */ if (!(entry & 0x8)) { buildAcceptTable(); } count = 0; for (i = 0; i <= HASHSIZE; i++) for (sp = hashtable[i]; sp != (symptr) 0; sp = sp->next) if ((isUserDefined(sp) || (show_not_yet_defined && isNotYetDefined(sp))) && acceptable(sp->master) && (((entry & 0x1) && sp->entry == SCOUT) || ((entry & 0x2) && sp->entry == DONALD) || sp->entry <= EDEN)) count++; saveHeapPtr = hptr; p = (symptr *) getheap(count * sizeof(symptr)); pptr = p; for (i = 0; i <= HASHSIZE; i++) for (sp = hashtable[i]; sp != (symptr) 0; sp = sp->next) if ((isUserDefined(sp) || (show_not_yet_defined && isNotYetDefined(sp))) && acceptable(sp->master) && (((entry & 0x1) && sp->entry == SCOUT) || ((entry & 0x2) && sp->entry == DONALD) || #ifdef WANT_SASAMI ((entry & 0x4) && sp->entry == SASAMI) || #endif sp->entry <= EDEN)) *pptr++ = sp; qsort(p, count, sizeof(symptr), symcmp); Tcl_EvalEC(interp, "cleanup eden"); for (i = 0; i < count; i++) { if (strcmp(p[i]->master, lastMaster)) { lastMaster = p[i]->master; Tcl_EvalEC(interp, ".eden.t.text config -state normal"); Tcl_VarEval(interp, ".eden.t.text insert end {AGENT ", lastMaster, "\n} masteragent", 0); Tcl_EvalEC(interp, ".eden.t.text config -state disabled"); } tkdefine(p[i]); } hptr = saveHeapPtr; Tcl_EvalEC(interp, ".eden.t.text mark set insert 1.0"); Tcl_EvalEC(interp, ".eden.t.text see insert"); return TCL_OK; } /* build a list of agents to be used in the View Options window */ int viewOptions(ClientData clientData, Tcl_Interp * interp, int argc, char *argv[]) { extern char *hptr; char *saveHeapPtr; extern symptr hashtable[]; symptr sp; symptr *p; symptr *pptr; Int count; Int i; char *lastMaster; if (argc != 1) { Tcl_AppendResult(interp, "wrong # args: should be \"", "setupViewOptions\"", 0); return TCL_ERROR; } lastMaster = ""; count = 0; for (i = 0; i <= HASHSIZE; i++) for (sp = hashtable[i]; sp != (symptr) 0; sp = sp->next) { if (strcmp(sp->master, lastMaster) && isUserDefined(sp)) { count++; lastMaster = sp->master; } } saveHeapPtr = hptr; p = (symptr *) getheap(count * sizeof(symptr)); lastMaster = ""; pptr = p; for (i = 0; i <= HASHSIZE; i++) for (sp = hashtable[i]; sp != (symptr) 0; sp = sp->next) { if (strcmp(sp->master, lastMaster) && isUserDefined(sp)) { *pptr++ = sp; lastMaster = sp->master; } } qsort(p, count, sizeof(symptr), symcmp); lastMaster = ""; for (i = 0; i < count; i++) { if (strcmp(p[i]->master, lastMaster)) { lastMaster = p[i]->master; Tcl_VarEval(interp, ".view.left.list insert end ", lastMaster, 0); } } hptr = saveHeapPtr; return TCL_OK; } static int symcmp(symptr * s1, symptr * s2) { int m; if (*s1 == *s2) return 0; if ((m = strcmp((*s1)->master, (*s2)->master))) return m; if ((*s1)->stype > (*s2)->stype) return 1; if ((*s1)->stype == (*s2)->stype) return strcmp((*s1)->name, (*s2)->name); return -1; } #endif /* not TTYEDEN ? */ /* forget a symbol named by the string (1st arg) from internal symbol table into a list */ #define OK 0 #define NOTFOUND 1 #define FAIL 2 void forget(void) { extern symptr hashtable[]; extern int hashindex(char *); extern symptr_QUEUE formula_queue, action_queue; extern void refer_to(symptr, symptr_QUEUE *); Datum d; int error_code; char *s; symptr sp, last; int i; symptr_QUEUE *Q; if (paracount < 1 || para(1).type != STRING) usage("forget(\"object_name\");"); s = para(1).u.s; last = (symptr) 0; error_code = NOTFOUND; i = hashindex(s); for (sp = hashtable[i]; sp != (symptr) 0; sp = (last = sp)->next) { if (strcmp(sp->name, s) == 0) { /* find sp */ ; if (Q_EMPTY(&sp->targets)) { if (sp->name) free(sp->name); /* if (sp->inst) free(sp->inst); */ if (sp->text) free(sp->text); freedatum(sp->d); /* sp->targets is already EMPTY */ refer_to(sp, &sp->targets); /* free sources */ if (last) last->next = sp->next; else hashtable[i] = sp->next; free(sp); error_code = OK;/* OK */ } else { /* some objects refers to this var */ /* FAIL */ /* error("can't forget", sp->name); */ error_code = FAIL; } /* remove object from evaluation queue */ switch (sp->stype) { case FORMULA: Q = &formula_queue; break; case BLTIN: case PROCEDURE: case FUNCTION: case PROCMACRO: Q = &action_queue; break; default: /* Is it an error ? */ Q = 0; break; /* don't queue up */ } if (Q) { DELETE_symptr_ATOM(Q, sp->Qloc); sp->Qloc = 0; } break; } } dpush(d, INTEGER, error_code); } static void packpara(Datum d, char *err_msg) { if (is_address(d)) *((Int *) getheap(sizeof(Int))) = (Int) & (dptr(d)->u.i); else switch (d.type) { case REAL: *((float *) getheap(sizeof(float))) = d.u.r; break; case INTEGER: *((int *) getheap(sizeof(int))) = d.u.i; break; case MYCHAR: *((char *) getheap(sizeof(char))) = d.u.i; break; case STRING: *((char **) getheap(sizeof(char **))) = d.u.s; break; case LIST: { Int n, i; n = d.u.a[0].u.i; /* no. of items */ for (i = 1; i <= n; i++) packpara(d.u.a[i], err_msg); } break; default: usage(err_msg); break; } } #define parameters (*fp->stackp) void pack(void) { char *mem; Datum d; mem = getheap(0); /* find the begin of memory block */ packpara(parameters, "address=pack(data,...);"); dpush(d, INTEGER, mem); } void array(void) { Int n; Datum d; if (paracount < 1) usage("list = array(n, data);"); mustint(para(1), "array()"); n = para(1).u.i; if (n < 0) error("listcat: -ve number in 1st argument"); if (paracount > 1) d = para(2); else d = UndefDatum; while (n--) push(d); makearr(para(1).u.i); } void user_error(void) { /* generate an error */ if (paracount > 0) { muststr(para(1), "user_error"); error(para(1).u.s); } else error("run-time error"); /* don't need a push since "error" never return */ } /*- touch variables (pointed to by a pointer) only their parents shall be re-evaluated -*/ void touch(void) { extern void schedule_parents_of(symptr); extern void eval_formula_queue(void); int i; for (i = 1; i <= paracount; i++) schedule_parents_of((symptr) para(i).u.v.y); eval_formula_queue(); pushUNDEF(); } void get_environ(void) { Datum d; char *s; if (paracount < 1) usage("string = getenv(\"env_name\")"); muststr(para(1), "getenv()"); if ((s = getenv(para(1).u.s))) { dpush(d, STRING, s); } else pushUNDEF(); } void put_environ(void) { Datum d; char *s; if (paracount < 1) usage("ok = putenv(\"env_name=value\")"); muststr(para(1), "putenv()"); s = getheap(strlen(para(1).u.s) + 1); strcpy(s, para(1).u.s); dpush(d, INTEGER, putenv(s)); } /*** errno ***/ #include void error_no(void) { Datum d; dpush(d, INTEGER, errno); } /*** process ***/ #undef FAIL #define FAIL (-1) void backgnd(void) { int pid; Datum d; Datum *p; int argc, i; char **argv; p = ¶(0); argc = p[0].u.i; if (argc < 2) usage("pid = backgnd(\"cmd\", \"cmd\", \"arg1\", ...);"); argv = (char **) emalloc(sizeof(char *) * argc); for (i = 2; i <= argc; i++) { muststr(p[i], "backgnd()"); argv[i - 2] = p[i].u.s; } argv[argc - 1] = (char *) 0; pid = fork(); switch (pid) { case 0: /* child process */ { FILE *f; f = fopen("/dev/null", "r"); close(0); /* close stdin */ dup2(fileno(f), 0); /* redirect stdin to /dev/null */ fclose(f); } pid = execvp(para(1).u.s, argv); if (pid == FAIL) { /* can't execute */ noticef("backgnd: can't execute %s\n", para(1).u.s); } break; default: /* parent process */ dpush(d, INTEGER, pid); break; } free(argv); } void pipe_process(void) { int pid; Datum d; Datum *p; int argc, i; char **argv; int fdes[2]; p = ¶(0); argc = p[0].u.i; if (argc < 2) usage("pid = pipe_process(\"cmd\", \"cmd\", \"arg1\", ...);"); muststr(p[1], "pipe_process()"); argv = (char **) getheap(sizeof(char *) * argc); for (i = 2; i <= argc; i++) { muststr(p[i], "pipe_process()"); argv[i - 2] = p[i].u.s; } argv[argc - 1] = (char *) 0; if (pipe(fdes) != FAIL) { pid = fork(); switch (pid) { case 0: /* child process */ i = fileno(stdin); close(i); /* close stdin */ dup2(fdes[0], i); /* redirect stdin */ close(fdes[1]); /* close other end */ pid = execvp(p[1].u.s, argv); if (pid == FAIL) { /* can't execute */ noticef("pipe: can't execute %s\n", p[1].u.s); } break; default: /* parent process */ i = fileno(stdout); close(i); /* close stdout */ dup2(fdes[1], i); /* redirect stdout */ close(fdes[0]); /* close other end */ dpush(d, INTEGER, pid); break; } } } void todo(void) { extern void queue(char *, char *); if (paracount < 1) usage("todo(string);"); muststr(para(1), "todo()"); queue(para(1).u.s, topMasterStack()); /* keep to the same master */ pushUNDEF(); } void get_msgq(void) { #ifdef ipc Datum d; if (paracount < 2) usage("msqid = get_message_queue(key,msgflg);"); mustint(para(1), "get_msgq()"); mustint(para(2), "get_msgq()"); dpush(d, INTEGER, msgget((key_t) para(1).u.i, para(2).u.i)); #endif } #define MSG_SIZE 1024 void send_message(void) { #ifdef ipc int msqid, msgflg; int result; int msize; Datum *p; Datum d; static struct msgbuf msg; p = ¶(0); if (p[0].u.i < 3) /* paracount */ usage("ok = send_msg(msqid,[mtype,mtext],msgflg);"); mustint(p[1], "send_msg()"); mustlist(p[2], "send_msg()"); if (p[2].u.a[0].u.i < 2) usage("ok = send_msg(msqid,[mtype,mtext],msgflg);"); mustint(p[2].u.a[1], "send_msg()"); muststr(p[2].u.a[2], "send_msg()"); mustint(p[3], "send_msg()"); msqid = p[1].u.i; msgflg = p[3].u.i; msg.mtype = (long) p[2].u.a[1].u.i; strncpy(msg.mtext, p[2].u.a[2].u.s, MSG_SIZE); msize = strlen(msg.mtext) + 1; if (msize > MSG_SIZE) msize = MSG_SIZE; result = msgsnd(msqid, &msg, msize, msgflg); if (result == -1) perror("send_msg"); dpush(d, INTEGER, result); #endif } void receive_message(void) { #ifdef ipc Datum *p; Datum d; int i, size; static struct msgbuf msg; p = ¶(0); if (p[0].u.i < 3) /* paracount */ usage("[mtype,mtext] = receive_message(msqid,mtype,msgflg);"); for (i = 1; i <= 3; i++) mustint(p[i], "receive_message()"); size = msgrcv(p[1].u.i, &msg, MSG_SIZE, (long) p[2].u.i, p[3].u.i); if (size == -1) { pushUNDEF(); } else { /* terminate the message with null character */ msg.mtext[(size >= MSG_SIZE) ? MSG_SIZE - 1 : size] = '\0'; dpush(d, INTEGER, msg.mtype); dpush(d, STRING, msg.mtext); makearr(2); } #endif } void remove_msgq(void) { #ifdef ipc Datum d; if (paracount < 1) usage("remove_msgq(msqid);"); mustint(para(1), "remove_msgq()"); dpush(d, INTEGER, msgctl(para(1).u.i, IPC_RMID, 0)); #endif } #ifndef TTYEDEN /* X Windows Stuff */ /**** * EX Commands * ****/ void E_Disp2PS(void) { if (paracount < 2) usage("Disp2PS(screen, file);"); pushUNDEF(); } void E_StringRemain(void) { if (paracount < 2) usage("StringRemain(screen, box);"); pushUNDEF(); } void E_tcl(void) { extern void warning(char *, char *); Datum d; if (paracount < 1) usage("string tcl(string)"); /* printf("E_tcl %s\n", para(1).u.s); */ if (Tcl_GlobalEval(interp, para(1).u.s) == TCL_OK) { dpush(d, STRING, interp->result); } else { char * errorInfo; errorInfo = interp->result; /* Can't use errorf etc as this uses Tcl, which might be in a mess... */ fprintf(stderr, "Eden tcl command, whilst executing `%s`, got Tcl errorInfo: %s\n", para(1).u.s, errorInfo); pushUNDEF(); } } static void Append(char *v, char *name, char *box) { Datum screenName, boxName; char *s; symptr sp; Datum *a; sp = lookup(v); if (sp == NULL) sp = install(v, VAR, UNDEF, 0); if (isundef(sp->d)) { makearr(0); sp->d = newdatum(pop()); } push(sp->d); s = (char *) getheap(strlen(name) + 1); strcpy(s, name); dpush(screenName, STRING, s); s = (char *) getheap(strlen(box) + 1); strcpy(s, box); dpush(boxName, STRING, s); makearr(2); a = (Datum *) erealloc(sp->d.u.a, (sp->d.u.a->u.i + 2) * sizeof(Datum)); a[++a->u.i] = newdatum(pop()); sp->d.u.a = a; sp->entry = topEntryStack(); sp->master = topMasterStack(); change(sp, FALSE); } static void Remove(char *v, char *name, char *box) { Datum d; int i, j; symptr sp; sp = lookup(v); for (i = sp->d.u.a[0].u.i; i > 0; i--) { d = sp->d.u.a[i]; if (d.u.a[0].u.i == 2 && isstr(d.u.a[1]) && strcmp(d.u.a[1].u.s, name) == 0 && isstr(d.u.a[2]) && strcmp(d.u.a[2].u.s, box) == 0) break; } if (i > 0) { freedatum(d); for (j = i + 1; j <= sp->d.u.a[0].u.i; j++) sp->d.u.a[j - 1] = sp->d.u.a[j]; --sp->d.u.a[0].u.i; sp->entry = topEntryStack(); sp->master = topMasterStack(); change(sp, FALSE); } } #include "screen.q.h" /* create a screen queue for bug fix --sun */ static ScoutScreenQ ScoutScreenList = EMPTYQUEUE(ScoutScreenList); #include "screen.q.c" /* create a screen queue - bug fix --sun */ void DisplayScreen(void) { Datum screen; int noOfscreen, noOfoScreen, next_ref, select; int k, l, r; int lskip, rskip; intQ *newref, *oldref, *new, discard, *ref, *r2; char *name; int lastBox; char s[256]; char *t; winfo *WinInfo; Datum oScreen; /* changed to variable rather than static --sun*/ winfo *oWinInfo; int MaxRef; intQ *Refer; ScoutScreen_ATOM ssptr; ScoutScreenQ ssq; if (paracount < 2 || !is_symbol(para(1)) || para(2).type != STRING) usage("DisplayScreen(&screen, screen_name);"); screen = symbol_of(para(1))->d; name = para(2).u.s; if (isundef(screen)) error("DisplayScreen called with screen undefined"); if (Q_EMPTY(&ScoutScreenList)) {init_ScoutScreenList();} if (!(ssptr = search_ScoutScreenQ(name))) {ssptr = add_ScoutScreen(name);} /* initialization */ oScreen = ssptr->obj.oScreen; Refer = ssptr->obj.Refer; MaxRef = ssptr->obj.MaxRef; oWinInfo = ssptr->obj.oWinInfo; /* trimming the size of the differences */ noOfscreen = screen.u.a[0].u.i; noOfoScreen = oScreen.u.a[0].u.i; k = (noOfscreen < noOfoScreen) ? noOfscreen : noOfoScreen; for (l = 1; l <= k; l++) if (datacmp(screen.u.a[l], oScreen.u.a[l])) break; lskip = l - 1; for (r = 0; r < k - lskip; r++) if (datacmp(screen.u.a[noOfscreen - r], oScreen.u.a[noOfoScreen - r])) break; rskip = r; /* printf("here %i %i %i %i %s %i\n", noOfscreen, noOfoScreen, lskip, rskip, name, MaxRef); */ /* match new windows to old windows */ newref = (intQ *) getheap(sizeof(intQ) * (noOfscreen - rskip - lskip)); for (l = 0; l < noOfscreen - rskip - lskip; l++) newref[l].prev = newref[l].next = newref + l; oldref = (intQ *) getheap(sizeof(intQ) * (noOfoScreen - rskip - lskip)); for (l = 0; l < noOfoScreen - rskip - lskip; l++) oldref[l].prev = oldref[l].next = oldref + l; for (k = lskip; k < noOfoScreen - rskip; k++) { for (l = lskip; l < noOfscreen - rskip; l++) { if (datacmp(oScreen.u.a[k + 1], screen.u.a[l + 1]) == 0) { /* identical window, take precedence */ new = (intQ *) getheap(sizeof(intQ)); new->obj = l; INSERT_Q(&oldref[k - lskip], new); new = (intQ *) getheap(sizeof(intQ)); new->obj = k; INSERT_Q(&newref[l - lskip], new); } else if ((oScreen.u.a[k + 1].u.a[1].u.i != 0 && oScreen.u.a[k + 1].u.a[1].u.i != 4) && (screen.u.a[l + 1].u.a[1].u.i != 0 && screen.u.a[l + 1].u.a[1].u.i != 4) && strcmp(oScreen.u.a[k + 1].u.a[5].u.s, screen.u.a[l + 1].u.a[5].u.s) == 0) { /* same picture, lower in precedence */ new = (intQ *) getheap(sizeof(intQ)); new->obj = l; APPEND_Q(&oldref[k - lskip], new); new = (intQ *) getheap(sizeof(intQ)); new->obj = k; APPEND_Q(&newref[l - lskip], new); } } } CLEAN_Q(&discard); next_ref = noOfoScreen + 1; for (l = lskip; l < noOfoScreen - rskip; l++) if (Q_EMPTY(&oldref[l - lskip])) { new = (intQ *) getheap(sizeof(intQ)); new->obj = l; APPEND_Q(&discard, new); } for (l = lskip; l < noOfscreen - rskip; l++) { if (Q_EMPTY(&newref[l - lskip])) { if (Q_EMPTY(&discard)) { select = next_ref++; } else { select = discard.next->obj; discard.next = discard.next->next; discard.next->prev = &discard; new = (intQ *) getheap(sizeof(intQ)); new->obj = l; INSERT_Q(&oldref[select - lskip], new); } } else { select = newref[l - lskip].next->obj; for (ref = newref[l - lskip].next->next; ref != &newref[l - lskip]; ref = ref->next) { for (r2 = oldref[ref->obj - lskip].next; r2 != &oldref[ref->obj - lskip]; r2 = r2->next) { if (r2->obj == l) { r2 = r2->prev; r2->next = r2->next->next; r2->next->prev = r2; } } } for (ref = oldref[select - lskip].next; ref != &oldref[select - lskip]; ref = ref->next) { for (r2 = newref[ref->obj - lskip].next; r2 != &newref[ref->obj - lskip]; r2 = r2->next) { if (r2->obj == select) { r2 = r2->prev; r2->next = r2->next->next; r2->next->prev = r2; } } } } newref[l - lskip].obj = select; } /* final judgment if any window should actually be discarded */ CLEAN_Q(&discard); for (l = lskip; l < noOfoScreen - rskip; l++) if (Q_EMPTY(&oldref[l - lskip])) { new = (intQ *) getheap(sizeof(intQ)); new->obj = l; APPEND_Q(&discard, new); } /* remove unmatched old windows */ for (ref = discard.next; ref != &discard; ref = ref->next) { new = (intQ *) emalloc(sizeof(intQ)); new->obj = oWinInfo[ref->obj].ref; APPEND_Q(Refer, new); for (r = oWinInfo[ref->obj].nbox; r > 0; --r) { sprintf(s, "catch {destroy .%s.b%d_%d}", name, oWinInfo[ref->obj].ref, r); Tcl_EvalEC(interp, s); } if ((oScreen.u.a[ref->obj + 1].u.a[1].u.i != 0) && (oScreen.u.a[ref->obj + 1].u.a[1].u.i != 4)) { sprintf(s, "b%d_1", oWinInfo[ref->obj].ref); Remove(oScreen.u.a[ref->obj + 1].u.a[5].u.s, name, s); } } /* setup new WinInfo */ WinInfo = (winfo *) emalloc(sizeof(winfo) * noOfscreen); for (r = 0; r < lskip; r++) WinInfo[r] = oWinInfo[r]; for (r = lskip; r < noOfscreen - rskip; r++) { if (newref[r - lskip].obj > noOfoScreen) { if (Q_EMPTY(Refer)) { WinInfo[r].ref = MaxRef++; } else { WinInfo[r].ref = Refer->next->obj; Refer->next = Refer->next->next; free(Refer->next->prev); Refer->next->prev = Refer; } WinInfo[r].nbox = 0; } else { WinInfo[r] = oWinInfo[newref[r - lskip].obj]; } } for (r = 1; r <= rskip; r++) WinInfo[noOfscreen - r] = oWinInfo[noOfoScreen - r]; /* draw new windows */ for (r = lskip; r < noOfscreen - rskip; r++) { Datum New, Old, win, screenName, winNo, boxName; if (newref[r - lskip].obj > noOfoScreen) { /* add window */ win = screen.u.a[r + 1]; switch (win.u.a[1].u.i) { /* looks like switching on CONTENT [Ash] */ case 0: /* TEXT [Ash] */ for (k = 1; k <= win.u.a[2].u.a[0].u.i; k++) { sprintf(s, "canvas .%s.b%d_%d", name, WinInfo[r].ref, k); Tcl_EvalEC(interp, s); } WinInfo[r].nbox = win.u.a[2].u.a[0].u.i; t = getheap(strlen(name) + 1); strcpy(t, name); dpush(screenName, STRING, t); dpush(winNo, INTEGER, r + 1); sprintf(s, "b%d", WinInfo[r].ref); t = getheap(strlen(s) + 1); strcpy(t, s); dpush(boxName, STRING, t); makearr(3); /* The next line is to make sure that the call command will not cause agentName to be prefixed to variables --sun */ appAgentName--; call(lookup("scout_show_canvas"), pop(), 0); appAgentName++; break; case 4: /* TEXTBOX [Ash] */ for (k = 1; k <= win.u.a[2].u.a[0].u.i; k++) { sprintf(s, "text .%s.b%d_%d", name, WinInfo[r].ref, k); Tcl_EvalEC(interp, s); } WinInfo[r].nbox = win.u.a[2].u.a[0].u.i; t = getheap(strlen(name) + 1); strcpy(t, name); dpush(screenName, STRING, t); dpush(winNo, INTEGER, r + 1); sprintf(s, "b%d", WinInfo[r].ref); t = getheap(strlen(s) + 1); strcpy(t, s); dpush(boxName, STRING, t); makearr(3); appAgentName--; call(lookup("scout_show_text"), pop(), 0); appAgentName++; break; case 1: /* DONALD [Ash] */ case 2: /* ARCA [Ash] */ default: /* IMAGE is 3 [Ash] */ sprintf(s, "canvas .%s.b%d_1", name, WinInfo[r].ref); Tcl_EvalEC(interp, s); WinInfo[r].nbox = 1; t = getheap(strlen(name) + 1); strcpy(t, name); dpush(screenName, STRING, t); /* 1st argument to scout_show_2D [Ash] */ dpush(winNo, INTEGER, r + 1); /* 2nd arg [Ash] */ sprintf(s, "b%d", WinInfo[r].ref); t = getheap(strlen(s) + 1); strcpy(t, s); dpush(boxName, STRING, t); /* 3rd arg [Ash] */ makearr(3); appAgentName--; call(lookup("scout_show_2D"), pop(), 0); appAgentName++; sprintf(s, "b%d_1", WinInfo[r].ref); Append(screen.u.a[r + 1].u.a[5].u.s, name, s); break; } } else if (datacmp(screen.u.a[r + 1], oScreen.u.a[newref[r - lskip].obj + 1])) { /* change existing window */ New = screen.u.a[r + 1]; Old = oScreen.u.a[newref[r - lskip].obj + 1]; for (k = New.u.a[2].u.a[0].u.i + 1; k <= Old.u.a[2].u.a[0].u.i; k++) { sprintf(s, "catch { destroy .%s.b%d_%d }", name, oWinInfo[r].ref, k); Tcl_EvalEC(interp, s); } for (k = Old.u.a[2].u.a[0].u.i + 1; k <= New.u.a[2].u.a[0].u.i; k++) { switch (New.u.a[1].u.i) { case 4: /* TEXTBOX [Ash] */ sprintf(s, "text .%s.b%d_%d", name, WinInfo[r].ref, k); Tcl_EvalEC(interp, s); break; default: /* TEXT [Ash] */ sprintf(s, "canvas .%s.b%d_%d", name, WinInfo[r].ref, k); Tcl_EvalEC(interp, s); break; } } WinInfo[r].nbox = New.u.a[2].u.a[0].u.i; if (((Old.u.a[1].u.i != 0) && (Old.u.a[1].u.i != 4)) || ((New.u.a[1].u.i != 0) && (New.u.a[1].u.i != 4)) || strcmp(Old.u.a[5].u.s, New.u.a[5].u.s)) { if (Old.u.a[1].u.i != 0 && Old.u.a[1].u.i != 4) { sprintf(s, "b%d_1", oWinInfo[newref[r - lskip].obj].ref); Remove(Old.u.a[5].u.s, name, s); } if (New.u.a[1].u.i != 0 && New.u.a[1].u.i != 4) { sprintf(s, "b%d_1", WinInfo[r].ref); Append(New.u.a[5].u.s, name, s); } } switch (New.u.a[1].u.i) { /* looks like switching on CONTENT [Ash] */ case 0: /* TEXT [Ash] */ t = getheap(strlen(name) + 1); strcpy(t, name); dpush(screenName, STRING, t); dpush(winNo, INTEGER, r + 1); sprintf(s, "b%d", WinInfo[r].ref); t = getheap(strlen(s) + 1); strcpy(t, s); dpush(boxName, STRING, t); makearr(3); appAgentName--; call(lookup("scout_show_canvas"), pop(), 0); appAgentName++; break; case 4: /* TEXTBOX [Ash] */ t = getheap(strlen(name) + 1); strcpy(t, name); dpush(screenName, STRING, t); dpush(winNo, INTEGER, r + 1); sprintf(s, "b%d", WinInfo[r].ref); t = getheap(strlen(s) + 1); strcpy(t, s); dpush(boxName, STRING, t); makearr(3); appAgentName--; call(lookup("scout_show_text"), pop(), 0); appAgentName++; break; case 1: /* DONALD [Ash] */ case 2: /* ARCA [Ash] */ default: /* IMAGE is 3 [Ash] */ t = getheap(strlen(name) + 1); strcpy(t, name); dpush(screenName, STRING, t); dpush(winNo, INTEGER, r + 1); sprintf(s, "b%d", WinInfo[r].ref); t = getheap(strlen(s) + 1); strcpy(t, s); dpush(boxName, STRING, t); makearr(3); appAgentName--; call(lookup("scout_show_2D"), pop(), 0); appAgentName++; break; } } } /* restack display */ lastBox = lskip == 0 ? 0 : WinInfo[lskip - 1].ref * 100 + WinInfo[lskip - 1].nbox; for (r = lskip; r < noOfscreen - rskip; r++) { for (l = 1; l <= WinInfo[r].nbox; l++) { if (lastBox == 0) { sprintf(s, "raise .%s.b%d_%d", name, WinInfo[r].ref, l); Tcl_EvalEC(interp, s); } else { sprintf(s, "lower .%s.b%d_%d .%s.b%d_%d", name, WinInfo[r].ref, l, name, lastBox / 100, lastBox % 100); Tcl_EvalEC(interp, s); } lastBox = WinInfo[r].ref * 100 + l; } } /* clean up and save information for next change of display */ ssptr->obj.oWinInfo = WinInfo; freedatum(ssptr->obj.oScreen); /* Bug fix - Patrick forgot this, meaning that each time DisplayScreen is called (because the screen changed), we leak some memory. [Ash] */ ssptr->obj.oScreen = newdatum(screen); ssptr->obj.MaxRef = MaxRef; ssptr->obj.Refer = Refer; /* UPDATE_ScoutScreen(name, ssptr); */ pushUNDEF(); } /*** Functions for manipulating assocative memory ***/ typedef struct btree { struct btree *l; struct btree *r; int key; Datum vp; Datum ent; Datum attr; } Btree; Btree *WidgetMap = 0; static Btree * searchKey( Btree * map, int key ) { if (map == 0) { map = (Btree *) emalloc(sizeof(Btree)); map->l = map->r = 0; map->key = 0; return map; } if (map->key == key) return map; if (map->key > key) { if (map->l) return searchKey(map->l, key); else return map; } else if (map->r) return searchKey(map->r, key); else return map; } static void replaceKey(Btree * map, int key, Datum vp, Datum ent, Datum attr) { Btree *ans; Btree *new; ans = searchKey(map, key); if (ans->key != key) { /* not there */ new = (Btree *) emalloc(sizeof(Btree)); new->key = key; new->vp = newdatum(vp); new->ent = newdatum(ent); new->attr = newdatum(attr); if (key > ans->key) { new->l = 0; new->r = ans->r; ans->r = new; } else { new->r = 0; new->l = ans->l; ans->l = new; } } else { /* found */ freedatum(ans->vp); freedatum(ans->ent); freedatum(ans->attr); ans->vp = newdatum(vp); ans->ent = newdatum(ent); ans->attr = newdatum(attr); } } static char lookAttrResult[80]; static void lookAttr(char *s, char *attr) { char *head; int ls, la; ls = strlen(s); la = strlen(attr); if (ls <= la + 1) { lookAttrResult[0] = '\0'; return; } head = strchr(s, ','); if (head == 0) head = s + ls; if (strncmp(s, attr, la) == 0 && s[la] == '=') { strncpy(lookAttrResult, s + la + 1, (head - s) - la - 1); lookAttrResult[(head - s) - la - 1] = '\0'; } else if (*head != '\0') { lookAttr(head + 1, attr); } else { lookAttrResult[0] = '\0'; } } void PlotShape(void) { Datum viewport_list, viewport_name, vp_list, segPtr, attrPtr; Datum d; char *attr; int segid, i, j, fullUpdate; Btree *ans; char s[256]; char *screen, *var, *v; if (paracount < 3 || para(1).type != LIST || !is_symbol(para(3))) usage("PlotShape(viewport_list, segid, &attr);"); viewport_list = para(1); segPtr = para(2); attrPtr = para(3); segid = is_symbol(segPtr) ? segPtr.u.v.x : segPtr.u.i; muststr(symbol_of(attrPtr)->d, "PlotShape()"); attr = symbol_of(attrPtr)->d.u.s; ans = searchKey(WidgetMap, segid); if (WidgetMap == 0) WidgetMap = ans; if (ans->key != segid || datacmp(ans->ent, *dptr(segPtr)) || datacmp(ans->attr, *dptr(attrPtr))) { fullUpdate = 1; } else { /* only the viewport list has changed at most */ fullUpdate = 0; } vp_list = newhdat(viewport_list); if (!fullUpdate) { for (i = vp_list.u.a[0].u.i; i > 0; --i) { for (j = ans->vp.u.a[0].u.i; j > 0; --j) { if (datacmp(vp_list.u.a[i], ans->vp.u.a[j]) == 0) { freedatum(ans->vp.u.a[j]); ans->vp.u.a[j] = UndefDatum; /* don't need to free vp_list.u.a[i] because it is created by newhdat() */ vp_list.u.a[i] = UndefDatum; break; /* expect at most one match */ } } } } lookAttr(attr, "locus"); if (strcmp(lookAttrResult, "true")) { if (ans->key == segid) for (i = 1; i <= ans->vp.u.a[0].u.i; i++) { Datum d; d = ans->vp.u.a[i]; if (isundef(d)) continue; sprintf(s, "if [ winfo exists .%s.%s ] { .%s.%s delete t%d }", d.u.a[1].u.s, d.u.a[2].u.s, d.u.a[1].u.s, d.u.a[2].u.s, segid); Tcl_EvalEC(interp, s); } } lookAttr(attr, "color"); if (strcmp(lookAttrResult, "transparent")) { for (i = 1; i <= vp_list.u.a[0].u.i; i++) { viewport_name = vp_list.u.a[i]; if (isundef(viewport_name)) continue; screen = viewport_name.u.a[1].u.s; var = viewport_name.u.a[2].u.s; push(viewport_name); push(segPtr); push(*dptr(segPtr)); push(attrPtr); sprintf(s, "%s_xOrigin", var); if ((v = Tcl_GetVar(interp, s, TCL_GLOBAL_ONLY)) == NULL) error2("tcl variable not found: ", s); d.type = REAL; d.u.r = atof(v); push(d); sprintf(s, "%s_yOrigin", var); if ((v = Tcl_GetVar(interp, s, TCL_GLOBAL_ONLY)) == NULL) error2("tcl variable not found: ", s); d.type = REAL; d.u.r = atof(v); push(d); sprintf(s, "%s_xScale", var); if ((v = Tcl_GetVar(interp, s, TCL_GLOBAL_ONLY)) == NULL) error2("tcl variable not found: ", s); d.type = REAL; d.u.r = atof(v); push(d); sprintf(s, "%s_yScale", var); if ((v = Tcl_GetVar(interp, s, TCL_GLOBAL_ONLY)) == NULL) error2("tcl variable not found: ", s); d.type = REAL; d.u.r = atof(v); push(d); makearr(8); appAgentName--; call(lookup("draw_shape"), pop(), 0); appAgentName++; } } replaceKey(WidgetMap, segid, viewport_list, *dptr(segPtr), *dptr(attrPtr)); } #endif /* TTYEDEN? */ #ifdef DISTRIB /*---------------------------------------------------------------------------*/ /* for agency --sun */ extern int isServer; extern char *topMasterStack(void); void sendServer(void) /* for distributed tkEden --sun */ { /* send scripts to server by using Tcl */ if (paracount != 2) usage("sendServer(\"servername\", \"scripts\")"); muststr(para(1), "sendServer()"); muststr(para(2), "sendServer()"); SendServer(para(1).u.s, para(2).u.s); } void SendServer(char *serverName, char * sentScripts) { extern void warning(char *, char *); Tcl_DString command; if (isServer) return; if ( *sentScripts != 0) { Tcl_DStringInit(&command); Tcl_DStringAppend(&command, "sendServer ", -1); Tcl_DStringAppendElement(&command, sentScripts); Tcl_EvalEC(interp, command.string); Tcl_DStringFree(&command); } } void sendClient(void) { /* send scripts to server by using Tcl */ if (paracount != 2) usage("sendClient(\"clientname\", \"scripts\")"); muststr(para(1), "sendClient()"); muststr(para(2), "sendClient()"); SendClient(para(1).u.s, para(2).u.s); } void SendClient(char *clientName, char *sentScripts) { extern void warning(char *, char *); Tcl_DString command; char *s; if (!isServer) { s = (char *) malloc(strlen(clientName) + 1 + strlen(sentScripts) + 1 + 20); strcpy(s, "sendClient(\""); strcat(s, clientName); strcat(s, "\", \""); strcat(s, sentScripts); strcat(s, "\");"); SendServer("", s); free(s); return; } if ( *sentScripts != 0 && *clientName !=0) { Tcl_DStringInit(&command); Tcl_DStringAppend(&command, "sendClient ", -1); Tcl_DStringAppendElement(&command, clientName); Tcl_DStringAppendElement(&command, sentScripts); Tcl_EvalEC(interp, command.string); Tcl_DStringFree(&command); } } void SendOtherClients(char *clientName, char *sentScripts) { extern void warning(char *, char *); Tcl_DString command; if ( *sentScripts != 0) { Tcl_DStringInit(&command); Tcl_DStringAppend(&command, "sendOtherClients ", -1); Tcl_DStringAppendElement(&command, clientName); Tcl_DStringAppendElement(&command, sentScripts); Tcl_EvalEC(interp, command.string); Tcl_DStringFree(&command); } } void renewObs(void) { extern char *textptr, textcode[]; extern char agentName[128]; extern symptr lookup(char *); extern int oracle_check(symptr); symptr sp; char *name, *s, *t; int errorSW; if (paracount != 1) usage("renewObs(\"Observablename\")"); muststr(para(1), "renewObs()"); name = para(1).u.s; if (!isServer) { /* Bloody awful use of magic numbers here by Patrick, I'm afraid. This caused a nasty bug: need to do a better way of alloc-ing space for strings. [Ash] */ s = (char *) malloc(strlen(name) + 20); strcpy(s, "renewObs(\""); strcat(s, name); strcat(s, "\");"); SendServer("", s); free(s); return; } /* isServer must now be true (note the return above) [Ash] */ if ((sp = lookup(name)) == 0) { s = (char *) malloc(strlen(name) + 22 + 1); sprintf(s, "no such an observable %s", name); errorSW=1; } else { if (!oracle_check(sp)) { s = (char *) malloc(strlen(name) + 34 + 1); sprintf(s, "no ORACLE privilege on observable %s", name); errorSW=1; } else { s = textptr = textcode; /* set textptr at the begin of textcode */ *textptr = '\0'; tkdefine1(sp); /* will put text into textcode and change textptr */ errorSW = 0; } } if (*s == '\0') { error("unknown error in Query()"); } if (*agentName == '\0') { /* for server */ if (errorSW) { error(s); free(s); } else printf("%s", s); } else { if (errorSW) { t = (char *) malloc(strlen(s) + 50); sprintf(t, "tcl(\"show hist 1\");\n/*** renewObs ERROR \n%s\n***/\n", s); SendClient(agentName, t); free(t); free(s); } else { SendClient(agentName, s); /* This should not be here (duh!). s is set above, and is actually pointing to somewhere in textcode at this point, which was declared in code.c as a statically allocated array. So we don't need to free it. [Ash, Meurig and Chris :] */ /* free(s); */ } } } void queryObs(void) { extern char *textptr, textcode[]; extern char agentName[128]; extern symptr lookup(char *); extern int oracle_check(symptr); symptr sp; char *name, *s, *t, *s1; int errorSW; if (paracount != 1) usage("queryObs(\"Observablename\")"); muststr(para(1), "queryObs()"); name = para(1).u.s; if (!isServer) { s = (char *) malloc(strlen(name) + 20); strcpy(s, "queryObs(\""); strcat(s, name); strcat(s, "\");"); SendServer("", s); free(s); return; } if ((sp = lookup(name)) == 0) { s = (char *) malloc(strlen(name) + 22 + 1); sprintf(s, "no such an observable %s", name); errorSW=1; } else { if (!oracle_check(sp)) { s = (char *) malloc(strlen(name) + 34 + 1); sprintf(s, "no ORACLE privilege on observable %s", name); errorSW=1; } else { s = textptr = textcode; /* set textptr at the begin of textcode */ *textptr = '\0'; tkdefine1(sp); /* will put text into textcode and change textptr */ /* get current value */ switch (sp->d.type) { case VAR: case BLTIN: case LIB: case RLIB: case FUNCTION: case PROCMACRO: case PROCEDURE: s1 = " "; break; case FORMULA: s1 = (char *) malloc(strlen(sp->name) + 30); sprintf(s1, "current state: %s = @\n", sp->name); break; default: tkdefineDatum(sp->d, defn); s1 = (char *) malloc(strlen(defn) + strlen(sp->name) + 30); sprintf(s1, "current state: %s = %s\n", sp->name, defn); break; } errorSW = 0; } } if (*s == '\0') { error("unknown error in Query()"); } if (*agentName == '\0') { /* for server */ if (errorSW) { error(s); free(s); } else {printf("%s%s", s, s1); free(s1); } } else { if (errorSW) { t = (char *) malloc(strlen(s) + 50); sprintf(t, "tcl(\"show hist 1\");\n/*** queryObs\n%s\n***/\n", s); SendClient(agentName, t); free(t); } else { t = (char *) malloc(strlen(s) + strlen(s1) + 50); /* sprintf(t, "writeln(\"%s\", \"%s\");\n", s, s1); */ sprintf(t, "tcl(\"show hist 1\");\n/*** queryObs\n%s%s\n***/\n", s, s1); SendClient(agentName, t); free(t); free(s1); } } } void propagate(void) { if (paracount != 2) usage("propagate(\"Observablename\", \"scripts\")"); muststr(para(1), "propagate()"); muststr(para(2), "propagate()"); if (isServer) propagateAgency1(para(1).u.s, para(2).u.s); else return; /* { if (streq(topMasterStack(), "input")) return; else error("no propagation in a client end. Please use sendServer command"); } */ } void propagate_agency(symptr sp) { extern char *textptr, textcode[]; char *s; /* printf("propagate %s", sp->name); */ if (!isServer) return; if (streq(sp->master, "system")) return; s = textptr = textcode; /* set textptr at the begin of textcode */ *textptr = '\0'; tkdefine1(sp); /* will put text into textcode and change textptr */ /* printf("tkdefine %s", s); */ if (textptr) propagateAgency(sp, s); } void propagateAgency(symptr sp, char *s) { extern char agentName[128]; extern char *everyone; extern agent_ATOM search_agent_Q(agent_QUEUE *, char *); agent_QUEUE *AQ = &sp->OracleOf; agent_ATOM A; extern Int *propagateType; char *temp = (char *) malloc(strlen(s)+1); if (!isServer) return; strcpy(temp, s); /* because textcode may be changed during propagation */ if (temp) { if (*propagateType == 1) { if (Q_EMPTY(AQ)) { return; /* exclusive use */ /* if (*autoPropagate) SendOtherClients(agentName, s); */ } else { if (search_agent_Q(AQ, everyone)) { SendOtherClients(agentName, temp); } else { FOREACH(A, AQ) { if (!streq(A->obj.name, agentName) && !streq(A->obj.name, "SYSTEM")) { SendClient(A->obj.name, temp); } } } } } if (*propagateType == 0) SendOtherClients(agentName, temp); if (*propagateType == -1) return; } free(temp); } void propagateAgency1(char *name, char *s) { extern char agentName[128]; extern symptr lookup(char *); extern Int *EveryOneAllowed; extern Int *propagateType; symptr sp; if (!isServer) return; if ((sp = lookup(name)) != 0) propagateAgency(sp, s); else if (*EveryOneAllowed == 1 && *propagateType != -1) SendOtherClients(agentName, s); /* new variable --- In Donald openshspe, int, boolean, real and char are not defined in Eden yet , even they are declared in Donald. So at this moment, agency is dependent on EveryOneAllowed.. */ } void addAgency(void) { Datum d; symptr sp; char *name, *type, *ObsName; int LSDtype; extern void add_Obs_Q(char *, int, char *); extern int isServer; if (!isServer) return; /* If it is running in client end, it does nothing so far */ if (paracount != 3) usage("addAgency(\"LSDagentName\", \"LSDtype\", \"observableName\")"); muststr(para(1), "addAgency()"); muststr(para(2), "addAgency()"); muststr(para(3), "addAgency()"); name = para(1).u.s; type = para(2).u.s; ObsName = para(3).u.s; if ((sp=lookup(ObsName)) == 0) sp = install(ObsName, VAR, UNDEF, 0); if (!strcmp(type, "oracle")) { add_agent_Q(&sp->OracleOf, name); LSDtype =1; } else { if (!strcmp(type, "handle")) { add_agent_Q(&sp->HandleOf, name); LSDtype = 2; } else { if (!strcmp(type, "state")) { add_agent_Q(&sp->StateOf, name); LSDtype = 3; } else dpush(d, INTEGER, 0); } } add_Obs_Q(name, LSDtype, ObsName); dpush(d, INTEGER, 1); } void removeAgency(void) { Datum d; symptr sp; char *name, *type, *ObsName; int LSDtype; extern void remove_Obs_Q(char *, int, char *); extern void delete_agent_Q(agent_QUEUE *, char *, char *); extern int isServer; if (!isServer) return; /* If it is running in client end, it does nothing so far */ if (paracount != 3) usage("removeAgency(\"LSDagentName\", \"LSDtype\", \"observableName\")"); muststr(para(1), "removeAgency()"); muststr(para(2), "removeAgency()"); muststr(para(3), "removeAgency()"); name = para(1).u.s; type = para(2).u.s; ObsName = para(3).u.s; if ((sp=lookup(ObsName)) == 0) error2("no such observable ", ObsName); if (!strcmp(type, "oracle")) { delete_agent_Q(&sp->OracleOf, name, ObsName); LSDtype = 1; } else { if (!strcmp(type, "handle")) { delete_agent_Q(&sp->HandleOf, name, ObsName); LSDtype =2; } else { if (!strcmp(type, "state")) { delete_agent_Q(&sp->StateOf, name, ObsName); LSDtype =3; } else dpush(d, INTEGER, 0); } } remove_Obs_Q(name, LSDtype, ObsName); dpush(d, INTEGER, 1); } void checkAgency(void) { Datum d; symptr sp; char *name, *type, *ObsName; agent_QUEUE *AQ; agent_ATOM A; extern agent_ATOM search_agent_Q(agent_QUEUE *, char *); extern int isServer; if (!isServer) return; /* If it is running in client end, it does nothing so far */ if (paracount != 3) usage("checkAgency(\"LSDagentName\", \"LSDtype\", \"observableName\")"); muststr(para(1), "checkAgency()"); muststr(para(2), "checkAgency()"); muststr(para(3), "checkAgency()"); name = para(1).u.s; type = para(2).u.s; ObsName = para(3).u.s; if ((sp=lookup(ObsName)) == 0) { dpush(d, INTEGER, 0); /* no such observable */ return; } if (!strcmp(type, "oracle")) { AQ = &sp->OracleOf; } else { if (!strcmp(type, "handle")) { AQ = &sp->HandleOf; } else { if (!strcmp(type, "state")) { AQ = &sp->StateOf; } else { dpush(d, INTEGER, 0); /* no such LSDtype */ return; } } } if ((A=search_agent_Q(AQ, name))!=0) { dpush(d, INTEGER, 1); } else { dpush(d, INTEGER, 0); } return; } #endif /* DISTRIB */ #if defined(WANT_SASAMI) && !defined(TTYEDEN) // -------------------------------------------------------------------------- // Sasami functions - these are just stubs which call the real function code // over in Sasami/functions.c // See Sasami/functions.c for descriptions // -------------------------------------------------------------------------- void ed_sasami_vertex(void) { int i; double x,y,z; if (paracount < 4) usage("sasami_vertex(n,x,y,z)"); if (para(1).type!=INTEGER) usage("n must be an integer"); if (para(2).type==REAL) { x=para(2).u.r; } else { x=para(2).u.i; } if (para(3).type==REAL) { y=para(3).u.r; } else { y=para(3).u.i; } if (para(4).type==REAL) { z=para(4).u.r; } else { z=para(4).u.i; } sasami_vertex(para(1).u.i,x,y,z); } void ed_sasami_set_bgcolour(void) { int i; double r,g,b; if (paracount < 3) usage("sasami_set_bgcolour(r,g,b)"); if (para(1).type==REAL) { r=para(1).u.r; } else { r=para(1).u.i; } if (para(2).type==REAL) { g=para(2).u.r; } else { g=para(2).u.i; } if (para(3).type==REAL) { b=para(3).u.r; } else { b=para(3).u.i; } sasami_set_bgcolour(r,g,b); } void ed_sasami_poly_geom_vertex(void) { int i; double r,g,b; if (paracount < 3) usage("sasami_poly_geom_vertex(,,)"); if (para(1).type!=INTEGER) usage(" must be an integer"); if (para(2).type!=INTEGER) usage(" must be an integer"); if (para(3).type!=INTEGER) usage(" must be an integer"); sasami_poly_geom_vertex(para(1).u.i,para(2).u.i,para(3).u.i); } void ed_sasami_poly_tex_vertex(void) { int i; double r,g,b; if (paracount < 3) usage("sasami_poly_tex_vertex(,,)"); if (para(1).type!=INTEGER) usage(" must be an integer"); if (para(2).type!=INTEGER) usage(" must be an integer"); if (para(3).type!=INTEGER) usage(" must be an integer"); sasami_poly_tex_vertex(para(1).u.i,para(2).u.i,para(3).u.i); } void ed_sasami_object_poly(void) { int i; double r,g,b; if (paracount < 3) usage("sasami_object_poly(,,)"); if (para(1).type!=INTEGER) usage(" must be an integer"); if (para(2).type!=INTEGER) usage(" must be an integer"); if (para(3).type!=INTEGER) usage(" must be an integer"); sasami_object_poly(para(1).u.i,para(2).u.i,para(3).u.i); } void ed_sasami_poly_colour(void) { int i; double r,g,b,a; if (paracount < 5) usage("sasami_poly_colour(poly,r,g,b,a)"); if (para(1).type!=INTEGER) usage(" must be an integer"); if (para(2).type==REAL) { r=para(2).u.r; } else { r=para(2).u.i; } if (para(3).type==REAL) { g=para(3).u.r; } else { g=para(3).u.i; } if (para(4).type==REAL) { b=para(4).u.r; } else { b=para(4).u.i; } if (para(5).type==REAL) { a=para(5).u.r; } else { a=para(5).u.i; } sasami_poly_colour(para(1).u.i,r,g,b,a); } void ed_sasami_poly_material(void) { int i; if (paracount < 2) usage("sasami_poly_material(,)"); if (para(1).type!=INTEGER) usage(" must be an integer"); if (para(2).type!=INTEGER) usage(" must be an integer"); sasami_poly_material(para(1).u.i,para(2).u.i); } void ed_sasami_object_pos(void) { int i; double x,y,z; if (paracount < 4) usage("sasami_object_pos(object,x,y,z)"); if (para(1).type!=INTEGER) usage(" must be an integer"); if (para(2).type==REAL) { x=para(2).u.r; } else { x=para(2).u.i; } if (para(3).type==REAL) { y=para(3).u.r; } else { y=para(3).u.i; } if (para(4).type==REAL) { z=para(4).u.r; } else { z=para(4).u.i; } sasami_object_pos(para(1).u.i,x,y,z); } void ed_sasami_object_rot(void) { int i; double x,y,z; if (paracount < 4) usage("sasami_object_rot(object,x,y,z)"); if (para(1).type!=INTEGER) usage(" must be an integer"); if (para(2).type==REAL) { x=para(2).u.r; } else { x=para(2).u.i; } if (para(3).type==REAL) { y=para(3).u.r; } else { y=para(3).u.i; } if (para(4).type==REAL) { z=para(4).u.r; } else { z=para(4).u.i; } sasami_object_rot(para(1).u.i,x,y,z); } void ed_sasami_object_scale(void) { int i; double x,y,z; if (paracount < 4) usage("sasami_object_scale(object,x,y,z)"); if (para(1).type!=INTEGER) usage(" must be an integer"); if (para(2).type==REAL) { x=para(2).u.r; } else { x=para(2).u.i; } if (para(3).type==REAL) { y=para(3).u.r; } else { y=para(3).u.i; } if (para(4).type==REAL) { z=para(4).u.r; } else { z=para(4).u.i; } sasami_object_scale(para(1).u.i,x,y,z); } void ed_sasami_viewport(void) { int x,y; if (paracount < 2) usage("sasami_viewport(x,y)"); if (para(1).type!=INTEGER) usage(" must be an integer"); if (para(2).type!=INTEGER) usage(" must be an integer"); sasami_viewport(para(1).u.i,para(2).u.i); } void ed_sasami_setshowaxes(void) { int n; if (paracount < 1) usage("sasami_setshowaxes(n)"); if (para(1).type!=INTEGER) usage(" must be an integer"); sasami_setshowaxes(para(1).u.i); } void ed_sasami_material_ambient(void) { int i; double r,g,b,a; if (paracount < 5) usage("sasami_material_ambient(material,r,g,b,a)"); if (para(1).type!=INTEGER) usage(" must be an integer"); if (para(2).type==REAL) { r=para(2).u.r; } else { r=para(2).u.i; } if (para(3).type==REAL) { g=para(3).u.r; } else { g=para(3).u.i; } if (para(4).type==REAL) { b=para(4).u.r; } else { b=para(4).u.i; } if (para(5).type==REAL) { a=para(5).u.r; } else { a=para(5).u.i; } sasami_material_ambient(para(1).u.i,r,g,b,a); } void ed_sasami_material_diffuse(void) { int i; double r,g,b,a; if (paracount < 5) usage("sasami_material_diffuse(material,r,g,b,a)"); if (para(1).type!=INTEGER) usage(" must be an integer"); if (para(2).type==REAL) { r=para(2).u.r; } else { r=para(2).u.i; } if (para(3).type==REAL) { g=para(3).u.r; } else { g=para(3).u.i; } if (para(4).type==REAL) { b=para(4).u.r; } else { b=para(4).u.i; } if (para(5).type==REAL) { a=para(5).u.r; } else { a=para(5).u.i; } sasami_material_diffuse(para(1).u.i,r,g,b,a); } void ed_sasami_material_specular(void) { int i; double r,g,b,a; if (paracount < 5) usage("sasami_material_specular(material,r,g,b,a)"); if (para(1).type!=INTEGER) usage(" must be an integer"); if (para(2).type==REAL) { r=para(2).u.r; } else { r=para(2).u.i; } if (para(3).type==REAL) { g=para(3).u.r; } else { g=para(3).u.i; } if (para(4).type==REAL) { b=para(4).u.r; } else { b=para(4).u.i; } if (para(5).type==REAL) { a=para(5).u.r; } else { a=para(5).u.i; } sasami_material_specular(para(1).u.i,r,g,b,a); } void ed_sasami_material_texture(void) { int i; double r,g,b,a; if (paracount < 2) usage("sasami_material_texture(material,texture)"); if (para(1).type!=INTEGER) usage(" must be an integer"); if (para(2).type!=STRING) usage(" must be a string"); sasami_material_texture(para(1).u.i,para(2).u.s); } void ed_sasami_light_pos(void) { int i; double x,y,z; if (paracount < 4) usage("sasami_light_pos(light,x,y,z)"); if (para(1).type!=INTEGER) usage(" must be an integer"); if (para(2).type==REAL) { x=para(2).u.r; } else { x=para(2).u.i; } if (para(3).type==REAL) { y=para(3).u.r; } else { y=para(3).u.i; } if (para(4).type==REAL) { z=para(4).u.r; } else { z=para(4).u.i; } sasami_light_pos(para(1).u.i,x,y,z); } void ed_sasami_light_ambient(void) { int i; double r,g,b,a; if (paracount < 5) usage("sasami_light_ambient(light,r,g,b,a)"); if (para(1).type!=INTEGER) usage(" must be an integer"); if (para(2).type==REAL) { r=para(2).u.r; } else { r=para(2).u.i; } if (para(3).type==REAL) { g=para(3).u.r; } else { g=para(3).u.i; } if (para(4).type==REAL) { b=para(4).u.r; } else { b=para(4).u.i; } if (para(5).type==REAL) { a=para(5).u.r; } else { a=para(5).u.i; } sasami_light_ambient(para(1).u.i,r,g,b,a); } void ed_sasami_light_diffuse(void) { int i; double r,g,b,a; if (paracount < 5) usage("sasami_light_diffuse(light,r,g,b,a)"); if (para(1).type!=INTEGER) usage(" must be an integer"); if (para(2).type==REAL) { r=para(2).u.r; } else { r=para(2).u.i; } if (para(3).type==REAL) { g=para(3).u.r; } else { g=para(3).u.i; } if (para(4).type==REAL) { b=para(4).u.r; } else { b=para(4).u.i; } if (para(5).type==REAL) { a=para(5).u.r; } else { a=para(5).u.i; } sasami_light_diffuse(para(1).u.i,r,g,b,a); } void ed_sasami_light_specular(void) { int i; double r,g,b,a; if (paracount < 5) usage("sasami_light_specular(light,r,g,b,a)"); if (para(1).type!=INTEGER) usage(" must be an integer"); if (para(2).type==REAL) { r=para(2).u.r; } else { r=para(2).u.i; } if (para(3).type==REAL) { g=para(3).u.r; } else { g=para(3).u.i; } if (para(4).type==REAL) { b=para(4).u.r; } else { b=para(4).u.i; } if (para(5).type==REAL) { a=para(5).u.r; } else { a=para(5).u.i; } sasami_light_specular(para(1).u.i,r,g,b,a); } void ed_sasami_light_enabled(void) { if (paracount < 2) usage("sasami_light_specular(light,e)"); if (para(1).type!=INTEGER) usage(" must be an integer"); if (para(2).type!=INTEGER) usage(" must be an integer"); sasami_light_enabled(para(1).u.i,para(2).u.i); } void ed_sasami_light_directional(void) { if (paracount < 2) usage("sasami_light_specular(light,d)"); if (para(1).type!=INTEGER) usage(" must be an integer"); if (para(2).type!=INTEGER) usage(" must be an integer"); sasami_light_directional(para(1).u.i,para(2).u.i); } void ed_sasami_light_attenuation(void) { int i; double a; if (paracount < 2) usage("sasami_light_attenuation(light,attenuation)"); if (para(1).type!=INTEGER) usage(" must be an integer"); if (para(2).type==REAL) { a=para(2).u.r; } else { a=para(2).u.i; } sasami_light_attenuation(para(1).u.i,a); } void ed_sasami_object_visible(void) { if (paracount < 2) usage("sasami_object_visible(object,e)"); if (para(1).type!=INTEGER) usage(" must be an integer"); if (para(2).type!=INTEGER) usage(" must be an integer"); sasami_object_visible(para(1).u.i,para(2).u.i); } #endif /* defined(WANT_SASAMI) && !defined(TTYEDEN) */ rtex(void) { int i; double x,y,z; if (paracount < 4) usage("sasami_vertex(n,x,y,z)"); if (para(1).type!=INTEGER) usage("n must be an integer"); if (para(2).type==REAL) { x=para(2).u.r; } else { x=para(tkeden1.18/Eden/agency.q.h010060000025250000147000000031400727406556000166110ustar00ashleydcsother00003470000356/* * $Id: agency.q.h,v 1.2 1999/11/16 21:20:40 ashley Rel1.10 $ */ #include "global.q.h" #ifndef STAMP_agent_QUEUE struct agent { char *name; }; typedef struct agent agent; struct agent_queue { struct agent_queue *prev; struct agent_queue *next; agent obj; }; typedef struct agent_queue agent_QUEUE; typedef agent_QUEUE *agent_ATOM; #ifndef streq #define streq(X,Y) (strcmp(X,Y)==0) #endif #define EQUAL_agent(A,B) streq(A.name,B.name) #define FREE_agent(A) if(A.name)free(A.name) extern agent_QUEUE *SEARCH_agent(agent_QUEUE *, agent, int); extern void DELETE_agent_ATOM(agent_QUEUE *, agent_ATOM); extern void MOVE_agent_Q(agent_QUEUE *, agent_QUEUE *); #ifndef NEW_agent #define NEW_agent(OBJ) OBJ #endif #define DESTROY_agent_ATOM(A) \ { \ FREE_agent((A)->obj); \ free(A); \ } #define DELETE_NTH_agent(Q,OBJ,n) DELETE_agent_ATOM(Q,SEARCH_agent(Q,OBJ,n)) #define DELETE_FIRST_agent(Q,OBJ) DELETE_agent_ATOM(Q,SEARCH_agent(Q,OBJ,1)) #define DELETE_FRONT_agent(Q) DELETE_agent_ATOM(Q,FRONT(Q)) #define DELETE_LAST_agent(Q) DELETE_agent_ATOM(Q,LAST(Q)) #define CLEAR_agent_Q(Q) \ while (!Q_EMPTY(Q)) DELETE_agent_ATOM(Q,(Q)->next) #define APPEND_agent_Q(Q,OBJ) \ { \ agent_ATOM A; \ ALLOC_ATOM(A); \ A->obj = NEW_agent(OBJ); \ APPEND_Q(Q,A); \ } #define INSERT_agent_Q(Q,OBJ) \ { \ agent_ATOM A; \ ALLOC_ATOM(A); \ A->obj = NEW_agent(OBJ); \ INSERT_Q(Q,A); \ } #define CONCAT_agent_Q(Qdst, Qsrc) \ { \ agent_QUEUE *P; \ FOREACH (P, Qsrc) APPEND_agent_Q(Qdst, P->obj); \ } #define IN_agent_Q(Q,OBJ) SEARCH_agent(Q,OBJ,1) #define STAMP_agent_QUEUE #endif tkeden1.18/Eden/agency.q.c010060000025250000147000000021370731245653200166050ustar00ashleydcsother00003470000356/* * $Id: agency.q.c,v 1.5 1999/11/16 21:20:40 ashley Rel1.10 $ */ static char rcsid5[] = "$Id: agency.q.c,v 1.5 1999/11/16 21:20:40 ashley Rel1.10 $"; #include "../config.h" #define EQUAL_agent(A,B) streq(A.name,B.name) #define FREE_agent(A) if(A.name)free(A.name) /* function prototypes */ agent_QUEUE *SEARCH_agent(agent_QUEUE *, agent, int); void DELETE_agent_ATOM(agent_QUEUE *, agent_ATOM); void MOVE_agent_Q(agent_QUEUE *, agent_QUEUE *); /* return the position of the n-th object in a agent queue */ agent_QUEUE * SEARCH_agent(agent_QUEUE * Q, agent obj, int n) { agent_QUEUE *P; FOREACH(P, Q) { if (EQUAL_agent(obj, P->obj) && !--n) return P; } return (agent_QUEUE *) 0; /* NOT FOUND */ } void DELETE_agent_ATOM(agent_QUEUE * Q, agent_ATOM A) { if (A && A != Q) { A->prev->next = A->next; A->next->prev = A->prev; DESTROY_agent_ATOM(A); } } void MOVE_agent_Q(agent_QUEUE * Qsrc, agent_QUEUE * Qdst) { if (!Q_EMPTY(Qsrc)) { (Qdst->prev->next = Qsrc->next)->prev = Qdst->prev; (Qsrc->prev->next = Qdst)->prev = Qsrc->prev; CLEAN_Q(Qsrc); } } tkeden1.18/Eden/yacc.c010060000025250000147000002356240731245770000160260ustar00ashleydcsother00003470000356 /* A Bison parser, made from yacc.y by GNU Bison version 1.28 */ #define YYBISON 1 /* Identify Bison output. */ #define UNDEF 257 #define REAL 258 #define INTEGER 259 #define MYCHAR 260 #define STRING 261 #define LIST 262 #define CONSTANT 263 #define VAR 264 #define FORMULA 265 #define BLTIN 266 #define LIB 267 #define RLIB 268 #define FUNC 269 #define PROC 270 #define PMAC 271 #define FUNCTION 272 #define PROCEDURE 273 #define PROCMACRO 274 #define AUTO 275 #define PARA 276 #define LOCAL 277 #define BREAK 278 #define CONTINUE 279 #define SWITCH 280 #define CASE 281 #define DEFAULT 282 #define DO 283 #define FOR 284 #define WHILE 285 #define IF 286 #define ELSE 287 #define SHIFT 288 #define APPEND 289 #define INSERT 290 #define DELETE 291 #define RETURN 292 #define ARG 293 #define IS 294 #define TILDE_GT 295 #define PLUS_EQ 296 #define MINUS_EQ 297 #define OR 298 #define LAZY_OR 299 #define AND 300 #define LAZY_AND 301 #define BITAND 302 #define BITOR 303 #define EQ_EQ 304 #define NOT_EQ 305 #define GT_EQ 306 #define LT_EQ 307 #define SLASH_SLASH 308 #define NEGATE 309 #define NOT 310 #define PLUS_PLUS 311 #define MINUS_MINUS 312 #define ASTERISK 313 #define EVAL 314 #line 1 "yacc.y" /* * $Id: yacc.y,v 1.14 2001/04/04 19:38:34 cssbz Exp $ */ /* This is from the Autoconf manual. Note the pragma directive is indented so that pre-ANSI C compilers will ignore it. [Ash] */ /* AIX requires this to be the first thing in the file */ #ifdef __GNUC__ # define alloca __builtin_alloca #else # if HAVE_ALLOCA_H # include # else # ifdef _AIX #pragma alloca # else # ifndef alloca /* predefined by HP cc +Olibcalls */ char *alloca (); # endif # endif # endif #endif static char rcsid[] = "$Id: yacc.y,v 1.14 2001/04/04 19:38:34 cssbz Exp $"; #include "../config.h" #include #include "eden.h" #include "emalloc.h" #ifdef HAVE_DMALLOC #include #endif #define YYERROR_VERBOSE 1 #define WANT_SETYYPARSEINIT #define code2(c1,c2) code(c1); code(c2) #define code3(c1,c2,c3) code(c1); code(c2); code(c3) #define fromto(F,T) (F)[1] = (Inst)((T)-((F)+2)) extern char *textptr, textcode[]; extern symptr_QUEUE break_q, cont_q; extern void patch(Inst *, Inst *, symptr_QUEUE *); extern void dispatch(Inst *, symptr_QUEUE *); #define dispatch_break() dispatch(progp, &break_q); code2(jmp, 0) #define dispatch_continue() dispatch(progp, &cont_q); code2(jmp, 0) #define patch_break(mark,p) patch(mark, p, &break_q) #define patch_continue(mark,p) patch(mark, p, &cont_q) #define rts (Inst) 0 typedef struct { Inst *location; Datum *dp; } Garbage; typedef struct { Inst *start; Inst *end; } UsefulGarbage; static int MAXGARBAGE = 0; static int MAXUSABLE = 0; static Garbage *garbage; static UsefulGarbage *usable; static int nGarbage = 0; static int nUsable = 0; static int garbageLevel = 0; extern int inEVAL; extern int *autocalc; /* Garbage seems to be a structure describing which information on the stack can be thrown away. But see also the Usable structure :) */ void markGarbage(location, dp) Inst *location; Datum *dp; { if (MAXGARBAGE == 0) { garbage = (Garbage *) emalloc(sizeof(Garbage) * 64); MAXGARBAGE = 64; } if (nGarbage == MAXGARBAGE) { MAXGARBAGE += 64; garbage = (Garbage *) erealloc(garbage, sizeof(Garbage) * MAXGARBAGE); } garbage[nGarbage].location = location; garbage[nGarbage].dp = dp; nGarbage++; } /* Usable describes information on the stack that must be kept. Usable overrides Garbage - see Garbage above :) */ void unmarkGarbage(start, end) Inst *start; Inst *end; { if (MAXUSABLE == 0) { usable = (UsefulGarbage *) emalloc(sizeof(UsefulGarbage) * 4); MAXUSABLE = 4; } if (nUsable == MAXUSABLE) { MAXUSABLE += 4; usable = (UsefulGarbage *) erealloc(usable, sizeof(UsefulGarbage) * MAXUSABLE); } usable[nUsable].start = start; usable[nUsable].end = end; nUsable++; } void incGarbageLevel(void) { garbageLevel++; } void decGarbageLevel(void) { --garbageLevel; } void clearGarbage(void) { int i, j, save; if (--garbageLevel == 0) { for (i = 0; i < nGarbage; i++) { save = 0; /* nonzero ('true') if we should keep this information */ for (j = 0; j < nUsable; j++) { if (garbage[i].location >= usable[j].start && garbage[i].location <= usable[j].end) { /* this garbage is within this usable section, so we should keep it */ save = 1; break; } } if (!save) { /* don't save the info - free it up */ freedatum(*garbage[i].dp); free(garbage[i].dp); } } nGarbage = nUsable = 0; } } void defnonly(char *s) { /* warn if illegal definition */ if (!indef) error2(s, "used outside definition"); } extern void addentry(Datum *, Inst *); extern Inst *code(/* Inst */); extern Inst *code_related_by(symptr); extern Inst *code_related_by_runtimelhs(); extern Inst *code_definition(int, symptr, Inst *, Inst *, Int, char *); extern Inst *code_definition_runtimelhs(int, Inst *, Inst *, Int, char *); extern Inst *code_eval(Inst *, Inst *); extern void execute(Inst *); /* can be used to execute pc at end with (rts) */ extern void codeswitch(struct t *); extern void insert_level_marker(int), delete_local_level(int); extern void push_text(char *, int); #line 174 "yacc.y" typedef union { Datum *dp; /* constants */ symptr sym; /* symbol table ptr */ Inst *inst; /* machine instruction */ Int narg; /* number of arguments */ Inst fun; /* binop */ struct t *sw; /* switch */ char *tbegin; /* beginning of text */ } YYSTYPE; #include #ifndef __cplusplus #ifndef __STDC__ #define const #endif #endif #define YYFINAL 277 #define YYFLAG -32768 #define YYNTBASE 84 #define YYTRANSLATE(x) ((unsigned)(x) <= 314 ? yytranslate[x] : 136) static const char yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 67, 2, 70, 74, 64, 71, 2, 78, 79, 62, 59, 42, 60, 2, 63, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 81, 80, 57, 43, 55, 46, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 75, 2, 76, 2, 2, 77, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 82, 2, 83, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 44, 45, 47, 48, 49, 50, 51, 52, 53, 54, 56, 58, 61, 65, 66, 68, 69, 72, 73 }; #if YYDEBUG != 0 static const short yyprhs[] = { 0, 0, 1, 3, 5, 7, 9, 11, 13, 18, 21, 25, 29, 33, 37, 40, 43, 46, 49, 51, 53, 55, 57, 59, 63, 68, 73, 75, 78, 81, 85, 88, 92, 98, 106, 112, 116, 119, 122, 125, 130, 138, 146, 153, 160, 169, 171, 173, 175, 177, 180, 182, 185, 187, 190, 191, 193, 196, 197, 198, 200, 204, 205, 208, 211, 213, 214, 216, 218, 220, 222, 224, 226, 228, 230, 232, 234, 236, 238, 241, 246, 250, 254, 258, 262, 266, 270, 274, 278, 282, 286, 290, 294, 295, 299, 302, 305, 308, 311, 318, 322, 326, 330, 334, 338, 342, 347, 349, 351, 353, 355, 357, 359, 361, 368, 369, 379, 381, 386, 387, 395, 397, 398, 408, 410, 412, 414, 416, 418, 419, 422, 423, 425, 427, 431, 432, 433, 438, 439, 440, 446, 448, 452, 453, 455, 457 }; static const short yyrhs[] = { -1, 90, 0, 1, 0, 106, 0, 23, 0, 74, 0, 39, 0, 85, 75, 108, 76, 0, 62, 88, 0, 62, 71, 85, 0, 77, 108, 77, 0, 78, 85, 79, 0, 85, 87, 108, 0, 68, 85, 0, 85, 68, 0, 69, 85, 0, 85, 69, 0, 43, 0, 44, 0, 45, 0, 85, 0, 89, 0, 78, 108, 79, 0, 88, 78, 134, 79, 0, 89, 75, 108, 76, 0, 114, 0, 108, 80, 0, 38, 80, 0, 38, 108, 80, 0, 34, 80, 0, 34, 85, 80, 0, 35, 85, 42, 108, 80, 0, 36, 85, 42, 108, 42, 108, 80, 0, 37, 85, 42, 108, 80, 0, 27, 9, 81, 0, 28, 81, 0, 24, 80, 0, 25, 80, 0, 103, 108, 104, 90, 0, 93, 94, 95, 96, 97, 98, 90, 0, 92, 90, 31, 78, 108, 79, 80, 0, 91, 78, 108, 79, 99, 90, 0, 32, 78, 108, 79, 99, 90, 0, 32, 78, 108, 79, 99, 90, 100, 90, 0, 101, 0, 80, 0, 31, 0, 29, 0, 30, 78, 0, 80, 0, 108, 80, 0, 80, 0, 108, 80, 0, 0, 79, 0, 108, 79, 0, 0, 0, 33, 0, 82, 102, 83, 0, 0, 102, 90, 0, 26, 78, 0, 79, 0, 0, 107, 0, 12, 0, 13, 0, 14, 0, 10, 0, 11, 0, 18, 0, 19, 0, 20, 0, 9, 0, 86, 0, 88, 0, 71, 85, 0, 75, 105, 134, 76, 0, 108, 59, 108, 0, 108, 60, 108, 0, 108, 62, 108, 0, 108, 63, 108, 0, 108, 64, 108, 0, 108, 61, 108, 0, 108, 55, 108, 0, 108, 56, 108, 0, 108, 57, 108, 0, 108, 58, 108, 0, 108, 53, 108, 0, 108, 54, 108, 0, 0, 46, 109, 85, 0, 60, 108, 0, 108, 70, 0, 67, 108, 0, 66, 108, 0, 108, 46, 99, 108, 111, 108, 0, 108, 49, 108, 0, 108, 47, 108, 0, 108, 112, 108, 0, 108, 113, 108, 0, 108, 51, 108, 0, 108, 52, 108, 0, 110, 78, 108, 79, 0, 73, 0, 81, 0, 50, 0, 48, 0, 118, 0, 121, 0, 115, 0, 107, 117, 75, 127, 76, 80, 0, 0, 77, 108, 77, 116, 117, 75, 127, 76, 80, 0, 41, 0, 107, 120, 108, 80, 0, 0, 77, 108, 77, 119, 120, 108, 80, 0, 40, 0, 0, 123, 107, 122, 126, 124, 129, 131, 102, 125, 0, 15, 0, 16, 0, 17, 0, 82, 0, 83, 0, 0, 81, 128, 0, 0, 128, 0, 107, 0, 128, 42, 107, 0, 0, 0, 22, 130, 133, 80, 0, 0, 0, 131, 21, 132, 133, 80, 0, 23, 0, 133, 42, 23, 0, 0, 135, 0, 108, 0, 135, 42, 108, 0 }; #endif #if YYDEBUG != 0 static const short yyrline[] = { 0, 238, 239, 242, 245, 247, 250, 253, 257, 258, 259, 260, 267, 270, 272, 273, 274, 275, 278, 279, 280, 283, 285, 286, 289, 292, 296, 298, 299, 301, 303, 306, 307, 309, 311, 313, 319, 325, 330, 335, 344, 360, 368, 377, 381, 386, 387, 390, 395, 400, 405, 406, 409, 410, 413, 416, 417, 420, 423, 426, 429, 432, 433, 437, 443, 446, 449, 450, 451, 452, 455, 457, 458, 459, 460, 463, 466, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 489, 490, 491, 492, 493, 496, 497, 498, 502, 506, 507, 508, 514, 516, 519, 525, 531, 532, 533, 536, 540, 541, 545, 549, 556, 557, 565, 571, 577, 594, 595, 596, 599, 612, 617, 619, 623, 625, 628, 630, 633, 634, 635, 638, 640, 642, 645, 647, 650, 651, 654, 656 }; #endif #if YYDEBUG != 0 || defined (YYERROR_VERBOSE) static const char * const yytname[] = { "$","error","$undefined.","UNDEF", "REAL","INTEGER","MYCHAR","STRING","LIST","CONSTANT","VAR","FORMULA","BLTIN", "LIB","RLIB","FUNC","PROC","PMAC","FUNCTION","PROCEDURE","PROCMACRO","AUTO", "PARA","LOCAL","BREAK","CONTINUE","SWITCH","CASE","DEFAULT","DO","FOR","WHILE", "IF","ELSE","SHIFT","APPEND","INSERT","DELETE","RETURN","ARG","IS","TILDE_GT", "','","'='","PLUS_EQ","MINUS_EQ","'?'","OR","LAZY_OR","AND","LAZY_AND","BITAND", "BITOR","EQ_EQ","NOT_EQ","'>'","GT_EQ","'<'","LT_EQ","'+'","'-'","SLASH_SLASH", "'*'","'/'","'%'","NEGATE","NOT","'!'","PLUS_PLUS","MINUS_MINUS","'#'","'&'", "ASTERISK","EVAL","'$'","'['","']'","'`'","'('","')'","';'","':'","'{'","'}'", "program","lvalue","asgn","asgnop","primary","secondary","stmt","while","do", "for","expr1","expr2","end_expr2","expr3","end_expr3","then","else","compound", "stmtlist","switch","cases","begin","id","identifier","expr","@1","evaluate", "colon","lazy_and","lazy_or","defn","declare_relation","@2","tilde_gt","declare_formula", "@3","is","declare_action","@4","action","def_begin","def_end","refer_opt","id_list_opt", "id_list","declare_para","@5","declare_local","@6","local_list","arglist","argument_list", NULL }; #endif static const short yyr1[] = { 0, 84, 84, 84, 85, 85, 85, 85, 85, 85, 85, 85, 85, 86, 86, 86, 86, 86, 87, 87, 87, 88, 88, 88, 89, 89, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 91, 92, 93, 94, 94, 95, 95, 96, 97, 97, 98, 99, 100, 101, 102, 102, 103, 104, 105, 106, 106, 106, 106, 107, 107, 107, 107, 107, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 109, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 108, 110, 111, 112, 113, 114, 114, 114, 115, 116, 115, 117, 118, 119, 118, 120, 122, 121, 123, 123, 123, 124, 125, 126, 126, 127, 127, 128, 128, 129, 130, 129, 131, 132, 131, 133, 133, 134, 134, 135, 135 }; static const short yyr2[] = { 0, 0, 1, 1, 1, 1, 1, 1, 4, 2, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 1, 3, 4, 4, 1, 2, 2, 3, 2, 3, 5, 7, 5, 3, 2, 2, 2, 4, 7, 7, 6, 6, 8, 1, 1, 1, 1, 2, 1, 2, 1, 2, 0, 1, 2, 0, 0, 1, 3, 0, 2, 2, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 3, 2, 2, 2, 2, 6, 3, 3, 3, 3, 3, 3, 4, 1, 1, 1, 1, 1, 1, 1, 6, 0, 9, 1, 4, 0, 7, 1, 0, 9, 1, 1, 1, 1, 1, 0, 2, 0, 1, 1, 3, 0, 0, 4, 0, 0, 5, 1, 3, 0, 1, 1, 3 }; static const short yydefact[] = { 0, 3, 75, 70, 71, 67, 68, 69, 123, 124, 125, 72, 73, 74, 5, 0, 0, 0, 0, 0, 48, 0, 47, 0, 0, 0, 0, 0, 0, 7, 92, 0, 0, 0, 0, 0, 0, 0, 106, 6, 65, 0, 0, 46, 61, 21, 76, 77, 22, 2, 0, 0, 0, 45, 0, 4, 66, 0, 0, 26, 112, 110, 111, 0, 37, 38, 63, 0, 36, 49, 0, 0, 0, 30, 0, 66, 0, 0, 0, 28, 0, 0, 94, 0, 21, 9, 97, 96, 14, 16, 78, 142, 0, 21, 0, 0, 18, 19, 20, 15, 17, 0, 0, 142, 0, 0, 0, 50, 0, 0, 0, 120, 116, 0, 0, 58, 0, 109, 0, 108, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 95, 27, 0, 0, 0, 121, 35, 0, 0, 0, 31, 0, 0, 0, 29, 93, 10, 144, 0, 143, 11, 12, 23, 60, 62, 0, 13, 0, 0, 0, 0, 52, 54, 0, 51, 64, 0, 130, 0, 0, 100, 99, 103, 104, 90, 91, 86, 87, 88, 89, 80, 81, 85, 82, 83, 84, 101, 102, 0, 128, 58, 11, 0, 0, 0, 79, 0, 0, 0, 8, 24, 25, 58, 0, 0, 53, 39, 132, 0, 131, 117, 0, 105, 0, 0, 0, 32, 0, 34, 145, 0, 0, 0, 0, 55, 57, 0, 0, 0, 107, 0, 129, 126, 134, 43, 0, 130, 0, 42, 0, 0, 56, 113, 133, 98, 135, 137, 59, 0, 33, 0, 119, 41, 40, 0, 61, 44, 0, 140, 0, 138, 0, 115, 0, 136, 0, 127, 122, 141, 0, 139, 0, 0, 0 }; static const short yydefgoto[] = { 275, 45, 46, 102, 47, 48, 158, 50, 51, 52, 108, 166, 208, 229, 244, 173, 252, 53, 95, 54, 170, 91, 55, 75, 57, 81, 58, 234, 136, 137, 59, 60, 201, 113, 61, 202, 114, 62, 193, 63, 237, 271, 218, 212, 213, 250, 258, 259, 269, 263, 152, 153 }; static const short yypact[] = { 257, -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -32768,-32768,-32768,-32768, -74, -55, -38, 28, -31,-32768, -36,-32768, -12, 115, 146, 146, 146, 555,-32768,-32768, 746, 760, 746, 746, 146, 146, 146,-32768,-32768,-32768, 746, 746,-32768,-32768, -11,-32768, -9, -23,-32768, 5, 481, 579,-32768, 746,-32768, 20, 829, 9,-32768,-32768, -32768,-32768, 25,-32768,-32768,-32768, -16,-32768,-32768, 746, 746, 146,-32768, -54,-32768, -37, -27, -26,-32768, 864, 146, 18, 146, 14, -9, 18, 18, 14, 14, 14, 746, 1382, 72, 1144, 331,-32768,-32768,-32768,-32768,-32768, 746, 746, 746, 746, 746, 60,-32768, 651, 899, 1178, -32768,-32768, 35, 746,-32768, 746,-32768, 746,-32768, 746, 746, 746, 746, 746, 746, 746, 746, 746, 746, 746, 746, 746, 746,-32768,-32768, 746, 746, 746,-32768,-32768, 1212, 1414, -48,-32768, 746, 746, 746,-32768, 14, 14, 1533, 17, 69, 45,-32768,-32768,-32768,-32768, 1446, 1533, 39, 1477, 1246, 41,-32768,-32768, 934,-32768,-32768, 481, 25, 969, 746, 1555, 1575, 251, 251, 324, 324, 12, 12, 12, 12, -8, -8, -8, 50, 50, 50, 1575, 1555, 1280, 43,-32768,-32768, 1004, 1508, 1039,-32768, 746, 89, 91,-32768,-32768,-32768,-32768, 746, 675,-32768,-32768, -32768, 56, 94,-32768, 793,-32768, 25, 55, 481,-32768, 746,-32768, 1533, 64, 746, 481, 1314,-32768,-32768, 1348, 62, 25,-32768, 746, 94,-32768, 121, 111, 1074, 25, 1109,-32768, 65, 481,-32768,-32768,-32768, 1533,-32768,-32768, -32768, 481,-32768, 70,-32768,-32768,-32768, 125, 129,-32768, 73,-32768, -41,-32768, 406,-32768, 132,-32768, 125,-32768, -32768,-32768, -39,-32768, 152, 161,-32768 }; static const short yypgoto[] = {-32768, -13,-32768,-32768, 130,-32768, 2,-32768,-32768,-32768,-32768, -32768,-32768,-32768,-32768, -186,-32768,-32768, -96,-32768,-32768, -32768,-32768, 0, -24,-32768,-32768,-32768,-32768,-32768,-32768, -32768,-32768, -34,-32768,-32768, -29,-32768,-32768,-32768,-32768, -32768,-32768, -72, -43,-32768,-32768,-32768,-32768, -94, 75, -32768 }; #define YYLAST 1645 static const short yytable[] = { 56, 267, 49, 267, 80, 145, 64, 82, 219, 86, 87, 74, 76, 77, 78, 146, 147, 92, 94, 84, 226, 101, 88, 89, 90, 65, 144, 101, 109, 93, 110, 155, 96, 97, 98, 3, 4, 67, 101, 268, 66, 274, 69, 11, 12, 13, 141, 142, 101, 101, 68, 56, 104, 106, 131, 132, 133, 99, 100, 143, 111, 112, 134, 139, 101, 140, 70, 151, 149, 103, 150, 128, 129, 130, 131, 132, 133, 159, 160, 151, 162, 163, 134, 105, 167, -118, -114, 138,-32768, 101, 172, 164, 174, 199, 175, 56, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 171, 200, 190, 191, 192, 96, 97, 98, 204, 207, 134, 196, 197, 198, 217, 3, 4, 5, 6, 7, 112, 111, 231, 11, 12, 13, 232, 236, 14, 240, 99, 100, 246, 249, 251, 256, 261, 101, 262, 215, 264, 155, 276, 266, 29, 272, 3, 4, 5, 6, 7, 277, 85, 265, 11, 12, 13, 224, 254, 14, 56, 211, 210, 225, 235, 273, 223, 32, 161, 0, 0, 0, 0, 227, 230, 29, 0, 0, 0, 39, 0, 0, 71, 72, 0, 73, 0, 239, 0, 0, 0, 241, 0, 0, 0, 0, 0, 0, 32, 0, 248, 0, 0, 0, 0, 0, 0, 211, 0, 56, 39, 238, 0, 71, 72, 0, 56, 0, 242, 0, 0, 0, 247, 0, 0, 0, 0, 0, 0, 0, 211, 0, 0, 0, 56, 0, 257, 0, 0, 0, 0, 0, 56, 0, 260, 0, 0, -1, 1, 0, 0, 0, 0, 0, 0, 56, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0, 0, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 0, 24, 25, 26, 27, 28, 29, 0, 0, 0, 0, 0, 0, 30, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 0, 31, 0, 32, 0, 134, 0, 33, 34, 35, 36, 0, 37, 0, 38, 39, 40, 0, 41, 42, 0, 43, 0, 44, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0, 0, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 0, 24, 25, 26, 27, 28, 29, 0, 0, 0, 0, 0, 0, 30, 0, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 0, 0, 31, 0, 32, 134, 0, 0, 33, 34, 35, 36, 0, 37, 0, 38, 39, 40, 0, 41, 42, 0, 43, 0, 44, 157, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0, 0, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 0, 24, 25, 26, 27, 28, 29, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31, 0, 32, 0, 0, 0, 33, 34, 35, 36, 0, 37, 0, 38, 39, 40, 0, 41, 42, 0, 43, 0, 44, 270, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0, 0, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 0, 24, 25, 26, 27, 28, 29, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31, 0, 32, 0, 0, 0, 33, 34, 35, 36, 0, 37, 0, 38, 39, 40, 0, 41, 42, 0, 43, 0, 44, 2, 3, 4, 5, 6, 7, 0, 0, 0, 11, 12, 13, 0, 0, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 4, 5, 6, 7, 29, 0, 0, 11, 12, 13, 0, 30, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31, 0, 32, 29, 0, 0, 33, 34, 35, 36, 30, 37, 0, 38, 39, 40, 0, 71, 42, 0, 79, 0, 0, 0, 31, 0, 32, 0, 0, 0, 33, 34, 35, 36, 0, 37, 0, 38, 39, 40, 0, 71, 42, 0, 107, 2, 3, 4, 5, 6, 7, 0, 0, 0, 11, 12, 13, 0, 0, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 4, 5, 6, 7, 29, 0, 0, 11, 12, 13, 0, 30, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 31, 0, 32, 29, 0, 0, 33, 34, 35, 36, 30, 37, 0, 38, 39, 40, 0, 71, 42, 0, 165, 0, 0, 0, 31, 0, 32, 0, 0, 0, 33, 34, 35, 36, 0, 37, 0, 38, 39, 40, 0, 71, 42, 228, 2, 3, 4, 5, 6, 7, 0, 0, 0, 11, 12, 13, 0, 0, 14, 3, 4, 5, 6, 7, 0, 0, 0, 11, 12, 13, 0, 0, 14, 0, 29, 0, 0, 0, 0, 0, 0, 30, 0, 0, 0, 0, 0, 0, 29, 0, 0, 0, 0, 0, 0, 31, 0, 32, 0, 0, 0, 33, 34, 35, 36, 0, 37, 0, 38, 39, 40, 32, 71, 42, 0, 0, 0, 0, 0, 0, 83, 0, 0, 39, 0, 0, 71, 42, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 0, 0, 0, 0, 0, 134, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 233, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 0, 0, 0, 0, 0, 134, 0, 0, 0, 0, 0, 0, 0, 0, 0, 135, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 0, 0, 0, 0, 0, 134, 0, 0, 0, 0, 0, 0, 0, 0, 0, 148, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 0, 0, 0, 0, 0, 134, 0, 0, 0, 0, 0, 0, 0, 0, 0, 168, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 0, 0, 0, 0, 0, 134, 0, 0, 0, 0, 0, 0, 0, 0, 0, 209, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 0, 0, 0, 0, 0, 134, 0, 0, 0, 0, 0, 0, 0, 0, 0, 214, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 0, 0, 0, 0, 0, 134, 0, 0, 0, 0, 0, 0, 0, 0, 0, 220, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 0, 0, 0, 0, 0, 134, 0, 0, 0, 0, 0, 0, 0, 0, 0, 222, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 0, 0, 0, 0, 0, 134, 0, 0, 0, 0, 0, 0, 0, 0, 0, 253, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 0, 0, 0, 0, 0, 134, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 0, 0, 0, 0, 0, 134, 0, 0, 0, 0, 0, 0, 0, 0, 156, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 0, 0, 0, 0, 0, 134, 0, 0, 0, 0, 0, 0, 0, 0, 169, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 0, 0, 0, 0, 0, 134, 0, 0, 0, 0, 0, 0, 0, 0, 194, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 0, 0, 0, 0, 0, 134, 0, 0, 0, 0, 0, 0, 0, 0, 206, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 0, 0, 0, 0, 0, 134, 0, 0, 0, 0, 0, 0, 0, 0, 216, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 0, 0, 0, 0, 0, 134, 0, 0, 0, 0, 0, 0, 0, 0, 243, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 0, 0, 0, 0, 0, 134, 0, 0, 0, 0, 0, 0, 0, 0, 245, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 0, 0, 0, 0, 0, 134, 0, 0, 0, 0, 0, 0, 154, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 0, 0, 0, 0, 0, 134, 0, 0, 0, 0, 0, 0, 195, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 0, 0, 0, 0, 0, 134, 0, 0, 0, 0, 0, 203, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 0, 0, 0, 0, 0, 134, 0, 0, 221, 0, 0, 205, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 0, 0, 0, 0, 0, 134, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 0, 0, 0, 0, 0, 134, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 0, 0, 0, 0, 0, 134, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 0, 0, 0, 0, 0, 134 }; static const short yycheck[] = { 0, 42, 0, 42, 28, 42, 80, 31, 194, 33, 34, 24, 25, 26, 27, 42, 42, 41, 42, 32, 206, 75, 35, 36, 37, 80, 80, 75, 52, 42, 54, 79, 43, 44, 45, 10, 11, 9, 75, 80, 78, 80, 78, 18, 19, 20, 70, 71, 75, 75, 81, 51, 75, 51, 62, 63, 64, 68, 69, 72, 40, 41, 70, 63, 75, 81, 78, 91, 81, 78, 83, 59, 60, 61, 62, 63, 64, 101, 102, 103, 104, 105, 70, 78, 108, 40, 41, 78, 70, 75, 114, 31, 116, 76, 118, 95, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 75, 42, 136, 137, 138, 43, 44, 45, 79, 78, 70, 145, 146, 147, 81, 10, 11, 12, 13, 14, 41, 40, 76, 18, 19, 20, 42, 82, 23, 75, 68, 69, 80, 22, 33, 80, 76, 75, 23, 173, 21, 79, 0, 80, 39, 23, 10, 11, 12, 13, 14, 0, 32, 259, 18, 19, 20, 201, 240, 23, 170, 171, 170, 202, 217, 269, 200, 62, 103, -1, -1, -1, -1, 207, 208, 39, -1, -1, -1, 74, -1, -1, 77, 78, -1, 80, -1, 221, -1, -1, -1, 225, -1, -1, -1, -1, -1, -1, 62, -1, 234, -1, -1, -1, -1, -1, -1, 217, -1, 219, 74, 219, -1, 77, 78, -1, 226, -1, 226, -1, -1, -1, 232, -1, -1, -1, -1, -1, -1, -1, 240, -1, -1, -1, 244, -1, 244, -1, -1, -1, -1, -1, 252, -1, 252, -1, -1, 0, 1, -1, -1, -1, -1, -1, -1, 265, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -1, -1, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, -1, 34, 35, 36, 37, 38, 39, -1, -1, -1, -1, -1, -1, 46, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, 60, -1, 62, -1, 70, -1, 66, 67, 68, 69, -1, 71, -1, 73, 74, 75, -1, 77, 78, -1, 80, -1, 82, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -1, -1, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, -1, 34, 35, 36, 37, 38, 39, -1, -1, -1, -1, -1, -1, 46, -1, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, -1, 60, -1, 62, 70, -1, -1, 66, 67, 68, 69, -1, 71, -1, 73, 74, 75, -1, 77, 78, -1, 80, -1, 82, 83, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -1, -1, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, -1, 34, 35, 36, 37, 38, 39, -1, -1, -1, -1, -1, -1, 46, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 60, -1, 62, -1, -1, -1, 66, 67, 68, 69, -1, 71, -1, 73, 74, 75, -1, 77, 78, -1, 80, -1, 82, 83, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, -1, -1, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, -1, 34, 35, 36, 37, 38, 39, -1, -1, -1, -1, -1, -1, 46, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 60, -1, 62, -1, -1, -1, 66, 67, 68, 69, -1, 71, -1, 73, 74, 75, -1, 77, 78, -1, 80, -1, 82, 9, 10, 11, 12, 13, 14, -1, -1, -1, 18, 19, 20, -1, -1, 23, -1, -1, -1, -1, -1, -1, -1, -1, -1, 9, 10, 11, 12, 13, 14, 39, -1, -1, 18, 19, 20, -1, 46, 23, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 60, -1, 62, 39, -1, -1, 66, 67, 68, 69, 46, 71, -1, 73, 74, 75, -1, 77, 78, -1, 80, -1, -1, -1, 60, -1, 62, -1, -1, -1, 66, 67, 68, 69, -1, 71, -1, 73, 74, 75, -1, 77, 78, -1, 80, 9, 10, 11, 12, 13, 14, -1, -1, -1, 18, 19, 20, -1, -1, 23, -1, -1, -1, -1, -1, -1, -1, -1, -1, 9, 10, 11, 12, 13, 14, 39, -1, -1, 18, 19, 20, -1, 46, 23, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 60, -1, 62, 39, -1, -1, 66, 67, 68, 69, 46, 71, -1, 73, 74, 75, -1, 77, 78, -1, 80, -1, -1, -1, 60, -1, 62, -1, -1, -1, 66, 67, 68, 69, -1, 71, -1, 73, 74, 75, -1, 77, 78, 79, 9, 10, 11, 12, 13, 14, -1, -1, -1, 18, 19, 20, -1, -1, 23, 10, 11, 12, 13, 14, -1, -1, -1, 18, 19, 20, -1, -1, 23, -1, 39, -1, -1, -1, -1, -1, -1, 46, -1, -1, -1, -1, -1, -1, 39, -1, -1, -1, -1, -1, -1, 60, -1, 62, -1, -1, -1, 66, 67, 68, 69, -1, 71, -1, 73, 74, 75, 62, 77, 78, -1, -1, -1, -1, -1, -1, 71, -1, -1, 74, -1, -1, 77, 78, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, -1, -1, -1, -1, 70, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 81, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, -1, -1, -1, -1, 70, -1, -1, -1, -1, -1, -1, -1, -1, -1, 80, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, -1, -1, -1, -1, 70, -1, -1, -1, -1, -1, -1, -1, -1, -1, 80, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, -1, -1, -1, -1, 70, -1, -1, -1, -1, -1, -1, -1, -1, -1, 80, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, -1, -1, -1, -1, 70, -1, -1, -1, -1, -1, -1, -1, -1, -1, 80, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, -1, -1, -1, -1, 70, -1, -1, -1, -1, -1, -1, -1, -1, -1, 80, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, -1, -1, -1, -1, 70, -1, -1, -1, -1, -1, -1, -1, -1, -1, 80, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, -1, -1, -1, -1, 70, -1, -1, -1, -1, -1, -1, -1, -1, -1, 80, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, -1, -1, -1, -1, 70, -1, -1, -1, -1, -1, -1, -1, -1, -1, 80, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, -1, -1, -1, -1, 70, -1, -1, -1, -1, -1, -1, -1, -1, -1, 80, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, -1, -1, -1, -1, 70, -1, -1, -1, -1, -1, -1, -1, -1, 79, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, -1, -1, -1, -1, 70, -1, -1, -1, -1, -1, -1, -1, -1, 79, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, -1, -1, -1, -1, 70, -1, -1, -1, -1, -1, -1, -1, -1, 79, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, -1, -1, -1, -1, 70, -1, -1, -1, -1, -1, -1, -1, -1, 79, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, -1, -1, -1, -1, 70, -1, -1, -1, -1, -1, -1, -1, -1, 79, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, -1, -1, -1, -1, 70, -1, -1, -1, -1, -1, -1, -1, -1, 79, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, -1, -1, -1, -1, 70, -1, -1, -1, -1, -1, -1, -1, -1, 79, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, -1, -1, -1, -1, 70, -1, -1, -1, -1, -1, -1, 77, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, -1, -1, -1, -1, 70, -1, -1, -1, -1, -1, -1, 77, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, -1, -1, -1, -1, 70, -1, -1, -1, -1, -1, 76, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, -1, -1, -1, -1, 70, -1, -1, 42, -1, -1, 76, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, -1, -1, -1, -1, 70, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, -1, -1, -1, -1, 70, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, -1, -1, -1, -1, 70, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, -1, -1, -1, -1, -1, 70 }; /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ /* MODIFICATION 1: fix all #line directives as they have the wrong * filename and line numbers. Note #line no = actual number + 1 * #line 3 "/usr/local/share/bison.simple" */ #line 7 "bison/bison.simple" /* END MODIFICATION 1 */ /* This file comes from bison-1.28. */ /* This is a MODIFIED version of bison's Skeleton output parser The change is such that the parser only process one token at each call to yyparse(). The token is the argument to yyparse(). This means that this parser is token driven. Example use: while (token = yylex()) { yyparse(token); } Additionally: error handling patched to show expected when there are > 5 expected during an error. [Ash, May 2001]. There are 13 patches of MODIFICATION in the Skeleton (not including this comment) */ /* Skeleton output parser for bison, Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* As a special exception, when this file is copied by Bison into a Bison output file, you may use that output file without restriction. This special exception was added by the Free Software Foundation in version 1.24 of Bison. */ /* This is the parser code that is written into each bison parser when the %semantic_parser declaration is not specified in the grammar. It was written by Richard Stallman by simplifying the hairy parser used when %semantic_parser is specified. */ #ifndef YYSTACK_USE_ALLOCA #ifdef alloca #define YYSTACK_USE_ALLOCA #else /* alloca not defined */ #ifdef __GNUC__ #define YYSTACK_USE_ALLOCA #define alloca __builtin_alloca #else /* not GNU C. */ #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386)) #define YYSTACK_USE_ALLOCA #include #else /* not sparc */ /* We think this test detects Watcom and Microsoft C. */ /* This used to test MSDOS, but that is a bad idea since that symbol is in the user namespace. */ #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__) #if 0 /* No need for malloc.h, which pollutes the namespace; instead, just don't use alloca. */ #include #endif #else /* not MSDOS, or __TURBOC__ */ #if defined(_AIX) /* I don't know what this was needed for, but it pollutes the namespace. So I turned it off. rms, 2 May 1997. */ /* #include */ #pragma alloca #define YYSTACK_USE_ALLOCA #else /* not MSDOS, or __TURBOC__, or _AIX */ #if 0 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up, and on HPUX 10. Eventually we can turn this on. */ #define YYSTACK_USE_ALLOCA #define alloca __builtin_alloca #endif /* __hpux */ #endif #endif /* not _AIX */ #endif /* not MSDOS, or __TURBOC__ */ #endif /* not sparc */ #endif /* not GNU C */ #endif /* alloca not defined */ #endif /* YYSTACK_USE_ALLOCA not defined */ #ifdef YYSTACK_USE_ALLOCA #define YYSTACK_ALLOC alloca #else #define YYSTACK_ALLOC malloc #endif /* Note: there must be only one dollar sign in this file. It is replaced by the list of actions, each action as one case of the switch. */ #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) #define YYEMPTY -2 #define YYEOF 0 #define YYACCEPT goto yyacceptlab #define YYABORT goto yyabortlab #define YYERROR goto yyerrlab1 /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. Once GCC version 2 has supplanted version 1, this can go. */ #define YYFAIL goto yyerrlab #define YYRECOVERING() (!!yyerrstatus) #define YYBACKUP(token, value) \ do \ if (yychar == YYEMPTY && yylen == 1) \ { yychar = (token), yylval = (value); \ yychar1 = YYTRANSLATE (yychar); \ YYPOPSTACK; \ goto yybackup; \ } \ else \ { yyerror ("syntax error: cannot back up"); YYERROR; } \ while (0) #define YYTERROR 1 #define YYERRCODE 256 #ifndef YYPURE #define YYLEX yylex() #endif #ifdef YYPURE #ifdef YYLSP_NEEDED #ifdef YYLEX_PARAM #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) #else #define YYLEX yylex(&yylval, &yylloc) #endif #else /* not YYLSP_NEEDED */ #ifdef YYLEX_PARAM #define YYLEX yylex(&yylval, YYLEX_PARAM) #else #define YYLEX yylex(&yylval) #endif #endif /* not YYLSP_NEEDED */ #endif /* If nonreentrant, generate the variables here */ #ifndef YYPURE int yychar; /* the lookahead symbol */ YYSTYPE yylval; /* the semantic value of the */ /* lookahead symbol */ #ifdef YYLSP_NEEDED YYLTYPE yylloc; /* location data for the lookahead */ /* symbol */ #endif int yynerrs; /* number of parse errors so far */ #endif /* not YYPURE */ #if YYDEBUG != 0 int yydebug; /* nonzero means print parse trace */ /* Since this is uninitialized, it does not stop multiple parsers from coexisting. */ #endif /* YYINITDEPTH indicates the initial size of the parser's stacks */ #ifndef YYINITDEPTH #define YYINITDEPTH 200 #endif /* YYMAXDEPTH is the maximum size the stacks can grow to (effective only if the built-in stack extension method is used). */ #if YYMAXDEPTH == 0 #undef YYMAXDEPTH #endif #ifndef YYMAXDEPTH #define YYMAXDEPTH 10000 #endif /* Define __yy_memcpy. Note that the size argument should be passed with type unsigned int, because that is what the non-GCC definitions require. With GCC, __builtin_memcpy takes an arg of type size_t, but it can handle unsigned int. */ #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) #else /* not GNU C or C++ */ #ifndef __cplusplus /* This is the most reliable way to avoid incompatibilities in available built-in functions on various systems. */ static void __yy_memcpy (to, from, count) char *to; char *from; unsigned int count; { register char *f = from; register char *t = to; register int i = count; while (i-- > 0) *t++ = *f++; } #else /* __cplusplus */ /* This is the most reliable way to avoid incompatibilities in available built-in functions on various systems. */ static void __yy_memcpy (char *to, char *from, unsigned int count) { register char *t = to; register char *f = from; register int i = count; while (i-- > 0) *t++ = *f++; } #endif #endif /* MODIFICATION 2: same as MODIFICATION 1 * #line 217 "/usr/local/share/bison.simple" */ #line 241 "bison/bison.simple" /* END MODIFICATION 2 */ /* The user can define YYPARSE_PARAM as the name of an argument to be passed into yyparse. The argument should have type void *. It should actually point to an object. Grammar actions can access the variable by casting it to the proper pointer type. */ #ifdef YYPARSE_PARAM #ifdef __cplusplus #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM #define YYPARSE_PARAM_DECL #else /* not __cplusplus */ #define YYPARSE_PARAM_ARG YYPARSE_PARAM #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; #endif /* not __cplusplus */ #else /* not YYPARSE_PARAM */ #define YYPARSE_PARAM_ARG #define YYPARSE_PARAM_DECL #endif /* not YYPARSE_PARAM */ /* Prevent warning if -Wstrict-prototypes. */ #ifdef __GNUC__ /* MODIFICATION 3: yyparse() takes an argument that is the lex token * #ifdef YYPARSE_PARAM * int yyparse (void *); * #else * int yyparse (void); * #endif */ int yyparse(int); /* END MODIFICATION 3 */ #endif /* MODIFICATION 4: add a variable yy_parse_init to control the initialisation of the parser and an accessor function */ static int yy_parse_init = 1; #ifdef WANT_SETYYPARSEINIT /* Added this function to allow Eden to use this bison.simple. Needs conditional compilation as we can only have one function with this name otherwise the linker moans (can't compile this into Donald, Scout etc). The name here doesn't get automatically translated by the sed or bison -p. [Ash] */ void setyyparseinit(int setto) { yy_parse_init = setto; } #endif /* END MODIFICATION 4 */ /* MODIFICATION 5: turning the local variables of yyparse() into static, global variables so that the parser can be reentered */ static int yystate; static int yyn; static short *yyssp; static YYSTYPE *yyvsp; static int yyerrstatus; /* number of tokens to shift before error messages enabled */ static int yychar1 = 0; /* lookahead token as an internal (translated) token number */ static short yyssa[YYINITDEPTH]; /* the state stack */ static YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ static short *yyss = yyssa; /* refer to the stacks thru separate pointers */ static YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ #ifdef YYLSP_NEEDED static YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ static YYLTYPE *yyls = yylsa; static YYLTYPE *yylsp; #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) #else #define YYPOPSTACK (yyvsp--, yyssp--) #endif static int yystacksize = YYINITDEPTH; static int yyfree_stacks = 0; #ifdef YYPURE static int yychar; static YYSTYPE yylval; static int yynerrs; #ifdef YYLSP_NEEDED static YYLTYPE yylloc; #endif #endif static YYSTYPE yyval; /* the variable used to return */ /* semantic values from the action */ /* routines */ static int yylen; /* END MODIFICATION 5 */ /* MODIFICATION 6: yyparse() takes an argument that is the lex token * int * yyparse(YYPARSE_PARAM_ARG) * YYPARSE_PARAM_DECL * { */ int yyparse(token) int token; { /* END MODIFICATION 6 */ /* MODIFICATION 7: deal with initialisation */ int yy_token_read = 0; if (!yy_parse_init) goto lex; yy_parse_init = 0; /* END MODIFICATION 7 */ #if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Starting parse\n"); #endif yystate = 0; yyerrstatus = 0; yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ yyssp = yyss - 1; yyvsp = yyvs; #ifdef YYLSP_NEEDED yylsp = yyls; #endif /* Push a new state, which is found in yystate . */ /* In all cases, when you get here, the value and location stacks have just been pushed. so pushing a state here evens the stacks. */ yynewstate: *++yyssp = yystate; if (yyssp >= yyss + yystacksize - 1) { /* Give user a chance to reallocate the stack */ /* Use copies of these so that the &'s don't force the real ones into memory. */ YYSTYPE *yyvs1 = yyvs; short *yyss1 = yyss; #ifdef YYLSP_NEEDED YYLTYPE *yyls1 = yyls; #endif /* Get the current used size of the three stacks, in elements. */ int size = yyssp - yyss + 1; #ifdef yyoverflow /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. */ #ifdef YYLSP_NEEDED /* This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow("parser stack overflow", &yyss1, size * sizeof (*yyssp), &yyvs1, size * sizeof (*yyvsp), &yyls1, size * sizeof (*yylsp), &yystacksize); #else yyoverflow("parser stack overflow", &yyss1, size * sizeof (*yyssp), &yyvs1, size * sizeof (*yyvsp), &yystacksize); #endif yyss = yyss1; yyvs = yyvs1; #ifdef YYLSP_NEEDED yyls = yyls1; #endif #else /* no yyoverflow */ /* Extend the stack our own way. */ if (yystacksize >= YYMAXDEPTH) { yyerror("parser stack overflow"); if (yyfree_stacks) { free (yyss); free (yyvs); #ifdef YYLSP_NEEDED free (yyls); #endif } return 2; } yystacksize *= 2; if (yystacksize > YYMAXDEPTH) yystacksize = YYMAXDEPTH; #ifndef YYSTACK_USE_ALLOCA yyfree_stacks = 1; #endif yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp)); __yy_memcpy ((char *)yyss, (char *)yyss1, size * (unsigned int) sizeof (*yyssp)); yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp)); __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * (unsigned int) sizeof (*yyvsp)); #ifdef YYLSP_NEEDED yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp)); __yy_memcpy ((char *)yyls, (char *)yyls1, size * (unsigned int) sizeof (*yylsp)); #endif #endif /* no yyoverflow */ yyssp = yyss + size - 1; yyvsp = yyvs + size - 1; #ifdef YYLSP_NEEDED yylsp = yyls + size - 1; #endif #if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Stack size increased to %d\n", yystacksize); #endif if (yyssp >= yyss + yystacksize - 1) YYABORT; } #if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Entering state %d\n", yystate); #endif goto yybackup; yybackup: /* Do appropriate processing given the current state. */ /* Read a lookahead token if we need one and don't already have one. */ /* yyresume: */ /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yyn == YYFLAG) goto yydefault; /* Not known => get a lookahead token if don't already have one. */ /* yychar is either YYEMPTY or YYEOF or a valid token in external form. */ if (yychar == YYEMPTY) { #if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Reading a token: "); #endif /* MODIFICATION 8: consume the argument token * yychar = YYLEX; */ lex: if (yy_token_read) return -1; /* token consumed */ yy_token_read = 1; yychar = token; /* END MODIFICATION 8 */ } /* Convert token to internal form (in yychar1) for indexing tables with */ if (yychar <= 0) /* This means end of input. */ { yychar1 = 0; yychar = YYEOF; /* Don't call YYLEX any more */ #if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Now at end of input.\n"); #endif } else { yychar1 = YYTRANSLATE(yychar); #if YYDEBUG != 0 if (yydebug) { fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); /* Give the individual parser a way to print the precise meaning of a token, for further debugging info. */ #ifdef YYPRINT YYPRINT (stderr, yychar, yylval); #endif fprintf (stderr, ")\n"); } #endif } yyn += yychar1; if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) goto yydefault; yyn = yytable[yyn]; /* yyn is what to do for this token type in this state. Negative => reduce, -yyn is rule number. Positive => shift, yyn is new state. New state is final state => don't bother to shift, just return success. 0, or most negative number => error. */ if (yyn < 0) { if (yyn == YYFLAG) goto yyerrlab; yyn = -yyn; goto yyreduce; } else if (yyn == 0) goto yyerrlab; if (yyn == YYFINAL) YYACCEPT; /* Shift the lookahead token. */ #if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); #endif /* Discard the token being shifted unless it is eof. */ if (yychar != YYEOF) yychar = YYEMPTY; *++yyvsp = yylval; #ifdef YYLSP_NEEDED *++yylsp = yylloc; #endif /* count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; yystate = yyn; goto yynewstate; /* Do the default action for the current state. */ yydefault: yyn = yydefact[yystate]; if (yyn == 0) goto yyerrlab; /* Do a reduction. yyn is the number of a rule to reduce with. */ yyreduce: yylen = yyr2[yyn]; if (yylen > 0) yyval = yyvsp[1-yylen]; /* implement default value of the action */ #if YYDEBUG != 0 if (yydebug) { int i; fprintf (stderr, "Reducing via rule %d (line %d), ", yyn, yyrline[yyn]); /* Print the symbols being reduced, and their result. */ for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) fprintf (stderr, "%s ", yytname[yyrhs[i]]); fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); } #endif switch (yyn) { case 2: #line 239 "yacc.y" { code2(freeheap, rts); textptr = textcode; return 1; ; break;} case 3: #line 242 "yacc.y" { yyerrok; ; break;} case 4: #line 246 "yacc.y" { yyval.inst = code2(addr, yyvsp[0].sym); ; break;} case 5: #line 247 "yacc.y" { defnonly("local variable"); yyval.inst = code2(localaddr, yyvsp[0].narg); ; break;} case 6: #line 250 "yacc.y" { defnonly("$"); yyval.inst = code2(localaddr, (Inst)0); ; break;} case 7: #line 253 "yacc.y" { defnonly("$"); yyval.inst = code2(localaddr, (Inst)0); code3(pushint, (Inst)yyvsp[0].narg, indexcalc); ; break;} case 8: #line 257 "yacc.y" { code(indexcalc); ; break;} case 9: #line 258 "yacc.y" { yyval.inst = yyvsp[0].inst; ; break;} case 10: #line 259 "yacc.y" { yyval.inst = yyvsp[0].inst; ; break;} case 11: #line 260 "yacc.y" { yyval.inst = yyvsp[-1].inst; code(lookup_address); /* Patrick added some code here in yacc.y 1.8 which evaluated this address at parse time. I think this may have been an attempt to fix the problems of referential dependency, but it doesn't work, so removed again. [Ash] */ ; break;} case 12: #line 267 "yacc.y" { yyval.inst = yyvsp[-1].inst; ; break;} case 13: #line 271 "yacc.y" { code(yyvsp[-1].fun); ; break;} case 14: #line 272 "yacc.y" { code(pre_inc); yyval.inst = yyvsp[0].inst; ; break;} case 15: #line 273 "yacc.y" { code(post_inc); ; break;} case 16: #line 274 "yacc.y" { code(pre_dec); yyval.inst = yyvsp[0].inst; ; break;} case 17: #line 275 "yacc.y" { code(post_dec); ; break;} case 18: #line 278 "yacc.y" { yyval.fun = assign; ; break;} case 19: #line 279 "yacc.y" { yyval.fun = inc_asgn; ; break;} case 20: #line 280 "yacc.y" { yyval.fun = dec_asgn; ; break;} case 21: #line 284 "yacc.y" { code(getvalue); ; break;} case 23: #line 286 "yacc.y" { yyval.inst = yyvsp[-1].inst; ; break;} case 24: #line 291 "yacc.y" { code3(makelist, yyvsp[-1].narg, eval); ; break;} case 25: #line 293 "yacc.y" { code(sel); ; break;} case 27: #line 298 "yacc.y" { code2(popd, freeheap); ; break;} case 28: #line 299 "yacc.y" { defnonly("return"); yyval.inst = code2(pushUNDEF, rts); ; break;} case 29: #line 301 "yacc.y" { defnonly("return"); yyval.inst = yyvsp[-1].inst; code(rts); ; break;} case 30: #line 303 "yacc.y" { defnonly("shift"); yyval.inst = code3(localaddr, 0, shift); ; break;} case 31: #line 306 "yacc.y" { yyval.inst = yyvsp[-1].inst; code(shift); ; break;} case 32: #line 308 "yacc.y" { yyval.inst = yyvsp[-3].inst; code2(append, freeheap); ; break;} case 33: #line 310 "yacc.y" { yyval.inst = yyvsp[-5].inst; code2(insert, freeheap); ; break;} case 34: #line 312 "yacc.y" { yyval.inst = yyvsp[-3].inst; code2(delete, freeheap); ; break;} case 35: #line 313 "yacc.y" { if (inswitch) addentry(yyvsp[-1].dp, progp); else error("'case' used outside switch"); yyval.inst = progp; ; break;} case 36: #line 319 "yacc.y" { if (inswitch) addentry(0, progp); else error("'default' used outside switch"); yyval.inst = progp; ; break;} case 37: #line 325 "yacc.y" { if (!inloop && !inswitch) error("'break' used outside loop/switch"); yyval.inst = progp; dispatch_break(); ; break;} case 38: #line 330 "yacc.y" { if (!inloop) error("'continue' used outside loop"); yyval.inst = progp; dispatch_continue(); ; break;} case 39: #line 335 "yacc.y" { dispatch_break(); fromto(yyvsp[-1].inst, progp); code(switchcode); codeswitch(yyvsp[-3].sw); patch_break(yyvsp[-2].inst, progp); yyval.inst = yyvsp[-2].inst; --inswitch; ; break;} case 40: #line 348 "yacc.y" { Inst * p = code(jmp); code(yyvsp[-2].inst - (p + 2)); fromto(yyvsp[-3].inst, yyvsp[0].inst); if (yyvsp[-4].inst != yyvsp[-3].inst - 2) fromto(yyvsp[-3].inst-2, progp); fromto(yyvsp[-1].inst, yyvsp[-4].inst); patch_continue(yyvsp[-5].inst, yyvsp[-2].inst); patch_break(yyvsp[-5].inst, progp); yyval.inst = yyvsp[-5].inst; --inloop; ; break;} case 41: #line 361 "yacc.y" { Inst * p = code(jpt); code(yyvsp[-5].inst - (p + 2)); patch_continue(yyvsp[-5].inst, yyvsp[-2].inst); patch_break(yyvsp[-5].inst, progp); yyval.inst = yyvsp[-5].inst; --inloop; ; break;} case 42: #line 369 "yacc.y" { Inst * p = code(jmp); code(yyvsp[-3].inst - (p + 2)); fromto(yyvsp[-1].inst, progp); patch_continue(yyvsp[-3].inst, yyvsp[-3].inst); patch_break(yyvsp[-3].inst, progp); yyval.inst = yyvsp[-3].inst; --inloop; ; break;} case 43: #line 378 "yacc.y" { fromto(yyvsp[-1].inst, progp); yyval.inst = yyvsp[-3].inst; ; break;} case 44: #line 382 "yacc.y" { fromto(yyvsp[-3].inst, yyvsp[0].inst); fromto(yyvsp[-1].inst, progp); yyval.inst = yyvsp[-5].inst; ; break;} case 46: #line 387 "yacc.y" { yyval.inst = progp; ; break;} case 47: #line 390 "yacc.y" { inloop++; dispatch(progp, &cont_q); dispatch(progp, &break_q); ; break;} case 48: #line 395 "yacc.y" { inloop++; dispatch(progp, &cont_q); dispatch(progp, &break_q); ; break;} case 49: #line 400 "yacc.y" { inloop++; dispatch(progp, &cont_q); dispatch(progp, &break_q); ; break;} case 50: #line 405 "yacc.y" { yyval.inst = progp; ; break;} case 51: #line 406 "yacc.y" { code(popd); ; break;} case 52: #line 409 "yacc.y" { yyval.inst = code2(jmp, 0); ; break;} case 53: #line 410 "yacc.y" { code2(jpnt, 0); ; break;} case 54: #line 413 "yacc.y" { yyval.inst = code2(jmp, 0); ; break;} case 55: #line 416 "yacc.y" { yyval.inst = code2(jmp, 0); ; break;} case 56: #line 417 "yacc.y" { code3(popd, jmp, 0); ; break;} case 57: #line 420 "yacc.y" { yyval.inst = code2(jmp, 0); ; break;} case 58: #line 423 "yacc.y" { yyval.inst = code2(jpnt, 0); ; break;} case 59: #line 426 "yacc.y" { yyval.inst = code2(jmp, 0); ; break;} case 60: #line 429 "yacc.y" { yyval.inst = yyvsp[-1].inst; ; break;} case 61: #line 432 "yacc.y" { yyval.inst = progp; ; break;} case 62: #line 433 "yacc.y" { /*fprintf(stderr, "rd inprocmacro=%d\n", inprocmacro);*/ if (inprocmacro) code(eager); ; break;} case 63: #line 437 "yacc.y" { yyval.sw = entry_ptr; inswitch++; dispatch(progp, &break_q); ; break;} case 64: #line 443 "yacc.y" { yyval.inst = code2(jmp, 0); ; break;} case 65: #line 446 "yacc.y" { yyval.inst = progp; ; break;} case 66: #line 449 "yacc.y" { if (informula && !inEVAL) addID(yyvsp[0].sym); ; break;} case 75: #line 464 "yacc.y" { markGarbage(progp, yyvsp[0].dp); yyval.inst = code2(constpush, (Inst)yyvsp[0].dp); ; break;} case 76: #line 466 "yacc.y" { if (informula) error("assignment used inside formula"); ; break;} case 78: #line 470 "yacc.y" { yyval.inst = yyvsp[0].inst; ; break;} case 79: #line 471 "yacc.y" { code2(makelist, (Inst)yyvsp[-1].narg); yyval.inst = yyvsp[-2].inst; ; break;} case 80: #line 472 "yacc.y" { code(add); ; break;} case 81: #line 473 "yacc.y" { code(sub); ; break;} case 82: #line 474 "yacc.y" { code(mul); ; break;} case 83: #line 475 "yacc.y" { code(divide); ; break;} case 84: #line 476 "yacc.y" { code(mod); ; break;} case 85: #line 477 "yacc.y" { code(concat); ; break;} case 86: #line 478 "yacc.y" { code(gt); ; break;} case 87: #line 479 "yacc.y" { code(ge); ; break;} case 88: #line 480 "yacc.y" { code(lt); ; break;} case 89: #line 481 "yacc.y" { code(le); ; break;} case 90: #line 482 "yacc.y" { code(eq); ; break;} case 91: #line 483 "yacc.y" { code(ne); ; break;} case 92: #line 484 "yacc.y" { code(noupdate); ; break;} case 93: #line 485 "yacc.y" { yyval.inst = yyvsp[0].inst; code(query); code(resetupdate); ; break;} case 94: #line 489 "yacc.y" { yyval.inst = yyvsp[0].inst; code(negate); ; break;} case 95: #line 490 "yacc.y" { code(listsize); ; break;} case 96: #line 491 "yacc.y" { yyval.inst = yyvsp[0].inst; code(lazy_not); ; break;} case 97: #line 492 "yacc.y" { yyval.inst = yyvsp[0].inst; code(not); ; break;} case 98: #line 493 "yacc.y" { fromto(yyvsp[-3].inst, yyvsp[0].inst); fromto(yyvsp[-1].inst, progp); ; break;} case 99: #line 496 "yacc.y" { code(and); ; break;} case 100: #line 497 "yacc.y" { code(or); ; break;} case 101: #line 499 "yacc.y" { fromto(yyvsp[-1].inst, progp); code(cnv_2_bool); ; break;} case 102: #line 503 "yacc.y" { fromto(yyvsp[-1].inst, progp); code(cnv_2_bool); ; break;} case 103: #line 506 "yacc.y" { code(bitand); ; break;} case 104: #line 507 "yacc.y" { code(bitor); ; break;} case 105: #line 508 "yacc.y" { code(rts); unmarkGarbage(yyvsp[-1].inst, progp); yyval.inst = code_eval(yyvsp[-1].inst, progp); inEVAL = 0; ; break;} case 106: #line 514 "yacc.y" { inEVAL = 1; ; break;} case 107: #line 516 "yacc.y" { yyval.inst = code2(jmp, 0); ; break;} case 108: #line 519 "yacc.y" { code(ddup); yyval.inst = code2(jpnt, 0); code(popd); ; break;} case 109: #line 525 "yacc.y" { code(ddup); yyval.inst = code2(jpnf, 0); code(popd); ; break;} case 113: #line 538 "yacc.y" { yyval.inst = code_related_by(yyvsp[-5].sym); ; break;} case 114: #line 540 "yacc.y" { yyval.inst = yyvsp[-1].inst; code(lookup_address); ; break;} case 115: #line 542 "yacc.y" { yyval.inst = code_related_by_runtimelhs(); ; break;} case 116: #line 546 "yacc.y" { addID((symptr) 0); ; break;} case 117: #line 550 "yacc.y" { informula = 0; code(rts); unmarkGarbage(yyvsp[-1].inst, progp); yyval.inst = code_definition( FORMULA, yyvsp[-3].sym, yyvsp[-1].inst, progp, 0, yyvsp[-2].tbegin); ; break;} case 118: #line 556 "yacc.y" { code(lookup_address); ; break;} case 119: #line 557 "yacc.y" { informula = 0; code(rts); unmarkGarbage(yyvsp[-1].inst, progp); yyval.inst = code_definition_runtimelhs( FORMULA, yyvsp[-1].inst, progp, 0, yyvsp[-2].tbegin); ; break;} case 120: #line 565 "yacc.y" { yyval.tbegin = textptr; informula = 1; addID((symptr) 0); ; break;} case 121: #line 572 "yacc.y" { inprocmacro = (yyvsp[-1].narg == 2); /*fprintf(stderr, "inprocmacro=%d\n", inprocmacro);*/ addID((symptr) 0); ; break;} case 122: #line 581 "yacc.y" { code2(pushUNDEF, rts); unmarkGarbage(yyvsp[-1].inst, progp); yyval.inst = code_definition( (yyvsp[-8].narg ? ((yyvsp[-8].narg == 1) ? FUNCTION : PROCMACRO) : PROCEDURE), yyvsp[-7].sym, yyvsp[-1].inst, progp, yyvsp[-2].narg, yyvsp[-4].tbegin ); delete_local_level(yyvsp[0].narg); inprocmacro = 0; ; break;} case 123: #line 594 "yacc.y" { yyval.narg = 1; ; break;} case 124: #line 595 "yacc.y" { yyval.narg = 0; ; break;} case 125: #line 596 "yacc.y" { yyval.narg = 2; ; break;} case 126: #line 600 "yacc.y" { static char c = '{'; if (indef) yyval.tbegin = textptr - 1; else { yyval.tbegin = textptr; push_text(&c,1); } insert_level_marker(++indef); ; break;} case 127: #line 613 "yacc.y" { yyval.narg = indef--; ; break;} case 128: #line 618 "yacc.y" { yyval.narg = 0; ; break;} case 129: #line 619 "yacc.y" { yyval.narg = yyvsp[0].narg; ; break;} case 130: #line 624 "yacc.y" { yyval.narg = 0; ; break;} case 132: #line 629 "yacc.y" { yyval.narg = 1; addID(yyvsp[0].sym); ; break;} case 133: #line 630 "yacc.y" { yyval.narg = yyvsp[-2].narg + 1; addID(yyvsp[0].sym); ; break;} case 135: #line 634 "yacc.y" { inpara = 1; ; break;} case 136: #line 635 "yacc.y" { inpara = 0; ; break;} case 137: #line 639 "yacc.y" { yyval.narg = 0; ; break;} case 138: #line 641 "yacc.y" { inauto = 1; ; break;} case 139: #line 642 "yacc.y" { inauto = 0; yyval.narg = yyvsp[-4].narg + yyvsp[-1].narg; ; break;} case 140: #line 646 "yacc.y" { yyval.narg = 1; ; break;} case 141: #line 647 "yacc.y" { yyval.narg = yyvsp[-2].narg + 1; ; break;} case 142: #line 650 "yacc.y" { yyval.narg = 0; ; break;} case 144: #line 655 "yacc.y" { yyval.narg = 1; ; break;} case 145: #line 656 "yacc.y" { yyval.narg = yyvsp[-2].narg + 1; ; break;} } /* the action file gets copied in in place of this dollarsign */ /* MODIFICATION 9: same as MODIFICATION 1 * #line 543 "/usr/local/share/bison.simple" */ #line 617 "bison/bison.simple" /* END MODIFICATION 9 */ yyvsp -= yylen; yyssp -= yylen; #ifdef YYLSP_NEEDED yylsp -= yylen; #endif #if YYDEBUG != 0 if (yydebug) { short *ssp1 = yyss - 1; fprintf (stderr, "state stack now"); while (ssp1 != yyssp) fprintf (stderr, " %d", *++ssp1); fprintf (stderr, "\n"); } #endif *++yyvsp = yyval; #ifdef YYLSP_NEEDED yylsp++; if (yylen == 0) { yylsp->first_line = yylloc.first_line; yylsp->first_column = yylloc.first_column; yylsp->last_line = (yylsp-1)->last_line; yylsp->last_column = (yylsp-1)->last_column; yylsp->text = 0; } else { yylsp->last_line = (yylsp+yylen-1)->last_line; yylsp->last_column = (yylsp+yylen-1)->last_column; } #endif /* Now "shift" the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ yyn = yyr1[yyn]; yystate = yypgoto[yyn - YYNTBASE] + *yyssp; if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else yystate = yydefgoto[yyn - YYNTBASE]; goto yynewstate; yyerrlab: /* here on detecting error */ if (! yyerrstatus) /* If not already recovering from an error, report this error. */ { ++yynerrs; #ifdef YYERROR_VERBOSE yyn = yypact[yystate]; if (yyn > YYFLAG && yyn < YYLAST) { int size = 0; char *msg; int x, count; count = 0; /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ for (x = (yyn < 0 ? -yyn : 0); x < (sizeof(yytname) / sizeof(char *)); x++) if (yycheck[x + yyn] == x) size += strlen(yytname[x]) + 15, count++; /* MODIFICATION 10: increase space for error message * msg = (char *) malloc(size + 15); */ msg = (char *) malloc(size + 100); /* END MODIFICATION 10 */ if (msg != 0) { strcpy(msg, "parse error"); /* MODIFICATION 11: print expected even when there are > 5 expected * if (count < 5) */ if (1) /* END MODIFICATION 11 */ { count = 0; for (x = (yyn < 0 ? -yyn : 0); x < (sizeof(yytname) / sizeof(char *)); x++) if (yycheck[x + yyn] == x) { /* MODIFICATION 12: indicate when there are > 5 expected but not printed */ if (count > 5) count++; else { /* END MODIFICATION 12 */ strcat(msg, count == 0 ? ", expecting `" : " or `"); strcat(msg, yytname[x]); strcat(msg, "'"); count++; /* MODIFICATION 13: indicate when there are > 5 expected but not printed * } */ } } if (count > 5) { sprintf(msg + strlen(msg), " or... (%d other possibilities)", count - 6); } /* END MODIFICATION 13 */ } yyerror(msg); free(msg); } else yyerror ("parse error; also virtual memory exceeded"); } else #endif /* YYERROR_VERBOSE */ yyerror("parse error"); } goto yyerrlab1; yyerrlab1: /* here on error raised explicitly by an action */ if (yyerrstatus == 3) { /* if just tried and failed to reuse lookahead token after an error, discard it. */ /* return failure if at end of input */ if (yychar == YYEOF) YYABORT; #if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); #endif yychar = YYEMPTY; } /* Else will try to reuse lookahead token after shifting the error token. */ yyerrstatus = 3; /* Each real token shifted decrements this */ goto yyerrhandle; yyerrdefault: /* current state does not do anything special for the error token. */ #if 0 /* This is wrong; only states that explicitly want error tokens should shift them. */ yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ if (yyn) goto yydefault; #endif yyerrpop: /* pop the current state because it cannot handle the error token */ if (yyssp == yyss) YYABORT; yyvsp--; yystate = *--yyssp; #ifdef YYLSP_NEEDED yylsp--; #endif #if YYDEBUG != 0 if (yydebug) { short *ssp1 = yyss - 1; fprintf (stderr, "Error: state stack now"); while (ssp1 != yyssp) fprintf (stderr, " %d", *++ssp1); fprintf (stderr, "\n"); } #endif yyerrhandle: yyn = yypact[yystate]; if (yyn == YYFLAG) goto yyerrdefault; yyn += YYTERROR; if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) goto yyerrdefault; yyn = yytable[yyn]; if (yyn < 0) { if (yyn == YYFLAG) goto yyerrpop; yyn = -yyn; goto yyreduce; } else if (yyn == 0) goto yyerrpop; if (yyn == YYFINAL) YYACCEPT; #if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Shifting error token, "); #endif *++yyvsp = yylval; #ifdef YYLSP_NEEDED *++yylsp = yylloc; #endif yystate = yyn; goto yynewstate; yyacceptlab: /* YYACCEPT comes here. */ if (yyfree_stacks) { free (yyss); free (yyvs); #ifdef YYLSP_NEEDED free (yyls); #endif } return 0; yyabortlab: /* YYABORT comes here. */ if (yyfree_stacks) { free (yyss); free (yyvs); #ifdef YYLSP_NEEDED free (yyls); #endif } return 1; } #line 658 "yacc.y" /*----------------------- end of grammar --------------------------*/ cc.y" { yyval.inst = yyvsp[0].inst; code(lazy_not); ; break;} case 97: #line 492 "yacc.y" { yyval.inst =tkeden1.18/Eden/yacc.h010060000025250000147000000025650731245770000160270ustar00ashleydcsother00003470000356typedef union { Datum *dp; /* constants */ symptr sym; /* symbol table ptr */ Inst *inst; /* machine instruction */ Int narg; /* number of arguments */ Inst fun; /* binop */ struct t *sw; /* switch */ char *tbegin; /* beginning of text */ } YYSTYPE; #define UNDEF 257 #define REAL 258 #define INTEGER 259 #define MYCHAR 260 #define STRING 261 #define LIST 262 #define CONSTANT 263 #define VAR 264 #define FORMULA 265 #define BLTIN 266 #define LIB 267 #define RLIB 268 #define FUNC 269 #define PROC 270 #define PMAC 271 #define FUNCTION 272 #define PROCEDURE 273 #define PROCMACRO 274 #define AUTO 275 #define PARA 276 #define LOCAL 277 #define BREAK 278 #define CONTINUE 279 #define SWITCH 280 #define CASE 281 #define DEFAULT 282 #define DO 283 #define FOR 284 #define WHILE 285 #define IF 286 #define ELSE 287 #define SHIFT 288 #define APPEND 289 #define INSERT 290 #define DELETE 291 #define RETURN 292 #define ARG 293 #define IS 294 #define TILDE_GT 295 #define PLUS_EQ 296 #define MINUS_EQ 297 #define OR 298 #define LAZY_OR 299 #define AND 300 #define LAZY_AND 301 #define BITAND 302 #define BITOR 303 #define EQ_EQ 304 #define NOT_EQ 305 #define GT_EQ 306 #define LT_EQ 307 #define SLASH_SLASH 308 #define NEGATE 309 #define NOT 310 #define PLUS_PLUS 311 #define MINUS_MINUS 312 #define ASTERISK 313 #define EVAL 314 extern YYSTYPE yylval; tkeden1.18/Eden/error.h010060000025250000147000000003360727434333200162350ustar00ashleydcsother00003470000356/* * $Id$ */ /* error.h */ extern void errorf(char *, ...); #define error(s) errorf("%s", s) #define error2(s, t) errorf("%s%s", s, t) extern void notice(char *, char *); extern void msgContent(char *, char *, int); tkeden1.18/EX/004070000025250000147000000000000731700574200143715ustar00ashleydcsother00003470000356tkeden1.18/EX/script.h010060000025250000147000000007440727406554200160600ustar00ashleydcsother00003470000356/* * $Id: script.h,v 1.6 1999/11/16 21:20:40 ashley Rel1.10 $ */ typedef struct Script { int maxScript; /* maximum size of script */ char *text; /* actual translated script */ int ready; /* if a complete statement is translated */ } Script; extern Script *newScript(void); extern void resetScript(Script *); extern void deleteScript(Script *); extern void appendEden(char *, Script *); extern void appendnEden(char *, Script *, int); tkeden1.18/EX/script.c010060000025250000147000000043160731247366400160530ustar00ashleydcsother00003470000356/* * $Id: script.c,v 1.12 1999/11/16 22:33:23 ashley Rel1.10 $ */ static char rcsid[] = "$Id: script.c,v 1.12 1999/11/16 22:33:23 ashley Rel1.10 $"; #include #include #include "../config.h" #include "script.h" #include "../Eden/emalloc.h" #ifdef HAVE_DMALLOC #include #endif /* function prototypes */ Script *newScript(void); void resetScript(Script *); void deleteScript(Script *); void appendEden(char *, Script *); void appendnEden(char *, Script *, int); #define TEXTLEN 1024 static Script **ScriptBuffer; static int nScriptBuffer = 0; static int scriptLevel = 0; Script * newScript(void) { Script *script; if (nScriptBuffer > scriptLevel) { /* there are spare script buffers */ script = ScriptBuffer[scriptLevel]; } else { /* need a new script buffer */ script = (Script *) emalloc(sizeof(Script)); script->text = (char *) emalloc(TEXTLEN); script->maxScript = TEXTLEN; if (nScriptBuffer == 0) { ScriptBuffer = (Script **) emalloc(sizeof(Script *)); } else { ScriptBuffer = (Script **) erealloc(ScriptBuffer, sizeof(Script *) * (nScriptBuffer + 1)); } ScriptBuffer[nScriptBuffer++] = script; } script->text[0] = '\0'; script->ready = 0; scriptLevel++; return script; } void resetScript(Script * script) { script->text[0] = '\0'; script->ready = 0; } void deleteScript(Script * script) { scriptLevel--; script->ready = 0; } /* Append s to the end of script, expanding script if necessary [Ash] */ void appendEden(char *s, Script * script) { if (script->maxScript > (int) strlen(script->text) + (int) strlen(s)) { strcat(script->text, s); } else { script->text = (char *) erealloc(script->text, script->maxScript * 2); script->maxScript *= 2; strcat(script->text, s); } } /* Append at most n characters of s to the end of script, expanding script if necessary [Ash] */ void appendnEden(char *s, Script * script, int n) { if (script->maxScript > (int) strlen(script->text) + n) { strncat(script->text, s, n); } else { script->text = (char *) erealloc(script->text, script->maxScript * 2); script->maxScript *= 2; strncat(script->text, s, n); } } tkeden1.18/EX/parser.c010060000025250000147000000210110731246164600160270ustar00ashleydcsother00003470000356/* * $Id: parser.c,v 1.10 2000/08/31 14:49:40 ashley Rel1.10 $ */ static char rcsid[] = "$Id: parser.c,v 1.10 2000/08/31 14:49:40 ashley Rel1.10 $"; #include "../config.h" #include #include #include #include extern Tcl_Interp *interp; extern void change_prompt(void); extern char agentName[128]; /* sun */ #include "script.h" #include "../Eden/notation.h" #include "../Eden/eden.h" int lineno = 1; /* starting line number = 1 */ int prompt_on = 1; #define STRING_DEV 0 notationType currentNotation = EDEN; /* Possibly used to control the display of context on top of the Input window [Ash] */ char currentAgentName[128] = " "; char currentAgentType[3] = ">>"; /* EXPERIENCE: connecting to a TCL variable, you have to use a pointer rather than an array. --sun */ char *currentAgentNamePtr = 0; char *currentAgentTypePtr = 0; char *current_Notation = "%eden"; /* sun - different from currentNotation (mind the underbar!) */ Script *curScript; /* function prototypes */ void changeNotation(notationType); void setprompt(void); static void distribute(char *, Script *); void evaluate(char *, char *); #ifdef DISTRIB int getNotation(ClientData, Tcl_Interp *, int, char *[]); /* sun */ static void getClientName(char *, Script *); static int readIn; static char clientName[128]; #endif /* DISTRIB */ void changeNotation(notationType notation) { currentNotation = notation; } #ifdef DISTRIB /* To enable us to pack data in its own notation to enable it to be sent between machines (or clients... :) [Ash] */ int /* for distributed tkeden --sun */ getNotation(ClientData clientData, Tcl_Interp * interp, int argc, char *argv[]) { extern char agentType[3]; if (currentNotation == EDEN) current_Notation = "%eden"; if (currentNotation == DONALD) current_Notation = "%donald"; if (currentNotation == SCOUT) current_Notation = "%scout"; if (currentNotation == LSD) current_Notation = "%lsd"; #ifdef WANT_SASAMI if (currentNotation == SASAMI) current_Notation = "%sasami"; #endif /* currentAgentName = agentName; currentAgentType = agentType; */ return TCL_OK; } #endif /* DISTRIB */ void setprompt(void) { char label[128]; char *stmtType; /* the contents of the label above the Input window [Ash] */ extern char *dd_prompt; extern char agentType[3]; #ifdef DISTRIB extern char *LSDagentName; #endif /* DISTRIB */ if (currentNotation == EDEN) { current_Notation = "%eden"; stmtType = "Enter EDEN Statements:"; } #ifdef WANT_SASAMI if (currentNotation == SASAMI) { current_Notation = "%sasami"; strcpy(label,"Enter Sasami Statements :"); stmtType = label; } #endif if (currentNotation == DONALD) { current_Notation = "%donald"; change_prompt(); /* update string for DoNaLD context */ strcpy(label, "Enter DoNaLD Statements (in context "); strcat(label, dd_prompt); strcat(label, "):"); stmtType = label; } if (currentNotation == SCOUT) { current_Notation = "%scout"; stmtType = "Enter SCOUT Statements:"; } #ifdef DISTRIB if (currentNotation == LSD) { current_Notation = "%lsd"; if (LSDagentName == (char *) 0) sprintf(label, "Enter LSD Description :"); else sprintf(label, "Enter LSD Description for AGENT %s : ", LSDagentName); stmtType = label; } #endif /* DISTRIB */ Tcl_VarEval(interp, ".prompt config -text {", stmtType, "}", 0); Tcl_VarEval(interp, "set notation {", current_Notation, "}", 0); /* Display the current VA above the Input window [Ash] */ if (*agentName) strcpy(currentAgentName, agentName); else strcpy(currentAgentName, ""); if (*agentType) strcpy(currentAgentType, agentType); else strcpy(currentAgentType, ">>"); } #ifdef DISTRIB /* This implements some wierd functionality for Meurig, sending definitions to clients using a >>$ type notation. It probably isn't needed any more, but a little tricky to delete it. [Ash, with Patrick] */ static void getClientName(char *str, Script *script) { extern symptr lookup(char *); symptr sp; char *s1= str; char *s2 =0; char *sptr; int i; char clientVarName[128]; if (strncmp(s1, ">$", 2) == 0 || strncmp(s1, "<$", 2) == 0) { s2=s1; s1++; s1++; for (sptr = s1, i = 0; *s1 != '\0' && *s1 != '\n'; s1++, i++); if (strncmp(s2, ">$", 2) == 0) { strncat(clientName, sptr, i); } else { *clientVarName=0; strncpy(clientVarName, sptr, i); if ((sp=lookup(clientVarName)) == 0 || i==0) { *clientName=0; } else { strcpy(clientName, sp->d.u.s); } } readIn=0; } if (strncmp(s1, "$$", 2) == 0) { *clientName=0; readIn=1; } if (strncmp(s1, ">>$", 3) == 0 || strncmp(s1, "><$", 3) == 0) { s2=s1; s1 = s1+3; for (sptr = s1, i = 0; *s1 != '\0' && *s1 != '\n'; s1++, i++); if (strncmp(s2, ">>$", 3) == 0) { strncpy(clientName, sptr, i); } else { *clientVarName=0; strncpy(clientVarName, sptr, i); if ((sp=lookup(clientVarName)) == 0 || i==0) { *clientName=0; } else { strcpy(clientName, sp->d.u.s); } } appendnEden(">>", script, 2); appendEden(clientName, script); appendnEden("\n", script, 1); readIn=1; } } #endif /* DISTRIB */ static void distribute(char *str, Script * script) { char *s = str; char *sptr; int i; #ifdef DISTRIB char sentData[2048]; #endif /* DISTRIB */ /* Ensure the script is in the correct notation [Ash] */ switch (currentNotation) { case DONALD: appendEden("%donald\n", script); break; case SCOUT: appendEden("%scout\n", script); break; #ifdef WANT_SASAMI case SASAMI: appendEden("%sasami\n", script); break; #endif /* WANT_SASAMI */ #ifdef DISTRIB case LSD: appendEden("%lsd\n", script); #endif /* DISTRIB */ default: break; } while (*s) { /* If this line is a %notation line, update our idea of which notation we are currently using. A %notation line is appended for the current notation for every line above [Ash] */ if (strncmp(s, "%donald", 7) == 0) { /* is DoNaLD */ changeNotation(DONALD); } else if (strncmp(s, "%scout", 6) == 0) { /* is SCOUT */ changeNotation(SCOUT); #ifdef DISTRIB } else if (strncmp(s, "%lsd", 4) == 0) { /* is LSD */ changeNotation(LSD); #endif /* DISTRIB */ } else if (strncmp(s, "%eden", 5) == 0) { /* is EDEN */ changeNotation(EDEN); #ifdef WANT_SASAMI } else if (strncmp(s, "%sasami", 7) == 0) { /* is Sasami */ changeNotation(SASAMI); #endif /* WANT_SASAMI */ } /* Count the number of chars in s (terminated by \0 or \n) [Ash] */ for (sptr = s, i = 0; *s != '\0' && *s != '\n'; s++, i++); #ifdef DISTRIB if (strncmp(sptr, ">>$", 3)==0 || strncmp(sptr, "><$", 3)==0 || strncmp(sptr, ">$", 2) == 0 || strncmp(sptr, "<$", 2) == 0 || strncmp(sptr, "$$", 2) == 0) { /* Meurig's funny extra notation - probably not used any more [Ash, with Patrick <--blame Patrick for this! :] */ getClientName(sptr, script); } else { if (readIn == 1) { appendnEden(sptr, script, i); appendnEden("\n", script, 1); } if (*clientName !=0) { *sentData=0; strncat(sentData, sptr, i); appendEden("sendClient(\"", script); appendEden(clientName, script); appendEden("\", \"", script); appendEden(sentData, script); appendEden("\");\n", script); } } #else /* Append one line of s to script [Ash] */ appendnEden(sptr, script, i); appendnEden("\n", script, 1); #endif /* DISTRIB */ if (*s != '\0') { /* *s must be '\n' */ s++; } lineno++; } } /* evaluate() = translate followed by queue() */ void evaluate(char *s, char *master) { Script *script; extern Script *dd_script, *st_script; #ifdef WANT_SASAMI extern Script *sa_script; #endif extern void queue(char *, char *); script = newScript(); dd_script = st_script = script; #ifdef WANT_SASAMI sa_script = script; #endif #ifdef DISTRIB *clientName=0; readIn=1; #endif /* DISTRIB */ distribute(s, script); queue(script->text, master); deleteScript(script); } tkeden1.18/EX/Makefile.in010060000025250000147000000002120731543702600164320ustar00ashleydcsother00003470000356# # $Id: Makefile.in,v 1.12 1999/11/16 22:35:26 ashley Rel1.10 $ # SOURCES = ex.c parser.c script.c LIB = libex.a include ../generic.mk tkeden1.18/EX/ex.c010060000025250000147000000275570731642322200151640ustar00ashleydcsother00003470000356/* * $Id: ex.c,v 1.22 1999/11/16 22:35:59 ashley Rel1.10 $ */ /* [Ben] Check for Win32 */ #ifndef __WIN32__ # if defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__) # define __WIN32__ # endif #endif static char rcsid[] = "$Id: ex.c,v 1.22 1999/11/16 22:35:59 ashley Rel1.10 $"; #include #include #include #include #include #include #include /* for PATH_MAX */ #include "../config.h" #include "../Eden/notation.h" #include "../Eden/eden.h" #include "../version.h" #ifdef DISTRIB #include /* for MAXHOSTNAMELEN on Solaris [Ash] */ #include /* for MAXHOSTNAMELEN on Linux [Ash] */ #endif #include "../Eden/emalloc.h" #ifdef HAVE_DMALLOC #include #endif extern int run(short, void *, char *); extern void queue(char *, char *); extern void warning(char *, char *); extern void pushMasterStack(char *); extern void popMasterStack(void); extern void evaluate(char *, char *); extern void terminate(int); extern int eden_interrupt_handler(ClientData, Tcl_Interp *, int, char *[]); extern int dumpeden(ClientData, Tcl_Interp *, int, char *[]); extern int dumpscout(ClientData, Tcl_Interp *, int, char *[]); extern int dumpdonald(ClientData, Tcl_Interp *, int, char *[]); extern int viewOptions(ClientData, Tcl_Interp *, int, char *[]); #ifdef DISTRIB extern int dumpLSD(ClientData, Tcl_Interp *, int, char *[]); extern int getNotation(ClientData, Tcl_Interp *, int, char *[]); /* sun */ #endif /* DISTRIB */ #include /* Tcl caches environment variables: so we must use Tcl's versions of the getenv and putenv functions [Ash] */ /* Tcl 8.2.0 Makefile implies don't use the Tcl getenv [Ash] */ #define putenv Tcl_PutEnv #define setenv TclSetEnv #define unsetenv TclUnsetEnv #include Tcl_Interp *interp; Tk_Window mainWindow; static int edenCmd(ClientData, Tcl_Interp *, int, char *[]); static int todoCmd(ClientData, Tcl_Interp *, int, char *[]); static int evaluateCmd(ClientData, Tcl_Interp *, int, char *[]); static int quitCmd(ClientData, Tcl_Interp *, int, char *[]); static int refreshCmd(ClientData, Tcl_Interp *, int, char *[]); static int gotoCmd(ClientData, Tcl_Interp *, int, char *[]); int Tcl_AppInit(Tcl_Interp *); void EXinit(void); extern char *ex_sptr, ex_sbuf[]; char *sptr; extern char *progname; extern char *libLocation; #define STRING_DEV 0 /* This implements the Tcl "eden" command [Ash] */ static int edenCmd(ClientData clientData, Tcl_Interp * interp, int argc, char *argv[]) { notationType notation; if (argc != 2) { warning("Tcl: ", "eden: wrong # of arguments"); } notation = currentNotation; changeNotation(EDEN); pushMasterStack("user"); run(STRING_DEV, argv[1], 0); popMasterStack(); changeNotation(notation); return TCL_OK; } static int todoCmd(ClientData clientData, Tcl_Interp * interp, int argc, char *argv[]) { if (argc != 2) { warning("Tcl: ", "eden: wrong # of arguments"); } queue(argv[1], "interface"); return TCL_OK; } static int evaluateCmd(ClientData clientData, Tcl_Interp * interp, int argc, char *argv[]) { if (argc != 2) { warning("Tcl: ", "evaluate: wrong # of arguments"); } evaluate(argv[1], "input"); return TCL_OK; } static int quitCmd(ClientData clientData, Tcl_Interp * interp, int argc, char *argv[]) { terminate(0); return TCL_ERROR; } static int refreshCmd(ClientData clientData, Tcl_Interp * interp, int argc, char *argv[]) { Tk_Window tkwin; XEvent e; if (argc != 2) { warning("Tcl: ", "refresh: wrong # of arguments"); } tkwin = Tk_NameToWindow(interp, argv[1], mainWindow); e.xexpose.type = Expose; e.xexpose.send_event = True; e.xexpose.display = Tk_Display(tkwin); e.xexpose.window = Tk_WindowId(tkwin); e.xexpose.x = 0; e.xexpose.y = 0; e.xexpose.width = Tk_Width(tkwin); e.xexpose.height = Tk_Height(tkwin); e.xexpose.count = 1; XSendEvent(Tk_Display(tkwin), Tk_WindowId(tkwin), True, NoEventMask, &e); return TCL_OK; } static int gotoCmd(ClientData clientData, Tcl_Interp * interp, int argc, char *argv[]) { #ifndef __WIN32__ Tk_Window tkwin; if (argc != 4) { interp->result = "wrong # args"; return TCL_ERROR; } if (strlen(argv[1]) == 0) { XWarpPointer(Tk_Display(mainWindow), 0, None, 0, 0, 0, 0, atoi(argv[2]), atoi(argv[3])); } else { tkwin = Tk_NameToWindow(interp, argv[1], mainWindow); XWarpPointer(Tk_Display(tkwin), 0, Tk_WindowId(tkwin), 0, 0, 0, 0, atoi(argv[2]), atoi(argv[3])); } interp->result = ""; return TCL_OK; #endif } /* Tcl_Eval with Error Check - uses Tcl_EvalEx for speed if we have it [Ash] */ #ifdef HAVE_TCL_EVALEX #define TCL_EVALEX(i, s, n, f) Tcl_EvalEx(i, s, n, f) #else #define TCL_EVALEX(i, s, n, f) Tcl_Eval(i, s) #endif inline void Tcl_EvalEC(Tcl_Interp * interp, char *script) { if (TCL_EVALEX(interp, script, -1, 0) != TCL_OK) { errorf("Tcl error (Tcl_EvalEC): %s", Tcl_GetStringResult(interp)); } } /* Tcl_GlobalEval with Error Check - uses Tcl_EvalEx for speed [Ash] */ inline void Tcl_GlobalEvalEC(Tcl_Interp * interp, char *script) { if (TCL_EVALEX(interp, script, -1, TCL_EVAL_GLOBAL) != TCL_OK) { errorf("Tcl error (Tcl_GlobalEvalEC): %s", Tcl_GetStringResult(interp)); } } #ifdef __CYGWIN__ int cygwin_conv_to_full_win32_path_tcl(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[]) { extern cygwin_conv_to_full_win32_path(const char *path, char *win32_path); char winpath[PATH_MAX]; if (argc != 2) { warning("cygwin_conv_to_full_win32_path: one argument is required", 0); } if (!cygwin_conv_to_full_win32_path(argv[1], winpath)) { Tcl_SetResult(interp, winpath, TCL_STATIC); return TCL_OK; } else { return TCL_ERROR; } } #endif int Tcl_AppInit(Tcl_Interp * interp) { if (Tcl_Init(interp) == TCL_ERROR) return TCL_ERROR; if (Tk_Init(interp) == TCL_ERROR) return TCL_ERROR; Tcl_CreateCommand(interp, "quit", quitCmd, NULL, NULL); Tcl_CreateCommand(interp, "evaluate", evaluateCmd, NULL, NULL); Tcl_CreateCommand(interp, "eden", edenCmd, NULL, NULL); Tcl_CreateCommand(interp, "todo", todoCmd, NULL, NULL); Tcl_CreateCommand(interp, "refresh", refreshCmd, NULL, NULL); Tcl_CreateCommand(interp, "goto", gotoCmd, NULL, NULL); Tcl_CreateCommand(interp, "dumpeden", dumpeden, NULL, NULL); Tcl_CreateCommand(interp, "dumpscout", dumpscout, NULL, NULL); Tcl_CreateCommand(interp, "dumpdonald", dumpdonald, NULL, NULL); Tcl_CreateCommand(interp, "setupViewOptions", viewOptions, NULL, NULL); Tcl_CreateCommand(interp, "interrupt", eden_interrupt_handler, NULL, NULL); #ifdef DISTRIB Tcl_CreateCommand(interp, "dumpLSD", dumpLSD, NULL, NULL); Tcl_CreateCommand(interp, "getOldNotation", getNotation, NULL, NULL); Tcl_CreateCommand(interp, "getCurrentNotation", getNotation, NULL, NULL); #endif /* DISTRIB */ #ifdef __WIN32__ Tcl_CreateCommand(interp, "cygwin_conv_to_full_win32_path", cygwin_conv_to_full_win32_path_tcl, NULL, NULL); #endif return TCL_OK; } void EXinitTcl(void) { interp = Tcl_CreateInterp(); /* Set the "tcl_interactive" variable. */ Tcl_SetVar(interp, "tcl_interactive", "1", TCL_GLOBAL_ONLY); /* Invoke application-specific initialization. */ if (Tcl_AppInit(interp) != TCL_OK) { fprintf(stderr, "Tcl_AppInit failed: %s\n", interp->result); exit(1); } } void EXinit(void) { extern char *progname; #ifdef DISTRIB extern char hostName[MAXHOSTNAMELEN]; /* provided in Eden/main.c [Ash] */ extern int socketPort; /* for distributed tkEden --sun */ extern char *current_Notation; extern char *hostNamePtr; extern Int *synchronize; extern int isServer; #endif /* DISTRIB */ char *name = "/edenio.tcl"; extern char currentAgentName[128]; extern char currentAgentType[3]; extern char *currentAgentNamePtr; extern char *currentAgentTypePtr; char fullname[255]; /* This seems safe to do: if $DISPLAY is unset, Tcl_AppInit will have failed earlier [Ash] */ char *display = getenv("DISPLAY"); char *class = (char *) ckalloc((unsigned) (strlen(progname) + 1)); char *envcontents; /* These must be static so they don't go out of scope and disappear, leaving Tcl saying "where are they", causing Seg faults etc. D'oh! [Ash] */ static char *version; /* version of tkeden [Ash] */ static char *variant; /* whether tty, tk, d, ? [Ash] */ static char *webSite; /* address of the EM web site [Ash] */ static char *win32version; /* Win32 version number [Ben] */ static char *sasamiAvail; /* whether we have sasami [Ash] */ strcpy(class, progname); class[0] = toupper((unsigned char) class[0]); /* EXinitTcl() should have already been called by main.c [Ash] */ mainWindow = Tk_MainWindow(interp); ckfree(class); if (mainWindow == NULL) { fprintf(stderr, "%s\n", interp->result); exit(1); } /* Work out file name of Tcl interface code */ strcpy(fullname, libLocation); strcat(fullname, name); currentAgentNamePtr = currentAgentName; currentAgentTypePtr = currentAgentType; #ifdef DISTRIB if (isServer) { /* DISTRIB, server */ Tcl_LinkVar(interp, "svcPort", (char *) &socketPort, TCL_LINK_INT); Tcl_LinkVar(interp, "eshost", (char *) &hostNamePtr, TCL_LINK_STRING); Tcl_LinkVar(interp, "oldNotation", (char *) ¤t_Notation, TCL_LINK_STRING); Tcl_LinkVar(interp, "oldAgentType", (char *) ¤tAgentTypePtr, TCL_LINK_STRING); Tcl_LinkVar(interp, "oldAgentName", (char *) ¤tAgentNamePtr, TCL_LINK_STRING); } else { /* DISTRIB, client */ Tcl_LinkVar(interp, "esport", (char *) &socketPort, TCL_LINK_INT); Tcl_LinkVar(interp, "eshost", (char *) &hostNamePtr, TCL_LINK_STRING); Tcl_LinkVar(interp, "currentNotation", (char *) ¤t_Notation, TCL_LINK_STRING); } /* printf("sockPort = %i", socketPort); */ Tcl_LinkVar(interp, "synchronize", (char *) synchronize, TCL_LINK_INT); Tcl_LinkVar(interp, "_dtkeden_isServer", (char *) &isServer, TCL_LINK_BOOLEAN | TCL_LINK_READ_ONLY); #endif /* DISTRIB */ /* Create Tcl variables... */ version = Tcl_Alloc(TKEDEN_VERSION_MAX_LEN); *version = 0; strcat(version, TKEDEN_VERSION); Tcl_LinkVar(interp, "_tkeden_version", (char *) &version, TCL_LINK_STRING | TCL_LINK_READ_ONLY); variant = Tcl_Alloc(TKEDEN_VARIANT_MAX_LEN); *variant = 0; strcat(variant, TKEDEN_VARIANT); Tcl_LinkVar(interp, "_tkeden_variant", (char *) &variant, TCL_LINK_STRING | TCL_LINK_READ_ONLY); webSite = Tcl_Alloc(TKEDEN_WEB_SITE_MAX_LEN); *webSite = 0; strcat(webSite, TKEDEN_WEB_SITE); Tcl_LinkVar(interp, "_tkeden_web_site", (char *) &webSite, TCL_LINK_STRING | TCL_LINK_READ_ONLY); sasamiAvail = Tcl_Alloc(2); *sasamiAvail = 0; #ifdef WANT_SASAMI strcat(sasamiAvail, "1"); #else strcat(sasamiAvail, "0"); #endif Tcl_LinkVar(interp, "_tkeden_sasamiAvail", (char *) &sasamiAvail, TCL_LINK_STRING | TCL_LINK_READ_ONLY); /* [Ben] Create _tkeden_win32_version variable (used in TCL to check for Win32) _tkeden_win32_version is "0.0" if not running on Win32 This is set in version.h */ win32version = Tcl_Alloc(TKEDEN_WIN32_VERSION_MAX_LEN); *win32version = 0; strcat(win32version, TKEDEN_WIN32_VERSION); Tcl_LinkVar(interp, "_tkeden_win32_version", (char *) &win32version, TCL_LINK_STRING | TCL_LINK_READ_ONLY); if (Tcl_EvalFile(interp, fullname) != TCL_OK) { fprintf(stderr, "%s: Tcl error whilst evaluating %s\n", progname, fullname); fprintf(stderr, "Tcl errorInfo (from EXinit): %s\n", Tcl_GetVar(interp, "errorInfo", 0)); exit(1); } #ifdef DISTRIB /* setSocketPort(); */ #endif /* DISTRIB */ } ta, Tcl_Interp *, int, char *[]); static int todoCmd(ClientData, Tcl_Interp *, int, char *[]); static int evaluateCmd(ClientData, Tcl_Interp *,tkeden1.18/EX/CVS/004070000025250000147000000000000731677661000150345ustar00ashleydcsother00003470000356tkeden1.18/EX/CVS/Root010060000025250000147000000000360727406554400157000ustar00ashleydcsother00003470000356cssbz@127.0.0.1:/cvsroot/eden tkeden1.18/EX/CVS/Repository010060000025250000147000000000120727406554400171260ustar00ashleydcsother00003470000356tkeden/EX tkeden1.18/EX/CVS/Entries010060000025250000147000000005650727406554400163750ustar00ashleydcsother00003470000356/Makefile.in/1.12/Wed Apr 11 17:55:13 2001// /disp.c/1.10/Wed Apr 11 17:55:16 2001// /disp.h/1.7/Wed Apr 11 17:55:16 2001// /ex.c/1.22/Wed Apr 11 17:55:25 2001// /parser.c/1.10/Wed Apr 11 17:55:34 2001// /script.c/1.12/Wed Apr 11 17:55:39 2001// /script.h/1.6/Wed Apr 11 17:55:39 2001// /win32ex.c/1.2/Wed Apr 11 17:55:39 2001// /win32ex.h/1.2/Wed Apr 11 17:55:39 2001// D tkeden1.18/install-sh010070000025250000147000000112450727406554000160650ustar00ashleydcsother00003470000356#! /bin/sh # # install - install a program, script, or datafile # This comes from X11R5. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. # # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" transformbasename="" transform_arg="" instcmd="$mvprog" chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" dst="" dir_arg="" while [ x"$1" != x ]; do case $1 in -c) instcmd="$cpprog" shift continue;; -d) dir_arg=true shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd="$stripprog" shift continue;; -t=*) transformarg=`echo $1 | sed 's/-t=//'` shift continue;; -b=*) transformbasename=`echo $1 | sed 's/-b=//'` shift continue;; *) if [ x"$src" = x ] then src=$1 else # this colon is to work around a 386BSD /bin/sh bug : dst=$1 fi shift continue;; esac done if [ x"$src" = x ] then echo "install: no input file specified" exit 1 else true fi if [ x"$dir_arg" != x ]; then dst=$src src="" if [ -d $dst ]; then instcmd=: else instcmd=mkdir fi else # Waiting for this to be detected by the "$instcmd $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f $src -o -d $src ] then true else echo "install: $src does not exist" exit 1 fi if [ x"$dst" = x ] then echo "install: no destination specified" exit 1 else true fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic if [ -d $dst ] then dst="$dst"/`basename $src` else true fi fi ## this sed command emulates the dirname command dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` # Make sure that the destination directory exists. # this part is taken from Noah Friedman's mkinstalldirs script # Skip lots of stat calls in the usual case. if [ ! -d "$dstdir" ]; then defaultIFS=' ' IFS="${IFS-${defaultIFS}}" oIFS="${IFS}" # Some sh's can't handle IFS=/ for some reason. IFS='%' set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` IFS="${oIFS}" pathcomp='' while [ $# -ne 0 ] ; do pathcomp="${pathcomp}${1}" shift if [ ! -d "${pathcomp}" ] ; then $mkdirprog "${pathcomp}" else true fi pathcomp="${pathcomp}/" done fi if [ x"$dir_arg" != x ] then $doit $instcmd $dst && if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi else # If we're going to rename the final executable, determine the name now. if [ x"$transformarg" = x ] then dstfile=`basename $dst` else dstfile=`basename $dst $transformbasename | sed $transformarg`$transformbasename fi # don't allow the sed command to completely eliminate the filename if [ x"$dstfile" = x ] then dstfile=`basename $dst` else true fi # Make a temp file name in the proper directory. dsttmp=$dstdir/#inst.$$# # Move or copy the file name to the temp name $doit $instcmd $src $dsttmp && trap "rm -f ${dsttmp}" 0 && # and set any options; do chmod last to preserve setuid bits # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $instcmd $src $dsttmp" command. if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && # Now rename the file to the real destination. $doit $rmcmd -f $dstdir/$dstfile && $doit $mvcmd $dsttmp $dstdir/$dstfile fi && exit 0 tkeden1.18/lib-tkeden/004070000025250000147000000000000731677661000161035ustar00ashleydcsother00003470000356tkeden1.18/lib-tkeden/server.tcl010060000025250000147000000177210730550215400201100ustar00ashleydcsother00003470000356# # $Id: server.tcl,v 1.4 1999/09/21 19:09:49 ashley Rel1.10 $ # # Just the server specific bits of tcl. This is sourced when appropriate # from edenio.tcl [Ash] # Client-Server & Socket # display the message of client connection on client window proc appendWindows {win text} { $win config -state normal $win insert end $text $win see end $win config -state disabled } # display the scripts sent by client on client window # send scripts to each client proc sendClientsSock {wsock msg} { global EOF clientsReply EOS synchronize foreach sock $wsock { if {$sock == "Own"} { appendHist "$msg\n" evaluate "$msg\n" } else { # puts "test$sock" #if {$synchronize > 0} { # comment it due to the possibility of dead-lock # don't change the name of synchronize which comes from Eden/main.server.c # incr clientsReply -1 # puts $sock "$msg\n$EOS" puts $sock "$msg\n$EOF" #} else {puts $sock "$msg\n$EOF"} } } #if {$synchronize > 0} { # comment it due to the possibility of dead-lock # while {$clientsReply < 0} { # vwait clientsReply # } #} } proc sendOtherClients {exceptUsr msg} { #Don't change procedure's name which is connected to C programs of Eden. global clientSock sockName if {[llength $clientSock] != 0 } { set otherClients $clientSock if {[llength $exceptUsr] != 0 && [info exists sockName($exceptUsr)]} { set exceptClient [lsearch $clientSock $sockName($exceptUsr)] if {$exceptClient >= 0 } { set otherClients [lreplace $clientSock $exceptClient $exceptClient] } } sendClientsSock $otherClients $msg } } proc sendClient {wusr msg} { #Don't change procedure's name which is connected to C programs of Eden. global sockName if {[info exists sockName($wusr)]} { sendClientsSock \{$sockName($wusr)\} $msg } } # read scripts from tkeden input window and send them to each client proc sendScripts {} { global clientSock set text [.text get 1.0 end] # .menu.accept invoke # puts "send $text" sendClientsSock $clientSock $text } # read each definition into send window until EOF is found and then # send all to each client proc doService {sock addr msg} { global EOF EOU clientSock proType clientName sockName receivedMessage global oldNotation oldAgentName oldAgentType global EOS clientsReply synchronize ECS serverJobID JOBID set msg [string trimright $msg] if {$msg == "" || $msg == "\n"} return set msg1 [string rang $msg 0 10] if {$msg1 == $EOS} { #if {$synchronize > 0} {incr clientsReply} return } if {$msg1 != $EOF && $msg1 !=$EOU && $msg1 != $ECS} { append receivedMessage($sock) "$msg\n" return } if {$msg1 == $EOU} { ;# agent's name input by a client set loginClientName [string rang $msg 11 end] # getOldNotation # if {[llength $clientSock] == 0} { # evaluate ">>\n%eden\nCLIENT_LIST = \[\];\n$oldAgentType$oldAgentName\n$oldNotation\n" # } CLIENT_LIST has been declared in Scout.init.e */ evaluate ">>\n%eden\nappend CLIENT_LIST, \"$loginClientName\";\n$oldAgentType$oldAgentName\n$oldNotation\n" lappend clientSock $sock set clientName($sock) $loginClientName set sockName($loginClientName) $sock set receivedMessage($sock) "" return } set text $receivedMessage($sock) set sendClientName $clientName($sock) if {$msg1 == $EOF || $msg1 == $ECS} { if {$proType == "2" || $proType == "0"} { # getOldNotation incr JOBID appendHist ">~$sendClientName\n" appendHist $text appendHist "$oldAgentType$oldAgentName\n" appendHist "$oldNotation\n" # cannot change oldNotation, oldAgentType & oldAgentName. it comes from EX/EXinit(). # puts ">~$sendClientName\n$text\n%eden\ntcl(\"setServerJobID $JOBID\");\n$oldAgentType$oldAgentName\n$oldNotation\n" evaluate ">~$sendClientName\n$text\n%eden\ntcl(\"setServerJobID $JOBID\");\n$oldAgentType$oldAgentName\n$oldNotation\n" if {$proType == "2"} { set otherClients $clientSock set delClient [lsearch $clientSock $sock] if {$delClient >= 0 } { set otherClients [lreplace $clientSock $delClient $delClient] } sendClientsSock $otherClients $text } } elseif {$proType == "1" } { set text ">>$sendClientName\n$text\n>>\n" .text insert end $text } elseif {$proType == "3" } { set text ">>$sendClientName\n$text\n>>\n" # puts $text # getOldNotation appendHist $text evaluate "$text\n$oldAgentType$oldAgentName\n$oldNotation\n"; # cannot change oldNotation. it comes from EX/EXinit(). } if {$msg1 == $ECS} { #puts "5000" #after 50000 # slow down client's speed to let server do service #puts "$serverJobID $JOBID" while {$serverJobID != $JOBID} { vwait serverJobID } puts $sockName($sendClientName) $ECS } set receivedMessage($sock) "" return } } # Handles the input from the client and client shutdown proc svcHandler {sock addr} { global clientSock clientName sockName receivedMessage global oldNotation oldAgentName oldAgentType set msg [gets $sock] ;# get the client packet if {[eof $sock]} { ;# client gone or finished appendWindows .client.t.text "[fconfigure $sock -peername] disconnected \ at [exec date]\n" close $sock ;# release the servers client channel set delClient [lsearch $clientSock $sock] if {$delClient >= 0 } { set clientSock [lreplace $clientSock $delClient $delClient] # getOldNotation evaluate ">>\n%eden\ndelete CLIENT_LIST, $delClient+1;\ \n$oldAgentType$oldAgentName\n$oldNotation\n" unset sockName($clientName($sock)) unset clientName($sock) unset receivedMessage($sock) } } else { doService $sock $addr $msg } } proc setServerJobID { value } { global serverJobID set serverJobID $value } # Accept-Connection handler for Server. # called When client makes a connection to the server # Its passed the channel we're to communicate with the client on, # The address of the client and the port we're using # # Setup a handler for (incoming) communication on # the client channel - send connection Reply and log connection proc connect {sock addr port} { # if {[badConnect $addr]} { # close $sock # return # } # Setup handler for future communication on client socket global clientSock set sockPeerName [fconfigure $sock -peername] # lappend clientSock $sock # evaluate "append CLIENT_LIST, \"$sock\";" fileevent $sock readable [list svcHandler $sock $addr] # Note we've accepted a connection (show how get peer info fm socket) appendWindows .client.t.text "Accept from $sockPeerName\n\ Accepted connection from $addr at [exec date]\n" # Read client input in lines, disable blocking I/O fconfigure $sock -buffering line -blocking 0 # Send Acceptance string to client # puts $sock "$addr:$port, You are connected to the echo server." # puts $sock "It is now [exec date]" } # Create a server socket on port $svcPort. # Call proc connect when a client attempts a connection. set clientSock {} set sockName(Own) "Own" set EOF "@#$%EOF%$#@" set EOU "@#$%EOU%$#@" set EOS "@#$%EOS%$#@" set ECS "@#$%ECS%$#@" set clientsReply 0 set JOBID 0 set serverJobID 0 socket -server connect $svcPort ;# cannot change the name of svcPort as it comes from EXinit() in EX/ex.c puts "$variantversion: server socket setup: channel <[expr $svcPort-9000]> on host <$eshost>" #puts "so far so good..." update #vwait events ;# handle events till variable events is set tkeden1.18/lib-tkeden/scout.init.e010060000025250000147000000505370731677544200203630ustar00ashleydcsother00003470000356/** * tkeden version 1.2 * **/ /**** * * * This file is the function library of the SCOUT system * * It contains definitions of attributes, EDEN version of * * some SCOUT functions, screen updating functions and * * its sub-functions and initialization procedures * * * ****/ /** Initialise EX **/ TKversion = tcl("set tk_patchLevel"); BuggyCanvas = TKversion < "4.0b3" && TKversion != "4.0"; /* luckily these first two are the same as required by donald in donald.init.e. These must be the same values as are defined in the Scout namespace in Scout/lex.c (init_scout). Also define these in builtinf.h [Ash] */ OFF = 0; ON = 1; MOTION = 2; ENTER = 4; LEAVE = 8; CLIENT_LIST = []; /* declare a list for server end to list all connected clients */ DFfont = "{courier 10}"; DFscreen = "screen"; /* should not change this */ DFalign = 0; /* 0 - no, 1 - left, 2 - right, 3 - centre, 4 - left & right */ DFbgcolor = tcl(". cget -background"); DFfgcolor = "black"; DFbdcolor = "black"; DFborder = 0; DFrelief = "raise"; DFxmin = 0; DFymin = 0; DFxmax = 1000; DFymax = 1000; DFhighlight = 1; DFsensitive = OFF; proc OpenDisplay { para name, width, height; if (name[1] >= 'A' && name[1] <= 'Z') name = "_"//name; tcl("toplevel ."//name//" -background "//DFbgcolor// " -width "//str(width)//" -height "//str(height)); tcl("wm protocol ."//name//" WM_DELETE_WINDOW { set show_"//name// " 0; show "//name//" 0;}"); tcl("wm title ."//name//" \""//name//" ($variantversion)\""); tcl("uplevel #0 {set show_"//name//" 1}"); /* the -underline here should really look through the other items in the * menu and find the first unique character to use as a key shortcut * [Ash], April 2001 */ tcl(".menu.show add checkbutton -label "//name// " -variable show_"//name//" -command {show "//name// " $show_"//name//"} -underline 1"); execute("%scout\ndisplay ~" // name // ";\n%eden\n"); } proc DestroyDisplay { para name; if (name[1] >= 'A' && name[1] <= 'Z') name = "_"//name; tcl("destroy ."//name); tcl(".menu.show delete "//name); tcl("unset show_"//name); } func StringWidth { para win, font, string; return int(tcl("font measure " // font // " -displayof ." // win // " " // string)); } func FontWidth { para win, font; /* Measuring the width of the (wide) character 'W' */ return StringWidth(win, font, "W"); } func FontHeight { para win, font; return int(tcl("font metrics " // font // " -displayof ." // win // " -linespace")); } func DisplayDepth { para win; return int(tcl("winfo depth ." // win)); } /* This gets called when '%scout' is done for the first time */ proc scoutScreenInitOpen { OpenDisplay(DFscreen, 500, 500); fontWidth is FontWidth(DFscreen, DFfont); fontHeight is FontHeight(DFscreen, DFfont); displayDepth is DisplayDepth(DFscreen); } /**** * SCOUT functions * ****/ func pt_add /* ( point, point) */ /* + (point addition) */ { return [$1[1] + $2[1], $1[2] + $2[2]]; } func pt_subtract /* ( point, point) */ /* - (point subtraction) */ { return [$1[1] - $2[1], $1[2] - $2[2]]; } func row { return $1 * fontHeight; } func column { return $1 * fontWidth; } proc update_row : fontHeight { touch(&row); } proc update_column : fontWidth { touch(&column); } func dotint /* ( list, int ) */ /* .1 (i.e. dotint(point, 1)) .2 (i.e. dotint(point, 2)) .type (i.e. dotint(window, 1)) .frame (i.e. dotint(window, 2)) .string (i.e. dotint(window, 3)) .box (i.e. dotint(window, 4)) .pict (i.e. dotint(window, 5)) .xmin (i.e. dotint(window, 6)) .ymin (i.e. dotint(window, 7)) .xmax (i.e. dotint(window, 8)) .ymax (i.e. dotint(window, 9)) .bg (i.e. dotint(window, 10)) .fg (i.e. dotint(window, 11)) .border (i.e. dotint(window, 12)) .align (i.e. dotint(window, 13)) .sensitive (i.e. dotint(window, 14)) .bordercolor (i.e. dotint(window, 15)) .font (i.e. dotint(window, 16)) .relief (i.e. dotint(window, 17)) .(int) (for frame and display) */ { return $1[int($2)]; } func dotne /* ( box ) */ /* .ne */ { return [$1[3], $1[2]]; } func dotnw /* ( box ) */ /* .nw */ { return [$1[1], $1[2]]; } func dotse /* ( box ) */ /* .se */ { return [$1[3], $1[4]]; } func dotsw /* ( box ) */ /* .sw */ { return [$1[1], $1[4]]; } func dotn /* ( box ) */ /* .n */ { return [($1[1] + $1[3]) / 2, $1[2]]; } func dote /* ( box ) */ /* .e */ { return [$1[3], ($1[2] + $1[4]) / 2]; } func dots /* ( box ) */ /* .s */ { return [($1[1] + $1[3]) / 2, $1[4]]; } func dotw /* ( box ) */ /* .w */ { return [$1[1], ($1[2] + $1[4]) / 2]; } func boxshift /* ( box, x, y ) */ { para box, x, y; return [box[1] + x, box[2] + y, box[3] + x, box[4] + y]; } func app /* ( list, position, element ) */ /* append (for both frame and display) */ { insert $1, int($2) + 1, $3; return $1; } func del /* ( list, position ) */ /* delete (for both frame and display) */ { delete $1, $2; return $1; } func list_append /* ( list, list ) */ /* & (for both frame and display) */ { return $1 // $2; } func formbox /* ( point, point ) */ /* constructor of box : < P1, P2 > */ { return [$1[1], $1[2], $2[1], $2[2]]; } proc update_textbox : column, row { touch(&textbox); } func textbox { return [$1[1], $1[2], $1[1] + column($3) + 1, $1[2] + row($2) - 1]; } func box_width /* ( box ) */ /* return the width of the box in pixel */ { return $1[3] - $1[1] + 1; } func box_height /* ( box ) */ /* return the height of the box in pixel */ { return $1[4] - $1[2] + 1; } func capacity /* ( box ) */ /* return [r, c], no of row and no of col the box can hold */ { return [($1[4] - $1[2] - 1) / fontHeight, ($1[3] - $1[1] - 1) / fontWidth]; } /*** * string manipulating functions * ***/ func Quote { para s; auto ret, i; if (type(s) != "string") { return str(s); } ret = "\""; for (i = 1; i <= s#; i++) { switch (s[i]) { case '"': ret = ret // "\\\""; break; case '\\': ret = ret // "\\\\"; break; default: ret = ret // s[i]; break; } } return ret // "\""; } /** * image related functions * **/ /* return the height of an image */ func ImageHeight { return tcl("image height "//$1); } /* return the width of an image */ func ImageWidth { return tcl("image width "//$1); } /* read, name and return the image from file image format currently available are ppm and gif */ func ImageFile { para imageName, type, filename; xoutput("image create photo", imageName, "-format", type, "-file", filename); return imageName; } /* scale the srcImage, name and return the scaled image as imageName */ /* This function uses the external utility pnmscale to do the job as Tcl can only currently scale images by integer amounts, and requires "zoom" for positive and "subsample" for negative amounts. Unfortunately the pnm utilities seem to be quite a UNIX thing and getting this way of things to work on Windoz could be quite a headache. :(. Anyway - if you want to fudge a scaled image using only Tcl, use something like xoutput("image create photo ", imageName); xoutput(imageName, "copy", srcImage, "-subsample 3"); return imageName here. [Ash, Sept 2000] */ func ImageScale { para imageName, srcImage, xscale, yscale; tcl("image create photo "//imageName); xoutput(srcImage, "write /tmp/1"//imageName); xoutput("exec pnmscale -xscale", xscale, "-yscale", yscale, "/tmp/1"//imageName, "> /tmp/2"//imageName); xoutput(imageName, "read /tmp/2"//imageName); xoutput("exec rm /tmp/1"//imageName, "/tmp/2"//imageName); return imageName; } /* cut a rectangle out of the srcImage, name and return result as imageName */ func ImageCut { para imageName, srcImage, x, y, width, height; tcl("image create photo "//imageName); xoutput(srcImage, "write /tmp/1"//imageName); xoutput("exec pnmcut", x, y, width, height, "/tmp/1"//imageName, "> /tmp/2"//imageName); xoutput(imageName, "read /tmp/2"//imageName); xoutput("exec rm /tmp/1"//imageName, "/tmp/2"//imageName); return imageName; } /* create pattern using ppmpat */ /* ppmpat generates ascii PPM which cannot be recognised by Tk */ func ImagePat { para imageName, form, width, height; tcl("image create photo "//imageName); xoutput("exec ppmpat -"//form, width, height, "> /tmp/1"//imageName); xoutput(imageName, "read /tmp/1"//imageName); xoutput("exec rm /tmp/1"//imageName); return imageName; } /* procedure for displaying an image */ proc ShowImage { para I_source, source; auto command, i, width, height; for (i = 1; i <= (*source)#; i++) { command = "."//(*source)[i][1]//"."//(*source)[i][2]; width = int(tcl(command//" cget -width")); height = int(tcl(command//" cget -height")); xoutput(command, "create image", width / 2, height / 2, "-tags image -image", *I_source); } } / screen updating actions / func Position { para bd, width, just; auto x, j, anchor; switch (int(just)) { case 1: x = 0; j = "left"; anchor = "nw"; break; case 2: x = width; j = "right"; anchor = "ne"; break; case 3: x = width / 2; j = "center"; anchor = "n"; break; case 0: case 4: /* not supported by Tk */ default: x = 0; j = "left"; anchor = "nw"; break; } return str(int(bd + x))//" "//str(int(bd))//" -anchor "//anchor //" -justify "//j; } proc scout_show_2D /* display a DoNaLD/ARCA picture */ { para screen, winNo, boxName; /* writeln("scout_show_2D: ", $); */ scout_show_2D_window(`screen`[winNo], "."//screen//"."//boxName//"_1", boxName//"_1"); } proc dobinding { para sensitive, widget, windowName, var, boxNumber; auto mouseName, keyName, mousePosName, mouseEnterName, mouseLeaveName, xCoord, yCoord; sensitive = int(sensitive); /* yuk - integerhonest hack [Ash] */ if (boxNumber > 0) { /* TEXT - have the boxNumber within the frame to deal with */ mouseName = "~"//windowName//"_mouse_"//str(boxNumber); keyName = "~"//windowName//"_key_"//str(boxNumber); mousePosName = "~"//windowName//"_mousePos_"//str(boxNumber); mouseEnterName = "~"//windowName//"_mouseEnter_"//str(boxNumber); mouseLeaveName = "~"//windowName//"_mouseLeave_"//str(boxNumber); xCoord = "%x"; yCoord = "%y"; } else { /* not TEXT - no boxNumber but must correct for window coordinate system */ mouseName = "~"//windowName//"_mouse"; keyName = "~"//windowName//"_key"; mousePosName = "~"//windowName//"_mousePos"; mouseEnterName = "~"//windowName//"_mouseEnter"; mouseLeaveName = "~"//windowName//"_mouseLeave"; xCoord = "[expr (%x-$"//var//"_xOrigin)/$"//var//"_xScale]"; yCoord = "[expr (%y-$"//var//"_yOrigin)/$"//var//"_yScale]"; } if (sensitive bitand ON) { /* the window is interested in mouse actions and key strokes */ xoutput("bind", widget, "