Import of GNU bc-1.03
This commit is contained in:
parent
1a7920257d
commit
5f1de942a7
@ -1,3 +1,188 @@
|
||||
Thu Nov 3 14:09:31 1994 Phil Nelson (phil@cs.wwu.edu)
|
||||
|
||||
* Makefile.in: added targets uninstall, installdirs and modified
|
||||
other targets to get makes in a directory other than srcdir to
|
||||
work.
|
||||
|
||||
* configure.in: added shell commands to get configure to work
|
||||
correctly in directories other than srcdir.
|
||||
|
||||
Wed Nov 2 10:18:19 1994 Phil Nelson (phil@cs.wwu.edu)
|
||||
|
||||
* bc.1 bc.y bcdefs.h const.h execute.c global.c global.h load.c
|
||||
main.c number.c number.h proto.h sbc.y scan.l storage.c util.c:
|
||||
updated copyright to 1994.
|
||||
|
||||
* version.h: updated version number and copyright date.
|
||||
|
||||
* Makefile.in, configure.in, Install: updated for use with
|
||||
autoconf-2.0 and install-sh. Changed target install a bit.
|
||||
|
||||
* install-sh: Included this file from the autoconf-2.0
|
||||
distribution to have configure run without errors.
|
||||
|
||||
* README: updated to version 1.03.
|
||||
|
||||
Mon Oct 31 10:26:28 1994 Phil Nelson (phil@cs.wwu.edu)
|
||||
|
||||
* Added Ken Pizzini's dc implementation that uses bc numeric
|
||||
routines. The following files have been added:
|
||||
dc-Concerns dc-array.c dc-eval.c dc-misc.c dc-number.c
|
||||
dc-proto.h dc-regdef.h dc-stack.c dc-string.c dc-version.h
|
||||
dc.1 dc.h dc.texinfo
|
||||
|
||||
* dc-array.c: Added a conditional include of stdlib.h to get
|
||||
size_t defined on my SunOS 4.1.3 system.
|
||||
|
||||
* configure.in: Added support for dc.
|
||||
|
||||
* Makefile.in: Added support for dc. Added rule to make
|
||||
config.h.in.
|
||||
|
||||
Sun Aug 7 15:09:19 1994 Phil Nelson (phil@cs.wwu.edu)
|
||||
|
||||
* configure.in, Makefile.in, acconfig.h: Add support for autoconf.
|
||||
Removed old Makefile.
|
||||
|
||||
Wed Jul 20 22:46:32 1994 Phil Nelson (phil@cs.wwu.edu)
|
||||
|
||||
* bc.y: change definition of next_label in function definition.
|
||||
Previous value of 0 caused break to not work. It is now 1.
|
||||
|
||||
Fri Apr 8 14:16:37 1994 Phil Nelson (phil@cs.wwu.edu)
|
||||
|
||||
* Makefile: Change the distribution to include libmath.h.dist
|
||||
which is a copy of libmath.h that has the compiled libmath.b.
|
||||
|
||||
Sun Feb 13 01:08:14 1994 Phil Nelson (phil@cs.wwu.edu)
|
||||
|
||||
* execute.c: Change the string quote characters to be more like
|
||||
C. \a => alert (bell) \b => backspace and added \q => ".
|
||||
|
||||
* bc.1: Updated information on above changes.
|
||||
|
||||
Wed Oct 27 23:34:40 1993 Phil Nelson (phil@cs.wwu.edu)
|
||||
|
||||
* Makefile: Changed compress to gzip. Changed the
|
||||
comment and definition of the DOT_IS_LAST compile option.
|
||||
|
||||
* scan.l: Changed DOT_IS_LAST to NO_DOT_LAST and changed
|
||||
the test so "." is the last variable is standard.
|
||||
|
||||
Wed May 19 15:15:12 1993 Phil Nelson (phil at cs.wwu.edu)
|
||||
|
||||
* number.c: Fixed output of negative numbers in bases other than
|
||||
base 10.
|
||||
|
||||
Wed Apr 21 11:56:31 1993 Phil Nelson (phil at cs.wwu.edu)
|
||||
|
||||
* bc.1: Changed Steve Sommars e-mail address.
|
||||
|
||||
Wed Apr 14 12:13:39 1993 Phil Nelson (phil at cs.wwu.edu)
|
||||
|
||||
* sbc.y: removed leading , on first line.
|
||||
|
||||
Wed Mar 31 16:12:39 1993 Phil Nelson (phil at cs.wwu.edu)
|
||||
|
||||
* bc.1: Updated segment number for function bodies.
|
||||
|
||||
Thu Mar 11 15:34:34 1993 Phil Nelson (phil at cs.wwu.edu)
|
||||
|
||||
* Makefile: added version.h to bc.o's dependency list.
|
||||
|
||||
Mon Mar 1 14:00:46 1993 Phil Nelson (phil at cs.wwu.edu)
|
||||
|
||||
* util.c: (nextarg) changed parameter "val" to be an int.
|
||||
|
||||
Tue Feb 16 10:06:45 1993 Phil Nelson (phil at cs.wwu.edu)
|
||||
|
||||
* util.c: (call_str, arg_str) added a function call_str that
|
||||
correctly produces the string of argmuent types for a function
|
||||
call. arg_str produced them in the reverse order. This
|
||||
eliminated the need for the "comma" argument to arg_str, which
|
||||
was removed.
|
||||
|
||||
* bc.y: changed the calls to arg_str to have only one parameter
|
||||
in the function definition rule and replaced the call to arg_str
|
||||
with call_str in the function call rule.
|
||||
|
||||
Tue Nov 24 17:38:40 1992 Phil Nelson (phil at cs.wwu.edu)
|
||||
|
||||
* Makefile: Added LEXLIB definitions for use with lex.
|
||||
|
||||
Thu Oct 22 13:43:16 1992 Phil Nelson (phil at cs.wwu.edu)
|
||||
|
||||
* number.c (bc_raise): Rearranged and added code to speed up
|
||||
the computation by not doing unneeded multiplications.
|
||||
|
||||
Wed Sep 30 10:43:52 1992 Phil Nelson (phil at cs.wwu.edu)
|
||||
|
||||
* global.h: Fixed documentation.
|
||||
|
||||
Tue Sep 29 15:27:50 1992 Phil Nelson (phil at cs.wwu.edu)
|
||||
|
||||
* storage.c (process_params): Changed processing of more arguments
|
||||
than in a function definition to just a return.
|
||||
|
||||
* Makefile: Made changes to make it more in conformance with the
|
||||
GNU coding standards.
|
||||
|
||||
Tue Jul 7 21:09:07 1992 Phil Nelson (phil at cs.wwu.edu)
|
||||
|
||||
* (const.h, bc.y, util.c) Added code so that when the math
|
||||
library is loaded, redefinition of any math library function
|
||||
will not cause the other functions to quit working correctly.
|
||||
Before this change, redefining a(x) would cause s(x) and c(x)
|
||||
to quit working and redefining s(x) would cause c(x) to quit
|
||||
working.
|
||||
|
||||
Wed Jul 1 14:35:29 1992 Phil Nelson (phil at cs.wwu.edu)
|
||||
|
||||
* (libmath.b) Changed the calculation of scale for computing
|
||||
e(x) and l(x). This provides a little more accuracy in the
|
||||
last digit at the expense of a little speed.
|
||||
|
||||
* (Test/checklib.b) Changed tests to be parameterized and test
|
||||
more values.
|
||||
|
||||
Thu Jun 25 09:22:59 1992 Phil Nelson (phil at cs.wwu.edu)
|
||||
|
||||
* (configure) changed the script from looking in the
|
||||
include directory for a .h file to asking cc (gcc) to
|
||||
find the .h file. This will allow better detection
|
||||
of include files available to the C compiler.
|
||||
|
||||
Wed Jun 24 22:11:37 1992 Phil Nelson (phil at cs.wwu.edu)
|
||||
|
||||
* (bc.y) Added a warning for the "last" variable.
|
||||
|
||||
* (scan.l) Added code to allow for a single dot (.) to be the
|
||||
same as the variable "last". This is not a "standard" feature,
|
||||
but is provided for those who want it.
|
||||
|
||||
* (Install) Documented the new define for dot (.).
|
||||
|
||||
* (bc.1) Documented the use of dot (.) for "last".
|
||||
|
||||
* (Makefile) Added an easy method for adding extra defines for
|
||||
use during the compile. Set DOT_IS_LAST as a standard
|
||||
extra define.
|
||||
|
||||
* (number.c) Changed the code for sqrt for better speed.
|
||||
|
||||
Mon Jun 22 21:47:05 1992 Phil Nelson (phil at cs.wwu.edu)
|
||||
|
||||
* Changed the name of math.h to libmath.h to avoid conflict
|
||||
with /usr/include/math.h. Changed all references to math.h
|
||||
to libmath.h in all files.
|
||||
|
||||
* (configure) Changed the test for long strings accepted by
|
||||
cc to not include libmath.h and thus not need to distribute
|
||||
a file that is generated by the system.
|
||||
|
||||
* (Makefile) Changed PREFIX, BINDIR, LIBDIR, and MANDIR to
|
||||
lower case.
|
||||
|
||||
Tue Mar 3 10:16:07 1992 Phil Nelson (phil at cs.wwu.edu)
|
||||
|
||||
* (main.c) Added missing } at line 140.
|
||||
|
53
gnu/usr.bin/bc/Examples/pi.b
Normal file
53
gnu/usr.bin/bc/Examples/pi.b
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
This is a program to determine the distribution of digits in the
|
||||
fraction part of PI. It will look at the first scale digits.
|
||||
|
||||
The results are left in the global variable digits.
|
||||
digits[0] is the number of 0's in PI.
|
||||
|
||||
This program requires the math library.
|
||||
*/
|
||||
|
||||
define pi () {
|
||||
auto ix, pi, save_scale, work;
|
||||
|
||||
save_scale = scale;
|
||||
scale += 5;
|
||||
print "\n\nCalculating PI to ",scale," digits. Please wait . . .";
|
||||
pi = 4*a(1);
|
||||
scale -= 5;
|
||||
work = pi;
|
||||
|
||||
print "\nCounting digits. . .";
|
||||
for (ix = 0; ix < 10; ix++) digits[ix] = 0;
|
||||
|
||||
/* Extract the One's digit from pi. */
|
||||
scale = 0;
|
||||
one_digit = work / 1;
|
||||
|
||||
for (ix = save_scale; ix > 0; ix--) {
|
||||
|
||||
/* Remove the One's digit and multiply by 10. */
|
||||
scale = ix;
|
||||
work = (work - one_digit) / 1 * 10;
|
||||
|
||||
/* Extract the One's digit. */
|
||||
scale = 0;
|
||||
one_digit = work / 1;
|
||||
|
||||
digits[one_digit] += 1;
|
||||
}
|
||||
|
||||
/* Restore the scale. */
|
||||
scale = save_scale;
|
||||
|
||||
/* Report. */
|
||||
print "\n\n"
|
||||
print "PI to ", scale, " digits is:\n", pi/1, "\n\n"
|
||||
print "The frequency of the digits are:\n"
|
||||
for (ix = 0; ix < 10; ix++) {
|
||||
print " ", ix, " - ", digits[ix], " times\n"
|
||||
}
|
||||
|
||||
print "\n\n"
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
/* An example that finds all primes between 2 and limit. */
|
||||
|
||||
define primes (limit) {
|
||||
auto prime[], num, p, root, i
|
||||
auto num, p, root, i
|
||||
|
||||
prime[1] = 2;
|
||||
prime[2] = 3;
|
||||
|
40
gnu/usr.bin/bc/Examples/twins.b
Normal file
40
gnu/usr.bin/bc/Examples/twins.b
Normal file
@ -0,0 +1,40 @@
|
||||
|
||||
/* An example that finds all primes between 2 and limit. */
|
||||
|
||||
define primes (limit) {
|
||||
auto num, p, root, i
|
||||
|
||||
prime[1] = 2;
|
||||
prime[2] = 3;
|
||||
num = 2;
|
||||
scale = 0;
|
||||
|
||||
for ( p=5; p <= limit; p += 2) {
|
||||
root = sqrt(p);
|
||||
isprime = 1;
|
||||
for ( i = 1; i < num && prime[i] <= root; i++ ) {
|
||||
if ( p % prime[i] == 0 ) {
|
||||
isprime = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isprime) {
|
||||
num += 1;
|
||||
prime [num] = p;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
print "\ntyping 'twins (10)' will print all twin primes less than 10.\n"
|
||||
|
||||
define twins (limit) {
|
||||
auto i;
|
||||
|
||||
i = primes(limit+2);
|
||||
|
||||
for (i=1; prime[i] > 0; i++) {
|
||||
if ((prime[i]+2) == prime[i+1]) \
|
||||
print "twins are ", prime[i], " and ", prime[i+1], "\n"
|
||||
}
|
||||
}
|
@ -1,80 +1,46 @@
|
||||
|
||||
INSTALLATION
|
||||
------------
|
||||
INSTALLATION for GNU bc version 1.03 (Including GNU dc.)
|
||||
---------------------------------------------------------
|
||||
|
||||
a) Make sure you have a working vsprintf and vfprintf in your library.
|
||||
(If your system does not have them in your library, you can get
|
||||
a copy of the BSD4.3-tahoe stdio that is freely copyable. It
|
||||
is available from uunet.uu.net. For Minix systems, a vsprintf.c
|
||||
is included.)
|
||||
one of several stdio packages that are freely copyable. The GNU
|
||||
libc has a complete stdio package. For Minix 1.5 systems,
|
||||
a vsprintf.c is included.)
|
||||
|
||||
b) EDIT the Makefile for the correct definitions. Read the comments in
|
||||
the the Makefile and make the changes needed. (A "full" explanation
|
||||
of all the C defines are given at the end of this file.) If your are
|
||||
on a MINIX machine, make sure the correct definitions for $O, $CFLAGS,
|
||||
and $LDFLAGS are uncommented in the makefile.
|
||||
NOTE: "configure" is a shell scritp that is automatically run by make
|
||||
to configure the bc source to your operating system. You should still
|
||||
look at the Makefile.
|
||||
b) run "configure" with the "standard" options for a configure of gnu
|
||||
products. The major parameter for bc is the "--prefix=path"
|
||||
option to find the executable and manual directories. For more help,
|
||||
give the command "configure --help".
|
||||
|
||||
d) "make derived" (If you need it.)
|
||||
c) "make derived" (If you need it.)
|
||||
The distribution contains the files bc.c.dist y.tab.h.dist and
|
||||
scan.c.dist. These are provided so that you do not need a working
|
||||
yacc and flex (lex). This program was designed to work with the free
|
||||
programs byacc (berkeley yacc) and flex. It should work with other
|
||||
versions of yacc and lex, but it is not guaranteed to work.
|
||||
|
||||
If you do not have yacc or flex, give the command to get the *.dist
|
||||
files to their proper place. This insures that make will not try
|
||||
to make these derived files from their original source. Use the
|
||||
"make derived" before trying to compile bc.
|
||||
If you do not have yacc or flex, give the command "make derived" to
|
||||
get the *.dist files to their proper place. This insures that make
|
||||
will not try to make these derived files from their original source.
|
||||
Use the "make derived" before trying to compile bc and dc.
|
||||
|
||||
e) "make"
|
||||
compiles bc
|
||||
compiles bc and dc.
|
||||
|
||||
f) "make install"
|
||||
installs bc and libmath.b (if needed) in their directories.
|
||||
installs bc, dc, libmath.b (if needed), bc.1, dc.1 and dc.info
|
||||
in their proper directories.
|
||||
|
||||
g) Use bc!
|
||||
g) Use bc and dc!
|
||||
|
||||
|
||||
DEFINES
|
||||
-------
|
||||
|
||||
The following the are some defines that are automatically generated
|
||||
by the configure script. In most cases, you do not need to deal
|
||||
with them. The configure script is automatically run by make.
|
||||
|
||||
BC_MATH_FILE=$(LIBFILE)
|
||||
This defines the location of the math library file. If you
|
||||
use this definition, the math library is read from LIBFILE.
|
||||
If you do not define this, bc will include a "compiled" form
|
||||
of the math library with the executable and will not need to
|
||||
read any external file if the -l flag is given.
|
||||
|
||||
VARARGS
|
||||
The variable args mechanism is assumed to be ANSI stdarg.
|
||||
Use -DVARARGS for Ultrix, SUN-OS, BSD, and other UNIX versions that
|
||||
use traditional varargs,
|
||||
For MINIX and ANSI compilers (gcc et al) do NOT use -DVARARGS.
|
||||
|
||||
NO_LIMITS
|
||||
Use this for systems without the /usr/include/limits.h file.
|
||||
(BSD4.3 is one.) You should check the values of INT_MAX and
|
||||
LONG_MAX in the file const.h if you use -DNO_LIMITS.
|
||||
|
||||
NO_UNISTD
|
||||
Use this for systems without /usr/include/unistd.h.
|
||||
|
||||
-DNO_STDLIB
|
||||
Use this for systems without /usr/include/stdlib.h.
|
||||
|
||||
STRINGS_H
|
||||
Include the file <strings.h> instead of <string.h>.
|
||||
|
||||
|
||||
The following defines may need to be added by hand to the Makefile if
|
||||
you want them. They are not generated by the configure script.
|
||||
The following defines you may or may not want. To delete one standardly on,
|
||||
edit the Makefile.in. If you want add their definitions, put their
|
||||
definition in an environment variable "CFLAGS" for the configure script.
|
||||
|
||||
-DOLD_EQ_OP
|
||||
Causes bc to recognize =<op> as the same as <op>=. The =<op> is
|
||||
@ -82,15 +48,18 @@ DEFINES
|
||||
it is equivalent to "a -= 1" and with OLD_EQ_OP undefined it is
|
||||
equivalent to "a = -1".
|
||||
|
||||
-DDOT_IS_LAST
|
||||
Causes bc to recognize a single period (".") as a shorthand notation
|
||||
for the standard variable "last". (This is standardly defined.)
|
||||
|
||||
-DSMALL_BUF
|
||||
Use this IF you are using flex AND you have a systems with limited
|
||||
memory space. If you use this, you should also use -DBC_MATH_FILE.
|
||||
This is "standard" for MINIX systems running on the IBM_PC.
|
||||
memory space.
|
||||
|
||||
-DSHORTNAMES
|
||||
If your compiler keeps a limited number of characters from names,
|
||||
you should include this define. It is needed for the K&R compiler
|
||||
on MINIX and is automatically added for MINIX on the IBM_PC.
|
||||
on MINIX.
|
||||
|
||||
-DDEBUG=n
|
||||
Compile the debugging code. The higher the number, the more
|
||||
@ -105,3 +74,12 @@ POSSIBLE PROBLEMS
|
||||
definitions of malloc and free. Others should compile with the
|
||||
correct set of defines.
|
||||
|
||||
Hopefully, the autoconf/configure system should remove all problems.
|
||||
|
||||
If you do a "make realclean", it removes all files that can be derived
|
||||
from some other files. This also removes the file "libmath.h" that
|
||||
is used by the configure script. Without it there, the configure
|
||||
script makes wrong assumptions about the abilities of your compiler.
|
||||
To get things back to the point where configure works well you will
|
||||
need to "make libmath.h", "make distclean" and then run configure again.
|
||||
|
||||
|
314
gnu/usr.bin/bc/Makefile.in
Normal file
314
gnu/usr.bin/bc/Makefile.in
Normal file
@ -0,0 +1,314 @@
|
||||
# Makefile for GNU bc and dc. -*- Indented-Text -*-
|
||||
# Copyright (C) 1993, 1994 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., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
# @configure_input@
|
||||
|
||||
#### Start of system configuration section. ####
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
bindir = $(exec_prefix)/bin
|
||||
datadir = $(prefix)/lib
|
||||
libdir = $(prefix)/lib
|
||||
infodir = $(prefix)/info
|
||||
|
||||
# Where to install the manual pages.
|
||||
mandir = $(prefix)/man/man1
|
||||
# Extension (not including `.') for the installed manual page filenames.
|
||||
manext = 1
|
||||
|
||||
#
|
||||
# This is the name of the library file, if needed. This definition should
|
||||
# not be deleted.
|
||||
#
|
||||
LIBFILE = $(libdir)/libmath.b
|
||||
|
||||
#
|
||||
# Programs definitions for use by make.
|
||||
#
|
||||
|
||||
SHELL = /bin/sh
|
||||
YACC = @YACC@
|
||||
LEX = @LEX@
|
||||
CC = @CC@
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
|
||||
UUENCODE = uue
|
||||
|
||||
LIBS = @LIBS@ @LEXLIB@
|
||||
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
|
||||
MAKEINFO = makeinfo
|
||||
TEXI2DVI = texi2dvi
|
||||
|
||||
# stuff for cflags
|
||||
|
||||
STDDEFS = -D_POSIX_SOURCE -DDOT_IS_LAST
|
||||
INCDIR = -I. -I$(srcdir)
|
||||
|
||||
#
|
||||
# The following are the standard definitions. For MINIX PC, you need to
|
||||
# comment these out and select one of the MINIX PC definition sets.
|
||||
# Other configuration defines are generated automatically. See the
|
||||
# README file for more details.
|
||||
#
|
||||
O=o
|
||||
CFLAGS = -O $(INCDIR) $(STDDEFS) @CFLAGS@
|
||||
LDFLAGS =
|
||||
#
|
||||
# For the PC version of MINIX (K&R compiler), use the following lines.
|
||||
#
|
||||
#O=s
|
||||
#CFLAGS = -O $(INCDIR) $(STDDEFS) @CFLAGS@
|
||||
#LDFLAGS = -i
|
||||
#
|
||||
# For the PC version of MINIX (ANSI compiler), use the following lines:
|
||||
#
|
||||
#O=o
|
||||
#CFLAGS = -m $(INCDIR) $(STDDEFS) @CFLAGS@
|
||||
#LDFLAGS = -i
|
||||
#
|
||||
#
|
||||
DISTFILES = COPYING Makefile.in Install bc.y bcdefs.h const.h version.h \
|
||||
execute.c global.c global.h load.c main.c number.c storage.c \
|
||||
number.h proto.h scan.l util.c vfprintf.c README bc.1 sbc.y \
|
||||
fix_libmath.h libmath.b configure configure.in config.h.in \
|
||||
acconfig.h ChangeLog \
|
||||
dc.1 dc.texinfo \
|
||||
dc-array.c dc-eval.c dc-misc.c dc-number.c dc-stack.c \
|
||||
dc-string.c dc.h dc-proto.h dc-regdef.h dc-version.h \
|
||||
install-sh
|
||||
#
|
||||
BCOFILES = scan.$O util.$O main.$O number.$O storage.$O load.$O execute.$O
|
||||
DCOFILES = dc-misc.$O dc-eval.$O dc-stack.$O dc-array.$O dc-string.$O \
|
||||
dc-number.$O
|
||||
#
|
||||
SUBDIRS = Examples Test
|
||||
#
|
||||
EXTRAFILES = bc.c.dist scan.c.dist y.tab.h.dist libmath.h dc.info
|
||||
#
|
||||
|
||||
all: bc dc dc.info
|
||||
|
||||
### targets required by GNU Coding standards ###
|
||||
|
||||
Makefile: Makefile.in config.status
|
||||
./config.status
|
||||
|
||||
#config.status: configure
|
||||
# $(srcdir)/configure --srcdir=$(srcdir) --no-create
|
||||
#
|
||||
#configure: configure.in
|
||||
# cd $(srcdir); autoconf
|
||||
|
||||
bc: $& config.h bc.$O $(BCOFILES) global.$O
|
||||
$(CC) $(LDFLAGS) -o bc bc.$O $(BCOFILES) global.$O $(LIBS)
|
||||
|
||||
dc: $(DCOFILES) number.o
|
||||
$(CC) $(LDFLAGS) -o dc $(DCOFILES) number.o $(LIBS)
|
||||
|
||||
sbc: sbc.$O $(BCOFILES) global.$O
|
||||
$(CC) -o sbc $(LDFLAGS) sbc.$O $(BCOFILES) global.$O $(LIBS)
|
||||
|
||||
config.h.in:
|
||||
autoheader
|
||||
|
||||
config.h: config.h.in configure
|
||||
./configure
|
||||
|
||||
libmath.h: libmath.b
|
||||
$(MAKE) fbc
|
||||
./fbc -c libmath.b </dev/null >libmath.h
|
||||
./fix_libmath.h
|
||||
rm -f ./fbc
|
||||
|
||||
fbc: $(BCOFILES) bc.$O
|
||||
echo \"\" > libmath.h
|
||||
$(CC) -c $(CFLAGS) global.c
|
||||
$(CC) -o fbc $(LDFLAGS) bc.$O $(BCOFILES) global.$O $(LEXLIB)
|
||||
|
||||
install: installdirs bc libmath.b config.h
|
||||
rm -f $(bindir)/bc $(bindir)/dc
|
||||
$(INSTALL_PROGRAM) bc $(bindir)
|
||||
$(INSTALL_PROGRAM) dc $(bindir)
|
||||
chmod 555 $(bindir)/bc $(bindir)/dc
|
||||
if grep -s "define BC_MATH_FILE" config.h; \
|
||||
then rm -f $(libdir)/libmath.b; \
|
||||
$(INSTALL_DATA) $(srcdir)/libmath.b $(libdir); \
|
||||
chmod 444 $(libdir)/libmath.b; \
|
||||
else true; \
|
||||
fi
|
||||
$(INSTALL_DATA) $(srcdir)/bc.1 $(mandir)
|
||||
$(INSTALL_DATA) $(srcdir)/dc.1 $(mandir)
|
||||
$(INSTALL_DATA) $(srcdir)/dc.info $(infodir)
|
||||
|
||||
installdirs:
|
||||
-mkdir $(prefix)
|
||||
-mkdir $(bindir)
|
||||
-if grep -s "define BC_MATH_FILE" config.h; \
|
||||
then mkdir $(libdir)
|
||||
else true; \
|
||||
fi
|
||||
-mkdir $(mandir)
|
||||
-mkdir $(infodir)
|
||||
|
||||
uninstall:
|
||||
rm -f $(bindir)/bc $(bindir)/dc
|
||||
if grep -s "define BC_MATH_FILE" config.h; \
|
||||
then rm -f $(libdir)/libmath.b;
|
||||
else true; \
|
||||
fi
|
||||
rm -f $(mandir)/bc1 $(mandir)/dc.1
|
||||
rm -f $(infodir)/dc.info
|
||||
|
||||
dist: $(EXTRAFILES)
|
||||
OF=`sed -n 's/.*\([0-9][0-9]*\.[0-9][0-9]*\).*/bc-\1/p' version.h` \
|
||||
; rm -rf $$OF \
|
||||
; mkdir $$OF \
|
||||
; chmod 777 $$OF \
|
||||
; for file in $(DISTFILES) ; do ln $(srcdir)/$$file $$OF/$$file; done \
|
||||
; for file in $(EXTRAFILES) ; do ln $$file $$OF/$$file; done \
|
||||
; for dir in $(SUBDIRS); do \
|
||||
mkdir $$OF/$$dir ; chmod 777 $$OF/$$dir ; \
|
||||
cp $(srcdir)/$$dir/* $$OF/$$dir; done \
|
||||
; tar cf $$OF.tar $$OF \
|
||||
; gzip $$OF.tar \
|
||||
; rm -rf $$OF
|
||||
|
||||
shars: dist
|
||||
OF=`sed -n 's/.*\([0-9][0-9]*\.[0-9][0-9]*\).*/bc-\1/p' version.h` \
|
||||
; $(UUENCODE) $$OF.tar.Z - > $$OF.uue \
|
||||
; split -775 $$OF.uue $$OF-u. \
|
||||
; for file in $$OF-u.a?; do shar $$file > $$file.sh; done
|
||||
|
||||
minixdist: $(EXTRAFILES)
|
||||
OF=`sed -n 's/.*\([0-9][0-9]*\.[0-9][0-9]*\).*/bc-\1/p' version.h` \
|
||||
; rm -rf $$OF \
|
||||
; mkdir $$OF \
|
||||
; cd $$OF \
|
||||
; for file in $(DISTFILES) $(EXTRAFILES); do ln ../$$file; done \
|
||||
; cd .. \
|
||||
; tar cf $$OF.tar $$OF \
|
||||
; gzip $$OF.tar \
|
||||
; rm -rf $$OF
|
||||
|
||||
minixshars: minixdist
|
||||
OF=`sed -n 's/.*\([0-9][0-9]*\.[0-9][0-9]*\).*/bc-\1/p' version.h` \
|
||||
; $(UUENCODE) $$OF.tar.Z - > $$OF.uue \
|
||||
; split -775 $$OF.uue $$OF-u. \
|
||||
; for file in $$OF-u.a?; do shar $$file > $$file.sh; done
|
||||
|
||||
csrshars: $(EXTRAFILES)
|
||||
findsrc -dy $(DISTFILES) $(EXTRAFILES) $(SUBDIRS) | \
|
||||
makekit -npart -oMANIFEST
|
||||
|
||||
bc.c.dist: bc.c
|
||||
cp bc.c bc.c.dist
|
||||
|
||||
scan.c.dist: scan.c
|
||||
cp scan.c scan.c.dist
|
||||
|
||||
y.tab.h.dist: y.tab.h
|
||||
cp y.tab.h y.tab.h.dist
|
||||
|
||||
extra: $(EXTRAFILES)
|
||||
|
||||
# assumes that the extra files exist!
|
||||
derived:
|
||||
@if [ ! -f $(srcdir)/bc.c.dist ] ; then \
|
||||
echo "You do not have a complete distribution. Get a new copy or"; \
|
||||
echo "see if you can make the derived files using lex and yacc."; \
|
||||
exit 1; \
|
||||
fi
|
||||
cp $(srcdir)/bc.c.dist bc.c
|
||||
cp $(srcdir)/scan.c.dist scan.c
|
||||
cp $(srcdir)/y.tab.h.dist y.tab.h
|
||||
|
||||
clean:
|
||||
rm -f *.$O core ERRS *~ *.bak *.Z
|
||||
|
||||
distclean: clean
|
||||
rm -f scan.c y.tab.h bc.c sbc.c bc sbc bc-dist* config.h bc-*.* \
|
||||
dc part?? MANIFEST* config.h config.status config.log config.cache \
|
||||
Makefile *.aux *.cp *.dvi *.fn *.ky *.log *.pg *.toc *.tp *.vr
|
||||
|
||||
mostlyclean: distclean
|
||||
|
||||
realclean: distclean
|
||||
rm -rf *.dist configure libmath.h dc.info config.h.in
|
||||
|
||||
scan.c: scan.l
|
||||
$(LEX) scan.l
|
||||
mv lex.yy.c scan.c
|
||||
|
||||
y.tab.h bc.c: bc.y
|
||||
@echo "expect 1 shift/reduce conflict"
|
||||
$(YACC) -d bc.y
|
||||
mv y.tab.c bc.c
|
||||
|
||||
sbc.c: sbc.y
|
||||
$(YACC) -d sbc.y
|
||||
mv y.tab.c sbc.c
|
||||
|
||||
# Information files
|
||||
info: dc.info
|
||||
dvi: dc.dvi
|
||||
|
||||
#bc.info: bc.texinfo
|
||||
# $(MAKEINFO) -I$(srcdir) --no-split bc.texinfo
|
||||
#
|
||||
#bc.dvi: bc.texinfo
|
||||
# $(TEXI2DVI) $(srcdir)/bc.texinfo
|
||||
|
||||
dc.info: dc.texinfo
|
||||
$(MAKEINFO) -I$(srcdir) --no-split dc.texinfo
|
||||
|
||||
dc.dvi: dc.texinfo
|
||||
$(TEXI2DVI) $(srcdir)/dc.texinfo
|
||||
|
||||
|
||||
global.$O: bcdefs.h global.h libmath.h global.c
|
||||
bc.$O: bcdefs.h global.h bc.y
|
||||
execute.$O: bcdefs.h global.h execute.c
|
||||
load.$O: bcdefs.h global.h load.c
|
||||
main.$O: bcdefs.h global.h version.h main.c
|
||||
number.$O: bcdefs.h Makefile number.c
|
||||
sbc.$O: bcdefs.h global.h sbc.y
|
||||
scan.$O: bcdefs.h global.h y.tab.h scan.c
|
||||
storage.$O: bcdefs.h global.h storage.c
|
||||
util.$O: bcdefs.h global.h version.h util.c
|
||||
|
||||
bcdefs.h: number.h const.h config.h
|
||||
touch bcdefs.h
|
||||
|
||||
dc-array.$O : dc-array.c config.h dc.h dc-proto.h dc-regdef.h
|
||||
dc-eval.$O : dc-eval.c config.h dc.h dc-proto.h
|
||||
dc-misc.$O : dc-misc.c config.h dc.h dc-proto.h dc-version.h
|
||||
dc-number.$O : dc-number.c config.h bcdefs.h const.h version.h number.h \
|
||||
proto.h global.h dc.h dc-proto.h
|
||||
dc-stack.$O : dc-stack.c config.h dc.h dc-proto.h dc-regdef.h
|
||||
dc-string.$O : dc-string.c config.h dc.h dc-proto.h
|
||||
number.$O : number.c bcdefs.h config.h const.h version.h number.h proto.h
|
@ -1,10 +1,26 @@
|
||||
Program: GNU bc
|
||||
Author: Philip A. Nelson
|
||||
E-mail: phil@cs.wwu.edu
|
||||
OS: UNIX (BSD, System V, MINIX, POSIX)
|
||||
Copying: GNU GPL version 2
|
||||
Copyright holder: Free Software Foundation, Inc.
|
||||
Version: bc version 1.01
|
||||
This is GNU bc version 1.03.
|
||||
|
||||
Changes from 1.02
|
||||
|
||||
minor bug fixes in bc.
|
||||
|
||||
addition of Ken Pizzini's dc program that uses the GNU bc
|
||||
arbitrary precision arithmetic routines.
|
||||
|
||||
Changes from 1.01
|
||||
|
||||
minor bug fixes.
|
||||
|
||||
|
||||
-------- Original comp.sources.reviewed README --------
|
||||
|
||||
Program: GNU bc
|
||||
Author: Philip A. Nelson
|
||||
E-mail: phil@cs.wwu.edu
|
||||
OS: UNIX (BSD, System V, MINIX, POSIX)
|
||||
Copying: GNU GPL version 2
|
||||
Copyright holder: Free Software Foundation, Inc.
|
||||
Version: bc version 1.01
|
||||
Required: vsprintf and vfprintf routines.
|
||||
Machines: It has been compiled and run on the following environments:
|
||||
BSD4.3 (VAX 11)
|
||||
@ -20,7 +36,7 @@ Machines: It has been compiled and run on the following environments:
|
||||
bc is an arbitrary precision numeric processing language. Syntax is
|
||||
similar to C, but differs in many substantial areas. It supports
|
||||
interactive execution of statements. bc is a utility included in the
|
||||
POSIX P1003.2/D11 draft standard.
|
||||
POSIX P1003.2/D11 draft standard.
|
||||
|
||||
This version was written to be a POSIX compliant bc processor with
|
||||
several extensions to the draft standard. Option flags are available
|
||||
|
8
gnu/usr.bin/bc/README.NetBSD
Normal file
8
gnu/usr.bin/bc/README.NetBSD
Normal file
@ -0,0 +1,8 @@
|
||||
This is GNU bc 1.03.
|
||||
|
||||
The original GNU distribution included GNU dc in the same distribution.
|
||||
GNU dc part is found in the NetBSD source tree in /usr/src/gnu/usr.bin/dc.
|
||||
|
||||
With all the files located in the bc and dc directories, an "original"
|
||||
bc-1.03 distribution could be regenerated. (It require GNU autoconf 2.0.)
|
||||
|
40
gnu/usr.bin/bc/Test/BUG.bc
Normal file
40
gnu/usr.bin/bc/Test/BUG.bc
Normal file
@ -0,0 +1,40 @@
|
||||
/* <--- bug.bc ---><--- bug.bc ---><--- bug.bc ---><--- bug.bc ---> */
|
||||
|
||||
/*
|
||||
* See the file "signum" for a description and reference for this
|
||||
* program.
|
||||
*
|
||||
* THIS BUG IS *NOT* IN GNU BC!!!
|
||||
*
|
||||
*/
|
||||
|
||||
obase=16
|
||||
ibase=16
|
||||
x=1A8F5C99605AE52 /* dividend */
|
||||
y=BB0B404 /* divisor */
|
||||
q=245A07AD /* (correct) quotient */
|
||||
r=147EB9E /* (correct) remainder */
|
||||
"Base 16
|
||||
"
|
||||
"x = "; x /* output numbers just to be sure... */
|
||||
"y = "; y
|
||||
"quo = "; q
|
||||
"rem = "; r
|
||||
"x/y = "; x/y /* watch this result! */
|
||||
"x%y = "; x%y /* watch this result! */
|
||||
"y*q+r= "; y*q+r /* check quotient & remainder */
|
||||
/*
|
||||
* Do the same thing in base 10:
|
||||
*/
|
||||
"
|
||||
Base 10
|
||||
"
|
||||
ibase=A
|
||||
obase=10
|
||||
"x = "; x /* output numbers just to be sure... */
|
||||
"y = "; y
|
||||
"q = "; q
|
||||
"r = "; r
|
||||
"x/y = "; x/y /* watch this result! */
|
||||
"x%y = "; x%y /* watch this result! */
|
||||
"y*q+r= "; y*q+r /* check quotient & remainder */
|
@ -1,3 +1,5 @@
|
||||
for (a=0; a<100; a++) x=a(a)
|
||||
for (a=0; a<1000; a+=2) x=a(a)
|
||||
x
|
||||
for (a=0; a<2; a+=.01) x=a(a)
|
||||
x
|
||||
quit
|
||||
|
@ -36,74 +36,74 @@ Percent failed: "; scale = 2; c*100/b;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
b = begining scale value,
|
||||
l = limit scale value,
|
||||
i = increment scale value.
|
||||
|
||||
if b is set to a non-zero value before this file is executed,
|
||||
b, l and i are not reset.
|
||||
*/
|
||||
|
||||
if (b == 0) { b = 10; l = 61; i = 10; }
|
||||
|
||||
"
|
||||
Checking e(x)"
|
||||
define f(x) {
|
||||
return (e(x))
|
||||
}
|
||||
for (s=10; s<l; s=s+i) {
|
||||
"
|
||||
scale = 10"
|
||||
j = t(-50,50,1,10,14)
|
||||
"
|
||||
scale = 20"
|
||||
j = t(-50,50,1,20,24)
|
||||
scale = "; s
|
||||
j = t(0,200,1,s,s+4)
|
||||
}
|
||||
|
||||
"
|
||||
Checking l(x)"
|
||||
define f(x) {
|
||||
return (l(x))
|
||||
}
|
||||
for (s=10; s<l; s=s+i) {
|
||||
"
|
||||
scale = 10"
|
||||
j = t(1,10000,100,10,14)
|
||||
"
|
||||
scale = 20"
|
||||
j = t(1,10000,100,20,24)
|
||||
scale = "; s
|
||||
j = t(1,10000,25,s,s+4)
|
||||
}
|
||||
|
||||
"
|
||||
Checking s(x)"
|
||||
define f(x) {
|
||||
return (s(x))
|
||||
}
|
||||
for (s=10; s<l; s=s+i) {
|
||||
"
|
||||
scale = 10"
|
||||
j = t(0,8*a(1),.01,10,14)
|
||||
"
|
||||
scale = 20"
|
||||
j = t(1,8*a(1),.01,20,24)
|
||||
scale = "; s
|
||||
j = t(0,8*a(1),.01,s,s+4)
|
||||
}
|
||||
|
||||
"
|
||||
Checking a(x)"
|
||||
define f(x) {
|
||||
return (a(x))
|
||||
}
|
||||
for (s=10; s<l; s=s+i) {
|
||||
"
|
||||
scale = 10"
|
||||
j = t(-100,100,1,10,14)
|
||||
"
|
||||
scale = 20"
|
||||
j = t(-100,100,1,20,24)
|
||||
scale = "; s
|
||||
j = t(-1000,1000,10,s,s+4)
|
||||
}
|
||||
|
||||
"
|
||||
Checking j(n,x)"
|
||||
define f(x) {
|
||||
return (j(n,x))
|
||||
}
|
||||
for (s=10; s<l; s=s+i) {
|
||||
"
|
||||
n=0, scale=10"
|
||||
n=0, scale = "; s
|
||||
n=0
|
||||
j = t(0,30,.1,10,14)
|
||||
j = t(0,30,.1,s,s+4)
|
||||
"
|
||||
n=1, scale=10"
|
||||
n=1, scale = "; s
|
||||
n=1
|
||||
j = t(0,30,.1,10,14)
|
||||
"
|
||||
n=0, scale=20"
|
||||
n=0
|
||||
j = t(0,30,.1,20,24)
|
||||
"
|
||||
n=1, scale=20"
|
||||
n=1
|
||||
j = t(0,30,.1,20,24)
|
||||
j = t(0,30,.1,s,s+4)
|
||||
}
|
||||
|
||||
|
87
gnu/usr.bin/bc/Test/signum
Normal file
87
gnu/usr.bin/bc/Test/signum
Normal file
@ -0,0 +1,87 @@
|
||||
|
||||
|
||||
|
||||
/* From gnu@cygnus.com Wed Jul 14 13:46:44 1993
|
||||
Return-Path: <gnu@cygnus.com>
|
||||
To: phil@cs.wwu.edu, gnu@cygnus.com
|
||||
Subject: bc/dc - no rest for the wicked
|
||||
Date: Tue, 06 Jul 93 19:12:40 -0700
|
||||
From: gnu@cygnus.com
|
||||
|
||||
GNU bc 1.02 passes all these tests. Can you add the test to the distribution?
|
||||
Putting it into a DejaGnu test case for GNU bc would be a great thing, too.
|
||||
(I haven't seen the Signum paper, maybe you can dig it out.)
|
||||
|
||||
John Gilmore
|
||||
Cygnus Support
|
||||
|
||||
------- Forwarded Message
|
||||
|
||||
Date: Tue, 6 Jul 93 08:45:48 PDT
|
||||
From: uunet!Eng.Sun.COM!David.Hough@uunet.UU.NET (David Hough)
|
||||
Message-Id: <9307061545.AA14477@dgh.Eng.Sun.COM>
|
||||
To: numeric-interest@validgh.com
|
||||
Subject: bc/dc - no rest for the wicked
|
||||
|
||||
Steve Sommars sent me a bc script which reproduces ALL the test cases from
|
||||
Dittmer's paper. Neither SunOS 5.2 on SPARC nor 5.1 on x86 come out clean.
|
||||
Anybody else who has fixed all the bugs would be justified in
|
||||
bragging about it here. */
|
||||
|
||||
|
||||
/*Ingo Dittmer, ACM Signum, April 1993, page 8-11*/
|
||||
define g(x,y,z){
|
||||
auto a
|
||||
a=x%y
|
||||
if(a!=z){
|
||||
"
|
||||
x=";x
|
||||
"y=";y
|
||||
"Should be ";z
|
||||
"was ";a
|
||||
}
|
||||
}
|
||||
|
||||
/*Table 1*/
|
||||
g=g(53894380494284,9980035577,2188378484)
|
||||
g=g(47907874973121,9980035577,3704203521)
|
||||
g=g(76850276401922,9980035577,4002459022)
|
||||
g=g(85830854846664,9980035577,2548884464)
|
||||
g=g(43915353970066,9980035577,3197431266)
|
||||
g=g(35930746212825,9980035577,2618135625)
|
||||
g=g(51900604524715,9980035577,4419524315)
|
||||
g=g(87827018005068,9980035577,2704927468)
|
||||
g=g(57887902441764,9980035577,3696095164)
|
||||
g=g(96810941031110,9980035577,4595934210)
|
||||
|
||||
/*Table 2*/
|
||||
g=g(86833646827370,9980035577,7337307470)
|
||||
g=g(77850880592435,9980035577,6603091835)
|
||||
g=g(84836601050323,9980035577,6298645823)
|
||||
g=g(85835110016211,9980035577,6804054011)
|
||||
g=g(94817143459192,9980035577,6805477692)
|
||||
g=g(94818870293481,9980035577,8532311981)
|
||||
g=g(91823235571154,9980035577,6908262754)
|
||||
g=g(59885451951796,9980035577,5238489796)
|
||||
g=g(80844460893239,9980035577,6172719539)
|
||||
g=g(67869195894693,9980035577,4953971093)
|
||||
g=g(95813990985202,9980035577,5649446002)
|
||||
|
||||
/*Skip Table 3, duplicate of line 1, table 1*/
|
||||
|
||||
/*Table 4*/
|
||||
g=g(28420950579078013018256253301,17987947258,16619542243)
|
||||
g=g(12015118977201790601658257234,16687885701,8697335297)
|
||||
g=g(14349070374946789715188912007,13712994561,3605141129)
|
||||
g=g(61984050238512905451986475027,13337935089,5296182558)
|
||||
g=g(86189707791214681859449918641,17837971389,14435206830)
|
||||
g=g(66747908181102582528134773954,19462997965,8615839889)
|
||||
|
||||
/*Table 6*/
|
||||
g=g(4999253,9998,253)
|
||||
g=g(8996373,9995,873)
|
||||
|
||||
|
||||
/* Added by Phil Nelson..... */
|
||||
"end of tests
|
||||
"
|
@ -1,3 +1,5 @@
|
||||
for (i=0; i<8*a(1); i=i+.01) x=s(i)
|
||||
x
|
||||
for (i=i; i<16*a(1); i=i+.01) x=s(i+.1234123412341234)
|
||||
x
|
||||
quit
|
||||
|
@ -1,4 +1,13 @@
|
||||
scale = 20
|
||||
scale = 5
|
||||
for (a=1; a<500; a++) r=sqrt(a)
|
||||
r
|
||||
scale = 10
|
||||
for (a=1; a<500; a++) r=sqrt(a)
|
||||
r
|
||||
scale = 25
|
||||
for (a=1; a<500; a++) r=sqrt(a)
|
||||
r
|
||||
scale = 40
|
||||
for (a=1; a<500; a++) r=sqrt(a)
|
||||
r
|
||||
quit
|
||||
|
@ -1 +1 @@
|
||||
1.02
|
||||
1.03
|
||||
|
2
gnu/usr.bin/bc/acconfig.h
Normal file
2
gnu/usr.bin/bc/acconfig.h
Normal file
@ -0,0 +1,2 @@
|
||||
/* define if the math lib is to be loaded from a file. */
|
||||
#undef BC_MATH_FILE
|
@ -3,7 +3,7 @@
|
||||
extensions to the language. */
|
||||
|
||||
/* This file is part of bc written for MINIX.
|
||||
Copyright (C) 1991, 1992 Free Software Foundation, Inc.
|
||||
Copyright (C) 1991, 1992, 1993, 1994 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
|
||||
@ -300,15 +300,16 @@ function : Define NAME '(' opt_parameter_list ')' '{'
|
||||
{
|
||||
/* Check auto list against parameter list? */
|
||||
check_params ($4,$8);
|
||||
sprintf (genstr, "F%d,%s.%s[", lookup($2,FUNCT),
|
||||
arg_str ($4,TRUE), arg_str ($8,TRUE));
|
||||
sprintf (genstr, "F%d,%s.%s[",
|
||||
lookup($2,FUNCTDEF),
|
||||
arg_str ($4), arg_str ($8));
|
||||
generate (genstr);
|
||||
free_args ($4);
|
||||
free_args ($8);
|
||||
$1 = next_label;
|
||||
next_label = 0;
|
||||
next_label = 1;
|
||||
}
|
||||
statement_list NEWLINE '}'
|
||||
statement_list /* NEWLINE */ '}'
|
||||
{
|
||||
generate ("0R]");
|
||||
next_label = $1;
|
||||
@ -530,7 +531,7 @@ expression : named_expression ASSIGN_OP
|
||||
{
|
||||
sprintf (genstr, "C%d,%s:",
|
||||
lookup ($1,FUNCT),
|
||||
arg_str ($3,FALSE));
|
||||
call_str ($3));
|
||||
free_args ($3);
|
||||
}
|
||||
else
|
||||
@ -607,6 +608,8 @@ named_expression : NAME
|
||||
| Scale
|
||||
{ $$ = 2; }
|
||||
| Last
|
||||
{ $$ = 3; }
|
||||
{ $$ = 3;
|
||||
warn ("Last variable");
|
||||
}
|
||||
;
|
||||
%%
|
||||
|
30
gnu/usr.bin/bc/configure.in
Normal file
30
gnu/usr.bin/bc/configure.in
Normal file
@ -0,0 +1,30 @@
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
AC_INIT(bc.1)
|
||||
AC_CONFIG_HEADER(config.h)
|
||||
AC_PROG_CC
|
||||
AC_MINIX
|
||||
AC_PROG_YACC
|
||||
AC_PROG_LEX
|
||||
if test "$LEX" = "flex" ; then
|
||||
LEX="flex -I8"
|
||||
fi
|
||||
AC_PROG_INSTALL
|
||||
AC_C_CONST
|
||||
AC_TYPE_SIZE_T
|
||||
dnl AC_PTRDIFF_T
|
||||
AC_CHECK_HEADERS(stdarg.h stddef.h stdlib.h string.h limits.h unistd.h)
|
||||
AC_CHECK_FUNCS(isgraph)
|
||||
SaveCFLAGS="$CFLAGS"
|
||||
CFLAGS="-g -O -I. -I$srcdir"
|
||||
AC_MSG_CHECKING(if long strings are accepted by the C compiler)
|
||||
AC_TRY_COMPILE([
|
||||
char libmath[] =
|
||||
#include "libmath.h"
|
||||
;
|
||||
],[],AC_MSG_RESULT(yes),
|
||||
AC_DEFINE(BC_MATH_FILE,"libmath.b")
|
||||
AC_MSG_RESULT(no)
|
||||
AC_MSG_WARN(libmath.b will not be preloaded into the executable))
|
||||
CFLAGS="$SaveCFLAGS"
|
||||
AC_OUTPUT(Makefile)
|
||||
|
8
gnu/usr.bin/bc/fix_libmath.h
Normal file
8
gnu/usr.bin/bc/fix_libmath.h
Normal file
@ -0,0 +1,8 @@
|
||||
ed libmath.h <<EOS-EOS
|
||||
1,1s/^/"/
|
||||
1,\$s/\$/\\\\/
|
||||
\$,\$d
|
||||
\$,\$s/\\\\\$/"/
|
||||
w
|
||||
q
|
||||
EOS-EOS
|
238
gnu/usr.bin/bc/install-sh
Normal file
238
gnu/usr.bin/bc/install-sh
Normal file
@ -0,0 +1,238 @@
|
||||
#!/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}"
|
||||
|
||||
tranformbasename=""
|
||||
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
|
@ -1,7 +1,7 @@
|
||||
/* libmath.b for bc for minix. */
|
||||
|
||||
/* This file is part of bc written for MINIX.
|
||||
Copyright (C) 1991, 1992 Free Software Foundation, Inc.
|
||||
Copyright (C) 1991, 1992, 1993 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
|
||||
@ -35,7 +35,17 @@ scale = 20
|
||||
*/
|
||||
|
||||
define e(x) {
|
||||
auto a, d, e, f, i, m, v, z
|
||||
auto a, d, e, f, i, m, n, v, z
|
||||
|
||||
/* a - holds x^y of x^y/y! */
|
||||
/* d - holds y! */
|
||||
/* e - is the value x^y/y! */
|
||||
/* v - is the sum of the e's */
|
||||
/* f - number of times x was divided by 2. */
|
||||
/* m - is 1 if x was minus. */
|
||||
/* i - iteration count. */
|
||||
/* n - the scale to compute the sum. */
|
||||
/* z - orignal scale. */
|
||||
|
||||
/* Check the sign of x. */
|
||||
if (x<0) {
|
||||
@ -45,13 +55,16 @@ define e(x) {
|
||||
|
||||
/* Precondition x. */
|
||||
z = scale;
|
||||
scale = 4 + z + .44*x;
|
||||
n = 6 + z + .44*x;
|
||||
scale = scale(x)+1;
|
||||
while (x > 1) {
|
||||
f += 1;
|
||||
x /= 2;
|
||||
scale += 1;
|
||||
}
|
||||
|
||||
/* Initialize the variables. */
|
||||
scale = n;
|
||||
v = 1+x
|
||||
a = x
|
||||
d = 1
|
||||
@ -81,7 +94,7 @@ define l(x) {
|
||||
|
||||
/* Precondition x to make .5 < x < 2.0. */
|
||||
z = scale;
|
||||
scale += 4;
|
||||
scale = 6 + scale;
|
||||
f = 2;
|
||||
i=0
|
||||
while (x >= 2) { /* for large numbers */
|
||||
@ -117,7 +130,7 @@ define s(x) {
|
||||
|
||||
/* precondition x. */
|
||||
z = scale
|
||||
scale = 1.1*z + 1;
|
||||
scale = 1.1*z + 2;
|
||||
v = a(1)
|
||||
if (x < 0) {
|
||||
m = 1;
|
||||
@ -160,38 +173,50 @@ define c(x) {
|
||||
define a(x) {
|
||||
auto a, e, f, i, m, n, s, v, z
|
||||
|
||||
/* Special case and for fast answers */
|
||||
if (x==1) {
|
||||
if (scale <= 25) return (.7853981633974483096156608/1)
|
||||
if (scale <= 40) return (.7853981633974483096156608458198757210492/1)
|
||||
if (scale <= 60) \
|
||||
return (.785398163397448309615660845819875721049292349843776455243736/1)
|
||||
}
|
||||
if (x==.2) {
|
||||
if (scale <= 25) return (.1973955598498807583700497/1)
|
||||
if (scale <= 40) return (.1973955598498807583700497651947902934475/1)
|
||||
if (scale <= 60) \
|
||||
return (.197395559849880758370049765194790293447585103787852101517688/1)
|
||||
}
|
||||
/* a is the value of a(.2) if it is needed. */
|
||||
/* f is the value to multiply by a in the return. */
|
||||
/* e is the value of the current term in the series. */
|
||||
/* v is the accumulated value of the series. */
|
||||
/* m is 1 or -1 depending on x (-x -> -1). results are divided by m. */
|
||||
/* i is the denominator value for series element. */
|
||||
/* n is the numerator value for the series element. */
|
||||
/* s is -x*x. */
|
||||
/* z is the saved user's scale. */
|
||||
|
||||
/* Negative x? */
|
||||
m = 1;
|
||||
if (x<0) {
|
||||
m = 1;
|
||||
m = -1;
|
||||
x = -x;
|
||||
}
|
||||
|
||||
/* Special case and for fast answers */
|
||||
if (x==1) {
|
||||
if (scale <= 25) return (.7853981633974483096156608/m)
|
||||
if (scale <= 40) return (.7853981633974483096156608458198757210492/m)
|
||||
if (scale <= 60) \
|
||||
return (.785398163397448309615660845819875721049292349843776455243736/m)
|
||||
}
|
||||
if (x==.2) {
|
||||
if (scale <= 25) return (.1973955598498807583700497/m)
|
||||
if (scale <= 40) return (.1973955598498807583700497651947902934475/m)
|
||||
if (scale <= 60) \
|
||||
return (.197395559849880758370049765194790293447585103787852101517688/m)
|
||||
}
|
||||
|
||||
|
||||
/* Save the scale. */
|
||||
z = scale;
|
||||
|
||||
/* Note: a and f are known to be zero due to being auto vars. */
|
||||
/* Calculate atan of a known number. */
|
||||
if (x > .2) {
|
||||
scale = z+4;
|
||||
scale = z+5;
|
||||
a = a(.2);
|
||||
}
|
||||
|
||||
/* Precondition x. */
|
||||
scale = z+2;
|
||||
scale = z+3;
|
||||
while (x > .2) {
|
||||
f += 1;
|
||||
x = (x-.2) / (1+x*.2);
|
||||
@ -206,8 +231,7 @@ define a(x) {
|
||||
e = (n *= s) / i;
|
||||
if (e == 0) {
|
||||
scale = z;
|
||||
if (m) return ((f*a+v)/-1);
|
||||
return ((f*a+v)/1);
|
||||
return ((f*a+v)/m);
|
||||
}
|
||||
v += e
|
||||
}
|
||||
|
40
gnu/usr.bin/bc/libmath.h
Normal file
40
gnu/usr.bin/bc/libmath.h
Normal file
@ -0,0 +1,40 @@
|
||||
"@iK20:s2:p@r\
|
||||
@iF1,4.5,6,7,8,9,10,11,12,13[l4:0<Z1:1s10:pl4:ns4:pN1:l2:s13:\
|
||||
pK6:l13:+K.44:l4:*+s11:pl4:cS1+s2:pN2:l4:1>Z3:l8:1+s8:pl4:K2:\
|
||||
/s4:pl2:1+s2:pJ2:N3:l11:s2:p1l4:+s12:pl4:s5:p1s6:pK2:s9:pN5:1\
|
||||
B6:J4:N7:l9:i9:pJ5:N6:l5:l4:*s5:l6:l9:*s6:/s7:pl7:0=Z8:l8:0>Z9:\
|
||||
N10:l8:d8:Z11:l12:l12:*s12:pJ10:N11:N9:l13:s2:pl10:Z12:1l12:/\
|
||||
RN12:l12:1/RN8:l12:l7:+s12:pJ7:N4:0R]@r\
|
||||
@iF2,4.7,8,9,10,11,12,13[l4:0{Z1:1K10:l2:^-RN1:l2:s13:pK6:l2:\
|
||||
+s2:pK2:s8:p0s9:pN2:l4:K2:}Z3:l8:K2:*s8:pl4:cRs4:pJ2:N3:N4:l4:\
|
||||
K.5:{Z5:l8:K2:*s8:pl4:cRs4:pJ4:N5:l4:1-l4:1+/s11:s12:pl11:l11:\
|
||||
*s10:pK3:s9:pN7:1B8:J6:N9:l9:K2:+s9:pJ7:N8:l11:l10:*s11:l9:/s7:\
|
||||
pl7:0=Z10:l8:l12:*s12:pl13:s2:pl12:1/RN10:l12:l7:+s12:pJ9:N6:\
|
||||
0R]@r\
|
||||
@iF3,4.7,9,10,11,14,12,13[l2:s13:pK1.1:l13:*K2:+s2:p1C4,0:s12:\
|
||||
pl4:0<Z1:1s10:pl4:ns4:pN1:0s2:pl4:l12:/K2:+K4:/s11:pl4:K4:l11:\
|
||||
*l12:*-s4:pl11:K2:%Z2:l4:ns4:pN2:l13:K2:+s2:pl4:s7:s12:pl4:nl4:\
|
||||
*s14:pK3:s9:pN4:1B5:J3:N6:l9:K2:+s9:pJ4:N5:l7:l14:l9:l9:1-*/*\
|
||||
s7:pl7:0=Z7:l13:s2:pl10:Z8:l12:n1/RN8:l12:1/RN7:l12:l7:+s12:p\
|
||||
J6:N3:0R]@r\
|
||||
@iF5,4.12[l2:1+s2:pl4:1C4,0:K2:*+C3,0:s12:pl2:1-s2:pl12:1/R0R]\
|
||||
@r\
|
||||
@iF4,4.5,7,8,9,10,11,14,12,13[1s10:pl4:0<Z1:1ns10:pl4:ns4:pN1:\
|
||||
l4:1=Z2:l2:K25:{Z3:K.7853981633974483096156608:l10:/RN3:l2:K40\
|
||||
:{Z4:K.7853981633974483096156608458198757210492:l10:/RN4:l2:K\
|
||||
60:{Z5:K.785398163397448309615660845819875721049292349843776455243736\
|
||||
:l10:/RN5:N2:l4:K.2:=Z6:l2:K25:{Z7:K.1973955598498807583700497\
|
||||
:l10:/RN7:l2:K40:{Z8:K.1973955598498807583700497651947902934475\
|
||||
:l10:/RN8:l2:K60:{Z9:K.197395559849880758370049765194790293447585103787852101517688\
|
||||
:l10:/RN9:N6:l2:s13:pl4:K.2:>Z10:l13:K5:+s2:pK.2:C4,0:s5:pN10:\
|
||||
l13:K3:+s2:pN11:l4:K.2:>Z12:l8:1+s8:pl4:K.2:-1l4:K.2:*+/s4:pJ11:N12:\
|
||||
l4:s11:s12:pl4:nl4:*s14:pK3:s9:pN14:1B15:J13:N16:l9:K2:+s9:pJ14:N15:\
|
||||
l11:l14:*s11:l9:/s7:pl7:0=Z17:l13:s2:pl8:l5:*l12:+l10:/RN17:l12:\
|
||||
l7:+s12:pJ16:N13:0R]@r\
|
||||
@iF6,11,4.5,6,7,8,9,10,14,12,13[l2:s13:p0s2:pl11:1/s11:pl11:0\
|
||||
<Z1:l11:ns11:pl11:K2:%1=Z2:1s10:pN2:N1:1s8:pK2:s9:pN4:l9:l11:\
|
||||
{B5:J3:N6:l9:i9:pJ4:N5:l8:l9:*s8:pJ6:N3:K1.5:l13:*s2:pl4:l11:\
|
||||
^K2:l11:^/l8:/s8:p1s7:s12:pl4:nl4:*K4:/s14:pK1.5:l13:*s2:p1s9:\
|
||||
pN8:1B9:J7:N10:l9:i9:pJ8:N9:l7:l14:*l9:/l11:l9:+/s7:pl7:0=Z11:\
|
||||
l13:s2:pl10:Z12:l8:nl12:*1/RN12:l8:l12:*1/RN11:l12:l7:+s12:pJ10:N7:\
|
||||
0R]@r"
|
@ -1,8 +1,8 @@
|
||||
, %{
|
||||
%{
|
||||
/* sbc.y: A POSIX bc processor written for minix with no extensions. */
|
||||
|
||||
/* This file is part of bc written for MINIX.
|
||||
Copyright (C) 1991, 1992 Free Software Foundation, Inc.
|
||||
Copyright (C) 1991, 1992, 1993, 1994 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
|
||||
|
@ -2,7 +2,7 @@
|
||||
/* scan.l: the (f)lex description file for the scanner. */
|
||||
|
||||
/* This file is part of bc written for MINIX.
|
||||
Copyright (C) 1991, 1992 Free Software Foundation, Inc.
|
||||
Copyright (C) 1991, 1992, 1993, 1994 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
|
||||
@ -79,6 +79,13 @@ warranty return(Warranty);
|
||||
continue return(Continue);
|
||||
print return(Print);
|
||||
limits return(Limits);
|
||||
"." {
|
||||
#ifdef DOT_IS_LAST
|
||||
return(Last);
|
||||
#else
|
||||
yyerror ("illegal character: %s",yytext);
|
||||
#endif
|
||||
}
|
||||
"+"|"-"|";"|"("|")"|"{"|"}"|"["|"]"|","|"^" { yylval.c_value = yytext[0];
|
||||
return((int)yytext[0]); }
|
||||
&& { return(AND); }
|
||||
|
Loading…
Reference in New Issue
Block a user