-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcib71.c
1496 lines (1243 loc) · 31.8 KB
/
cib71.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* <R>
* cib71, b7_exp()
* basado en b6 usando algo de b4
* b4 - proximidad
* b6 - prefix, multiples I/F, log format
* </R>
*/
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
/* ----------------------------- b60.c ------------------------------ */
/* ----------------------------- b61.c ------------------------------ */
#if CIAPI
#include "ciapi.h"
#if !TLS
#define ciapip cib7p->ciapip
#else
DWORD extern ciapiTlsIndex;
#endif
#else /* CIAPI */
#include "cisis.h"
#endif /* CIAPI */
#if !CICPP
#include "cib70.h"
#endif /* CICPP */
#if CICPP
char * CIB7::b7_exp(RECSTRU *recp,
char *dbnamp, /* ptr nome base de dados a ler */
char *qryp, /* ptr formulacao */
char *buffup, /* area addr for fldupdat */
char *qrydbnp, /* query data base */
RECSTRU *crecp, /* registro de controle qrydbnp */
int *errnop) /* addr para codigo de erro */
#else /* CICPP */
char *b7_exp(cib7p,irec,dbnamp,qryp,buffup,qrydbnp,crec,errnop) /*
------------
...
retorna NULL ou ptr erro
*/
b7_CIB7 *cib7p; /* variables globales */
LONGX irec; /* vrecp para store */
char *dbnamp; /* ptr nome base de dados a ler */
char *qryp; /* ptr formulacao */
char *buffup; /* area addr for fldupdat */
char *qrydbnp; /* query data base */
LONGX crec; /* registro de controle qrydbnp */
int *errnop; /* addr para codigo de erro */
#endif /* CICPP */
{
#if !CICPP
RECSTRU *recp;
#endif /* CICPP */
LONGX answer;
char *b7buffup = NULL;
char *trim;
#if DISTRACE
printf("b7_exp - irec,dbnamp,qryp: %"_LD_",%s,'%s' [%s]\n",
irec,dbnamp,qryp,qrydbnp);
#endif
#if BEFORE20010117
#if SHOWCORE
if (b70trace) showcore("b7_exp");
#endif
#endif /* BEFORE */
strcpy(b7errxy,"b7_exp");
#if FATRAP
b71error = setjmp(b71jumper);
#else
b7error = b71error = 0;
#endif /* FATRAP */
B7_EXPERROR:
if (b71error != 0) {
#if ERRTRACE
printf("setjmp - error=%d (%s)\n",b71error,b7errxy);
#endif
*errnop=b71error;
#if CICPP
if (b7buffup) delete[] b7buffup;
#else /* CICPP */
if (b7buffup) FREE(b7buffup);
#endif /* CICPP */
return(b7errxy);
}
#if CICPP
try { b7buffup = new char[((ALLOPARM)MAXMFRL+1)]; }
catch (BAD_ALLOC) { b7buffup = (char *)ALLONULL; }
if (b7buffup == (char *)ALLONULL){ b7_experr(B7_THISP -8,"buffup/ALLOC",0);
goto B7_EXPERROR;
}
#else /* CICPP */
b7buffup = (char *)ALLOC((ALLOPARM)MAXMFRL+1);
if (b7buffup == (char *)ALLONULL){ b7_experr(B7_THISP -8,"buffup/ALLOC",0);
goto B7_EXPERROR;
}
if (!ndbxs) dbxinit(); /* init vdbxp/vrecp/vtrmp if not yet init - AOT, 28/10/2005 */
recp=vrecp[irec];
#endif /* CICPP */
if (!recp){
b7_experr(B7_THISP B7EE_X2,"b7_exp/recallok/recp",0);
goto B7_EXPERROR;
}
#if CICPP
if (!recp->recmfp){
b7_experr(B7_THISP B7EE_X2,"b7_exp/recallok/recmfp",0);
goto B7_EXPERROR;
}
#endif /* CICPP */
trim = qryp + ( strlen( qryp ) - 1 );
for( ;isspace( *trim ); trim-- )
*trim='\0';
b7recp=recp;
RECtype = TYPEMFR;
if (qrydbnp) {
RECdbxp = dbxstorp(qrydbnp);
if (RDBmsmfn <= 0L) {
recisis0(qrydbnp);
RDBmsmfn = 1L;
}
MFRmfn=RDBmsmfn;
#if CICPP
crecp->xrecord(dbnamp,0);
crecp->xrecord(qrydbnp,0);
#else /* CICPP */
record(crec,qrydbnp,0);
#endif /* CICPP */
}
else {
RECdbxp = NULL;
if (MFRmfn == 0) MFRmfn=1; else MFRmfn=MFRmfn+1;
}
RECrc=RCNORMAL;
MFRmfrl=LEADER;
MFRmfbwb=MFRmfbwp=0;
MFRbase=MFRmfrl;
MFRnvf=0;
MFRstatus=ACTIVE;
/* store MFQTDBN0 */
sprintf(b7buffup,"A%d|%s|",MFQTDBN0,dbnamp);
#if CICPP
if (recp->xfldupdat(b7buffup))
#else /* CICPP */
if (fldupdat(irec,b7buffup))
#endif /* CICPP */
{
b7_experr(B7_THISP -3,"b7_exp/MFQTDBN0",0);
goto B7_EXPERROR;
}
/* store MFQTQRY0 */
sprintf(b7buffup,"A%d|%s|",MFQTQRY0,qryp);
#if CICPP
if (recp->xfldupdat(b7buffup))
#else /* CICPP */
if (fldupdat(irec,b7buffup))
#endif /* CICPP */
{
b7_experr(B7_THISP -4,"b7_exp/MFQTQRY0",0);
goto B7_EXPERROR;
}
/* setup MFQTOBJ0 fldupdat */
#if BOLTRACE
b7objp=b7buffup;
#endif
b7batchp=b7buffup;
sprintf(b7batchp,"A%d\n",MFQTOBJ0); b7batchp+=strlen(b7batchp); /* | AOT, 27/05/2004 */
/* aponta expressao para gettoken */
toknextp=qryp;
/* analisa primeiro comando */
nb7oprs=0;
statement(B7_THISP &answer);
/* analisa demais */
do {
if (*token) {
statement(B7_THISP &answer);
}
else
break;
} while (1);
if( b7error ) {
b7_experr(B7_THISP b7error,"b7_exp/statement",0);
goto B7_EXPERROR;
}
*b7batchp++ = OPRXEND;
#if TESTNotNULL
strcpy(b7batchp,"Not NULL"); b7batchp+=strlen(b7batchp);
#endif
*b7batchp++ = '\n'; /* '|'; AOT, 27/05/2004 */
*b7batchp='\0';
#if CICPP
if (recp->xfldupdat(b7buffup))
#else /* CICPP */
if (fldupdat(irec,b7buffup))
#endif /* CICPP */
{
b7_experr(B7_THISP -5,"b7_exp/fldupdat",0);
goto B7_EXPERROR;
}
if (qrydbnp) {
#if CICPP
recp->xrecupdat();
#else /* CICPP */
recupdat(crec,irec);
#endif /* CICPP */
}
#if BOLTRACE
display("end");
#endif
RECtype = TYPEMFQ;
#if BEFORE20010117
#if SHOWCORE
if (b70trace) showcore("b7_exp - exit");
#endif
#endif /* BEFORE20010117 */
*errnop=0;
sprintf( buffup, "%s", b7buffup);
#if CICPP
delete[] b7buffup;
#else /* CICPP */
FREE(b7buffup);
#endif /* CICPP */
return(NULL);
}
#if CICPP
void CIB7::statement(LONGX *result)
#else /*CICPP*/
void statement(cib7p,result)
b7_CIB7 *cib7p;
LONGX *result;
#endif /*CICPP*/
{
#if BOLTRACE
display("statement");
#endif
get_token(B7_THIS );
if (!*token){
b7_experr(B7_THISP 1,"",0);
return;
}
astatement(B7_THISP result);
if (*token && *token != ';'){
b7_experr(B7_THISP 2,token,toklen);
return;
}
/*** nao gera fim de execucao */
;
#if BOLTRACE
printf("statement - fim:'%s'\n",b7objp);
#endif
}
#if CICPP
void CIB7::astatement(LONGX *result)
#else /*CICPP*/
void astatement(cib7p,result)
b7_CIB7* cib7p;
LONGX *result;
#endif /*CICPP*/
{
char *p,*slotp;
int n,slotl;
char *acclevp;
#if BOLTRACE
display("astatement");
#endif
acclevp=b7batchp;
if (toktyp == TOKTERM && *token == '#') { /* #{idx/filn} */
slotp=token; slotl=toklen;
p=tokbackp; get_token(B7_THIS );
if (toktyp == TOKDELIM && *token == '=') {
#if BOLTRACE
printf("\n+++ %s",slotp);
#endif
get_token(B7_THIS );
expression(B7_THISP result);
/*** gera assign para o slot */
nb7oprs++;
*b7batchp++ = ZASS;
for (p=slotp, n=slotl; n--; )
*b7batchp++ = *p++;
*b7batchp++ = OPRNULL;
*b7batchp = '\0'; /* tmp end */
}
else {
#if BOLTRACE
printf("putback - tokbackp=%s\n",tokbackp);
#endif
toknextp=p; get_token(B7_THIS );
expression(B7_THISP result);
}
}
else {
expression(B7_THISP result);
}
for (p=acclevp; p != b7batchp; p++)
#if FIXTRACE
putchar(*p);
putchar('\n');
#else
; /* next p */
#endif
if( b7error )
return;
fixup( B7_THISP acclevp,p-1);
#if FIXTRACE
puts(acclevp);
#endif
#if BOLTRACE
printf("astatement - fim:'%s'\n",b7objp);
#endif
}
#if CICPP
char CIB7::expression(LONGX *result)
#else /*CICPP*/
char expression(cib7p,result)
b7_CIB7 *cib7p;
LONGX *result;
#endif /*CICPP*/
{
char op;
int opl;
LONGX hold;
#if BOLTRACE
display("expression");
#endif
conjunction(B7_THISP result);
op=tokopr; opl=tokqty;
while (op == ZORX) {
get_token(B7_THIS );
conjunction(B7_THISP &hold);
semaction(B7_THISP TBOOL,op,opl,result,&hold);
op=tokopr; opl=tokqty;
}
#if BOLTRACE
printf("expression - fim - '%s'\n",b7objp);
#endif
return(PSTLEVEL);
}
#if CICPP
char CIB7::conjunction(LONGX *result)
#else /*CICPP*/
char conjunction(cib7p,result)
b7_CIB7 *cib7p;
LONGX *result;
#endif /*CICPP*/
{
char op;
int opl;
LONGX hold;
#if BOLTRACE
display("conjunction");
#endif
#if !LIND
conjgop(B7_THISP &hold);
#else
primitive(B7_THISP &hold);
#endif
op=tokopr; opl=tokqty;
while (op == ZAND || op == ZANN) {
get_token(B7_THIS );
#if !LIND
conjgop(B7_THISP &hold);
#else
primitive(B7_THISP &hold);
#endif
semaction(B7_THISP TBOOL,op,opl,result,&hold);
op=tokopr; opl=tokqty;
}
#if BOLTRACE
printf("conjunction - fim - '%s'\n",b7objp);
#endif
return(PSTLEVEL);
}
#if !LIND
#if CICPP
char CIB7::conjgop(LONGX *result)
#else /*CICPP*/
char conjgop(cib7p,result)
b7_CIB7 *cib7p;
LONGX *result;
#endif /*CICPP*/
{
char op;
int opl;
LONGX hold;
#if BOLTRACE
display("conjgop");
#endif
conjfop(B7_THISP result);
op=tokopr; opl=tokqty;
while (op == ZANG) {
get_token(B7_THIS );
conjfop(B7_THISP &hold);
semaction(B7_THISP TBOOL,op,opl,result,&hold);
op=tokopr; opl=tokqty;
}
#if BOLTRACE
printf("conjgop - fim - '%s'\n",b7objp);
#endif
return(PSTLEVEL);
}
#if CICPP
char CIB7::conjfop(LONGX *result)
#else /*CICPP*/
char conjfop(cib7p,result)
b7_CIB7 *cib7p;
LONGX *result;
#endif /*CICPP*/
{
char op;
int opl;
LONGX hold;
#if BOLTRACE
display("conjfop");
#endif
conjpop(B7_THISP result);
op=tokopr; opl=tokqty;
while (op == ZANF) {
get_token(B7_THIS );
conjpop(B7_THISP &hold);
semaction(B7_THISP TBOOL,op,opl,result,&hold);
op=tokopr; opl=tokqty;
}
#if BOLTRACE
printf("conjfop - fim - '%s'\n",b7objp);
#endif
return(PSTLEVEL);
}
#if CICPP
char CIB7::conjpop(LONGX *result)
#else /*CICPP*/
char conjpop(cib7p,result)
b7_CIB7 *cib7p;
LONGX *result;
#endif /*CICPP*/
{
char op;
int opl;
LONGX hold;
#if BOLTRACE
display("conjpop");
#endif
conjeop(B7_THISP result);
op=tokopr; opl=tokqty;
while (op == ZANP) {
get_token(B7_THIS );
conjeop(B7_THISP &hold);
semaction(B7_THISP TBOOL,op,opl,result,&hold);
op=tokopr; opl=tokqty;
}
#if BOLTRACE
printf("conjpop - fim - '%s'\n",b7objp);
#endif
return(PSTLEVEL);
}
#if CICPP
char CIB7::conjeop(LONGX *result)
#else /*CICPP*/
char conjeop(cib7p,result)
b7_CIB7 *cib7p;
LONGX *result;
#endif /*CICPP*/
{
char op;
int opl;
LONGX hold;
#if BOLTRACE
display("conjeop");
#endif
primitive(B7_THISP result);
op=tokopr; opl=tokqty;
while (op == ZANE) {
get_token(B7_THIS );
primitive(B7_THISP &hold);
semaction(B7_THISP TBOOL,op,opl,result,&hold);
op=tokopr; opl=tokqty;
}
#if BOLTRACE
printf("conjeop - fim - '%s'\n",b7objp);
#endif
return(PSTLEVEL);
}
#endif /* LIND */
#if CICPP
char CIB7::primitive(LONGX *result)
#else /*CICPP*/
char primitive(cib7p,result)
b7_CIB7 *cib7p;
LONGX *result;
#endif /*CICPP*/
{
char *p;
int n;
int aspc;
#if BOLTRACE
printf /* display() */ ("primitive - '%s'\n",b7objp);
#endif
switch (toktyp) {
case TOKNULL:
b7_experr(B7_THISP 3,"",0);
return ' ';
case TOKDELIM:
if (tokopr == '(') {
get_token(B7_THIS );
expression(B7_THISP result);
if (tokopr != ')'){
b7_experr(B7_THISP 4,token,toklen);
return ' ';
}
}
else{
b7_experr(B7_THISP 5,token,toklen);
return ' ';
}
#if BOLTRACE
display("primitive.D");
#endif
break;
case TOKTERM:
/*** gera carga do termo */
nb7oprs++;
if (tokqualp) {
if (tokqualn <= 0)
fatal("b7_primitive/tokqualn");
*b7batchp++ = ZQUA;
for (p=tokqualp, n=tokquall; n--; )
*b7batchp++ = *p++;
*b7batchp++ = OPRNULL;
nb7oprs++;
}
*b7batchp++ = ZLDV;
*b7batchp++ = PSTLEVEL; /* room for pstlevel */
for (aspc=0,p=token, n=toklen; n--; ){
/*
<R>
Eliminar los carascteres de escape.
*/
if( *p == '\\' ){
memmove( p, p+1, strlen(p) );
*b7batchp++ = *p++;
continue;
}
/* ASPAS */
if( *p == '"' )
aspc++;
*b7batchp++ = *p++;
}
if( aspc )
if( aspc%2 ){
b7_experr( B7_THISP 10, token, toklen );
return ' ';
}
/* </R> */
*b7batchp++ = OPRNULL;
*b7batchp = '\0'; /* tmp end */
#if BOLTRACE
display("primitive.T");
#endif
break;
default:
b7_experr(B7_THISP 6,token,toklen);
return ' ';
}
get_token(B7_THIS );
#if BOLTRACE
printf("primitive - fim - '%s'\n",b7objp);
#endif
return(PSTLEVEL);
}
#if CICPP
void CIB7::semaction(int type,
char op,
int opl,
LONGX *r,
LONGX *h)
#else /*CICPP*/
void semaction(cib7p,type,op,opl,r,h)
b7_CIB7* cib7p;
int type;
char op;
int opl;
LONGX *r,*h;
#endif /*CICPP*/
{
#if BOLTRACE
printf("semaction - op=%c\n",op);
#endif
/*** gera operacao com o topo-1 e topo */
nb7oprs++;
*b7batchp++ = op;
*b7batchp++ = opl + '0';
*b7batchp++ = ACCLEVEL; /* room for acclevel */
*b7batchp++ = OPRNULL;
*b7batchp = '\0'; /* tmp end */
op=type+(*r)+(*h); /* no wrn */
}
#if CICPP
void CIB7::fixup(char *p1, char* p2)
#else /* CICPP */
void fixup(cib7p,p1,p2)
b7_CIB7 *cib7p;
char *p1;
char *p2;
#endif /* CICPP */
{
char *p,c;
int x;
#if FIXTRACE
printf("fixup "); for (p=p1; p!=p2; p++) putchar(*p);
getchar();
#endif
if (*p2 != OPRNULL) fatal("*p2 != OPRNULL");
for (nop=0, p=p1; p != p2; p++) {
x=0;
switch (*p) {
case PSTLEVEL: c= *(p-1);
switch (c) {
case ZLDV: x='0'; break;
default: fatal("b7_exp/PSTLEVEL");
}
break;
case ACCLEVEL: c= *(p-2);
switch (c) {
case ZORX:
case ZAND:
case ZANN: x='1'; break;
#if !LIND
case ZANG: x='2'; break;
case ZANF: x='3'; break;
case ZANP:
case ZANE: x='4'; break;
#endif /* !LIND */
default: fatal("b7_exp/ACCLEVEL");
}
break;
}
if (x) {
if (nop >= MAXVOPR){
b7_experr(B7_THISP -7,"fixup/MAXVOPR",0);
return;
}
vetopr[nop]=c; vetcas[nop]=x; vetopp[nop]=p;
#if FIXTRACE
printf("#%2d opr=%c cas=%c opp=%.3s\n",
nop,vetopr[nop],vetcas[nop],vetopp[nop]);
#endif
nop++;
}
}
if (nop == 0)
fatal("fixup/nop");
#if FIXTRACE
xtrac=0;
#endif
fixlev(B7_THISP nop-1,'1');
/* check '#' */
for (p=p1; p != p2; p++) {
if (*p == ZLDV)
if (*(p+1) >= '1' && *(p+1) <= '4')
if (*(p+2) == '#')
if (*(p+1) != '1'){
b7_experr(B7_THISP 22,"#",1);
return;
}
}
}
#if CICPP
int CIB7::fixlev(int i2, char level)
#else
int fixlev(cib7p,i2,level)
b7_CIB7 *cib7p;
int i2;
char level;
#endif
{
#if FIXTRACE
int n;
for (n=xtrac; n--; ) printf(" ");
printf("[%d] i2=%d level=%c ",xtrac,i2,level);
#endif
if (i2 < 0) return(i2);
#if FIXTRACE
printf("%.9s\n",vetopp[i2]);
#endif
*vetopp[i2]=level;
if (vetopr[i2] != ZLDV) { /* operation */
#if FIXTRACE
xtrac++;
#endif
if (vetcas[i2] > level)
level=vetcas[i2];
if (i2 < 2)
fatal("fixlev/i2<2");
i2=fixlev(B7_THISP i2-1,level);
if (i2 < 0)
fatal("fixlev/i2<0");
i2=fixlev(B7_THISP i2-1,level);
#if FIXTRACE
xtrac--;
#endif
}
return(i2);
}
#define iswhite(c) isspace(c)
#if CICPP
void CIB7::get_token()
#else
void get_token(cib7p)
b7_CIB7 *cib7p;
#endif
{
char *toknp,*toknxp,toknx;
char *tkkbackp;
char *tkknextp;
char *tkken;
char tkktyp;
char tkkopr;
int tkkqty;
int tkklen;
char *p;
int loop;
NEWTOKEN:
tokmassp=NULL;
gettoken(B7_THIS);
tokqualp=NULL;
tokquall=tokqualn=0;
switch (toktyp) {
case TOKDELIM:
break;
case TOKTERM:
if (!*token) {
toktyp=TOKNULL;
break;
}
for (toknxp=toknextp; iswhite(*toknxp); toknxp++);
toknx = (*toknxp == '/') ? '/' : '\0';
while (toklen && iswhite(*(toknextp-1))) {
toklen--;
toknextp--;
}
toknp=token+toklen;
while (toklen && iswhite(*(toknp-1))) {
toklen--;
toknp--;
}
if (b7batchp) /* intbrm - 06/01/93 */
tokmassp=b7_massp(B7_THISP token,toklen,B7EE_PFX);
if (*(toknp-1) == '/' || toknx == '/') {
tkkbackp=tokbackp;
tkknextp=toknextp;
tkken=token;
tkktyp=toktyp;
tkkopr=tokopr;
tkkqty=tokqty;
tkklen=toklen;
if (toknx == '/')
toknextp=toknxp+1;
gettoken(B7_THIS); /* '(' */
if (tokopr == '(') {
tokqualp=toknextp;
gettoken(B7_THIS); /* 10,20,30,...,qualifier_n */
tokquall=toklen;
gettoken(B7_THIS); /* ')' */
if (tokopr == ')') {
tokqualn=1;
for (p=tokqualp, loop=tokquall; loop--; p++) {
if (iswhite(*p))
continue;
if (*p == ',')
tokqualn++;
if (tokqualn >= MAXQUAL){
b7_experr(B7_THISP 7,tokqualp,tokquall);
return;
}
}
}
else{
b7_experr(B7_THISP 8,tokqualp,tokquall);
return;
}
token=tkken;
toktyp=tkktyp;
tokopr=tkkopr;
tokqty=tkkqty;
toklen=tkklen;
if (toknx != '/')
do {
toklen--;
toknp--;
} while (toklen && iswhite(*(toknp-1)));
}
else {
tokbackp=tkkbackp;
toknextp=tkknextp;
token=tkken;
toktyp=tkktyp;
tokopr=tkkopr;
tokqty=tkkqty;
toklen=tkklen;
}
}
;
#if MASSAGE
tokmassp=b7_massp(token,toklen,tokqualp,tokquall,toknextp);
#endif
;
break;
default:
fatal("b7_expr/get_token");
}
#if TOKTRACE
#if !BOLTRACE
display("get_token");
#endif
#endif
if (tokmassp) {
toknextp=tokmassp;
goto NEWTOKEN;
}
}