Release calc version 2.12.0.4

This commit is contained in:
Landon Curt Noll
2006-06-20 03:31:22 -07:00
parent bd3086138b
commit afe37ec851
25 changed files with 437 additions and 202 deletions

76
CHANGES
View File

@@ -260,6 +260,78 @@ The following are the changes from calc version 2.12.0 to date:
Updated the "help variable" text to reflect the current calc
use of ` (backquote), * (star), and & (ampersand).
Removal of some restrictions on the use of the same identifier
for more than one of parameter, local, static or global variable.
For example, at command level, one could use:
for (local x = 0; x < 10; x++) print sqrt(x);
At the beginning of a statement, "(global A)" is a way of
indicating a reference to the variable A, whereas "global A"
would be taken as a declaration. Parentheses are not required in
"++global A" or "global A++" when "global" is used in this way.
The patch extends this "specifier" (or "qualifier") feature
to static variables, but such that "static A" refers only
to a static variable at the current file and function scope
levels. (If there is already a static variable A at the current
file and function levels, a declaration statement "static A"
would end the scope of that variable and define a new static
variable with identifier A. A "global A" declaration is more
drastic in that it ends the scope of any static variable A at
the same or higher scope levels.)
Unlike a static declaration in which an "initialization" occurs at
most once, in the specifier case, "static A = expr" is simply an
assignment which may be repeated any number of times. An example
of its use is:
define np() = static a = nextprime(a);
For n not too large, the n-th call to this function will
return the n-th prime. The variable a here will be private to
the function.
Because one can use "global", "local" or "static" to specify a
type of variable, there seems little point in restricting the
ways identifiers that can be used in more than one of these
or as parameters. Obviously, introducing A as a local variable
when it is being used as a parameter can lead to confusion and a
warning is appropriate, but if it is to be used only occasionally,
it might be convenient to be able to refer to it as "local A"
rather than introducing another identifier. While it may be
silly to use the same identifier for both a parameter and local
variable, it should not be illegal.
The provision of warnings for possibly questionable programming in
function definitions.
Added config("redecl_warn", boolean) to control if calc issues
warnings about variables being declared. The config("redecl_warn")
value is TRUE by default.
Added config("dupvar_warn", boolean) to control if calc issues
warnings about when variable names collide. Examples of variable name
collisions include when:
* both local and static variables have the same name
* both local and global variables have the same name
* both function parameter and local variables have the same name
* both function parameter and global variables have the same name
The config("dupvar_warn") value is TRUE by default.
Fix of a bug which causes some static variables not to be correctly
unscoped when their identifiers are used in a global declaration.
Change of "undefine" from a command-level keyword to statement level and
introduction of an "undefine static A" statement to end the scope of a
static variable A at the current file/function levels.
Change/restored the syntax rules for "for" and "while" loops to
recognize an unescaped newline in top-level command-level statements.
The following are the changes from calc version 2.11.10.1 to 2.11.11:
@@ -6077,8 +6149,8 @@ Following is a list of visible changes to calc from version 1.24.7 to 1.26.1:
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.80 $
## @(#) $Id: CHANGES,v 29.80 2006/06/11 07:52:58 chongo Exp $
## @(#) $Revision: 29.82 $
## @(#) $Id: CHANGES,v 29.82 2006/06/20 10:26:41 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/RCS/CHANGES,v $
##
## Under source code control: 1993/06/02 18:12:57

15
addop.c
View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.12 $
* @(#) $Id: addop.c,v 29.12 2006/06/03 22:47:28 chongo Exp $
* @(#) $Revision: 29.13 $
* @(#) $Id: addop.c,v 29.13 2006/06/20 10:28:06 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/addop.c,v $
*
* Under source code control: 1990/02/15 01:48:10
@@ -280,13 +280,13 @@ rmuserfunc(char *name)
index = findstr(&funcnames, name);
if (index < 0) {
errorcount--;
scanerror(T_NULL,
"Attempt to undefine an undefined function\n\t\"%s\"", name);
warning("No function named \"%s\" to be undefined", name);
return;
}
if (functions[index] == NULL)
if (functions[index] == NULL) {
warning("No defined function \"%s\" to be undefined", name);
return;
}
freenumbers(functions[index]);
free(functions[index]);
if ((inputisterminal() && conf->resource_debug & RSCDBG_STDIN_FUNC) ||
@@ -527,8 +527,7 @@ addop(long op)
fp->f_opcodecount -= diff;
oldop = OP_NOP;
oldoldop = OP_NOP;
errorcount--;
scanerror(T_NULL, "Constant before comma operator");
warning("Constant before comma operator");
return;
}
break;

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.3 $
* @(#) $Id: ellip.cal,v 29.3 2006/03/07 22:16:25 chongo Exp $
* @(#) $Revision: 29.4 $
* @(#) $Id: ellip.cal,v 29.4 2006/06/20 09:29:16 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/ellip.cal,v $
*
* Under source code control: 1990/02/15 01:50:33
@@ -28,16 +28,17 @@
*/
/*
* Attempt to factor numbers using elliptic functions.
* y^2 = x^3 + a*x + b (mod N).
* Attempt to factor numbers using elliptic functions:
*
* Many points (x,y) (mod N) are found that solve the above equation,
* y^2 = x^3 + a*x + b (mod ellip_N).
*
* Many points (x,y) (mod ellip_N) are found that solve the above equation,
* starting from a trivial solution and 'multiplying' that point together
* to generate high powers of the point, looking for such a point whose
* order contains a common factor with N. The order of the group of points
* varies almost randomly within a certain interval for each choice of a
* and b, and thus each choice provides an independent opportunity to
* factor N. To generate a trivial solution, a is chosen and then b is
* order contains a common factor with ellip_N. The order of the group of
* points varies almost randomly within a certain interval for each choice of
* a and b, and thus each choice provides an independent opportunity to
* factor ellip_N. To generate a trivial solution, a is chosen and then b is
* selected so that (1,1) is a solution. The multiplication is done using
* the basic fact that the equation is a cubic, and so if a line hits the
* curve in two rational points, then the third intersection point must
@@ -45,9 +46,9 @@
* the number of rational solutions can be made very large. When modular
* arithmetic is used, solving for the third point requires the taking of a
* modular inverse (instead of division), and if this fails, then the GCD
* of the failing value and N provides a factor of N. This description is
* only an approximation, read "A Course in Number Theory and Cryptography"
* by Neal Koblitz for a good explanation.
* of the failing value and ellip_N provides a factor of ellip_N.
* This description is only an approximation, read "A Course in Number
* Theory and Cryptography" by Neal Koblitz for a good explanation.
*
* efactor(iN, ia, B, force)
* iN is the number to be factored.
@@ -81,15 +82,15 @@
*
* If a factor is found, it is returned and is also saved in the global
* variable f. The number being factored is also saved in the global
* variable N.
* variable ellip_N.
*/
obj point {x, y};
global N; /* number to factor */
global a; /* first coefficient */
global b; /* second coefficient */
global f; /* found factor */
global ellip_N; /* number to factor */
global ellip_a; /* first coefficient */
global ellip_b; /* second coefficient */
global ellip_f; /* found factor */
define efactor(iN, ia, B, force)
@@ -103,28 +104,28 @@ define efactor(iN, ia, B, force)
if (isnull(ia))
ia = 1;
obj point x;
a = ia;
b = -ia;
N = iN;
C = isqrt(N);
ellip_a = ia;
ellip_b = -ia;
ellip_N = iN;
C = isqrt(ellip_N);
C = 2 * C + 2 * isqrt(C) + 1;
f = 0;
while (f == 0) {
print "A =", a;
ellip_f = 0;
while (ellip_f == 0) {
print "A =", ellip_a;
x.x = 1;
x.y = 1;
print 2, x;
x = x ^ (2 ^ (highbit(C) + 1));
for (p = 3; ((p < B) && (f == 0)); p += 2) {
for (p = 3; ((p < B) && (ellip_f == 0)); p += 2) {
if (!ptest(p, 1))
continue;
print p, x;
x = x ^ (p ^ ((highbit(C) // highbit(p)) + 1));
}
a++;
b--;
ellip_a++;
ellip_b--;
}
return f;
return ellip_f;
}
@@ -143,16 +144,16 @@ define point_mul(p1, p2)
if (p1 == p2)
return point_square(`p1);
obj point r;
m = (minv(p2.x - p1.x, N) * (p2.y - p1.y)) % N;
m = (minv(p2.x - p1.x, ellip_N) * (p2.y - p1.y)) % ellip_N;
if (m == 0) {
if (f == 0)
f = gcd(p2.x - p1.x, N);
if (ellip_f == 0)
ellip_f = gcd(p2.x - p1.x, ellip_N);
r.x = 1;
r.y = 1;
return r;
}
r.x = (m^2 - p1.x - p2.x) % N;
r.y = ((m * (p1.x - r.x)) - p1.y) % N;
r.x = (m^2 - p1.x - p2.x) % ellip_N;
r.y = ((m * (p1.x - r.x)) - p1.y) % ellip_N;
return r;
}
@@ -162,16 +163,16 @@ define point_square(p)
local r, m;
obj point r;
m = ((3 * p.x^2 + a) * minv(p.y << 1, N)) % N;
m = ((3 * p.x^2 + ellip_a) * minv(p.y << 1, ellip_N)) % ellip_N;
if (m == 0) {
if (f == 0)
f = gcd(p.y << 1, N);
if (ellip_f == 0)
ellip_f = gcd(p.y << 1, ellip_N);
r.x = 1;
r.y = 1;
return r;
}
r.x = (m^2 - p.x - p.x) % N;
r.y = ((m * (p.x - r.x)) - p.y) % N;
r.x = (m^2 - p.x - p.x) % ellip_N;
r.y = ((m * (p.x - r.x)) - p.y) % ellip_N;
return r;
}
@@ -184,7 +185,7 @@ define point_pow(p, pow)
if (isodd(pow))
r = p;
t = p;
for (bit = 2; ((bit <= pow) && (f == 0)); bit <<= 1) {
for (bit = 2; ((bit <= pow) && (ellip_f == 0)); bit <<= 1) {
t = point_square(`t);
if (bit & pow)
r = point_mul(`t, `r);

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.2 $
* @(#) $Id: prompt.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
* @(#) $Revision: 29.3 $
* @(#) $Id: prompt.cal,v 29.3 2006/06/20 09:29:16 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/prompt.cal,v $
*
* Under source code control: 1995/12/18 04:43:25
@@ -101,7 +101,7 @@ define adder() {
}
}
global x;
global prompt_x;
define showvalues(str) {
local s;
@@ -109,8 +109,8 @@ define showvalues(str) {
s = prompt("? ");
if (s == "end")
break;
x = eval(s);
if (!isnum(x)) {
prompt_x = eval(s);
if (!isnum(prompt_x)) {
print "Please enter a number";
continue;
}

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.29 $
* @(#) $Id: regress.cal,v 29.29 2006/06/11 07:07:23 chongo Exp $
* @(#) $Revision: 29.31 $
* @(#) $Id: regress.cal,v 29.31 2006/06/20 10:25:00 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/regress.cal,v $
*
* Under source code control: 1990/02/15 01:50:36
@@ -201,7 +201,6 @@ define test_variables()
local x1, x2, x3;
global g1, g2;
local t;
global globalvar;
local x;
print '350: Beginning test_variables';
@@ -3972,7 +3971,7 @@ print '088: parsed test_fileop()';
/*
* global and static assignment tests
*/
global a = 10, b, c d = 20, e, f;
global a = 10, b, c d = 20, e;
print '089: global a = 10, b, c d = 20, e, f';
vrfy(a == 10, '090: a == 10');
vrfy(b == 0, '091: b == 0');
@@ -4672,13 +4671,11 @@ print '137: parsed test_random()';
/*
* test_newsyn - test new command completion syntax and scope rules
*/
for (s5500 = 0, i = 0; i < 5; i++)
s5500 += i;
for (s5500 = 0, i = 0; i < 5; i++) s5500 += i;
print "138: for (s5500 = 0, i = 0; i < 5; i++) s5500 += i;";
vrfy(s5500 == 10, '139: s5500 == 10');
vrfy(i == 5, '140: i == 5');
for (s5500 = 0, i = 0; i < 9; i++)
{
for (s5500 = 0, i = 0; i < 9; i++) {
s5500 += i;
}
print "141: for (s5500 = 0, i = 0; i < 9; i++) { s5500 += i; }";
@@ -4726,7 +4723,6 @@ define test_newsyn()
vrfy(i == 3, '5509: i == 3');
/**/
{
local i;
for (s5500 = 0, i = 0; i < 11; i++)
s5500 += i;
vrfy(s5500 == 55, '5510: s5500 == 45');
@@ -5138,8 +5134,6 @@ print '156: parsed test_size()';
/*
* test_assign - test assignment of constants and variables
*/
global A, B; /* A, B for "constants" */
print '157: global A, B';
global X5800, Y5800; /* X5800, Y5800 for "variables" */
print '158: global X5800, Y5800';
obj xy5800 {x, y};
@@ -7818,7 +7812,27 @@ read -once "test8500";
print;
print '8600: Starting test of up to 1024 args'
read -once "test8600";
/* 86xx: Ending test of up to 1024 args is printed by test8600.cal */
/* 860x: Ending test of up to 1024 args is printed by test8600.cal */
/*
* dupvar_warn and redecl_warn testing
*/
print;
print '8650: Starting test of dupvar_warn and redecl_warn config parameters';
vrfy(config("redecl_warn",0), '8651: config("redecl_warn",0)');
vrfy(config("dupvar_warn",0), '8652: config("dupvar_warn",0)');
vrfy(u_glob == 6, '8653: u_glob == 6');
global u_glob = 555;
print '8654: reclare u_glob';
vrfy(u_glob == 555, '8655: u_glob == 555');
define func_8650(u_glob) { local u_glob; return u_glob; }
print '8656: u_glob as both local and parameter';
define func_8650a(u_glob) { static u_glob; return u_glob; }
print '8657: u_glob as both static and parameter';
vrfy(config("redecl_warn",1)==0, '8658: config("redecl_warn",1)==0');
vrfy(config("dupvar_warn",1)==0, '8659: config("dupvar_warn",1)==0');
/* 865x: Ending test of up to 1024 args is printed by test8600.cal */
/*
@@ -7826,6 +7840,7 @@ read -once "test8600";
*
* We use the dotest driver to evaluate test-97xx data files.
*/
print;
print '8700: Starting dotest runs'
print '8701: read -once "dotest"';
read -once "dotest";
@@ -7835,6 +7850,7 @@ vrfy(dotest("set8700.line", 8703) == 0,
'8703: dotest("set8700.line", 8703) == 0');
/* 87xx: Ending dotest runs is printed by set8700.test */
/*
* read various calc resource files
*

View File

@@ -17,8 +17,8 @@
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.1 $
## @(#) $Id: set8700.line,v 29.1 2006/05/20 19:35:33 chongo Exp $
## @(#) $Revision: 29.2 $
## @(#) $Id: set8700.line,v 29.2 2006/06/20 09:29:16 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/set8700.line,v $
##
## Under source code control: 2006/05/20 14:10:11
@@ -143,7 +143,7 @@ a #= 4, a == 1
## Binary # operator not defined for strings
global set8700_A; protect(set8700_A) == 0
protect(set8700_A) == 0
## Testing with one lvalue
isnull(protect(set8700_A,65))
protect(set8700_A) == 65
@@ -302,7 +302,7 @@ protect(set8700_B,0), set8700_B = set8700_getA1(), protect(set8700_B) == 1024
protect(set8700_B,0), set8700_B = set8700_getA2(), protect(set8700_B) == 1024
set8700_B = set8700_getvar(), protect(set8700_B) == 1024 + 256
global set8700_x, set8700_y; set8700_x = 7, protect(set8700_x) == 0
set8700_x = 7, protect(set8700_x) == 0
protect(7,2) == error(10234)
protect(set8700_x,2.5) == error(10235)
protect(set8700_x,"abc") == error(10235)
@@ -322,7 +322,6 @@ set8700_x++ == error(10385)
set8700_x == 7
set8700_x-- == error(10388)
global set8700_A, set8700_B; 1
protect(set8700_A,0), protect(set8700_A,16), 1
set8700_A = "abcdef", protect(set8700_A) == 16 ## No copy to set8700_A
protect(set8700_B,0), set8700_B = "xyz", protect(set8700_B) == 0

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.2 $
* @(#) $Id: test2700.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
* @(#) $Revision: 29.3 $
* @(#) $Id: test2700.cal,v 29.3 2006/06/20 09:29:16 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test2700.cal,v $
*
* Under source code control: 1995/11/01 22:52:25
@@ -41,8 +41,7 @@
*/
global defaultverbose = 1;
global err;
defaultverbose = 1;
define mknonnegreal() {
switch(rand(8)) {

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.2 $
* @(#) $Id: test3300.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
* @(#) $Revision: 29.3 $
* @(#) $Id: test3300.cal,v 29.3 2006/06/20 09:29:16 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test3300.cal,v $
*
* Under source code control: 1995/12/02 04:27:41
@@ -30,8 +30,7 @@
*/
global defaultverbose = 1; /* default verbose value */
global err;
defaultverbose = 1; /* default verbose value */
define testi(str, n, N, verbose)
{

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.2 $
* @(#) $Id: test3400.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
* @(#) $Revision: 29.3 $
* @(#) $Id: test3400.cal,v 29.3 2006/06/20 09:29:16 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test3400.cal,v $
*
* Under source code control: 1995/12/02 05:20:11
@@ -54,8 +54,7 @@
*/
global defaultverbose = 1; /* default verbose value */
global err;
defaultverbose = 1; /* default verbose value */
global pi1k = pi(1e-1000);

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.2 $
* @(#) $Id: test3500.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
* @(#) $Revision: 29.3 $
* @(#) $Id: test3500.cal,v 29.3 2006/06/20 09:29:16 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test3500.cal,v $
*
* Under source code control: 1995/12/18 22:50:46
@@ -53,8 +53,7 @@
*/
global defaultverbose = 1; /* default verbose value */
global err;
defaultverbose = 1; /* default verbose value */
define testfrem(x,y,verbose)
{

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.2 $
* @(#) $Id: test4000.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
* @(#) $Revision: 29.3 $
* @(#) $Id: test4000.cal,v 29.3 2006/06/20 09:29:16 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test4000.cal,v $
*
* Under source code control: 1996/03/13 02:38:45
@@ -75,8 +75,7 @@
*/
global defaultverbose = 1; /* default verbose value */
global err;
defaultverbose = 1; /* default verbose value */
/*
* test defaults

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.3 $
* @(#) $Id: test4100.cal,v 29.3 2006/06/10 20:19:20 chongo Exp $
* @(#) $Revision: 29.4 $
* @(#) $Id: test4100.cal,v 29.4 2006/06/20 09:29:16 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test4100.cal,v $
*
* Under source code control: 1996/03/13 03:53:22
@@ -70,18 +70,16 @@
*/
global defaultverbose = 1; /* default verbose value */
global err;
defaultverbose = 1; /* default verbose value */
/*
* test defaults
*/
global K1 = 2^17;
global K2 = 2^12;
global BASEB = 16;
global BASE = 2^BASEB;
global test4100_K1 = 2^17;
global test4100_K2 = 2^12;
global test4100_BASE = 2^config("baseb");
define rlen_4100(N) = rand(BASE^(N-1), BASE^N);
define rlen_4100(N) = rand(test4100_BASE^(N-1), test4100_BASE^N);
define olen(N)
{
@@ -234,7 +232,7 @@ define times(str,N,n,verbose)
m = olen(N);
m2 = m^2;
if (isnull(n)) {
n = ceil(K1/power(N,1.585));
n = ceil(test4100_K1/power(N,1.585));
if (verbose > 1)
printf("n = %d\n", n);
}
@@ -308,7 +306,7 @@ define powtimes(str, N1, N2, n, verbose)
N2 = 1;
if (isnull(n)) {
n = ceil(K2/power(N1, 1.585)/N2);
n = ceil(test4100_K2/power(N1, 1.585)/N2);
printf ("n = %d\n", n);
}
mat A[n];
@@ -408,7 +406,7 @@ define inittimes(str,N,n,verbose)
}
m = 0;
if (isnull(n)) {
n = ceil(K1/N^2);
n = ceil(test4100_K1/N^2);
if (verbose > 1) {
printf ("n = %d\n", n);
}

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.4 $
* @(#) $Id: test4600.cal,v 29.4 2001/04/10 22:09:02 chongo Exp $
* @(#) $Revision: 29.5 $
* @(#) $Id: test4600.cal,v 29.5 2006/06/20 09:29:16 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test4600.cal,v $
*
* Under source code control: 1996/07/02 20:04:40
@@ -30,8 +30,7 @@
*/
global defaultverbose = 1 /* default verbose value */
global err;
defaultverbose = 1; /* default verbose value */
/*
* test globals

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.2 $
* @(#) $Id: test5100.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
* @(#) $Revision: 29.3 $
* @(#) $Id: test5100.cal,v 29.3 2006/06/20 09:29:16 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test5100.cal,v $
*
* Under source code control: 1996/12/02 23:57:10
@@ -30,8 +30,7 @@
*/
global defaultverbose = 1; /* default verbose value */
global err;
defaultverbose = 1; /* default verbose value */
/*
* We test the new code generator declaration scope and order.

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.2 $
* @(#) $Id: test5200.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
* @(#) $Revision: 29.3 $
* @(#) $Id: test5200.cal,v 29.3 2006/06/20 09:29:16 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/test5200.cal,v $
*
* Under source code control: 1997/02/07 02:48:10
@@ -30,8 +30,7 @@
*/
global defaultverbose = 1; /* default verbose value */
global err;
defaultverbose = 1; /* default verbose value */
/*
* test the fix of a global/static bug

163
codegen.c
View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.20 $
* @(#) $Id: codegen.c,v 29.20 2006/06/11 07:25:14 chongo Exp $
* @(#) $Revision: 29.21 $
* @(#) $Id: codegen.c,v 29.21 2006/06/20 10:28:06 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/codegen.c,v $
*
* Under source code control: 1990/02/15 01:48:13
@@ -136,10 +136,6 @@ getcommands(BOOL toplevel)
getfunction();
break;
case T_UNDEFINE:
ungetfunction();
break;
case T_EOF:
if (!toplevel)
exitfilescope();
@@ -306,9 +302,8 @@ ungetfunction(void)
name = tokensymbol();
type = getbuiltinfunc(name);
if (type >= 0) {
errorcount--;
scanerror(T_NULL,
"Attempt to undefine the builtin function \"%s\"", name);
warning(
"Cannot undefine builtin function \"%s\"", name);
continue;
}
rmuserfunc(name);
@@ -316,6 +311,16 @@ ungetfunction(void)
case T_MULT:
rmalluserfunc();
continue;
case T_STATIC:
if (gettoken() != T_SYMBOL) {
scanerror(T_SEMICOLON,
"Non-identifier following \"undefine static\"");
return;
}
name = tokensymbol();
endscope(name, FALSE);
continue;
case T_NEWLINE:
case T_SEMICOLON:
case T_EOF:
@@ -634,6 +639,10 @@ getstatement(LABEL *contlabel, LABEL *breaklabel, LABEL *nextcaselabel, LABEL *d
(void) getdeclarations(SYM_LOCAL);
break;
case T_UNDEFINE:
ungetfunction();
break;
case T_RIGHTBRACE:
scanerror(T_NULL, "Extraneous right brace");
return;
@@ -799,10 +808,10 @@ getstatement(LABEL *contlabel, LABEL *breaklabel, LABEL *nextcaselabel, LABEL *d
setlabel(&label3);
if (contlabel == NULL_LABEL)
contlabel = &label3;
(void) tokenmode(oldmode);
getstatement(contlabel, breaklabel, NULL_LABEL, NULL_LABEL);
addoplabel(OP_JUMP, contlabel);
setlabel(breaklabel);
(void) tokenmode(oldmode);
return;
case T_WHILE:
@@ -811,6 +820,7 @@ getstatement(LABEL *contlabel, LABEL *breaklabel, LABEL *nextcaselabel, LABEL *d
clearlabel(contlabel);
setlabel(contlabel);
getcondition();
(void) tokenmode(oldmode);
if (gettoken() != T_SEMICOLON) {
breaklabel = &label2;
clearlabel(breaklabel);
@@ -823,7 +833,6 @@ getstatement(LABEL *contlabel, LABEL *breaklabel, LABEL *nextcaselabel, LABEL *d
} else {
addoplabel(OP_JUMPNZ, contlabel);
}
(void) tokenmode(oldmode);
return;
case T_DO:
@@ -2124,7 +2133,8 @@ getterm(void)
case T_GLOBAL:
if (gettoken() != T_SYMBOL) {
scanerror(T_NULL, "Global id expected");
scanerror(T_NULL,
"No identifier after global specifier");
break;
}
rescantoken();
@@ -2133,19 +2143,30 @@ getterm(void)
case T_LOCAL:
if (gettoken() != T_SYMBOL) {
scanerror(T_NULL, "Local id expected");
scanerror(T_NULL,
"No identifier after local specifier");
break;
}
rescantoken();
type = getidexpr(TRUE, T_LOCAL);
break;
case T_STATIC:
if (gettoken() != T_SYMBOL) {
scanerror(T_NULL,
"No identifier after static specifier");
break;
}
rescantoken();
type = getidexpr(TRUE, T_STATIC);
break;
case T_LEFTBRACKET:
scanerror(T_NULL, "Bad index usage");
scanerror(T_NULL, "Left bracket with no preceding lvalue");
break;
case T_PERIOD:
scanerror(T_NULL, "Bad element reference");
scanerror(T_NULL, "Period with no preceding lvalue");
break;
default:
@@ -2207,7 +2228,8 @@ getidexpr(BOOL okmat, int autodef)
type = 0;
break;
case T_ASSIGN:
if (autodef != T_GLOBAL && autodef != T_LOCAL)
if (autodef != T_GLOBAL && autodef != T_LOCAL &&
autodef != T_STATIC)
autodef = 1;
/* fall into default case */
default:
@@ -2408,22 +2430,11 @@ getshowstatement(void)
"stri\000"
"lite\000"
"opco\000", name);
if (arg == 19) {
if (gettoken() != T_SYMBOL) {
rescantoken();
scanerror(T_SEMICOLON,
"Function name expected");
return;
}
index = adduserfunc(tokensymbol());
addopone(OP_SHOW, index + 19);
return;
}
if (arg > 0)
addopone(OP_SHOW, arg);
else
printf("Unknown SHOW parameter ignored\n");
return;
break;
case T_GLOBAL:
arg = 13; break;
case T_STATIC:
arg = 14; break;
default:
printf("SHOW command to be followed by at least ");
printf("four letters of one of:\n");
@@ -2438,6 +2449,21 @@ getshowstatement(void)
return;
}
if (arg == 19) {
if (gettoken() != T_SYMBOL) {
rescantoken();
scanerror(T_SEMICOLON,
"Function name expected for show statement");
return;
}
index = adduserfunc(tokensymbol());
addopone(OP_SHOW, index + 19);
return;
}
if (arg > 0)
addopone(OP_SHOW, arg);
else
warning("Unknown parameter for show statement");
}
@@ -2556,8 +2582,9 @@ getid(char *buf)
* Define a symbol name to be of the specified symbol type. The scope
* of a static variable with the same name is terminated if symtype is
* global or if symtype is static and the old variable is at the same
* level. A scan error occurs if the name is already in use in an
* incompatible manner.
* level. Warnings are issued when a global or local variable is
* redeclared and when in the same body the variable will be accessible only
^ with the appropriate specfier.
*/
static void
definesymbol(char *name, int symtype)
@@ -2566,25 +2593,48 @@ definesymbol(char *name, int symtype)
case SYM_STATIC:
if (symtype == SYM_GLOBAL || symtype == SYM_STATIC)
endscope(name, symtype == SYM_GLOBAL);
/*FALLTHRU*/
case SYM_UNDEFINED:
break;
case SYM_GLOBAL:
if (symtype == SYM_GLOBAL && conf->redecl_warn) {
warning("redeclaraion of global \"%s\"",
name);
return;
}
break;
case SYM_LOCAL:
if (symtype == SYM_LOCAL && conf->redecl_warn) {
warning("redeclaraion of local \"%s\"",
name);
return;
}
if (symtype == SYM_GLOBAL && conf->dupvar_warn) {
warning("both local and global \"%s\" defined", name);
break;
}
if (conf->dupvar_warn) {
warning("both local and static \"%s\" defined", name);
}
break;
case SYM_PARAM:
if (symtype == SYM_LOCAL && conf->dupvar_warn) {
warning("both local and parameter \"%s\" defined",
name);
break;
}
if (symtype == SYM_GLOBAL && conf->dupvar_warn) {
warning("both global and parameter \"%s\" defined",
name);
break;
}
if (conf->dupvar_warn) {
warning("both static and parameter \"%s\" defined", name);
}
}
if (symtype == SYM_LOCAL)
(void) addlocal(name);
else
(void) addglobal(name, (symtype == SYM_STATIC));
break;
case SYM_LOCAL:
if (symtype == SYM_LOCAL)
return;
/*FALLTHRU*/
case SYM_PARAM:
scanerror(T_COMMA,
"Variable \"%s\" is already defined", name);
return;
}
}
@@ -2602,21 +2652,28 @@ definesymbol(char *name, int symtype)
static void
usesymbol(char *name, int autodef)
{
int type;
type = symboltype(name);
if (autodef == T_GLOBAL) {
if (type == SYM_GLOBAL) {
warning("Unnecessary global specifier");
}
addopptr(OP_GLOBALADDR, (char *) addglobal(name, FALSE));
return;
}
if (autodef == T_LOCAL) {
if (symboltype(name) == SYM_PARAM) {
scanerror(T_COMMA,
"Variable \"%s\" is already defined", name);
if (autodef == T_STATIC) {
addopptr(OP_GLOBALADDR, (char *) addglobal(name, TRUE));
return;
}
if (autodef == T_LOCAL) {
if (type == SYM_LOCAL) {
warning("Unnecessary local specifier");
}
addopone(OP_LOCALADDR, addlocal(name));
return;
}
switch (symboltype(name)) {
switch (type) {
case SYM_LOCAL:
addopone(OP_LOCALADDR, (long) findlocal(name));
return;

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.20 $
* @(#) $Id: config.c,v 29.20 2006/06/11 00:08:56 chongo Exp $
* @(#) $Revision: 29.21 $
* @(#) $Id: config.c,v 29.21 2006/06/20 10:25:45 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/config.c,v $
*
* Under source code control: 1991/07/20 00:21:56
@@ -98,6 +98,8 @@ NAMETYPE configs[] = {
{"allow_custom", CONFIG_ALLOW_CUSTOM},
{"version", CONFIG_VERSION},
{"baseb", CONFIG_BASEB},
{"redecl_warn", CONFIG_REDECL_WARN},
{"dupvar_warn", CONFIG_DUPVAR_WARN},
{NULL, 0}
};
@@ -162,6 +164,8 @@ CONFIG oldstd = { /* backward compatible standard configuration */
&allow_custom, /* *TRUE=> custom functions are enabled */
NULL, /* version */
BASEB, /* base for calculations */
TRUE, /* warn when redeclaring */
TRUE, /* warn when variable names collide */
};
CONFIG newstd = { /* new non-backward compatible configuration */
MODE_INITIAL, /* current output mode */
@@ -220,6 +224,8 @@ CONFIG newstd = { /* new non-backward compatible configuration */
&allow_custom, /* *TRUE=> custom functions are enabled */
NULL, /* version */
BASEB, /* base for calculations */
TRUE, /* warn when redeclaring */
TRUE, /* warn when variable names collide */
};
CONFIG *conf = NULL; /* loaded in at startup - current configuration */
@@ -906,6 +912,34 @@ setconfig(int type, VALUE *vp)
math_error("The baseb config parameter is read-only");
/*NOTREACHED*/
case CONFIG_REDECL_WARN:
if (vp->v_type == V_NUM) {
q = vp->v_num;
conf->redecl_warn = !qiszero(q);
} else if (vp->v_type == V_STR) {
temp = lookup_long(truth, vp->v_str->s_str);
if (temp < 0) {
math_error("Illegal truth value for redecl_warn");
/*NOTREACHED*/
}
conf->redecl_warn = (int)temp;
}
break;
case CONFIG_DUPVAR_WARN:
if (vp->v_type == V_NUM) {
q = vp->v_num;
conf->dupvar_warn = !qiszero(q);
} else if (vp->v_type == V_STR) {
temp = lookup_long(truth, vp->v_str->s_str);
if (temp < 0) {
math_error("Illegal truth value for dupvar_warn");
/*NOTREACHED*/
}
conf->dupvar_warn = (int)temp;
}
break;
default:
math_error("Setting illegal config parameter");
/*NOTREACHED*/
@@ -1287,6 +1321,14 @@ config_value(CONFIG *cfg, int type, VALUE *vp)
i = BASEB;
break;
case CONFIG_REDECL_WARN:
i = (cfg->redecl_warn ? 1 : 0);
break;
case CONFIG_DUPVAR_WARN:
i = (cfg->dupvar_warn ? 1 : 0);
break;
default:
math_error("Getting illegal CONFIG element");
/*NOTREACHED*/

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.18 $
* @(#) $Id: config.h,v 29.18 2006/06/06 07:17:02 chongo Exp $
* @(#) $Revision: 29.19 $
* @(#) $Id: config.h,v 29.19 2006/06/20 10:25:45 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/config.h,v $
*
* Under source code control: 1995/11/01 22:20:17
@@ -95,6 +95,8 @@
#define CONFIG_COMPILE_CUSTOM 41
#define CONFIG_ALLOW_CUSTOM 42
#define CONFIG_BASEB 43
#define CONFIG_REDECL_WARN 44
#define CONFIG_DUPVAR_WARN 45
/*
@@ -164,6 +166,8 @@ struct config {
BOOL *allow_custom; /* ptr to if custom functions are allowed */
char *version; /* calc version string */
int baseb; /* base for calculations */
BOOL redecl_warn; /* TRUE => warn of redeclating variables */
BOOL dupvar_warn; /* TRUE => warn of var name collisions */
};
typedef struct config CONFIG;

6
hash.c
View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.9 $
* @(#) $Id: hash.c,v 29.9 2006/06/06 07:17:02 chongo Exp $
* @(#) $Revision: 29.10 $
* @(#) $Id: hash.c,v 29.10 2006/06/20 10:25:45 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/hash.c,v $
*
* Under source code control: 1995/11/23 05:13:11
@@ -996,6 +996,8 @@ hash_value(int type, void *v, HASH *state)
}
state = hash_str(type, value->v_config->version, state);
state = hash_int(type, value->v_config->baseb, state);
state = hash_bool(type, value->v_config->redecl_warn, state);
state = hash_bool(type, value->v_config->dupvar_warn, state);
break;
case V_HASH:

View File

@@ -50,13 +50,13 @@ DESCRIPTION
"prompt" default interactive prompt
"more" default interactive multi-line input prompt
"blkmaxprint" number of block octets to print, 0 means all
"blkverbose" TRUE=>print all lines, FALSE=>skip duplicates
"blkverbose" TRUE => print all lines, FALSE=>skip duplicates
"blkbase" block output base
"blkfmt" block output format
"calc_debug" controls internal calc debug information
"resource_debug" controls resource file debug information
"user_debug" for user defined debug information
"verbose_quit" TRUE=>print message on empty quit or abort
"verbose_quit" TRUE => print message on empty quit or abort
"ctrl_d" The interactive meaning of ^D (Control D)
"program" Read-only calc program or shell script path
"basename" Read-only basename of the program value
@@ -66,6 +66,8 @@ DESCRIPTION
"allow_custom" TRUE=>custom functions are enabled
"version" Read-only calc version
"baseb" bits in calculation base, a read-only value
"redecl_warn" TRUE => warn when redeclaring
"dupvar_warn" TRUE => warn when variable names collide
The "all" config value allows one to save/restore the configuration
set of values. The return of:
@@ -279,14 +281,14 @@ DESCRIPTION
established on a 1.8GHz AMD 32-bit CPU of ~3406 BogoMIPS when
the two algorithms are about equal in speed. For that CPU test,
config("baseb") was 32. This means that by default numbers up to
(3388*32)+31 = 108447 bits in length (< 32645 decinal digits) use
(3388*32)+31 = 108447 bits in length (< 32645 decimal digits) use
the 1st algorithm, for squaring.
The default value for config("mul2") is 1780. This default was
established on a 1.8GHz AMD 32-bit CPU of ~3406 BogoMIPS when
the two algorithms are about equal in speed. For that CPU test,
config("baseb") was 32. This means that by default numbers up to
(1779*32)+31 = 56927 bits in length (< 17137 decinal digits) use
(1779*32)+31 = 56927 bits in length (< 17137 decimal digits) use
the 1st algorithm, for multiplication.
A value of zero resets the parameter back to their default values.
@@ -315,7 +317,7 @@ DESCRIPTION
established on a 1.8GHz AMD 32-bit CPU of ~3406 BogoMIPS when
the two algorithms are about equal in speed. For that CPU test,
config("baseb") was 32. This means that by default numbers up to
(176*32)+31 = 5663 bits in length (< 1704 decinal digits) use the
(176*32)+31 = 5663 bits in length (< 1704 decimal digits) use the
1st algorithm, for calculating powers modulo another number.
A value of zero resets the parameter back to their default values.
@@ -344,7 +346,7 @@ DESCRIPTION
established as 5/4 (the historical ratio of config("pow2") to
config("pow2")) of the config("pow2") value. This means that if
config("baseb") is 32, then by default numbers up to (220*32)+31 =
7071 bits in length (< 2128 decinal digits) use the REDC algorithm,
7071 bits in length (< 2128 decimal digits) use the REDC algorithm,
for calculating powers modulo another number.
A value of zero resets the parameter back to their default values.
@@ -430,7 +432,7 @@ DESCRIPTION
=-=
config("leadzero", bool)
config("leadzero", boolean)
The "leadzero" parameter controls whether or not a 0 is printed
before the decimal point in non-zero fractions with absolute value
@@ -439,7 +441,7 @@ DESCRIPTION
=-=
config("fullzero", bool)
config("fullzero", boolean)
The "fullzero" parameter controls whether or not in decimal floating-
point printing, the digits are padded with zeros to reach the
@@ -490,7 +492,7 @@ DESCRIPTION
=-=
config("blkverbose", bool)
config("blkverbose", boolean)
The "blkverbose" determines if all lines, including duplicates
should be printed. If TRUE, then all lines are printed. If false,
@@ -656,7 +658,7 @@ DESCRIPTION
=-=
config("verbose_quit", bool)
config("verbose_quit", boolean)
The "verbose_quit" controls the print of the message:
@@ -835,6 +837,31 @@ DESCRIPTION
This config parameter is read-only and cannot be set.
=-=
config("redecl_warn", boolean)
Config("redecl_warn") controls whether or not a warning is issued
when redeclaring variables.
The initial "redecl_warn" value is 1.
=-=
config("dupvar_warn", boolean)
Config("dupvar_warn") controls whether or not a warning is issued
when a variable name collides with an exist name of a higher scope.
Examples of collisions are when:
* both local and static variables have the same name
* both local and global variables have the same name
* both function parameter and local variables have the same name
* both function parameter and global variables have the same name
The initial "redecl_warn" value is 1.
EXAMPLE
; current_cfg = config("all");
; config("tilde", off),;
@@ -893,6 +920,8 @@ EXAMPLE
allow_custom 0
version "2.12.0"
baseb 32
redecl_warn 1
dupvar_warn 1
; display()
20
@@ -925,8 +954,8 @@ SEE ALSO
## received a copy with calc; if not, write to Free Software Foundation, Inc.
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
##
## @(#) $Revision: 29.15 $
## @(#) $Id: config,v 29.15 2006/06/11 07:22:05 chongo Exp $
## @(#) $Revision: 29.16 $
## @(#) $Id: config,v 29.16 2006/06/20 10:25:00 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/config,v $
##
## Under source code control: 1991/07/21 04:37:17

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.10 $
* @(#) $Id: quickhash.c,v 29.10 2006/06/06 07:17:02 chongo Exp $
* @(#) $Revision: 29.11 $
* @(#) $Id: quickhash.c,v 29.11 2006/06/20 10:25:45 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/quickhash.c,v $
*
* Under source code control: 1995/03/04 11:34:23
@@ -488,6 +488,8 @@ config_hash(CONFIG *cfg, QCKHASH val)
val = fnv_strhash(cfg->version, val);
}
value = (((value>>5) | (value<<27)) ^ (USB32)cfg->baseb);
value = (((value>>5) | (value<<27)) ^ (USB32)cfg->redecl_warn);
value = (((value>>5) | (value<<27)) ^ (USB32)cfg->dupvar_warn);
/*
* hash the epsilon if possible

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.5 $
* @(#) $Id: symbol.c,v 29.5 2006/05/20 08:43:55 chongo Exp $
* @(#) $Revision: 29.6 $
* @(#) $Id: symbol.c,v 29.6 2006/06/20 10:28:06 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/symbol.c,v $
*
* Under source code control: 1990/02/15 01:48:23
@@ -511,6 +511,7 @@ endscope(char *name, BOOL isglobal)
prevsp->g_next = sp->g_next;
else
*hp = sp->g_next;
continue;
}
}
prevsp = sp;
@@ -754,10 +755,10 @@ symboltype(char *name)
{
GLOBAL *sp;
if (findlocal(name) >= 0)
return SYM_LOCAL;
if (findparam(name) >= 0)
return SYM_PARAM;
if (findlocal(name) >= 0)
return SYM_LOCAL;
sp = findglobal(name);
if (sp) {
if (sp->g_filescope == SCOPE_GLOBAL)

24
token.c
View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.8 $
* @(#) $Id: token.c,v 29.8 2006/06/03 22:47:28 chongo Exp $
* @(#) $Revision: 29.9 $
* @(#) $Id: token.c,v 29.9 2006/06/20 10:28:06 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/token.c,v $
*
* Under source code control: 1990/02/15 01:48:25
@@ -770,3 +770,23 @@ scanerror(int skip, char *fmt, ...)
}
}
}
/*
* Display a warning and return to compiling
*/
void
warning(char *fmt, ...)
{
va_list ap;
char *name; /* name of file with error */
char buf[MAXERROR+1];
name = inputname();
if (name)
fprintf(stderr, "\"%s\", line %ld: ", name, linenumber());
va_start(ap, fmt);
vsnprintf(buf, MAXERROR, fmt, ap);
va_end(ap);
buf[MAXERROR] = '\0';
fprintf(stderr, "Warning: %s\n", buf);
}

View File

@@ -17,8 +17,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.4 $
* @(#) $Id: token.h,v 29.4 2001/06/08 21:00:58 chongo Exp $
* @(#) $Revision: 29.5 $
* @(#) $Id: token.h,v 29.5 2006/06/20 10:28:06 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/token.h,v $
*
* Under source code control: 1990/02/15 01:48:37
@@ -176,6 +176,7 @@ extern int tokenmode(int flag);
extern int gettoken(void);
extern void rescantoken(void);
extern void scanerror(int, char *, ...);
extern void warning(char *, ...);
#endif /* !__TOKEN_H__ */

View File

@@ -19,8 +19,8 @@
* received a copy with calc; if not, write to Free Software Foundation, Inc.
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* @(#) $Revision: 29.60 $
* @(#) $Id: version.c,v 29.60 2006/06/11 07:52:58 chongo Exp $
* @(#) $Revision: 29.61 $
* @(#) $Id: version.c,v 29.61 2006/06/20 09:27:07 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/version.c,v $
*
* Under source code control: 1990/05/22 11:00:58
@@ -48,7 +48,7 @@ static char *program;
#define MAJOR_VER 2 /* major version */
#define MINOR_VER 12 /* minor version */
#define MAJOR_PATCH 0 /* patch level or 0 if no patch */
#define MINOR_PATCH 3 /* test number or 0 if no minor patch */
#define MINOR_PATCH 4 /* test number or 0 if no minor patch */
/*