From ccfa797b689b850215fb76ef3da2a65bfe6332bf Mon Sep 17 00:00:00 2001 From: Landon Curt Noll Date: Tue, 2 Feb 2021 20:33:59 -0800 Subject: [PATCH] Changes as per calc 2.12.7.3 --- BUGS | 48 +++++++++++++++++++++++++++++++ CHANGES | 21 ++++++++++++++ Makefile.ship | 18 ++++++++++-- calc.c | 2 +- calc.man | 64 +++++++++++++++++++++++++++++------------- calc.spec.in | 28 ++++++++++-------- cscript/4dsphere.calc | 10 ++++--- cscript/Makefile | 2 +- cscript/fproduct.calc | 6 ++-- cscript/mersenne.calc | 17 ++++++----- cscript/piforever.calc | 4 +-- cscript/plus.calc | 17 ++++++----- cscript/powerterm.calc | 17 ++++++----- cscript/simple.calc | 10 +++++-- cscript/square.calc | 12 +++----- custom/Makefile | 2 +- custom/Makefile.head | 2 +- version.c | 2 +- 18 files changed, 205 insertions(+), 77 deletions(-) mode change 100644 => 100755 cscript/simple.calc diff --git a/BUGS b/BUGS index 37cde3d..86c28c8 100644 --- a/BUGS +++ b/BUGS @@ -80,6 +80,54 @@ Known bugs: The output of the alg_config.cal resource file is bogus. We would welcome a replacement for this code. + Calc shell scripts do not read from stdin properly, + we all as a number of the cscript examples. + + The argv() function is behaving differently + when run in calc shell script mode: + + When calc is run as: + + calc -s a bb ccc + + and given this input on the command prompt: + + print "config(\"program\")=", config("program"); + print "argv()=", argv(); + argc = argv(); + for (i=0; i < argc; ++i) { + print "argv(":i:")=", argv(i); + } + + calc prints: + + config("program")= calc + argv()= 3 + argv(0)= a + argv(1)= bb + argv(2)= ccc + + but when it is run as a script called ./simple: + + #!/usr/local/bin/calc -q -s -f + print "config(\"program\")=", config("program"); + print "argv()=", argv(); + argc = argv(); + for (i=0; i < argc; ++i) { + print "argv(":i:")=", argv(i); + } + + under Linux prints: + + config("program")= /usr/bin/calc + argv()= 4 + argv(0)= ./simple + argv(1)= a + argv(2)= bb + argv(3)= ccc + + and under macOS simply enters into interactive mode. + 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. diff --git a/CHANGES b/CHANGES index bf3a875..5ec4d0c 100644 --- a/CHANGES +++ b/CHANGES @@ -18,6 +18,27 @@ The following are the changes from calc version 2.12.7.1 to date: Fixed a segfault when getpwuid() returned NULL during initialization. Thanks goes to baratharon GitHub user for reporting this issue. + Requiring calc shell scripts to use -s -f at the end of the + initial #! line. + + Fixed /tmp/mersenne example in calc(1) man page. + + Added make variable ${ARCH_CFLAGS}. The ${ARCH_CFLAGS} is + added after ${CCMISC} and before ${EXTRA_CFLAGS} when building + the ${CFLAGS} for compiling C code. are ${CC} when compiling + C files. The default value is: + + ARCH_CFLAGS= -march=native + + which directs C compiler to compile for the native machine. + To disable use of '-march=native', set ARCH_CFLAGS to the empty + string as in: + + make all ARCH_CFLAGS= + + To make calc RPMs more portable, they are compiled with an + empty ARCH_CFLAGS. + The following are the changes from calc version 2.12.6.10: to 2.12.7.0: diff --git a/Makefile.ship b/Makefile.ship index e9630f8..df38125 100644 --- a/Makefile.ship +++ b/Makefile.ship @@ -1054,7 +1054,7 @@ EXT= # The default calc versions # -VERSION= 2.12.7.2 +VERSION= 2.12.7.3 # Names of shared libraries with versions # @@ -1116,16 +1116,26 @@ STRIP= strip EXTRA_CFLAGS= EXTRA_LDFLAGS= +# Architecture compile flags +# +# The ARCH_CFLAGS are ${CC} when compiling C files. They follow +# CCMISC and preceed EXTRA_CFLAGS. +# +ARCH_CFLAGS= -march=native +#ARCH_CFLAGS= + # COMMON_CFLAGS are the common ${CC} flags used for all programs, both # intermediate and final calc and calc related programs # #if 0 /* start of skip for non-Gnu makefiles */ ifdef ALLOW_CUSTOM #endif /* end of skip for non-Gnu makefiles */ -COMMON_CFLAGS= -DCALC_SRC ${ALLOW_CUSTOM} ${CCWARN} ${CCMISC} ${EXTRA_CFLAGS} +COMMON_CFLAGS= -DCALC_SRC ${ALLOW_CUSTOM} ${CCWARN} \ + ${CCMISC} ${ARCH_CFLAGS} ${EXTRA_CFLAGS} #if 0 /* start of skip for non-Gnu makefiles */ else -COMMON_CFLAGS= -DCALC_SRC -UCUSTOM ${CCWARN} ${CCMISC} ${EXTRA_CFLAGS} +COMMON_CFLAGS= -DCALC_SRC -UCUSTOM ${CCWARN} \ + ${CCMISC} ${ARCH_CFLAGS} ${EXTRA_CFLAGS} endif #endif /* end of skip for non-Gnu makefiles */ @@ -1900,6 +1910,7 @@ SAMPLE_OBJ= sample_many.o sample_rand.o CUSTOM_PASSDOWN= \ ALLOW_CUSTOM="${ALLOW_CUSTOM}" \ AR=${AR} \ + ARCH_CFLAGS=${ARCH_CFLAGS} \ AWK=${AWK} \ BINDIR="${BINDIR}" \ BLD_TYPE="${BLD_TYPE}" \ @@ -4041,6 +4052,7 @@ env: @echo 'ALIGN32=${ALIGN32}'; echo '' @echo 'ALLOW_CUSTOM=${ALLOW_CUSTOM}'; echo '' @echo 'AR=${AR}'; echo '' + @echo 'ARCH_CFLAGS=${ARCH_CFLAGS}'; echo '' @echo 'AWK=${AWK}'; echo '' @echo 'BINDIR=${BINDIR}'; echo '' @echo 'BLD_TYPE=${BLD_TYPE}'; echo '' diff --git a/calc.c b/calc.c index 0f5a505..65299f6 100644 --- a/calc.c +++ b/calc.c @@ -449,7 +449,7 @@ main(int argc, char **argv) "\t[-O] [-p] [-q] [-s] [-u] [-v] " "[--] [calc_cmd ...]\n" "usage: %s ... -f filename\n" - "1st cscript line: #/path/to/calc ... -f\n", + "1st cscript line: #/path/to/calc ... -s -f\n", program, program); exit(20); } diff --git a/calc.man b/calc.man index 0146d30..25602a2 100644 --- a/calc.man +++ b/calc.man @@ -50,7 +50,7 @@ calc \- arbitrary precision calculator .RB [ [\-\-]\ calc_cmd\ \&.\|.\|. ] .in -5n .sp -\fI#!${BINDIR}/calc\fP\ [other_flags\ \&...] \fB\-f\fP +\fI#!${BINDIR}/calc\fP\ [other_flags\ \&...] \fB\-s\fP \fB\-f\fP .SH DESCRIPTION \& .br @@ -219,24 +219,29 @@ The getenv() builtin will still return values, however. .TP .B \-f +This flag is normally only with calc shell scripts. +.sp 1 This flag is required when using calc in .BR "shell script mode" . It must be at the end of the initial .B #! -line of the script. +line of the script +and must be immedately preceeded by the +.B \-s +flag. .sp 1 -This flag is normally only at the end of a calc shell script. If the first line of an executable file begins .B #! followed by the absolute pathname of the .B calc -program and the flag +program and if the first line ends with the two flags +.B \-s .B \-f as in: .sp 1 .in +5n .nf -\fI#!${BINDIR}/calc\fP\ [other_flags\ \&...] \fB\-f\fP +\fI#!${BINDIR}/calc\fP\ [other_flags\ \&...] \fB\-s\fP \fB\-f\fP .fi .in -5n .sp 1 @@ -270,7 +275,7 @@ on the command line: .sp 1 .in +5n .nf -\fIcalc\fP\ [other_flags\ \&...] \fB\-f\fP filename +\fIcalc\fP\ [other_flags\ \&...] \fB\-s\fP \fB\-f\fP filename .fi .in -5n .sp 1 @@ -283,6 +288,16 @@ Use of .B \-f implies .BR \-s . +However in a calc shell script, +one must include +.B \-f +before +.B \-s +on the initial +.B #! +line. + +.sp 1 In addition, .B \-d and @@ -753,25 +768,28 @@ If the first line of an executable file begins .B #! followed by the absolute pathname of the .B calc -program and the flag +program and the first line ends with the two flags +.B \-s .B \-f as in: .sp 1 .in +5n .nf -\fI#!${BINDIR}/calc\fP\ [other_flags\ \&...] \fB\-f\fP +\fI#!${BINDIR}/calc\fP\ [other_flags\ \&...] \fB\-s\fP \fB\-f\fP .fi .in -5n .sp 1 the rest of the file will be processed in .BR "shell script mode" . Note that +.B \-s .B \-f must at the end of the initial ``#!'' line. Any other optional .B "other_flags" must come before the +.B \-s .BR \-f . .sp 1 In @@ -803,18 +821,26 @@ the file .sp 1 .in +5n .nf -\fI#!${BINDIR}/calc\fP\ \&\fB\-q\fP \fB\-f\fP -# -# mersenne - an example of a calc \fBshell script file\fP +\fI#!${BINDIR}/calc\fP\ \&\fB\-q\fP \&\fB\-s\fP \fB\-f\fP + +/* setup */ +argc = argv(); +program = argv(0); +stderr = files(2); /* parse args */ -if (argv() != 1) { - fprintf(files(2), "usage: %s exp\\n", config("program")); +if (argc != 2) { + fprintf(stderr, "usage: %s exp\n", program); + abort "must give one exponent arg"; +} +exp = eval(argv(1)); +if (!isint(exp) || exp < 0) { + fprintf(stderr, "%s: exp must be non-negative integer\n", program); abort "must give one exponent arg"; } /* print the mersenne number */ -print "2^": argv(0) : "-1 =", 2^eval(argv(0))-1; +print "2^": exp : "-1 =", 2^exp-1; .fi .in -5n .sp 1 @@ -844,9 +870,9 @@ will print: .sp 1 Note that because .B \-s -is assumed in +is required in .B "shell script mode" -and non-dashed args are made available as +non-dashed args are made available as strings via the .BR argv () builtin function. @@ -854,16 +880,16 @@ Therefore: .sp 1 .in +5n .nf -2^eval(argv(0))-1 +2^eval(argv(1))-1 .fi .in -5n .sp 1 will print the decimal value of 2^n-1 -but +whereas .sp 1 .in +5n .nf -2^argv(0)-1 +2^argv(1)-1 .fi .in -5n .sp 1 diff --git a/calc.spec.in b/calc.spec.in index 7a3afae..4614c32 100644 --- a/calc.spec.in +++ b/calc.spec.in @@ -32,7 +32,7 @@ Summary: Arbitrary precision calculator. Name: calc Version: <<>> -Release: 12 +Release: 13 License: LGPL Group: Applications/Engineering Source: http://www.isthe.com/chongo/src/calc/%{name}-%{version}.tar.bz2 @@ -76,48 +76,48 @@ For the latest calc release, see the project home page: %build echo '-=- calc.spec beginning make clobber -=-' -make -j1 T=%{_buildroot} BINDIR=%{_bindir} LIBDIR=%{_libdir} \ +make -j1 T=%{_buildroot} BINDIR=%{_bindir} LIBDIR=%{_libdir} ARCH_CFLAGS= \ CALC_SHAREDIR=%{_datadir}/%{name} CALC_INCDIR=%{_includedir}/calc \ MANDIR=%{_mandir}/man1 EXT= V=@ clobber echo '-=- calc.spec ending make clobber -=-' echo '-=- calc.spec beginning make calc-static-only -=-' -make -j1 T=%{_buildroot} BINDIR=%{_bindir} LIBDIR=%{_libdir} \ +make -j1 T=%{_buildroot} BINDIR=%{_bindir} LIBDIR=%{_libdir} ARCH_CFLAGS= \ CALC_SHAREDIR=%{_datadir}/%{name} CALC_INCDIR=%{_includedir}/calc \ MANDIR=%{_mandir}/man1 EXT= V=@ calc-static-only BLD_TYPE=calc-static-only echo '-=- calc.spec ending make calc-static-only -=-' echo '-=- calc.spec beginning make rpm-hide-static -=-' -make -j1 T=%{_buildroot} BINDIR=%{_bindir} LIBDIR=%{_libdir} \ +make -j1 T=%{_buildroot} BINDIR=%{_bindir} LIBDIR=%{_libdir} ARCH_CFLAGS= \ CALC_SHAREDIR=%{_datadir}/%{name} CALC_INCDIR=%{_includedir}/calc \ MANDIR=%{_mandir}/man1 EXT= V=@ rpm-hide-static echo '-=- calc.spec ending make rpm-hide-static -=-' echo '-=- calc.spec beginning make clobber (again) -=-' -make -j1 T=%{_buildroot} BINDIR=%{_bindir} LIBDIR=%{_libdir} \ +make -j1 T=%{_buildroot} BINDIR=%{_bindir} LIBDIR=%{_libdir} ARCH_CFLAGS= \ CALC_SHAREDIR=%{_datadir}/%{name} CALC_INCDIR=%{_includedir}/calc \ MANDIR=%{_mandir}/man1 EXT= V=@ clobber echo '-=- calc.spec ending make clobber (again) -=-' echo '-=- calc.spec beginning make calc-dynamic-only -=-' -make -j1 T=%{_buildroot} BINDIR=%{_bindir} LIBDIR=%{_libdir} \ +make -j1 T=%{_buildroot} BINDIR=%{_bindir} LIBDIR=%{_libdir} ARCH_CFLAGS= \ CALC_SHAREDIR=%{_datadir}/%{name} CALC_INCDIR=%{_includedir}/calc \ MANDIR=%{_mandir}/man1 EXT= V=@ calc-dynamic-only \ BLD_TYPE=calc-dynamic-only LD_SHARE= echo '-=- calc.spec ending make calc-dynamic-only -=-' echo '-=- calc.spec beginning make chk -=-' -make -j1 T=%{_buildroot} BINDIR=%{_bindir} LIBDIR=%{_libdir} \ +make -j1 T=%{_buildroot} BINDIR=%{_bindir} LIBDIR=%{_libdir} ARCH_CFLAGS= \ CALC_SHAREDIR=%{_datadir}/%{name} CALC_INCDIR=%{_includedir}/calc \ MANDIR=%{_mandir}/man1 EXT= V=@ chk echo '-=- calc.spec ending make chk -=-' echo '-=- calc.spec beginning make rpm-unhide-static -=-' -make -j1 T=%{_buildroot} BINDIR=%{_bindir} LIBDIR=%{_libdir} \ +make -j1 T=%{_buildroot} BINDIR=%{_bindir} LIBDIR=%{_libdir} ARCH_CFLAGS= \ CALC_SHAREDIR=%{_datadir}/%{name} CALC_INCDIR=%{_includedir}/calc \ MANDIR=%{_mandir}/man1 EXT= V=@ rpm-unhide-static echo '-=- calc.spec ending make rpm-unhide-static -=-' echo '-=- calc.spec beginning make rpm-clean-static -=-' -make -j1 BINDIR=%{_bindir} LIBDIR=%{_libdir} \ +make -j1 BINDIR=%{_bindir} LIBDIR=%{_libdir} ARCH_CFLAGS= \ CALC_SHAREDIR=%{_datadir}/%{name} CALC_INCDIR=%{_includedir}/calc \ MANDIR=%{_mandir}/man1 EXT= V=@ rpm-clean-static echo '-=- calc.spec ending make rpm-clean-static -=-' echo '-=- calc.spec beginning make rpm-chk-static -=-' -make -j1 T=%{_buildroot} BINDIR=%{_bindir} LIBDIR=%{_libdir} \ +make -j1 T=%{_buildroot} BINDIR=%{_bindir} LIBDIR=%{_libdir} ARCH_CFLAGS= \ CALC_SHAREDIR=%{_datadir}/%{name} CALC_INCDIR=%{_includedir}/calc \ MANDIR=%{_mandir}/man1 EXT= V=@ rpm-chk-static echo '-=- calc.spec ending make rpm-chk-static -=-' @@ -125,7 +125,7 @@ echo '-=- calc.spec ending make rpm-chk-static -=-' %install echo '-=- calc.spec beginning make install -=-' mkdir -p %{_buildroot} -make -j1 T=%{_buildroot} BINDIR=%{_bindir} LIBDIR=%{_libdir} \ +make -j1 T=%{_buildroot} BINDIR=%{_bindir} LIBDIR=%{_libdir} ARCH_CFLAGS= \ CALC_SHAREDIR=%{_datadir}/%{name} CALC_INCDIR=%{_includedir}/calc \ MANDIR=%{_mandir}/man1 EXT= V=@ install echo '-=- calc.spec ending make install -=-' @@ -165,6 +165,12 @@ echo '-=- calc.spec beginning make clean -=-' %attr(644, root, root) %{_libdir}/libcustcalc.a %changelog +* Sun Mar 24 2019 cLandon Curt Noll http://www.isthe.com/chongo +- Release: 13 +- Disable compiling with the default ARCH_CFLAGS= -march=native + by clearking the ARCH_CFLAGS value in order to maximize + the RPM binary protability. + * Mon Sep 01 2014 Landon Curt Noll http://www.isthe.com/chongo - Release: 12 - Removed use of %{?_smp_mflags}. On Ubuntu 14.04, the -j2 diff --git a/cscript/4dsphere.calc b/cscript/4dsphere.calc index b967400..8508e27 100644 --- a/cscript/4dsphere.calc +++ b/cscript/4dsphere.calc @@ -10,7 +10,7 @@ * ... ... * x5 y5 z5 w5 point 5 in R^4 * - * Copyright (C) 2001,2014 Landon Curt Noll + * Copyright (C) 2001,2014,2019 Landon Curt Noll * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License @@ -37,9 +37,11 @@ * parse args */ argc = argv(); -if (argc != 25) { - fprintf(files(2), "usage: %s x0 y0 z0 w0 x1 y1 z1 w1 ... x5 y5 z5 w5\n", - argv(0)); +stderr = files(2); +program = argv(0); +if (argc != 24) { + fprintf(stderr, "usage: %s x0 y0 z0 w0 x1 y1 z1 w1 ... x5 y5 z5 w5\n", + program); exit; } x0 = eval(argv(1)); diff --git a/cscript/Makefile b/cscript/Makefile index 804bb19..2a11d4b 100644 --- a/cscript/Makefile +++ b/cscript/Makefile @@ -199,7 +199,7 @@ SCRIPT= 4dsphere fproduct mersenne piforever plus powerterm \ simple square SCRIPT_SRC= 4dsphere.calc fproduct.calc mersenne.calc \ - piforever.calc plus.calc powerterm.calc simple.calc square.calc + piforever.calc plus.calc powerterm.calc simple.calc # These files are found (but not built) in the distribution # diff --git a/cscript/fproduct.calc b/cscript/fproduct.calc index 2dcb94e..1f7be5b 100644 --- a/cscript/fproduct.calc +++ b/cscript/fproduct.calc @@ -8,7 +8,7 @@ * filename where to write the product, use - for stdout * term ... terms to multiply * - * Copyright (C) 2001,2014 Landon Curt Noll + * Copyright (C) 2001,2014,2019 Landon Curt Noll * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License @@ -35,8 +35,10 @@ * parse args */ argc = argv(); +stderr = files(2); +program = argv(0); if (argc < 2) { - fprintf(files(2), "usage: %s term [term ...]\n", argv(0)); + fprintf(stderr, "usage: %s term [term ...]\n", program); exit; } filename = argv(1); diff --git a/cscript/mersenne.calc b/cscript/mersenne.calc index 3aa1202..0d49ef5 100644 --- a/cscript/mersenne.calc +++ b/cscript/mersenne.calc @@ -2,7 +2,7 @@ /* * mersenne - print the value of a mersenne number * - * Copyright (C) 1999-2007,2014 Landon Curt Noll + * Copyright (C) 1999-2007,2014,2019 Landon Curt Noll * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License @@ -32,16 +32,19 @@ /* * parse args */ -if (argv() != 2) { - /* we include the name of this script in the error message */ - fprintf(files(2), "usage: %s exp\n", config("program")); - abort "wrong number of args"; +argc = argv(); +stderr = files(2); +program = argv(0); +if (argc != 2) { + /* we include the name of this script in the error message */ + fprintf(stderr, "usage: %s exp\n", program); + abort "wrong number of args"; } -global n = eval(argv(1)); +n = eval(argv(1)); if (!isint(n) || n <= 0) { - quit "Argument to be a positive integer"; + quit "Argument to be a positive integer"; } /* diff --git a/cscript/piforever.calc b/cscript/piforever.calc index 7316724..95a027e 100644 --- a/cscript/piforever.calc +++ b/cscript/piforever.calc @@ -1,8 +1,8 @@ -#!/usr/local/src/bin/calc/calc -q -f +#!/usr/local/src/bin/calc/calc -q -s -f /* * piforever - print digits of pi forever (or as long as your mem/cpu allow) * - * Copyright (C) 1999-2007,2014 Landon Curt Noll + * Copyright (C) 1999-2007,2014,2019 Landon Curt Noll * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License diff --git a/cscript/plus.calc b/cscript/plus.calc index 0e6d269..f750af9 100644 --- a/cscript/plus.calc +++ b/cscript/plus.calc @@ -1,8 +1,8 @@ -#!/usr/local/src/bin/calc/calc -q -f +#!/usr/local/src/bin/calc/calc -q -s -f /* * plus - add two or more arguments together * - * Copyright (C) 1999-2007,2014 Landon Curt Noll + * Copyright (C) 1999-2007,2014,2019 Landon Curt Noll * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License @@ -32,10 +32,13 @@ /* * parse args */ -if (argv() < 2) { - /* we include the name of this script in the error message */ - fprintf(files(2), "usage: %s value ...\n", config("program")); - abort "not enough args"; +argc = argv(); +stderr = files(2); +program = argv(0); +if (argc < 2) { + /* we include the name of this script in the error message */ + fprintf(stderr, "usage: %s value ...\n", program); + abort "not enough args"; } /* @@ -45,6 +48,6 @@ if (argv() < 2) { */ sum = 0; for (i=1; i < argv(); ++i) { - sum += eval(argv(i)); + sum += eval(argv(i)); } print sum; diff --git a/cscript/powerterm.calc b/cscript/powerterm.calc index e3fedc5..992133d 100644 --- a/cscript/powerterm.calc +++ b/cscript/powerterm.calc @@ -8,7 +8,7 @@ * base_limit largest base we will consider (def: 10000) * value value to convert into sums of powers of integers * - * Copyright (C) 2001,2014 Landon Curt Noll + * Copyright (C) 2001,2014,2019 Landon Curt Noll * * Calc is open software; you can redistribute it and/or modify it under * the powerterm of the version 2.1 of the GNU Lesser General Public License @@ -35,28 +35,31 @@ /* * parse args */ +argc = argv(); +stderr = files(2); +program = argv(0); config("verbose_quit", 0),; base_lim = 10000; /* default: highest base we will consider */ -if (argv() < 2 || argv() > 3) { - fprintf(files(2), "usage: %s [base_limit] value\n", argv(0)); +if (argc < 2 || argc > 3) { + fprintf(stderr, "usage: %s [base_limit] value\n", program); exit; } -if (argv() == 3) { +if (argc == 3) { x = eval(argv(2)); base_lim = eval(argv(1)); } else { x = eval(argv(1)); } if (! isint(x)) { - fprintf(files(2), "%s: value must be an integer\n"); + fprintf(stderr, "%s: value must be an integer\n", program); exit; } if (! isint(base_lim)) { - fprintf(files(2), "%s: base limit must be an integer\n"); + fprintf(stderr, "%s: base limit must be an integer\n", program); exit; } if (base_lim <= 1) { - fprintf(files(2), "%s: base limit is too small\n"); + fprintf(stderr, "%s: base limit is too small\n", program); exit; } ++base_lim; diff --git a/cscript/simple.calc b/cscript/simple.calc old mode 100644 new mode 100755 index 50e5ebd..95ffa7f --- a/cscript/simple.calc +++ b/cscript/simple.calc @@ -1,8 +1,8 @@ -#!/usr/local/src/bin/calc/calc -q -f +#!/usr/local/src/bin/calc/calc -q -s -f /* * simple - an example of a simple calc shell script * - * Copyright (C) 1999-2007,2014 Landon Curt Noll + * Copyright (C) 1999-2007,2014,2019 Landon Curt Noll * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License @@ -30,3 +30,9 @@ * This is an example of a simple calc shell script. */ print "This simple calc shell script works!" +print "config(\"program\")=", config("program"); +print "argv()=", argv(); +argc = argv(); +for (i=0; i < argc; ++i) { + print "argv(":i:")=", argv(i); +} diff --git a/cscript/square.calc b/cscript/square.calc index c0c7f52..b1e3d4c 100644 --- a/cscript/square.calc +++ b/cscript/square.calc @@ -1,8 +1,8 @@ -#!/usr/local/src/bin/calc/calc -q -f +#!/usr/local/src/bin/calc/calc -q -s -f /* * sqaure - print the squares of input values * - * Copyright (C) 2000-2007,2014 Ernest Bowen + * Copyright (C) 2000-2007,2014,2019 Ernest Bowen * * Calc is open software; you can redistribute it and/or modify it under * the terms of the version 2.1 of the GNU Lesser General Public License @@ -33,10 +33,6 @@ * cat file | ./square * echo "123" | ./square * - * Within calc: - * - * > read square - * * With input from a terminal, there is no prompt but each non-empty * line of input is evaluated as a calc expression and if it can be * calculated, the square of the value of that expression is displayed. @@ -59,6 +55,6 @@ */ -global s; -while ((s = prompt(""))) +while (s = fgetline(files(0))) { print "\t":eval(s)^2; +} diff --git a/custom/Makefile b/custom/Makefile index 894e7f4..0d3752c 100644 --- a/custom/Makefile +++ b/custom/Makefile @@ -348,7 +348,7 @@ EXT= # The default calc versions # -VERSION= 2.12.7.2 +VERSION= 2.12.7.3 # Names of shared libraries with versions # diff --git a/custom/Makefile.head b/custom/Makefile.head index 94d14a1..fe56ace 100644 --- a/custom/Makefile.head +++ b/custom/Makefile.head @@ -348,7 +348,7 @@ EXT= # The default calc versions # -VERSION= 2.12.7.2 +VERSION= 2.12.7.3 # Names of shared libraries with versions # diff --git a/version.c b/version.c index bafd8c0..e3c1422 100644 --- a/version.c +++ b/version.c @@ -45,7 +45,7 @@ static char *program; #define MAJOR_VER 2 /* major library version */ #define MINOR_VER 12 /* minor library version */ #define MAJOR_PATCH 7 /* major software level under library version */ -#define MINOR_PATCH 2 /* minor software level or 0 if not patched */ +#define MINOR_PATCH 3 /* minor software level or 0 if not patched */ /*