mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
Changes as per calc 2.12.7.3
This commit is contained in:
@@ -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));
|
||||
|
@@ -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
|
||||
#
|
||||
|
@@ -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);
|
||||
|
@@ -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";
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -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
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
10
cscript/simple.calc
Normal file → Executable file
10
cscript/simple.calc
Normal file → Executable file
@@ -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);
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user