"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "statement.c" between
bas-2.5.tar.gz and bas-2.6.tar.gz

About: bas is an interpreter for the programming language BASIC.

statement.c  (bas-2.5):statement.c  (bas-2.6)
skipping to change at line 657 skipping to change at line 657
{ {
{ "Xemacs", "+%ld " }, { "Xemacs", "+%ld " },
{ "cemacs", "+%ld " }, { "cemacs", "+%ld " },
{ "emacs", "+%ld " }, { "emacs", "+%ld " },
{ "emori", "-l%ld " }, { "emori", "-l%ld " },
{ "fe", "-l%ld " }, { "fe", "-l%ld " },
{ "jed", "+%ld " }, { "jed", "+%ld " },
{ "jmacs", "+%ld " }, { "jmacs", "+%ld " },
{ "joe", "+%ld " }, { "joe", "+%ld " },
{ "modeori", "-l%ld " }, { "modeori", "-l%ld " },
{ "nano", "+%ld " },
{ "origami", "-l%ld " }, { "origami", "-l%ld " },
{ "vi", "-c%ld " }, { "vi", "-c%ld " },
{ "vim", "+%ld " }, { "vim", "+%ld " },
{ "xemacs", "+%ld " } { "xemacs", "+%ld " }
}; };
unsigned int i; unsigned int i;
pid_t pid; pid_t pid;
/*}}}*/ /*}}}*/
if (!DIRECTMODE) if (!DIRECTMODE)
skipping to change at line 1080 skipping to change at line 1081
return Value_new_ERROR(value,TYPEMISMATCH4); return Value_new_ERROR(value,TYPEMISMATCH4);
} }
if (pass==INTERPRET) FS_field(chn,&l->u.string,offset,width); if (pass==INTERPRET) FS_field(chn,&l->u.string,offset,width);
offset+=width; offset+=width;
if (pc.token->type==T_COMMA) ++pc.token; if (pc.token->type==T_COMMA) ++pc.token;
else break; else break;
} }
return (struct Value*)0; return (struct Value*)0;
} }
/*}}}*/ /*}}}*/
struct Value *stmt_FILES(struct Value *value) /*{{{*/
{
struct Pc curpc;
pid_t pid;
int status;
++pc.token;
curpc=pc;
if (eval(value,_("file specification"))->type==V_ERROR || Value_retype(value,V
_STRING)->type==V_ERROR)
{
Value_destroy(value);
Value_new_STRING(value);
pc=curpc;
}
if (pass==INTERPRET)
{
String_quote(&value->u.string);
String_insertChar(&value->u.string, 0, 'l');
String_insertChar(&value->u.string, 1, 's');
String_insertChar(&value->u.string, 2, ' ');
String_insertChar(&value->u.string, 3, '-');
String_insertChar(&value->u.string, 4, 'l');
String_insertChar(&value->u.string, 5, ' ');
FS_shellmode(STDCHANNEL);
switch (pid=fork())
{
case -1:
{
FS_fsmode(STDCHANNEL);
Value_destroy(value);
return Value_new_ERROR(value,FORKFAILED,strerror(errno));
}
case 0:
{
execl("/bin/sh","sh","-c",value->u.string.character,(const char*)0);
exit(127);
}
default:
{
while (waitpid(pid,&status,0)==-1 && errno!=EINTR);
}
}
FS_fsmode(STDCHANNEL);
}
Value_destroy(value);
return (struct Value*)0;
}
/*}}}*/
struct Value *stmt_FOR(struct Value *value) /*{{{*/ struct Value *stmt_FOR(struct Value *value) /*{{{*/
{ {
struct Pc forpc=pc; struct Pc forpc=pc;
struct Pc varpc; struct Pc varpc;
struct Pc limitpc; struct Pc limitpc;
struct Value limit,stepValue; struct Value limit,stepValue;
++pc.token; ++pc.token;
varpc=pc; varpc=pc;
if (pc.token->type!=T_IDENTIFIER) return Value_new_ERROR(value,MISSINGLOOPIDEN T); if (pc.token->type!=T_IDENTIFIER) return Value_new_ERROR(value,MISSINGLOOPIDEN T);
skipping to change at line 1103 skipping to change at line 1152
++pc.token; ++pc.token;
if (eval(&limit,(const char*)0)->type==V_ERROR) if (eval(&limit,(const char*)0)->type==V_ERROR)
{ {
*value=limit; *value=limit;
return value; return value;
} }
Value_retype(&limit,value->type); Value_retype(&limit,value->type);
assert(limit.type!=V_ERROR); assert(limit.type!=V_ERROR);
if (pc.token->type==T_STEP) /* STEP x */ /*{{{*/ if (pc.token->type==T_STEP) /* STEP x */ /*{{{*/
{ {
struct Pc stepPc; struct Pc stepPc,stepValuePc;
++pc.token;
stepPc=pc; stepPc=pc;
++pc.token;
stepValuePc=pc;
if (eval(&stepValue,"`step'")->type==V_ERROR) if (eval(&stepValue,"`step'")->type==V_ERROR)
{ {
Value_destroy(value); Value_destroy(value);
*value=stepValue; *value=stepValue;
pc=stepPc; pc=stepValuePc;
return value; return value;
} }
Value_retype(&stepValue,value->type); Value_retype(&stepValue,value->type);
assert(stepValue.type!=V_ERROR); assert(stepValue.type!=V_ERROR);
Value_destroy(&stepPc.token->u.step);
Value_clone(&stepPc.token->u.step,&stepValue);
} }
/*}}}*/ /*}}}*/
else /* implicit numeric STEP */ /*{{{*/ else /* implicit numeric STEP */ /*{{{*/
{ {
if (value->type==V_INTEGER) VALUE_NEW_INTEGER(&stepValue,1); if (value->type==V_INTEGER) VALUE_NEW_INTEGER(&stepValue,1);
else VALUE_NEW_REAL(&stepValue,1.0); else VALUE_NEW_REAL(&stepValue,1.0);
} }
/*}}}*/ /*}}}*/
if (Value_exitFor(value,&limit,&stepValue)) pc=forpc.token->u.exitfor; if (Value_exitFor(value,&limit,&stepValue)) pc=forpc.token->u.exitfor;
Value_destroy(&limit); Value_destroy(&limit);
skipping to change at line 2056 skipping to change at line 2108
if (evalGeometry(value,&dim,geometry)) return value; if (evalGeometry(value,&dim,geometry)) return value;
if (pass==INTERPRET) if (pass==INTERPRET)
{ {
Var_destroy(var1); Var_destroy(var1);
Var_new(var1,vartype,dim,geometry,optionbase); Var_new(var1,vartype,dim,geometry,optionbase);
} }
} }
if (pass==INTERPRET) if (pass==INTERPRET)
{ {
unsigned int i; unsigned int i;
int unused=1-var1->base; unsigned int unused=1-var1->base;
if ((var1->dim!=1 && var1->dim!=2) || var1->base<0 || var1->base>1) return Value_new_ERROR(value,NOMATRIX,var1->dim,var1->base); if ((var1->dim!=1 && var1->dim!=2) || var1->base<0 || var1->base>1) return Value_new_ERROR(value,NOMATRIX,var1->dim,var1->base);
if (var1->dim==1) if (var1->dim==1)
{ {
for (i=unused; i<var1->geometry[0]; ++i) for (i=unused; i<var1->geometry[0]; ++i)
{ {
int c=-1; int c=-1;
Value_destroy(&(var1->value[i])); Value_destroy(&(var1->value[i]));
switch (op) switch (op)
skipping to change at line 2079 skipping to change at line 2131
case T_ZER: c=0; break; case T_ZER: c=0; break;
case T_IDN: c=(i==unused?1:0); break; case T_IDN: c=(i==unused?1:0); break;
default: assert(0); default: assert(0);
} }
if (var1->type==V_INTEGER) Value_new_INTEGER(&(var1->value[i]),c); if (var1->type==V_INTEGER) Value_new_INTEGER(&(var1->value[i]),c);
else Value_new_REAL(&(var1->value[i]),(double)c); else Value_new_REAL(&(var1->value[i]),(double)c);
} }
} }
else else
{ {
int j; unsigned int j;
for (i=unused; i<var1->geometry[0]; ++i) for (j=unused; j<var1->geometry [1]; ++j) for (i=unused; i<var1->geometry[0]; ++i) for (j=unused; j<var1->geometry [1]; ++j)
{ {
int c=-1; int c=-1;
Value_destroy(&(var1->value[i*var1->geometry[1]+j])); Value_destroy(&(var1->value[i*var1->geometry[1]+j]));
switch (op) switch (op)
{ {
case T_CON: c=1; break; case T_CON: c=1; break;
case T_ZER: c=0; break; case T_ZER: c=0; break;
skipping to change at line 2181 skipping to change at line 2233
if (pass==INTERPRET) if (pass==INTERPRET)
{ {
Var_destroy(var); Var_destroy(var);
Var_new(var,vartype,dim,geometry,optionbase); Var_new(var,vartype,dim,geometry,optionbase);
} }
} }
if (pass==INTERPRET) if (pass==INTERPRET)
{ {
unsigned int i,j; unsigned int i,j;
int unused=1-var->base; int unused=1-var->base;
int columns; unsigned int columns;
struct Token *inputdata,*t; struct Token *inputdata,*t;
if (var->dim!=1 && var->dim!=2) return Value_new_ERROR(value,NOMATRIX,var- >dim); if (var->dim!=1 && var->dim!=2) return Value_new_ERROR(value,NOMATRIX,var- >dim);
columns=var->dim==1 ? 0 : var->geometry[1]; columns=var->dim==1 ? 0 : var->geometry[1];
inputdata=t=(struct Token*)0; inputdata=t=(struct Token*)0;
for (i=unused,j=unused; i<var->geometry[0]; ) for (i=unused,j=unused; i<var->geometry[0]; )
{ {
struct String s; struct String s;
if (!inputdata) if (!inputdata)
skipping to change at line 2328 skipping to change at line 2380
{ {
Value_destroy(&usingval); Value_destroy(&usingval);
return Value_new_ERROR(value,REDECLARATION); return Value_new_ERROR(value,REDECLARATION);
} }
var=&pc.token->u.identifier->sym->u.var; var=&pc.token->u.identifier->sym->u.var;
++pc.token; ++pc.token;
if (pc.token->type==T_SEMICOLON) zoned=0; if (pc.token->type==T_SEMICOLON) zoned=0;
if (pass==INTERPRET) if (pass==INTERPRET)
{ {
unsigned int i,j; unsigned int i,j;
int unused=1-var->base; unsigned int unused=1-var->base;
int g0,g1; unsigned int g0,g1;
if ((var->dim!=1 && var->dim!=2) || var->base<0 || var->base>1) return Val ue_new_ERROR(value,NOMATRIX,var->dim,var->base); if ((var->dim!=1 && var->dim!=2) || var->base<0 || var->base>1) return Val ue_new_ERROR(value,NOMATRIX,var->dim,var->base);
if ((notfirst ? FS_putChar(chn,'\n') : FS_nextline(chn))==-1) if ((notfirst ? FS_putChar(chn,'\n') : FS_nextline(chn))==-1)
{ {
Value_destroy(&usingval); Value_destroy(&usingval);
return Value_new_ERROR(value,IOERROR,FS_errmsg); return Value_new_ERROR(value,IOERROR,FS_errmsg);
} }
g0=var->geometry[0]; g0=var->geometry[0];
g1=var->dim==1 ? unused+1 : var->geometry[1]; g1=var->dim==1 ? unused+1 : var->geometry[1];
for (i=unused; i<g0; ++i) for (i=unused; i<g0; ++i)
skipping to change at line 2426 skipping to change at line 2478
{ {
if (dataread(value,&(var->value[i]))) if (dataread(value,&(var->value[i])))
{ {
pc=lvaluepc; pc=lvaluepc;
return value; return value;
} }
} }
} }
else else
{ {
int j; unsigned int j;
for (i=unused; i<var->geometry[0]; ++i) for (j=unused; j<var->geometry[1 ]; ++j) for (i=unused; i<var->geometry[0]; ++i) for (j=unused; j<var->geometry[1 ]; ++j)
{ {
if (dataread(value,&(var->value[i*var->geometry[1]+j]))) if (dataread(value,&(var->value[i*var->geometry[1]+j])))
{ {
pc=lvaluepc; pc=lvaluepc;
return value; return value;
} }
} }
} }
skipping to change at line 2504 skipping to change at line 2556
notfirst=1; notfirst=1;
if (pass==DECLARE && Global_variable(&globals,pc.token->u.identifier,pc.toke n->u.identifier->defaultType,GLOBALARRAY,0)==0) if (pass==DECLARE && Global_variable(&globals,pc.token->u.identifier,pc.toke n->u.identifier->defaultType,GLOBALARRAY,0)==0)
{ {
return Value_new_ERROR(value,REDECLARATION); return Value_new_ERROR(value,REDECLARATION);
} }
var=&pc.token->u.identifier->sym->u.var; var=&pc.token->u.identifier->sym->u.var;
++pc.token; ++pc.token;
if (pass==INTERPRET) if (pass==INTERPRET)
{ {
unsigned int i,j; unsigned int i,j;
int unused=1-var->base; unsigned int unused=1-var->base;
int g0,g1; unsigned int g0,g1;
if ((var->dim!=1 && var->dim!=2) || var->base<0 || var->base>1) return Val ue_new_ERROR(value,NOMATRIX,var->dim,var->base); if ((var->dim!=1 && var->dim!=2) || var->base<0 || var->base>1) return Val ue_new_ERROR(value,NOMATRIX,var->dim,var->base);
g0=var->geometry[0]; g0=var->geometry[0];
g1=var->dim==1 ? unused+1 : var->geometry[1]; g1=var->dim==1 ? unused+1 : var->geometry[1];
for (i=unused; i<g0; ++i) for (i=unused; i<g0; ++i)
{ {
comma=0; comma=0;
for (j=unused; j<g1; ++j) for (j=unused; j<g1; ++j)
{ {
struct String s; struct String s;
skipping to change at line 2615 skipping to change at line 2667
pc=savepc; pc=savepc;
/*}}}*/ /*}}}*/
/* get limit value and increment */ /*{{{*/ /* get limit value and increment */ /*{{{*/
savepc=pc; savepc=pc;
pc=(*next)[level].limit; pc=(*next)[level].limit;
if (eval(value,_("limit"))->type==V_ERROR) return value; if (eval(value,_("limit"))->type==V_ERROR) return value;
Value_retype(value,l->type); Value_retype(value,l->type);
assert(value->type!=V_ERROR); assert(value->type!=V_ERROR);
if (pc.token->type==T_STEP) if (pc.token->type==T_STEP)
{ {
++pc.token; Value_clone(&inc,&pc.token->u.step);
if (eval(&inc,_("step"))->type==V_ERROR)
{
Value_destroy(value);
*value=inc;
return value;
}
} }
else VALUE_NEW_INTEGER(&inc,1); else VALUE_NEW_INTEGER(&inc,1);
VALUE_RETYPE(&inc,l->type); VALUE_RETYPE(&inc,l->type);
assert(inc.type!=V_ERROR); assert(inc.type!=V_ERROR);
pc=savepc; pc=savepc;
/*}}}*/ /*}}}*/
Value_add(l,&inc,1); Value_add(l,&inc,1);
if (Value_exitFor(l,value,&inc)) if (Value_exitFor(l,value,&inc))
{ {
Value_destroy(value); Value_destroy(value);
 End of changes. 14 change blocks. 
18 lines changed or deleted 65 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)