-
Notifications
You must be signed in to change notification settings - Fork 7
/
lispf42.c
5423 lines (5031 loc) · 129 KB
/
lispf42.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
/* lispf42.f -- translated by f2c (version 20000704).
You must link the resulting object file with the libraries:
-lf2c -lm (in that order)
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <signal.h>
#include "f2c.h"
double pow(), fmod();
extern time_t start_time;
extern int f4_open(int lun, char *file, char *mode);
extern int f4_close(int lun);
extern void setup(void);
extern int f4_readu(int lun, char *v, int n);
extern void f4_start_read(void);
extern int f4_read(int lun, char *v, int n);
extern int f4_write(int lun, char *v, int n);
extern int f4_write_lf(int lun);
extern int f4_rewind(int lun);
#define SHOWINT(x) fprintf(stderr, #x " = %d\n", x)
static void usage(char *);
//#define FORTRAN_LIB
/* Common Block Declarations */
extern struct {
integer narea, jbytes, ibytes, bytes, chdiv, maxint, maxbig, maxrec,
natomp, nfreep, jbp, numbp, nfreet, numadd, npname, nfreeb, natom,
nstack, nhtab, bignum, ismall, dpnp, dpname, ipromp, nathsh,
nbytes, nchtyp, nbmess, maxmes, iresol, ipower;
real bigmax, fuzz;
integer garbs, cgarbs, ngarbs, agarbs;
real rmax;
} a_;
#define a_1 a_
extern struct {
integer arg, arg2, arg3, alist__, form, temp1, temp2, temp3, i1cons,
i2cons, nargs, nil, a000, apply, eval, fncell, fexpr, funarg,
lambda, array, string, substr, lispx, nlambd, unboun, prog, quote,
expr, error, sform, sinter, subarg, dotat, t, subr0, subr11,
subr1, subr2, subr3, subr, fsubr, ip, jp, ipp, jpp, middl, abup1,
cht, chr, numgen, unused, brlev, brflg, iflg1, iflg2, isplft;
logical ibreak;
integer errtyp, iobuff, maxlun, lunsys, lunins, lunuts, maxpar, itabwg,
lunin, rdpos, lmargr, margr, lunut, prtpos, lmarg, marg, levell,
levelp, dreg[7], abuff[160], rdbuff[160], prbuff[160], buff[160],
imess[400];
real *pname;
integer *pnp, *htab, *stack;
} b_;
#define b_1 b_
extern struct {
integer *car, *cdr, chtab[256];
} carcdr_;
#define carcdr_1 carcdr_
extern struct {
integer space, lpar, rpar, ilbchr, irbchr, strchr, iqchr, ubr, dot, itchr,
iplus, iminus, ifig[10], atend, softbr, echar, nochar;
} chars_;
#define chars_1 chars_
extern struct {
integer *jill, *jack, env, tops, hill, hillw;
} jaan_;
#define jaan_1 jaan_
extern struct {
integer protxt[80], prolen;
} prompt_;
#define prompt_1 prompt_
/* Table of constant values */
static integer c__1 = 1;
static struct { integer fill; char val[0+1]; char fill2[3]; } c_b3_st = { 0,
"" };
#define c_b3 c_b3_st.val
static struct { integer fill; char val[12+1]; char fill2[3]; } c_b4_st = { 0,
"LISPF4.IMG " };
#define c_b4 c_b4_st.val
static struct { integer fill; char val[4+1]; char fill2[3]; } c_b5_st = { 0,
"OLD " };
#define c_b5 c_b5_st.val
static struct { integer fill; char val[12+1]; char fill2[3]; } c_b6_st = { 0,
"UNFORMATTED " };
#define c_b6 c_b6_st.val
static integer c__10 = 10;
static integer c__0 = 0;
static integer c__2 = 2;
static integer c__3 = 3;
static struct { integer fill; char val[8+1]; char fill2[3]; } c_b98_st = { 0,
"SYSATOMS" };
#define c_b98 c_b98_st.val
static integer c__15 = 15;
static real c_b239 = 1.f;
static integer c__4 = 4;
static integer c__24 = 24;
static integer c__36 = 36;
static integer c__39 = 39;
static integer c__30 = 30;
/* ******FLOSOR (AUX ROUTINES FOR INTERPRETER) */
/* *********************************************************************** */
/* * * */
/* * LISP F4 (FLOATING) * */
/* * ------- * */
/* * * */
/* * THE SYSTEM WAS WRITTEN BY UPDATED BY * */
/* * DR. MATS NORDSTROM HANS ERIKSSON AND * */
/* * KRISTINA JOHANSSON * */
/* * DR. TORE RISCH * */
/* * READER, PRINTER, ARRAYS, AND FLONUMS * */
/* * WERE ADDED BY MATS CARLSSON * */
/* * THE STACK-VARIANT OF THE * */
/* * INTERPRETER WAS WRITTEN BY JAAN KOORT * */
/* * * */
/* * UPMAIL * */
/* * STUREGATAN 2A * */
/* * S-752 23 UPPSALA * */
/* * SWEDEN * */
/* * * */
/* * THE WORK WAS SUPPORTED BY THE SWEDISH BOARD * */
/* * FOR TECHNICAL DEVELOPMENT (STU) NO 76-4253. * */
/* * * */
/* *********************************************************************** */
/* *IBM SUPPLIED MACHINE CODE* EXTERNAL BRSERV */
#ifdef FORTRAN_LIB
/* Main program */ int MAIN__(void)
#else
int main(int argc, char *argv[])
#endif
{
/* Initialized data */
#ifdef FORTRAN_LIB
static integer istart = 0; /* 0=SYSATOMS, 1=LISPF4.IMG */
#else
integer istart; /* 0=SYSATOMS, 1=argv[1] */
#endif
/* System generated locals */
olist o__1;
cllist cl__1;
/* Builtin functions */
/* Subroutine */ int s_stop(char *, ftnlen);
integer f_open(olist *), f_clos(cllist *);
/* Local variables */
static integer ixcc;
extern /* Subroutine */ int init1_(void), init2_(void), brset_(void),
lspex_(void), lispf4_(integer *);
extern integer rollin_(integer *);
start_time = time(NULL);
/* -- SET UP INTERRUPT HANDLER */
brset_();
a_1.nfreet = CELLS;
a_1.natom = ATOMS;
a_1.nstack = STACK;
jaan_1.hill = STACK;
a_1.npname = ARRAY;
istart = 1; /* require image file */
#ifndef FORTRAN_LIB
while (argc > 1 && *argv[1] == '-') {
switch (argv[1][1]) {
case 'c': /* car/cdr cells */
a_1.nfreet = atoi(argv[1]+2);
break;
case 'a': /* atoms */
a_1.natom = atoi(argv[1]+2);
break;
case 's': /* stack space */
a_1.nstack = atoi(argv[1]+2);
jaan_1.hill = a_1.nstack;
break;
case 'p': /* print names / strings / reals / arrays */
a_1.npname = atoi(argv[1]+2);
break;
case 'x':
istart = 0; /* no image file but requires SYSATOMS */
break;
case '-':
case 'h':
case '?':
default:
usage(argv[0]);
return 0;
}
argc--;
argv++;
}
#endif
carcdr_1.car = (integer *) calloc(a_1.nfreet, sizeof(integer));
carcdr_1.cdr = (integer *) calloc(a_1.nfreet, sizeof(integer));
b_1.pnp = (integer *) calloc(a_1.natom+1, sizeof(integer));
a_1.nhtab = (integer)(1.5 * (double) a_1.natom);
b_1.htab = (integer *) calloc(a_1.nhtab, sizeof(integer));
b_1.stack = (integer *) calloc(a_1.nstack, sizeof(integer));
jaan_1.jill = (integer *) calloc(jaan_1.hill, sizeof(integer));
jaan_1.jack = (integer *) calloc(jaan_1.hill, sizeof(integer));
b_1.pname = (real *) calloc(a_1.npname+2, sizeof(real));
if (!carcdr_1.cdr ||
!carcdr_1.cdr ||
!b_1.pnp ||
!b_1.htab ||
!b_1.stack ||
!jaan_1.jill ||
!jaan_1.jack ||
!b_1.pname) {
fprintf(stderr, "Out of memory\n");
exit(-1);
}
if (istart && argc <= 1) {
fprintf(stderr, "Image file required. For help: %s -h\n", argv[0]);
exit(-1);
}
init1_();
if (istart != 0) {
goto L10;
}
init2_();
istart = 1;
lispf4_(&c__1);
lspex_();
#ifdef FORTRAN_LIB
s_stop(c_b3, (ftnlen)0);
#else
exit(0);
#endif
/* -- IN CASE OF INTERRUPT AND RESTART THE VARIABLE ISTART */
/* -- TELLS IF WE HAVE DONE THE INIT, THEN WE CAN CALL THE INTERPRETER */
/* -- DIRECTLY */
/* -- ON COMPUTERS WHERE YOU SAVE CORE IMAGES (E.G. DEC20) YOU CAN */
/* -- START THE LISPF4 SYSTEM, READ ALL LISPCODE YOU WANT AND THEN */
/* -- EXIT AND SAVE THE CORE IMAGE. THIS WAY YOU DONT HAVE TO USE ROLLFILES */
/* -- */
L10:
#ifdef FORTRAN_LIB
o__1.oerr = 0;
o__1.ounit = 10;
o__1.ofnmlen = 10;
o__1.ofnm = c_b4;
o__1.orl = 0;
o__1.osta = c_b5;
o__1.oacc = 0;
o__1.ofm = c_b6;
o__1.oblnk = 0;
f_open(&o__1);
ixcc = rollin_(&c__10);
cl__1.cerr = 0;
cl__1.cunit = 10;
cl__1.csta = 0;
f_clos(&cl__1);
#else
#ifdef unix
f4_open(10, argv[1], "r");
#else
f4_open(10, argv[1], "rb");
#endif
ixcc = rollin_(&c__10);
f4_close(10);
#endif
lispf4_(&c__1);
lspex_();
#ifdef FORTRAN_LIB
s_stop(c_b3, (ftnlen)0);
#else
exit(0);
#endif
return 0;
} /* MAIN__ */
/* Subroutine */ int apush_(integer *i__)
{
/* OMMON AND INTEGER DECLARATIONS */
/* OMMON AND INTEGER DECLARATIONS END */
--b_1.jp;
if (b_1.ip >= b_1.jp) {
goto L2;
}
b_1.stack[b_1.jp - 1] = *i__;
return 0;
L2:
b_1.stack[b_1.ip - 1] = 16;
++b_1.jp;
return 0;
} /* apush_ */
/* Subroutine */ int apush2_(integer *i__, integer *j)
{
/* OMMON AND INTEGER DECLARATIONS */
/* OMMON AND INTEGER DECLARATIONS END */
b_1.jp += -2;
if (b_1.ip >= b_1.jp) {
goto L2;
}
b_1.stack[b_1.jp] = *i__;
b_1.stack[b_1.jp - 1] = *j;
return 0;
L2:
b_1.stack[b_1.ip - 1] = 16;
b_1.jp += 2;
return 0;
} /* apush2_ */
/* Subroutine */ int apop_(integer *i__)
{
/* OMMON AND INTEGER DECLARATIONS */
/* OMMON AND INTEGER DECLARATIONS END */
if (b_1.jp > a_1.nstack) {
goto L2;
}
*i__ = b_1.stack[b_1.jp - 1];
++b_1.jp;
return 0;
L2:
b_1.stack[b_1.ip - 1] = 17;
b_1.jp = b_1.ip + 1;
return 0;
} /* apop_ */
/* Subroutine */ int apop2_(integer *i__, integer *j)
{
/* OMMON AND INTEGER DECLARATIONS */
/* OMMON AND INTEGER DECLARATIONS END */
if (b_1.jp > a_1.nstack) {
goto L2;
}
*i__ = b_1.stack[b_1.jp - 1];
*j = b_1.stack[b_1.jp];
b_1.jp += 2;
return 0;
L2:
b_1.stack[b_1.ip - 1] = 17;
b_1.jp = b_1.ip + 1;
return 0;
} /* apop2_ */
/* Subroutine */ int apush3_(integer *i__, integer *j, integer *k)
{
/* OMMON AND INTEGER DECLARATIONS */
/* OMMON AND INTEGER DECLARATIONS END */
b_1.jp += -3;
if (b_1.ip >= b_1.jp) {
goto L2;
}
b_1.stack[b_1.jp + 1] = *i__;
b_1.stack[b_1.jp] = *j;
b_1.stack[b_1.jp - 1] = *k;
return 0;
L2:
b_1.stack[b_1.ip - 1] = 16;
b_1.jp += 3;
return 0;
} /* apush3_ */
/* Subroutine */ int apop3_(integer *i__, integer *j, integer *k)
{
/* OMMON AND INTEGER DECLARATIONS */
/* OMMON AND INTEGER DECLARATIONS END */
if (b_1.jp > a_1.nstack) {
goto L2;
}
*i__ = b_1.stack[b_1.jp - 1];
*j = b_1.stack[b_1.jp];
*k = b_1.stack[b_1.jp + 1];
b_1.jp += 3;
return 0;
L2:
b_1.stack[b_1.ip - 1] = 17;
b_1.jp = b_1.ip + 1;
return 0;
} /* apop3_ */
/* Subroutine */ int fpush_(integer *i__)
{
/* OMMON AND INTEGER DECLARATIONS */
/* OMMON AND INTEGER DECLARATIONS END */
++b_1.ip;
if (b_1.ip >= b_1.jp) {
goto L2;
}
/* L1: */
b_1.stack[b_1.ip - 1] = *i__;
return 0;
L2:
--b_1.ip;
b_1.stack[b_1.ip - 1] = 16;
return 0;
} /* fpush_ */
/* Subroutine */ int fpop_(integer *i__)
{
/* OMMON AND INTEGER DECLARATIONS */
/* OMMON AND INTEGER DECLARATIONS END */
*i__ = b_1.stack[b_1.ip - 1];
--b_1.ip;
return 0;
} /* fpop_ */
integer cons_(integer *i1, integer *i2)
{
/* System generated locals */
integer ret_val;
/* Local variables */
extern integer garb0_(integer *, integer *);
static integer icons;
/* OMMON AND INTEGER DECLARATIONS */
/* OMMON AND INTEGER DECLARATIONS END */
if (a_1.nfreep == b_1.nil) {
goto L3;
}
icons = a_1.nfreep;
ret_val = icons;
a_1.nfreep = carcdr_1.cdr[a_1.nfreep - 1];
/* *SETC* CALL SETCAR(ICONS,I1) */
carcdr_1.car[icons - 1] = *i1;
/* *SETC* CALL SETCDR(ICONS,I2) */
carcdr_1.cdr[icons - 1] = *i2;
return ret_val;
L3:
ret_val = garb0_(i1, i2);
return ret_val;
} /* cons_ */
integer garb0_(integer *i1, integer *i2)
{
/* System generated locals */
integer ret_val;
/* Local variables */
extern integer garb_(integer *);
static integer i__, icons;
/* PERFORM A FREE CELL GARB */
/* OMMON AND INTEGER DECLARATIONS */
/* OMMON AND INTEGER DECLARATIONS END */
/* L3: */
b_1.i1cons = *i1;
b_1.i2cons = *i2;
i__ = garb_(&c__0);
icons = a_1.nfreep;
ret_val = icons;
a_1.nfreep = carcdr_1.cdr[a_1.nfreep - 1];
/* *SETC* CALL SETCAR(ICONS,I1CONS) */
carcdr_1.car[icons - 1] = b_1.i1cons;
/* *SETC* CALL SETCDR(ICONS,I2CONS) */
carcdr_1.cdr[icons - 1] = b_1.i2cons;
if (i__ > b_1.isplft) {
return ret_val;
}
b_1.isplft /= 2;
b_1.ibreak = TRUE_;
b_1.errtyp = 34;
return ret_val;
} /* garb0_ */
integer subpr_(integer *ix, integer *iy, integer *is)
{
/* System generated locals */
integer ret_val=0;
/* Local variables */
static integer icdr;
extern /* Subroutine */ int apop_(integer *);
extern integer cons_(integer *, integer *);
static integer i__, j, k;
#define s ((integer *)&b_1.temp2) /* ((integer *)&b_1 + 6) */
extern integer equal_(integer *, integer *);
extern /* Subroutine */ int fpush_(integer *), apush_(integer *);
#define res ((integer *)&b_1.temp1) /* ((integer *)&b_1 + 5) */
/* OMMON AND INTEGER DECLARATIONS */
/* OMMON AND INTEGER DECLARATIONS END */
*s = *is;
fpush_(&c__1);
/* -- MEMB TEST OF S IN IX */
L5:
j = *ix;
k = *iy;
L6:
if (j <= a_1.natom || j > a_1.nfreet) {
goto L7;
}
if (k <= a_1.natom || k > a_1.nfreet) {
k = b_1.nil;
}
if (equal_(&carcdr_1.car[j - 1], s) == b_1.t) {
goto L8;
}
j = carcdr_1.cdr[j - 1];
k = carcdr_1.cdr[k - 1];
goto L6;
L7:
if (j == b_1.nil || j != *s) {
goto L10;
}
/* -- (SUBPAIR '(X Y . Z) '(A B C D E) '(X Y Z))= */
/* -- (A B C D E) */
*res = k;
goto L20;
L8:
*res = carcdr_1.car[k - 1];
goto L20;
L10:
if (*s > a_1.natom && *s <= a_1.nfreet) {
goto L30;
}
/* L16: */
*res = *s;
L20:
i__ = b_1.stack[b_1.ip - 1];
if (i__ > 3) {
goto L90;
}
/* L25: */
--b_1.ip;
switch (i__) {
case 1: goto L50;
case 2: goto L35;
case 3: goto L40;
}
L30:
icdr = carcdr_1.cdr[*s - 1];
apush_(&icdr);
fpush_(&c__2);
*s = carcdr_1.car[*s - 1];
goto L5;
L35:
*s = b_1.stack[b_1.jp - 1];
b_1.stack[b_1.jp - 1] = *res;
fpush_(&c__3);
goto L5;
L40:
apop_(s);
*res = cons_(s, res);
goto L20;
L50:
ret_val = *res;
return ret_val;
/* PDL OVERFLOW. LEAVE OFLO ADDRESS (16) IN F-STACK */
L90:
return ret_val;
} /* subpr_ */
#undef res
#undef s
integer equal_(integer *ii, integer *jj)
{
/* System generated locals */
integer ret_val;
/* Local variables */
extern /* Subroutine */ int apop2_(integer *, integer *);
static integer i__, j;
extern /* Subroutine */ int apush2_(integer *, integer *);
static integer in, jn;
extern integer comppn_(integer *, integer *);
extern doublereal gtreal_(integer *, integer *);
static integer jpe;
/* OMMON AND INTEGER DECLARATIONS */
/* OMMON AND INTEGER DECLARATIONS END */
jpe = b_1.jp;
i__ = *ii;
j = *jj;
L10:
if (i__ == j) {
goto L50;
}
if (i__ <= a_1.natom) {
goto L80;
}
if (i__ > a_1.nfreet) {
goto L70;
}
if (j <= a_1.natom || j > a_1.nfreet) {
goto L60;
}
/* I NOT EQ J. I AND J ARE LISTS */
/* L15: */
apush2_(&i__, &j);
i__ = carcdr_1.car[i__ - 1];
j = carcdr_1.car[j - 1];
goto L10;
L20:
apop2_(&j, &i__);
i__ = carcdr_1.cdr[i__ - 1];
j = carcdr_1.cdr[j - 1];
goto L10;
L50:
if (b_1.jp < jpe) {
goto L20;
}
/* L51: */
ret_val = b_1.t;
return ret_val;
L60:
b_1.jp = jpe;
ret_val = b_1.nil;
return ret_val;
/* I = NUMBER */
L70:
if (j <= a_1.nfreet) {
goto L60;
}
if (gtreal_(&i__, &in) != gtreal_(&j, &jn)) {
goto L60;
}
if (in != jn) {
goto L60;
}
goto L50;
/* I = LITERAL/STRING */
L80:
if (0 == comppn_(&i__, &j)) {
goto L50;
}
goto L60;
} /* equal_ */
integer get_(integer *j, integer *i__)
{
/* System generated locals */
integer ret_val;
/* Local variables */
static integer k;
/* OMMON AND INTEGER DECLARATIONS */
/* OMMON AND INTEGER DECLARATIONS END */
if (*j > a_1.nfreet) {
goto L40;
}
k = carcdr_1.cdr[*j - 1];
L8:
if (k <= a_1.natom || k > a_1.nfreet) {
goto L40;
}
if (carcdr_1.car[k - 1] == *i__) {
goto L20;
}
/* L12: */
k = carcdr_1.cdr[k - 1];
k = carcdr_1.cdr[k - 1];
goto L8;
L20:
k = carcdr_1.cdr[k - 1];
ret_val = carcdr_1.car[k - 1];
return ret_val;
L40:
ret_val = b_1.nil;
return ret_val;
} /* get_ */
integer getpn_(integer *x, integer *main, integer *jb, integer *ipl)
{
/* System generated locals */
integer ret_val;
/* Local variables */
static integer l, ii;
extern integer getnum_(integer *);
/* ----- */
/* DECODES THE LITATOM/STRING/SUBSTRING X */
/* MAIN <-- POINTER TO MAIN STRING, IF SUBSTRING */
/* JB <-- BYTE OFFSET TO PRINTNAME */
/* IPL <-- BYTE LENGTH OF PRINTNAME */
/* GETPN <-- -1 = X INVALID, 0 = LITATOM, 1 = STRING/SUBSTRING */
/* ----- */
/* OMMON AND INTEGER DECLARATIONS */
/* OMMON AND INTEGER DECLARATIONS END */
if (*x > a_1.natom) {
goto L9010;
}
*jb = b_1.pnp[*x - 1];
*ipl = b_1.pnp[*x] - *jb;
*main = *x;
if (carcdr_1.car[*x - 1] == b_1.string) {
goto L9030;
}
if (carcdr_1.car[*x - 1] != b_1.substr) {
goto L9020;
}
/* TAKE CARE OF THE SUBSTR CASE */
l = carcdr_1.cdr[*x - 1];
if (l > a_1.nfreet) {
goto L9010;
}
*main = carcdr_1.car[l - 1];
if (*main > a_1.natom) {
goto L9010;
}
if (carcdr_1.car[*main - 1] != b_1.string) {
goto L9010;
}
l = carcdr_1.cdr[l - 1];
if (l > a_1.nfreet) {
goto L9010;
}
if (carcdr_1.car[l - 1] <= a_1.nfreet || carcdr_1.cdr[l - 1] <=
a_1.nfreet) {
goto L9010;
}
/* GET BYTE ADDR */
ii = carcdr_1.car[l - 1];
*jb = b_1.pnp[*main - 1] + getnum_(&ii) - 1;
/* GET BYTE LENGTH */
ii = carcdr_1.cdr[l - 1];
*ipl = getnum_(&ii);
goto L9030;
/* EXITS. */
L9010:
ret_val = -1;
return ret_val;
L9020:
ret_val = 0;
return ret_val;
L9030:
ret_val = 1;
return ret_val;
} /* getpn_ */
integer comppn_(integer *x, integer *y)
{
/* System generated locals */
integer ret_val, i__1;
/* Local variables */
static integer main, i__;
extern /* Subroutine */ int getch_(real *, integer *, integer *);
extern integer getpn_(integer *, integer *, integer *, integer *);
static integer jb, jb2, ich, jch, min__, ipl, ipl2;
/* ----- */
/* COMPARES THE PRINTNAMES OF ITS ARGUMENTS */
/* COMPPN <-- -2 IF X ILLEGAL; <-- 2 IF Y IS ILLEGAL; */
/* <-- -1 IF X < Y; <-- 1 IF X > Y; */
/* <-- 0 IF X = Y; */
/* ----- */
/* OMMON AND INTEGER DECLARATIONS */
/* OMMON AND INTEGER DECLARATIONS END */
ret_val = -2;
if (0 > getpn_(x, &main, &jb, &ipl)) {
return ret_val;
}
ret_val = 2;
if (0 > getpn_(y, &main, &jb2, &ipl2)) {
return ret_val;
}
ret_val = 0;
min__ = ipl;
if (ipl > ipl2) {
min__ = ipl2;
}
if (min__ == 0) {
goto L20;
}
/* COMPARE BYTE BY BYTE */
i__1 = min__;
for (i__ = 1; i__ <= i__1 || i__ == 1; ++i__) {
getch_(b_1.pname, &ich, &jb);
getch_(b_1.pname, &jch, &jb2);
if (ich < jch) {
goto L30;
}
if (ich > jch) {
goto L40;
}
++jb;
/* L10: */
++jb2;
}
L20:
if ((i__1 = ipl - ipl2) < 0) {
goto L30;
} else if (i__1 == 0) {
goto L50;
} else {
goto L40;
}
L30:
ret_val = -1;
goto L50;
L40:
ret_val = 1;
L50:
return ret_val;
} /* comppn_ */
/* Subroutine */ int arrutl_(integer *iptr, integer *iactn, integer *ipart,
integer *ifirst, integer *ilen)
{
/* System generated locals */
integer i__1;
static integer equiv_3[3], equiv_6[3];
/* Local variables */
#define llen (equiv_6)
#define llen1 (equiv_6)
#define llen2 (equiv_6 + 1)
#define llen3 (equiv_6 + 2)
static integer j;
#define lword (equiv_3)
static integer lbyte1, lbyte2, lbyte3;
#define lword1 (equiv_3)
#define lword2 (equiv_3 + 1)
#define lword3 (equiv_3 + 2)
#define jpname ((shortint *) b_1.pname) /* ((shortint *)&b_1 + 2244) */
#define ipname ((integer *) b_1.pname) /* ((integer *)&b_1 + 1122) */
static integer jfirst, ind;
/* ---- */
/* + TAKES CARE OF THE SYSTEM'S ARRAY HANDLING. */
/* ARRAYS ARE REPRESENTED AS FOLLOWS: */
/* +--------------+ */
/* ! ! */
/* PNAME:...(Z * * (POINTERS) Z (INTEGERS) Z (REALS)) (NEXT ATOM)... */
/* ! ! ! ! */
/* ! +-------------------------+ ! */
/* PNP:(IPTR) (IPTR+1) */
/* CAR(IPTR) = ARRAY (BYTE POINTERS) */
/* CDR(IPTR) = NIL (Z = 0 OR MORE SLACK BYTES) */
/* + PARAMETERS: */
/* IPTR LISP POINTER TO ARRAY (AS ABOVE) */
/* IACTN = 1 GET ARRAY ELEMENT */
/* = 2 SET ARRAY ELEMENT */
/* = 3 SET IFIRST AND ILEN TO ARRAY PART BOUNDS */
/* = 4 MAKE AN ARRAY PART, INITTED TO IFIRST */
/* IPART = 1 POINTER PART IS REFERRED TO */
/* = 2 INTEGER PART */
/* = 3 REAL PART */
/* IFIRST: ARRAY PART RELATIVE INDEX (IACTN = 1,2) OR */
/* PNAME RELATIVE INDEX (IACTN = 3,4) */
/* ILEN: PNAME RELATIVE INDEX TO VALUE (IACTN = 1,2) OR */
/* NO. OF ELEMENTS IN PART (IACTN = 3,4) */
/* + NUMERIC ELEMENT VALUES ARE TRANSMITTED VIA IPNAME/PNAME */
/* ----- */
/* OMMON AND INTEGER DECLARATIONS */
/* OMMON AND INTEGER DECLARATIONS END */
if (b_1.ibreak) {
goto L9000;
}
/* CHECK PARAMETER IPTR */
if (*iptr < b_1.nil || *iptr > a_1.natom) {
goto L8010;
}
if (carcdr_1.car[*iptr - 1] != b_1.array) {
goto L8010;
}
/* GET ARRAY BOUNDS */
lbyte1 = b_1.pnp[*iptr - 1];
lbyte1 = abs(lbyte1);
*lword1 = (lbyte1 - 2) / a_1.jbytes + 4;
if (*iactn == 4 && *ipart == 1) {
goto L4000;
}
lbyte2 = jpname[*lword1 - 3];
*llen1 = (lbyte2 - lbyte1) / a_1.jbytes - 2;
if (*ipart < 2) {
goto L20;
}
*lword2 = (lbyte2 - 2) / a_1.ibytes + 2;
lbyte3 = jpname[*lword1 - 2];
*llen2 = (lbyte3 - lbyte2) / a_1.ibytes;
if (*ipart < 3) {
goto L20;
}
*lword3 = (lbyte3 - 2) / a_1.bytes + 2;
*llen3 = b_1.pnp[*iptr];
*llen3 = (abs(*llen3) - lbyte3) / a_1.bytes;
L20:
switch (*iactn) {
case 1: goto L1000;
case 2: goto L2000;
case 3: goto L3000;
case 4: goto L4000;
}
/* GET ARRAY ELEMENT (CALLED BY ELT,ELTI,ELTR) */
L1000:
if (*ifirst <= 0 || *ifirst > llen[*ipart - 1]) {
goto L8020;
}
*ilen = lword[*ipart - 1] + *ifirst - 1;
goto L9000;
/* SET ARRAY ELEMENT (CALLED BY SETA,SETI,SETR) */
L2000:
if (*ifirst <= 0 || *ifirst > llen[*ipart - 1]) {
goto L8020;
}
ind = lword[*ipart - 1] + *ifirst - 1;
if (*ipart == 1) {
jpname[ind - 1] = jpname[*ilen - 1];
}
if (*ipart == 2) {
ipname[ind - 1] = ipname[*ilen - 1];
}
if (*ipart == 3) {
b_1.pname[ind - 1] = b_1.pname[*ilen - 1];
}
goto L9000;
/* GET ARRAY BOUNDS (CALLED BY ARRAYSIZE AND GARB (STEPS 1,6)) */
L3000:
*ifirst = lword[*ipart - 1];
*ilen = llen[*ipart - 1];
goto L9000;
/* MAKE AN ARRAY (CALLED BY ARRAY AND GARB (STEP 4)) */
/* REQUIRES THAT WE HAVE ENSURED THAT THERE IS ENOUGH SPACE ALREADY */
/* IFIRST = 0 YIELDS DEFAULT VALUES IN THE NEW ARRAY */
L4000:
jfirst = *ifirst;
switch (*ipart) {
case 1: goto L4100;
case 2: goto L4200;
case 3: goto L4300;
}
/* PTR PART */
L4100:
i__1 = *ilen + 2;
a_1.jbp = ((a_1.jbp + a_1.jbytes - 2) / a_1.jbytes + i__1) * a_1.jbytes +
1;
if (*ilen == 0 || *lword1 == jfirst) {
goto L4410;
}
i__1 = *ilen;
for (j = 1; j <= i__1 || j == 1; ++j) {
if (jfirst == 0) {
goto L4120;
}
jpname[*lword1 - 1] = jpname[jfirst - 1];
++jfirst;
goto L4150;
L4120:
jpname[*lword1 - 1] = (shortint) b_1.nil;
L4150:
++(*lword1);
}
goto L4410;
/* INT PART */
L4200:
a_1.jbp = ((a_1.jbp + a_1.ibytes - 2) / a_1.ibytes + *ilen) * a_1.ibytes
+ 1;
if (*ilen == 0 || *lword2 == jfirst) {
goto L4420;
}
i__1 = *ilen;
for (j = 1; j <= i__1 || j == 1; ++j) {
if (jfirst == 0) {
goto L4220;
}
ipname[*lword2 - 1] = ipname[jfirst - 1];