Subversion Repositories wimsdev

Rev

Rev 8161 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8161 Rev 8195
Line 115... Line 115...
115
      }
115
      }
116
      if(p2>buf && !myisspace(p2[-1])) *p2++=' ';
116
      if(p2>buf && !myisspace(p2[-1])) *p2++=' ';
117
      *p2++=*p1;
117
      *p2++=*p1;
118
      if(p1[1] && !myisspace(p1[1])) *p2++=' ';
118
      if(p1[1] && !myisspace(p1[1])) *p2++=' ';
119
    }
119
    }
120
    if(p2>=buf+MAX_LINELEN) error("string_too_long");
120
    if(p2>=buf+MAX_LINELEN) sym_error("string_too_long");
121
    *p2=0;
121
    *p2=0;
122
    snprintf(p,MAX_LINELEN,"%s",buf);
122
    snprintf(p,MAX_LINELEN,"%s",buf);
123
}
123
}
124
 
124
 
125
void alphaonly(char *p)
125
void alphaonly(char *p)
Line 164... Line 164...
164
{
164
{
165
    char *pp;
165
    char *pp;
166
    if(*p=='[') {
166
    if(*p=='[') {
167
      pp=find_matching(p+1,']');
167
      pp=find_matching(p+1,']');
168
      if(pp!=NULL) return pp+1;
168
      if(pp!=NULL) return pp+1;
169
      else error("unmatched_parentheses %.20s",p);
169
      else sym_error("unmatched_parentheses %.20s",p);
170
    }
170
    }
171
    return find_word_end(p);
171
    return find_word_end(p);
172
}
172
}
173
 
173
 
174
#define find_atom_start(x) find_word_start(x)
174
#define find_atom_start(x) find_word_start(x)
Line 185... Line 185...
185
 
185
 
186
    if(dic[macrodic].len<=0) return;
186
    if(dic[macrodic].len<=0) return;
187
    repcnt=start=0; pt=p;
187
    repcnt=start=0; pt=p;
188
    recalc:
188
    recalc:
189
    repcnt++;
189
    repcnt++;
190
    if(repcnt>=MAX_BLOCKS) error("macro_level_overflow %.20s",p);
190
    if(repcnt>=MAX_BLOCKS) sym_error("macro_level_overflow %.20s",p);
191
    for(i=start, pp=find_atom_start(pt); i<MAX_BLOCKS && *pp; pp=next_atom(pp), i++)
191
    for(i=start, pp=find_atom_start(pt); i<MAX_BLOCKS && *pp; pp=next_atom(pp), i++)
192
      atoms[i]=pp;
192
      atoms[i]=pp;
193
    if(i>=MAX_BLOCKS-1) error("block_overflow %.20s",p);
193
    if(i>=MAX_BLOCKS-1) sym_error("block_overflow %.20s",p);
194
    atoms[i]=pp+strlen(pp);
194
    atoms[i]=pp+strlen(pp);
195
    for(k=0;k<i;k++) {
195
    for(k=0;k<i;k++) {
196
      pp=atoms[k]; switch(*pp) {
196
      pp=atoms[k]; switch(*pp) {
197
          case '[': {
197
          case '[': {
198
            pe=find_atom_end(pp); pp++;
198
            pe=find_atom_end(pp); pp++;
Line 206... Line 206...
206
                  atom2[m]=p2;
206
                  atom2[m]=p2;
207
                }
207
                }
208
                if(m==0) m=1;
208
                if(m==0) m=1;
209
                snprintf(tbuf,sizeof(tbuf),"%s",pp);
209
                snprintf(tbuf,sizeof(tbuf),"%s",pp);
210
                _translate(tbuf,macrodic);
210
                _translate(tbuf,macrodic);
211
                if(tbuf[0]==0) error("bad_macro %.50s",pp);
211
                if(tbuf[0]==0) sym_error("bad_macro %.50s",pp);
212
                for(p1=strchr(tbuf,'@'); p1; p1=strchr(p1,'@')) {
212
                for(p1=strchr(tbuf,'@'); p1; p1=strchr(p1,'@')) {
213
                  for(p2=p1+1;isdigit(*p2) || *p2=='-';p2++);
213
                  for(p2=p1+1;isdigit(*p2) || *p2=='-';p2++);
214
                  if(p2==p1+1 || p2>p1+6) error("syntax_error %.20s",p1);
214
                  if(p2==p1+1 || p2>p1+6) sym_error("syntax_error %.20s",p1);
215
                  memmove(vbuf,p1,p2-p1); vbuf[p2-p1]=0;
215
                  memmove(vbuf,p1,p2-p1); vbuf[p2-p1]=0;
216
                  n=atoi(vbuf+1);
216
                  n=atoi(vbuf+1);
217
                  if(n<=0 || n>m) error("wrong_parmcnt macro %.50s",pp);
217
                  if(n<=0 || n>m) sym_error("wrong_parmcnt macro %.50s",pp);
218
                  string_modify(tbuf,p1,p2,atom2[n-1]);
218
                  string_modify(tbuf,p1,p2,atom2[n-1]);
219
                }
219
                }
220
                n=strlen(tbuf); if(n<MAX_LINELEN) {
220
                n=strlen(tbuf); if(n<MAX_LINELEN) {
221
                  tbuf[n++]=' '; tbuf[n]=0;
221
                  tbuf[n++]=' '; tbuf[n]=0;
222
                }
222
                }
Line 225... Line 225...
225
            }
225
            }
226
            break;
226
            break;
227
          }
227
          }
228
          case '_': {
228
          case '_': {
229
            pe=find_word_end(pp);
229
            pe=find_word_end(pp);
230
            if(pe-pp>MAX_NAMELEN) error("name_too_long %.20s",pp);
230
            if(pe-pp>MAX_NAMELEN) sym_error("name_too_long %.20s",pp);
231
            memmove(tbuf,pp,pe-pp); tbuf[pe-pp]=0;
231
            memmove(tbuf,pp,pe-pp); tbuf[pe-pp]=0;
232
            _translate(tbuf,macrodic);
232
            _translate(tbuf,macrodic);
233
            if(tbuf[0]==0) break;
233
            if(tbuf[0]==0) break;
234
            pt1=pp; pt2=find_atom_end(pt1); min=k;
234
            pt1=pp; pt2=find_atom_end(pt1); min=k;
235
            for(p1=strchr(tbuf,'@'); p1; p1=strchr(p1,'@')) {
235
            for(p1=strchr(tbuf,'@'); p1; p1=strchr(p1,'@')) {
236
                for(p2=p1+1;isdigit(*p2) || *p2=='-';p2++);
236
                for(p2=p1+1;isdigit(*p2) || *p2=='-';p2++);
237
                if(p2==p1+1 || p2>p1+6) error("syntax_error %.20s",p1);
237
                if(p2==p1+1 || p2>p1+6) sym_error("syntax_error %.20s",p1);
238
                memmove(vbuf,p1,p2-p1); vbuf[p2-p1]=0;
238
                memmove(vbuf,p1,p2-p1); vbuf[p2-p1]=0;
239
                n=atoi(vbuf+1);
239
                n=atoi(vbuf+1);
240
                if(n<-4 || n==0 || n>4) error("bad_macro %.20s",atoms[k]);
240
                if(n<-4 || n==0 || n>4) sym_error("bad_macro %.20s",atoms[k]);
241
                n+=k;
241
                n+=k;
242
                if(n<0 || n>=i) error("bad_macro_position %.20s",atoms[k]);
242
                if(n<0 || n>=i) sym_error("bad_macro_position %.20s",atoms[k]);
243
                p3=find_atom_end(atoms[n]);
243
                p3=find_atom_end(atoms[n]);
244
                if(p3>pt2) pt2=p3;
244
                if(p3>pt2) pt2=p3;
245
                if(atoms[n]<pt1) {min=n;pt1=atoms[n];}
245
                if(atoms[n]<pt1) {min=n;pt1=atoms[n];}
246
                memmove(ttbuf,atoms[n],p3-atoms[n]); ttbuf[p3-atoms[n]]=' ';
246
                memmove(ttbuf,atoms[n],p3-atoms[n]); ttbuf[p3-atoms[n]]=' ';
247
                ttbuf[p3-atoms[n]+1]=0;
247
                ttbuf[p3-atoms[n]+1]=0;
Line 258... Line 258...
258
char *add2cp(char *p)
258
char *add2cp(char *p)
259
{
259
{
260
    char *pp, *p1, *p2, buf[MAX_LINELEN+1];
260
    char *pp, *p1, *p2, buf[MAX_LINELEN+1];
261
    int l;
261
    int l;
262
    snprintf(buf,sizeof(buf),"%s",p); strfold(buf); l=strlen(buf);
262
    snprintf(buf,sizeof(buf),"%s",p); strfold(buf); l=strlen(buf);
263
    if((cpnext-cpbuf)+l>=MAX_LINELEN) error("string_too_long");
263
    if((cpnext-cpbuf)+l>=MAX_LINELEN) sym_error("string_too_long");
264
    pp=cpnext; memmove(pp,buf,l+1); cpnext+=l+1;
264
    pp=cpnext; memmove(pp,buf,l+1); cpnext+=l+1;
265
    if(!noaddw) for(p1=find_word_start(buf); *p1; p1=find_word_start(p2)) {
265
    if(!noaddw) for(p1=find_word_start(buf); *p1; p1=find_word_start(p2)) {
266
      p2=find_word_end(p1); l=p2-p1;
266
      p2=find_word_end(p1); l=p2-p1;
267
      if(*p2) *p2++=0;
267
      if(*p2) *p2++=0;
268
      if(wordchr(wbuf,p1)!=NULL) continue;
268
      if(wordchr(wbuf,p1)!=NULL) continue;
Line 299... Line 299...
299
    l=0; p3=p; do {
299
    l=0; p3=p; do {
300
      p1=find_word_start(p3);
300
      p1=find_word_start(p3);
301
      if(*p1) l++;
301
      if(*p1) l++;
302
      p2=strparchr(p1,'[');
302
      p2=strparchr(p1,'[');
303
      if(p2!=NULL) p3=find_matching(p2+1,']');
303
      if(p2!=NULL) p3=find_matching(p2+1,']');
304
      if(p3==NULL) error("unmatched_parentheses %.20s",p);
304
      if(p3==NULL) sym_error("unmatched_parentheses %.20s",p);
305
      if(p2!=NULL && p2>p1) l++;
305
      if(p2!=NULL && p2>p1) l++;
306
      p3++;
306
      p3++;
307
    } while(p2!=NULL);
307
    } while(p2!=NULL);
308
    if(l==0) {
308
    if(l==0) {
309
      buf[0]=0; cp_string(buf,blk,next);
309
      buf[0]=0; cp_string(buf,blk,next);
310
      return;
310
      return;
311
    }
311
    }
312
    idx=start=nextblock; nextblock+=l-1; end=nextblock;
312
    idx=start=nextblock; nextblock+=l-1; end=nextblock;
313
    if(nextblock > MAX_BLOCKS) error("block_overflow %.20s",p);
313
    if(nextblock > MAX_BLOCKS) sym_error("block_overflow %.20s",p);
314
    for(p1=find_word_start(p); *p1; p1=find_word_start(p3)) {
314
    for(p1=find_word_start(p); *p1; p1=find_word_start(p3)) {
315
      p2=strparchr(p1,'[');
315
      p2=strparchr(p1,'[');
316
      if(p2==NULL) p2=p1+strlen(p1);
316
      if(p2==NULL) p2=p1+strlen(p1);
317
      ll=p2-p1;
317
      ll=p2-p1;
318
      if(ll>0) {
318
      if(ll>0) {
Line 353... Line 353...
353
    int i, t, idx;
353
    int i, t, idx;
354
    char buf[MAX_LINELEN+1];
354
    char buf[MAX_LINELEN+1];
355
    char *pp, *pe;
355
    char *pp, *pe;
356
 
356
 
357
    idx=nextblock; nextblock+=n;
357
    idx=nextblock; nextblock+=n;
358
    if(nextblock > MAX_BLOCKS) error("block_overflow %.20s",p);
358
    if(nextblock > MAX_BLOCKS) sym_error("block_overflow %.20s",p);
359
    blk->len=n;
359
    blk->len=n;
360
    blk->sublock=idx;
360
    blk->sublock=idx;
361
    blk->fn=mt_permpick;
361
    blk->fn=mt_permpick;
362
    blk->lcnt=clist.lcnt;
362
    blk->lcnt=clist.lcnt;
363
    blk->nextblock=next;
363
    blk->nextblock=next;
364
    if(nextlist+n > MAX_LISTS) error("list_overflow %.20s",p);
364
    if(nextlist+n > MAX_LISTS) sym_error("list_overflow %.20s",p);
365
    blk->listlen=listbuf+nextlist; nextlist+=n;
365
    blk->listlen=listbuf+nextlist; nextlist+=n;
366
    for(i=t=0; i<clist.lcnt; i++) {
366
    for(i=t=0; i<clist.lcnt; i++) {
367
      blk->listlen[i]=clist.listlen[i];
367
      blk->listlen[i]=clist.listlen[i];
368
      blk->lists[i]=listbuf+nextlist+t;
368
      blk->lists[i]=listbuf+nextlist+t;
369
      t+=clist.listlen[i];
369
      t+=clist.listlen[i];
370
    }
370
    }
371
    if(nextlist+t > MAX_LISTS) error("list_overflow %.20s",p);
371
    if(nextlist+t > MAX_LISTS) sym_error("list_overflow %.20s",p);
372
    memmove(listbuf+nextlist,clist.list,t*sizeof(listtype));
372
    memmove(listbuf+nextlist,clist.list,t*sizeof(listtype));
373
    nextlist+=t;
373
    nextlist+=t;
374
    for(i=0, pp=find_word_start(p);i<n;i++,idx++,pp=find_word_start(pe)) {
374
    for(i=0, pp=find_word_start(p);i<n;i++,idx++,pp=find_word_start(pe)) {
375
      pe=strparchr(pp,delim);
375
      pe=strparchr(pp,delim);
376
      if(pe==NULL) pe=pp+strlen(pp); else *pe++=0;
376
      if(pe==NULL) pe=pp+strlen(pp); else *pe++=0;
Line 405... Line 405...
405
{
405
{
406
    int i, n;
406
    int i, n;
407
    listtype ltab[MAX_BLOCKS];
407
    listtype ltab[MAX_BLOCKS];
408
    listtype len;
408
    listtype len;
409
 
409
 
410
    n=objnum(p,','); if(n<4) error("wrong_parmcnt ins %.20s",p);
410
    n=objnum(p,','); if(n<4) sym_error("wrong_parmcnt ins %.20s",p);
411
    if(n>=MAX_BLOCKS/2) error("block_overflow %.20s",p);
411
    if(n>=MAX_BLOCKS/2) sym_error("block_overflow %.20s",p);
412
    clist.lcnt=1; len=2*n-5; clist.listlen=&len;
412
    clist.lcnt=1; len=2*n-5; clist.listlen=&len;
413
    for(i=0;i<n-2;i++) ltab[2*i]=-2;
413
    for(i=0;i<n-2;i++) ltab[2*i]=-2;
414
    for(i=0;i<n-4;i++) ltab[2*i+1]=0;
414
    for(i=0;i<n-4;i++) ltab[2*i+1]=0;
415
    ltab[len-2]=1;
415
    ltab[len-2]=1;
416
    clist.list=ltab;
416
    clist.list=ltab;
Line 423... Line 423...
423
    int i, n, t;
423
    int i, n, t;
424
    char *p1;
424
    char *p1;
425
    listtype ltab[MAX_BLOCKS];
425
    listtype ltab[MAX_BLOCKS];
426
    listtype len;
426
    listtype len;
427
 
427
 
428
    n=objnum(p,','); if(n<4) error("wrong_parmcnt ins %.20s",p);
428
    n=objnum(p,','); if(n<4) sym_error("wrong_parmcnt ins %.20s",p);
429
    if(n>=MAX_BLOCKS/2) error("block_overflow %.20s",p);
429
    if(n>=MAX_BLOCKS/2) sym_error("block_overflow %.20s",p);
430
    p1=find_item_end(p); if(*p1) *p1++=0;
430
    p1=find_item_end(p); if(*p1) *p1++=0;
431
    t=atoi(p); if(t<=0 || t>n-3) error("syntax_error ins %.20s",p);
431
    t=atoi(p); if(t<=0 || t>n-3) sym_error("syntax_error ins %.20s",p);
432
    clist.lcnt=1; len=2*t-1; clist.listlen=&len;
432
    clist.lcnt=1; len=2*t-1; clist.listlen=&len;
433
    for(i=0;i<t;i++) ltab[2*i]=-2;
433
    for(i=0;i<t;i++) ltab[2*i]=-2;
434
    for(i=0;i<t-1;i++) ltab[2*i+1]=0;
434
    for(i=0;i<t-1;i++) ltab[2*i+1]=0;
435
    ltab[len-2]=1;
435
    ltab[len-2]=1;
436
    clist.list=ltab;
436
    clist.list=ltab;
Line 441... Line 441...
441
void cp_dic(char *p, struct block *blk, int next)
441
void cp_dic(char *p, struct block *blk, int next)
442
{
442
{
443
    int i, n;
443
    int i, n;
444
    char *p1, *p2;
444
    char *p1, *p2;
445
    n=objnum(p,',');
445
    n=objnum(p,',');
446
    if(n!=1) error("wrong_parmcnt dic %.20s",p);
446
    if(n!=1) sym_error("wrong_parmcnt dic %.20s",p);
447
    p1=find_word_start(p); p2=find_word_end(p1);
447
    p1=find_word_start(p); p2=find_word_end(p1);
448
    if(*p2) *p2++=0;
448
    if(*p2) *p2++=0;
449
    p2=find_word_start(p2);
449
    p2=find_word_start(p2);
450
    i=getdic(p1);
450
    i=getdic(p1);
451
    if(i<0) error("bad_dictionary %.20s",p1);
451
    if(i<0) sym_error("bad_dictionary %.20s",p1);
452
    noaddw=3;
452
    noaddw=3;
453
    blk->string=add2cp(p2);
453
    blk->string=add2cp(p2);
454
    noaddw=0;
454
    noaddw=0;
455
    blk->len=strlen(blk->string);
455
    blk->len=strlen(blk->string);
456
    blk->lind1=i;
456
    blk->lind1=i;
Line 464... Line 464...
464
    listtype ltab[]={0,1,2,2,3,0};
464
    listtype ltab[]={0,1,2,2,3,0};
465
    listtype len[]={3,3};
465
    listtype len[]={3,3};
466
 
466
 
467
    clist.lcnt=2; clist.listlen=len; clist.list=ltab;
467
    clist.lcnt=2; clist.listlen=len; clist.list=ltab;
468
    n=objnum(p,',');
468
    n=objnum(p,',');
469
    if(n!=4) error("wrong_parmcnt dperm %.20s",p);
469
    if(n!=4) sym_error("wrong_parmcnt dperm %.20s",p);
470
    _permpick(p,n,blk,blk-blockbuf,',');
470
    _permpick(p,n,blk,blk-blockbuf,',');
471
}
471
}
472
 
472
 
473
void cp_ins(char *p, struct block *blk, int next)
473
void cp_ins(char *p, struct block *blk, int next)
474
{
474
{
475
    int i, n;
475
    int i, n;
476
    listtype ltab[MAX_BLOCKS];
476
    listtype ltab[MAX_BLOCKS];
477
    listtype len;
477
    listtype len;
478
 
478
 
479
    n=objnum(p,','); if(n<3) error("wrong_parmcnt ins %.20s",p);
479
    n=objnum(p,','); if(n<3) sym_error("wrong_parmcnt ins %.20s",p);
480
    if(n>=MAX_BLOCKS/2) error("block_overflow %.20s",p);
480
    if(n>=MAX_BLOCKS/2) sym_error("block_overflow %.20s",p);
481
    clist.lcnt=1; len=2*n-2; clist.listlen=&len;
481
    clist.lcnt=1; len=2*n-2; clist.listlen=&len;
482
    for(i=1;i<n;i++) ltab[2*i-2]=i;
482
    for(i=1;i<n;i++) ltab[2*i-2]=i;
483
    for(i=1;i<len;i+=2) ltab[i]=-12;
483
    for(i=1;i<len;i+=2) ltab[i]=-12;
484
    ltab[len-1]=-13;
484
    ltab[len-1]=-13;
485
    clist.list=ltab;
485
    clist.list=ltab;
Line 493... Line 493...
493
    listtype ltab[]={0,1,2,2,1,0};
493
    listtype ltab[]={0,1,2,2,1,0};
494
    listtype len[]={3,3};
494
    listtype len[]={3,3};
495
 
495
 
496
    clist.lcnt=2; clist.listlen=len; clist.list=ltab;
496
    clist.lcnt=2; clist.listlen=len; clist.list=ltab;
497
    n=objnum(p,',');
497
    n=objnum(p,',');
498
    if(n!=3) error("wrong_parmcnt iperm %.20s",p);
498
    if(n!=3) sym_error("wrong_parmcnt iperm %.20s",p);
499
    _permpick(p,n,blk,blk-blockbuf,',');
499
    _permpick(p,n,blk,blk-blockbuf,',');
500
}
500
}
501
 
501
 
502
void cp_m(char *p, struct block *blk, int next)
502
void cp_m(char *p, struct block *blk, int next)
503
{
503
{
504
    int i, idx;
504
    int i, idx;
505
    char buf[MAX_LINELEN+1];
505
    char buf[MAX_LINELEN+1];
506
 
506
 
507
    i=objnum(p,','); if(i!=1) error("wrong_parmcnt m %.20s",p);
507
    i=objnum(p,','); if(i!=1) sym_error("wrong_parmcnt m %.20s",p);
508
    blk->fn=mt_m;
508
    blk->fn=mt_m;
509
    blk->string=NULL;
509
    blk->string=NULL;
510
    blk->len=1;
510
    blk->len=1;
511
    blk->nextblock=next;
511
    blk->nextblock=next;
512
    p=find_word_start(p);singlespace(p);strip_trailing_spaces(p);
512
    p=find_word_start(p);singlespace(p);strip_trailing_spaces(p);
513
    for(i=0;i<Mcnt && strcmp(p,Mind[i].Mptr)!=0;i++);
513
    for(i=0;i<Mcnt && strcmp(p,Mind[i].Mptr)!=0;i++);
514
    if(nextblock >= MAX_BLOCKS-2) error("block_overflow %.20s",p);
514
    if(nextblock >= MAX_BLOCKS-2) sym_error("block_overflow %.20s",p);
515
    if(i<Mcnt) blk->sublock=Mind[i].blkptr;
515
    if(i<Mcnt) blk->sublock=Mind[i].blkptr;
516
    else {
516
    else {
517
      i=strlen(p);
517
      i=strlen(p);
518
      if(Mnext-Mbuf+i >= MAX_LINELEN-1) error("Mbuf_overflow %.20s",p);
518
      if(Mnext-Mbuf+i >= MAX_LINELEN-1) sym_error("Mbuf_overflow %.20s",p);
519
      if(Mcnt >= MAX_BLOCKS) error("Mind_overflow %.20s",p);
519
      if(Mcnt >= MAX_BLOCKS) sym_error("Mind_overflow %.20s",p);
520
      Mind[Mcnt].Mptr=Mnext; Mind[Mcnt].blkptr=nextblock;
520
      Mind[Mcnt].Mptr=Mnext; Mind[Mcnt].blkptr=nextblock;
521
      Mcnt++;
521
      Mcnt++;
522
      memcpy(Mnext,p,i+1); Mnext+=i+1;
522
      memcpy(Mnext,p,i+1); Mnext+=i+1;
523
      idx=nextblock; blk->sublock=idx; nextblock++;
523
      idx=nextblock; blk->sublock=idx; nextblock++;
524
      snprintf(buf,sizeof(buf),"%s",p);
524
      snprintf(buf,sizeof(buf),"%s",p);
Line 530... Line 530...
530
void cp_neg(char *p, struct block *blk, int next)
530
void cp_neg(char *p, struct block *blk, int next)
531
{
531
{
532
    int n, idx;
532
    int n, idx;
533
    char buf[MAX_LINELEN+1];
533
    char buf[MAX_LINELEN+1];
534
    n=objnum(p,','); if(n==0) n=1;
534
    n=objnum(p,','); if(n==0) n=1;
535
    if(n>1) error("wrong_parmcnt neg %.20s",p);
535
    if(n>1) sym_error("wrong_parmcnt neg %.20s",p);
536
    blk->fn=mt_neg;
536
    blk->fn=mt_neg;
537
    blk->len=1;
537
    blk->len=1;
538
    blk->nextblock=next;
538
    blk->nextblock=next;
539
    if(nextblock >= MAX_BLOCKS) error("block_overflow %.20s",p);
539
    if(nextblock >= MAX_BLOCKS) sym_error("block_overflow %.20s",p);
540
    idx=nextblock; blk->sublock=idx; nextblock++;
540
    idx=nextblock; blk->sublock=idx; nextblock++;
541
    snprintf(buf,sizeof(buf),"%s",p);
541
    snprintf(buf,sizeof(buf),"%s",p);
542
    cp_cutline(buf,blockbuf+idx,blk-blockbuf);
542
    cp_cutline(buf,blockbuf+idx,blk-blockbuf);
543
}
543
}
544
 
544
 
Line 555... Line 555...
555
    listtype ltab[MAX_BLOCKS];
555
    listtype ltab[MAX_BLOCKS];
556
    listtype len;
556
    listtype len;
557
    char *p1;
557
    char *p1;
558
 
558
 
559
    n=objnum(p,','); n--;
559
    n=objnum(p,','); n--;
560
    if(n<2) error("wrong_parmcnt pick %.20s",p);
560
    if(n<2) sym_error("wrong_parmcnt pick %.20s",p);
561
    if(n>=MAX_BLOCKS) error("block_overflow %.20s",p);
561
    if(n>=MAX_BLOCKS) sym_error("block_overflow %.20s",p);
562
    p1=strparchr(p,','); *p1++=0;
562
    p1=strparchr(p,','); *p1++=0;
563
    p=find_word_start(p); v=0;
563
    p=find_word_start(p); v=0;
564
    if(*p=='-') {p++; type-=5;}
564
    if(*p=='-') {p++; type-=5;}
565
    else if(*p=='+') {v=2; p++;}
565
    else if(*p=='+') {v=2; p++;}
566
    t=atoi(p); if(t<1 || t>MAX_PICKS || t>n) error("bad_pickcnt %.20s",p);
566
    t=atoi(p); if(t<1 || t>MAX_PICKS || t>n) sym_error("bad_pickcnt %.20s",p);
567
    clist.lcnt=1; len=t+v; clist.listlen=&len;
567
    clist.lcnt=1; len=t+v; clist.listlen=&len;
568
    for(i=0;i<t;i++) ltab[i]=type;
568
    for(i=0;i<t;i++) ltab[i]=type;
569
    if(v) {ltab[i++]=-6; ltab[i]=-5;}
569
    if(v) {ltab[i++]=-6; ltab[i]=-5;}
570
    clist.list=ltab;
570
    clist.list=ltab;
571
    _permpick(p1,n,blk,blk-blockbuf,',');
571
    _permpick(p1,n,blk,blk-blockbuf,',');
Line 574... Line 574...
574
void cp_out(char *p, struct block *blk, int next)
574
void cp_out(char *p, struct block *blk, int next)
575
{
575
{
576
    char buf[MAX_LINELEN+1];
576
    char buf[MAX_LINELEN+1];
577
    char *p1;
577
    char *p1;
578
    int n, idx;
578
    int n, idx;
579
    n=objnum(p,','); if(n!=2) error("wrong_parmcnt out %.20s",p);
579
    n=objnum(p,','); if(n!=2) sym_error("wrong_parmcnt out %.20s",p);
580
    p1=strparchr(p,','); if(p1) *p1++=0; else p1=p+strlen(p);
580
    p1=strparchr(p,','); if(p1) *p1++=0; else p1=p+strlen(p);
581
    p=find_word_start(p); *find_word_end(p)=0;
581
    p=find_word_start(p); *find_word_end(p)=0;
582
    noaddw=3;
582
    noaddw=3;
583
    blk->string=add2cp(p);
583
    blk->string=add2cp(p);
584
    noaddw=0;
584
    noaddw=0;
585
    blk->len=strlen(blk->string);
585
    blk->len=strlen(blk->string);
586
    blk->fn=mt_out;
586
    blk->fn=mt_out;
587
    blk->nextblock=next;
587
    blk->nextblock=next;
588
    if(nextblock >= MAX_BLOCKS) error("block_overflow %.20s",p);
588
    if(nextblock >= MAX_BLOCKS) sym_error("block_overflow %.20s",p);
589
    idx=nextblock; blk->sublock=idx; nextblock++;
589
    idx=nextblock; blk->sublock=idx; nextblock++;
590
    snprintf(buf,sizeof(buf),"%s",p1);
590
    snprintf(buf,sizeof(buf),"%s",p1);
591
    cp_cutline(buf,blockbuf+idx,blk-blockbuf);
591
    cp_cutline(buf,blockbuf+idx,blk-blockbuf);
592
}
592
}
593
 
593
 
Line 601... Line 601...
601
    int i, n;
601
    int i, n;
602
    listtype ltab[MAX_BLOCKS];
602
    listtype ltab[MAX_BLOCKS];
603
    listtype len;
603
    listtype len;
604
 
604
 
605
    n=objnum(p,','); if(n==0) n=1;
605
    n=objnum(p,','); if(n==0) n=1;
606
    if(n>=MAX_BLOCKS) error("block_overflow %.20s",p);
606
    if(n>=MAX_BLOCKS) sym_error("block_overflow %.20s",p);
607
    clist.lcnt=1; len=n; clist.listlen=&len;
607
    clist.lcnt=1; len=n; clist.listlen=&len;
608
    for(i=0;i<n;i++) ltab[i]=-2;
608
    for(i=0;i<n;i++) ltab[i]=-2;
609
    clist.list=ltab;
609
    clist.list=ltab;
610
    _permpick(p,n,blk,blk-blockbuf,',');
610
    _permpick(p,n,blk,blk-blockbuf,',');
611
}
611
}
Line 636... Line 636...
636
 
636
 
637
void cp_wild(char *p, struct block *blk, int next)
637
void cp_wild(char *p, struct block *blk, int next)
638
{
638
{
639
    int n, min, max;
639
    int n, min, max;
640
    char *pp, *pe;
640
    char *pp, *pe;
641
    n=objnum(p,','); if(n!=1) error("wrong_parmcnt wild %.20s\n",p);
641
    n=objnum(p,','); if(n!=1) sym_error("wrong_parmcnt wild %.20s\n",p);
642
    blk->string="";
642
    blk->string="";
643
    max=min=0;
643
    max=min=0;
644
    for(pp=find_word_start(p); *pp; pp=find_word_start(pe)) {
644
    for(pp=find_word_start(p); *pp; pp=find_word_start(pe)) {
645
      pe=find_word_end(pp);
645
      pe=find_word_end(pp);
646
      if(pp[0]!='*') error("syntax_error wild %.20s\n",p);
646
      if(pp[0]!='*') sym_error("syntax_error wild %.20s\n",p);
647
      if(pp[1]!='*') {
647
      if(pp[1]!='*') {
648
          min++; continue;
648
          min++; continue;
649
      }
649
      }
650
      if(isdigit(pp[2])) max+=atoi(pp+2);
650
      if(isdigit(pp[2])) max+=atoi(pp+2);
651
      else max=MAX_BLOCKS;
651
      else max=MAX_BLOCKS;
Line 690... Line 690...
690
    if(myisupper(*p)) {
690
    if(myisupper(*p)) {
691
      for(pe=p; pe-p < MAX_BINAME && myisalpha(*pe); pe++);
691
      for(pe=p; pe-p < MAX_BINAME && myisalpha(*pe); pe++);
692
      if(*pe==':') {
692
      if(*pe==':') {
693
          *pe++=0;
693
          *pe++=0;
694
          i=search_list(builtin,builtincnt,sizeof(builtin[0]),p);
694
          i=search_list(builtin,builtincnt,sizeof(builtin[0]),p);
695
          if(i<0) error("unknown_cmd %.20s",p);
695
          if(i<0) sym_error("unknown_cmd %.20s",p);
696
          builtin[i].fn(pe,blk,next);
696
          builtin[i].fn(pe,blk,next);
697
          blk->nextblock=next;
697
          blk->nextblock=next;
698
          return;
698
          return;
699
      }
699
      }
700
    }
700
    }