1 eÿabs.c
\0\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0B
\ 1/* $Id: abs.c,v 2.4 1994/06/24 11:27:24 ceriel Exp $ */
4 * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
5 * See the copyright notice in the ACK home directory, in the file "Copyright".
12 double _abr(f) double f;
14 return( f>=0.0?f: -f);
16 asc.c
\0\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0²
\0#include "bc_string.h"
18 /* $Id: asc.c,v 2.4 1994/06/24 11:27:29 ceriel Exp $ */
23 if(str==0 || str->strval==0)
25 return( *str->strval);
27 asrt.c
\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0|
\0/* $Id: asrt.c,v 2.3 1994/06/24 11:27:33 ceriel Exp $ */
32 printf("ASSERTION ERROR\n");
36 atn.c
\0\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0*
\ 5/*
37 * (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
38 * See the copyright notice in the ACK home directory, in the file "Copyright".
40 * Author: Ceriel J.H. Jacobs
43 /* $Id: atn.c,v 2.7 1994/06/24 11:27:37 ceriel Exp $ */
52 /* Algorithm and coefficients from:
53 "Software manual for the elementary functions"
54 by W.J. Cody and W. Waite, Prentice-Hall, 1980
58 -0.13688768894191926929e+2,
59 -0.20505855195861651981e+2,
60 -0.84946240351320683534e+1,
61 -0.83758299368150059274e+0
64 0.41066306682575781263e+2,
65 0.86157349597130242515e+2,
66 0.59578436142597344465e+2,
67 0.15024001160028576121e+2,
72 0.52359877559829887307710723554658381, /* pi/6 */
74 1.04719755119659774615421446109316763 /* pi/3 */
90 if (x > 0.26794919243112270647) { /* 2-sqtr(3) */
92 x = (((0.73205080756887729353*x-0.5)-0.5)+x)/
93 (1.73205080756887729353+x);
96 /* ??? avoid underflow ??? */
99 x += x * g * POLYNOM3(g, p) / POLYNOM4(g, q);
104 chr.c
\0\0\0\0\0\0\0\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0Ú
\0#include "bc_string.h"
106 /* $Id: chr.c,v 2.5 1994/06/24 11:27:42 ceriel Exp $ */
121 conversion.c
\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0à
\ 1/* $Id: conversion.c,v 2.3 1994/06/24 11:27:47 ceriel Exp $ */
123 int _cint(f) double f;
126 if( f<-32768 || f>32767) error(4);
142 double _fcint(f) double f;
157 if( f<-32768.0 || f>32767.0) error(4);
158 r= _sgn(f) * _fcint((f>0.0? f : -f));
161 hlt.c
\0sion.c
\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0u
\0/* $Id: hlt.c,v 2.4 1994/06/24 11:28:11 ceriel Exp $ */
173 2mki.c
\0sion.c
\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0×
\ 1#include "bc_string.h"
175 /* $Id: mki.c,v 2.7 1994/06/24 11:28:26 ceriel Exp $ */
184 * ( (long *)s->strval ) = i ;
194 * ( (double *)s->strval ) = d ;
200 return *( (long *) s->strval) ;
205 return *( (double *) s->strval) ;
207 roct.c
\0sion.c
\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0\93\ 1#include "bc_string.h"
209 /* $Id: oct.c,v 2.6 1994/06/24 11:28:30 ceriel Exp $ */
215 sprintf(buffer,"%o",i);
216 return( (String *)_newstr(buffer));
224 sprintf(buffer,"%x",i);
225 return( (String *)_newstr(buffer));
234 return (String *) _newstr(buffer);
237 peek.c
\0ion.c
\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0l
\ 1/* $Id: peek.c,v 2.3 1994/06/24 11:28:34 ceriel Exp $ */
242 /* this can not work properly for machines in which the
243 POINTERSIZE differs from the integer size
251 printf("peek %d = %d\n",addr,i);
263 power.c
\0on.c
\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0Ã
\ 1/* $Id: power.c,v 2.3 1994/06/24 11:28:38 ceriel Exp $ */
270 double _log(), _exp();
288 temp = _exp(base * _log(-pownr));
293 return(_exp(base * _log(pownr)));
295 eexp.c
\0c
\0on.c
\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0Ú
\ 6/*
296 * (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
297 * See the copyright notice in the ACK home directory, in the file "Copyright".
299 * Author: Ceriel J.H. Jacobs
302 /* $Id: exp.c,v 2.7 1994/06/24 11:27:56 ceriel Exp $ */
312 extern double _fef();
320 fl = _fef(fl,&currexp);
324 fl *= (double) (1L << 30);
327 fl *= (double) (1L << exp);
331 fl /= (double) (1L << 30);
334 fl /= (double) (1L << -exp);
343 /* Algorithm and coefficients from:
344 "Software manual for the elementary functions"
345 by W.J. Cody and W. Waite, Prentice-Hall, 1980
348 static double p[] = {
349 0.25000000000000000000e+0,
350 0.75753180159422776666e-2,
351 0.31555192765684646356e-4
354 static double q[] = {
355 0.50000000000000000000e+0,
356 0.56817302698551221787e-1,
357 0.63121894374398503557e-3,
358 0.75104028399870046114e-6
362 int negative = x < 0;
364 if (x <= M_LN_MIN_D) {
367 if (x >= M_LN_MAX_D) {
368 if (x > M_LN_MAX_D) error(3);
371 if (negative) x = -x;
373 /* ??? avoid underflow ??? */
375 n = x * M_LOG2E + 0.5; /* 1/ln(2) = log2(e), 0.5 added for rounding */
378 double x1 = (long) x;
381 g = ((x1-xn*0.693359375)+x2) - xn*(-2.1219444005469058277e-4);
388 x = g * POLYNOM2(xn, p);
390 return (ldexp(0.5 + x/(POLYNOM3(xn, q) - x), n));
392 log.c
\0c
\0on.c
\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0t
\ 4/*
393 * (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
394 * See the copyright notice in the ACK home directory, in the file "Copyright".
396 * Author: Ceriel J.H. Jacobs
399 /* $Id: log.c,v 2.6 1994/06/24 11:28:20 ceriel Exp $ */
408 /* Algorithm and coefficients from:
409 "Software manual for the elementary functions"
410 by W.J. Cody and W. Waite, Prentice-Hall, 1980
412 static double a[] = {
413 -0.64124943423745581147e2,
414 0.16383943563021534222e2,
415 -0.78956112887491257267e0
417 static double b[] = {
418 -0.76949932108494879777e3,
419 0.31203222091924532844e3,
420 -0.35667977739034646171e2,
424 extern double _fef();
425 double znum, zden, z, w;
433 x = _fef(x, &exponent);
435 znum = (x - 0.5) - 0.5;
436 zden = x * 0.5 + 0.5;
440 zden = znum * 0.5 + 0.5;
443 z = znum/zden; w = z * z;
444 x = z + z * w * (POLYNOM2(w,a)/POLYNOM3(w,b));
446 x += z * (-2.121944400546905827679e-4);
447 return x + z * 0.693359375;
449 print.c
\0on.c
\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0b
\ 4#include "bc_string.h"
452 /* $Id: print.c,v 2.6 1994/06/24 11:28:42 ceriel Exp $ */
454 /* Here all routine to generate terminal oriented output is located */
458 /* prompt for terminal input */
474 sprintf(buffer," %d ",i);
475 else sprintf(buffer,"-%d ",-i);
482 register char *c = buffer;
487 sprintf(buffer," %e",f);
489 else sprintf(buffer," %f",f);
494 sprintf(buffer,"-%e",-f);
496 else sprintf(buffer,"-%f",-f);
499 for( ; *c && *c!= ' ';c++) ;
501 while( c>buffer && *c== '0')
511 /* BASIC strings trailing zeroes */
525 if( str==0) _out("<null>");
526 else _out(str->strval);
528 io.c
\0.c
\0on.c
\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0Ã
\ 5#include "bc_io.h"
531 /* $Id: io.c,v 2.5 1994/06/24 11:28:16 ceriel Exp $ */
533 struct sgttyb _ttydef;
535 /* BASIC has some nasty io characteristics */
539 int _width = 75, _pos=0, _zonewidth=15;
546 if( _chann== -1) pos= _pos;
547 else pos= _fdtable[_chann].pos;
550 if( pos>= _width){ _outnl(); pos=0;}
551 fputc(*str++, _chanwr);
554 if( _chann== -1) _pos=pos;
555 else _fdtable[_chann].pos= pos;
564 _fdtable[_chann].pos=0;
568 /* go to next zone */
572 else pos= _fdtable[_chann].pos;
582 } while( pos % _zonewidth != 0);
583 if( _chann== -1) _pos=pos;
584 else _fdtable[_chann].pos= pos;
589 register int holder ;
596 _ttydef.sg_flags &= ~ECHO;
598 }else pos= _fdtable[_chann].pos;
600 while( (holder = fgetc(_chanrd)) != EOF && holder != '\n'){
602 if( _chann == -1) putchar(holder);
609 _ttydef.sg_flags |= ECHO;
611 } else _fdtable[_chann].pos= pos;
616 if( x> _width) error(3);
617 if( x< _pos) _outnl();
623 while(x-->0) _out(" ");
625 orandom.c
\0n.c
\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0\91\ 1/* $Id: random.c,v 2.6 1994/06/24 11:28:45 ceriel Exp $ */
627 #if !defined(EM_WSIZE)
628 #define EM_WSIZE _EM_WSIZE
635 printf("Random number seed (-32768 to 32767) ? ");
645 double _rnd(d) double d;
647 double f; f= (int) rand();
656 aread.c
\0c
\0n.c
\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\08
\v#include "bc_string.h"
660 /* $Id: read.c,v 2.6 1994/06/24 11:28:49 ceriel Exp $ */
665 while( (c=fgetc(_chanrd)) != EOF && c!= '\n')
673 printf("readskip\n");
675 while( (c=fgetc(_chanrd)) != EOF && c!= ',' && c!= '\n')
685 printf("read int from %d\n",_chann);
688 if( fscanf(_chanrd,"%d",&i) != 1)
690 if( ferror(_chanrd)) error(29);
691 if( feof(_chanrd)) error(2);
694 _asschn(); /* may be closed by now */
695 fgets(buf,1024,_chanrd);
701 }else { readskip(); *addr=i;}
710 printf("read flt from %d\n",_chann);
713 if( fscanf(_chanrd,"%lf",&f) != 1)
715 if( ferror(_chanrd)) error(29);
716 if( feof(_chanrd)) error(2);
719 fgets(buf,1024,_chanrd);
725 }else { readskip(); *addr=f;}
735 printf("read str from %d\n",_chann);
740 while(isspace(kar) && kar!= EOF)
745 /* read quoted string */
747 printf("qouted string\n");
749 while ( (kar= fgetc(_chanrd)) != EOF && kar!='"' ) *c++ = kar ;
755 /* read normal string */
758 printf("non-qouted string\n");
760 while( (kar= fgetc(_chanrd)) != ',' && kar!= EOF &&
761 !isspace(kar) && kar!='\n')
766 if( ferror(_chanrd)) error(29);
767 if( feof(_chanrd)) error(2);
770 fgets(buffer,1024,_chanrd);
778 printf("string read: %s\n",buffer);
781 /* save value read */
783 *s= (String *) _newstr(buffer);
786 extern int _seektab[];
795 printf("seek to %d",line);
800 /* search number of lines to skip */
801 for(nr=0; _seektab[nr] && _seektab[nr]< line; nr+=2)
803 printf("test %d %d\n",_seektab[nr], _seektab[nr+1]);
808 printf(" %d lines to skip\n",nr);
810 while(nr-- >0 ) fgets(buffer,1024,_chanrd);
817 if( fgets(buffer,1024,_chanrd) == 0)
828 *s= (String *) _newstr(buffer);
830 return.c
\0n.c
\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0"
\ 2/* $Id: return.c,v 2.3 1994/06/24 11:28:54 ceriel Exp $ */
832 #define MAXNESTING 1000
834 int _gotable[MAXNESTING];
840 /* administer gosub */
842 printf("store %d in %d\n",x,topstk);
844 if( topstk== MAXNESTING) error(26);
850 /* make sure that a return label index is on top
853 printf("return to %d %d\n",_gotable[topstk-1],topstk-1);
855 if( topstk==0 || topstk==MAXNESTING)
857 return( _gotable[--topstk]);
859 sgn.c
\0.c
\0n.c
\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0Ã
\0/* $Id: sgn.c,v 2.4 1994/06/24 11:29:08 ceriel Exp $ */
872 if (v >= 0) return 1;
875 esin.c
\0.c
\0n.c
\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0ë
\ 6/*
876 * (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
877 * See the copyright notice in the ACK home directory, in the file "Copyright".
879 * Author: Ceriel J.H. Jacobs
882 /* $Id: sin.c,v 2.6 1994/06/24 11:29:12 ceriel Exp $ */
891 /* Algorithm and coefficients from:
892 "Software manual for the elementary functions"
893 by W.J. Cody and W. Waite, Prentice-Hall, 1980
896 static double r[] = {
897 -0.16666666666666665052e+0,
898 0.83333333333331650314e-2,
899 -0.19841269841201840457e-3,
900 0.27557319210152756119e-5,
901 -0.25052106798274584544e-7,
902 0.16058936490371589114e-9,
903 -0.76429178068910467734e-12,
904 0.27204790957888846175e-14
921 /* ??? avoid loss of significance, if y is too large, error ??? */
923 y = y * M_1_PI + 0.5;
925 /* Use extended precision to calculate reduced argument.
926 Here we used 12 bits of the mantissa for a1.
927 Also split x in integer part x1 and fraction part x2.
929 #define A1 3.1416015625
930 #define A2 -8.908910206761537356617e-6
933 extern double _fif();
936 if (_fif(y, 0.5, &x1)) neg = !neg;
937 if (cos_flag) y -= 0.5;
938 x2 = _fif(x, 1.0, &x1);
951 /* ??? avoid underflow ??? */
954 x += x * y * POLYNOM7(y, r);
978 return _sin(x)/_cos(x);
980 ifif.e
\0.c
\0n.c
\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0Ô
\ 1#
981 mes 2,EM_WSIZE,EM_PSIZE
983 ; $Id: fif.e,v 2.2 1994/06/24 11:28:04 ceriel Exp $
986 #define ARG2 EM_DSIZE
987 #define IRES 2*EM_DSIZE
989 ; _fif is called with three parameters:
990 ; - address of integer part result (IRES)
993 ; and returns an EM_DSIZE-byte floating point number
1005 sqt.c
\0.c
\0n.c
\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0\90\ 4/*
1006 * (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
1007 * See the copyright notice in the ACK home directory, in the file "Copyright".
1009 * Author: Ceriel J.H. Jacobs
1012 /* $Id: sqt.c,v 2.5 1994/06/24 11:29:15 ceriel Exp $ */
1024 extern double _fef();
1032 fl = _fef(fl,&currexp);
1036 fl *= (double) (1L << 30);
1039 fl *= (double) (1L << exp);
1043 fl /= (double) (1L << 30);
1046 fl /= (double) (1L << -exp);
1055 extern double _fef();
1060 if (x < 0) error(3);
1064 val = _fef(x, &exponent);
1069 val = ldexp(val + 1.0, exponent/2 - 1);
1070 /* was: val = (val + 1.0)/2.0; val = ldexp(val, exponent/2); */
1071 for (exponent = NITER - 1; exponent >= 0; exponent--) {
1072 val = (val + x / val) / 2.0;
1076 fef.e
\0.c
\0n.c
\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0±
\ 1#
1077 mes 2,EM_WSIZE,EM_PSIZE
1079 ; $Id: fef.e,v 2.2 1994/06/24 11:28:00 ceriel Exp $
1082 #define ERES EM_DSIZE
1084 ; _fef is called with two parameters:
1085 ; - address of exponent result (ERES)
1086 ; - floating point number to be split (FARG)
1087 ; and returns an EM_DSIZE-byte floating point number
1099 stop.c
\0c
\0n.c
\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0\96\0/* $Id: stop.c,v 2.3 1994/06/24 11:29:19 ceriel Exp $ */
1106 printf("Break in %d\n", _erlsym);
1109 string.c
\0n.c
\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0A
\f#include "bc_string.h"
1111 /* $Id: string.c,v 2.10 1996/11/26 15:02:36 ceriel Exp $ */
1113 #define ok(X) if( X ==0) return;
1114 #define okr(X) if( X ==0) return(0);
1116 extern char *salloc() ;
1122 return(str->strlength);
1124 String *_newstr(str)
1129 s= (String *) salloc(sizeof(String));
1131 s->strlength= strlen(str);
1132 s->strval= salloc(s->strlength+1);
1133 strcpy(s->strval,str);
1139 /* one more variable uses the string */
1147 /* Strings in ROM are initialized with this count */
1148 if ( str->strcount==9999 ) return ;
1150 if(str->strcount<=0) _delstr(str);
1168 String *_concat(s1,s2)
1174 s= (String *) salloc(sizeof(String));
1175 s->strlength= _length(s1)+_length(s2);
1176 s->strval= salloc(s->strlength+1);
1178 strcpy(s->strval,s2->strval);
1179 strcat(s->strval,s1->strval);
1186 return(strcmp(s2->strval,s1->strval));
1189 String *_left(size,s)
1197 if( size <0 || size >s->strlength) error(3);
1198 ns= (String *) salloc(sizeof(String));
1199 ns->strval= salloc(size+1);
1201 for(i=0; i<size && s->strval[i];i++)
1202 ns->strval[i]= s->strval[i];
1215 s= (String *) salloc(sizeof(String));
1218 s->strval= salloc(len+1);
1228 String *_string(f, d)
1235 if( i<0 || i>MAXSTRING) error(3);
1236 s= (String *) salloc(sizeof(String));
1239 s->strval= salloc(i+1);
1245 _midstmt(s2,i1,i2,s)
1251 /*printf("mid called %d %d %s %s\n",i1,i2,s->strval, s2->strval);*/
1252 if (i2 < 0 || i1 < -1) error(3);
1253 if( s->strlength<i2 || s2->strlength < i1) error(3); /* source string too short */
1254 if( i1== -1) i1= s2->strlength;
1255 l= s->strlength - i2+1;
1257 strncpy(s->strval+i2-1,s2->strval,i1);
1259 String *_mid(i1,i2,s)
1266 /* printf("mid fcn called %d %d %s\n",i1,i2,s->strval);*/
1267 if (i2 < 0 || i1 < -1) return(s2); /* or error? */
1268 if( i1 == -1) i1= s->strlength;
1269 s2= _newstr(s->strval);
1271 if( s->strlength<i2) return(s2); /* source string too short */
1272 l= s->strlength - i2+1;
1274 strncpy(s2->strval,s->strval+i2-1,i1);
1279 String *_right(length,str)
1286 i= _length(str)-length;
1288 s= _newstr(str->strval+i);
1291 \0salloc.c
\0n.c
\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0\16\ 1/* $Id: salloc.c,v 2.4 1994/06/24 11:29:00 ceriel Exp $ */
1293 extern char *malloc() ;
1295 char * salloc(length)
1301 for(s=c;s<c+length;s++) *s = 0;
1311 swap.c
\0c
\0n.c
\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0:
\ 1#include "bc_string.h"
1313 /* $Id: swap.c,v 2.5 1994/06/24 11:29:27 ceriel Exp $ */
1341 trace.c
\0\0n.c
\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0c
\0/* $Id: trace.c,v 2.4 1994/06/24 11:29:31 ceriel Exp $ */
1348 nwrite.c
\0\0n.c
\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0>
\ 2#include "bc_string.h"
1351 /* $Id: write.c,v 2.5 1994/06/24 11:29:42 ceriel Exp $ */
1353 /* assume that the channel has been set */
1357 if( fputc('\n',_chanwr) == EOF) error(29);
1361 if( fputc(',',_chanwr) == EOF) error(29);
1367 if( fputc(' ',_chanwr)==EOF) error(29);
1368 fprintf(_chanwr,"%d",i);
1369 if( ferror(_chanwr) ) error(29);
1374 fprintf(_chanwr,"%f",f);
1375 if( ferror(_chanwr) ) error(29);
1380 fprintf(_chanwr,"\"%s\"",s->strval);
1381 if( ferror(_chanwr) ) error(29);
1383 file.c
\0\0\0n.c
\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0Ö
\b#include "bc_string.h"
1387 /* $Id: file.c,v 2.6 1994/06/24 11:28:08 ceriel Exp $ */
1389 Filedesc _fdtable[16];
1390 /* BASIC file descriptor table */
1391 /* Channel assignment:
1400 FILE *_chanrd = stdin;
1401 FILE *_chanwr = stdout;
1407 printf("setchannel %d\n",index);
1417 if( index<0 || index>15)
1420 _chanrd= _chanwr= _fdtable[index].fd;
1426 printf("_asschn %d\n",_chann);
1428 if( _chann == -1) return;
1430 printf(" file %d\n", _fdtable[_chann].fd);
1432 if( _chann<0 || _chann>15)
1434 if( _fdtable[_chann].fd== 0)
1436 if( feof( _fdtable[_chann].fd))
1443 if( nr<1 || nr >15 || _fdtable[nr].fd==0) error(3);
1444 fclose(_fdtable[nr].fd);
1445 _fdtable[nr].fd=0; _fdtable[nr].fname=0;
1448 _opnchn(reclen,fname,mode)
1449 String *mode,*fname;
1452 /* channel has been set */
1457 printf("open %d %s %s \n",reclen,mode->strval,fname->strval);
1459 /* check for opened/closed file */
1460 if(_fdtable[_chann].fd)
1462 switch(*mode->strval)
1466 if( (f=fopen(fname->strval,"w")) == NULL)
1472 if( (f=fopen(fname->strval,"r")) == NULL)
1478 if( (f=fopen(fname->strval,"a")) == NULL)
1483 printf("file mode %s\n",mode->strval);
1486 _chanwr= _chanrd= _fdtable[_chann].fd= f;
1487 _fdtable[_chann].fname= fname->strval;
1488 _fdtable[_chann].reclength= reclen;
1489 _fdtable[_chann].mode= m;
1491 printf("file descr %d\n",f);
1500 if( channel<0 || channel >15) error(3);
1501 fd= _fdtable[channel].fd;
1505 if( feof(_fdtable[channel].fd) ) return(-1);
1512 /* close all open files */
1518 error.c
\0\0n.c
\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0]
\ 6/* $Id: error.c,v 2.3 1994/06/24 11:27:52 ceriel Exp $ */
1520 /* error takes an error value in the range of 0-255 */
1521 /* and generates a trap */
1523 char *errortable[255]={
1525 /* 1 */ "RETURN without GOSUB",
1526 /* 2 */ "Out of data",
1527 /* 3 */ "Illegal function call",
1529 /* 5 */ "Out of memory",
1530 /* 6 */ "Undefined line ",
1531 /* 7 */ "Subscript out of range",
1532 /* 8 */ "Redimensioned array",
1533 /* 9 */ "Division by zero",
1534 /* 10 */ "Illegal indirect",
1535 /* 11 */ "Type mismatch",
1536 /* 12 */ "Out of string space",
1537 /* 13 */ "String too long",
1538 /* 14 */ "String formula too complex",
1539 /* 15 */ "Can't continue",
1540 /* 16 */ "Undefined user function",
1541 /* 17 */ "No resume",
1542 /* 18 */ "Resume without error",
1543 /* 19 */ "Unprintable error",
1544 /* 20 */ "Missing operand",
1545 /* 21 */ "Line buffer overflow",
1546 /* 22 */ "FOR without NEXT",
1547 /* 23 */ "WHILE without WEND",
1548 /* 24 */ "WEND without WHILE",
1549 /* 25 */ "Field overflow",
1550 /* 26 */ "Internal error",
1551 /* 27 */ "Bad file number",
1552 /* 28 */ "File not found",
1553 /* 29 */ "Bad file mode",
1554 /* 30 */ "File already open",
1555 /* 31 */ "Disk IO error",
1556 /* 32 */ "File already exists",
1557 /* 33 */ "Disk full",
1558 /* 34 */ "Input past end",
1559 /* 35 */ "Bad record number",
1560 /* 36 */ "Bad file name",
1561 /* 37 */ "Direct statement in file",
1562 /* 38 */ "Too many files",
1563 /* 39 */ "File not open",
1564 /* 40 */ "Syntax error in data",
1575 if( index<0 || index >40 )
1576 printf("LINE %d:ERROR %d: Unprintable error\n",_erlsym,index);
1577 else printf("LINE %d:ERROR %d: %s\n",_erlsym,index,errortable[index]);
1581 8trap.c
\0\0\0n.c
\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0<
\ 3#include <signal.h>
1588 /* $Id: trap.c,v 2.5 1994/06/24 11:29:36 ceriel Exp $ */
1591 int _trpline; /* BASIC return label */
1597 /*debug printf("trap set to %d\n",nr);*/
1604 extern int _errsym,_erlsym;
1609 printf("LINE %d: FATAL ERROR: trap %d\n",_erlsym,i);
1611 printf("trap occurred %d return %d\n",i,_trpline);
1618 /* initialize trap routines */
1622 signal(i,_trpfatal);
1635 if( _trpline==0) exit(-1);
1637 _trpline=0; /* should be reset by user */
1639 longjmp(trpbuf,line);
1641 setline.e
\0.c
\0\0\0\0\0\0\ 2\ 2¤
\ 1\0\0É
\0#
1642 mes 2,EM_WSIZE,EM_PSIZE
1643 ; $Id: setline.e,v 2.2 1994/06/24 11:29:04 ceriel Exp $
1644 ; Save the line where the error occurred