mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
Release calc version 2.12.1.8
This commit is contained in:
49
CHANGES
49
CHANGES
@@ -1,4 +1,45 @@
|
|||||||
The following are the changes from calc version 2.12.1.6 to date:
|
The following are the changes from calc version 2.12.1.7 to date:
|
||||||
|
|
||||||
|
Fixed calc cscripts that contained comments that were not valid calc
|
||||||
|
comments. Improved calc comment documentation in "help unexpected"
|
||||||
|
to help other avoid similar mistakes. Calc comments are of the form:
|
||||||
|
|
||||||
|
/* c style comments */
|
||||||
|
/*
|
||||||
|
* multi-line
|
||||||
|
* commentts
|
||||||
|
*/
|
||||||
|
## two or more #-signs
|
||||||
|
### in a row
|
||||||
|
### Note that # along is a calc uniary and binary operator
|
||||||
|
|
||||||
|
Added "help pound" or "help #' to document the # operator, comments,
|
||||||
|
and the first line of cscript files.
|
||||||
|
|
||||||
|
Documented these help commands in "help help":
|
||||||
|
|
||||||
|
help ->
|
||||||
|
help *
|
||||||
|
help .
|
||||||
|
help %
|
||||||
|
help //
|
||||||
|
help #
|
||||||
|
|
||||||
|
The usage help file is now formed from the contents of the calc man page.
|
||||||
|
So "help usage" prints the version of the calc man page. Added ${COL}
|
||||||
|
makefile symbol to support the formation of the calc.usage file from
|
||||||
|
calc.1 via the CALCPAGER (less).
|
||||||
|
|
||||||
|
The "help calc" command is now equivalent to "help help".
|
||||||
|
|
||||||
|
The "help define" command is now equivalent to "help command".
|
||||||
|
|
||||||
|
Fixed calc command line usage message.
|
||||||
|
|
||||||
|
Fixed missing README.src file in RPM src and tgz src tarball.
|
||||||
|
|
||||||
|
|
||||||
|
The following are the changes from calc version 2.12.1.6 to 2.12.1.6:
|
||||||
|
|
||||||
Added the calc builtin function, usertime(), to return the amount of
|
Added the calc builtin function, usertime(), to return the amount of
|
||||||
user CPU time used by the current process. Unlike the old runtime()
|
user CPU time used by the current process. Unlike the old runtime()
|
||||||
@@ -2646,8 +2687,6 @@ The following are the changes from calc version 2.10.3t5.38 to 2.11.3t5.46:
|
|||||||
into a single section.
|
into a single section.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
The following are the changes from calc version 2.10.3t5.34 to 2.10.3t5.37:
|
The following are the changes from calc version 2.10.3t5.34 to 2.10.3t5.37:
|
||||||
|
|
||||||
Per request from David I Bell, the README line:
|
Per request from David I Bell, the README line:
|
||||||
@@ -6281,8 +6320,8 @@ Following is a list of visible changes to calc from version 1.24.7 to 1.26.1:
|
|||||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||||
##
|
##
|
||||||
## @(#) $Revision: 29.91 $
|
## @(#) $Revision: 29.94 $
|
||||||
## @(#) $Id: CHANGES,v 29.91 2007/01/03 21:27:55 chongo Exp $
|
## @(#) $Id: CHANGES,v 29.94 2007/02/07 01:38:03 chongo Exp $
|
||||||
## @(#) $Source: /usr/local/src/cmd/calc/RCS/CHANGES,v $
|
## @(#) $Source: /usr/local/src/cmd/calc/RCS/CHANGES,v $
|
||||||
##
|
##
|
||||||
## Under source code control: 1993/06/02 18:12:57
|
## Under source code control: 1993/06/02 18:12:57
|
||||||
|
36
Makefile
36
Makefile
@@ -32,8 +32,8 @@
|
|||||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#
|
#
|
||||||
MAKEFILE_REV= $$Revision: 29.83 $$
|
MAKEFILE_REV= $$Revision: 29.84 $$
|
||||||
# @(#) $Id: Makefile.ship,v 29.83 2007/01/03 21:29:50 chongo Exp $
|
# @(#) $Id: Makefile.ship,v 29.84 2007/02/07 00:34:23 chongo Exp $
|
||||||
# @(#) $Source: /usr/local/src/cmd/calc/RCS/Makefile.ship,v $
|
# @(#) $Source: /usr/local/src/cmd/calc/RCS/Makefile.ship,v $
|
||||||
#
|
#
|
||||||
# Under source code control: 1990/02/15 01:48:41
|
# Under source code control: 1990/02/15 01:48:41
|
||||||
@@ -1206,6 +1206,7 @@ CO= co
|
|||||||
AR= ar
|
AR= ar
|
||||||
TRUE= true
|
TRUE= true
|
||||||
CAT= cat
|
CAT= cat
|
||||||
|
COL= col
|
||||||
# assume the X11 makedepend tool for the depend rule
|
# assume the X11 makedepend tool for the depend rule
|
||||||
MAKEDEPEND= makedepend
|
MAKEDEPEND= makedepend
|
||||||
|
|
||||||
@@ -1570,7 +1571,7 @@ PROGS= calc${EXT} ${UTIL_PROGS}
|
|||||||
# complete list of targets
|
# complete list of targets
|
||||||
#
|
#
|
||||||
TARGETS= ${LICENSE} ${CALC_LIBS} custom/.all calc${EXT} sample/.all \
|
TARGETS= ${LICENSE} ${CALC_LIBS} custom/.all calc${EXT} sample/.all \
|
||||||
cal/.all help/.all help/builtin cscript/.all calc.1
|
cal/.all help/.all help/builtin cscript/.all calc.1 calc.usage
|
||||||
|
|
||||||
|
|
||||||
###
|
###
|
||||||
@@ -1593,16 +1594,24 @@ libcalc.a: ${LIBOBJS} ${MAKE_FILE}
|
|||||||
${CHMOD} 0644 libcalc.a
|
${CHMOD} 0644 libcalc.a
|
||||||
|
|
||||||
calc.1: calc.man ${MAKE_FILE}
|
calc.1: calc.man ${MAKE_FILE}
|
||||||
-${RM} -f calc.1
|
-${RM} -f $@
|
||||||
${SED} -e 's:$${LIBDIR}:${LIBDIR}:g' \
|
${Q} echo forming calc.1 from calc.man
|
||||||
-e 's,$${BINDIR},${BINDIR},g' \
|
@${SED} -e 's:$${LIBDIR}:${LIBDIR}:g' \
|
||||||
-e 's,$${CALCPATH},${CALCPATH},g' \
|
-e 's,$${BINDIR},${BINDIR},g' \
|
||||||
-e 's,$${SCRIPTDIR},${SCRIPTDIR},g' \
|
-e 's,$${CALCPATH},${CALCPATH},g' \
|
||||||
-e 's,$${CALC_INCDIR},${CALC_INCDIR},g' \
|
-e 's,$${SCRIPTDIR},${SCRIPTDIR},g' \
|
||||||
-e 's,$${CUSTOMCALDIR},${CUSTOMCALDIR},g' \
|
-e 's,$${CALC_INCDIR},${CALC_INCDIR},g' \
|
||||||
-e 's,$${CUSTOMINCDIR},${CUSTOMINCDIR},g' \
|
-e 's,$${CUSTOMCALDIR},${CUSTOMCALDIR},g' \
|
||||||
-e 's,$${CUSTOMHELPDIR},${CUSTOMHELPDIR},g' \
|
-e 's,$${CUSTOMINCDIR},${CUSTOMINCDIR},g' \
|
||||||
-e 's,$${CALCRC},${CALCRC},g' < calc.man > calc.1
|
-e 's,$${CUSTOMHELPDIR},${CUSTOMHELPDIR},g' \
|
||||||
|
-e 's,$${CALCRC},${CALCRC},g' < calc.man > calc.1
|
||||||
|
${Q} echo calc.man formed
|
||||||
|
|
||||||
|
calc.usage: calc.1
|
||||||
|
-${RM} -f $@
|
||||||
|
${Q} echo forming calc.usage from calc.1
|
||||||
|
${CALCPAGER} calc.1 | ${COL} -b > $@
|
||||||
|
${Q} echo calc.usage formed
|
||||||
|
|
||||||
##
|
##
|
||||||
#
|
#
|
||||||
@@ -3357,6 +3366,7 @@ env:
|
|||||||
@echo 'SORT=${SORT}'; echo ''
|
@echo 'SORT=${SORT}'; echo ''
|
||||||
@echo 'TEE=${TEE}'; echo ''
|
@echo 'TEE=${TEE}'; echo ''
|
||||||
@echo 'CTAGS=${CTAGS}'; echo ''
|
@echo 'CTAGS=${CTAGS}'; echo ''
|
||||||
|
@echo 'COL=${COL}'; echo ''
|
||||||
@echo 'MAKEDEPEND=${MAKEDEPEND}'; echo ''
|
@echo 'MAKEDEPEND=${MAKEDEPEND}'; echo ''
|
||||||
@echo 'MKDIR_ARG=${MKDIR_ARG}'; echo ''
|
@echo 'MKDIR_ARG=${MKDIR_ARG}'; echo ''
|
||||||
@echo 'EXT=${EXT}'; echo ''
|
@echo 'EXT=${EXT}'; echo ''
|
||||||
|
15
calc.c
15
calc.c
@@ -19,8 +19,8 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.13 $
|
* @(#) $Revision: 29.14 $
|
||||||
* @(#) $Id: calc.c,v 29.13 2006/05/19 15:26:10 chongo Exp $
|
* @(#) $Id: calc.c,v 29.14 2007/02/07 00:37:25 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/calc.c,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/RCS/calc.c,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1990/02/15 01:48:11
|
* Under source code control: 1990/02/15 01:48:11
|
||||||
@@ -416,6 +416,7 @@ main(int argc, char **argv)
|
|||||||
cp++;
|
cp++;
|
||||||
*bp++ = ';';
|
*bp++ = ';';
|
||||||
cmdlen++;
|
cmdlen++;
|
||||||
|
s_flag = TRUE; /* -f implies -s */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 's':
|
case 's':
|
||||||
@@ -431,11 +432,13 @@ main(int argc, char **argv)
|
|||||||
fprintf(stderr, "Illegal option -%c\n",
|
fprintf(stderr, "Illegal option -%c\n",
|
||||||
c);
|
c);
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"usage: %s [-a] [-c] [-C] [-d] [-e] [-h] [-i] [-m mode]\n"
|
"usage: %s [-c] [-C] [-d] [-e] [-h] [-i] [-m mode]\n"
|
||||||
"\t[-D calc_debug[:resource_debug[:user_debug]]]\n"
|
"\t[-D calc_debug[:resource_debug[:user_debug]]]\n"
|
||||||
"\t[-O] [-p] [-q] [-u] [-v] "
|
"\t[-O] [-p] [-q] [-s] [-u] [-v] "
|
||||||
"[--] [calc_cmd ...]\n",
|
"[--] [calc_cmd ...]\n"
|
||||||
program);
|
"usage: %s ... -f filename\n"
|
||||||
|
"1st cscript line: #/path/to/calc ... -f\n",
|
||||||
|
program, program);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (havearg)
|
if (havearg)
|
||||||
|
8
calc.man
8
calc.man
@@ -1,5 +1,5 @@
|
|||||||
.\"
|
.\"
|
||||||
.\" Copyright (C) 1999-2004 Landon Curt Noll
|
.\" Copyright (C) 1999-2007 Landon Curt Noll
|
||||||
.\"
|
.\"
|
||||||
.\" Calc is open software; you can redistribute it and/or modify it under
|
.\" Calc is open software; you can redistribute it and/or modify it under
|
||||||
.\" the terms of the version 2.1 of the GNU Lesser General Public License
|
.\" the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -15,8 +15,8 @@
|
|||||||
.\" received a copy with calc; if not, write to Free Software Foundation, Inc.
|
.\" received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
.\" 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
.\" 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||||
.\"
|
.\"
|
||||||
.\" @(#) $Revision: 29.20 $
|
.\" @(#) $Revision: 29.21 $
|
||||||
.\" @(#) $Id: calc.man,v 29.20 2006/06/01 12:04:16 chongo Exp $
|
.\" @(#) $Id: calc.man,v 29.21 2007/02/07 00:38:43 chongo Exp $
|
||||||
.\" @(#) $Source: /usr/local/src/cmd/calc/RCS/calc.man,v $
|
.\" @(#) $Source: /usr/local/src/cmd/calc/RCS/calc.man,v $
|
||||||
.\"
|
.\"
|
||||||
.\" Under source code control: 1991/07/23 05:48:26
|
.\" Under source code control: 1991/07/23 05:48:26
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
.\" calculator by David I. Bell
|
.\" calculator by David I. Bell
|
||||||
.\" man page by Landon Noll
|
.\" man page by Landon Noll
|
||||||
.\"
|
.\"
|
||||||
.TH calc 1 "^..^" "1999-11-30"
|
.TH calc 1 "^..^" "2007-02-06"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
calc \- arbitrary precision calculator
|
calc \- arbitrary precision calculator
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
#!/usr/local/src/cmd/calc/calc -q -s -f
|
#!/usr/local/src/cmd/calc/calc -q -f
|
||||||
/*
|
/*
|
||||||
* 4dsphere - determine if 6 points lie on the surface of a sphere in R^4
|
* 4dsphere - determine if 6 points lie on the surface of a sphere in R^4
|
||||||
*
|
*
|
||||||
@@ -26,8 +26,8 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 1.3 $
|
* @(#) $Revision: 1.4 $
|
||||||
* @(#) $Id: 4dsphere.calc,v 1.3 2001/06/06 09:06:29 chongo Exp $
|
* @(#) $Id: 4dsphere.calc,v 1.4 2007/02/07 00:34:04 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/4dsphere.calc,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/4dsphere.calc,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 2001/05/03 19:02:03
|
* Under source code control: 2001/05/03 19:02:03
|
||||||
|
@@ -17,8 +17,8 @@
|
|||||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#
|
#
|
||||||
# @(#) $Revision: 29.28 $
|
# @(#) $Revision: 29.31 $
|
||||||
# @(#) $Id: Makefile,v 29.28 2006/09/18 13:13:25 chongo Exp $
|
# @(#) $Id: Makefile,v 29.31 2007/02/07 01:43:56 chongo Exp $
|
||||||
# @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/Makefile,v $
|
# @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/Makefile,v $
|
||||||
#
|
#
|
||||||
# Under source code control: 1999/11/29 11:10:26
|
# Under source code control: 1999/11/29 11:10:26
|
||||||
@@ -199,7 +199,7 @@ SCRIPT_SRC= 4dsphere.calc fproduct.calc mersenne.calc \
|
|||||||
|
|
||||||
# These files are found (but not built) in the distribution
|
# These files are found (but not built) in the distribution
|
||||||
#
|
#
|
||||||
DISTLIST= ${SCRIPT_SRC} ${MAKE_FILE} README
|
DISTLIST= ${SCRIPT_SRC} ${MAKE_FILE} README.src
|
||||||
|
|
||||||
# These files are used to make (but not build) a calc .a library
|
# These files are used to make (but not build) a calc .a library
|
||||||
#
|
#
|
||||||
@@ -211,12 +211,16 @@ CALCLIBLIST=
|
|||||||
# in the upper level ../Makefile
|
# in the upper level ../Makefile
|
||||||
#
|
#
|
||||||
CSCRIPT_TARGETS= ${SCRIPT}
|
CSCRIPT_TARGETS= ${SCRIPT}
|
||||||
TARGETS= ${CSCRIPT_TARGETS}
|
TARGETS= ${CSCRIPT_TARGETS} README
|
||||||
|
|
||||||
# The reason for this Makefile
|
# The reason for this Makefile
|
||||||
#
|
#
|
||||||
all: ${TARGETS} .all
|
all: ${TARGETS} .all
|
||||||
|
|
||||||
|
README: README.src
|
||||||
|
@${RM} -f $@
|
||||||
|
@${SED} -e "s:#!/usr/local/src/cmd/calc/calc:#!${BINDIR}/calc:" $?>$@
|
||||||
|
|
||||||
# used by the upper level Makefile to determine if we have done all
|
# used by the upper level Makefile to determine if we have done all
|
||||||
#
|
#
|
||||||
# NOTE: Due to bogus shells found on one common system we must have
|
# NOTE: Due to bogus shells found on one common system we must have
|
||||||
|
@@ -5,6 +5,46 @@ These calc shell scripts are provided because they serve as examples of
|
|||||||
how use the calc language, and/or because the authors thought them to
|
how use the calc language, and/or because the authors thought them to
|
||||||
be useful!
|
be useful!
|
||||||
|
|
||||||
|
Please note that calc shell scripts must start with the line:
|
||||||
|
|
||||||
|
#!/usr/local/src/cmd/calc/calc -q -f
|
||||||
|
|
||||||
|
The above line MUST start in column 1 of the first line. The first line
|
||||||
|
must also end in -f. The -q is optional, but is recommended to disable
|
||||||
|
the processing of calc startup scripts.
|
||||||
|
|
||||||
|
Also please note that single # shell line comments are not supported in calc.
|
||||||
|
Comments must be /* c-like comment */ or start with a double ## symbol.
|
||||||
|
|
||||||
|
This is the correct way to form a calc shell script:
|
||||||
|
|
||||||
|
#!/usr/local/src/cmd/calc/calc -q -f
|
||||||
|
|
||||||
|
/* a correct comment */
|
||||||
|
## another correct comment
|
||||||
|
### two or more together is also a comment
|
||||||
|
/*
|
||||||
|
* another correct comment
|
||||||
|
*/
|
||||||
|
print "2+2 =", 2+2; ## yet another comment
|
||||||
|
|
||||||
|
The first argument after the path to calc executable must be an -S.
|
||||||
|
The next arguments are optional. The -q is often recommended because
|
||||||
|
it will disable the processing of the startup scripts.
|
||||||
|
|
||||||
|
For more informaton about calc command lines, see "help usage".
|
||||||
|
|
||||||
|
This next example WRONG:
|
||||||
|
|
||||||
|
#!/usr/local/src/cmd/calc/calc -q
|
||||||
|
|
||||||
|
# This is not a calc calc comment because it has only a single #
|
||||||
|
# You must to start comments with ## or /*
|
||||||
|
# is is also wrong because the first line does not end in -f
|
||||||
|
print "This example has invalid comments"
|
||||||
|
|
||||||
|
#####
|
||||||
|
|
||||||
If you write something that you think is useful, please send it to:
|
If you write something that you think is useful, please send it to:
|
||||||
|
|
||||||
calc-contrib at asthe dot com
|
calc-contrib at asthe dot com
|
||||||
@@ -77,9 +117,9 @@ simple
|
|||||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||||
##
|
##
|
||||||
## @(#) $Revision: 29.10 $
|
## @(#) $Revision: 29.11 $
|
||||||
## @(#) $Id: README,v 29.10 2001/06/10 19:34:40 chongo Exp $
|
## @(#) $Id: README.src,v 29.11 2007/02/07 00:33:10 chongo Exp $
|
||||||
## @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/README,v $
|
## @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/README.src,v $
|
||||||
##
|
##
|
||||||
## Under source code control: 1999/12/17 10:23:40
|
## Under source code control: 1999/12/17 10:23:40
|
||||||
## File existed as early as: 1999
|
## File existed as early as: 1999
|
@@ -1,4 +1,4 @@
|
|||||||
#!/usr/local/src/cmd/calc/calc -q -s -f
|
#!/usr/local/src/cmd/calc/calc -q -f
|
||||||
/*
|
/*
|
||||||
* fproduct - write the big Endian product of terms to a file
|
* fproduct - write the big Endian product of terms to a file
|
||||||
*
|
*
|
||||||
@@ -24,8 +24,8 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.2 $
|
* @(#) $Revision: 29.3 $
|
||||||
* @(#) $Id: fproduct.calc,v 29.2 2001/06/06 09:06:29 chongo Exp $
|
* @(#) $Id: fproduct.calc,v 29.3 2007/02/07 00:34:04 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/fproduct.calc,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/fproduct.calc,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 2001/04/07 20:13:11
|
* Under source code control: 2001/04/07 20:13:11
|
||||||
|
@@ -1,35 +1,36 @@
|
|||||||
#!/usr/local/src/cmd/calc/calc -q -s -f
|
#!/usr/local/src/cmd/calc/calc -q -f
|
||||||
#
|
/*
|
||||||
# mersenne - print the value of a mersenne number
|
* mersenne - print the value of a mersenne number
|
||||||
#
|
*
|
||||||
# Copyright (C) 1999 Landon Curt Noll
|
* Copyright (C) 1999-2007 Landon Curt Noll
|
||||||
#
|
*
|
||||||
# Calc is open software; you can redistribute it and/or modify it under
|
* Calc is open software; you can redistribute it and/or modify it under
|
||||||
# the terms of the version 2.1 of the GNU Lesser General Public License
|
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
# as published by the Free Software Foundation.
|
* as published by the Free Software Foundation.
|
||||||
#
|
*
|
||||||
# Calc is distributed in the hope that it will be useful, but WITHOUT
|
* Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||||
# Public License for more details.
|
* Public License for more details.
|
||||||
#
|
*
|
||||||
# A copy of version 2.1 of the GNU Lesser General Public License is
|
* A copy of version 2.1 of the GNU Lesser General Public License is
|
||||||
# distributed with calc under the filename COPYING-LGPL. You should have
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#
|
*
|
||||||
# @(#) $Revision: 29.3 $
|
* @(#) $Revision: 29.4 $
|
||||||
# @(#) $Id: mersenne.calc,v 29.3 2000/12/15 14:56:54 chongo Exp $
|
* @(#) $Id: mersenne.calc,v 29.4 2007/02/07 00:34:04 chongo Exp $
|
||||||
# @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/mersenne.calc,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/mersenne.calc,v $
|
||||||
#
|
*
|
||||||
# Under source code control: 1999/11/30 00:09:01;
|
* Under source code control: 1999/11/30 00:09:01;
|
||||||
# File existed as early as: 1999
|
* File existed as early as: 1999
|
||||||
#
|
*
|
||||||
# chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||||
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||||
|
*
|
||||||
# usage:
|
* usage:
|
||||||
# mersenne exp
|
* mersenne exp
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -1,35 +1,36 @@
|
|||||||
#!/usr/local/src/cmd/calc/calc -q -f
|
#!/usr/local/src/cmd/calc/calc -q -f
|
||||||
#
|
/*
|
||||||
# piforever - print digits of pi forever (or as long as your mem/cpu allow)
|
* piforever - print digits of pi forever (or as long as your mem/cpu allow)
|
||||||
#
|
*
|
||||||
# Copyright (C) 1999 Landon Curt Noll
|
* Copyright (C) 1999-2007 Landon Curt Noll
|
||||||
#
|
*
|
||||||
# Calc is open software; you can redistribute it and/or modify it under
|
* Calc is open software; you can redistribute it and/or modify it under
|
||||||
# the terms of the version 2.1 of the GNU Lesser General Public License
|
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
# as published by the Free Software Foundation.
|
* as published by the Free Software Foundation.
|
||||||
#
|
*
|
||||||
# Calc is distributed in the hope that it will be useful, but WITHOUT
|
* Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||||
# Public License for more details.
|
* Public License for more details.
|
||||||
#
|
*
|
||||||
# A copy of version 2.1 of the GNU Lesser General Public License is
|
* A copy of version 2.1 of the GNU Lesser General Public License is
|
||||||
# distributed with calc under the filename COPYING-LGPL. You should have
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#
|
*
|
||||||
# @(#) $Revision: 29.3 $
|
* @(#) $Revision: 29.4 $
|
||||||
# @(#) $Id: piforever.calc,v 29.3 2000/12/15 14:56:54 chongo Exp $
|
* @(#) $Id: piforever.calc,v 29.4 2007/02/07 00:34:04 chongo Exp $
|
||||||
# @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/piforever.calc,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/piforever.calc,v $
|
||||||
#
|
*
|
||||||
# Under source code control: 1999/11/30 00:11:36
|
* Under source code control: 1999/11/30 00:11:36
|
||||||
# File existed as early as: 1999
|
* File existed as early as: 1999
|
||||||
#
|
*
|
||||||
# chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||||
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||||
|
*
|
||||||
# usage:
|
* usage:
|
||||||
# piforever
|
* piforever
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
read -once pi.cal
|
read -once pi.cal
|
||||||
|
@@ -1,35 +1,36 @@
|
|||||||
#!/usr/local/src/cmd/calc/calc -q -s -f
|
#!/usr/local/src/cmd/calc/calc -q -f
|
||||||
#
|
/*
|
||||||
# plus - add two or more arguments together
|
* plus - add two or more arguments together
|
||||||
#
|
*
|
||||||
# Copyright (C) 1999 Landon Curt Noll
|
* Copyright (C) 1999-2007 Landon Curt Noll
|
||||||
#
|
*
|
||||||
# Calc is open software; you can redistribute it and/or modify it under
|
* Calc is open software; you can redistribute it and/or modify it under
|
||||||
# the terms of the version 2.1 of the GNU Lesser General Public License
|
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
# as published by the Free Software Foundation.
|
* as published by the Free Software Foundation.
|
||||||
#
|
*
|
||||||
# Calc is distributed in the hope that it will be useful, but WITHOUT
|
* Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||||
# Public License for more details.
|
* Public License for more details.
|
||||||
#
|
*
|
||||||
# A copy of version 2.1 of the GNU Lesser General Public License is
|
* A copy of version 2.1 of the GNU Lesser General Public License is
|
||||||
# distributed with calc under the filename COPYING-LGPL. You should have
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#
|
*
|
||||||
# @(#) $Revision: 29.3 $
|
* @(#) $Revision: 29.4 $
|
||||||
# @(#) $Id: plus.calc,v 29.3 2000/12/15 14:56:54 chongo Exp $
|
* @(#) $Id: plus.calc,v 29.4 2007/02/07 00:34:04 chongo Exp $
|
||||||
# @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/plus.calc,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/plus.calc,v $
|
||||||
#
|
*
|
||||||
# Under source code control: 1999/11/29 10:22:37
|
* Under source code control: 1999/11/29 10:22:37
|
||||||
# File existed as early as: 1999
|
* File existed as early as: 1999
|
||||||
#
|
*
|
||||||
# chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||||
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||||
|
*
|
||||||
# usage:
|
* usage:
|
||||||
# plus val ...
|
* plus val ...
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
#!/usr/local/src/cmd/calc/calc -q -s -f
|
#!/usr/local/src/cmd/calc/calc -q -f
|
||||||
/*
|
/*
|
||||||
* powerterm - print the argument as a sum of powers of integers
|
* powerterm - print the argument as a sum of powers of integers
|
||||||
*
|
*
|
||||||
@@ -24,8 +24,8 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.6 $
|
* @(#) $Revision: 29.7 $
|
||||||
* @(#) $Id: powerterm.calc,v 29.6 2001/06/06 09:06:29 chongo Exp $
|
* @(#) $Id: powerterm.calc,v 29.7 2007/02/07 00:34:04 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/powerterm.calc,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/powerterm.calc,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 2001/04/24 23:49:11
|
* Under source code control: 2001/04/24 23:49:11
|
||||||
|
@@ -1,32 +1,33 @@
|
|||||||
#!/usr/local/src/cmd/calc/calc -q -f
|
#!/usr/local/src/cmd/calc/calc -q -f
|
||||||
#
|
/*
|
||||||
# simple - an example of a simple calc shell script
|
* simple - an example of a simple calc shell script
|
||||||
#
|
*
|
||||||
# Copyright (C) 1999 Landon Curt Noll
|
* Copyright (C) 1999-2007 Landon Curt Noll
|
||||||
#
|
*
|
||||||
# Calc is open software; you can redistribute it and/or modify it under
|
* Calc is open software; you can redistribute it and/or modify it under
|
||||||
# the terms of the version 2.1 of the GNU Lesser General Public License
|
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
# as published by the Free Software Foundation.
|
* as published by the Free Software Foundation.
|
||||||
#
|
*
|
||||||
# Calc is distributed in the hope that it will be useful, but WITHOUT
|
* Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||||
# Public License for more details.
|
* Public License for more details.
|
||||||
#
|
*
|
||||||
# A copy of version 2.1 of the GNU Lesser General Public License is
|
* A copy of version 2.1 of the GNU Lesser General Public License is
|
||||||
# distributed with calc under the filename COPYING-LGPL. You should have
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#
|
*
|
||||||
# @(#) $Revision: 29.3 $
|
* @(#) $Revision: 29.4 $
|
||||||
# @(#) $Id: simple.calc,v 29.3 2000/12/15 14:56:54 chongo Exp $
|
* @(#) $Id: simple.calc,v 29.4 2007/02/07 00:34:04 chongo Exp $
|
||||||
# @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/simple.calc,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/simple.calc,v $
|
||||||
#
|
*
|
||||||
# Under source code control: 1999/11/29 10:22:37
|
* Under source code control: 1999/11/29 10:22:37
|
||||||
# File existed as early as: 1999
|
* File existed as early as: 1999
|
||||||
#
|
*
|
||||||
# chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||||
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -1,64 +1,67 @@
|
|||||||
#!/usr/local/src/cmd/calc/calc -q -f
|
#!/usr/local/src/cmd/calc/calc -q -f
|
||||||
#
|
/*
|
||||||
# sqaure - print the squares of input values
|
* sqaure - print the squares of input values
|
||||||
#
|
*
|
||||||
# Copyright (C) 2000 Ernest Bowen
|
* Copyright (C) 2000-2007 Ernest Bowen
|
||||||
#
|
*
|
||||||
# Calc is open software; you can redistribute it and/or modify it under
|
* Calc is open software; you can redistribute it and/or modify it under
|
||||||
# the terms of the version 2.1 of the GNU Lesser General Public License
|
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
# as published by the Free Software Foundation.
|
* as published by the Free Software Foundation.
|
||||||
#
|
*
|
||||||
# Calc is distributed in the hope that it will be useful, but WITHOUT
|
* Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||||
# Public License for more details.
|
* Public License for more details.
|
||||||
#
|
*
|
||||||
# A copy of version 2.1 of the GNU Lesser General Public License is
|
* A copy of version 2.1 of the GNU Lesser General Public License is
|
||||||
# distributed with calc under the filename COPYING-LGPL. You should have
|
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#
|
*
|
||||||
# @(#) $Revision: 29.3 $
|
* @(#) $Revision: 29.4 $
|
||||||
# @(#) $Id: square.calc,v 29.3 2000/12/17 14:31:58 chongo Exp $
|
* @(#) $Id: square.calc,v 29.4 2007/02/07 00:34:04 chongo Exp $
|
||||||
# @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/square.calc,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/cscript/RCS/square.calc,v $
|
||||||
#
|
*
|
||||||
# Under source code control: 2000/12/15 06:52:01
|
* Under source code control: 2000/12/15 06:52:01
|
||||||
# File existed as early as: 2000
|
* File existed as early as: 2000
|
||||||
#
|
*
|
||||||
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Usage:
|
||||||
|
*
|
||||||
|
* From the shell:
|
||||||
|
*
|
||||||
|
* ./square
|
||||||
|
* cat file | ./square
|
||||||
|
* echo "123" | ./square
|
||||||
|
*
|
||||||
|
* Within calc:
|
||||||
|
*
|
||||||
|
* > read square
|
||||||
|
*
|
||||||
|
* With input from a terminal, there is no prompt but each non-empty
|
||||||
|
* line of input is evaluated as a calc expression and if it can be
|
||||||
|
* calculated, the square of the value of that expression is displayed.
|
||||||
|
* Execution stops when an empty line is input.
|
||||||
|
*
|
||||||
|
* From the shell:
|
||||||
|
*
|
||||||
|
* ./square
|
||||||
|
*
|
||||||
|
* The following shows lines of input followed by output:
|
||||||
|
*
|
||||||
|
* 1234
|
||||||
|
* 1522756
|
||||||
|
* ln(2)
|
||||||
|
* ~.48045301391820142467
|
||||||
|
* config("mode","frac"), bernoulli(10)
|
||||||
|
* 25/4356
|
||||||
|
* config("mode", "hex"), 0xff
|
||||||
|
* 0xfe01
|
||||||
|
*/
|
||||||
|
|
||||||
# Usage:
|
|
||||||
#
|
|
||||||
# From the shell:
|
|
||||||
#
|
|
||||||
# ./square
|
|
||||||
# cat file | ./square
|
|
||||||
# echo "123" | ./square
|
|
||||||
#
|
|
||||||
# Within calc:
|
|
||||||
#
|
|
||||||
# > read square
|
|
||||||
#
|
|
||||||
# With input from a terminal, there is no prompt but each non-empty
|
|
||||||
# line of input is evaluated as a calc expression and if it can be
|
|
||||||
# calculated, the square of the value of that expression is displayed.
|
|
||||||
# Execution stops when an empty line is input.
|
|
||||||
#
|
|
||||||
# From the shell:
|
|
||||||
#
|
|
||||||
# ./square
|
|
||||||
#
|
|
||||||
# The following shows lines of input followed by output:
|
|
||||||
#
|
|
||||||
# 1234
|
|
||||||
# 1522756
|
|
||||||
# ln(2)
|
|
||||||
# ~.48045301391820142467
|
|
||||||
# config("mode","frac"), bernoulli(10)
|
|
||||||
# 25/4356
|
|
||||||
# config("mode", "hex"), 0xff
|
|
||||||
# 0xfe01
|
|
||||||
#
|
|
||||||
|
|
||||||
global s;
|
global s;
|
||||||
while ((s = prompt("")))
|
while ((s = prompt("")))
|
||||||
|
7
help.c
7
help.c
@@ -17,8 +17,8 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.8 $
|
* @(#) $Revision: 29.9 $
|
||||||
* @(#) $Id: help.c,v 29.8 2001/04/08 08:29:28 chongo Exp $
|
* @(#) $Id: help.c,v 29.9 2007/02/07 00:37:52 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/help.c,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/RCS/help.c,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1997/09/14 10:58:30
|
* Under source code control: 1997/09/14 10:58:30
|
||||||
@@ -62,6 +62,8 @@ static struct help_alias {
|
|||||||
{".", "oldvalue"},
|
{".", "oldvalue"},
|
||||||
{"%", "mod"},
|
{"%", "mod"},
|
||||||
{"//", "quo"},
|
{"//", "quo"},
|
||||||
|
{"#", "pound"},
|
||||||
|
{"calc", "help"},
|
||||||
{"copy", "blkcpy"},
|
{"copy", "blkcpy"},
|
||||||
{"copying", "COPYING"},
|
{"copying", "COPYING"},
|
||||||
{"copying-lgpl", "COPYING-LGPL"},
|
{"copying-lgpl", "COPYING-LGPL"},
|
||||||
@@ -71,6 +73,7 @@ static struct help_alias {
|
|||||||
{"COPYRIGHT", "copyright"},
|
{"COPYRIGHT", "copyright"},
|
||||||
{"Copyleft", "copyright"},
|
{"Copyleft", "copyright"},
|
||||||
{"COPYLEFT", "copyright"},
|
{"COPYLEFT", "copyright"},
|
||||||
|
{"define", "command"},
|
||||||
{"read", "command"},
|
{"read", "command"},
|
||||||
{"write", "command"},
|
{"write", "command"},
|
||||||
{"quit", "command"},
|
{"quit", "command"},
|
||||||
|
@@ -18,8 +18,8 @@
|
|||||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#
|
#
|
||||||
# @(#) $Revision: 29.35 $
|
# @(#) $Revision: 29.36 $
|
||||||
# @(#) $Id: Makefile,v 29.35 2006/12/16 10:32:54 chongo Exp $
|
# @(#) $Id: Makefile,v 29.36 2007/02/07 00:31:06 chongo Exp $
|
||||||
# @(#) $Source: /usr/local/src/cmd/calc/help/RCS/Makefile,v $
|
# @(#) $Source: /usr/local/src/cmd/calc/help/RCS/Makefile,v $
|
||||||
#
|
#
|
||||||
# Under source code control: 1991/07/23 06:47:57
|
# Under source code control: 1991/07/23 06:47:57
|
||||||
@@ -169,7 +169,7 @@ SED= sed
|
|||||||
SORT= sort
|
SORT= sort
|
||||||
FMT= fmt
|
FMT= fmt
|
||||||
CMP= cmp
|
CMP= cmp
|
||||||
CP= cm
|
CP= cp
|
||||||
MV= mv
|
MV= mv
|
||||||
TRUE= true
|
TRUE= true
|
||||||
RM= rm
|
RM= rm
|
||||||
@@ -214,9 +214,9 @@ STD_HELP_FILES_8= operator statement
|
|||||||
|
|
||||||
BLT_HELP_FILES_9= resource
|
BLT_HELP_FILES_9= resource
|
||||||
|
|
||||||
STD_HELP_FILES_10= types usage script
|
STD_HELP_FILES_10= types script
|
||||||
|
|
||||||
BLT_HELP_FILES_10a= cscript
|
BLT_HELP_FILES_10a= usage cscript
|
||||||
|
|
||||||
STD_HELP_FILES_10b= unexpected variable
|
STD_HELP_FILES_10b= unexpected variable
|
||||||
|
|
||||||
@@ -292,9 +292,9 @@ DETAIL_HELP= abs access acos acosh acot acoth acsc acsch address agd append \
|
|||||||
ln log lowbit ltol makelist matdim matfill matmax matmin matsum \
|
ln log lowbit ltol makelist matdim matfill matmax matmin matsum \
|
||||||
mattrace mattrans max md5 memsize meq min minv mmin mne mod modify \
|
mattrace mattrans max md5 memsize meq min minv mmin mne mod modify \
|
||||||
name near newerror nextcand nextprime norm null num oldvalue ord \
|
name near newerror nextcand nextprime norm null num oldvalue ord \
|
||||||
param perm pfact pi pix places pmod polar poly pop popcnt power \
|
param perm pfact pi pix places pmod polar poly pop popcnt pound \
|
||||||
prevcand prevprime printf prompt protect ptest push putenv quo \
|
power prevcand prevprime printf prompt protect ptest push putenv \
|
||||||
quomod rand randbit random randombit randperm rcin rcmul rcout \
|
quo quomod rand randbit random randombit randperm rcin rcmul rcout \
|
||||||
rcpow rcsq re remove reverse rewind rm root round rsearch runtime \
|
rcpow rcsq re remove reverse rewind rm root round rsearch runtime \
|
||||||
saveval scale scan scanf search sec sech seed segment select sgn \
|
saveval scale scan scanf search sec sech seed segment select sgn \
|
||||||
sha sha1 sin sinh size sizeof sleep sort sqrt srand srandom ssq \
|
sha sha1 sin sinh size sizeof sleep sort sqrt srand srandom ssq \
|
||||||
@@ -325,7 +325,7 @@ DISTLIST= ${STD_HELP_FILES} ${DETAIL_HELP} ${MAKE_FILE} \
|
|||||||
CALCLIBLIST=
|
CALCLIBLIST=
|
||||||
|
|
||||||
all: ${FULL_HELP_FILES} full ${DETAIL_HELP} ${DETAIL_CLONE} \
|
all: ${FULL_HELP_FILES} full ${DETAIL_HELP} ${DETAIL_CLONE} \
|
||||||
${SINGULAR_FILES} calc .all
|
${SINGULAR_FILES} .all
|
||||||
|
|
||||||
# used by the upper level Makefile to determine of we have done all
|
# used by the upper level Makefile to determine of we have done all
|
||||||
#
|
#
|
||||||
@@ -410,9 +410,9 @@ errorcodes: ../calcerr.h errorcodes.hdr errorcodes.sed
|
|||||||
${TRUE}; \
|
${TRUE}; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
calc: usage
|
usage: ../calc.usage
|
||||||
${RM} -f $@
|
${RM} -f $@
|
||||||
${CP} usage $@
|
${CP} ../calc.usage $@
|
||||||
${CHMOD} 0444 $@
|
${CHMOD} 0444 $@
|
||||||
-@if [ -z "${Q}" ]; then \
|
-@if [ -z "${Q}" ]; then \
|
||||||
echo ''; \
|
echo ''; \
|
||||||
@@ -422,6 +422,9 @@ calc: usage
|
|||||||
${TRUE}; \
|
${TRUE}; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
../calc.usage:
|
||||||
|
(cd ..; $(MAKE) calc.usage)
|
||||||
|
|
||||||
custom_cal: ../custom/CUSTOM_CAL
|
custom_cal: ../custom/CUSTOM_CAL
|
||||||
${RM} -f $@
|
${RM} -f $@
|
||||||
${CP} ../custom/CUSTOM_CAL $@
|
${CP} ../custom/CUSTOM_CAL $@
|
||||||
@@ -494,6 +497,11 @@ cscript: ../cscript/README
|
|||||||
${TRUE}; \
|
${TRUE}; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
../cscript/README: ../cscript/README.src
|
||||||
|
${Q} echo "forming cscript/README"
|
||||||
|
-${Q} ${RM} -f $@
|
||||||
|
(cd ../cscript; $(MAKE) README)
|
||||||
|
|
||||||
full: ${FULL_HELP_FILES} ${MAKE_FILE}
|
full: ${FULL_HELP_FILES} ${MAKE_FILE}
|
||||||
${Q} echo "forming full"
|
${Q} echo "forming full"
|
||||||
-${Q} ${RM} -f $@
|
-${Q} ${RM} -f $@
|
||||||
|
36
help/help
36
help/help
@@ -51,15 +51,6 @@ following topics:
|
|||||||
|
|
||||||
full all of the above (in the above order)
|
full all of the above (in the above order)
|
||||||
|
|
||||||
You can also ask for help on a particular function name. For example,
|
|
||||||
|
|
||||||
help asinh
|
|
||||||
help round
|
|
||||||
|
|
||||||
or on a particular symbol such as:
|
|
||||||
|
|
||||||
help =
|
|
||||||
|
|
||||||
For example:
|
For example:
|
||||||
|
|
||||||
help usage
|
help usage
|
||||||
@@ -71,6 +62,27 @@ without invoking any startup code by running calc as follows:
|
|||||||
|
|
||||||
where 'topic' is one of the topics listed above.
|
where 'topic' is one of the topics listed above.
|
||||||
|
|
||||||
|
You can also ask for help on a particular builtin function name. For example:
|
||||||
|
|
||||||
|
help asinh
|
||||||
|
help round
|
||||||
|
|
||||||
|
See:
|
||||||
|
|
||||||
|
help builtin
|
||||||
|
|
||||||
|
for a list of builtin functions.
|
||||||
|
|
||||||
|
Some calc operators have their own help pages:
|
||||||
|
|
||||||
|
help =
|
||||||
|
help ->
|
||||||
|
help *
|
||||||
|
help .
|
||||||
|
help %
|
||||||
|
help //
|
||||||
|
help #
|
||||||
|
|
||||||
If the -m mode disallows opening files for reading or execution of programs,
|
If the -m mode disallows opening files for reading or execution of programs,
|
||||||
then the help facility will be disabled. See:
|
then the help facility will be disabled. See:
|
||||||
|
|
||||||
@@ -103,7 +115,7 @@ as the same effect as:
|
|||||||
|
|
||||||
custom("help", "anything");
|
custom("help", "anything");
|
||||||
|
|
||||||
## Copyright (C) 1999 Landon Curt Noll
|
## Copyright (C) 1999-2007 Landon Curt Noll
|
||||||
##
|
##
|
||||||
## Calc is open software; you can redistribute it and/or modify it under
|
## Calc is open software; you can redistribute it and/or modify it under
|
||||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -119,8 +131,8 @@ as the same effect as:
|
|||||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||||
##
|
##
|
||||||
## @(#) $Revision: 29.3 $
|
## @(#) $Revision: 29.4 $
|
||||||
## @(#) $Id: help,v 29.3 2000/06/07 14:02:33 chongo Exp $
|
## @(#) $Id: help,v 29.4 2007/02/07 00:30:04 chongo Exp $
|
||||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/help,v $
|
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/help,v $
|
||||||
##
|
##
|
||||||
## Under source code control: 1991/07/21 04:37:20
|
## Under source code control: 1991/07/21 04:37:20
|
||||||
|
127
help/pound
Normal file
127
help/pound
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
NAME
|
||||||
|
#
|
||||||
|
|
||||||
|
SYNOPSIS
|
||||||
|
#!/usr/local/src/cmd/calc/calc -q -f
|
||||||
|
# x
|
||||||
|
x # y
|
||||||
|
## comment
|
||||||
|
|
||||||
|
TYPES
|
||||||
|
x, y integer or real
|
||||||
|
|
||||||
|
return integer (uniary operator case)
|
||||||
|
integer or real (binary operator case)
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
The pound sign or sharp sign "#" has special meaning in calc.
|
||||||
|
|
||||||
|
As a uniary operator:
|
||||||
|
|
||||||
|
# value
|
||||||
|
|
||||||
|
returns the number of 1 bits, or pop-count of the absolute value of
|
||||||
|
the numerator (abs(num(value))). Therefore when x is a non-negative
|
||||||
|
integer , # x is the pop-count of x. And thus when x is a negative
|
||||||
|
integer, # x returns the pop-count of abs(x). And in the general
|
||||||
|
case when x is a real, # x returns the pop-count of abs(num(x)).
|
||||||
|
|
||||||
|
As a binary operator:
|
||||||
|
|
||||||
|
x # y
|
||||||
|
|
||||||
|
returns abs(x-y), the absolute value of the difference.
|
||||||
|
|
||||||
|
When two or more pound signs in a row start a comment:
|
||||||
|
|
||||||
|
## this is a comment
|
||||||
|
### this is also a comment
|
||||||
|
print "this will print"; ## but this will not because it is a comment
|
||||||
|
|
||||||
|
A pound sign followed by a bang also starts a comment:
|
||||||
|
|
||||||
|
#! strictly speaking, this is a comment
|
||||||
|
print "this is correct but not recommended" #! acts like ##
|
||||||
|
|
||||||
|
On POSIX / Un*X / Linux / BSD conforming systems, when an executable
|
||||||
|
starts with the two bytes # and !, the remainder of the 1st line
|
||||||
|
(up to an operating system imposed limit) is taken to be the path
|
||||||
|
to the shell (plus shell arguments) that is to be executed. The
|
||||||
|
kernel appends the filename of the executable as a final argument
|
||||||
|
to the shell.
|
||||||
|
|
||||||
|
For example, of an executable file contains:
|
||||||
|
|
||||||
|
#!/usr/local/src/cmd/calc/calc -q -f
|
||||||
|
/* NOTE: The #! above must start in column 1 of the 1st line */
|
||||||
|
/* The 1st line must end with -f */
|
||||||
|
## Single # shell comments don't work, use two or more
|
||||||
|
print "2+2 =", 2+2;
|
||||||
|
|
||||||
|
When the above file it is executed by the kernel, it will print:
|
||||||
|
|
||||||
|
2+2 = 4
|
||||||
|
|
||||||
|
Such files are known to calc as cscripts. See "help cscript"
|
||||||
|
for examples.
|
||||||
|
|
||||||
|
It is suggested that the -q be added to the first line to
|
||||||
|
disable the reading of the startup scripts. It is not mandatory.
|
||||||
|
|
||||||
|
The last argument of the first line must be -f without the filename
|
||||||
|
because the kernel will supply the cscript filename as a final
|
||||||
|
argument. The final -f also implies -s. See "help usage" for
|
||||||
|
more information.
|
||||||
|
|
||||||
|
|
||||||
|
EXAMPLE
|
||||||
|
; #3
|
||||||
|
2
|
||||||
|
; #3.5
|
||||||
|
3
|
||||||
|
; 4 # 5
|
||||||
|
1
|
||||||
|
; 5 # 4
|
||||||
|
1
|
||||||
|
|
||||||
|
; pi() # exp(1)
|
||||||
|
0.4233108251307480031
|
||||||
|
; exp(1) # pi()
|
||||||
|
0.4233108251307480031
|
||||||
|
|
||||||
|
; ## this is a comment
|
||||||
|
|
||||||
|
LIMITS
|
||||||
|
none
|
||||||
|
|
||||||
|
LINK LIBRARY
|
||||||
|
none
|
||||||
|
|
||||||
|
SEE ALSO
|
||||||
|
cscript, unexpected, usage
|
||||||
|
|
||||||
|
## Copyright (C) 2007 Landon Curt Noll
|
||||||
|
##
|
||||||
|
## Calc is open software; you can redistribute it and/or modify it under
|
||||||
|
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
|
## as published by the Free Software Foundation.
|
||||||
|
##
|
||||||
|
## Calc 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 Lesser General
|
||||||
|
## Public License for more details.
|
||||||
|
##
|
||||||
|
## A copy of version 2.1 of the GNU Lesser General Public License is
|
||||||
|
## distributed with calc under the filename COPYING-LGPL. You should have
|
||||||
|
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
|
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
##
|
||||||
|
## @(#) $Revision: 29.1 $
|
||||||
|
## @(#) $Id: pound,v 29.1 2007/02/06 23:48:15 chongo Exp $
|
||||||
|
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/pound,v $
|
||||||
|
##
|
||||||
|
## Under source code control: 2007/02/06 14:09
|
||||||
|
## File existed as early as: 2007
|
||||||
|
##
|
||||||
|
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||||
|
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
@@ -291,12 +291,36 @@ Statements
|
|||||||
|
|
||||||
Also see the help topic:
|
Also see the help topic:
|
||||||
|
|
||||||
command top level commands
|
help command top level commands
|
||||||
expression calc expression syntax
|
help expression calc expression syntax
|
||||||
builtin calc builtin functions
|
help builtin calc builtin functions
|
||||||
usage how to invoke the calc command and calc -options
|
help usage how to invoke the calc command and calc -options
|
||||||
|
|
||||||
## Copyright (C) 1999-2006 Landon Curt Noll
|
You may obtain help on individual builtin functions. For example:
|
||||||
|
|
||||||
|
help asinh
|
||||||
|
help round
|
||||||
|
|
||||||
|
See:
|
||||||
|
help builtin
|
||||||
|
|
||||||
|
for a list of builtin functions.
|
||||||
|
|
||||||
|
Some calc operators have their own help pages:
|
||||||
|
|
||||||
|
help ->
|
||||||
|
help *
|
||||||
|
help .
|
||||||
|
help %
|
||||||
|
help //
|
||||||
|
help #
|
||||||
|
|
||||||
|
See also:
|
||||||
|
|
||||||
|
help help
|
||||||
|
|
||||||
|
|
||||||
|
## Copyright (C) 1999-2007 Landon Curt Noll
|
||||||
##
|
##
|
||||||
## Calc is open software; you can redistribute it and/or modify it under
|
## Calc is open software; you can redistribute it and/or modify it under
|
||||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
## the terms of the version 2.1 of the GNU Lesser General Public License
|
||||||
@@ -312,8 +336,8 @@ Statements
|
|||||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||||
##
|
##
|
||||||
## @(#) $Revision: 29.3 $
|
## @(#) $Revision: 29.4 $
|
||||||
## @(#) $Id: statement,v 29.3 2007/01/03 21:26:22 chongo Exp $
|
## @(#) $Id: statement,v 29.4 2007/02/07 00:29:06 chongo Exp $
|
||||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/statement,v $
|
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/statement,v $
|
||||||
##
|
##
|
||||||
## Under source code control: 1991/07/21 04:37:23
|
## Under source code control: 1991/07/21 04:37:23
|
||||||
|
@@ -248,6 +248,29 @@ Unexpected
|
|||||||
In addition to the C style /* comment lines */, lines that begin with
|
In addition to the C style /* comment lines */, lines that begin with
|
||||||
#! are treated as comments.
|
#! are treated as comments.
|
||||||
|
|
||||||
|
A single # is an calc operator, not a comment. However two or more
|
||||||
|
##'s in a row is a comment. See "help pound" for more information.
|
||||||
|
|
||||||
|
#!/usr/local/src/cmd/calc/calc -q -f
|
||||||
|
|
||||||
|
/* a correct comment */
|
||||||
|
## another correct comment
|
||||||
|
### two or more together is also a comment
|
||||||
|
/*
|
||||||
|
* another correct comment
|
||||||
|
*/
|
||||||
|
print "2+2 =", 2+2; ## yet another comment
|
||||||
|
|
||||||
|
This next example is WRONG:
|
||||||
|
|
||||||
|
#!/usr/local/src/cmd/calc/calc -q -f
|
||||||
|
|
||||||
|
# This is not a calc calc comment because it has only a single #
|
||||||
|
# You must to start comments with ## or /*
|
||||||
|
print "This example has invalid comments"
|
||||||
|
|
||||||
|
See "help cscript" and "help usage" for more information.
|
||||||
|
|
||||||
|
|
||||||
The { must be on the same line as an if, for, while or do
|
The { must be on the same line as an if, for, while or do
|
||||||
=========================================================
|
=========================================================
|
||||||
@@ -312,8 +335,8 @@ Unexpected
|
|||||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||||
##
|
##
|
||||||
## @(#) $Revision: 29.3 $
|
## @(#) $Revision: 29.4 $
|
||||||
## @(#) $Id: unexpected,v 29.3 2007/01/03 21:26:22 chongo Exp $
|
## @(#) $Id: unexpected,v 29.4 2007/02/07 00:30:33 chongo Exp $
|
||||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/unexpected,v $
|
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/unexpected,v $
|
||||||
##
|
##
|
||||||
## Under source code control: 1997/03/21 13:15:18
|
## Under source code control: 1997/03/21 13:15:18
|
||||||
|
370
help/usage
370
help/usage
@@ -1,370 +0,0 @@
|
|||||||
Calc command line
|
|
||||||
|
|
||||||
Calc has the following command line:
|
|
||||||
|
|
||||||
calc [-c] [-C] [-d] [-D calc_debug[:resource_debug[:user_debug]]]
|
|
||||||
[-e] [-h] [-i] [-m mode] [-n] [-p] [-q] [-s] [-u] [-v]
|
|
||||||
[calc_cmd ...]
|
|
||||||
|
|
||||||
#!/usr/local/bin/calc -S [other_flags]
|
|
||||||
|
|
||||||
-c Continue reading command lines even after an scan/parse
|
|
||||||
error has caused the abandonment of a line. Note that this
|
|
||||||
option only deals with scanning and parsing of the calc
|
|
||||||
language. It does not deal with execution or run-time errors.
|
|
||||||
|
|
||||||
For example:
|
|
||||||
|
|
||||||
calc read many_errors.cal
|
|
||||||
|
|
||||||
will cause calc to abort on the first syntax error, whereas:
|
|
||||||
|
|
||||||
calc -c read many_errors.cal
|
|
||||||
|
|
||||||
will cause calc to try to process each line being read
|
|
||||||
despite the scan/parse errors that it encounters.
|
|
||||||
|
|
||||||
By default, calc startup resource files are
|
|
||||||
silently ignored if not found. This flag will report
|
|
||||||
missing startup scripts unless -d is also given.
|
|
||||||
|
|
||||||
|
|
||||||
-C Permit the execution of custom builtin functions.
|
|
||||||
Without this flag, calling the custom() builtin
|
|
||||||
function will simply generate an error.
|
|
||||||
|
|
||||||
Use of this flag may cause calc to execute functions
|
|
||||||
that are non-standard and that are not portable.
|
|
||||||
Custom builtin functions are disabled by default for
|
|
||||||
this reason.
|
|
||||||
|
|
||||||
|
|
||||||
-d Disable the printing of the opening title. The
|
|
||||||
printing of resource file debug and informational messages is
|
|
||||||
also disabled as if config("resource_debug", 0) had been
|
|
||||||
executed.
|
|
||||||
|
|
||||||
For example:
|
|
||||||
|
|
||||||
calc 'read qtime; qtime(2)'
|
|
||||||
|
|
||||||
will output something like:
|
|
||||||
|
|
||||||
qtime(utc_hr_offset) defined
|
|
||||||
It's nearly ten past six.
|
|
||||||
|
|
||||||
whereas:
|
|
||||||
|
|
||||||
calc -d 'read qtime; qtime(2)'
|
|
||||||
|
|
||||||
will just say:
|
|
||||||
|
|
||||||
It's nearly ten past six.
|
|
||||||
|
|
||||||
This flag disables the reporting of missing calc
|
|
||||||
startup scripts.
|
|
||||||
|
|
||||||
|
|
||||||
-D calc_debug[:resource_debug:[user_debug]]
|
|
||||||
Force the initial value of config("calc_debug"),
|
|
||||||
config("resource_debug") and config("user_debug").
|
|
||||||
|
|
||||||
The : separated strings are interpreted as signed 32
|
|
||||||
bit integers. After an optional leading sign a leading
|
|
||||||
zero indicates octal conversion, and a leading ``0x''
|
|
||||||
or ``0X'' hexadecimal conversion. Otherwise, decimal
|
|
||||||
conversion is assumed.
|
|
||||||
|
|
||||||
By default, calc_debug is 0, resource_debug is 3 and
|
|
||||||
user_debug is 0.
|
|
||||||
|
|
||||||
For more information use the following calc command:
|
|
||||||
|
|
||||||
help config
|
|
||||||
|
|
||||||
|
|
||||||
-e Ignore any environment variables on startup. The
|
|
||||||
getenv() builtin will still return values, however.
|
|
||||||
|
|
||||||
|
|
||||||
-h Print a help message. This option implies -q. This is
|
|
||||||
equivalent to the calc command help help. The help
|
|
||||||
facility is disabled unless the mode is 5 or 7. See
|
|
||||||
-m.
|
|
||||||
|
|
||||||
|
|
||||||
-i Become interactive if possible. If calc_cmd args are given,
|
|
||||||
by default, calc will execute them and exit. This flag causes
|
|
||||||
calc to drop into interactive mode after the commands are
|
|
||||||
executed.
|
|
||||||
|
|
||||||
For example:
|
|
||||||
|
|
||||||
calc 2+5
|
|
||||||
|
|
||||||
will print the value 7 and exit whereas:
|
|
||||||
|
|
||||||
calc -i 2+5
|
|
||||||
|
|
||||||
will print the value 7 and prompt the user for more
|
|
||||||
calc commands.
|
|
||||||
|
|
||||||
|
|
||||||
-m mode
|
|
||||||
This flag sets the permission mode of calc. It
|
|
||||||
controls the ability for calc to open files and execute
|
|
||||||
programs. Mode may be a number from 0 to 7.
|
|
||||||
|
|
||||||
The mode value is interpreted in a way similar to that
|
|
||||||
of the chmod(1) octal mode:
|
|
||||||
|
|
||||||
0 do not open any file, do not execute progs
|
|
||||||
1 do not open any file
|
|
||||||
2 do not open files for reading, do not execute progs
|
|
||||||
3 do not open files for reading
|
|
||||||
4 do not open files for writing, do not execute progs
|
|
||||||
5 do not open files for writing
|
|
||||||
6 do not execute any program
|
|
||||||
7 allow everything (default mode)
|
|
||||||
|
|
||||||
If one wished to run calc from a privileged user, one
|
|
||||||
might want to use -m 0 in an effort to make calc
|
|
||||||
somewhat more secure.
|
|
||||||
|
|
||||||
Mode bits for reading and writing apply only on an
|
|
||||||
open. Files already open are not effected. Thus if
|
|
||||||
one wanted to use the -m 0 in an effort to make calc
|
|
||||||
somewhat more secure, but still wanted to read and
|
|
||||||
write a specific file, one might want to do in sh(1),
|
|
||||||
ksh(1), bash(1)-like shells:
|
|
||||||
|
|
||||||
calc -m 0 3<a.file
|
|
||||||
|
|
||||||
Files presented to calc in this way are opened in an
|
|
||||||
unknown mode. Calc will attempt to read or write them
|
|
||||||
if directed.
|
|
||||||
|
|
||||||
If the mode disables opening of files for reading, then
|
|
||||||
the startup resource files are disabled as if -q was
|
|
||||||
given. The reading of key bindings is also disabled
|
|
||||||
when the mode disables opening of files for reading.
|
|
||||||
|
|
||||||
|
|
||||||
-O Use the old classic defaults instead of the default
|
|
||||||
configuration. This flag as the same effect as executing
|
|
||||||
config("all", "oldcfg") at startup time.
|
|
||||||
|
|
||||||
NOTE: Older versions of calc used -n to setup a modified
|
|
||||||
form of the default calc configuration. The -n flag
|
|
||||||
currently does nothing. Use of the -n flag is now
|
|
||||||
deprecated and may used for something else in the future.
|
|
||||||
|
|
||||||
-p Pipe processing is enabled by use of -p. For example:
|
|
||||||
|
|
||||||
calc -p '2^21701-1' | fizzbin
|
|
||||||
|
|
||||||
In pipe mode, calc does not prompt, does not print
|
|
||||||
leading tabs and does not print the initial header.
|
|
||||||
The -p flag overrides -i.
|
|
||||||
|
|
||||||
|
|
||||||
-q Disable the reading of the startup scripts.
|
|
||||||
|
|
||||||
|
|
||||||
-s By default, all calc_cmd args are evaluated and
|
|
||||||
executed. This flag will disable their evaluation and
|
|
||||||
instead make them available as strings for the argv()
|
|
||||||
builtin function.
|
|
||||||
|
|
||||||
|
|
||||||
-u Disable buffering of stdin and stdout.
|
|
||||||
|
|
||||||
|
|
||||||
-v Print the calc version number and exit.
|
|
||||||
|
|
||||||
|
|
||||||
CALC COMMAND ARGUMENTS
|
|
||||||
|
|
||||||
With no calc_cmd arguments, calc operates interactively. If one
|
|
||||||
or more arguments are given on the command line and -s is NOT
|
|
||||||
given, then calc will read and execute them and either attempt
|
|
||||||
to go interactive according as the -i flag was present or absent.
|
|
||||||
|
|
||||||
If -s is given, calc will not evaluate any calc_cmd
|
|
||||||
arguments but instead make them available as strings to the
|
|
||||||
argv() builtin function.
|
|
||||||
|
|
||||||
Sufficiently simple commands with no no characters like
|
|
||||||
parentheses, brackets, semicolons, '*', which have special
|
|
||||||
interpretations in UNIX commands may be entered, possibly with
|
|
||||||
spaces, until the terminating newline. For example:
|
|
||||||
|
|
||||||
calc 23 + 47
|
|
||||||
|
|
||||||
should respond with display of 70, but:
|
|
||||||
|
|
||||||
calc 23 * 47
|
|
||||||
|
|
||||||
may fail. Such cases can usually be made to work as expected by
|
|
||||||
enclosing the command between single quotation marks as in:
|
|
||||||
|
|
||||||
calc '23 * 47'
|
|
||||||
|
|
||||||
and
|
|
||||||
|
|
||||||
calc 'print sqrt(2), exp(1)'
|
|
||||||
|
|
||||||
If '!' is to be used to indicate the factorial function, for
|
|
||||||
shells like csh for which '!' followed by a non-space character
|
|
||||||
is used for history substitution, it may be necessary to
|
|
||||||
include a space or use a backslash to escape the special
|
|
||||||
meaning of '!'. For example, the command "print 27!^2" may have
|
|
||||||
to be replaced by "print 27! ^2" or "print 27\!^2".
|
|
||||||
|
|
||||||
|
|
||||||
CALC STARTUP FILES
|
|
||||||
|
|
||||||
Normally on startup, if the environment variable $CALCRC is
|
|
||||||
undefined and calc is invoked without the -q flag, or if
|
|
||||||
$CALCRC is defined and calc is invoked with -e, calc looks
|
|
||||||
for a file "startup" in the calc resource directory, .calcrc in
|
|
||||||
the user's home directory, and .calcinit in the current directory.
|
|
||||||
If one or more of these are found, they are read in succession
|
|
||||||
as calc scripts and their commands executed. When defined,
|
|
||||||
$CALCRC is to contain a ':' separated list of names of files,
|
|
||||||
and if calc is then invoked without either the -q or -e flags,
|
|
||||||
these files are read in succession and their commands executed.
|
|
||||||
No error condition is produced if a listed file is not found.
|
|
||||||
|
|
||||||
If the mode specified by -m disables opening of files for
|
|
||||||
reading, then the reading of startup files is also disabled
|
|
||||||
as if -q was given.
|
|
||||||
|
|
||||||
|
|
||||||
CALC FILE SEARCH PATH
|
|
||||||
|
|
||||||
If the environment variable $CALCPATH is undefined, or if it
|
|
||||||
is defined and calc is invoked with the -e flag, when a file
|
|
||||||
name not beginning with /, ~ or ./, is specified as in:
|
|
||||||
|
|
||||||
calc read myfile
|
|
||||||
|
|
||||||
calc searches in succession:
|
|
||||||
|
|
||||||
./myfile
|
|
||||||
./myfile.cal
|
|
||||||
${LIBDIR}/myfile
|
|
||||||
${LIBDIR}/myfile.cal
|
|
||||||
${CUSTOMCALDIR}/myfile
|
|
||||||
${CUSTOMCALDIR}/myfile.cal
|
|
||||||
|
|
||||||
If the file is found, the search stops and the commands in
|
|
||||||
the file are executed. It is an error if no readable file
|
|
||||||
with the specified name is found. An alternative search
|
|
||||||
path can be specified by defining $CALCPATH in the same way
|
|
||||||
as PATH is defined, as a ':' separated list of directories,
|
|
||||||
and then invoking calc without the -e flag.
|
|
||||||
|
|
||||||
Calc treats all open files, other than stdin, stdout and
|
|
||||||
stderr as files available for reading and writing. One may
|
|
||||||
present calc with an already open file using sh(1), ksh(1),
|
|
||||||
bash(1)-like shells is to:
|
|
||||||
|
|
||||||
calc 3<open_file 4<open_file2
|
|
||||||
|
|
||||||
|
|
||||||
SHELL SCRIPT MODE
|
|
||||||
|
|
||||||
If first line of an executable file begins #! followed by the
|
|
||||||
absolute pathname of the calc program and the flag -S as in
|
|
||||||
|
|
||||||
#!/usr/local/bin/calc -S [other_flags]
|
|
||||||
|
|
||||||
the rest of the file will be processed in shell script mode.
|
|
||||||
Note that -S (UPPER CASE S) must be the first -flag on the
|
|
||||||
``#!'' line. Any optional ``other_flags'' must come after
|
|
||||||
the -S.
|
|
||||||
|
|
||||||
In shell script mode the contents of the file are read and
|
|
||||||
executed as if they were in a file being processed by a read
|
|
||||||
command, except that a "command" beginning with '#' followed by
|
|
||||||
whitespace and ending at the next newline is treated as a comment.
|
|
||||||
Any optional ``other_flags'' will be parsed first followed by
|
|
||||||
the later lines within the script itself.
|
|
||||||
|
|
||||||
In shell script mode, -s (lower case s) is always assumed.
|
|
||||||
In addition, -d and -p are automatically set if -i is not
|
|
||||||
given.
|
|
||||||
|
|
||||||
For example, if the file /tmp/mersenne:
|
|
||||||
|
|
||||||
#!/usr/local/bin/calc -S -q
|
|
||||||
#
|
|
||||||
# mersenne - an example of a calc shell script file
|
|
||||||
|
|
||||||
/* parse args */
|
|
||||||
if (argv() != 1) {
|
|
||||||
fprintf(files(2), "usage: %s exp\n", config("program"));
|
|
||||||
abort "must give one exponent arg";
|
|
||||||
}
|
|
||||||
|
|
||||||
/* print the mersenne number */
|
|
||||||
print "2^": argv(0) : "-1 =", 2^eval(argv(0))-1;
|
|
||||||
|
|
||||||
is made an executable file by:
|
|
||||||
|
|
||||||
chmod +x /tmp/mersenne
|
|
||||||
|
|
||||||
then the command line:
|
|
||||||
|
|
||||||
/tmp/mersenne 127
|
|
||||||
|
|
||||||
will print:
|
|
||||||
|
|
||||||
2^127-1 = 170141183460469231731687303715884105727
|
|
||||||
|
|
||||||
Note that because -s is assumed in shell script mode and
|
|
||||||
non-dashed args are made available as strings via the argv()
|
|
||||||
builtin function. Therefore:
|
|
||||||
|
|
||||||
2^eval(argv(0))-1
|
|
||||||
|
|
||||||
will print the decimal value of 2^n-1 but
|
|
||||||
|
|
||||||
2^argv(0)-1
|
|
||||||
|
|
||||||
will not.
|
|
||||||
|
|
||||||
For more information use the following calc commands:
|
|
||||||
|
|
||||||
help help
|
|
||||||
help overview
|
|
||||||
help config
|
|
||||||
help argv
|
|
||||||
help environment
|
|
||||||
|
|
||||||
## Copyright (C) 1999 Landon Curt Noll
|
|
||||||
##
|
|
||||||
## Calc is open software; you can redistribute it and/or modify it under
|
|
||||||
## the terms of the version 2.1 of the GNU Lesser General Public License
|
|
||||||
## as published by the Free Software Foundation.
|
|
||||||
##
|
|
||||||
## Calc 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 Lesser General
|
|
||||||
## Public License for more details.
|
|
||||||
##
|
|
||||||
## A copy of version 2.1 of the GNU Lesser General Public License is
|
|
||||||
## distributed with calc under the filename COPYING-LGPL. You should have
|
|
||||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
|
||||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
|
||||||
##
|
|
||||||
## @(#) $Revision: 29.8 $
|
|
||||||
## @(#) $Id: usage,v 29.8 2006/06/01 12:04:16 chongo Exp $
|
|
||||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/usage,v $
|
|
||||||
##
|
|
||||||
## Under source code control: 1991/07/21 04:37:25
|
|
||||||
## File existed as early as: 1991
|
|
||||||
##
|
|
||||||
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
|
||||||
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
|
@@ -19,8 +19,8 @@
|
|||||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*
|
*
|
||||||
* @(#) $Revision: 29.72 $
|
* @(#) $Revision: 29.74 $
|
||||||
* @(#) $Id: version.c,v 29.72 2007/01/03 21:27:55 chongo Exp $
|
* @(#) $Id: version.c,v 29.74 2007/02/07 01:37:07 chongo Exp $
|
||||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/version.c,v $
|
* @(#) $Source: /usr/local/src/cmd/calc/RCS/version.c,v $
|
||||||
*
|
*
|
||||||
* Under source code control: 1990/05/22 11:00:58
|
* Under source code control: 1990/05/22 11:00:58
|
||||||
@@ -48,7 +48,7 @@ static char *program;
|
|||||||
#define MAJOR_VER 2 /* major version */
|
#define MAJOR_VER 2 /* major version */
|
||||||
#define MINOR_VER 12 /* minor version */
|
#define MINOR_VER 12 /* minor version */
|
||||||
#define MAJOR_PATCH 1 /* patch level or 0 if no patch */
|
#define MAJOR_PATCH 1 /* patch level or 0 if no patch */
|
||||||
#define MINOR_PATCH 6 /* test number or 0 if no minor patch */
|
#define MINOR_PATCH 8 /* test number or 0 if no minor patch */
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user