Browse files

Updating to version 1.04.

  • Loading branch information...
1 parent 0ec25f8 commit 287b2c6a0f4f1f7827439e3cf9f4f3a6b1650815 phil committed Apr 29, 1997
@@ -1,13 +1,19 @@
-# $Id: Makefile,v 1994/12/01 04:24:14 phil Exp $
+# $NetBSD: Makefile,v 1997/04/29 00:11:10 phil Exp $
PROG= bc
-SRCS= bc.c scan.c util.c main.c number.c storage.c load.c execute.c global.c
+SRCS= bc.c scan.c util.c main.c number.c storage.c load.c execute.c \
+ global.c getopt.c getopt1.c
LDADD+= -ll
-CLEANFILES+= bc.c scan.c
+CLEANFILES+= bc.c scan.c bc.h
+bc.c bc.h: bc.y
+ $(YACC) -d bc.y
+ mv bc.c
+ mv bc.h
.include <>
@@ -1,8 +1,13 @@
-This is GNU bc 1.03.
+This is GNU bc 1.04.
+The full distribution of GNU bc-1.04 may be found at any GNU software
+archive. The master copy is at
+Not everything included in the full bc-1.04 distribution is included.
+The files included here are only the needed files for building bc on
+NetBSD. Their location in the NetBSD tree are different than in the
+original bc-1.04 source tree.
-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.)
@@ -1,8 +1,8 @@
.\" bc.1 - the *roff document processor source for the bc manual
-.\" This file is part of bc written initially for MINIX.
-.\" Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
+.\" This file is part of GNU bc.
+.\" Copyright (C) 1991, 1992, 1993, 1994, 1997 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
@@ -26,13 +26,13 @@
.\" Bellingham, WA 98226-9062
-.TH bc 1 .\" "Command Manual" v1.03 "Nov 2, 1994"
+.TH bc 1 .\" "Command Manual" v1.04 "June 22, 1995"
bc - An arbitrary precision calculator language
-\fBbc\fR [ \fB-lws\fR ] [ \fI file ...\fR ]
+\fBbc\fR [ \fB-lwsqv\fR ] [long-options] [ \fI file ...\fR ]
-This man page documents GNU bc version 1.03.
+This man page documents GNU bc version 1.04.
\fBbc\fR is a language that supports arbitrary precision numbers
with interactive execution of statements. There are some similarities
@@ -58,6 +58,20 @@ Define the standard math library.
Give warnings for extensions to POSIX \fBbc\fR.
.IP -s
Process exactly the POSIX \fBbc\fR language.
+.IP -q
+Do not print the normal GNU bc welcome.
+.IP -v
+Print the version number and copyright and quit.
+.IP --mathlib
+Define the standard math library.
+.IP --warn
+Give warnings for extensions to POSIX \fBbc\fR.
+.IP --standard
+Process exactly the POSIX \fBbc\fR language.
+.IP --quiet
+Do not print the normal GNU bc welcome.
+.IP --version
+Print the version number and copyright and quit.
The most basic element in \fBbc\fR is the number. Numbers are
arbitrary precision numbers. This precision is both in the integer
@@ -99,6 +113,11 @@ single space in the input. (This causes comments to delimit other
input items. For example, a comment can not be found in the middle of
a variable name.) Comments include any newlines (end of line) between
the start and the end of the comment.
+To support the use of scripts for \fBbc\fR, a single line comment has been
+added as an extension. A single line comment starts at a \fB#\fR
+character and continues to the next end of the line. The end of line
+character is not part of the comment and is processed normally.
The numbers are manipulated by expressions and statements. Since
the language was designed to be interactive, statements and expressions
@@ -109,7 +128,7 @@ detail later, are defined when encountered.)
A simple expression is just a constant. \fBbc\fR converts constants
into internal decimal numbers using the current input base, specified
by the variable \fBibase\fR. (There is an exception in functions.)
-The legal values of \fBibase\fR are 2 through 16 (F). Assigning a
+The legal values of \fBibase\fR are 2 through 16. Assigning a
value outside this range to \fBibase\fR will result in a value of 2
or 16. Input numbers may contain the characters 0-9 and A-F. (Note:
They must be capitals. Lower case letters are variable names.)
@@ -339,7 +358,7 @@ Any other character following the backslash will be ignored.
.IP "{ statement_list }"
This is the compound statement. It allows multiple statements to be
grouped together for execution.
-.IP "\fBif\fR ( expression ) \fBthen\fR statement1 [\fBelse\fR statement2]"
+.IP "\fBif\fR ( expression ) statement1 [\fBelse\fR statement2]"
The if statement evaluates the expression and executes statement1 or
statement2 depending on the value of the expression. If the expression
is non-zero, statement1 is executed. If statement2 is present and
@@ -431,7 +450,7 @@ A runtime error will also occur for the call to an undefined function.
The \fIauto_list\fR is an optional list of variables that are for
"local" use. The syntax of the auto list (if present) is "\fBauto
-\fIname \fR, ... ;". (The semicolon is optional.) Each \fIname\fR is
+\fIname\fR, ... ;". (The semicolon is optional.) Each \fIname\fR is
the name of an auto variable. Arrays may be specified by using the
same notation as used in parameters. These variables have their
values pushed onto a stack at the start of the function. The
@@ -468,11 +487,11 @@ and the default scale is set to 20. The math functions will calculate their
results to the scale set at the time of their call.
The math library defines the following functions:
.IP "s (\fIx\fR)"
-The sine of x in radians.
+The sine of x, x is in radians.
.IP "c (\fIx\fR)"
-The cosine of x in radians.
+The cosine of x, x is in radians.
.IP "a (\fIx\fR)"
-The arctangent of x.
+The arctangent of x, arctangent returns radians.
.IP "l (\fIx\fR)"
The natural logarithm of x.
.IP "e (\fIx\fR)"
@@ -575,6 +594,19 @@ define f (x) {
+GNU \fBbc\fR can be compiled (via a configure option) to use the
+GNU \fBreadline\fR input editor library. This allows the user
+to do more editing of lines before sending them to \fBbc\fR.
+It also allows for a history of previous lines typed. When this
+option is selected, \fBbc\fR has one more special variable.
+This special variable, \fBhistory\fR is the number of lines of
+history retained. A value of -1 means that an unlimited number
+of history lines are retained. This is the default value.
+Setting the value of \fBhistory\fR to a positive number restricts
+the number of history lines to the number given. The value of
+0 disables the history feature. For more information, read the
+user manuals for the GNU \fBreadline\fR and \fBhistory\fR libraries.
This version of
.B bc
@@ -626,8 +658,11 @@ POSIX \fBbc\fR does not have a print statement .
.IP "continue statement"
POSIX \fBbc\fR does not have a continue statement.
.IP "array parameters"
-POSIX \fBbc\fR does not have array parameters. Other implementations
-of \fBbc\fR may have call by value array parameters.
+POSIX \fBbc\fR does not (currently) support array parameters in full.
+The POSIX grammar allows for arrays in function definitions, but does
+not provide a method to specify an array as an actual parameter. (This
+is most likely an oversight in the grammar.) Traditional implementations
+of \fBbc\fR have only call by value array parameters.
.IP "=+, =-, =*, =/, =%, =^"
POSIX \fBbc\fR does not require these "old style" assignment operators to
be defined. This version may allow these "old style" assignments. Use
@@ -708,6 +743,23 @@ to have more than 16 segments of 1024 bytes.
.IP "variable names"
The current limit on the number of unique names is 32767 for each of
simple variables, arrays and functions.
+The following environment variables are processed by \fBbc\fR:
+This is the same as the \fB-s\fR option.
+This is another mechanism to get arguments to \fBbc\fR. The
+format is the same as the command line arguments. These arguments
+are processed first, so any files listed in the environent arguments
+are processed before any command line argument files. This allows
+the user to set up "standard" options and files to be processed
+at every invocation of \fBbc\fR. The files in the environment
+variables would typically contain function definitions for functions
+the user wants defined every time \fBbc\fR is run.
+This should be an integer specifing the number of characters in an
+output line for numbers. This includes the backslash and newline characters
+for long numbers.
In most installations, \fBbc\fR is completely self-contained.
Where executable size is of importance or the C compiler does
@@ -720,6 +772,10 @@ that the file is unavailable and terminate. Also, there are compile
and run time diagnostics that should be self-explanatory.
Error recovery is not very good yet.
+Email bug reports to
+.BR .
+Be sure to include the word ``bc'' somewhere in the ``Subject:'' field.
Philip A. Nelson
Oops, something went wrong.

0 comments on commit 287b2c6

Please sign in to comment.