several fixes for new basic compiler

This commit is contained in:
ceriel 1988-07-01 17:30:06 +00:00
parent c2af3d7faa
commit 5157a5a186
5 changed files with 35 additions and 13 deletions

View file

@ -5,3 +5,8 @@ int nr;
{
exit(nr);
}
_goto_err()
{
error(3);
}

View file

@ -14,6 +14,11 @@ String *_hex(i)
int i;
{
char buffer[30];
register char *p = buffer;
sprintf(buffer,"%x",i);
while (*p) {
if (*p >= 'a' && *p <= 'f') *p += 'A'-'a';
p++;
}
return( (String *)_newstr(buffer));
}

View file

@ -3,23 +3,25 @@
_randomi()
{
int i;
double f;
_setchan(-1);
printf("Random number seed (-32768 to 32767) ? ");
_readint(&i);
f=i;
_setrand(f);
_setrand(i);
}
_setrand(f)
double f;
{
_setrand(i)
int i;
i=f;
{
srand(i);
}
double _rnd(d) double d;
{
double f; f= (int) rand();
return(f/32767.0);
return(f/
#if EM_WSIZE == 4
2147483647.0
#else
32767.0
#endif
);
}

View file

@ -7,3 +7,10 @@ double v;
if( v<0) return(-1);
return(0);
}
_forsgn(v)
double v;
{
if (v >= 0) return 1;
return -1;
}

View file

@ -64,8 +64,9 @@ String *s1,*s2;
int length;
okr(s1); okr(s2);
s= (String *) salloc(sizeof(String));
length= _len(s1)+_len(s2)+1;
s->strval= salloc(length);
s->strlength= _len(s1)+_len(s2);
s->strval= salloc(s->strlength+1);
s->strcount = 1;
strcpy(s->strval,s2->strval);
strcat(s->strval,s1->strval);
return(s);
@ -116,7 +117,7 @@ int d;
String *_strascii()
{
}
String *_string(d,f)
String *_string(f, d)
double d,f;
{
int i,j;
@ -139,9 +140,10 @@ String *s, *s2;
{
int l;
/* printf("mid called %d %d %s %s\n",i1,i2,s->strval, s2->strval);*/
/*printf("mid called %d %d %s %s\n",i1,i2,s->strval, s2->strval);*/
if (i2 < 0 || i1 < -1) error(3);
if( s->strlength<i2 || s->strlength < i1+i2) error(3); /* source string too short */
if( i1== -1) i1= s2->strlength;
if( s->strlength<i2) error(3); /* source string too short */
l= s->strlength - i2+1;
if( i1>l ) i1=l;
strncpy(s->strval+i2-1,s2->strval,i1);
@ -154,6 +156,7 @@ String *s;
String *s2;
/* printf("mid fcn called %d %d %s\n",i1,i2,s->strval);*/
if (i2 < 0 || i1 < -1) return(s2); /* or error? */
if( i1 == -1) i1= s->strlength;
s2= _newstr(s->strval);
s2->strval[0]=0;