Release calc version 2.12.0.8

This commit is contained in:
Landon Curt Noll
2006-08-20 10:53:51 -07:00
parent ee99adf8ca
commit c335809b5f
25 changed files with 598 additions and 231 deletions

53
BUGS
View File

@@ -68,10 +68,6 @@ of a context diff patch).
Known bugs:
The stoponerror() facility does not seem to work, or perhaps
the stoponerror help file is incorrect. The stoponerror help file
lacks examples because of this problem.
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.
@@ -114,51 +110,6 @@ Problems with old systems that have known work-a-rounds:
to fail the regression test. The work-a-round is to compile with -O
or to use gcc-2.96 or later.
This bug has been observed on the Sparc and the PowerPC machine.
On the PowerPC with gcc-2.95 when compiled with -O2, the following
patch seems to help:
*** zfunc.c.orig Fri Feb 23 18:18:39 2001
--- zfunc.c Fri Feb 23 18:39:33 2001
***************
*** 1481,1487 ****
{
HALF *a, *A, *b, *a0, u;
int i, j, j1, j2, k, k1, m, m0, m1, n, n0, o;
! FULL d, e, f, g, h, s, t, x, topbit;
int remsign;
BOOL up, onebit;
ZVALUE sqrt;
--- 1481,1488 ----
{
HALF *a, *A, *b, *a0, u;
int i, j, j1, j2, k, k1, m, m0, m1, n, n0, o;
! volatile FULL d;
! FULL e, f, g, h, s, t, x, topbit;
int remsign;
BOOL up, onebit;
ZVALUE sqrt;
*** zmath.c 2000/06/07 14:02:13 29.2
--- zmath.c 2001/03/13 19:47:03
***************
*** 1608,1614 ****
void
zbitvalue(long n, ZVALUE *res)
{
! ZVALUE z;
if (n < 0) n = 0;
z.sign = 0;
--- 1608,1614 ----
void
zbitvalue(long n, ZVALUE *res)
{
! volatile ZVALUE z;
if (n < 0) n = 0;
z.sign = 0;
* There are problems compiling calc on the sparcv9 under 64 bit
Solaris. On that platform, gcc-2.96 is able to compile calc, but
calc dumps core very early on in startup. It is said that sparcv9
@@ -190,8 +141,8 @@ Problems with old systems that have known work-a-rounds:
## 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.24 $
## @(#) $Id: BUGS,v 29.24 2006/05/21 07:54:13 chongo Exp $
## @(#) $Revision: 29.25 $
## @(#) $Id: BUGS,v 29.25 2006/08/20 17:51:25 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/RCS/BUGS,v $
##
## Under source code control: 1994/03/18 14:06:13

19
CHANGES
View File

@@ -367,6 +367,21 @@ The following are the changes from calc version 2.12.0 to date:
Changed the "Copyright" line in the rpm spec file to a "License" line
as per new rpm v4.4 syntax.
The quomod() builtin function does not allow constants for its 3rd
and 4th arguments. Updated the "help quomod" file and added more
quomod regression tests.
Added patch from Ernest Bowen <ebowen at une dot edu dot au> to
add the builtin: estr(). The estr(x) will return a representation
of a null, string, real number, complex number, list, matrix,
object. block, named block, error as a string.
Added patch from Ernest Bowen <ebowen at une dot edu dot au> to
add the builtin: fgetfile(). The fgetfile(x) will return the rest
of an open file as a string.
Improved help files for fgetfield, fputs, name, or quomod.
The following are the changes from calc version 2.11.10.1 to 2.11.11:
@@ -6187,8 +6202,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.84 $
## @(#) $Id: CHANGES,v 29.84 2006/06/26 05:53:25 chongo Exp $
## @(#) $Revision: 29.86 $
## @(#) $Id: CHANGES,v 29.86 2006/08/20 16:18:10 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/RCS/CHANGES,v $
##
## Under source code control: 1993/06/02 18:12:57

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.34 $
* @(#) $Id: regress.cal,v 29.34 2006/06/25 20:33:26 chongo Exp $
* @(#) $Revision: 29.35 $
* @(#) $Id: regress.cal,v 29.35 2006/08/20 16:16:11 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/regress.cal,v $
*
* Under source code control: 1990/02/15 01:50:36
@@ -743,6 +743,7 @@ define test_functions()
local pi;
local h, n, r, m, v;
local n2, m2, v2;
local t;
print '700: Beginning test_functions';
@@ -3461,7 +3462,7 @@ print '070: parsed test_redc()';
*/
define test_fileops()
{
local a, b, c, f, m, n, p, r, x, y, z;
local a, b, c, f, m, n, p, r, s, x, y, z;
local L = "Landon";
local C = "Curt";
local N = "Noll";
@@ -3588,13 +3589,36 @@ define test_fileops()
vrfy(isfile(p=fopen(long,"r")) == 0,
'4268: isfile(p=fopen(long,"r")) == 0');
/*
* test fgetfile() and fgetline()
*/
vrfy(!iserror(p=fopen("tmp4200","w")),
'4269: !iserror(p=fopen("tmp4200","w"))');
vrfy(!iserror(fputs(p,"chongo\n")),
'4270: !iserror(fputs(p,"chongo\n"))');
vrfy(!iserror(fputs(p,"w\0a\0s\n")),
'4271: !iserror(fputs(p,"w\0a\0s\n"))');
vrfy(!iserror(fputs(p,"here\n")),
'4272: !iserror(fputs(p,"here\n"))');
vrfy(!iserror(fclose(p)), '4273: !iserror(fclose(p))');
vrfy(!iserror(p=fopen("tmp4200","r")),
'4274: !iserror(p=fopen("tmp4200","r"))');
vrfy(!iserror(s=fgetline(p)), '4275: !iserror(s=fgetline(p))');
vrfy(strcmp(s,"chongo") == 0, '4276: strcmp(s,"chongo") == 0');
vrfy(!iserror(s=fgetfile(p)), '4277: !iserror(s=fgetfile(p))');
vrfy(strcmp(s,"w\0a\0s\nhere\n") == 0,
'4278: strcmp(s,"w\0a\0s\nhere\n") == 0');
vrfy(!iserror(fclose(p)), '4279: !iserror(fclose(p))');
/*
* cleanup
*/
x = rm("junk4200");
print '4269: x = rm("junk4200")';
print '4280: x = rm("junk4200")';
x = rm("tmp4200");
print '4281: x = rm("tmp4200")';
print '4270: Ending test_fileops';
print '4282: Ending test_fileops';
}
print '071: parsed test_fileops()';

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.cal,v 29.1 2006/05/20 19:35:33 chongo Exp $
* @(#) $Revision: 29.2 $
* @(#) $Id: set8700.cal,v 29.2 2006/08/20 16:16:11 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/set8700.cal,v $
*
* Under source code control: 2006/05/20 14:10:11
@@ -70,3 +70,8 @@ define set8700_g(set8700_x)
obj set8700_point {
set8700_x, set8700_y, set8700_z
}
global mat set8700_c[] = { 1, 2+3i, -5+4i, 5i+6, -7i };
global mat set8700_e[] = { 0, 1, 0, 0, 2, -3/2, 2, -1/2,
-3, 0.5, -1.0, 0.5, 1.0, 0.0, 0.0, 0.0 };

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: set8700.line,v 29.2 2006/06/20 09:29:16 chongo Exp $
## @(#) $Revision: 29.4 $
## @(#) $Id: set8700.line,v 29.4 2006/08/20 16:16:11 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/set8700.line,v $
##
## Under source code control: 2006/05/20 14:10:11
@@ -402,3 +402,28 @@ set8700_P == (obj set8700_point = {1,2,3})
set8700_L = list(mat[1] = {set8700_P}), protect(set8700_L[0][0]) == 16
set8700_L = {{{4,5,6}}}, set8700_L[0][0] == set8700_P
protect(set8700_L,0,2), set8700_L = {{{4,5,6}}}, set8700_L[0][0] == (obj set8700_point = {4,5,6})
## Testing quomod
quomod(14,5,3,4) == error(10374)
global set8700_a,set8700_b; quomod("abc", 4, set8700_a, set8700_b) == error(10375)
quomod(14,5,set8700_a,set8700_b,0) == 1 && set8700_a == 2 && set8700_b == 4
quomod(14,5,set8700_a,set8700_b,1) == 1 && set8700_a == 3 && set8700_b == -1
quomod("abc",2,set8700_a,set8700_b) == error(10375)
set8700_a = "abc"; quomod(14,5,set8700_a,set8700_b) == error(10375)
set8700_a = null(); quomod(14,5,set8700_a,set8700_b,24) == 1; set8700_a == 3 && set8700_b == -1
quomod(14,5,set8700_a,set8700_a) == error(10374)
quomod(14,5,set8700_a,set8700_b,-1) == error(10375)
protect(set8700_a,1); quomod(17,2,set8700_a,set8700_b) == error(10376)
protect(set8700_a,0); quomod(17,2,set8700_a,set8700_b); set8700_a == 8 && set8700_b == 1
set8700_p = &set8700_a, set8700_q = &set8700_b; quomod(14,5,*set8700_p,*set8700_q); *set8700_p == 2 && *set8700_q == 4
## Testing estr
base(1/3) == 10
strcmp(estr(null()), "\"\"") == 0
strcmp(estr(bernoulli(48)), "-5609403368997817686249127547/46410") == 0
strcmp(estr(sin(3i)), "1001787492740990189897i/100000000000000000000") == 0
base(10) == 1/3
strcmp(estr("fizzbin"), "\"fizzbin\"") == 0
strcmp(estr(set8700_c), "mat[5]={1,2+3i,-5+4i,6+5i,-7i}") == 0
strcmp(estr(set8700_e), "mat[16]={0,1,0,0,2,-3/2,2,-1/2,-3,1/2,-1,1/2,1,0,0,0}") == 0
strcmp(estr(list(2,3,5)), "list(2,3,5)") == 0

8
calc.h
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.18 $
* @(#) $Id: calc.h,v 29.18 2006/05/21 07:28:54 chongo Exp $
* @(#) $Revision: 29.19 $
* @(#) $Id: calc.h,v 29.19 2006/08/20 15:01:30 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/calc.h,v $
*
* Under source code control: 1990/02/15 01:48:31
@@ -113,10 +113,10 @@ extern DLL int closeid(FILEID id);
extern DLL int getcharid(FILEID id);
extern DLL int idprintf(FILEID id, char *fmt, int count, VALUE **vals);
extern DLL int idfputc(FILEID id, int ch);
extern DLL int idfputs(FILEID id, char *str);
extern DLL int idfputs(FILEID id, STRING *str);
extern DLL int printid(FILEID id, int flags);
extern DLL int flushid(FILEID id);
extern DLL int readid(FILEID id, int flags, char **retptr);
extern DLL int readid(FILEID id, int flags, STRING **retptr);
extern DLL int getloc(FILEID id, ZVALUE *loc);
extern DLL int setloc(FILEID id, ZVALUE zpos);
extern DLL int getsize(FILEID id, ZVALUE *size);

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: calcerr.tbl,v 29.9 2006/06/25 20:33:26 chongo Exp $
# @(#) $Revision: 29.10 $
# @(#) $Id: calcerr.tbl,v 29.10 2006/08/20 15:01:30 chongo Exp $
# @(#) $Source: /usr/local/src/cmd/calc/RCS/calcerr.tbl,v $
#
# Under source code control: 1996/05/23 17:38:44
@@ -445,3 +445,7 @@ E_FPATHOPEN1 Non-string arguments for fpathopen
E_FPATHOPEN2 Unrecognized mode for fpathopen
E_LOG1 Bad epsilon argument for log
E_LOG2 Non-numeric first argument for log
E_FGETFILE1 Non-file argument for fgetfile
E_FGETFILE2 File argument for fgetfile not open for reading
E_FGETFILE3 Unable to set file position in fgetfile
E_ESTR Non-representable type for estr

View File

@@ -18,8 +18,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: check.awk,v 29.3 2006/05/20 19:43:39 chongo Exp $
# @(#) $Revision: 29.4 $
# @(#) $Id: check.awk,v 29.4 2006/08/20 16:16:31 chongo Exp $
# @(#) $Source: /usr/local/src/cmd/calc/RCS/check.awk,v $
#
# Under source code control: 1996/05/25 22:07:58
@@ -64,7 +64,7 @@ NF == 0 {
end_seen = 1;
}
$1 ~ /^[0-9]+:/ || $1 ~ /^[0-9]+-[0-9]*:/ {
$1 ~ /^[0-9]+:/ || $1 ~ /^[0-9]+-[0-9]*:/ || $1 ~ /^"))$/ {
if (error > 0) {
if (havebuf2) {
print buf2;

38
file.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.15 $
* @(#) $Id: file.c,v 29.15 2006/05/22 19:04:45 chongo Exp $
* @(#) $Revision: 29.16 $
* @(#) $Id: file.c,v 29.16 2006/08/20 15:01:30 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/file.c,v $
*
* Under source code control: 1991/07/20 00:21:56
@@ -746,10 +746,10 @@ flushall(void)
* given:
* id file to read from
* flags read flags (see above)
* retptr returned pointer to string
* retstr returned pointer to string
*/
int
readid(FILEID id, int flags, char **retptr)
readid(FILEID id, int flags, STRING **retstr)
{
FILEIO *fiop; /* file structure */
FILE *fp;
@@ -761,6 +761,7 @@ readid(FILEID id, int flags, char **retptr)
int c;
BOOL nlstop, nullstop, wsstop, rmstop, done;
FILEPOS fpos;
STRING *newstr;
totlen = 0;
str = NULL;
@@ -831,7 +832,10 @@ readid(FILEID id, int flags, char **retptr)
if ((nullstop && c == '\0') && !rmstop)
str[totlen - 1] = '\0';
str[totlen] = '\0';
*retptr = str;
newstr = stralloc();
newstr->s_len = totlen;
newstr->s_str = str;
*retstr = newstr;
return 0;
}
@@ -895,7 +899,7 @@ printid(FILEID id, int flags)
math_chr('"');
return 0;
}
math_fmt("FILE %d \"%s\" (%s, ", id, fiop->name, fiop->mode);
math_fmt("FILE %d \"%s\" (%s", id, fiop->name, fiop->mode);
/*
* print file position
@@ -904,11 +908,13 @@ printid(FILEID id, int flags)
fp = fiop->fp;
if (get_open_pos(fp, &pos) < 0) {
math_str("Error while determining file position!)");
if (fileno(fp) > 2)
math_str("Error while determining file position!");
math_chr(')');
return 0;
}
math_str("pos ");
math_str(", pos ");
zprintval(pos, 0, 0);
zfree(pos);
@@ -1233,10 +1239,13 @@ idungetc(FILEID id, int ch)
* str string to write
*/
int
idfputs(FILEID id, char *str)
idfputs(FILEID id, STRING *str)
{
FILEIO *fiop;
FILEPOS fpos;
FILE *fp;
char *c;
long len;
/* get the file info pointer */
fiop = findid(id, TRUE);
@@ -1251,14 +1260,13 @@ idfputs(FILEID id, char *str)
fiop->action = 'w';
/* set output to file */
math_setfp(fiop->fp);
fp = fiop->fp;
len = str->s_len;
c = str->s_str;
/* write the string */
math_str(str);
while (len-- > 0)
fputc(*c++, fp);
/* restore output to stdout */
math_setfp(stdout);
return 0;
}

90
func.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.28 $
* @(#) $Id: func.c,v 29.28 2006/06/25 20:33:26 chongo Exp $
* @(#) $Revision: 29.30 $
* @(#) $Id: func.c,v 29.30 2006/08/20 15:01:30 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/func.c,v $
*
* Under source code control: 1990/02/15 01:48:15
@@ -357,6 +357,24 @@ f_str(VALUE *vp)
}
static VALUE
f_estr(VALUE *vp)
{
VALUE result;
char *cp;
/* initialize result */
result.v_type = V_STR;
result.v_subtype = V_NOSUBTYPE;
math_divertio();
printestr(vp);
cp = math_getdivertedio();
result.v_str = makestring(cp);
return result;
}
static VALUE
f_name(VALUE *vp)
{
@@ -3572,14 +3590,16 @@ f_quomod(int count, VALUE **vals)
v3 = vals[2];
v4 = vals[3];
if (v3->v_type != V_ADDR || v4->v_type != V_ADDR)
if (v3->v_type != V_ADDR || v4->v_type != V_ADDR ||
v3->v_addr == v4->v_addr)
return error_value(E_QUOMOD1);
if (count == 5) {
v5 = vals[4];
if (v5->v_type == V_ADDR)
v5 = v5->v_addr;
if (v5->v_type != V_NUM || qisfrac(v5->v_num) ||
qisneg(v5->v_num)) return error_value(E_QUOMOD2);
qisneg(v5->v_num) || zge31b(v5->v_num->num))
return error_value(E_QUOMOD2);
rnd = qtoi(v5->v_num);
} else
rnd = conf->quomod;
@@ -3588,22 +3608,29 @@ f_quomod(int count, VALUE **vals)
v1 = v1->v_addr;
if (v2->v_type == V_ADDR)
v2 = v2->v_addr;
if (v1->v_type != V_NUM || v2->v_type != V_NUM)
return error_value(E_QUOMOD2);
v3 = v3->v_addr;
v4 = v4->v_addr;
if (v1->v_type != V_NUM || v2->v_type != V_NUM ||
(v3->v_type != V_NUM && v3->v_type != V_NULL) ||
(v4->v_type != V_NUM && v4->v_type != V_NULL))
return error_value(E_QUOMOD2);
s3 = v3->v_subtype;
s4 = v4->v_subtype;
if ((s3 | s4) & V_NOASSIGNTO)
return error_value(E_QUOMOD3);
freevalue(v3);
freevalue(v4);
v3->v_type = V_NUM;
v4->v_type = V_NUM;
v3->v_subtype = s3;
v4->v_subtype = s4;
res = qquomod(v1->v_num, v2->v_num, &v3->v_num, &v4->v_num, rnd);
result.v_type = V_NUM;
result.v_subtype = V_NOSUBTYPE;
@@ -5827,7 +5854,7 @@ strscan(char *s, int count, VALUE **vals)
static int
filescan(FILEID id, int count, VALUE **vals)
{
char *str;
STRING *str;
int i;
int n = 0;
VALUE val;
@@ -5848,7 +5875,7 @@ filescan(FILEID id, int count, VALUE **vals)
if (i > 0)
return EOF;
n++;
val.v_str = makenewstring(str);
val.v_str = str;
result = f_eval(&val);
var = *vals++;
if (var->v_type == V_ADDR) {
@@ -6095,7 +6122,7 @@ f_fputs(int count, VALUE **vals)
return error_value(E_FPUTS2);
}
for (i = 1; i < count; i++) {
err = idfputs(vals[0]->v_file, vals[i]->v_str->s_str);
err = idfputs(vals[0]->v_file, vals[i]->v_str);
if (err > 0)
return error_value(E_FPUTS3);
}
@@ -6242,7 +6269,7 @@ static VALUE
f_fgetline(VALUE *vp)
{
VALUE result;
char *str;
STRING *str;
int i;
/* initialize VALUE */
@@ -6256,7 +6283,7 @@ f_fgetline(VALUE *vp)
result.v_type = V_NULL;
if (i == 0) {
result.v_type = V_STR;
result.v_str = makestring(str);
result.v_str = str;
}
return result;
}
@@ -6266,7 +6293,7 @@ static VALUE
f_fgets(VALUE *vp)
{
VALUE result;
char *str;
STRING *str;
int i;
/* initialize VALUE */
@@ -6280,7 +6307,7 @@ f_fgets(VALUE *vp)
result.v_type = V_NULL;
if (i == 0) {
result.v_type = V_STR;
result.v_str = makestring(str);
result.v_str = str;
}
return result;
}
@@ -6290,7 +6317,7 @@ static VALUE
f_fgetstr(VALUE *vp)
{
VALUE result;
char *str;
STRING *str;
int i;
/* initialize VALUE */
@@ -6304,7 +6331,7 @@ f_fgetstr(VALUE *vp)
result.v_type = V_NULL;
if (i == 0) {
result.v_type = V_STR;
result.v_str = makestring(str);
result.v_str = str;
}
return result;
}
@@ -6314,7 +6341,7 @@ static VALUE
f_fgetfield(VALUE *vp)
{
VALUE result;
char *str;
STRING *str;
int i;
/* initialize VALUE */
@@ -6328,7 +6355,32 @@ f_fgetfield(VALUE *vp)
result.v_type = V_NULL;
if (i == 0) {
result.v_type = V_STR;
result.v_str = makestring(str);
result.v_str = str;
}
return result;
}
static VALUE
f_fgetfile(VALUE *vp)
{
VALUE result;
STRING *str;
int i;
/* initialize VALUE */
result.v_subtype = V_NOSUBTYPE;
if (vp->v_type != V_FILE)
return error_value(E_FGETFILE1);
i = readid(vp->v_file, 0, &str);
if (i == 1)
return error_value(E_FGETFILE2);
if (i == 3)
return error_value(E_FGETFILE3);
result.v_type = V_NULL;
if (i == 0) {
result.v_type = V_STR;
result.v_str = str;
}
return result;
}
@@ -8165,6 +8217,8 @@ static CONST struct builtin builtins[] = {
"set or read calc_errno"},
{"error", 0, 1, 0, OP_NOP, 0, f_error,
"generate error value"},
{"estr", 1, 1, 0, OP_NOP, 0, f_estr,
"exact text string representation of value"},
{"euler", 1, 1, 0, OP_NOP, 0, f_euler,
"Euler number"},
{"eval", 1, 1, 0, OP_NOP, 0, f_eval,
@@ -8195,6 +8249,8 @@ static CONST struct builtin builtins[] = {
"read next char from file"},
{"fgetfield", 1, 1, 0, OP_NOP, 0, f_fgetfield,
"read next white-space delimited field from file"},
{"fgetfile", 1, 1, 0, OP_NOP, 0, f_fgetfile,
"read to end of file"},
{"fgetline", 1, 1, 0, OP_NOP, 0, f_fgetline,
"read next line from file, newline removed"},
{"fgets", 1, 1, 0, OP_NOP, 0, f_fgets,

View File

@@ -18,8 +18,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: Makefile,v 29.29 2006/06/26 05:46:06 chongo Exp $
# @(#) $Revision: 29.30 $
# @(#) $Id: Makefile,v 29.30 2006/08/20 15:01:57 chongo Exp $
# @(#) $Source: /usr/local/src/cmd/calc/help/RCS/Makefile,v $
#
# Under source code control: 1991/07/23 06:47:57
@@ -267,15 +267,15 @@ BLT_HELP_FILES= ${BLT_HELP_FILES_3} ${BLT_HELP_FILES_5} \
#
DETAIL_HELP= abs access acos acosh acot acoth acsc acsch address agd append \
appr arg argv arrow asec asech asin asinh assign atan atan2 atanh \
avg base base2 bernoulli bit blk blkcpy blkfree blocks bround btrunc \
calc_tty calclevel catalan ceil cfappr cfsim char cmdbuf cmp comb \
conj cos cosh cot coth count cp csc csch ctime delete den dereference \
det digit digits display dp epsilon errcount errmax errno error \
euler eval exp fact factor fclose fcnt feof ferror fflush fgetc \
fgetfield fgetline fgets fgetstr fib files floor fopen forall \
fpathopen fprintf fputc fputs fputstr frac free freebernoulli \
freeeuler freeglobals freeredc freestatics frem freopen fscan \
fscanf fseek fsize ftell gcd gcdrem gd getenv hash head highbit \
avg base base2 bernoulli bit blk blkcpy blkfree blocks bround \
btrunc calc_tty calclevel catalan ceil cfappr cfsim char cmdbuf \
cmp comb conj cos cosh cot coth count cp csc csch ctime delete den \
dereference det digit digits display dp epsilon errcount errmax \
errno error estr euler eval exp fact factor fclose fcnt feof ferror \
fflush fgetc fgetfield fgetfile fgetline fgets fgetstr fib files \
floor fopen forall fpathopen fprintf fputc fputs fputstr frac free \
freebernoulli freeeuler freeglobals freeredc freestatics frem freopen \
fscan fscanf fseek fsize ftell gcd gcdrem gd getenv hash head highbit \
hmean hnrmod hypot ilog ilog10 ilog2 im indices inputlevel insert \
int inverse iroot isassoc isatty isblk isconfig isdefined iserror \
iseven isfile ishash isident isint islist ismat ismult isnull isnum \

45
help/estr Normal file
View File

@@ -0,0 +1,45 @@
NAME
estr - represent some types of value by text strings
SYNOPSIS
estr(x)
TYPES
x null, string, real or complex number, list, matrix,
object. block, named block, error
return string
DESCRIPTION
This function attempts to represent x exactly by a string s of
ordinary text characters such that eval(s) == x.
If x is null, estr(x) returns the string "".
If x is a string, estr(x) returns the string in which occurrences of
newline, tab, ", \, etc. have been converted to \n, \t, \",
\\, etc., '\0' to \000 or \0 according as the next character is
or is not an octal digit, and other non-text characters to their
escaped hex representation, e.g. char(165) becomes \xa5.
For real x, estr(x) represebts x in fractional mode.
EXAMPLE
; estr("abc\0xyz\00023\n\xa5\r\n")
""abc\0xyz\00023\n\xa5\r\n""
; estr(1.67)
"167/100"
; estr(mat[3] = {2, list(3,5), "abc"})
"mat[3]={2,list(3,5),"abc""
LIMITS
none
LINK LIBRARY
none
SEE ALSO
str, strprintf

View File

@@ -7,19 +7,18 @@ SYNOPSIS
TYPES
fs file stream open for reading
return string, null or error value
return string or null
DESCRIPTION
If characters cannot be read from the file, an error value is returned.
Otherwise starting at the current file position, any whitespace
Starting at the current file position, any whitespace
characters are skipped. If the reading reaches end-of-file, the
null value is returned. If non-whitespace is encountered, formation
of a string begins, continuing until whitespace of '\0' or end-of-file
is reached. The returned value is this string (terminated as usual
by a null character). After the operation, the file position will
be immediately after the first whitespace character of '\0' or at
end-of-file.
null value is returned. Otherwise the function returns the empty
string "" if the first non-white character is '\0', and in other cases,
the string formed by the non-white-space characters read until '\0' or
a white-space character or te end of the file is reached. In the
cases where the reading is stopped by '\0' or white-space character,
the file position will be that immediately after that character.
EXAMPLE
@@ -67,8 +66,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.5 $
## @(#) $Id: fgetfield,v 29.5 2006/06/25 22:16:55 chongo Exp $
## @(#) $Revision: 29.6 $
## @(#) $Id: fgetfield,v 29.6 2006/08/20 15:01:57 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/fgetfield,v $
##
## Under source code control: 1996/04/30 03:05:17

72
help/fgetfile Normal file
View File

@@ -0,0 +1,72 @@
NAME
fgetfile - read the rest of a file to form a string
SYNOPSIS
fgetfile(fs)
TYPES
fs file stream open for reading
return string or null value
DESCRIPTION
If the current file position for fs is the end of the file, the
null value is returned.
Otherwise the function returns the string formed from reading all
characters from the current file position to the end of the file.
If the content of the file "newfile" is a sequence of statements that
could form the body of function definition, the statement sequence
fs = fopen("newfile", "r");
eval(fgetfile(fs));
achieves the same as the command
read newfile;
EXAMPLE
; f = fopen("/tmp/newfile", "w")
; fputs(f, "abc\0xyz\n\t\xb0\0\r\v123"
; freopen(f, "r")
; estr(fgetfile(f))
""abc\0xyz\n\t\xb0\0\r\v123""
LIMITS
none
LINK LIBRARY
none
SEE ALSO
fgets, fgetstr, files, fopen, fprintf, fputs, fputstr
## Copyright (C) 1999-2006 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
## as published by the Free Software Foundation.
##
## Calc is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
## Public License for more details.
##
## A copy of version 2.1 of the GNU Lesser General Public License is
## distributed with calc under the filename COPYING-LGPL. You should have
## 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: fgetfile,v 29.2 2006/08/20 15:01:57 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/fgetfile,v $
##
## Under source code control: 1996/04/30 03:05:17
## File existed as early as: 1996
##
## chongo <was here> /\oo/\ http://www.isthe.com/chongo/
## Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/

View File

@@ -2,34 +2,34 @@ NAME
fputs - write a string to a file
SYNOPSIS
fputs(fd, data)
fputs(fd, s1, s2, ...)
TYPES
fd file
data str
fd file stream open for writing
s1, s2, ... strings
return nil
return null value
DESCRIPTION
This function writes the string found in data to the file
associated with fd.
This function writes in succession the strings s1, s2, ..., to the
file associated with fd.
EXAMPLE
; fd = fopen("/tmp/newfile", "w")
; fputs(fd, "chongo was here\n")
; fputs(fd, "chongo was", " here\n")
; fd2 = fopen("/tmp/newfile", "r")
; fgetline(fd2)
"chongo was here"
LIMITS
fd must be associated with an open file
The number of arguments is not to exceed 1024
LINK LIBRARY
none
SEE ALSO
errno, fclose, feof, ferror, fflush, fgetc, fgetline, fgets, files, fopen,
fprintf, fputc, fputs, fseek, fsize, ftell, isfile, printf, prompt
errno, fclose, feof, ferror, fflush, fgetc, fgetfile, fgetline, fgets,
files, fopen, fprintf, fputc, fseek, fsize, ftell, isfile
## Copyright (C) 1999 Landon Curt Noll
##
@@ -47,8 +47,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.3 $
## @(#) $Id: fputs,v 29.3 2006/05/07 07:25:46 chongo Exp $
## @(#) $Revision: 29.4 $
## @(#) $Id: fputs,v 29.4 2006/08/20 15:01:57 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/fputs,v $
##
## Under source code control: 1995/03/04 11:33:20

View File

@@ -26,7 +26,7 @@ EXAMPLE
; name(f)
"/tmp/beta"
; names(files(0))
; name(files(0))
"(stdin)"
LIMITS
@@ -54,8 +54,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.4 $
## @(#) $Id: name,v 29.4 2006/06/25 22:16:55 chongo Exp $
## @(#) $Revision: 29.5 $
## @(#) $Id: name,v 29.5 2006/08/20 15:01:57 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/name,v $
##
## Under source code control: 1997/04/05 14:12:44

View File

@@ -1,41 +1,73 @@
NAME
quomod - assign quotient and remainder to two variables
quomod - assign quotient and remainder to two lvalues
SYNOPSIS
quomod(x, y, q, r [, rnd])
quomod(x, y, Q, R [, rnd])
TYPES
x real
y real
q any
r any
rnd integer, defaults to config("quomod")
Q null-or-real-valued lvalue with assign-to permission
R null-or-real-valued lvalue with assign-to permission
rnd nonnegative integer, defaults to config("quomod")
return real
return 0 or 1
DESCRIPTION
Returns 0 or 1 according as x is or is not a multiple of y.
Let x = q * y + r where q is an integer and 0 <= r < y
This function assigns the values q and r to the variables
Q and R. If x >= 0, the results for Q and R are the same as
those given by Q = x // y, R = x % y.
If y is nonzero and x/y is an integer q, this function assigns
q to Q and zero to R, and returns zero.
The argument rnd (if passed or config value config("quomod") if the
rnd argument is not passed) impacts the rounding mode for producing
the quotient and modulus. See "help quo" details of how the quotient
is impacted by rounding modes. See "help mod" for details of how
the modulus is impacted by rounding modes. The only difference on
those descriptions is that quomod() is controlled by a single config
value config("quomod") instead of config("quo") and config("mod").
If y is zero, zero is assigned to Q, x to R and 0 or 1 returned
according as x is zero or nonzero.
XXX - replace the above paragraph and directly describe how rnd
and config("quomod") impact quomod.
In the remaining case, y nonzero and x/y not an intger, there
are two pairs (q,r) for which x = q * y + r, q is an integer, and
abs(r) < abs(y). Depending on the low 5 bits of rnd, the q and r
of one of these pairs will be assigned to Q and R respectively,
and the number 1 returned. The effects of rnd can be described in
terms of the way q is related to x/y, e.g. by rounding down,
rounding towards zero, rounding to a nearest integeri, etc. or
by properties of the remainder r, e.g. positive, negative,
smallest, etc. The effects of the most commonly used values of
rnd are described in the following table:
The C language method of modulus and integer division is:
rnd q r
0 round down. q = floor(x/y) same sign as y
1 round up, q = ceil(x/y) opposite sign to y
2 round to zero, q = int(x/y) same sign as x, r = y * frac(x/y)
3 round from zero oppsite sign to x
4 positive
5 negative
6 same sign as x/y
7 opposite sigh to x/y
8 to nearest even
9 to nearest odd
For 16 <= rnd < 32, the rounding is to the nearest integer and r
is the smallest (in absolute value) remainder except when x/y is
halfway between consecutive integers, in which case the rounding
is as given by the 4 low bits of rnd. Using rnd = 24 gives the
cpmmonly used principle of rounding: round to the nearest integer,
but take the even integer when there are two equally close integers.
For more detail on the effects of rnd for values other than those
listed above, see "help quo" and "help mod".
In all cases, the values assigned to Q and R by quomod(x, y, Q, R, rnd)
are the same as those given by Q = quo(x,y,rnd), R = mod(x,y,rnd).
If config("quo") == rnd, Q is also given by quo(x,y) or x // y.
If config("mod") == rnd, R is also given by mod(x,y) or x % y.
The rounding used by the C language for x / y and x % y corresponds
to rnd = 2.
An error values is returned and the values of Q and R are not changed
if Q and R are not both lvalues, or if the current value of any
argument is not as specified above, or if Q or R has no-assign-to
prptection, e.g. after protect(Q,1).
config("quomod", 2)
config("quo", 2)
config("mod", 2)
EXAMPLE
; global u, v;
@@ -59,13 +91,13 @@ EXAMPLE
1 3 -1
LIMITS
y > 0
rnd < 2^31
LINK LIBRARY
BOOL qquomod(NUMBER *q1, NUMBER *q2, NUMBER **retqdiv, NUMBER **retqmod)
BOOL qquomod(NUMBER *q1, NUMBER *q2, NUMBER **quo, NUMBER **mod)
SEE ALSO
//, %
//, %, quo, mod, floor. ceil, int. frac
## Copyright (C) 1999-2006 Landon Curt Noll
##
@@ -83,8 +115,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.5 $
## @(#) $Id: quomod,v 29.5 2006/06/25 20:33:26 chongo Exp $
## @(#) $Revision: 29.7 $
## @(#) $Id: quomod,v 29.7 2006/08/20 15:01:57 chongo Exp $
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/quomod,v $
##
## Under source code control: 1995/05/07 03:17:03

46
rpm.mk
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.
#
MAKEFILE_REV= $$Revision: 29.13 $$
# @(#) $Id: rpm.mk,v 29.13 2003/04/15 03:39:17 chongo Exp $
MAKEFILE_REV= $$Revision: 29.14 $$
# @(#) $Id: rpm.mk,v 29.14 2006/08/20 16:47:51 chongo Exp $
# @(#) $Source: /usr/local/src/cmd/calc/RCS/rpm.mk,v $
#
# Under source code control: 2003/02/16 20:21:39
@@ -55,7 +55,7 @@ RPM686= $(PROJECT)-$(PROJECT_RELEASE).${TARCH}.rpm
DRPM686= $(PROJECT_NAME)-devel-$(PROJECT_VERSION)-$(PROJECT_RELEASE).${TARCH}.rpm
SRPM= $(PROJECT)-$(PROJECT_RELEASE).src.rpm
TMPDIR= /var/tmp
RHDIR= /usr/src/redhat
RPMDIR= /usr/src/redhat
all: calc.spec ver_calc
$(MAKE) -f rpm.mk PROJECT_VERSION="`./ver_calc`" \
@@ -80,50 +80,50 @@ calc.spec: calc.spec.in ver_calc
srcpkg: make_rhdir
find . -depth -print | egrep -v '/RCS|/CVS|/NOTES|\.gone' | \
cpio -dumpv $(TMPDIR)/$(PROJECT)
(cd $(TMPDIR); tar cf - $(PROJECT) | \
gzip -c > $(RHDIR)/SOURCES/$(TARBALL))
(cd $(TMPDIR); tar cf - $(PROJECT)) | \
gzip -c > $(RPMDIR)/SOURCES/$(TARBALL)
rm -fr $(TMPDIR)/$(PROJECT)
.PHONY: rpm
rpm: srcpkg calc.spec
$(MAKE) -f Makefile clean
cp $(SPECFILE) $(RHDIR)/SPECS/$(SPECFILE)
rm -f $(RHDIR)/RPMS/${TARCH}/$(RPM686)
rm -f $(RHDIR)/RPMS/${TARCH}/$(DRPM686)
rm -f $(RHDIR)/SRPMS/$(SRPM)
${RPMBUILD_TOOL} ${RPMBUILD_OPTION} $(RHDIR)/SPECS/$(SPECFILE)
@if [ ! -f "$(RHDIR)/SRPMS/$(SRPM)" ]; then \
cp $(SPECFILE) $(RPMDIR)/SPECS/$(SPECFILE)
rm -f $(RPMDIR)/RPMS/${TARCH}/$(RPM686)
rm -f $(RPMDIR)/RPMS/${TARCH}/$(DRPM686)
rm -f $(RPMDIR)/SRPMS/$(SRPM)
${RPMBUILD_TOOL} ${RPMBUILD_OPTION} $(RPMDIR)/SPECS/$(SPECFILE)
@if [ ! -f "$(RPMDIR)/SRPMS/$(SRPM)" ]; then \
echo "SRPMS/$(SRPM) not found" 1>&2; \
exit 3; \
fi
@echo
@echo "RPM package sizes:"
@echo
@cd $(RHDIR); ls -1s RPMS/${TARCH}/$(RPM686) \
@cd $(RPMDIR); ls -1s RPMS/${TARCH}/$(RPM686) \
RPMS/${TARCH}/$(DRPM686) SRPMS/$(SRPM)
@echo
@echo "RPM package md5 hashes:"
@echo
-@cd $(RHDIR); ${MD5SUM} RPMS/${TARCH}/$(RPM686) \
-@cd $(RPMDIR); ${MD5SUM} RPMS/${TARCH}/$(RPM686) \
RPMS/${TARCH}/$(DRPM686) SRPMS/$(SRPM)
@echo
@echo "RPM package sha1 hashes:"
@echo
-@cd $(RHDIR); ${SHA1SUM} RPMS/${TARCH}/$(RPM686) \
-@cd $(RPMDIR); ${SHA1SUM} RPMS/${TARCH}/$(RPM686) \
RPMS/${TARCH}/$(DRPM686) SRPMS/$(SRPM)
@echo
@echo "RPM package locations:"
@echo
@ls -1 $(RHDIR)/RPMS/${TARCH}/$(RPM686) \
$(RHDIR)/RPMS/${TARCH}/$(DRPM686) $(RHDIR)/SRPMS/$(SRPM)
@ls -1 $(RPMDIR)/RPMS/${TARCH}/$(RPM686) \
$(RPMDIR)/RPMS/${TARCH}/$(DRPM686) $(RPMDIR)/SRPMS/$(SRPM)
@echo
@echo "All done! -- Jessica Noll, Age 2"
@echo
.PHONY: make_rhdir
make_rhdir:
for i in $(RHDIR) $(RHDIR)/RPMS $(RHDIR)/SOURCES \
$(RHDIR)/SPECS $(RHDIR)/SRPMS $(RHDIR)/BUILD; do \
for i in $(RPMDIR) $(RPMDIR)/RPMS $(RPMDIR)/SOURCES \
$(RPMDIR)/SPECS $(RPMDIR)/SRPMS $(RPMDIR)/BUILD; do \
if [ ! -d $$i ] ; then \
mkdir -p $$i; \
fi; \
@@ -136,9 +136,9 @@ logdate:
.PHONY: chkpkg
chkpkg:
for i in $(RHDIR)/RPMS/${TARCH}/$(RPM686) \
$(RHDIR)/RPMS/${TARCH}/$(DRPM686) \
$(RHDIR)/SRPMS/$(SRPM) ; do \
for i in $(RPMDIR)/RPMS/${TARCH}/$(RPM686) \
$(RPMDIR)/RPMS/${TARCH}/$(DRPM686) \
$(RPMDIR)/SRPMS/$(SRPM) ; do \
echo "***** start $$i" ; \
${RPM_TOOL} -qpi $$i ; \
echo "***** files $$i" ; \
@@ -165,8 +165,8 @@ installrpm:
echo "must be root to install RPMs" 1>&2; \
exit 5; \
fi
${RPM_TOOL} -ivh $(RHDIR)/RPMS/${TARCH}/$(RPM686)
${RPM_TOOL} -ivh $(RHDIR)/RPMS/${TARCH}/$(DRPM686)
${RPM_TOOL} -ivh $(RPMDIR)/RPMS/${TARCH}/$(RPM686)
${RPM_TOOL} -ivh $(RPMDIR)/RPMS/${TARCH}/$(DRPM686)
.PHONY: uninstallrpm
uninstallrpm:

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.9 $
* @(#) $Id: string.c,v 29.9 2006/05/20 10:13:39 chongo Exp $
* @(#) $Revision: 29.10 $
* @(#) $Id: string.c,v 29.10 2006/08/20 15:01:30 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/string.c,v $
*
* Under source code control: 1990/02/15 01:48:10
@@ -1292,18 +1292,15 @@ freestringconstant(long index)
long
printechar(char *c)
{
long n;
unsigned char ch;
unsigned char ch, cc;
unsigned char ech; /* for escape sequence */
unsigned char nch; /* for next character */
BOOL three;
ch = *c;
if (ch >= ' ' && ch < 127 && ch != '\\' && ch != '\"') {
putchar(ch);
if (ch >= ' ' && ch < 127 && ch != '\\' && ch != '\"' && ch != '\'') {
math_chr(ch);
return 1;
}
putchar('\\');
math_chr('\\');
ech = 0;
switch (ch) {
case '\n': ech = 'n'; break;
@@ -1314,28 +1311,28 @@ printechar(char *c)
case '\v': ech = 'v'; break;
case '\\': ech = '\\'; break;
case '\"': ech = '\"'; break;
case '\'': ech = '\''; break;
case 0: ech = '0'; break;
case 7: ech = 'a'; break;
case 27: ech = 'e'; break;
}
if (ech == '0') {
cc = *(c + 1);
if (cc >= '0' && cc < '8') {
math_str("000");
return 4;
}
}
if (ech) {
putchar(ech);
math_chr(ech);
return 2;
}
nch = *(c + 1);
three = (nch >= '0' && nch < '8');
n = 2;
if (three || ch >= 64) {
putchar('0' + ch/64);
n++;
}
ch %= 64;
if (three || ch >= 8) {
putchar('0' + ch/8);
n++;
}
ch %= 8;
putchar('0' + ch);
return n;
math_chr('x');
cc = ch / 16;
math_chr((cc < 10) ? '0' + cc : 87 + cc);
cc = ch % 16;
math_chr((cc < 10) ? '0' + cc : 87 + cc);
return 4;
}
@@ -1376,11 +1373,23 @@ fitstring(char *str, long len, long width)
n++;
}
if (j > i)
printf("...");
math_str("...");
while (j++ < len)
(void) printechar(c++);
}
void
strprint(STRING *str) {
long n;
char *c;
c = str->s_str;
n = str->s_len;
while (n-- > 0)
(void) printechar(c++);
}
void
showstrings(void)
{

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.6 $
* @(#) $Id: string.h,v 29.6 2006/05/19 15:26:10 chongo Exp $
* @(#) $Revision: 29.7 $
* @(#) $Id: string.h,v 29.7 2006/08/20 15:01:30 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/string.h,v $
*
* Under source code control: 1990/02/15 01:48:36
@@ -73,6 +73,7 @@ extern STRING *findstring(long index);
extern STRING *slink(STRING *);
extern void sfree(STRING *);
extern void fitstring(char *, long, long);
extern void strprint(STRING *);
extern void showstrings(void);
extern void showliterals(void);
extern STRING _nullstring_;

116
value.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: value.c,v 29.9 2006/06/01 11:47:07 chongo Exp $
* @(#) $Revision: 29.10 $
* @(#) $Id: value.c,v 29.10 2006/08/20 15:01:30 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/value.c,v $
*
* Under source code control: 1990/02/15 01:48:25
@@ -2752,6 +2752,118 @@ printvalue(VALUE *vp, int flags)
}
}
/*
* Print an exact text representation of a value
*/
void
printestr(VALUE *vp)
{
LISTELEM *ep;
MATRIX *mp;
OBJECT *op;
BLOCK *bp;
int mode;
long i, min, max;
USB8 *cp;
if (vp->v_type < 0) {
math_fmt("error(%d)", -vp->v_type);
return;
}
switch(vp->v_type) {
case V_NULL:
math_str("\"\"");
return;
case V_STR:
math_chr('"');
strprint(vp->v_str);
math_chr('"');
return;
case V_NUM:
qprintnum(vp->v_num, MODE_FRAC);
return;
case V_COM:
mode = math_setmode(MODE_FRAC);
comprint(vp->v_com);
math_setmode(mode);
return;
case V_LIST:
math_str("list(");
ep = vp->v_list->l_first;
if (ep) {
printestr(&ep->e_value);
while ((ep = ep->e_next)) {
math_chr(',');
printestr(&ep->e_value);
}
}
math_chr(')');
return;
case V_MAT:
mp = vp->v_mat;
if (mp->m_dim == 0)
math_str("(mat[])");
else {
math_str("mat[");
for (i = 0; i < mp->m_dim; i++) {
min = mp->m_min[i];
max = mp->m_max[i];
if (i > 0)
math_chr(',');
if (min)
math_fmt("%ld:%ld", min, max);
else
math_fmt("%ld", max + 1);
}
math_chr(']');
}
i = mp->m_size;
vp = mp->m_table;
break;
case V_OBJ:
op = vp->v_obj;
math_fmt("obj %s",objtypename(op->o_actions->oa_index));
i = op->o_actions->oa_count;
vp = op->o_table;
break;
case V_BLOCK:
case V_NBLOCK:
math_str("blk(");
if (vp->v_type == V_BLOCK)
bp = vp->v_block;
else {
math_fmt("\"%s\",", vp->v_nblock->name);
bp = vp->v_nblock->blk;
}
i = bp->datalen;
math_fmt("%d,%d)", i, bp->blkchunk);
cp = bp->data;
if (i > 0) {
math_str("={");
math_fmt("%d", *cp);
while (--i > 0) {
math_chr(',');
math_fmt("%d", *++cp);
}
math_chr('}');
}
return;
default:
math_str("\"???\"");
return;
}
if (i > 0) {
math_str("={");
printestr(vp);
while (--i > 0) {
math_chr(',');
printestr(++vp);
}
math_chr('}');
}
}
/*
* config_print - print a configuration value

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: value.h,v 29.10 2006/05/19 15:26:10 chongo Exp $
* @(#) $Revision: 29.11 $
* @(#) $Id: value.h,v 29.11 2006/08/20 15:01:30 chongo Exp $
* @(#) $Source: /usr/local/src/cmd/calc/RCS/value.h,v $
*
* Under source code control: 1993/07/30 19:42:47
@@ -243,6 +243,7 @@ extern DLL void relvalue(VALUE *v1, VALUE *v2, VALUE *vres);
extern DLL void sgnvalue(VALUE *vp, VALUE *vres);
extern DLL QCKHASH hashvalue(VALUE *vp, QCKHASH val);
extern DLL void printvalue(VALUE *vp, int flags);
extern DLL void printestr(VALUE *vp);
extern DLL BOOL precvalue(VALUE *v1, VALUE *v2);
extern DLL VALUE error_value(int e);
extern DLL int set_errno(int e);

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.63 $
* @(#) $Id: version.c,v 29.63 2006/06/26 05:53:25 chongo Exp $
* @(#) $Revision: 29.65 $
* @(#) $Id: version.c,v 29.65 2006/08/20 16:18:10 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 6 /* test number or 0 if no minor patch */
#define MINOR_PATCH 8 /* test number or 0 if no minor patch */
/*

View File

@@ -427,5 +427,9 @@ CONST char *error_table[E__COUNT+2] = {
"Unrecognized mode for fpathopen",
"Bad epsilon argument for log",
"Non-numeric first argument for log",
"Non-file argument for fgetfile",
"File argument for fgetfile not open for reading",
"Unable to set file position in fgetfile",
"Non-representable type for estr",
NULL
};

View File

@@ -424,9 +424,13 @@
#define E_FPATHOPEN2 10411 /* Unrecognized mode for fpathopen */
#define E_LOG1 10412 /* Bad epsilon argument for log */
#define E_LOG2 10413 /* Non-numeric first argument for log */
#define E_FGETFILE1 10414 /* Non-file argument for fgetfile */
#define E_FGETFILE2 10415 /* File argument for fgetfile not open for reading */
#define E_FGETFILE3 10416 /* Unable to set file position in fgetfile */
#define E_ESTR 10417 /* Non-representable type for estr */
#define E__HIGHEST 10413 /* highest calc error */
#define E__COUNT 413 /* number of calc errors */
#define E__HIGHEST 10417 /* highest calc error */
#define E__COUNT 417 /* number of calc errors */
#define E_USERDEF 20000 /* base of user defined errors */
/* names of calc error values */