Release calc version 2.11.0t8.4

This commit is contained in:
Landon Curt Noll
1999-10-25 14:26:00 -07:00
parent 49be672338
commit 8db10967e8
6 changed files with 109 additions and 45 deletions

17
BUGS
View File

@@ -68,9 +68,20 @@ importantly, fixes (in the form of a context diff patch) to:
Known bugs: Known bugs:
None reported. We are sure some bugs exist. When you find them, * calc -i ignores quit binding or EOF input in some cases. For example:
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. echo 'define f(x) { ' > myfile
calc -i read myfile
"./myfile", line 2: End-of-file in function body
Error in commands
>
At this point, calc will re-prompt if you give it an EOF, or
type ^D while using lib/altbind or while ^D is bound to quit.
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.
=-= =-=

21
CHANGES
View File

@@ -50,6 +50,27 @@ Following is the change from calc version 2.11.0t8 to date:
http://reality.sgi.com/chongo/tech/comp/fnv/index.html http://reality.sgi.com/chongo/tech/comp/fnv/index.html
Removed an unused argument in the function getbody() in codegen.c.
Encountering of EOF in getbody() will cause a scanerror rather then
stop activity. This will now result in a scanerror:
echo 'define f(x) { ' > myfile
calc -i read myfile
A '{' at the start of a command and a later matching '}' surrounding zero
or more statements (and possibly newlines) results in a function body to
be "evaluated". This permits another command to follow on the same
line as the '}' as in:
{display(5)} read something;
and:
{static a = 5} define f(x) = a + x;
String constants can now be concatenated. For exmaple:
s = "curds" ' and ' "whey";
Following is the change from calc version 2.11.0t7 to 2.11.0t7.5: Following is the change from calc version 2.11.0t7 to 2.11.0t7.5:

View File

@@ -31,7 +31,7 @@ static void getshowstatement(void);
static void getfunction(void); static void getfunction(void);
static void ungetfunction(void); static void ungetfunction(void);
static void getbody(LABEL *contlabel, LABEL *breaklabel, static void getbody(LABEL *contlabel, LABEL *breaklabel,
LABEL *nextcaselabel, LABEL *defaultlabel, BOOL toplevel); LABEL *nextcaselabel, LABEL *defaultlabel);
static void getdeclarations(int symtype); static void getdeclarations(int symtype);
static void getsimpledeclaration (int symtype); static void getsimpledeclaration (int symtype);
static int getonevariable (int symtype); static int getonevariable (int symtype);
@@ -190,22 +190,26 @@ evaluate(BOOL nestflag)
funcname = (nestflag ? "**" : "*"); funcname = (nestflag ? "**" : "*");
beginfunc(funcname, nestflag); beginfunc(funcname, nestflag);
if (nestflag) if (gettoken() == T_LEFTBRACE) {
(void) tokenmode(TM_DEFAULT); getbody(NULL_LABEL, NULL_LABEL, NULL_LABEL, NULL_LABEL);
while (loop) { } else {
switch (gettoken()) { if (nestflag)
case T_SEMICOLON: (void) tokenmode(TM_DEFAULT);
break; rescantoken();
while (loop) {
switch (gettoken()) {
case T_SEMICOLON:
break;
case T_NEWLINE:
case T_EOF:
loop = 0;
break;
case T_NEWLINE: default:
case T_EOF: rescantoken();
loop = 0; getstatement(NULL_LABEL, NULL_LABEL,
break; NULL_LABEL, NULL_LABEL);
}
default:
rescantoken();
getstatement(NULL_LABEL, NULL_LABEL,
NULL_LABEL, NULL_LABEL);
} }
} }
addop(OP_UNDEF); addop(OP_UNDEF);
@@ -322,13 +326,11 @@ getfunction(void)
} }
switch (gettoken()) { switch (gettoken()) {
case T_ASSIGN: case T_ASSIGN:
rescantoken();
getsimplebody(); getsimplebody();
break; break;
case T_LEFTBRACE: case T_LEFTBRACE:
rescantoken();
getbody(NULL_LABEL, NULL_LABEL, NULL_LABEL, getbody(NULL_LABEL, NULL_LABEL, NULL_LABEL,
NULL_LABEL, TRUE); NULL_LABEL);
break; break;
default: default:
scanerror(T_NULL, scanerror(T_NULL,
@@ -347,11 +349,6 @@ getfunction(void)
static void static void
getsimplebody(void) getsimplebody(void)
{ {
if (gettoken() != T_ASSIGN) {
scanerror(T_SEMICOLON,
"Missing equals for simple function body");
return;
}
(void) tokenmode(TM_NEWLINES); (void) tokenmode(TM_NEWLINES);
(void) getexprlist(); (void) getexprlist();
addop(OP_RETURN); addop(OP_RETURN);
@@ -365,14 +362,10 @@ getsimplebody(void)
*/ */
/*ARGSUSED*/ /*ARGSUSED*/
static void static void
getbody(LABEL *contlabel, LABEL *breaklabel, LABEL *nextcaselabel, LABEL *defaultlabel, BOOL toplevel) getbody(LABEL *contlabel, LABEL *breaklabel, LABEL *nextcaselabel, LABEL *defaultlabel)
{ {
int oldmode; int oldmode;
if (gettoken() != T_LEFTBRACE) {
scanerror(T_SEMICOLON, "Missing left brace for function body");
return;
}
oldmode = tokenmode(TM_DEFAULT); oldmode = tokenmode(TM_DEFAULT);
while (TRUE) { while (TRUE) {
switch (gettoken()) { switch (gettoken()) {
@@ -380,6 +373,10 @@ getbody(LABEL *contlabel, LABEL *breaklabel, LABEL *nextcaselabel, LABEL *defaul
(void) tokenmode(oldmode); (void) tokenmode(oldmode);
return; return;
case T_EOF:
scanerror(T_SEMICOLON, "End-of-file in function body");
return;
default: default:
rescantoken(); rescantoken();
getstatement(contlabel, breaklabel, nextcaselabel, defaultlabel); getstatement(contlabel, breaklabel, nextcaselabel, defaultlabel);
@@ -595,8 +592,7 @@ getstatement(LABEL *contlabel, LABEL *breaklabel, LABEL *nextcaselabel, LABEL *d
break; break;
case T_LEFTBRACE: case T_LEFTBRACE:
rescantoken(); getbody(contlabel, breaklabel, nextcaselabel, defaultlabel);
getbody(contlabel, breaklabel, nextcaselabel, defaultlabel, FALSE);
return; return;
case T_IF: case T_IF:

View File

@@ -6861,7 +6861,7 @@ print '181: parsed test_ptr()';
*/ */
define test_newstring() define test_newstring()
{ {
local A, B, C, D, S, p; local A, B, C, D, S, p, q;
print '7700: Beginning test_newstring'; print '7700: Beginning test_newstring';
@@ -6953,7 +6953,14 @@ define test_newstring()
print '7762: setbit(A, 16, 0);'; print '7762: setbit(A, 16, 0);';
vrfy(A == "A\255fdef", '7763: A == "A\255fdef"'); vrfy(A == "A\255fdef", '7763: A == "A\255fdef"');
print '7764: Ending test_newstring'; q = "curds" " and " "whey";
print '7764: q = "curds" " and " "whey"';
vrfy(q == "curds and whey", '7765: q == "curds and whey"');
q = "chongo" ' was ' "here";
print '7766: q = "chongo" \' was \' "here"';
vrfy(q == "chongo was here", '7767: q == "chongo was here"');
print '7768: Ending test_newstring';
} }
print '182: parsed test_newstring()'; print '182: parsed test_newstring()';
@@ -7201,16 +7208,27 @@ print '1700: Beginning read test';
value = 0; value = 0;
vrfy(value == 0, '1701: value == 0'); vrfy(value == 0, '1701: value == 0');
read "test1700"; read "test1700";
vrfy(value == 1, '1702: value == 1'); print '1702: read "test1700";';
read -once "test1700";
vrfy(value == 1, '1703: value == 1'); vrfy(value == 1, '1703: value == 1');
read -once "test1700";
print '1704: read -once "test1700";';
vrfy(value == 1, '1705: value == 1');
read "test1700.cal"; read "test1700.cal";
vrfy(value == 2, '1704: value == 2'); print '1706: read "test1700.cal";';
vrfy(value == 2, '1707: value == 2');
read -once "test1700.cal"; read -once "test1700.cal";
vrfy(value == 2, '1705: value == 2'); print '1708: read -once "test1700.cal";';
vrfy(value == 2, '1709: value == 2');
read "test1700.cal"; read "test1700.cal";
vrfy(value == 3, '1706: value == 3'); print '1710: read "test1700.cal";';
print '1707: Ending read test'; vrfy(value == 3, '1711: value == 3');
{++value;} read "test1700.cal";
print '1712: {++value;} read "test1700.cal";';
vrfy(value == 5, '1713: value == 5');
{++value;} read -once "test1700.cal";
print '1714: {++value;} read -once "test1700.cal";';
vrfy(value == 6, '1715: value == 6');
print '1716: Ending read test';
print; print;
return test_obj(); return test_obj();
@@ -7285,6 +7303,9 @@ print;
return test_size(); return test_size();
print; print;
/*
* 5800 assignment tests
*/
return test_assign(5800, 1); return test_assign(5800, 1);
define xy5800_assign(a,b) { }; define xy5800_assign(a,b) { };
print '5812: define xy5800_assign(a,b) { }'; print '5812: define xy5800_assign(a,b) { }';
@@ -7329,7 +7350,7 @@ X5800 = obj xy5800 = {1,2};
print '5864: X5800 = obj xy5800 = {1,2}'; print '5864: X5800 = obj xy5800 = {1,2}';
vrfy(X5800 == (obj xy5800 = {1,2}), vrfy(X5800 == (obj xy5800 = {1,2}),
'5865: X5800 == (obj xy5800 = {1,2})'); '5865: X5800 == (obj xy5800 = {1,2})');
print '5899: End of 5800 sequence'; print '5866: End of 5800 sequence';
print; print;
return test_is(); return test_is();
@@ -7413,7 +7434,10 @@ print '8304: define h8300(x)=x^3;define i8300(x)=x-1;define j8300(x)=x+1;';
vrfy(h8300(10) == 1000, '8305: h8300(10) == 1000'); vrfy(h8300(10) == 1000, '8305: h8300(10) == 1000');
vrfy(i8300(10) == 9, '8306: i8300(10) == 9'); vrfy(i8300(10) == 9, '8306: i8300(10) == 9');
vrfy(j8300(10) == 11, '8307: j8300(10) == 11'); vrfy(j8300(10) == 11, '8307: j8300(10) == 11');
print '8308: Ending define tests'; {static k8300 = 5} define l8300(x) = k8300 + x;
print '8308: {static k8300 = 5} define l8300(x) = k8300 + x;';
vrfy(l8300(10) == 15, '8309: l8300(10) == 15');
print '8310: Ending define tests';
/* /*

12
token.c
View File

@@ -438,6 +438,18 @@ eatstring(int quotechar)
case '"': case '"':
case '\'': case '\'':
if (ch == quotechar) { if (ch == quotechar) {
for (;;) {
ch = nextchar();
if (ch != ' ' && ch != '\t' &&
(ch != '\n' ||
newlines))
break;
}
if (ch == '"' || ch == '\'') {
quotechar = ch;
continue;
}
reread();
done = TRUE; done = TRUE;
ch = '\0'; ch = '\0';
} }

View File

@@ -12,7 +12,7 @@
#define MAJOR_VER 2 /* major version */ #define MAJOR_VER 2 /* major version */
#define MINOR_VER 11 /* minor version */ #define MINOR_VER 11 /* minor version */
#define MAJOR_PATCH 0 /* patch level or 0 if no patch */ #define MAJOR_PATCH 0 /* patch level or 0 if no patch */
#define MINOR_PATCH "8.3" /* test number or empty string if no patch */ #define MINOR_PATCH "8.4" /* test number or empty string if no patch */
/* /*
* calc version constants * calc version constants