Compare commits

...

4 Commits

Author SHA1 Message Date
Landon Curt Noll
7d0b761de3 Release calc version 2.11.0t9.4.3 2017-05-21 15:38:33 -07:00
Landon Curt Noll
82ff31f246 Release calc version 2.11.0t9.4.2 2017-05-21 15:38:32 -07:00
Landon Curt Noll
7cb0a77c25 Release calc version 2.11.0t9.4.1 2017-05-21 15:38:32 -07:00
Landon Curt Noll
afb0e5c32a Release calc version 2.11.0t9.4 2017-05-21 15:38:32 -07:00
84 changed files with 1049 additions and 587 deletions

57
BUGS
View File

@@ -24,7 +24,7 @@ To be sure that your version of calc is up to date, check out:
The calc web site is located at:
http://reality.sgi.com/chongo/tech/comp/calc
http://reality.sgi.com/chongo/tech/comp/calc/index.html
=-=
@@ -96,31 +96,36 @@ Known bugs:
the terminal in a 'bad' state, as if stty -icanon -echo -echoe
had been executed.
* Dec Alpha Linux compiling with gcc-2.95.1 (or gcc-2.95.2) and
-O2 fails the version 2.11.0t8.10 regression test with:
* Use of 'fmt' in the 2nd arg of printf() calls in c_sysinfo.c
cause some compilers to issue warnings.
make -s check
000: Beginning regression tests
001: Some of these tests may take a while ...
002: Within each section, output should be numbered sequentially
003: parsed global definitions
004: parsed vrfy()
005: parsed prob(str)
006: parsed getglobalvar()
007: parsed test_booleans()
008: parsed test_variables()
make: *** [check] Segmentation fault (core dumped)
We are sure some more bugs exist. When you find them, please let
us know! See the above for details on how to report and were to
EMail your bug reports and hopefully patches to fix them.
Other programs have reported problems when compiling -O2 with
gcc-2.95.1 on the Alpha and Mips.
=-=
One work-a-round is to not compile with -O2 (perhaps just -O).
Another work-a-round is not use gcc-2.95.1.
Other items of note:
* There is a bug in gcc-2.95 that causes calc, when compiled with -O2,
to fail the regression test. The work-a-round is to compile with -O
or to use gcc-2.96 or later.
* There is a bug in some versions of the Dec/Compaq cc for the Alpha
where the following:
#include <stdio.h>
#define SVAL(a,b) (unsigned long)(0x ## a ## b ## ULL)
main(){SVAL(b8a8aeb0,8168eadc);}
fails because it puts a space inside the concatenated hex. Calc
has code that is affected by this bug. This bug has been reported
to Compaq and may be fixed in the future. A work-a-round is to
compile with cc -std0 or to use a later version of their compiler.
* On a Digital UNIX V4.0F (Rev. 1229) on a 500 Mhz 21264, make check
dies a horrible death starting in test 600 and 622 gives 100s of
messages for calc version 2.11.0t9.2 using the Dec's cc with -O2
and without -std0:
messages for calc version 2.11.0t9.4 using the Dec's cc with -O2:
600: Beginning test_bignums
601: muldivcheck 1
@@ -135,6 +140,12 @@ Known bugs:
it finally hangs at test 2000.
We are sure some more bugs exist. When you find them, please let
us know! See the above for details on how to report and were to
EMail your bug reports and hopefully patches to fix them.
The work-a-round is to compile calc without the optimizer. If this
happens to you, try compiling without -O and without -O2. I.e., in
the Makefile, set:
DEBUG= -g
or set:
DEBUG=

192
CHANGES
View File

@@ -2,14 +2,14 @@ Following is the change from calc version 2.11.0t8.9.1 to date:
The config("verbose_quit") will control the printing of the message:
Quit or abort executed
Quit or abort executed
when a non-interactive ABORT, QUIT or EXIT is encounted. By default,
config("verbose_quit") is TRUE and the message is printed. If one does:
when a non-interactive ABORT, QUIT or EXIT is encounted. By default,
config("verbose_quit") is TRUE and the message is printed. If one does:
config("verbose_quit", 0)
config("verbose_quit", 0)
the message is disabled.
the message is disabled.
Added 8400 regression test set and test8400.cal to test the new
quit and config("verbose_quit") functionality.
@@ -33,34 +33,34 @@ Following is the change from calc version 2.11.0t8.9.1 to date:
When prompt() occurs while reading a file, it will take input from
the terminal rather than taking it from a file. For example:
/* This demonstrates the use of prompt() and some other things */
config("verbose_quit", 0);
define getnumber() {
local x;
for (;;) {
x = eval(prompt(">>> "));
if (isnum(x))
return x;
print "Not a number! Try again";
/* This demonstrates the use of prompt() and some other things */
config("verbose_quit", 0);
define getnumber() {
local x;
for (;;) {
x = eval(prompt(">>> "));
if (isnum(x))
return x;
print "Not a number! Try again";
}
}
}
print "This will display the sqrt of each number you enter";
print "Enter quit to stop";
for (;;) {
print sqrt(getnumber());
}
print "Good bye";
print "This will display the sqrt of each number you enter";
print "Enter quit to stop";
for (;;) {
print sqrt(getnumber());
}
print "Good bye";
Comments entered at input terminal level may be spread over several
lines. For example:
Comments entered at input terminal level may be spread over several
lines. For example:
/*
* Assume that this calc script is called: comment.cal
* Then these commands now work:
* cat comment.cal | calc
* calc < comment.cal
*/
print "Hello";
/*
* Assume that this calc script is called: comment.cal
* Then these commands now work:
* cat comment.cal | calc
* calc < comment.cal
*/
print "Hello";
Added:
@@ -95,27 +95,135 @@ Following is the change from calc version 2.11.0t8.9.1 to date:
GNU-readline. Note that GNU-readline is not shipped with calc.
His patch only provides the hooks to use it. One must comment out:
USE_READLINE=
READLINE_LIB=
READLINE_INCLUDE=
USE_READLINE=
READLINE_LIB=
READLINE_INCLUDE=
and comment in:
and comment in:
USE_READLINE= -DUSE_READLINE
READLINE_LIB= -lreadline -lhistory
READLINE_INCLUDE= -I/usr/include/readline
USE_READLINE= -DUSE_READLINE
READLINE_LIB= -lreadline -lhistory
READLINE_INCLUDE= -I/usr/include/readline
in addition to pre-installing GNU-readline in your system to use
this facility.
in addition to pre-installing GNU-readline in your system to use
this facility.
Changed the "object already defined" math_error message to a
scanerror message.
Changed the "object already defined" math_error to a scanerror message.
Removed the limit on the number of object types.
Calc tarballs are now named calc-version.tar.gz and untar into
a sub-directory called calc-version.
Made a small change to declarations of static variables to reduce
the internal opcodes needed to declare them.
Fixed a permission problem on ranlib-ed *.a files that was reported
by Michael Somos <somos@grail.cba.csuohio.edu>.
Added patch by Klaus Alexander Seistrup <klaus@seistrup.dk> related
to GNU-readline:
+ enable calc specific bindings in ~/.inputrc
+ save a copy of your session to disk and reload them next
time you're using calc
+ only add a line to the history if it is different from
the previous line
Added the Makefile symbol HAVE_GETRUSAGE to determine if the
system supports the getrusage() system call.
Fixed the make depend code in the custom and sample Makefiles.
Fixed how the help/builtin file is formed. The help/Makefile is
now given the name of the native C compiler by the top level Makefile.
The include files are installed under INCDIRCALC (a new Makefile variable)
which by default is ${INCDIR}/calc. The INCDIR (also a new Makefile var)
by default is /usr/local/include. Include files previously installed
directly under ${LIBDIR} will be removed.
Added the piforever() funcion to lib/pi.cal. It was written by
Klaus Alexander Seistrup <klaus@seistrup.dk> and was inspired by
an algorithm conceived by Lambert Meertens. (See also the ABC
Programmer's Handbook, by Geurts, Meertens & Pemberton, published
by Prentice-Hall (UK) Ltd., 1990.) The piforever() funcion prints
digits of pi for as long as your memory and system uptime allows. :-)
Fixed the URLs found thruout the source and documentation which did
not and in /, but should for performance and server load reasons.
Cleaned up and improved handling of "mat" and "obj". The comma in:
mat A[2], B[3];
is changed to whatever is appropriate in the context:
+ comma operator
+ separator of arguments in a function call
+ separator of arguments in a defintion
etc.
The expression (mat A[2]), B[3] returns B[3], assuming B already
exists as something created by a statement like: global mat B[4].
What used to be done by the expression:
mat A[2], B[3]
will now require something like:
mat A[2], mat B[3] or A = mat[2], B = mat[3]
For example, if obj point and obj pair are known types, the
following is now allowed:
L = list(mat[2], mat[3], obj point, obj pair)
As another example, the following is allowed:
define f(a = mat[2] = {3,4}) = 5 * a;
as well as the following:
obj point {x,y}, PP = obj pair {A,B} = {obj point, obj point}
which creates two object types at compile time and when executed,
assigns a pair-object value to a variable PP.
Fixed a bug whereby a for loop would behave incorrectly. For example:
config("trace", 2),
global x;
define f() {for ( ; x > 0; x--) {print x;}}
x = 5, f()
will stop after printing 1 instead of looping forever.
Added values l_format, which when CHECK_L_FORMAT is defined ahead
of including longlong.h will help detect when a system can deal with
'long long' but not '%lld' in printf. If a system with 'long long'
uses '%ld' to print a 64 bit value, then l_format will be > 0;
othewise if "%lld" is required, l_format will be < 0.
Added HAVE_STRDUP Makefile variable as well as the have_strdup.c
program that forms the have_strdup.h file. The have_strdup.h file
will define HAVE_STRDUP is the system has strdup(). If HAVE_STRDUP
is not defined, then calc will use calc_strdup() to simulate
the real strdup() function.
Calc no longer makes use of sys_errlist and sys_nerr. Some systems
no longer suppor these values (even though they should from a
legacy prospective). Calc now relies on the fact that strerror()
will return NULL of no such system error exists. System errors >=
10000 will be considered calc errors instead. The Makefile symbol
ERRNO_DECL has gone away as well as calc_errno.c and calc_errno.h.
On system errors are are not known to to the libc strerror() function,
strerror() will now print something such as:
Unknown error 9999
Following is the change from calc version 2.11.0t8 to 2.11.0t8.9:
@@ -416,7 +524,7 @@ Following is the change from calc version 2.11.0t7 to 2.11.0t7.5:
The main calc URL is now:
http://reality.sgi.com/chongo/tech/comp/calc
http://reality.sgi.com/chongo/tech/comp/calc/
Misc calc man page fixes.

415
Makefile
View File

@@ -261,6 +261,30 @@ HAVE_GETPRID=
HAVE_URANDOM=
#HAVE_URANDOM= -DHAVE_NO_URANDOM
# Determine if we have getrusage()
#
# If HAVE_GETRUSAGE is empty, this makefile will run the have_memmv program
# to determine if getrusage() is supported. If HAVE_GETRUSAGE is set to
# -DHAVE_NO_GETRUSAGE, then calc will use internal functions to simulate
# the memory move function that does correct overlapping memory modes.
#
# If in doubt, leave HAVE_GETRUSAGE empty and this Makefile will figure it out.
#
HAVE_GETRUSAGE=
#HAVE_GETRUSAGE= -DHAVE_NO_GETRUSAGE
# Determine if we have strdup()
#
# If HAVE_STRDUP is empty, this makefile will run the have_memmv program
# to determine if strdup() is supported. If HAVE_STRDUP is set to
# -DHAVE_NO_STRDUP, then calc will use internal functions to simulate
# the memory move function that does correct overlapping memory modes.
#
# If in doubt, leave HAVE_STRDUP empty and this Makefile will figure it out.
#
HAVE_STRDUP=
#HAVE_STRDUP= -DHAVE_NO_STRDUP
# Some architectures such as Sparc do not allow one to access 32 bit values
# that are not alligned on a 32 bit boundary.
#
@@ -278,39 +302,6 @@ HAVE_URANDOM=
ALIGN32= -DMUST_ALIGN32
#ALIGN32= -UMUST_ALIGN32
# On most machines: errno sys_errlist and sys_nerr are declared
# by either <stdio.h> and/or <errno.h>. But some systems declare
# them somewhere else or do not declare them at all!
#
# If the system were doing a proper job in headers, this should declare them:
#
# #include <stdio.h>
# #include <errno.h>
#
# But one some systems one must explicitly declare them as:
#
# extern int errno;
# extern const char *const sys_errlist[];
# extern int sys_nerr;
#
# and on some old systems they must be explicitly and incorrectly declared as:
#
# extern int errno;
# extern char *sys_errlist[];
# extern int sys_nerr;
#
# ERRNO_DECL= let calc_errno.c determine how to declare them
# ERRNO_DECL= -DERRNO_NO_DECL headers declare them correctly
# ERRNO_DECL= -DERRNO_STD_DECL one must explicitly declare then
# ERRNO_DECL= -DERRNO_OLD_DECL one must explicitly & incorrectly declare them
#
# When in doubt, be safe leave ERRNO_DECL empty.
#
ERRNO_DECL=
#ERRNO_DECL= -DERRNO_NO_DECL
#ERRNO_DECL= -DERRNO_STD_DECL
#ERRNO_DECL= -DERRNO_OLD_DECL
# where to install binary files
#
BINDIR= /usr/local/bin
@@ -320,7 +311,9 @@ BINDIR= /usr/local/bin
# where to install the *.cal, *.h and *.a files
#
# ${TOPDIR} is the directory under which the calc directory will be placed.
# ${LIBDIR} is where the *.cal, *.h, *.a, bindings and help dir are installed.
# ${LIBDIR} is where the *.cal, *.a, bindings and help dir are installed.
# ${INCDIR} is where the locally installed include files are found.
# ${INCDIRCALC} is where the calc include files are installed.
# ${HELPDIR} is where the help directory is installed.
# ${CUSTOMLIBDIR} is where custom lib files are installed.
# ${CUSTOMHELPDIR} is where custom help files are installed.
@@ -332,6 +325,8 @@ TOPDIR= /usr/local/lib
#
LIBDIR= ${TOPDIR}/calc
HELPDIR= ${LIBDIR}/help
INCDIR= /usr/local/include
INCDIRCALC= ${INCDIR}/calc
CUSTOMLIBDIR= ${LIBDIR}/custom
CUSTOMHELPDIR= ${HELPDIR}/custhelp
@@ -438,12 +433,16 @@ CALCBINDINGS= bindings
# If in doubt, set USE_READLINE, READLINE_LIB and READLINE_INCLUDE to nothing.
#
USE_READLINE=
READLINE_LIB=
READLINE_INCLUDE=
#
#USE_READLINE= -DUSE_READLINE
#
READLINE_LIB=
#READLINE_LIB= -L/usr/gnu/lib -lreadline -lhistory
#READLINE_LIB= -lreadline -lhistory
#READLINE_INCLUDE= -I/usr/include/readline
#READLINE_LIB= -L/usr/local/lib -lreadline -lhistory
#
READLINE_INCLUDE=
#READLINE_INCLUDE= -I/usr/gnu/include
#READLINE_INCLUDE= -I/usr/local/include
# If $PAGER is not set, use this program to display a help file
#
@@ -742,7 +741,7 @@ CC= ${PURIFY} ${LCC}
#
###
#
# RS6000 set
# AIX RS/6000 set
#
#CCWARN=
#CCOPT= ${DEBUG} ${NO_SHARED}
@@ -838,6 +837,7 @@ SORT= sort
TEE= tee
LINT= lint
CTAGS= ctags
FMT= fmt
# assume the X11 makedepend tool for the depend rule
MAKEDEPEND= makedepend
# echo command location
@@ -909,9 +909,10 @@ BUILD_H_SRC= align32.h args.h calcerr.h conf.h endian_calc.h \
fposval.h have_const.h have_fpos.h have_malloc.h \
have_memmv.h have_newstr.h have_offscl.h have_posscl.h \
have_stdlib.h have_string.h have_times.h have_uid_t.h \
have_unistd.h longbits.h longlong.h terminal.h calc_errno.h \
have_unistd.h longbits.h longlong.h terminal.h \
have_ustat.h have_getsid.h have_getpgid.h \
have_gettime.h have_getprid.h have_urandom.h
have_gettime.h have_getprid.h have_urandom.h have_rusage.h \
have_strdup.h
# we build these .c files during the make
#
@@ -923,9 +924,9 @@ BUILD_C_SRC= calcerr.c
#
UTIL_C_SRC= align32.c endian.c longbits.c have_newstr.c have_uid_t.c \
have_const.c have_stdvs.c have_varvs.c fposval.c have_fpos.c \
longlong.c have_offscl.c have_posscl.c have_memmv.c calc_errno.c \
longlong.c have_offscl.c have_posscl.c have_memmv.c \
have_ustat.c have_getsid.c have_getpgid.c \
have_gettime.c have_getprid.c
have_gettime.c have_getprid.c have_rusage.c have_strdup.c
# these awk and sed tools are used in the process of building BUILD_H_SRC
# and BUILD_C_SRC
@@ -939,22 +940,22 @@ UTIL_MISC_SRC= calcerr_h.sed calcerr_h.awk calcerr_c.sed calcerr_c.awk \
#
UTIL_OBJS= endian.o longbits.o have_newstr.o have_uid_t.o \
have_const.o fposval.o have_fpos.o longlong.o try_strarg.o \
have_stdvs.o have_varvs.o have_posscl.o have_memmv.o calc_errno.o \
have_stdvs.o have_varvs.o have_posscl.o have_memmv.o \
have_ustat.o have_getsid.o have_getpgid.o \
have_gettime.o have_getprid.o ver_calc.o
have_gettime.o have_getprid.o ver_calc.o have_rusage.o have_strdup.o
# these temp files may be created (and removed) during the build of BUILD_C_SRC
#
UTIL_TMP= ll_tmp fpos_tmp fposv_tmp const_tmp uid_tmp newstr_tmp vs_tmp \
calc_errno_tmp memmv_tmp offscl_tmp posscl_tmp newstr_tmp \
getsid_tmp gettime_tmp getprid_tmp
memmv_tmp offscl_tmp posscl_tmp newstr_tmp \
getsid_tmp gettime_tmp getprid_tmp rusage_tmp strdup_tmp
# these utility progs may be used in the process of building BUILD_H_SRC
#
UTIL_PROGS= align32 fposval have_uid_t longlong have_const \
endian longbits have_newstr have_stdvs have_varvs calc_errno \
endian longbits have_newstr have_stdvs have_varvs \
have_ustat have_getsid have_getpgid \
have_gettime have_getprid ver_calc
have_gettime have_getprid ver_calc have_strdup
# These files are required by the regress.cal regression test.
#
@@ -1020,6 +1021,31 @@ SAMPLE_PASSDOWN= Q="${Q}" \
MAKEDEPEND=${MAKEDEPEND} \
SORT=${SORT}
# The compelte list of makefile vars passed down to help/Makefile.
#
HELP_PASSDOWN= Q="${Q}" \
TOPDIR="${TOPDIR}" \
LIBDIR="${LIBDIR}" \
HELPDIR="${HELPDIR}" \
CFLAGS="${CFLAGS} ${ALLOW_CUSTOM}" \
ICFLAGS="${ICFLAGS}" \
ILDFLAGS="${ILDFLAGS}" \
LCC="${LCC}" \
MAKE_FILE=${MAKE_FILE} \
SED=${SED} \
FMT=${FMT}
# The compelte list of makefile vars passed down to lib/Makefile.
#
LIB_PASSDOWN= Q="${Q}" \
TOPDIR="${TOPDIR}" \
LIBDIR="${LIBDIR}" \
HELPDIR="${HELPDIR}" \
MAKE_FILE=${MAKE_FILE} \
SED=${SED} \
MAKEDEPEND=${MAKEDEPEND} \
SORT=${SORT}
# complete list of .h files found (but not built) in the distribution
#
H_SRC= ${LIB_H_SRC}
@@ -1066,6 +1092,7 @@ libcalc.a: ${LIBOBJS} ${MAKE_FILE}
-rm -f libcalc.a
ar qc libcalc.a ${LIBOBJS}
${RANLIB} libcalc.a
chmod 0644 libcalc.a
calc.1: calc.man ${MAKE_FILE}
-rm -f calc.1
@@ -1081,13 +1108,14 @@ calc.1: calc.man ${MAKE_FILE}
##
calc.o: calc.c ${MAKE_FILE}
${CC} ${CFLAGS} ${CCOPT} ${ALLOW_CUSTOM} -c calc.c
${CC} ${CFLAGS} ${ALLOW_CUSTOM} -c calc.c
custom.o: custom.c ${MAKE_FILE}
${CC} ${CFLAGS} ${ALLOW_CUSTOM} -c custom.c
hist.o: hist.c ${MAKE_FILE}
${CC} ${CFLAGS} ${TERMCONTROL} ${USE_READLINE} ${READLINE_INCLUDE} -c hist.c
${CC} ${CFLAGS} ${TERMCONTROL} ${USE_READLINE} ${READLINE_INCLUDE} \
-c hist.c
func.o: func.c ${MAKE_FILE}
${CC} ${CFLAGS} ${ALLOW_CUSTOM} -c func.c
@@ -1488,6 +1516,8 @@ longlong.h: longlong.c have_stdlib.h have_string.h ${MAKE_FILE}
else \
echo '#undef HAVE_LONGLONG' >> longlong.h; \
echo '#define LONGLONG_BITS 0 /* no */' >> longlong.h; \
echo '#undef LL_FORMAT' >> longlong.h; \
echo '#undef L_FORMAT' >> longlong.h; \
fi
${Q}echo '' >> longlong.h
${Q}echo '' >> longlong.h
@@ -2088,6 +2118,84 @@ have_urandom.h: ${MAKE_FILE}
true; \
fi
have_rusage.h: have_rusage.c ${MAKE_FILE}
-${Q}rm -f have_rusage have_rusage.o rusage_tmp have_rusage.h
${Q}echo 'forming have_rusage.h'
${Q}echo '/*' > have_rusage.h
${Q}echo ' * DO NOT EDIT -- generated by the Makefile' >> have_rusage.h
${Q}echo ' */' >> have_rusage.h
${Q}echo '' >> have_rusage.h
${Q}echo '' >> have_rusage.h
${Q}echo '#if !defined(__HAVE_RUSAGE_H__)' >> have_rusage.h
${Q}echo '#define __HAVE_RUSAGE_H__' >> have_rusage.h
${Q}echo '' >> have_rusage.h
${Q}echo '' >> have_rusage.h
${Q}echo '/* do we have or want getrusage()? */' >> have_rusage.h
-${Q}rm -f have_rusage.o have_rusage
-${Q}${LCC} ${ICFLAGS} ${HAVE_GETRUSAGE} have_rusage.c -c 2>/dev/null; \
true
-${Q}${LCC} ${ILDFLAGS} have_rusage.o -o have_rusage 2>/dev/null; true
-${Q}${SHELL} -c "./have_rusage > rusage_tmp 2>/dev/null" \
>/dev/null 2>&1; true
-${Q}if [ -s rusage_tmp ]; then \
cat rusage_tmp >> have_rusage.h; \
else \
echo '#undef HAVE_GETRUSAGE /* no */' >> have_rusage.h; \
fi
${Q}echo '' >> have_rusage.h
${Q}echo '' >> have_rusage.h
${Q}echo '#endif /* !__HAVE_RUSAGE_H__ */' >> have_rusage.h
-${Q}rm -f have_rusage have_rusage.o rusage_tmp
${Q}echo 'have_rusage.h formed'
-@if [ -z "${Q}" ]; then \
echo ''; \
echo '=-=-= start of $@ =-=-='; \
cat $@; \
echo '=-=-= end of $@ =-=-='; \
echo ''; \
else \
true; \
fi
have_strdup.h: have_strdup.c ${MAKE_FILE}
-${Q}rm -f have_strdup have_strdup.o strdup_tmp have_strdup.h
${Q}echo 'forming have_strdup.h'
${Q}echo '/*' > have_strdup.h
${Q}echo ' * DO NOT EDIT -- generated by the Makefile' >> have_strdup.h
${Q}echo ' */' >> have_strdup.h
${Q}echo '' >> have_strdup.h
${Q}echo '' >> have_strdup.h
${Q}echo '#if !defined(__HAVE_RUSAGE_H__)' >> have_strdup.h
${Q}echo '#define __HAVE_RUSAGE_H__' >> have_strdup.h
${Q}echo '' >> have_strdup.h
${Q}echo '' >> have_strdup.h
${Q}echo '/* do we have or want getstrdup()? */' >> have_strdup.h
-${Q}rm -f have_strdup.o have_strdup
-${Q}${LCC} ${ICFLAGS} ${HAVE_STRDUP} have_strdup.c -c 2>/dev/null; \
true
-${Q}${LCC} ${ILDFLAGS} have_strdup.o -o have_strdup 2>/dev/null; true
-${Q}${SHELL} -c "./have_strdup > strdup_tmp 2>/dev/null" \
>/dev/null 2>&1; true
-${Q}if [ -s strdup_tmp ]; then \
cat strdup_tmp >> have_strdup.h; \
else \
echo '#undef HAVE_STRDUP /* no */' >> have_strdup.h; \
fi
${Q}echo '' >> have_strdup.h
${Q}echo '' >> have_strdup.h
${Q}echo '#endif /* !__HAVE_RUSAGE_H__ */' >> have_strdup.h
-${Q}rm -f have_strdup have_strdup.o strdup_tmp
${Q}echo 'have_strdup.h formed'
-@if [ -z "${Q}" ]; then \
echo ''; \
echo '=-=-= start of $@ =-=-='; \
cat $@; \
echo '=-=-= end of $@ =-=-='; \
echo ''; \
else \
true; \
fi
args.h: have_stdvs.c have_varvs.c have_string.h have_unistd.h have_string.h
-${Q}rm -f args.h have_args
${Q}echo 'forming args.h'
@@ -2147,98 +2255,6 @@ args.h: have_stdvs.c have_varvs.c have_string.h have_unistd.h have_string.h
true; \
fi
calc_errno.h: calc_errno.c ${MAKE_FILE}
-${Q}rm -f calc_errno.h calc_errno calc_errno_tmp
${Q}echo 'forming calc_errno.h'
${Q}echo '/*' > calc_errno.h
${Q}echo ' * DO NOT EDIT -- generated by the Makefile' >> calc_errno.h
${Q}echo ' */' >> calc_errno.h
${Q}echo '' >> calc_errno.h
${Q}echo '' >> calc_errno.h
${Q}echo '#if !defined(__CALC_ERRNO_H__)' >> calc_errno.h
${Q}echo '#define __CALC_ERRNO_H__' >> calc_errno.h
${Q}echo '' >> calc_errno.h
${Q}echo '' >> calc_errno.h
-${Q}if [ X"${ERRNO_DECL}" = X"-DERRNO_NO_DECL" ]; then \
echo '/*' >> calc_errno.h; \
echo ' * The calc Makefile explicitly told us' >> calc_errno.h; \
echo ' * how to declare errno and friends.' >> calc_errno.h; \
echo ' */' >> calc_errno.h; \
echo '' >> calc_errno.h; \
echo '#include <stdio.h>' >> calc_errno.h; \
echo '#include <errno.h>' >> calc_errno.h; \
elif [ X"${ERRNO_DECL}" = X"-DERRNO_STD_DECL" ]; then \
echo '/*' >> calc_errno.h; \
echo ' * The calc Makefile explicitly told us' >> calc_errno.h; \
echo ' * how to declare errno and friends.' >> calc_errno.h; \
echo ' */' >> calc_errno.h; \
echo '' >> calc_errno.h; \
echo 'extern int errno; ' \
'/* last system error */' >> calc_errno.h; \
echo 'extern const char *const sys_errlist[];' \
' /* system error messages*/' >> calc_errno.h; \
echo 'extern int sys_nerr; ' \
'/* number of system errors */' >> calc_errno.h; \
elif [ X"${ERRNO_DECL}" = X"-DERRNO_OLD_DECL" ]; then \
echo '/*' >> calc_errno.h; \
echo ' * The calc Makefile explicitly told us' >> calc_errno.h; \
echo ' * how to declare errno and friends.' >> calc_errno.h; \
echo ' */' >> calc_errno.h; \
echo '' >> calc_errno.h; \
echo 'extern int errno; ' \
'/* last system error */' >> calc_errno.h; \
echo 'extern char *sys_errlist[];' \
' /* system error messages*/' >> calc_errno.h; \
echo 'extern int sys_nerr; ' \
'/* number of system errors */' >> calc_errno.h; \
else \
${LCC} ${ICFLAGS} -DTRY_ERRNO_NO_DECL \
calc_errno.c -o calc_errno 2>calc_errno_tmp; \
if [ -x ./calc_errno ]; then \
./calc_errno >> calc_errno.h; \
else \
${LCC} ${ICFLAGS} -DTRY_ERRNO_STD_DECL \
calc_errno.c -o calc_errno 2>calc_errno_tmp; \
if [ -x ./calc_errno ]; then \
./calc_errno >> calc_errno.h; \
else \
${LCC} ${ICFLAGS} -DTRY_ERRNO_OLD_DECL \
calc_errno.c -o calc_errno 2>calc_errno_tmp; \
if [ -x ./calc_errno ]; then \
./calc_errno >> calc_errno.h; \
else \
echo '/*' >> calc_errno.h; \
echo ' * We were unable to to determine' >> calc_errno.h; \
echo ' * how to declare errno and friends.' >> calc_errno.h; \
echo ' * So we will guess this will work' >> calc_errno.h; \
echo ' * and hope for the best.' >> calc_errno.h; \
echo ' */' >> calc_errno.h; \
echo '' >> calc_errno.h; \
echo 'extern int errno; ' \
'/* last system error */' >> calc_errno.h; \
echo 'extern const char *const sys_errlist[];' \
' /* system error messages*/' >> calc_errno.h; \
echo 'extern int sys_nerr; ' \
'/* number of system errors */' >> calc_errno.h; \
fi; \
fi; \
fi; \
fi
${Q}echo '' >> calc_errno.h
${Q}echo '' >> calc_errno.h
${Q}echo '#endif /* !__CALC_ERRNO_H__ */' >> calc_errno.h
-${Q}rm -f calc_errno calc_errno_tmp
${Q}echo 'calc_errno.h formed'
-@if [ -z "${Q}" ]; then \
echo ''; \
echo '=-=-= start of $@ =-=-='; \
cat $@; \
echo '=-=-= end of $@ =-=-='; \
echo ''; \
else \
true; \
fi
calcerr.h: calcerr.tbl calcerr_h.sed calcerr_h.awk ${MAKE_FILE}
-${Q}rm -f calerr.h
${Q}echo 'forming calcerr.h'
@@ -2319,27 +2335,21 @@ longbits: longbits.o
lib/.all:
${V} echo '=-=-=-=-= start of $@ rule =-=-=-=-='
${V} echo '=-=-=-=-= Invoking all rule for lib =-=-=-=-='
cd lib; ${MAKE} -f Makefile \
MAKE_FILE=${MAKE_FILE} TOPDIR=${TOPDIR} LIBDIR=${LIBDIR} \
HELPDIR=${HELPDIR} all
cd lib; ${MAKE} -f Makefile ${LIB_PASSDOWN} all
${V} echo '=-=-=-=-= Back to the main Makefile for $@ rule =-=-=-=-='
${V} echo '=-=-=-=-= end of $@ rule =-=-=-=-='
help/.all:
${V} echo '=-=-=-=-= start of $@ rule =-=-=-=-='
${V} echo '=-=-=-=-= Invoking all rule for help =-=-=-=-='
cd help; ${MAKE} -f Makefile \
MAKE_FILE=${MAKE_FILE} TOPDIR=${TOPDIR} LIBDIR=${LIBDIR} \
HELPDIR=${HELPDIR} all
cd help; ${MAKE} -f Makefile ${HELP_PASSDOWN} all
${V} echo '=-=-=-=-= Back to the main Makefile for $@ rule =-=-=-=-='
${V} echo '=-=-=-=-= end of $@ rule =-=-=-=-='
help/builtin: func.c help/builtin.top help/builtin.end help/funclist.sed
${V} echo '=-=-=-=-= start of $@ rule =-=-=-=-='
${V} echo '=-=-=-=-= Invoking builtin rule for help =-=-=-=-='
cd help; ${MAKE} -f Makefile \
MAKE_FILE=${MAKE_FILE} TOPDIR=${TOPDIR} LIBDIR=${LIBDIR} \
HELPDIR=${HELPDIR} builtin
cd help; ${MAKE} -f Makefile ${HELP_PASSDOWN} builtin
${V} echo '=-=-=-=-= Back to the main Makefile for $@ rule =-=-=-=-='
${V} echo '=-=-=-=-= end of $@ rule =-=-=-=-='
@@ -2439,9 +2449,7 @@ bsdi: ${LIB_H_SRC} ${BUILD_H_SRC} calc.1
echo chmod 0444 gen_h/$$i; \
chmod 0444 gen_h/$$i; \
done
cd help; ${MAKE} -f Makefile \
MAKE_FILE=${MAKE_FILE} TOPDIR=${TOPDIR} LIBDIR=${LIBDIR} \
HELPDIR=${HELPDIR} bsdi
cd help; ${MAKE} -f Makefile ${HELP_PASSDOWN} bsdi
${V} echo '=-=-=-=-= end of $@ rule =-=-=-=-='
##
@@ -2552,23 +2560,15 @@ distlist: ${DISTLIST}
${Q}(for i in ${DISTLIST}; do \
echo $$i; \
done; \
(cd help; ${MAKE} distlist \
MAKE_FILE=${MAKE_FILE} TOPDIR=${TOPDIR} LIBDIR=${LIBDIR} \
HELPDIR=${HELPDIR} SORT=${SORT}); \
(cd lib; ${MAKE} distlist \
MAKE_FILE=${MAKE_FILE} TOPDIR=${TOPDIR} LIBDIR=${LIBDIR} \
HELPDIR=${HELPDIR} SORT=${SORT}); \
(cd help; ${MAKE} ${HELP_PASSDOWN} distlist); \
(cd lib; ${MAKE} ${LIB_PASSDOWN} distlist); \
(cd custom; ${MAKE} ${CUSTOM_PASSDOWN} distlist); \
(cd sample; ${MAKE} ${SAMPLE_PASSDOWN} distlist)) | ${SORT}
distdir:
${Q}(echo .; \
(cd help; ${MAKE} distdir \
MAKE_FILE=${MAKE_FILE} TOPDIR=${TOPDIR} LIBDIR=${LIBDIR} \
HELPDIR=${HELPDIR} SORT=${SORT}); \
(cd lib; ${MAKE} distdir \
MAKE_FILE=${MAKE_FILE} TOPDIR=${TOPDIR} LIBDIR=${LIBDIR} \
HELPDIR=${HELPDIR} SORT=${SORT}); \
(cd help; ${MAKE} ${HELP_PASSDOWN} distdir); \
(cd lib; ${MAKE} ${LIB_PASSDOWN} distdir); \
(cd custom; ${MAKE} ${CUSTOM_PASSDOWN} distdir); \
(cd sample; ${MAKE} ${SAMPLE_PASSDOWN} distdir)) | ${SORT}
@@ -2630,7 +2630,6 @@ env:
@echo "HAVE_GETPRID=${HAVE_GETPRID}"; echo ""
@echo "HAVE_URANDOM=${HAVE_URANDOM}"; echo ""
@echo "ALIGN32=${ALIGN32}"; echo ""
@echo "ERRNO_DECL=${ERRNO_DECL}"; echo ""
@echo "BINDIR=${BINDIR}"; echo ""
@echo "TOPDIR=${TOPDIR}"; echo ""
@echo "LIBDIR=${LIBDIR}"; echo ""
@@ -2695,6 +2694,8 @@ env:
@echo "REGRESS_CAL=${REGRESS_CAL}"; echo ""
@echo "CUSTOM_PASSDOWN=${CUSTOM_PASSDOWN}"; echo ""
@echo "SAMPLE_PASSDOWN=${SAMPLE_PASSDOWN}"; echo ""
@echo "HELP_PASSDOWN=${HELP_PASSDOWN}"; echo ""
@echo "LIB_PASSDOWN=${LIB_PASSDOWN}"; echo ""
@echo "H_SRC=${H_SRC}"; echo ""
@echo "C_SRC=${C_SRC}"; echo ""
@echo "DISTLIST=${DISTLIST}"; echo ""
@@ -2792,14 +2793,10 @@ clean:
-rm -f ${UTIL_PROGS}
-rm -f .libcustcalc_error
${Q}echo '=-=-=-=-= Invoking $@ rule for help =-=-=-=-='
-cd help; ${MAKE} -f Makefile \
MAKE_FILE=${MAKE_FILE} TOPDIR=${TOPDIR} LIBDIR=${LIBDIR} \
HELPDIR=${HELPDIR} clean
-cd help; ${MAKE} -f Makefile ${HELP_PASSDOWN} clean
${Q}echo '=-=-=-=-= Back to the main Makefile for $@ rule =-=-=-=-='
${Q}echo '=-=-=-=-= Invoking $@ rule for lib =-=-=-=-='
-cd lib; ${MAKE} -f Makefile \
MAKE_FILE=${MAKE_FILE} TOPDIR=${TOPDIR} LIBDIR=${LIBDIR} \
HELPDIR=${HELPDIR} clean
-cd lib; ${MAKE} -f Makefile ${LIB_PASSDOWN} clean
${Q}echo '=-=-=-=-= Back to the main Makefile for $@ rule =-=-=-=-='
${V} echo '=-=-=-=-= Invoking $@ rule for custom =-=-=-=-='
cd custom; ${MAKE} -f Makefile ${CUSTOM_PASSDOWN} clean
@@ -2807,7 +2804,6 @@ clean:
${V} echo '=-=-=-=-= Invoking $@ rule for sample =-=-=-=-='
cd sample; ${MAKE} -f Makefile ${SAMPLE_PASSDOWN} clean
${V} echo '=-=-=-=-= Back to the main Makefile for $@ rule =-=-=-=-='
-rm -f funclist.o funclist.c
${Q}echo remove files that are obsolete
-rm -f endian.h stdarg.h libcalcerr.a lib/obj help/obj
-rm -f have_vs.c std_arg.h try_stdarg.c fnvhash.c
@@ -2830,14 +2826,10 @@ clobber: lintclean
-rm -f calc.pixie calc.rf calc.Counts calc.cord
-rm -rf gen_h skel Makefile.bak
${V} echo '=-=-=-=-= Invoking $@ rule for help =-=-=-=-='
-cd help;${MAKE} -f Makefile \
MAKE_FILE=${MAKE_FILE} TOPDIR=${TOPDIR} LIBDIR=${LIBDIR} \
HELPDIR=${HELPDIR} clobber
-cd help; ${MAKE} -f Makefile ${HELP_PASSDOWN} clobber
${V} echo '=-=-=-=-= Back to the main Makefile for $@ rule =-=-=-=-='
${V} echo '=-=-=-=-= Invoking $@ rule for lib =-=-=-=-='
-cd lib; ${MAKE} -f Makefile \
MAKE_FILE=${MAKE_FILE} TOPDIR=${TOPDIR} LIBDIR=${LIBDIR} \
HELPDIR=${HELPDIR} clobber
-cd lib; ${MAKE} -f Makefile ${LIB_PASSDOWN} clobber
${V} echo '=-=-=-=-= Back to the main Makefile for $@ rule =-=-=-=-='
${V} echo '=-=-=-=-= Invoking $@ rule for custom =-=-=-=-='
cd custom; ${MAKE} -f Makefile ${CUSTOM_PASSDOWN} clobber
@@ -2873,6 +2865,20 @@ install: calc libcalc.a ${LIB_H_SRC} ${BUILD_H_SRC} calc.1
true; \
fi
-chmod 0755 ${HELPDIR}
-${Q}if [ ! -d ${INCDIR} ]; then \
echo mkdir ${INCDIR}; \
mkdir ${INCDIR}; \
else \
true; \
fi
-chmod 0755 ${INCDIR}
-${Q}if [ ! -d ${INCDIRCALC} ]; then \
echo mkdir ${INCDIRCALC}; \
mkdir ${INCDIRCALC}; \
else \
true; \
fi
-chmod 0755 ${INCDIRCALC}
-${Q}if [ ! -d ${BINDIR} ]; then \
echo mkdir ${BINDIR}; \
mkdir ${BINDIR}; \
@@ -2884,14 +2890,10 @@ install: calc libcalc.a ${LIB_H_SRC} ${BUILD_H_SRC} calc.1
cp calc ${BINDIR}
-chmod 0555 ${BINDIR}/calc
${V} echo '=-=-=-=-= Invoking $@ rule for help =-=-=-=-='
cd help; ${MAKE} -f Makefile \
MAKE_FILE=${MAKE_FILE} TOPDIR=${TOPDIR} LIBDIR=${LIBDIR} \
HELPDIR=${HELPDIR} install
cd help; ${MAKE} -f Makefile ${HELP_PASSDOWN} install
${V} echo '=-=-=-=-= Back to the main Makefile for $@ rule =-=-=-=-='
${V} echo '=-=-=-=-= Invoking $@ rule for lib =-=-=-=-='
cd lib; ${MAKE} -f Makefile \
MAKE_FILE=${MAKE_FILE} TOPDIR=${TOPDIR} LIBDIR=${LIBDIR} \
HELPDIR=${HELPDIR} install
cd lib; ${MAKE} -f Makefile ${LIB_PASSDOWN} install
${V} echo '=-=-=-=-= Back to the main Makefile for $@ rule =-=-=-=-='
${V} echo '=-=-=-=-= Invoking $@ rule for custom =-=-=-=-='
cd custom; ${MAKE} -f Makefile ${CUSTOM_PASSDOWN} install
@@ -2900,16 +2902,18 @@ install: calc libcalc.a ${LIB_H_SRC} ${BUILD_H_SRC} calc.1
cd sample; ${MAKE} -f Makefile ${SAMPLE_PASSDOWN} install
${V} echo '=-=-=-=-= Back to the main Makefile for $@ rule =-=-=-=-='
-rm -f ${LIBDIR}/libcalc.a
cp libcalc.a ${LIBDIR}/libcalc.a
-chmod 0644 ${LIBDIR}/libcalc.a
cp -f libcalc.a ${LIBDIR}/libcalc.a
${RANLIB} ${LIBDIR}/libcalc.a
-chmod 0644 ${LIBDIR}/libcalc.a
-${Q}for i in ${LIB_H_SRC} ${BUILD_H_SRC}; do \
echo rm -f ${LIBDIR}/$$i; \
rm -f ${LIBDIR}/$$i; \
echo cp $$i ${LIBDIR}; \
cp $$i ${LIBDIR}; \
echo chmod 0444 ${LIBDIR}/$$i; \
chmod 0444 ${LIBDIR}/$$i; \
echo rm -f ${INCDIRCALC}/$$i; \
rm -f ${INCDIRCALC}/$$i; \
echo cp $$i ${INCDIRCALC}; \
cp $$i ${INCDIRCALC}; \
echo chmod 0444 ${INCDIRCALC}/$$i; \
chmod 0444 ${INCDIRCALC}/$$i; \
done
${Q}: If lint was made, install the lint library.
-${Q}if [ -f llib-lcalc.ln ]; then \
@@ -2952,6 +2956,8 @@ install: calc libcalc.a ${LIB_H_SRC} ${BUILD_H_SRC} calc.1
-rm -f ${LIBDIR}/stdarg.h stdarg.h
-rm -f ${LIBDIR}/prototype.h prototype.h
-rm -f ${LIBDIR}/libcalcerr.a libcalcerr.a
-rm -f ${LIBDIR}/calc_errno.h calc_errno.h ${INCDIRCALC}/calc_errno.h
-rm -f calc_errno.c calc_errno.o calc_errno
${V} echo '=-=-=-=-= end of $@ rule =-=-=-=-='
##
@@ -2973,6 +2979,7 @@ addop.o: config.h
addop.o: endian_calc.h
addop.o: func.h
addop.o: hash.h
addop.o: have_const.h
addop.o: have_malloc.h
addop.o: have_memmv.h
addop.o: have_newstr.h
@@ -3029,6 +3036,7 @@ blkcpy.o: config.h
blkcpy.o: endian_calc.h
blkcpy.o: file.h
blkcpy.o: hash.h
blkcpy.o: have_const.h
blkcpy.o: have_fpos.h
blkcpy.o: have_malloc.h
blkcpy.o: have_memmv.h
@@ -3117,7 +3125,6 @@ calc.o: symbol.h
calc.o: token.h
calc.o: value.h
calc.o: zmath.h
calc_errno.o: calc_errno.c
calcerr.o: calcerr.c
calcerr.o: calcerr.h
calcerr.o: have_const.h
@@ -3133,6 +3140,7 @@ codegen.o: config.h
codegen.o: endian_calc.h
codegen.o: func.h
codegen.o: hash.h
codegen.o: have_const.h
codegen.o: have_malloc.h
codegen.o: have_memmv.h
codegen.o: have_newstr.h
@@ -3217,6 +3225,7 @@ const.o: config.h
const.o: const.c
const.o: endian_calc.h
const.o: hash.h
const.o: have_const.h
const.o: have_malloc.h
const.o: have_memmv.h
const.o: have_newstr.h
@@ -3271,6 +3280,7 @@ file.o: file.c
file.o: file.h
file.o: fposval.h
file.o: hash.h
file.o: have_const.h
file.o: have_fpos.h
file.o: have_malloc.h
file.o: have_memmv.h
@@ -3295,7 +3305,6 @@ func.o: alloc.h
func.o: block.h
func.o: byteswap.h
func.o: calc.h
func.o: calc_errno.h
func.o: calcerr.h
func.o: cmath.h
func.o: config.h
@@ -3368,9 +3377,11 @@ have_newstr.o: have_newstr.c
have_offscl.o: have_offscl.c
have_posscl.o: have_fpos.h
have_posscl.o: have_posscl.c
have_rusage.o: have_rusage.c
have_stdvs.o: have_stdvs.c
have_stdvs.o: have_string.h
have_stdvs.o: have_unistd.h
have_strdup.o: have_strdup.c
have_uid_t.o: have_uid_t.c
have_uid_t.o: have_unistd.h
have_ustat.o: have_ustat.c
@@ -3387,6 +3398,7 @@ help.o: conf.h
help.o: config.h
help.o: endian_calc.h
help.o: hash.h
help.o: have_const.h
help.o: have_malloc.h
help.o: have_memmv.h
help.o: have_newstr.h
@@ -3412,10 +3424,12 @@ hist.o: cmath.h
hist.o: config.h
hist.o: endian_calc.h
hist.o: hash.h
hist.o: have_const.h
hist.o: have_malloc.h
hist.o: have_memmv.h
hist.o: have_newstr.h
hist.o: have_stdlib.h
hist.o: have_strdup.h
hist.o: have_string.h
hist.o: have_unistd.h
hist.o: hist.c
@@ -3440,11 +3454,13 @@ input.o: conf.h
input.o: config.h
input.o: endian_calc.h
input.o: hash.h
input.o: have_const.h
input.o: have_malloc.h
input.o: have_memmv.h
input.o: have_newstr.h
input.o: have_stdlib.h
input.o: have_string.h
input.o: have_unistd.h
input.o: hist.h
input.o: input.c
input.o: longbits.h
@@ -3469,6 +3485,7 @@ label.o: config.h
label.o: endian_calc.h
label.o: func.h
label.o: hash.h
label.o: have_const.h
label.o: have_malloc.h
label.o: have_memmv.h
label.o: have_newstr.h
@@ -3503,6 +3520,7 @@ lib_calc.o: have_malloc.h
lib_calc.o: have_memmv.h
lib_calc.o: have_newstr.h
lib_calc.o: have_stdlib.h
lib_calc.o: have_strdup.h
lib_calc.o: have_string.h
lib_calc.o: have_unistd.h
lib_calc.o: label.h
@@ -3598,6 +3616,7 @@ math_error.o: cmath.h
math_error.o: config.h
math_error.o: endian_calc.h
math_error.o: hash.h
math_error.o: have_const.h
math_error.o: have_malloc.h
math_error.o: have_memmv.h
math_error.o: have_newstr.h
@@ -3648,6 +3667,7 @@ obj.o: config.h
obj.o: endian_calc.h
obj.o: func.h
obj.o: hash.h
obj.o: have_const.h
obj.o: have_malloc.h
obj.o: have_memmv.h
obj.o: have_newstr.h
@@ -3861,6 +3881,7 @@ seed.o: have_gettime.h
seed.o: have_malloc.h
seed.o: have_memmv.h
seed.o: have_newstr.h
seed.o: have_rusage.h
seed.o: have_stdlib.h
seed.o: have_string.h
seed.o: have_urandom.h
@@ -3952,6 +3973,7 @@ string.o: cmath.h
string.o: config.h
string.o: endian_calc.h
string.o: hash.h
string.o: have_const.h
string.o: have_malloc.h
string.o: have_memmv.h
string.o: have_newstr.h
@@ -3977,6 +3999,7 @@ symbol.o: config.h
symbol.o: endian_calc.h
symbol.o: func.h
symbol.o: hash.h
symbol.o: have_const.h
symbol.o: have_malloc.h
symbol.o: have_memmv.h
symbol.o: have_newstr.h
@@ -4006,6 +4029,7 @@ token.o: cmath.h
token.o: config.h
token.o: endian_calc.h
token.o: hash.h
token.o: have_const.h
token.o: have_malloc.h
token.o: have_memmv.h
token.o: have_newstr.h
@@ -4065,6 +4089,7 @@ version.o: cmath.h
version.o: config.h
version.o: endian_calc.h
version.o: hash.h
version.o: have_const.h
version.o: have_malloc.h
version.o: have_memmv.h
version.o: have_newstr.h

2
README
View File

@@ -87,4 +87,4 @@ your full name.
The calc web site is located at:
http://reality.sgi.com/chongo/tech/comp/calc
http://reality.sgi.com/chongo/tech/comp/calc/

View File

@@ -4,7 +4,7 @@
* This file was written by:
*
* Landon Curt Noll
* http://reality.sgi.com/chongo
* http://reality.sgi.com/chongo/
*
* chongo <was here> /\../\
*

View File

@@ -4,7 +4,7 @@
* provided that this copyright notice remains intact.
*
* By: Ernest Bowen and Landon Curt Noll
* ernie@neumann.une.edu.au and http://reality.sgi.com/chongo
* ernie@neumann.une.edu.au and http://reality.sgi.com/chongo/
*/
#include <stdio.h>

View File

@@ -28,7 +28,7 @@
* Happy bit twiddling,
*
* Landon Curt Noll
* http://reality.sgi.com/chongo
* http://reality.sgi.com/chongo/
*
* chongo <was here> /\../\
*/

View File

@@ -28,7 +28,7 @@
* Happy bit twiddling,
*
* Landon Curt Noll
* http://reality.sgi.com/chongo
* http://reality.sgi.com/chongo/
*
* chongo <was here> /\../\
*/

9
calc.c
View File

@@ -39,9 +39,6 @@
/*
* static definitions and functions
*/
static char *usage = "usage: %s [-c] [-C] [-d] [-e] [-h] [-i] [-m mode]\n"
"\t[-D calc_debug[:lib_debug:[user_debug]]]\n"
"\t[-n] [-p] [-q] [-u] [-v] [[--] calc_cmd ...]\n";
static void intint(int arg); /* interrupt routine */
@@ -153,7 +150,11 @@ main(int argc, char **argv)
* we are too early in processing to call
* libcalc_call_me_last() - nothing to cleanup
*/
fprintf(stderr, usage, program);
fprintf(stderr,
"usage: %s [-c] [-C] [-d] [-e] [-h] [-i] [-m mode]\n"
"\t[-D calc_debug[:lib_debug:[user_debug]]]\n"
"\t[-n] [-p] [-q] [-u] [-v] [[--] calc_cmd ...]\n",
program);
exit(1);
}
}

3
calc.h
View File

@@ -14,6 +14,8 @@
#include "value.h"
#include "have_const.h"
/*
* Configuration definitions
@@ -140,6 +142,7 @@ extern void givehelp(char *type);
extern void libcalc_call_me_first(void);
extern void libcalc_call_me_last(void);
extern void showerrors(void);
extern char *calc_strdup(CONST char *);
/*
* Initialization

View File

@@ -618,7 +618,7 @@ Landon Noll maintains the the
web site is located at:
.sp
.in +0.5i
http://reality.sgi.com/chongo/tech/comp/calc
http://reality.sgi.com/chongo/tech/comp/calc/
.in -0.5i
.sp
One may join the

View File

@@ -1,123 +0,0 @@
/*
* errno - Determine how to declare errno, sys_errlist and sys_nerr
*
* On most machines: errno sys_errlist and sys_nerr are declared
* by either <stdio.h> and/or <errno.h>. But some systems declare
* them somewhere else or do not declare them at all!
*
* If the system were doing a proper job in headers, this should declare them:
*
* #include <stdio.h>
* #include <errno.h>
*
* But one some systems one must explicitly declare them as:
*
* extern int errno;
* extern const char *const sys_errlist[];
* extern int sys_nerr;
*
* and on some old systems they must be explicitly and incorrectly declared as:
*
* extern int errno;
* extern char *sys_errlist[];
* extern int sys_nerr;
*
* The purpose of this utility is try and find the right way to declare
* them and to output the middle of a header file called calc_errno.h.
*/
/*
* Copyright (c) 1999 by Landon Curt Noll. All Rights Reserved.
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby granted,
* provided that the above copyright, this permission notice and text
* this comment, and the disclaimer below appear in all of the following:
*
* supporting documentation
* source copies
* source works derived from this source
* binaries derived from this source or from derived source
*
* LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
* EVENT SHALL LANDON CURT NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
* chongo was here /\../\
*/
#include <stdio.h>
#if defined(TRY_ERRNO_NO_DECL)
# include <errno.h>
#endif /* TRY_ERRNO_NO_DECL */
int
main(void)
{
#if defined(TRY_ERRNO_NO_DECL)
printf("/*\n");
printf(" * The following comments were produced by calc_errno\n");
printf(" * in an effort to see if these values were correctly\n");
printf(" * declared when calc_errno.c was compiled.\n");
printf(" */\n\n");
printf("/* Initially errno is %d */\n", errno);
printf("/* There are %d entries in sys_errlist[] */\n", sys_nerr);
printf("/* The 2nd sys_errlist entry is \"%s\" */\n\n", sys_errlist[1]);
printf("/*\n");
printf(" * Based on the above, calc_errno now knows\n");
printf(" * how to declare errno and friends.\n");
printf(" */\n\n");
printf("#include <stdio.h>\n");
printf("#include <errno.h>\n");
#elif defined(TRY_ERRNO_OLD_DECL)
extern int errno; /* last system error */
extern char *sys_errlist[]; /* system error messages */
extern int sys_nerr; /* number of system errors*/
printf("/*\n");
printf(" * The following comments were produced by calc_errno\n");
printf(" * in an effort to see if these values were correctly\n");
printf(" * declared when calc_errno.c was compiled.\n");
printf(" */\n\n");
printf("/* Initially errno is %d */\n", errno);
printf("/* There are %d entries in sys_errlist[] */\n", sys_nerr);
printf("/* The 2nd sys_errlist entry is \"%s\" */\n\n", sys_errlist[1]);
printf("/*\n");
printf(" * Based on the above, calc_errno now knows\n");
printf(" * how to declare errno and friends.\n");
printf(" */\n\n");
printf("extern int errno;\t\t/* last system error */\n");
printf("extern char *sys_errlist[];\t"
"/* system error messages */\n");
printf("extern int sys_nerr;\t\t/* number of system errors*/\n");
#else /* assume defined(TRY_ERRNO_STD_DECL) */
extern int errno; /* last system error */
extern const char *const sys_errlist[]; /* system error messages */
extern int sys_nerr; /* number of system errors*/
printf("/*\n");
printf(" * The following comments were produced by calc_errno\n");
printf(" * in an effort to see if these values were correctly\n");
printf(" * declared when calc_errno.c was compiled.\n");
printf(" */\n\n");
printf("/* Initially errno is %d */\n", errno);
printf("/* There are %d entries in sys_errlist[] */\n", sys_nerr);
printf("/* The 2nd sys_errlist entry is \"%s\" */\n\n", sys_errlist[1]);
printf("/*\n");
printf(" * Based on the above, calc_errno now knows\n");
printf(" * how to declare errno and friends.\n");
printf(" */\n\n");
printf("extern int errno;\t\t\t/* last system error */\n");
printf("extern const char *const sys_errlist[];\t"
"/* system error messages */\n");
printf("extern int sys_nerr;\t\t\t/* number of system errors*/\n");
#endif
/* exit(0); */
return 0;
}

View File

@@ -32,8 +32,8 @@ static void getfunction(void);
static void ungetfunction(void);
static void getbody(LABEL *contlabel, LABEL *breaklabel,
LABEL *nextcaselabel, LABEL *defaultlabel);
static void getdeclarations(int symtype);
static void getsimpledeclaration (int symtype);
static int getdeclarations(int symtype);
static int getsimpledeclaration (int symtype);
static int getonevariable (int symtype);
static void getstatement(LABEL *contlabel, LABEL *breaklabel,
LABEL *nextcaselabel, LABEL *defaultlabel);
@@ -256,9 +256,15 @@ ungetfunction(void)
case T_MULT:
rmalluserfunc();
continue;
default:
case T_NEWLINE:
case T_SEMICOLON:
case T_EOF:
rescantoken();
return;
default:
scanerror(T_SEMICOLON,
"Non-name arg for undefine");
return;
}
}
}
@@ -398,9 +404,11 @@ getbody(LABEL *contlabel, LABEL *breaklabel, LABEL *nextcaselabel, LABEL *defaul
* declarations = { LOCAL | GLOBAL | STATIC } onedeclaration
* [ ',' onedeclaration ] ... ';'.
*/
static void
static int
getdeclarations(int symtype)
{
int res = 0;
while (TRUE) {
switch (gettoken()) {
case T_COMMA:
@@ -411,28 +419,31 @@ getdeclarations(int symtype)
case T_RIGHTBRACE:
case T_EOF:
rescantoken();
return;
return res;
case T_SYMBOL:
addopone(OP_DEBUG, linenumber());
rescantoken();
getsimpledeclaration(symtype);
if (getsimpledeclaration(symtype))
res = 1;
break;
case T_MAT:
addopone(OP_DEBUG, linenumber());
getmatdeclaration(symtype);
res = 1;
break;
case T_OBJ:
addopone(OP_DEBUG, linenumber());
getobjdeclaration(symtype);
addop(OP_POP);
res = 1;
break;
default:
scanerror(T_SEMICOLON, "Bad syntax in declaration statement");
return;
return res;
}
}
}
@@ -444,22 +455,24 @@ getdeclarations(int symtype)
* Subsequences end with "," or at end of line; spaces indicate
* repeated assignment, e.g. "c d = 2" has the effect of "c = 2, d = 2".
*/
static void
static int
getsimpledeclaration(int symtype)
{
int res = 0;
for (;;) {
switch (gettoken()) {
case T_SYMBOL:
rescantoken();
if (getonevariable(symtype))
res = getonevariable(symtype);
if (res)
addop(OP_POP);
continue;
case T_COMMA:
continue;
default:
rescantoken();
return;
return res;
}
}
}
@@ -508,11 +521,9 @@ getonevariable(int symtype)
* | BREAK ';'
* | RETURN assignment ';'
* | GOTO label ';'
* | MAT name '[' value [ ':' value ] [',' value [ ':' value ] ] ']' ';'
* | OBJ type '{' arg [ ',' arg ] ... '}' ] ';'
* | OBJ type name [ ',' name ] ';'
* | PRINT assignment [, assignment ] ... ';'
* | QUIT [ string ] ';'
* | ABORT [ string ] ';'
* | SHOW item ';'
* | body
* | assignment ';'
@@ -541,18 +552,20 @@ getstatement(LABEL *contlabel, LABEL *breaklabel, LABEL *nextcaselabel, LABEL *d
return;
case T_GLOBAL:
getdeclarations(SYM_GLOBAL);
(void) getdeclarations(SYM_GLOBAL);
break;
case T_STATIC:
clearlabel(&label);
addoplabel(OP_INITSTATIC, &label);
getdeclarations(SYM_STATIC);
setlabel(&label);
if (getdeclarations(SYM_STATIC))
setlabel(&label);
else
curfunc->f_opcodecount -= 2;
break;
case T_LOCAL:
getdeclarations(SYM_LOCAL);
(void) getdeclarations(SYM_LOCAL);
break;
case T_RIGHTBRACE:
@@ -692,14 +705,14 @@ getstatement(LABEL *contlabel, LABEL *breaklabel, LABEL *nextcaselabel, LABEL *d
}
}
if (gettoken() != T_RIGHTPAREN) { /* have 'c' part */
if (label1.l_offset <= 0)
if (label1.l_offset < 0)
addoplabel(OP_JUMP, &label3);
setlabel(&label2);
contlabel = &label2;
rescantoken();
(void) getexprlist();
addop(OP_POP);
if (label1.l_offset > 0)
if (label1.l_offset >= 0)
addoplabel(OP_JUMP, &label1);
if (gettoken() != T_RIGHTPAREN) {
(void) tokenmode(oldmode);
@@ -719,15 +732,21 @@ getstatement(LABEL *contlabel, LABEL *breaklabel, LABEL *nextcaselabel, LABEL *d
case T_WHILE:
oldmode = tokenmode(TM_DEFAULT);
contlabel = &label1;
breaklabel = &label2;
clearlabel(contlabel);
clearlabel(breaklabel);
setlabel(contlabel);
getcondition();
addoplabel(OP_JUMPZ, breaklabel);
getstatement(contlabel, breaklabel, NULL_LABEL, NULL_LABEL);
addoplabel(OP_JUMP, contlabel);
setlabel(breaklabel);
if (gettoken() != T_SEMICOLON) {
breaklabel = &label2;
clearlabel(breaklabel);
addoplabel(OP_JUMPZ, breaklabel);
rescantoken();
getstatement(contlabel, breaklabel,
NULL_LABEL, NULL_LABEL);
addoplabel(OP_JUMP, contlabel);
setlabel(breaklabel);
} else {
addoplabel(OP_JUMPNZ, contlabel);
}
(void) tokenmode(oldmode);
return;
@@ -1038,18 +1057,14 @@ getoneobj(long index, int symtype)
}
/*
* Routine to collect a set of variables for the specified object type
* and initialize them as being that type of object.
* Here
* objlist = name initlist [ ',' name initlist ] ... ';'.
* If symtype is SYM_UNDEFINED, then this is an OBJ statement where the
* values can be any variable expression, and no symbols are to be defined.
* Otherwise this is part of a declaration, and the variables must be raw
* symbol names which are defined with the specified symbol type.
* Routine to assign a specified object-type value to each of a set of
* variables in a "global", "local" or "static" declaration, or, if
* symtype is SYM_UNDEFINED, to create one object value of the specified
* type.
*
* given:
* name object name
* symtype type of symbol to collect for
* symtype declaration type
*/
static void
getobjvars(char *name, int symtype)
@@ -1063,6 +1078,8 @@ getobjvars(char *name, int symtype)
}
for (;;) {
getoneobj(index, symtype);
if (symtype == SYM_UNDEFINED)
return;
if (gettoken() != T_COMMA) {
rescantoken();
return;
@@ -1906,11 +1923,6 @@ getterm(void)
case T_MAT:
getonematrix(SYM_UNDEFINED);
while (gettoken() == T_COMMA) {
addop(OP_POP);
getonematrix(SYM_UNDEFINED);
}
rescantoken();
type = EXPR_ASSIGN;
break;

View File

@@ -29,7 +29,7 @@
* Happy bit twiddling,
*
* Landon Curt Noll
* http://reality.sgi.com/chongo
* http://reality.sgi.com/chongo/
*
* chongo <was here> /\../\
*/

View File

@@ -25,7 +25,7 @@
* Happy bit twiddling,
*
* Landon Curt Noll
* http://reality.sgi.com/chongo
* http://reality.sgi.com/chongo/
*
* chongo <was here> /\../\
*/

View File

@@ -29,7 +29,7 @@
* Happy bit twiddling,
*
* Landon Curt Noll
* http://reality.sgi.com/chongo
* http://reality.sgi.com/chongo/
*
* chongo <was here> /\../\
*/

View File

@@ -19,7 +19,7 @@
# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
#
# chongo was here /\../\ http://reality.sgi.com/chongo
# chongo was here /\../\ http://reality.sgi.com/chongo/
The following custom calc library files are provided because they serve
as examples of how use the custom interface. The custom interface

View File

@@ -27,7 +27,7 @@
# Happy bit twiddling,
#
# Landon Curt Noll
# http://reality.sgi.com/chongo
# http://reality.sgi.com/chongo/
#
# chongo <was here> /\../\
@@ -310,6 +310,15 @@ libcustcalc.a: ${CUSTCALC_OBJ} ${MAKE_FILE} ../Makefile
ar qc libcustcalc.a ${CUSTCALC_OBJ}
${RANLIB} libcustcalc.a
##
#
# Special .o files
#
##
c_sysinfo.o: c_sysinfo.c ${MAKE_FILE}
${CC} ${CFLAGS} c_sysinfo.c -c
##
#
# used by the upper level Makefile
@@ -415,12 +424,12 @@ depend:
else \
rm -f Makefile.tmp; \
mv Makefile Makefile.tmp; \
if [ -d RCS ]; then; \
if [ -d RCS ]; then \
co -l Makefile; \
fi ;\
mv Makefile.tmp Makefile; \
if [ -d RCS ]; then; \
echo new custom Makefile formed '--' you need to check it in'; \
if [ -d RCS ]; then \
echo 'new custom Makefile formed -- you need to check it in'; \
fi; \
fi

View File

@@ -10,7 +10,7 @@
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
* chongo was here /\../\ http://reality.sgi.com/chongo
* chongo was here /\../\ http://reality.sgi.com/chongo/
*/
/*
* argv - print information about various args

View File

@@ -16,7 +16,7 @@
* Happy bit twiddling,
*
* Landon Curt Noll
* http://reality.sgi.com/chongo
* http://reality.sgi.com/chongo/
*
* chongo <was here> /\../\
*/

View File

@@ -16,7 +16,7 @@
* Happy bit twiddling,
*
* Landon Curt Noll
* http://reality.sgi.com/chongo
* http://reality.sgi.com/chongo/
*
* chongo <was here> /\../\
*/

View File

@@ -16,7 +16,7 @@
* Happy bit twiddling,
*
* Landon Curt Noll
* http://reality.sgi.com/chongo
* http://reality.sgi.com/chongo/
*
* chongo <was here> /\../\
*/

View File

@@ -16,7 +16,7 @@
* Happy bit twiddling,
*
* Landon Curt Noll
* http://reality.sgi.com/chongo
* http://reality.sgi.com/chongo/
*
* chongo <was here> /\../\
*/
@@ -33,6 +33,7 @@
#include "../config.h"
#include "../calc.h"
#include "../longbits.h"
#define CHECK_L_FORMAT
#include "../longlong.h"
#include "../block.h"
#include "../calcerr.h"
@@ -306,17 +307,33 @@ static void
dump_name_value(void)
{
struct infoname *p; /* current infoname */
char *fmt; /* printf value format */
/* dump the entire table */
for (p = sys_info; p->name != NULL; ++p) {
if (p->str == NULL) {
#if LONG_BITS == FULL_BITS || FULL_BITS == 32 || !defined(HAVE_LONGLONG)
printf("%s%-23s\t%-8lu\t(0x%lx)\n",
fmt = "%s%-23s\t%-8lu\t(0x%lx)\n";
printf(fmt,
(conf->tab_ok ? "\t" : ""), p->name,
(unsigned long)p->nmbr,
(unsigned long)p->nmbr);
#else
printf("%s%-23s\t%-8llu\t(0x%llx)\n",
/*
* Determine of %ld can print a 64 bit long long.
*
* Some systems that can make use of %ld to print a
* a 64 bit value do not support the %lld type.
* So we will only try %lld if %ld does not work.
*/
if (l_format < 0) {
/* %ld prints lower 32 bits only, use %lld */
fmt = "%s%-23s\t%-8llu\t(0x%llx)\n";
} else {
/* %ld prints all 64 bits, use %ld */
fmt = "%s%-23s\t%-8lu\t(0x%lx)\n";
}
printf(fmt,
(conf->tab_ok ? "\t" : ""), p->name,
(unsigned long long)p->nmbr,
(unsigned long long)p->nmbr);
@@ -337,17 +354,33 @@ static void
dump_mening_value(void)
{
struct infoname *p; /* current infoname */
char *fmt; /* printf value format */
/* dump the entire table */
for (p = sys_info; p->name != NULL; ++p) {
if (p->str == NULL) {
#if LONG_BITS == FULL_BITS || FULL_BITS == 32 || !defined(HAVE_LONGLONG)
printf("%s%-36.36s\t%-8lu\t(0x%lx)\n",
fmt = "%s%-36.36s\t%-8lu\t(0x%lx)\n";
printf(fmt,
(conf->tab_ok ? "\t" : ""), p->meaning,
(unsigned long)p->nmbr,
(unsigned long)p->nmbr);
#else
printf("%s%-36.36s\t%-8llu\t(0x%llx)\n",
/*
* Determine of %ld can print a 64 bit long long.
*
* Some systems that can make use of %ld to print a
* a 64 bit value do not support the %lld type.
* So we will only try %lld if %ld does not work.
*/
if (l_format < 0) {
/* %ld prints lower 32 bits only, use %lld */
fmt = "%s%-36.36s\t%-8llu\t(0x%llx)\n";
} else {
/* %ld prints all 64 bits, use %ld */
fmt = "%s%-36.36s\t%-8lu\t(0x%lx)\n";
}
printf(fmt,
(conf->tab_ok ? "\t" : ""), p->meaning,
(unsigned long long)p->nmbr,
(unsigned long long)p->nmbr);

View File

@@ -25,7 +25,7 @@
* Happy bit twiddling,
*
* Landon Curt Noll
* http://reality.sgi.com/chongo
* http://reality.sgi.com/chongo/
*
* chongo <was here> /\../\
*/

View File

@@ -10,7 +10,7 @@
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
* chongo was here /\../\ http://reality.sgi.com/chongo
* chongo was here /\../\ http://reality.sgi.com/chongo/
*/
/*
* halflen - determine the length of numeric value in HALFs

66
func.c
View File

@@ -10,6 +10,7 @@
#include <stdio.h>
#include <ctype.h>
#include <sys/types.h>
#include <errno.h>
#if defined(FUNCLIST)
@@ -17,8 +18,6 @@
#else /* FUNCLIST */
#include "calc_errno.h"
#include "have_unistd.h"
#if defined(HAVE_UNISTD_H)
#include <unistd.h>
@@ -29,16 +28,24 @@
#include <stdlib.h>
#endif
#include "have_string.h"
#if defined(HAVE_STRING_H)
#include <string.h>
#endif
#include "have_times.h"
#if defined(HAVE_TIME_H)
#include <time.h>
#endif
#if defined(HAVE_TIMES_H)
#include <times.h>
#endif
#if defined(HAVE_SYS_TIME_H)
#include <sys/time.h>
#endif
#if defined(HAVE_SYS_TIMES_H)
#include <sys/times.h>
#endif
@@ -4628,6 +4635,7 @@ f_strerror(int count, VALUE **vals)
long i;
char *cp;
/* parse args */
if (count > 0) {
vp = vals[0];
if (vp->v_type < 0) {
@@ -4639,36 +4647,44 @@ f_strerror(int count, VALUE **vals)
if (i < 0 || i > 32767)
return error_value(E_STRERROR2);
}
}
else
} else {
i = set_errno(-1);
}
/* setup return type */
result.v_type = V_STR;
/* change the meaning of error 0 */
if (i == 0)
i = E__BASE;
/* firewall - return generic error string if it is not assigned */
if (i >= nexterrnum || (i > E__HIGHEST && i < E_USERDEF)
|| (i < E__BASE && i >= sys_nerr)) {
cp = (char *) malloc(12);
|| (i < E__BASE && strerror(i) == NULL)) {
cp = (char *) malloc(sizeof("Error 1234567890")+1);
if (cp == NULL) {
math_error("Out of memory for strerror");
/*NOTREACHED*/
}
sprintf(cp, "Error %ld", i);
sprintf(cp, "Unknown error %ld", i);
result.v_str = makestring(cp);
return result;
}
if (i < E__BASE) /* system error */
cp = (char *) sys_errlist[i];
/* system error */
if (i < E__BASE) {
cp = strerror(i);
else if (i >= E_USERDEF) /* user-described error */
/* user-described error */
} else if (i >= E_USERDEF) {
cp = namestr(&newerrorstr, i - E_USERDEF);
else /* calc-described error */
/* calc-described error */
} else {
cp = (char *)error_table[i - E__BASE];
}
/* return result as a V_STR */
result.v_str = makenewstring(cp);
return result;
}
@@ -7334,12 +7350,33 @@ static CONST struct builtin builtins[] = {
*
* When FUNCLIST is defined, we are being compiled by rules from the help
* sub-directory to form a program that will produce the main part of the
* buiiltin help file. These rules will convert the following function
* name into main and remove the 'sed me out' line.
* buiiltin help file.
*
* See the builtin rule in the help/Makefile for details.
*/
void /* sed me out */
#if defined(FUNCLIST)
/*ARGSUSED*/
int
main(int argc, char *argv[])
{
CONST struct builtin *bp; /* current function */
printf("\nName\tArgs\tDescription\n\n");
for (bp = builtins; bp->b_name; bp++) {
printf("%-9s ", bp->b_name);
if (bp->b_maxargs == IN)
printf("%d+ ", bp->b_minargs);
else if (bp->b_minargs == bp->b_maxargs)
printf("%-6d", bp->b_minargs);
else
printf("%d-%-4d", bp->b_minargs, bp->b_maxargs);
printf("%s\n", bp->b_desc);
}
printf("\n");
return 0; /* exit(0); */
}
#else /* FUNCLIST */
void
showbuiltins(void)
{
CONST struct builtin *bp; /* current function */
@@ -7357,6 +7394,7 @@ showbuiltins(void)
}
printf("\n");
}
#endif /* FUNCLIST */
#if !defined(FUNCLIST)

62
have_rusage.c Normal file
View File

@@ -0,0 +1,62 @@
/*
* have_rusage - Determine if we getrusage()
*
* usage:
* have_rusage
*
* Not all systems have the getrusage() function, so this may not
* compile on your system.
*
* This prog outputs several defines:
*
* HAVE_GETRUSAGE
* defined ==> use getrusage()
* undefined ==> do not call or cannot call getrusage()
*/
/*
* Copyright (c) 1999 by Landon Curt Noll. All Rights Reserved.
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby granted,
* provided that the above copyright, this permission notice and text
* this comment, and the disclaimer below appear in all of the following:
*
* supporting documentation
* source copies
* source works derived from this source
* binaries derived from this source or from derived source
*
* LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
* EVENT SHALL LANDON CURT NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
* chongo was here /\../\
*/
#include <sys/time.h>
#include <sys/resource.h>
int
main(void)
{
#if defined(HAVE_NO_GETRUSAGE)
printf("#undef HAVE_GETRUSAGE /* no */\n");
#else /* HAVE_NO_GETRUSAGE */
struct rusage rusage; /* resource utilization */
(void) getrusage(RUSAGE_SELF, &rusage);
printf("#define HAVE_GETRUSAGE /* yes */\n");
#endif /* HAVE_NO_GETRUSAGE */
/* exit(0); */
return 0;
}

62
have_strdup.c Normal file
View File

@@ -0,0 +1,62 @@
/*
* have_strdup - Determine if we strdup()
*
* usage:
* have_strdup
*
* Not all systems have the strdup() function, so this may not
* compile on your system.
*
* This prog outputs several defines:
*
* HAVE_STRDUP
* defined ==> use strdup()
* undefined ==> do not call or cannot call strdup()
*/
/*
* Copyright (c) 1999 by Landon Curt Noll. All Rights Reserved.
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby granted,
* provided that the above copyright, this permission notice and text
* this comment, and the disclaimer below appear in all of the following:
*
* supporting documentation
* source copies
* source works derived from this source
* binaries derived from this source or from derived source
*
* LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
* EVENT SHALL LANDON CURT NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
* chongo was here /\../\
*/
#include <string.h>
int
main(void)
{
#if defined(HAVE_NO_STRDUP)
printf("#undef HAVE_STRDUP /* no */\n");
#else /* HAVE_NO_STRDUP */
char *p;
p = strdup("#define HAVE_STRDUP /* yes */");
if (p != NULL) {
printf("%s\n", p);
}
#endif /* HAVE_NO_STRDUP */
/* exit(0); */
return 0;
}

View File

@@ -35,13 +35,12 @@ Q=@
# standard tools
#
NATIVE_CC= cc
NATIVE_CFLAGS=
LCC= cc
ICFLAGS=
ILDFLAGS=
SED= sed
SORT= sort
FMT= fmt
CMP= cmp
CAT= cat
# Standard and Builtin help files
#
@@ -234,7 +233,7 @@ bugs: ../BUGS
errorcodes: ../calcerr.h errorcodes.hdr errorcodes.sed
rm -f $@
${CAT} errorcodes.hdr > $@
cat errorcodes.hdr > $@
${SED} -n -f errorcodes.sed < ../calcerr.h >> $@
chmod 0444 $@
-@if [ -z "${Q}" ]; then \
@@ -359,17 +358,13 @@ ${SINGULAR_FILES}: ${PLURAL_FILES}
#
builtin: builtin.top builtin.end ../func.c funclist.sed
${Q}echo "forming builtin help file"
-${Q}rm -f builtin
${Q}cat builtin.top > builtin
-${Q}rm -f funclist.c
${Q}${SED} -n -f funclist.sed ../func.c > funclist.c
-${Q}rm -f ../funclist.c ../funclist.o ../funclist funclist
${Q}cp funclist.c ..
-${Q}(cd ..; \
${NATIVE_CC} ${NATIVE_CFLAGS} -DFUNCLIST funclist.c -o funclist; \
mv funclist help; \
rm -f funclist.c funclist.o funclist)
-${Q}rm -f funclist.o funclist
${Q}${LCC} ${ICFLAGS} -DFUNCLIST -I/usr/include -I.. funclist.c -c
${Q}${LCC} ${ILDFLAGS} funclist.o -o funclist
-${Q}rm -f builtin
${Q}cat builtin.top > builtin
${Q}./funclist | \
${SED} -e 's/^/ /' -e 's/[ ][ ]*$$//' >> builtin
${Q}cat builtin.end >> builtin

View File

@@ -11,6 +11,6 @@ Where to get the the latest versions of calc
for information on how to obtain up a recent version of calc.
Landon Curt Noll
http://reality.sgi.com/chongo
http://reality.sgi.com/chongo/
chongo <was here> /\../\

View File

@@ -58,6 +58,6 @@ One may join the calc testing group by sending a request to:
is your full name.
Landon Curt Noll
http://reality.sgi.com/chongo
http://reality.sgi.com/chongo/
chongo <was here> /\../\

View File

@@ -3,7 +3,5 @@ s/NUMBER[ ]*\*/int /
s/NUMBER/int/
s/STRINGHEAD/int/
s/\(".*",.*,.*\),.*,.*,.*,.*,/\1, 0, 0, 0, 0,/
/sed me out/d
s/showbuiltins/main/
s/[ ][ ]*$//
p

View File

@@ -15,12 +15,12 @@ DESCRIPTION
The basis of this hash algorithm was taken from an idea sent
as reviewer comments to the IEEE POSIX P1003.2 committee by:
Phong Vo (http://www.research.att.com/info/kpv)
Phong Vo (http://www.research.att.com/info/kpv/)
Glenn Fowler (http://www.research.att.com/~gsf/)
In a subsequent ballot round:
Landon Curt Noll (http://reality.sgi.com/chongo)
Landon Curt Noll (http://reality.sgi.com/chongo/)
improved on their algorithm. Some people tried this hash
and found that it worked rather well. In an EMail message

View File

@@ -19,9 +19,9 @@ DESCRIPTION
is almost certainly non-chaotic. This function is likely not
suitable for applications (such as cryptographic applications)
where the unpredictability of seeds is critical. For such critical
applications, lavarand should be used. Seed:
applications, lavarand should be used. See the URL:
http://lavarand.sgi.com
http://lavarand.sgi.com/index.html
for information about seeding a pseudo-random number generator
(such as rand() or random()) with the cryptographic hash of the

View File

@@ -222,8 +222,7 @@ DESCRIPTION
The pre-defined Blum moduli and quadratic residues were selected
by lavarand, a hardware random number generator. See the URL:
http://lavarand.sgi.com
XXX - This URL is not available on 17Feb97 ... but will be soon.
http://lavarand.sgi.com/index.html
for an explanation of how the lavarand random number generator works.
For more information, see the comments at the top of the calc

View File

@@ -50,6 +50,8 @@ Very High priority items:
* Fix any 'Known bugs' as noted in the BUGS file or as
displayed by 'calc help bugs'.
* Copyleft calc and place it under a LGPL.
=-=
High priority items:
@@ -79,10 +81,9 @@ High priority items:
then a $PAGER should be forked and execed after doing things such
as closing open file descriptors that the $PAGER does not need.
* Inspect changes made since the last major calc release (the
initial x.y.z version ... prior to any t sub-version) to help
ensure that they have not introduced new or re-introduced old bugs
into calc.
* The arg passdown to the lower level Makfiles should be reviewed
to determine which items really need to be passed down. The lower
level Makefiles should default to the shipped values.
* Consider using configure to build the calc Makefile.

67
hist.c
View File

@@ -31,6 +31,11 @@
#include "terminal.h"
#include "have_string.h"
#include "have_strdup.h"
#if !defined(HAVE_STRDUP)
# define strdup(x) calc_strdup((CONST char *)(x))
#endif /* HAVE_STRDUP */
#if defined(USE_TERMIOS)
# include <termios.h>
@@ -1440,8 +1445,11 @@ quit_calc(void)
#else /* USE_READLINE */
#include <readline.h>
#include <history.h>
#define HISTORY_LEN (1024) /* number of entries to save */
#include <readline/readline.h>
#include <readline/history.h>
/*
@@ -1454,6 +1462,9 @@ quit_calc(void)
*/
/* name of history file */
char *my_calc_history = NULL;
int
hist_getline(char *prompt, char *buf, int len)
{
@@ -1473,31 +1484,69 @@ hist_getline(char *prompt, char *buf, int len)
}
int
hist_init(char *filename)
{
return HIST_SUCCESS;
}
void
hist_term(void)
{
}
static void
my_stifle_history (void)
{
/* only save last number of entries */
stifle_history(HISTORY_LEN);
if (my_calc_history)
write_history(my_calc_history);
}
int
hist_init(char *filename)
{
/* used when parsing conditionals in ~/.inputrc */
rl_readline_name = "calc";
/* initialize interactive variables */
using_history();
/* name of history file */
my_calc_history = tilde_expand("~/.calc_history");
/* read previous history */
read_history(my_calc_history);
atexit(my_stifle_history);
return HIST_SUCCESS;
}
void
hist_saveline(char *line, int len)
{
static char *prev = NULL;
if (!len)
return;
/* ignore if identical with previous line */
if (prev != NULL && strcmp(prev, line) == 0)
return;
free (prev);
/* fail silently */
prev = strdup(line);
line[len - 1] = '\0';
add_history(line);
line[len - 1] = '\n';
}
#endif /* USE_READLINE */
#if defined(HIST_TEST)
/*

View File

@@ -273,10 +273,18 @@ pell.cal
pi.cal
qpi(epsilon)
piforever()
Calculate pi within the specified epsilon using the quartic convergence
iteration.
The qpi() calculate pi within the specified epsilon using the quartic
convergence iteration.
The piforever() prints digits of pi, nicely formatted, for as long
as your free memory space and system up time allows.
The piforever() funcion (written by Klaus Alexander Seistrup
<klaus@seistrup.dk>) was inspired by an algorithm conceived by
Lambert Meertens. See also the ABC Programmer's Handbook, by Geurts,
Meertens & Pemberton, published by Prentice-Hall (UK) Ltd., 1990.
pix.cal

View File

@@ -86,7 +86,7 @@
* i.e., any value that is 301 mod 420.
*
* Written by: Ernest W Bowen <ernie@neumann.une.edu.au>
* Interface by: Landon Curt Noll http://reality.sgi.com/chongo
* Interface by: Landon Curt Noll http://reality.sgi.com/chongo/
*/
static defaultmlist = list(2,3,5,7,11,13,17,19); /* The first eight primes */

View File

@@ -20,7 +20,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*
* Landon Curt Noll
* http://reality.sgi.com/chongo
* http://reality.sgi.com/chongo/
*
* chongo <was here> /\../\
*/

View File

@@ -20,7 +20,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*
* Landon Curt Noll
* http://reality.sgi.com/chongo
* http://reality.sgi.com/chongo/
*
* chongo <was here> /\../\
*/

View File

@@ -20,7 +20,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*
* Landon Curt Noll
* http://reality.sgi.com/chongo
* http://reality.sgi.com/chongo/
*
* chongo <was here> /\../\
*/

View File

@@ -20,7 +20,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*
* Landon Curt Noll
* http://reality.sgi.com/chongo
* http://reality.sgi.com/chongo/
*
* chongo <was here> /\../\
*/

View File

@@ -47,3 +47,75 @@ define qpi(epsilon)
}
return (bround(1/an, bits));
}
/*
* Print digits of PI forever, neatly formatted, using calc.
*
* Written by Klaus Alexander Seistrup <klaus@seistrup.dk>
* on a dull Friday evening in November 1999.
*
* Inspired by an algorithm conceived by Lambert Meertens.
*
* See also the ABC Programmer's Handbook, by Geurts, Meertens & Pemberton,
* published by Prentice-Hall (UK) Ltd., 1990.
*
*/
define piforever()
{
local k = 2;
local a = 4;
local b = 1;
local a1 = 12;
local b1 = 4;
local a2, b2, p, q, d, d1;
local stdout = files(1);
local first = 1, row = -1, col = 0;
while (1) {
/*
* Next approximation
*/
p = k * k;
q = k + k++;
a2 = a;
b2 = b;
a = a1;
a1 = p * a2 + q * a1;
b = b1;
b1 = p * b2 + q * b1;
/*
* Print common digits
*/
d = a // b;
d1 = a1 // b1;
while (d == d1) {
if (first) {
printf("%d.", d);
first = 0;
} else {
if (!(col % 50)) {
printf("\n");
col = 0;
if (!(++row % 20)) {
printf("\n");
row = 0;
}
}
printf("%d", d);
if (!(++col % 10))
printf(" ");
}
a = 10 * (a % b);
a1 = 10 * (a1 % b1);
d = a // b;
d1 = a1 // b1;
}
fflush(stdout);
}
}

View File

@@ -7,7 +7,7 @@
* utc_hr_offset Offset from UTC in hours.
*
* Written by: Klaus Alexander Seistrup <kseis@magnetic-ink.dk>
* With minor mods by: Landon Curt Noll <http://reality.sgi.com/chongo>
* With minor mods by: Landon Curt Noll <http://reality.sgi.com/chongo/>
*
* See:
* http://www.magnetic-ink.dk/download/qtime.html

View File

@@ -22,7 +22,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*
* Landon Curt Noll
* http://reality.sgi.com/chongo
* http://reality.sgi.com/chongo/
*
* chongo <was here> /\../\
*/

View File

@@ -1694,6 +1694,7 @@ define test_obj()
{
static obj surd a;
static obj surd b;
local PP;
print '1800: Beginning object test';
@@ -1731,7 +1732,10 @@ define test_obj()
vrfy(a <= a, '1828: a < a');
vrfy(isobj(a) == 1, '1829: isobj(a) == 1');
print '1830: Ending object test';
obj pt {x,y}, PP = obj pair {A,B} = {obj pt, obj pt};
print '1830: obj pt {x,y}, PP = obj pair {A,B} = {obj pt, obj pt}';
print '1831: Ending object test';
}
print '028: parsed test_obj()';
@@ -2867,7 +2871,7 @@ print '053: parsed test_frem()';
*/
define test_error()
{
local strx, e99, list1, e999;
local strx, e99, list1, e9999;
local a, b, c, n, x; /* used by newerror() */
print '3600: Beginning test_error';
@@ -3040,11 +3044,12 @@ define test_error()
'3710: newerror() == newerror("???")');
vrfy(newerror("") == newerror(),
'3711: newerror("") == newerror()');
e999 = error(999);
print '3712: e999 = error(999)';
vrfy(errno() == 999, '3713: errno() == 999');
vrfy(error() == e999, '3714: error() == e999');
vrfy(strerror() == "Error 999", '3715: strerror() == "Error 999"');
e9999 = error(9999);
print '3712: e9999 = error(9999)';
vrfy(errno() == 9999, '3713: errno() == 9999');
vrfy(error() == e9999, '3714: error() == e9999');
vrfy(strerror() == "Unknown error 9999",
'3715: strerror() == "Unknown error 9999"');
x = newerror("Alpha");
print '3716: x = newerror("Alpha")';
n = iserror(x);
@@ -3052,10 +3057,11 @@ define test_error()
vrfy(errno() == n, '3718: errno() == n');
vrfy(error() == x, '3719: error() == x');
vrfy(strerror() == "Alpha", '3720: strerror() == "Alpha"');
vrfy(errno(999) == n, '3721: errno() == n');
vrfy(errno() == 999, '3722: errno() == 999');
vrfy(error() == e999, '3723: error() == e999');
vrfy(strerror() == "Error 999", '3724: strerror() == "Error 999"');
vrfy(errno(9999) == n, '3721: errno() == n');
vrfy(errno() == 9999, '3722: errno() == 9999');
vrfy(error() == e9999, '3723: error() == e9999');
vrfy(strerror() == "Unknown error 9999",
'3724: strerror() == "Unknown error 9999"');
a = 1/0;
print '3725: a = 1/0';
vrfy(strerror() == "Division by zero",
@@ -4687,8 +4693,8 @@ define test_commaeq()
/*
* matrix assignment
*/
mat A[3] = {1,2,3}, B[2] = {1,2};
print '5625: mat A[3] = {1,2,3}, B[2] = {1,2}';
mat A[3] = {1,2,3}, mat B[2] = {1,2};
print '5625: mat A[3] = {1,2,3}, mat B[2] = {1,2}';
vrfy(A[0] == 1, '5626: A[0] == 1');
vrfy(B[1] == 2, '5627: B[1] == 2');
@@ -4916,8 +4922,8 @@ define test_assign(base, work)
print base+3: ': X5800 = base+3';
Y5800 = base+4;
print base+4: ': Y5800 = base+4';
obj xy5800 A={1,2}, B={3,4};
print base+5: ': obj xy5800 A={1,2}, B={3,4}';
obj xy5800 A={1,2}, obj xy5800 B={3,4};
print base+5: ': obj xy5800 A={1,2}, obj xy5000 B={3,4}';
/*
* test assignment
@@ -7372,7 +7378,7 @@ vrfy(X5800 == (obj xy5800 = {3,9}),
'5859: X5800 == (obj xy5800 = {3,9})');
vrfy(errno() > 0, '5860: errno() > 0');
vrfy(strerror() == "Incompatible types for =",
'5861: strerror() == "Incompatible types for ="');
'5861: strerror() == "Incompatible types for ="');
X5800 = 2;
print '5862: X5800 = 2';
vrfy(X5800 == (obj xy5800 = {2,0}),
@@ -7381,7 +7387,10 @@ X5800 = obj xy5800 = {1,2};
print '5864: X5800 = obj xy5800 = {1,2}';
vrfy(X5800 == (obj xy5800 = {1,2}),
'5865: X5800 == (obj xy5800 = {1,2})');
print '5866: End of 5800 sequence';
define f5800(a8500 = mat[2] = {3,4}) = 5 * a8500;
print '5866: define f5800(a8500 = mat[2] = {3,4}) = 5 * a8500;'
vrfy(f5800() == (mat[] = {15,20}),'5867: f5800() == (mat[] = {15,20})');
print '5868: End of 5800 sequence';
print;
return test_is();

View File

@@ -20,7 +20,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*
* Landon Curt Noll
* http://reality.sgi.com/chongo
* http://reality.sgi.com/chongo/
*
* chongo <was here> /\../\
*/

View File

@@ -4,7 +4,7 @@
* provided that this copyright notice remains intact.
*
* By: Landon Curt Noll
* http://reality.sgi.com/chongo
* http://reality.sgi.com/chongo/
*
* chongo <was here> /\../\
*

View File

@@ -4,7 +4,7 @@
* provided that this copyright notice remains intact.
*
* By: Landon Curt Noll
* http://reality.sgi.com/chongo
* http://reality.sgi.com/chongo/
*
* chongo <was here> /\../\
*

View File

@@ -4,7 +4,7 @@
* provided that this copyright notice remains intact.
*
* By: Ernest Bowen and Landon Curt Noll
* ernie@neumann.une.edu.au and http://reality.sgi.com/chongo
* ernie@neumann.une.edu.au and http://reality.sgi.com/chongo/
*
* This library is used by the 2600 series of the regress.cal test suite.
*/

View File

@@ -4,7 +4,7 @@
* provided that this copyright notice remains intact.
*
* By: Ernest Bowen and Landon Curt Noll
* ernie@neumann.une.edu.au and http://reality.sgi.com/chongo
* ernie@neumann.une.edu.au and http://reality.sgi.com/chongo/
*
* This library is used by the 2700 series of the regress.cal test suite.
*/

View File

@@ -4,7 +4,7 @@
* provided that this copyright notice remains intact.
*
* By: Ernest Bowen and Landon Curt Noll
* ernie@neumann.une.edu.au and http://reality.sgi.com/chongo
* ernie@neumann.une.edu.au and http://reality.sgi.com/chongo/
*
* This library is used by the 3100 series of the regress.cal test suite.
*/

View File

@@ -4,7 +4,7 @@
* provided that this copyright notice remains intact.
*
* By: Ernest Bowen and Landon Curt Noll
* ernie@neumann.une.edu.au and http://reality.sgi.com/chongo
* ernie@neumann.une.edu.au and http://reality.sgi.com/chongo/
*
* This library is used by the 3300 series of the regress.cal test suite.
*/

View File

@@ -4,7 +4,7 @@
* provided that this copyright notice remains intact.
*
* By: Ernest Bowen and Landon Curt Noll
* ernie@neumann.une.edu.au and http://reality.sgi.com/chongo
* ernie@neumann.une.edu.au and http://reality.sgi.com/chongo/
*
* This library is used by the 3400 series of the regress.cal test suite.
*/

View File

@@ -4,7 +4,7 @@
* provided that this copyright notice remains intact.
*
* By: Ernest Bowen and Landon Curt Noll
* ernie@neumann.une.edu.au and http://reality.sgi.com/chongo
* ernie@neumann.une.edu.au and http://reality.sgi.com/chongo/
*
* This library is used by the 3500 series of the regress.cal test suite.
*/

View File

@@ -4,7 +4,7 @@
* provided that this copyright notice remains intact.
*
* By: Ernest Bowen and Landon Curt Noll
* ernie@neumann.une.edu.au and http://reality.sgi.com/chongo
* ernie@neumann.une.edu.au and http://reality.sgi.com/chongo/
*
* This library is used by the 4000 series of the regress.cal test suite.
*/

View File

@@ -4,7 +4,7 @@
* provided that this copyright notice remains intact.
*
* By: Ernest Bowen and Landon Curt Noll
* ernie@neumann.une.edu.au and http://reality.sgi.com/chongo
* ernie@neumann.une.edu.au and http://reality.sgi.com/chongo/
*
* This library is used by the 4100 series of the regress.cal test suite.
*/

View File

@@ -4,7 +4,7 @@
* provided that this copyright notice remains intact.
*
* By: Ernest Bowen and Landon Curt Noll
* ernie@neumann.une.edu.au and http://reality.sgi.com/chongo
* ernie@neumann.une.edu.au and http://reality.sgi.com/chongo/
*
* This library is used by the 4600 series of the regress.cal test suite.
*/

View File

@@ -4,7 +4,7 @@
* provided that this copyright notice remains intact.
*
* By: Ernest Bowen and Landon Curt Noll
* ernie@neumann.une.edu.au and http://reality.sgi.com/chongo
* ernie@neumann.une.edu.au and http://reality.sgi.com/chongo/
*
* This library is used by the 5100 series of the regress.cal test suite.
*/

View File

@@ -4,7 +4,7 @@
* provided that this copyright notice remains intact.
*
* By: Ernest Bowen and Landon Curt Noll
* ernie@neumann.une.edu.au and http://reality.sgi.com/chongo
* ernie@neumann.une.edu.au and http://reality.sgi.com/chongo/
*
* This library is used by the 5200 series of the regress.cal test suite.
*/

View File

@@ -4,7 +4,7 @@
* provided that this copyright notice remains intact.
*
* By: Landon Curt Noll
* http://reality.sgi.com/chongo
* http://reality.sgi.com/chongo/
*
* chongo <was here> /\../\
*

View File

@@ -34,6 +34,11 @@
#include "symbol.h"
#include "func.h"
#include "have_strdup.h"
#if !defined(HAVE_STRDUP)
# define strdup(x) calc_strdup((CONST char *)(x))
#endif /* HAVE_STRDUP */
#include "have_unistd.h"
#if defined(HAVE_UNISTD_H)
#include <unistd.h>
@@ -310,14 +315,17 @@ static void
initenv(void)
{
struct passwd *ent; /* our password entry */
char *c;
/* determine the $CALCPATH value */
calcpath = (no_env ? NULL : getenv(CALCPATH));
c = getenv(CALCPATH);
calcpath = ((no_env || c == NULL) ? NULL : strdup(c));
if (calcpath == NULL)
calcpath = DEFAULTCALCPATH;
/* determine the $CALCRC value */
calcrc = (no_env ? NULL : getenv(CALCRC));
c = getenv(CALCRC);
calcrc = ((no_env || c == NULL) ? NULL : strdup(c));
if (calcrc == NULL) {
calcrc = DEFAULTCALCRC;
}
@@ -328,13 +336,15 @@ initenv(void)
}
/* determine the $CALCBINDINGS value */
calcbindings = (no_env ? NULL : getenv(CALCBINDINGS));
c = getenv(CALCBINDINGS);
calcbindings = ((no_env || c == NULL) ? NULL : strdup(c));
if (calcbindings == NULL) {
calcbindings = DEFAULTCALCBINDINGS;
}
/* determine the $HOME value */
home = (no_env ? NULL : getenv(HOME));
c = getenv(HOME);
home = ((no_env || c == NULL) ? NULL : strdup(c));
if (home == NULL || home[0] == '\0') {
ent = (struct passwd *)getpwuid(geteuid());
if (ent == NULL) {
@@ -346,13 +356,15 @@ initenv(void)
}
/* determine the $PAGER value */
pager = (no_env ? NULL : getenv(PAGER));
c = getenv(PAGER);
pager = ((no_env || c == NULL) ? NULL : strdup(c));
if (pager == NULL || *pager == '\0') {
pager = DEFAULTCALCPAGER;
}
/* determine the $SHELL value */
shell = (no_env ? NULL : getenv(SHELL));
c = getenv(SHELL);
shell = ((no_env || c == NULL) ? NULL : strdup(c));
if (shell == NULL)
shell = DEFAULTSHELL;
}
@@ -424,3 +436,45 @@ run_state_name(run state)
}
return "RUN_invalid";
}
/*
* calc_strdup - calc interface to provide or simulate strdup()
*/
char *
calc_strdup(CONST char *s1)
{
#if defined(HAVE_STRDUP)
return strdup(s1);
#else /* HAVE_STRDUP */
char *ret; /* return string */
/*
* firewall
*/
if (s1 == NULL) {
return NULL;
}
/*
* allocate duplicate storage
*/
ret = (char *)malloc(sizeof(char) * (strlen(s1)+1));
/*
* if we have storage, duplicate the string
*/
if (ret != NULL) {
strcpy(ret, s1);
}
/*
* return the new string, or NULL if malloc failed
*/
return ret;
#endif /* HAVE_STRDUP */
}

View File

@@ -62,8 +62,8 @@
/*
* have the compiler try its hand with unsigned and signed long longs
*/
unsigned long long val = 4294967297ULL;
long long val2 = -4294967297LL;
unsigned long long val = 0x1234567890123456ULL;
long long val2 = -1311768467284833366LL; /* -0x1234567890123456 */
int
@@ -90,14 +90,20 @@ main(int argc, char **argv)
if (longlong_bits > 0) {
/*
* if size is longer than an unsigned long, use it
* if size is longer than an unsigned long,
* and the negative 'long long' works, then use long long's
*/
if (longlong_bits > sizeof(unsigned long)*8) {
if (longlong_bits > sizeof(unsigned long)*8 && val2 < 0) {
/* use long long length */
printf("#define HAVE_LONGLONG\n");
printf("#define LONGLONG_BITS %d /* yes */\n",
longlong_bits);
printf("\n/* does %%lld work or does %%ld? */\n");
printf("#if defined(CHECK_L_FORMAT)\n");
printf("long long l_format = %ld;\n", val);
printf("#endif /* CHECK_L_FORMAT */\n");
}
}
/* exit(0); */

View File

@@ -28,7 +28,7 @@
* Happy bit twiddling,
*
* Landon Curt Noll
* http://reality.sgi.com/chongo
* http://reality.sgi.com/chongo/
*
* chongo <was here> /\../\
*/

View File

@@ -29,7 +29,7 @@
* Happy bit twiddling,
*
* Landon Curt Noll
* http://reality.sgi.com/chongo
* http://reality.sgi.com/chongo/
*
* chongo <was here> /\../\
*/

10
obj.c
View File

@@ -579,6 +579,16 @@ findelement(char *name)
}
/*
* Returns the name of object type with specified index
*/
char *
objtypename(unsigned long index)
{
return namestr(&objectnames, (long)index);
}
/*
* Return the value table offset to be used for an object element name.
* This converts the element index from the element table into an offset

View File

@@ -3773,11 +3773,14 @@ dumpop(unsigned long *pc)
return 3;
case OP_PRINT: case OP_JUMPZ: case OP_JUMPNZ: case OP_JUMP:
case OP_CONDORJUMP: case OP_CONDANDJUMP: case OP_CASEJUMP:
case OP_INITSTATIC: case OP_MATCREATE: case OP_OBJCREATE:
case OP_INITSTATIC: case OP_MATCREATE:
case OP_SHOW: case OP_ELEMINIT: case OP_ELEMADDR:
case OP_ELEMVALUE: case OP_JUMPNN:
printf(" %ld\n", *pc);
return 2;
case OP_OBJCREATE:
printf(" %s\n", objtypename(*pc));
return 2;
case OP_NUMBER: case OP_IMAGINARY:
qprintf(" %r", constvalue(*pc));
printf("\n");

2
poly.c
View File

@@ -4,7 +4,7 @@
* provided that this copyright notice remains intact.
*
* By: Ernest Bowen and Landon Curt Noll
* ernie@neumann.une.edu.au and http://reality.sgi.com/chongo
* ernie@neumann.une.edu.au and http://reality.sgi.com/chongo/
*/
#include "value.h"

View File

@@ -20,7 +20,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*
* Landon Curt Noll
* http://reality.sgi.com/chongo
* http://reality.sgi.com/chongo/
*
* chongo <was here> /\../\
*/
@@ -80,12 +80,12 @@ static QCKHASH blk_hash(BLOCK *blk, QCKHASH val);
* The basis of this hash algorithm was taken from an idea sent
* as reviewer comments to the IEEE POSIX P1003.2 committee by:
*
* Phong Vo (http://www.research.att.com/info/kpv)
* Phong Vo (http://www.research.att.com/info/kpv/)
* Glenn Fowler (http://www.research.att.com/~gsf/)
*
* In a subsequent ballot round:
*
* Landon Curt Noll (http://reality.sgi.com/chongo)
* Landon Curt Noll (http://reality.sgi.com/chongo/)
*
* improved on their algorithm. Some people tried this hash
* and found that it worked rather well. In an EMail message

View File

@@ -27,7 +27,7 @@
# Happy bit twiddling,
#
# Landon Curt Noll
# http://reality.sgi.com/chongo
# http://reality.sgi.com/chongo/
#
# chongo <was here> /\../\
@@ -398,11 +398,11 @@ depend:
else \
rm -f Makefile.tmp; \
mv Makefile Makefile.tmp; \
if [ -d RCS ]; then; \
if [ -d RCS ]; then \
co -l Makefile; \
fi; \
mv Makefile.tmp Makefile; \
if [ -d RCS ]; then; \
if [ -d RCS ]; then \
echo new sample Makefile formed, you need to check it in; \
fi; \
fi

22
seed.c
View File

@@ -6,7 +6,7 @@
* NOTE: This is not a good source of chaotic data. The lavarand
* system does a much better job of that. See:
*
* http://lavarand.sgi.com
* http://lavarand.sgi.com/index.html
*
* Copyright (c) 1999 by Landon Curt Noll. All Rights Reserved.
*
@@ -29,7 +29,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*
* Landon Curt Noll
* http://reality.sgi.com/chongo
* http://reality.sgi.com/chongo/
*
* chongo <was here> /\../\
*
@@ -53,6 +53,9 @@
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
#include <sys/time.h>
#include <sys/times.h>
#include <sys/resource.h>
#include <setjmp.h>
#include "qmath.h"
@@ -63,6 +66,7 @@
#include "have_gettime.h"
#include "have_getprid.h"
#include "have_urandom.h"
#include "have_rusage.h"
#if defined(HAVE_USTAT)
# include <ustat.h>
#endif /* HAVE_USTAT */
@@ -157,12 +161,12 @@ hash_buf(char *buf, unsigned len)
* The basis of this hash algorithm was taken from an idea sent
* as reviewer comments to the IEEE POSIX P1003.2 committee by:
*
* Phong Vo (http://www.research.att.com/info/kpv)
* Phong Vo (http://www.research.att.com/info/kpv/)
* Glenn Fowler (http://www.research.att.com/~gsf/)
*
* In a subsequent ballot round:
*
* Landon Curt Noll (http://reality.sgi.com/chongo)
* Landon Curt Noll (http://reality.sgi.com/chongo/)
*
* improved on their algorithm. Some people tried this hash
* and found that it worked rather well. In an EMail message
@@ -248,7 +252,7 @@ hash_buf(char *buf, unsigned len)
* NOTE: This is not a good source of chaotic data. The lavarand
* system does a much better job of that. See:
*
* http://lavarand.sgi.com
* http://lavarand.sgi.com/index.html
*
* PORTING NOTE:
* If when porting this code to your system and something
@@ -308,9 +312,13 @@ pseudo_seed(void)
#if defined(HAVE_GETPGID)
pid_t getpgid; /* process group ID */
#endif /* HAVE_GETPGID */
#if defined(HAVE_GETRUSAGE)
struct rusage rusage; /* resource utilization */
struct rusage rusage_chld; /* resource utilization of children */
#endif /* HAVE_GETRUSAGE */
struct timeval tp2; /* time of day again */
struct tms times; /* process times */
time_t time; /* local time */
size_t size; /* size of this data structure */
jmp_buf env; /* setjmp() context */
char *sdata_p; /* address of this structure */
@@ -377,9 +385,13 @@ pseudo_seed(void)
#if defined(HAVE_GETPGID)
sdata.getpgid = getpgid((pid_t)0);
#endif /* HAVE_GETPGID */
#if defined(HAVE_GETRUSAGE)
(void) getrusage(RUSAGE_SELF, &sdata.rusage);
(void) getrusage(RUSAGE_CHILDREN, &sdata.rusage_chld);
#endif /* HAVE_GETRUSAGE */
(void) gettimeofday(&sdata.tp2, NULL);
(void) times(&sdata.times);
sdata.time = time(NULL);
sdata.size = sizeof(sdata);
(void) setjmp(sdata.env);
sdata.sdata_p = (char *)&sdata;

4
shs.c
View File

@@ -12,7 +12,7 @@
* This file was Modified/Re-written by:
*
* Landon Curt Noll
* http://reality.sgi.com/chongo
* http://reality.sgi.com/chongo/
*
* chongo <was here> /\../\
*
@@ -29,7 +29,7 @@
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Based on Version 2.11 (09 Mar 1995) from Landon Curt Noll's
* (http://reality.sgi.com/chongo) shs hash program.
* (http://reality.sgi.com/chongo/) shs hash program.
*
****
*

2
shs.h
View File

@@ -12,7 +12,7 @@
* This file was Modified by:
*
* Landon Curt Noll
* http://reality.sgi.com/chongo
* http://reality.sgi.com/chongo/
*
* chongo <was here> /\../\
*

2
shs1.c
View File

@@ -6,7 +6,7 @@
* This file was Modified/Re-written by:
*
* Landon Curt Noll
* http://reality.sgi.com/chongo
* http://reality.sgi.com/chongo/
*
* chongo <was here> /\../\
*

2
shs1.h
View File

@@ -6,7 +6,7 @@
* This file was Modified by:
*
* Landon Curt Noll
* http://reality.sgi.com/chongo
* http://reality.sgi.com/chongo/
*
* chongo <was here> /\../\
*

View File

@@ -175,7 +175,10 @@ showglobals(void)
printf("\n");
}
}
printf(count ? "\n" : "No real-valued global variables\n");
if (count == 0) {
printf("No real-valued global variables\n");
}
putchar('\n');
}

View File

@@ -22,8 +22,6 @@
#define LINELEN 80 /* length of a typical tty line */
extern int sys_nerr;
/*
* Free a value and set its type to undefined.
*
@@ -2694,7 +2692,7 @@ printvalue(VALUE *vp, int flags)
if (type < 0) {
if (userfunc("error_print", vp))
return;
if (-type >= sys_nerr)
if (-type >= E__BASE)
printf("Error %d", -type);
else
printf("System error %d", -type);

View File

@@ -451,6 +451,7 @@ extern int checkobject(char *name);
extern void showobjfuncs(void);
extern void showobjtypes(void);
extern int findelement(char *name);
extern char *objtypename(unsigned long index);
extern int objoffset(OBJECT *op, long index);

View File

@@ -7,12 +7,18 @@
*/
#include <stdio.h>
#include "calc.h"
#if defined(CALC_VER)
#include <stdlib.h>
#include <unistd.h>
static char *program;
#else
# include "calc.h"
#endif
#define MAJOR_VER 2 /* major version */
#define MINOR_VER 11 /* minor version */
#define MAJOR_PATCH 0 /* patch level or 0 if no patch */
#define MINOR_PATCH "9.3.1" /* test number or empty string if no patch */
#define MINOR_PATCH "9.4.3" /* test number or empty string if no patch */
/*
* calc version constants
@@ -84,8 +90,6 @@ version(void)
#if defined(CALC_VER)
char *program; /* our name */
/*
* version - print the calc version
*/

View File

@@ -29,7 +29,7 @@
* Happy bit twiddling,
*
* Landon Curt Noll
* http://reality.sgi.com/chongo
* http://reality.sgi.com/chongo/
*
* chongo <was here> /\../\
*/

View File

@@ -29,7 +29,7 @@
* Happy bit twiddling,
*
* Landon Curt Noll
* http://reality.sgi.com/chongo
* http://reality.sgi.com/chongo/
*
* chongo <was here> /\../\
*/

View File

@@ -29,7 +29,7 @@
* Happy bit twiddling,
*
* Landon Curt Noll
* http://reality.sgi.com/chongo
* http://reality.sgi.com/chongo/
*
* chongo <was here> /\../\
*/
@@ -365,8 +365,7 @@
* were selected by lavarand, a hardware random number generator.
* See the URL:
*
* http://lavarand.sgi.com
* XXX - This URL is not available on 17Feb97 ... but will be soon.
* http://lavarand.sgi.com/index.html
*
* for an explination of how the lavarand random number generator works.
*

View File

@@ -29,7 +29,7 @@
* Happy bit twiddling,
*
* Landon Curt Noll
* http://reality.sgi.com/chongo
* http://reality.sgi.com/chongo/
*
* chongo <was here> /\../\
*/