/* main.c: The main program for bc. */
/* This file is part of bc written for MINIX.
Copyright (C) 1991, 1992 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 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; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
You may contact the author by:
us-mail: Philip A. Nelson
Computer Science Department, 9062
Western Washington University
Bellingham, WA 98226-9062
*************************************************************************/
/* Variables for processing multiple files. */
/* The main program for bc. */
/* Initialize many variables. */
if (isatty(0) && isatty(1))
/* Parse the command line */
ch
= getopt (argc
, argv
, "lcisvw");
case 'c': /* compile only */
case 'i': /* force interactive */
case 'w': /* Non standard features give warnings. */
case 's': /* Non standard features give errors. */
case 'v': /* Print the version. */
printf ("%s\n", BC_VERSION
);
ch
= getopt (argc
, argv
, "lcisvw");
/* Initialize the machine. */
/* Set up interrupts to print a message. */
signal (SIGINT
, use_quit
);
/* Initialize the front end. */
/* End the compile only output with a newline. */
/* This is the function that opens all the files.
It returns TRUE if the file was opened, otherwise
/* Set the line number. */
/* Check to see if we are done. */
if (is_std_in
) return (FALSE
);
/* Open the other files. */
if (use_math
&& first_file
)
/* Make the first file be the math library. */
new_file
= fopen (BC_MATH_FILE
, "r");
fprintf (stderr
, "Math Library unavailable.\n");
/* Load the code from a precompiled version of the math libarary. */
/* These MUST be in the order of first mention of each function.
That is why "a" comes before "c" even though "a" is defined after
after "c". "a" is used in "s"! */
tmp
= lookup ("e", FUNCT
);
tmp
= lookup ("l", FUNCT
);
tmp
= lookup ("s", FUNCT
);
tmp
= lookup ("a", FUNCT
);
tmp
= lookup ("c", FUNCT
);
tmp
= lookup ("j", FUNCT
);
/* One of the argv values. */
new_file
= fopen (g_argv
[optind
], "r");
fprintf (stderr
, "File %s is unavailable.\n", g_argv
[optind
++]);
/* If we fall through to here, we should return stdin. */
/* Set yyin to the new file. */
if (!first_file
) fclose (yyin
);
/* Message to use quit. */
printf ("\n(interrupt) use quit to exit.\n");
signal (SIGINT
, use_quit
);