Release calc version 2.11.0t9.4

This commit is contained in:
Landon Curt Noll
1999-11-05 05:04:03 -08:00
parent df32e3956d
commit afb0e5c32a
13 changed files with 375 additions and 111 deletions

28
CHANGES
View File

@@ -116,6 +116,34 @@ Following is the change from calc version 2.11.0t8.9.1 to date:
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.
Following is the change from calc version 2.11.0t8 to 2.11.0t8.9:

197
Makefile
View File

@@ -261,6 +261,18 @@ 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
# Some architectures such as Sparc do not allow one to access 32 bit values
# that are not alligned on a 32 bit boundary.
#
@@ -320,7 +332,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 +346,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 +454,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
#
@@ -726,6 +746,8 @@ CC= ${PURIFY} ${LCC}
# Warning: Some HP-UX optimizers are brain-damaged. If 'make check' fails use:
# DEBUG= -g
#
# On a systems call the C compiler 'cchp' instead of 'cc'.
#
#CCWARN=
#CCOPT= ${DEBUG} ${NO_SHARED}
#CCMISC= +e
@@ -738,6 +760,7 @@ CC= ${PURIFY} ${LCC}
#ILDFLAGS=
#
#LCC= cc
#LCC= cchp
#CC= ${PURIFY} ${LCC}
#
###
@@ -838,6 +861,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
@@ -911,7 +935,7 @@ BUILD_H_SRC= align32.h args.h calcerr.h conf.h endian_calc.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_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
# we build these .c files during the make
#
@@ -925,7 +949,7 @@ 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 \
have_ustat.c have_getsid.c have_getpgid.c \
have_gettime.c have_getprid.c
have_gettime.c have_getprid.c have_rusage.c
# these awk and sed tools are used in the process of building BUILD_H_SRC
# and BUILD_C_SRC
@@ -941,13 +965,13 @@ 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_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
# 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
getsid_tmp gettime_tmp getprid_tmp rusage_tmp
# these utility progs may be used in the process of building BUILD_H_SRC
#
@@ -1020,6 +1044,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 +1115,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
@@ -2088,6 +2138,45 @@ 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
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'
@@ -2319,27 +2408,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 +2522,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 +2633,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}
@@ -2695,6 +2768,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 +2867,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 +2878,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 +2900,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 +2939,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 +2964,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 +2976,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 \
@@ -3368,6 +3446,7 @@ 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
@@ -3445,6 +3524,7 @@ 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
@@ -3861,6 +3941,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

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;
}
}
}
@@ -541,18 +554,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);
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:

View File

@@ -415,12 +415,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

28
func.c
View File

@@ -7334,12 +7334,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 +7378,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;
}

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

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

62
hist.c
View File

@@ -1440,8 +1440,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 +1457,9 @@ quit_calc(void)
*/
/* name of history file */
char *my_calc_history = NULL;
int
hist_getline(char *prompt, char *buf, int len)
{
@@ -1473,31 +1479,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

@@ -310,14 +310,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 +331,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 +351,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;
}

View File

@@ -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

11
seed.c
View File

@@ -54,6 +54,8 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/resource.h>
#include <time.h>
#include <sys/times.h>
#include <setjmp.h>
#include "qmath.h"
#include "longbits.h"
@@ -63,6 +65,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 */
@@ -308,9 +311,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 +384,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;

View File

@@ -12,7 +12,7 @@
#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" /* test number or empty string if no patch */
/*
* calc version constants