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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
|
Path: funic!news.funet.fi!sunic!uupsi!rpi!zaphod.mps.ohio-state.edu!wuarchive!uunet!mcsun!hp4nl!charon!guido
From: [email protected] (Guido van Rossum)
Newsgroups: alt.sources
Subject: Python 0.9.1 part 19/21
Message-ID: <[email protected]>
Date: 19 Feb 91 17:42:49 GMT
Sender: [email protected]
Organization: CWI, Amsterdam
Lines: 1997
Originator: [email protected]
: This is a shell archive.
: Extract with 'sh this_file'.
:
: Extract part 01 first since it makes all directories
echo 'Start of pack.out, part 19 out of 21:'
if test -s 'demo/scripts/xxci.py'
then echo '*** I will not over-write existing file demo/scripts/xxci.py'
else
echo 'x - demo/scripts/xxci.py'
sed 's/^X//' > 'demo/scripts/xxci.py' << 'EOF'
X#! /ufs/guido/bin/sgi/python
X
X# xxci
X#
X# check in files for which rcsdiff returns nonzero exit status
X
Ximport sys
Ximport posix
Ximport stat
Ximport path
Ximport commands
X
XMAXSIZE = 200*1024 # Files this big must be binaries and are skipped.
X
Xdef getargs():
X args = sys.argv[1:]
X if args:
X return args
X print 'No arguments, checking almost *'
X for file in posix.listdir('.'):
X if not skipfile(file):
X args.append(file)
X if not args:
X print 'Nothing to do -- exit 1'
X sys.exit(1)
X args.sort()
X return args
X
Xbadnames = ['tags', 'xyzzy']
Xbadprefixes = ['.', ',', '@', '#', 'o.']
Xbadsuffixes = \
X ['~', '.a', '.o', '.old', '.bak', '.orig', '.new', '.prev', '.not']
X# XXX Should generalize even more to use fnmatch!
X
Xdef skipfile(file):
X if file in badnames or \
X badprefix(file) or badsuffix(file) or \
X path.islink(file) or path.isdir(file):
X return 1
X # Skip huge files -- probably binaries.
X try:
X st = posix.stat(file)
X except posix.error:
X return 1 # Doesn't exist -- skip it
X return st[stat.ST_SIZE] >= MAXSIZE
X
Xdef badprefix(file):
X for bad in badprefixes:
X if file[:len(bad)] = bad: return 1
X return 0
X
Xdef badsuffix(file):
X for bad in badsuffixes:
X if file[-len(bad):] = bad: return 1
X return 0
X
Xdef go(args):
X for file in args:
X print file + ':'
X if run('rcsdiff -c', file):
X if askyesno('Check in ' + file + ' ? '):
X sts = run('rcs -l', file) # ignored
X # can't use run() here because it's interactive
X sts = posix.system('ci -l ' + file)
X
Xdef run(cmd, file):
X sts, output = commands.getstatusoutput(cmd + commands.mkarg(file))
X if sts:
X print output
X print 'Exit status', sts
X return sts
X
Xdef askyesno(prompt):
X s = raw_input(prompt)
X return s in ['y', 'yes']
X
Xgo(getargs())
EOF
chmod +x 'demo/scripts/xxci.py'
fi
if test -s 'demo/sgi/gl_panel/apanel/apanel.s'
then echo '*** I will not over-write existing file demo/sgi/gl_panel/apanel/apanel.s'
else
echo 'x - demo/sgi/gl_panel/apanel/apanel.s'
sed 's/^X//' > 'demo/sgi/gl_panel/apanel/apanel.s' << 'EOF'
X;;; This file was automatically generated by the panel editor.
X;;; If you read it into gnu emacs, it will automagically format itself.
X
X(panel (prop help creator:user-panel-help)
X(prop user-panel #t)
X(label "Audio Control Panel")
X(x 395)
X(y 69)
X(al (pnl_filled_vslider (name "outputgain")
X(prop help creator:user-act-help)
X(label "output gain")
X(x 6.5)
X(y 0.75)
X(w 0.4)
X(h 4.35)
X(val 0.329)
X(labeltype 13)
X(downfunc move-then-resize)
X)
X(pnl_frame (prop help creator:user-frame-help)
X(x 0.25)
X(y 2.75)
X(w 5.1)
X(h 2.3)
X(downfunc move-then-resize)
X(al (pnl_filled_hslider (name "recordsize")
X(prop help creator:user-act-help)
X(label "recording length")
X(x -0.75)
X(w 3.3)
X(h 0.4)
X(val 0.1)
X(labeltype 11)
X(downfunc move-then-resize)
X)
X(pnl_label (prop help creator:user-act-help)
X(label "(max 10 seconds)")
X(x -0.75)
X(y -0.75)
X(downfunc move-then-resize)
X)
X(pnl_wide_button (name "recordbutton")
X(prop help creator:user-act-help)
X(label "record from microphone...")
X(x -0.75)
X(y 0.75)
X(w 4.7)
X(downfunc move-then-resize)
X)
X)
X)
X(pnl_wide_button (name "playbackbutton")
X(prop help creator:user-act-help)
X(label "playback to speaker")
X(x 0.25)
X(y 2)
X(w 5.15)
X(downfunc move-then-resize)
X)
X(pnl_wide_button (name "quitbutton")
X(prop help creator:user-act-help)
X(label "quit")
X(x 0.25)
X(y 0.25)
X(w 1.75)
X(downfunc move-then-resize)
X)
X)
X)
X;;; Local Variables:
X;;; mode: scheme
X;;; eval: (save-excursion (goto-char (point-min)) (kill-line 3))
X;;; eval: (save-excursion (goto-char (point-min)) (replace-regexp "[ \n]*)" ")"))
X;;; eval: (indent-region (point-min) (point-max) nil)
X;;; eval: (progn (kill-line -3) (delete-backward-char 1) (save-buffer))
X;;; End:
EOF
fi
if test -s 'demo/sgi/gl_panel/flying/light.s'
then echo '*** I will not over-write existing file demo/sgi/gl_panel/flying/light.s'
else
echo 'x - demo/sgi/gl_panel/flying/light.s'
sed 's/^X//' > 'demo/sgi/gl_panel/flying/light.s' << 'EOF'
X;;; This file was automatically generated by the panel editor.
X;;; If you read it into gnu emacs, it will automagically format itself.
X
X(panel (prop help creator:user-panel-help)
X(prop user-panel #t)
X(label "Light Sources")
X(al (pnl_hslider (name "X")
X(prop help creator:user-act-help)
X(label "x")
X(y 4)
X(w 3.3)
X(h 0.4)
X(val 0.50)
X(labeltype 0)
X(downfunc move-then-resize)
X)
X(pnl_hslider (name "Y")
X(prop help creator:user-act-help)
X(label "y")
X(y 3.5)
X(w 3.3)
X(h 0.4)
X(val 0.50)
X(labeltype 0)
X(downfunc move-then-resize)
X)
X(pnl_hslider (name "Z")
X(prop help creator:user-act-help)
X(label "z")
X(y 3)
X(w 3.3)
X(h 0.4)
X(val 0.50)
X(labeltype 0)
X(downfunc move-then-resize)
X)
X(pnl_radio_button (name "light2")
X(prop help creator:user-act-help)
X(label "light 2")
X(x 5)
X(y 4)
X(h 0.36)
X(downfunc move-then-resize)
X)
X(pnl_radio_button (name "light1")
X(prop help creator:user-act-help)
X(label "light 1")
X(x 5)
X(y 4.5)
X(h 0.36)
X(downfunc move-then-resize)
X)
X(pnl_toggle_button (name "local")
X(prop help creator:user-act-help)
X(label "local")
X(x 5)
X(y 2.75)
X(downfunc move-then-resize)
X)
X(pnl_filled_hslider (name "B")
X(prop help creator:user-act-help)
X(label "B")
X(w 3.3)
X(h 0.4)
X(labeltype 0)
X(downfunc move-then-resize)
X)
X(pnl_filled_hslider (name "G")
X(prop help creator:user-act-help)
X(label "G")
X(y 0.5)
X(w 3.3)
X(h 0.4)
X(labeltype 0)
X(downfunc move-then-resize)
X)
X(pnl_filled_hslider (name "R")
X(prop help creator:user-act-help)
X(label "R")
X(y 1)
X(w 3.3)
X(h 0.4)
X(labeltype 0)
X(downfunc move-then-resize)
X)
X)
X)
X;;; Local Variables:
X;;; mode: scheme
X;;; eval: (save-excursion (goto-char (point-min)) (kill-line 3))
X;;; eval: (save-excursion (goto-char (point-min)) (replace-regexp "[ \n]*)" ")"))
X;;; eval: (indent-region (point-min) (point-max) nil)
X;;; eval: (progn (kill-line -3) (delete-backward-char 1) (save-buffer))
X;;; End:
EOF
fi
if test -s 'demo/sgi/gl_panel/flying/panel.s'
then echo '*** I will not over-write existing file demo/sgi/gl_panel/flying/panel.s'
else
echo 'x - demo/sgi/gl_panel/flying/panel.s'
sed 's/^X//' > 'demo/sgi/gl_panel/flying/panel.s' << 'EOF'
X;;; This file was automatically generated by the panel editor.
X;;; If you read it into gnu emacs, it will automagically format itself.
X
X(panel (prop help creator:user-panel-help)
X(prop user-panel #t)
X(label "Panel Control")
X(x 394)
X(y 622)
X(al (pnl_radio_button (name "button4")
X(prop help creator:user-act-help)
X(y 2.5)
X(h 0.36)
X(downfunc move-then-resize)
X)
X(pnl_radio_button (name "button3")
X(prop help creator:user-act-help)
X(y 3)
X(h 0.36)
X(downfunc move-then-resize)
X)
X(pnl_radio_button (name "button2")
X(prop help creator:user-act-help)
X(y 3.5)
X(h 0.36)
X(downfunc move-then-resize)
X)
X(pnl_radio_button (name "button1")
X(prop help creator:user-act-help)
X(y 4)
X(h 0.36)
X(downfunc move-then-resize)
X)
X(pnl_wide_button (name "title1")
X(prop help creator:user-act-help)
X(x 0.75)
X(y 4.75)
X(w 2.44)
X(downfunc move-then-resize)
X)
X(pnl_wide_button (name "title2")
X(prop help creator:user-act-help)
X(x 3.5)
X(y 4.75)
X(w 2.44)
X(downfunc move-then-resize)
X)
X(pnl_wide_button (name "title3")
X(prop help creator:user-act-help)
X(x 6.25)
X(y 4.75)
X(w 2.44)
X(downfunc move-then-resize)
X)
X(pnl_wide_button (name "title4")
X(prop help creator:user-act-help)
X(x 9)
X(y 4.75)
X(w 2.44)
X(downfunc move-then-resize)
X)
X(pnl_button (name "root")
X(prop help creator:user-act-help)
X(label "R")
X(y 4.75)
X(labeltype 16)
X(downfunc move-then-resize)
X)
X)
X)
X;;; Local Variables:
X;;; mode: scheme
X;;; eval: (save-excursion (goto-char (point-min)) (kill-line 3))
X;;; eval: (save-excursion (goto-char (point-min)) (replace-regexp "[ \n]*)" ")"))
X;;; eval: (indent-region (point-min) (point-max) nil)
X;;; eval: (progn (kill-line -3) (delete-backward-char 1) (save-buffer))
X;;; End:
EOF
fi
if test -s 'lib/Abstract.py'
then echo '*** I will not over-write existing file lib/Abstract.py'
else
echo 'x - lib/Abstract.py'
sed 's/^X//' > 'lib/Abstract.py' << 'EOF'
X# Abstract classes for parents and children.
X#
X# Do not use as base class -- this is for documentation only.
X#
X# Note that the tree must be built top down (create the parent,
X# then add the children).
X#
X# Also note that the creation methods are not standardized --
X# these have extra parameters dependent on the widget type.
X# For historical reasons, button creation methods are called
X# define() while split creation methods are called create().
X
Xclass AbstractParent():
X #
X # Upcalls from child to parent
X #
X def addchild(self, child): unimpl()
X def delchild(self, child): unimpl()
X #
X def need_mouse(self, child): unimpl()
X def no_mouse(self, child): unimpl()
X #
X def need_timer(self, child): unimpl()
X def no_timer(self, child): unimpl()
X #
X # XXX need_kbd, no_kbd; focus???
X #
X def begindrawing(self): return unimpl()
X def beginmeasuring(self): return unimpl()
X #
X def change(self, area): unimpl()
X def scroll(self, (area, (dh, dv))): unimpl()
X def settimer(self, itimer): unimpl()
X
Xclass AbstractChild():
X #
X # Downcalls from parent to child
X #
X def destroy(self): unimpl()
X #
X def minsize(self, m): return unimpl()
X def getbounds(self): return unimpl()
X def setbounds(self, bounds): unimpl()
X def draw(self, (d, area)): unimpl()
X #
X # Downcalls only made after certain upcalls
X #
X def mouse_down(self, detail): unimpl()
X def mouse_move(self, detail): unimpl()
X def mouse_up(self, detail): unimpl()
X #
X def timer(self): unimpl()
X
X# A "Split" is a child that manages one or more children.
X# (This terminology is due to DEC SRC, except for CSplits.)
X# A child of a split may be another split, a button, a slider, etc.
X# Certain upcalls and downcalls can be handled transparently, but
X# for others (e.g., all geometry related calls) this is not possible.
X
Xclass AbstractSplit() = AbstractChild(), AbstractParent():
X pass
EOF
fi
if test -s 'lib/StripChart.py'
then echo '*** I will not over-write existing file lib/StripChart.py'
else
echo 'x - lib/StripChart.py'
sed 's/^X//' > 'lib/StripChart.py' << 'EOF'
X# Module 'StripChart'
X
Ximport rect
Xfrom Buttons import LabelAppearance, NoReactivity
X
X# A StripChart doesn't really look like a label but it needs a base class.
X# LabelAppearance allows it to be disabled and hilited.
X
Xclass StripChart() = LabelAppearance(), NoReactivity():
X #
X def define(self, (parent, scale)):
X self.parent = parent
X parent.addchild(self)
X self.init_appearance()
X self.init_reactivity()
X self.ydata = []
X self.scale = scale
X self.resetbounds()
X return self
X #
X def setbounds(self, bounds):
X LabelAppearance.setbounds(self, bounds)
X self.resetbounds()
X #
X def resetbounds(self):
X (left, top), (right, bottom) = self.bounds
X self.width = right-left
X self.height = bottom-top
X excess = len(self.ydata) - self.width
X if excess > 0:
X del self.ydata[:excess]
X elif excess < 0:
X while len(self.ydata) < self.width:
X self.ydata.insert(0, 0)
X #
X def append(self, y):
X self.ydata.append(y)
X excess = len(self.ydata) - self.width
X if excess > 0:
X del self.ydata[:excess]
X if self.bounds <> rect.empty:
X self.parent.scroll(self.bounds, (-excess, 0))
X if self.bounds <> rect.empty:
X (left, top), (right, bottom) = self.bounds
X i = len(self.ydata)
X area = (left+i-1, top), (left+i, bottom)
X self.draw(self.parent.begindrawing(), area)
X #
X def draw(self, (d, area)):
X area = rect.intersect(area, self.bounds)
X if area = rect.empty:
X print 'mt'
X return
X d.cliprect(area)
X d.erase(self.bounds)
X (a_left, a_top), (a_right, a_bottom) = area
X (left, top), (right, bottom) = self.bounds
X height = bottom - top
X i1 = a_left - left
X i2 = a_right - left
X for i in range(max(0, i1), min(len(self.ydata), i2)):
X split = bottom-self.ydata[i]*height/self.scale
X d.paint((left+i, split), (left+i+1, bottom))
X if not self.enabled:
X self.flipenable(d)
X if self.hilited:
X self.fliphilite(d)
X d.noclip()
EOF
fi
if test -s 'lib/cmp.py'
then echo '*** I will not over-write existing file lib/cmp.py'
else
echo 'x - lib/cmp.py'
sed 's/^X//' > 'lib/cmp.py' << 'EOF'
X# Module 'cmp'
X
X# Efficiently compare files, boolean outcome only (equal / not equal).
X
X# Tricks (used in this order):
X# - Files with identical type, size & mtime are assumed to be clones
X# - Files with different type or size cannot be identical
X# - We keep a cache of outcomes of earlier comparisons
X# - We don't fork a process to run 'cmp' but read the files ourselves
X
Ximport posix
X
Xcache = {}
X
Xdef cmp(f1, f2): # Compare two files, use the cache if possible.
X # Return 1 for identical files, 0 for different.
X # Raise exceptions if either file could not be statted, read, etc.
X s1, s2 = sig(posix.stat(f1)), sig(posix.stat(f2))
X if s1[0] <> 8 or s2[0] <> 8:
X # Either is a not a plain file -- always report as different
X return 0
X if s1 = s2:
X # type, size & mtime match -- report same
X return 1
X if s1[:2] <> s2[:2]: # Types or sizes differ, don't bother
X # types or sizes differ -- report different
X return 0
X # same type and size -- look in the cache
X key = f1 + ' ' + f2
X try:
X cs1, cs2, outcome = cache[key]
X # cache hit
X if s1 = cs1 and s2 = cs2:
X # cached signatures match
X return outcome
X # stale cached signature(s)
X except RuntimeError:
X # cache miss
X pass
X # really compare
X outcome = do_cmp(f1, f2)
X cache[key] = s1, s2, outcome
X return outcome
X
Xdef sig(st): # Return signature (i.e., type, size, mtime) from raw stat data
X # 0-5: st_mode, st_ino, st_dev, st_nlink, st_uid, st_gid
X # 6-9: st_size, st_atime, st_mtime, st_ctime
X type = st[0] / 4096
X size = st[6]
X mtime = st[8]
X return type, size, mtime
X
Xdef do_cmp(f1, f2): # Compare two files, really
X bufsize = 8096 # Could be tuned
X fp1 = open(f1, 'r')
X fp2 = open(f2, 'r')
X while 1:
X b1 = fp1.read(bufsize)
X b2 = fp2.read(bufsize)
X if b1 <> b2: return 0
X if not b1: return 1
EOF
fi
if test -s 'lib/commands.py'
then echo '*** I will not over-write existing file lib/commands.py'
else
echo 'x - lib/commands.py'
sed 's/^X//' > 'lib/commands.py' << 'EOF'
X# Module 'commands'
X#
X# Various tools for executing commands and looking at their output and status.
X
Ximport rand
Ximport posix
Ximport stat
Ximport path
X
X
X# Get 'ls -l' status for an object into a string
X#
Xdef getstatus(file):
X return getoutput('ls -ld' + mkarg(file))
X
X
X# Get the output from a shell command into a string.
X# The exit status is ignored; a trailing newline is stripped.
X# Assume the command will work with ' >tempfile 2>&1' appended.
X# XXX This should use posix.popen() instead, should it exist.
X#
Xdef getoutput(cmd):
X return getstatusoutput(cmd)[1]
X
X
X# Ditto but preserving the exit status.
X# Returns a pair (sts, output)
X#
Xdef getstatusoutput(cmd):
X tmp = '/usr/tmp/wdiff' + `rand.rand()`
X sts = -1
X try:
X sts = posix.system(cmd + ' >' + tmp + ' 2>&1')
X text = readfile(tmp)
X finally:
X altsts = posix.system('rm -f ' + tmp)
X if text[-1:] = '\n': text = text[:-1]
X return sts, text
X
X
X# Return a string containing a file's contents.
X#
Xdef readfile(fn):
X st = posix.stat(fn)
X size = st[stat.ST_SIZE]
X if not size: return ''
X try:
X fp = open(fn, 'r')
X except:
X raise posix.error, 'readfile(' + fn + '): open failed'
X try:
X return fp.read(size)
X except:
X raise posix.error, 'readfile(' + fn + '): read failed'
X
X
X# Make command argument from directory and pathname (prefix space, add quotes).
X#
Xdef mk2arg(head, x):
X return mkarg(path.cat(head, x))
X
X
X# Make a shell command argument from a string.
X# Two strategies: enclose in single quotes if it contains none;
X# otherwis, enclose in double quotes and prefix quotable characters
X# with backslash.
X#
Xdef mkarg(x):
X if '\'' not in x:
X return ' \'' + x + '\''
X s = ' "'
X for c in x:
X if c in '\\$"':
X s = s + '\\'
X s = s + c
X s = s + '"'
X return s
EOF
fi
if test -s 'lib/getopt.py'
then echo '*** I will not over-write existing file lib/getopt.py'
else
echo 'x - lib/getopt.py'
sed 's/^X//' > 'lib/getopt.py' << 'EOF'
X# module getopt -- Standard command line processing.
X
X# Function getopt.getopt() has a different interface but provides the
X# same functionality as the Unix getopt() function.
X
X# It has two arguments: the first should be argv[1:] (it doesn't want
X# the script name), the second the string of option letters as passed
X# to Unix getopt() (i.e., a string of allowable option letters, with
X# options requiring an argument followed by a colon).
X
X# It raises the exception getopt.error with a string argument if it
X# detects an error.
X
X# It returns two items:
X# (1) a list of pairs (option, option_argument) giving the options in
X# the order in which they were specified. (I'd use a dictionary
X# but applications may depend on option order or multiple
X# occurrences.) Boolean options have '' as option_argument.
X# (2) the list of remaining arguments (may be empty).
X
Xerror = 'getopt error'
X
Xdef getopt(args, options):
X list = []
X while args and args[0][0] = '-' and args[0] <> '-':
X if args[0] = '--':
X args = args[1:]
X break
X optstring, args = args[0][1:], args[1:]
X while optstring <> '':
X opt, optstring = optstring[0], optstring[1:]
X if classify(opt, options): # May raise exception as well
X if optstring = '':
X if not args:
X raise error, 'option -' + opt + ' requires argument'
X optstring, args = args[0], args[1:]
X optarg, optstring = optstring, ''
X else:
X optarg = ''
X list.append('-' + opt, optarg)
X return list, args
X
Xdef classify(opt, options): # Helper to check type of option
X for i in range(len(options)):
X if opt = options[i] <> ':':
X return options[i+1:i+2] = ':'
X raise error, 'option -' + opt + ' not recognized'
EOF
fi
if test -s 'lib/rect.py'
then echo '*** I will not over-write existing file lib/rect.py'
else
echo 'x - lib/rect.py'
sed 's/^X//' > 'lib/rect.py' << 'EOF'
X# Module 'rect'.
X#
X# Operations on rectangles.
X# There is some normalization: all results return the object 'empty'
X# if their result would contain no points.
X
X
X# Exception.
X#
Xerror = 'rect.error'
X
X
X# The empty rectangle.
X#
Xempty = (0, 0), (0, 0)
X
X
X# Check if a rectangle is empty.
X#
Xdef is_empty((left, top), (right, bottom)):
X return left >= right or top >= bottom
X
X
X# Compute the intersection or two or more rectangles.
X# This works with a list or tuple argument.
X#
Xdef intersect(list):
X if not list: raise error, 'intersect called with empty list'
X if is_empty(list[0]): return empty
X (left, top), (right, bottom) = list[0]
X for rect in list[1:]:
X if is_empty(rect):
X return empty
X (l, t), (r, b) = rect
X if left < l: left = l
X if top < t: top = t
X if right > r: right = r
X if bottom > b: bottom = b
X if is_empty((left, top), (right, bottom)):
X return empty
X return (left, top), (right, bottom)
X
X
X# Compute the smallest rectangle containing all given rectangles.
X# This works with a list or tuple argument.
X#
Xdef union(list):
X (left, top), (right, bottom) = empty
X for (l, t), (r, b) in list[1:]:
X if not is_empty((l, t), (r, b)):
X if l < left: left = l
X if t < top: top = t
X if r > right: right = r
X if b > bottom: bottom = b
X res = (left, top), (right, bottom)
X if is_empty(res):
X return empty
X return res
X
X
X# Check if a point is in a rectangle.
X#
Xdef pointinrect((h, v), ((left, top), (right, bottom))):
X return left <= h < right and top <= v < bottom
X
X
X# Return a rectangle that is dh, dv inside another
X#
Xdef inset(((left, top), (right, bottom)), (dh, dv)):
X left = left + dh
X top = top + dv
X right = right - dh
X bottom = bottom - dv
X r = (left, top), (right, bottom)
X if is_empty(r):
X return empty
X else:
X return r
X
X
X# Conversions between rectangles and 'geometry tuples',
X# given as origin (h, v) and dimensions (width, height).
X#
Xdef rect2geom((left, top), (right, bottom)):
X return (left, top), (right-left, bottom-top)
X
Xdef geom2rect((h, v), (width, height)):
X return (h, v), (h+width, v+height)
EOF
fi
if test -s 'lib/selection.py'
then echo '*** I will not over-write existing file lib/selection.py'
else
echo 'x - lib/selection.py'
sed 's/^X//' > 'lib/selection.py' << 'EOF'
X# DAWKINS' BLIND WATCHMAKER -- "METHINKS IT IS LIKE A WEASEL" EXAMPLE
X#
X# Start with a random phrase. Successively:
X# Breed a next generation by copying with small mutations.
X# Choose the member of the next generation that most closely resembles
X# the target phrase to start breeding the next generation.
X# How many generations will it take before the target is reached?
X
Xfrom whrandom import random
X
X# Parameters determining the problem space
XTarget = 'methinks it is like a weasel'
XAlphabet = ' abcdefghijklmnopqrstuvwxyz'
X
X# Parameters to play with
XGenerationSize = 100
XMutationChance = 1.0/28.0
X
XIndexSet = range(len(Target)) # Used to speed up loops
X
Xdef choice(sequence):
X n = len(sequence)
X i = int(random() * float(n)) % n
X return sequence[i]
X
Xdef random_phrase():
X phrase = ''
X for i in IndexSet:
X phrase = phrase + choice(Alphabet)
X return phrase
X
Xdef mutate_phrase(phrase):
X mutant = phrase
X for i in range(int(0.5 + MutationChance*float(len(phrase)))):
X i = choice(IndexSet)
X c = choice(Alphabet)
X mutant = mutant[:i] + c + mutant[i+1:]
X #print `mutant`
X return mutant
X
Xdef matching_factor(phrase):
X factor = 0
X for i in IndexSet:
X if phrase[i] = Target[i]: factor = factor + 1
X return factor
X
Xdef breed_generation(phrase):
X generation = [phrase]
X while len(generation) < GenerationSize:
X generation.append(mutate_phrase(phrase))
X return generation
X
Xdef select_best(generation):
X factor, selected = -1, ''
X for phrase in generation:
X f = matching_factor(phrase)
X if f > factor:
X factor, selected = f, phrase
X return selected
X
Xdef main():
X gen = 0
X phrase = random_phrase()
X print gen, `phrase`
X while phrase <> Target:
X next_generation = breed_generation(phrase)
X #print next_generation
X phrase = select_best(next_generation)
X gen = gen+1
X print gen, `phrase`
X
Xmain()
EOF
fi
if test -s 'lib/statcache.py'
then echo '*** I will not over-write existing file lib/statcache.py'
else
echo 'x - lib/statcache.py'
sed 's/^X//' > 'lib/statcache.py' << 'EOF'
X# Module 'statcache'
X#
X# Maintain a cache of file stats.
X# There are functions to reset the cache or to selectively remove items.
X
Ximport posix
Xfrom stat import *
X
X# The cache.
X# Keys are pathnames, values are `posix.stat' outcomes.
X#
Xcache = {}
X
X
X# Stat a file, possibly out of the cache.
X#
Xdef stat(path):
X if cache.has_key(path):
X return cache[path]
X cache[path] = ret = posix.stat(path)
X return ret
X
X
X# Reset the cache completely.
X# Hack: to reset a global variable, we import this module.
X#
Xdef reset():
X import statcache
X # Check that we really imported the same module
X if cache is not statcache.cache:
X raise 'sorry, statcache identity crisis'
X statcache.cache = {}
X
X
X# Remove a given item from the cache, if it exists.
X#
Xdef forget(path):
X if cache.has_key(path):
X del cache[path]
X
X
X# Remove all pathnames with a given prefix.
X#
Xdef forget_prefix(prefix):
X n = len(prefix)
X for path in cache.keys():
X if path[:n] = prefix:
X del cache[path]
X
X
X# Forget about a directory and all entries in it, but not about
X# entries in subdirectories.
X#
Xdef forget_dir(prefix):
X if prefix[-1:] = '/' and prefix <> '/':
X prefix = prefix[:-1]
X forget(prefix)
X if prefix[-1:] <> '/':
X prefix = prefix + '/'
X n = len(prefix)
X for path in cache.keys():
X if path[:n] = prefix:
X rest = path[n:]
X if rest[-1:] = '/': rest = rest[:-1]
X if '/' not in rest:
X del cache[path]
X
X
X# Remove all pathnames except with a given prefix.
X# Normally used with prefix = '/' after a chdir().
X#
Xdef forget_except_prefix(prefix):
X n = len(prefix)
X for path in cache.keys():
X if path[:n] <> prefix:
X del cache[path]
X
X
X# Check for directory.
X#
Xdef isdir(path):
X try:
X st = stat(path)
X except posix.error:
X return 0
X return S_ISDIR(st[ST_MODE])
EOF
fi
if test -s 'src/allobjects.h'
then echo '*** I will not over-write existing file src/allobjects.h'
else
echo 'x - src/allobjects.h'
sed 's/^X//' > 'src/allobjects.h' << 'EOF'
X/***********************************************************
XCopyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
XNetherlands.
X
X All Rights Reserved
X
XPermission to use, copy, modify, and distribute this software and its
Xdocumentation for any purpose and without fee is hereby granted,
Xprovided that the above copyright notice appear in all copies and that
Xboth that copyright notice and this permission notice appear in
Xsupporting documentation, and that the names of Stichting Mathematisch
XCentrum or CWI not be used in advertising or publicity pertaining to
Xdistribution of the software without specific, written prior permission.
X
XSTICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
XTHIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
XFITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
XFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
XWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
XACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
XOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
X
X******************************************************************/
X
X/* "allobjects.c" -- Source for precompiled header "allobjects.h" */
X
X#include <stdio.h>
X#include <string.h>
X
X#include "PROTO.h"
X
X#include "object.h"
X#include "objimpl.h"
X
X#include "intobject.h"
X#include "floatobject.h"
X#include "stringobject.h"
X#include "tupleobject.h"
X#include "listobject.h"
X#include "dictobject.h"
X#include "methodobject.h"
X#include "moduleobject.h"
X#include "funcobject.h"
X#include "classobject.h"
X#include "fileobject.h"
X
X#include "errors.h"
X#include "malloc.h"
X
Xextern char *strdup PROTO((const char *));
EOF
fi
if test -s 'src/bitset.h'
then echo '*** I will not over-write existing file src/bitset.h'
else
echo 'x - src/bitset.h'
sed 's/^X//' > 'src/bitset.h' << 'EOF'
X/***********************************************************
XCopyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
XNetherlands.
X
X All Rights Reserved
X
XPermission to use, copy, modify, and distribute this software and its
Xdocumentation for any purpose and without fee is hereby granted,
Xprovided that the above copyright notice appear in all copies and that
Xboth that copyright notice and this permission notice appear in
Xsupporting documentation, and that the names of Stichting Mathematisch
XCentrum or CWI not be used in advertising or publicity pertaining to
Xdistribution of the software without specific, written prior permission.
X
XSTICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
XTHIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
XFITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
XFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
XWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
XACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
XOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
X
X******************************************************************/
X
X/* Bitset interface */
X
X#define BYTE char
X
Xtypedef BYTE *bitset;
X
Xbitset newbitset PROTO((int nbits));
Xvoid delbitset PROTO((bitset bs));
X/* int testbit PROTO((bitset bs, int ibit)); /* Now a macro, see below */
Xint addbit PROTO((bitset bs, int ibit)); /* Returns 0 if already set */
Xint samebitset PROTO((bitset bs1, bitset bs2, int nbits));
Xvoid mergebitset PROTO((bitset bs1, bitset bs2, int nbits));
X
X#define BITSPERBYTE (8*sizeof(BYTE))
X#define NBYTES(nbits) (((nbits) + BITSPERBYTE - 1) / BITSPERBYTE)
X
X#define BIT2BYTE(ibit) ((ibit) / BITSPERBYTE)
X#define BIT2SHIFT(ibit) ((ibit) % BITSPERBYTE)
X#define BIT2MASK(ibit) (1 << BIT2SHIFT(ibit))
X#define BYTE2BIT(ibyte) ((ibyte) * BITSPERBYTE)
X
X#define testbit(ss, ibit) (((ss)[BIT2BYTE(ibit)] & BIT2MASK(ibit)) != 0)
EOF
fi
if test -s 'src/cgensupport.h'
then echo '*** I will not over-write existing file src/cgensupport.h'
else
echo 'x - src/cgensupport.h'
sed 's/^X//' > 'src/cgensupport.h' << 'EOF'
X/***********************************************************
XCopyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
XNetherlands.
X
X All Rights Reserved
X
XPermission to use, copy, modify, and distribute this software and its
Xdocumentation for any purpose and without fee is hereby granted,
Xprovided that the above copyright notice appear in all copies and that
Xboth that copyright notice and this permission notice appear in
Xsupporting documentation, and that the names of Stichting Mathematisch
XCentrum or CWI not be used in advertising or publicity pertaining to
Xdistribution of the software without specific, written prior permission.
X
XSTICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
XTHIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
XFITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
XFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
XWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
XACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
XOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
X
X******************************************************************/
X
X/* Definitions used by cgen output */
X
Xtypedef char *string;
X
X#define mknewlongobject(x) newintobject(x)
X#define mknewshortobject(x) newintobject((long)x)
X#define mknewfloatobject(x) newfloatobject(x)
X
Xextern object *mknewcharobject PROTO((int c));
X
Xextern int getiobjectarg PROTO((object *args, int nargs, int i, object **p_a));
Xextern int getilongarg PROTO((object *args, int nargs, int i, long *p_a));
Xextern int getishortarg PROTO((object *args, int nargs, int i, short *p_a));
Xextern int getifloatarg PROTO((object *args, int nargs, int i, float *p_a));
Xextern int getistringarg PROTO((object *args, int nargs, int i, string *p_a));
EOF
fi
if test -s 'src/classobject.h'
then echo '*** I will not over-write existing file src/classobject.h'
else
echo 'x - src/classobject.h'
sed 's/^X//' > 'src/classobject.h' << 'EOF'
X/***********************************************************
XCopyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
XNetherlands.
X
X All Rights Reserved
X
XPermission to use, copy, modify, and distribute this software and its
Xdocumentation for any purpose and without fee is hereby granted,
Xprovided that the above copyright notice appear in all copies and that
Xboth that copyright notice and this permission notice appear in
Xsupporting documentation, and that the names of Stichting Mathematisch
XCentrum or CWI not be used in advertising or publicity pertaining to
Xdistribution of the software without specific, written prior permission.
X
XSTICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
XTHIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
XFITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
XFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
XWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
XACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
XOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
X
X******************************************************************/
X
X/* Class object interface */
X
X/*
XClasses are really hacked in at the last moment.
XIt should be possible to use other object types as base classes,
Xbut currently it isn't. We'll see if we can fix that later, sigh...
X*/
X
Xextern typeobject Classtype, Classmembertype, Classmethodtype;
X
X#define is_classobject(op) ((op)->ob_type == &Classtype)
X#define is_classmemberobject(op) ((op)->ob_type == &Classmembertype)
X#define is_classmethodobject(op) ((op)->ob_type == &Classmethodtype)
X
Xextern object *newclassobject PROTO((object *, object *));
Xextern object *newclassmemberobject PROTO((object *));
Xextern object *newclassmethodobject PROTO((object *, object *));
X
Xextern object *classmethodgetfunc PROTO((object *));
Xextern object *classmethodgetself PROTO((object *));
EOF
fi
if test -s 'src/compile.h'
then echo '*** I will not over-write existing file src/compile.h'
else
echo 'x - src/compile.h'
sed 's/^X//' > 'src/compile.h' << 'EOF'
X/***********************************************************
XCopyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
XNetherlands.
X
X All Rights Reserved
X
XPermission to use, copy, modify, and distribute this software and its
Xdocumentation for any purpose and without fee is hereby granted,
Xprovided that the above copyright notice appear in all copies and that
Xboth that copyright notice and this permission notice appear in
Xsupporting documentation, and that the names of Stichting Mathematisch
XCentrum or CWI not be used in advertising or publicity pertaining to
Xdistribution of the software without specific, written prior permission.
X
XSTICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
XTHIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
XFITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
XFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
XWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
XACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
XOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
X
X******************************************************************/
X
X/* Definitions for compiled intermediate code */
X
X
X/* An intermediate code fragment contains:
X - a string that encodes the instructions,
X - a list of the constants,
X - and a list of the names used. */
X
Xtypedef struct {
X OB_HEAD
X stringobject *co_code; /* instruction opcodes */
X object *co_consts; /* list of immutable constant objects */
X object *co_names; /* list of stringobjects */
X object *co_filename; /* string */
X} codeobject;
X
Xextern typeobject Codetype;
X
X#define is_codeobject(op) ((op)->ob_type == &Codetype)
X
X
X/* Public interface */
Xcodeobject *compile PROTO((struct _node *, char *));
EOF
fi
if test -s 'src/dictobject.h'
then echo '*** I will not over-write existing file src/dictobject.h'
else
echo 'x - src/dictobject.h'
sed 's/^X//' > 'src/dictobject.h' << 'EOF'
X/***********************************************************
XCopyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
XNetherlands.
X
X All Rights Reserved
X
XPermission to use, copy, modify, and distribute this software and its
Xdocumentation for any purpose and without fee is hereby granted,
Xprovided that the above copyright notice appear in all copies and that
Xboth that copyright notice and this permission notice appear in
Xsupporting documentation, and that the names of Stichting Mathematisch
XCentrum or CWI not be used in advertising or publicity pertaining to
Xdistribution of the software without specific, written prior permission.
X
XSTICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
XTHIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
XFITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
XFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
XWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
XACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
XOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
X
X******************************************************************/
X
X/*
XDictionary object type -- mapping from char * to object.
XNB: the key is given as a char *, not as a stringobject.
XThese functions set errno for errors. Functions dictremove() and
Xdictinsert() return nonzero for errors, getdictsize() returns -1,
Xthe others NULL. A successful call to dictinsert() calls INCREF()
Xfor the inserted item.
X*/
X
Xextern typeobject Dicttype;
X
X#define is_dictobject(op) ((op)->ob_type == &Dicttype)
X
Xextern object *newdictobject PROTO((void));
Xextern object *dictlookup PROTO((object *dp, char *key));
Xextern int dictinsert PROTO((object *dp, char *key, object *item));
Xextern int dictremove PROTO((object *dp, char *key));
Xextern int getdictsize PROTO((object *dp));
Xextern char *getdictkey PROTO((object *dp, int i));
Xextern object *getdictkeys PROTO((object *dp));
EOF
fi
if test -s 'src/errors.h'
then echo '*** I will not over-write existing file src/errors.h'
else
echo 'x - src/errors.h'
sed 's/^X//' > 'src/errors.h' << 'EOF'
X/***********************************************************
XCopyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
XNetherlands.
X
X All Rights Reserved
X
XPermission to use, copy, modify, and distribute this software and its
Xdocumentation for any purpose and without fee is hereby granted,
Xprovided that the above copyright notice appear in all copies and that
Xboth that copyright notice and this permission notice appear in
Xsupporting documentation, and that the names of Stichting Mathematisch
XCentrum or CWI not be used in advertising or publicity pertaining to
Xdistribution of the software without specific, written prior permission.
X
XSTICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
XTHIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
XFITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
XFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
XWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
XACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
XOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
X
X******************************************************************/
X
X/* Error handling definitions */
X
Xvoid err_set PROTO((object *));
Xvoid err_setval PROTO((object *, object *));
Xvoid err_setstr PROTO((object *, char *));
Xint err_occurred PROTO((void));
Xvoid err_get PROTO((object **, object **));
Xvoid err_clear PROTO((void));
X
X/* Predefined exceptions */
X
Xextern object *RuntimeError;
Xextern object *EOFError;
Xextern object *TypeError;
Xextern object *MemoryError;
Xextern object *NameError;
Xextern object *SystemError;
Xextern object *KeyboardInterrupt;
X
X/* Some more planned for the future */
X
X#define IndexError RuntimeError
X#define KeyError RuntimeError
X#define ZeroDivisionError RuntimeError
X#define OverflowError RuntimeError
X
X/* Convenience functions */
X
Xextern int err_badarg PROTO((void));
Xextern object *err_nomem PROTO((void));
Xextern object *err_errno PROTO((object *));
Xextern void err_input PROTO((int));
X
Xextern void err_badcall PROTO((void));
EOF
fi
if test -s 'src/grammar1.c'
then echo '*** I will not over-write existing file src/grammar1.c'
else
echo 'x - src/grammar1.c'
sed 's/^X//' > 'src/grammar1.c' << 'EOF'
X/***********************************************************
XCopyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
XNetherlands.
X
X All Rights Reserved
X
XPermission to use, copy, modify, and distribute this software and its
Xdocumentation for any purpose and without fee is hereby granted,
Xprovided that the above copyright notice appear in all copies and that
Xboth that copyright notice and this permission notice appear in
Xsupporting documentation, and that the names of Stichting Mathematisch
XCentrum or CWI not be used in advertising or publicity pertaining to
Xdistribution of the software without specific, written prior permission.
X
XSTICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
XTHIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
XFITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
XFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
XWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
XACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
XOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
X
X******************************************************************/
X
X/* Grammar subroutines needed by parser */
X
X#include "pgenheaders.h"
X#include "assert.h"
X#include "grammar.h"
X#include "token.h"
X
X/* Return the DFA for the given type */
X
Xdfa *
Xfinddfa(g, type)
X grammar *g;
X register int type;
X{
X register int i;
X register dfa *d;
X
X for (i = g->g_ndfas, d = g->g_dfa; --i >= 0; d++) {
X if (d->d_type == type)
X return d;
X }
X assert(0);
X /* NOTREACHED */
X}
X
Xchar *
Xlabelrepr(lb)
X label *lb;
X{
X static char buf[100];
X
X if (lb->lb_type == ENDMARKER)
X return "EMPTY";
X else if (ISNONTERMINAL(lb->lb_type)) {
X if (lb->lb_str == NULL) {
X sprintf(buf, "NT%d", lb->lb_type);
X return buf;
X }
X else
X return lb->lb_str;
X }
X else {
X if (lb->lb_str == NULL)
X return tok_name[lb->lb_type];
X else {
X sprintf(buf, "%.32s(%.32s)",
X tok_name[lb->lb_type], lb->lb_str);
X return buf;
X }
X }
X}
EOF
fi
if test -s 'src/malloc.h'
then echo '*** I will not over-write existing file src/malloc.h'
else
echo 'x - src/malloc.h'
sed 's/^X//' > 'src/malloc.h' << 'EOF'
X/***********************************************************
XCopyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
XNetherlands.
X
X All Rights Reserved
X
XPermission to use, copy, modify, and distribute this software and its
Xdocumentation for any purpose and without fee is hereby granted,
Xprovided that the above copyright notice appear in all copies and that
Xboth that copyright notice and this permission notice appear in
Xsupporting documentation, and that the names of Stichting Mathematisch
XCentrum or CWI not be used in advertising or publicity pertaining to
Xdistribution of the software without specific, written prior permission.
X
XSTICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
XTHIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
XFITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
XFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
XWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
XACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
XOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
X
X******************************************************************/
X
X/* Lowest-level memory allocation interface */
X
X#ifdef THINK_C
X#define ANY void
X#ifndef THINK_C_3_0
X#define HAVE_STDLIB
X#endif
X#endif
X
X#ifdef __STD_C__
X#define ANY void
X#define HAVE_STDLIB
X#endif
X
X#ifndef ANY
X#define ANY char
X#endif
X
X#ifndef NULL
X#define NULL 0
X#endif
X
X#define NEW(type, n) ( (type *) malloc((n) * sizeof(type)) )
X#define RESIZE(p, type, n) \
X if ((p) == NULL) \
X (p) = (type *) malloc((n) * sizeof(type)); \
X else \
X (p) = (type *) realloc((char *)(p), (n) * sizeof(type))
X#define DEL(p) free((char *)p)
X#define XDEL(p) if ((p) == NULL) ; else DEL(p)
X
X#ifdef HAVE_STDLIB
X#include <stdlib.h>
X#else
Xextern ANY *malloc PROTO((unsigned int));
Xextern ANY *calloc PROTO((unsigned int, unsigned int));
Xextern ANY *realloc PROTO((ANY *, unsigned int));
Xextern void free PROTO((ANY *)); /* XXX sometimes int on Unix old systems */
X#endif
EOF
fi
if test -s 'src/node.h'
then echo '*** I will not over-write existing file src/node.h'
else
echo 'x - src/node.h'
sed 's/^X//' > 'src/node.h' << 'EOF'
X/***********************************************************
XCopyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
XNetherlands.
X
X All Rights Reserved
X
XPermission to use, copy, modify, and distribute this software and its
Xdocumentation for any purpose and without fee is hereby granted,
Xprovided that the above copyright notice appear in all copies and that
Xboth that copyright notice and this permission notice appear in
Xsupporting documentation, and that the names of Stichting Mathematisch
XCentrum or CWI not be used in advertising or publicity pertaining to
Xdistribution of the software without specific, written prior permission.
X
XSTICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
XTHIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
XFITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
XFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
XWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
XACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
XOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
X
X******************************************************************/
X
X/* Parse tree node interface */
X
Xtypedef struct _node {
X int n_type;
X char *n_str;
X int n_lineno;
X int n_nchildren;
X struct _node *n_child;
X} node;
X
Xextern node *newtree PROTO((int type));
Xextern node *addchild PROTO((node *n, int type, char *str, int lineno));
Xextern void freetree PROTO((node *n));
X
X/* Node access functions */
X#define NCH(n) ((n)->n_nchildren)
X#define CHILD(n, i) (&(n)->n_child[i])
X#define TYPE(n) ((n)->n_type)
X#define STR(n) ((n)->n_str)
X
X/* Assert that the type of a node is what we expect */
X#ifndef DEBUG
X#define REQ(n, type) { /*pass*/ ; }
X#else
X#define REQ(n, type) \
X { if (TYPE(n) != (type)) { \
X fprintf(stderr, "FATAL: node type %d, required %d\n", \
X TYPE(n), type); \
X abort(); \
X } }
X#endif
X
Xextern void listtree PROTO((node *));
Xextern void listnode PROTO((FILE *, node *));
EOF
fi
if test -s 'src/parser.h'
then echo '*** I will not over-write existing file src/parser.h'
else
echo 'x - src/parser.h'
sed 's/^X//' > 'src/parser.h' << 'EOF'
X/***********************************************************
XCopyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
XNetherlands.
X
X All Rights Reserved
X
XPermission to use, copy, modify, and distribute this software and its
Xdocumentation for any purpose and without fee is hereby granted,
Xprovided that the above copyright notice appear in all copies and that
Xboth that copyright notice and this permission notice appear in
Xsupporting documentation, and that the names of Stichting Mathematisch
XCentrum or CWI not be used in advertising or publicity pertaining to
Xdistribution of the software without specific, written prior permission.
X
XSTICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
XTHIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
XFITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
XFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
XWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
XACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
XOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
X
X******************************************************************/
X
X/* Parser interface */
X
X#define MAXSTACK 100
X
Xtypedef struct _stackentry {
X int s_state; /* State in current DFA */
X dfa *s_dfa; /* Current DFA */
X struct _node *s_parent; /* Where to add next node */
X} stackentry;
X
Xtypedef struct _stack {
X stackentry *s_top; /* Top entry */
X stackentry s_base[MAXSTACK];/* Array of stack entries */
X /* NB The stack grows down */
X} stack;
X
Xtypedef struct {
X struct _stack p_stack; /* Stack of parser states */
X struct _grammar *p_grammar; /* Grammar to use */
X struct _node *p_tree; /* Top of parse tree */
X} parser_state;
X
Xparser_state *newparser PROTO((struct _grammar *g, int start));
Xvoid delparser PROTO((parser_state *ps));
Xint addtoken PROTO((parser_state *ps, int type, char *str, int lineno));
Xvoid addaccelerators PROTO((grammar *g));
EOF
fi
if test -s 'src/pgenheaders.h'
then echo '*** I will not over-write existing file src/pgenheaders.h'
else
echo 'x - src/pgenheaders.h'
sed 's/^X//' > 'src/pgenheaders.h' << 'EOF'
X/***********************************************************
XCopyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
XNetherlands.
X
X All Rights Reserved
X
XPermission to use, copy, modify, and distribute this software and its
Xdocumentation for any purpose and without fee is hereby granted,
Xprovided that the above copyright notice appear in all copies and that
Xboth that copyright notice and this permission notice appear in
Xsupporting documentation, and that the names of Stichting Mathematisch
XCentrum or CWI not be used in advertising or publicity pertaining to
Xdistribution of the software without specific, written prior permission.
X
XSTICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
XTHIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
XFITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
XFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
XWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
XACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
XOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
X
X******************************************************************/
X
X/* Include files and extern declarations used by most of the parser.
X This is a precompiled header for THINK C. */
X
X#include <stdio.h>
X#include <string.h>
X
X#ifdef THINK_C
X/* #define THINK_C_3_0 /*** TURN THIS ON FOR THINK C 3.0 ****/
X#define label label_
X#undef label
X#endif
X
X#ifdef THINK_C_3_0
X#include <proto.h>
X#endif
X
X#ifdef THINK_C
X#ifndef THINK_C_3_0
X#include <stdlib.h>
X#endif
X#endif
X
X#include "PROTO.h"
X#include "malloc.h"
X
Xextern void fatal PROTO((char *));
EOF
fi
if test -s 'src/pythonrun.h'
then echo '*** I will not over-write existing file src/pythonrun.h'
else
echo 'x - src/pythonrun.h'
sed 's/^X//' > 'src/pythonrun.h' << 'EOF'
X/***********************************************************
XCopyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
XNetherlands.
X
X All Rights Reserved
X
XPermission to use, copy, modify, and distribute this software and its
Xdocumentation for any purpose and without fee is hereby granted,
Xprovided that the above copyright notice appear in all copies and that
Xboth that copyright notice and this permission notice appear in
Xsupporting documentation, and that the names of Stichting Mathematisch
XCentrum or CWI not be used in advertising or publicity pertaining to
Xdistribution of the software without specific, written prior permission.
X
XSTICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
XTHIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
XFITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
XFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
XWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
XACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
XOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
X
X******************************************************************/
X
X/* Interfaces to parse and execute pieces of python code */
X
Xvoid initall PROTO((void));
X
Xint run PROTO((FILE *, char *));
X
Xint run_script PROTO((FILE *, char *));
Xint run_tty_1 PROTO((FILE *, char *));
Xint run_tty_loop PROTO((FILE *, char *));
X
Xint parse_string PROTO((char *, int, struct _node **));
Xint parse_file PROTO((FILE *, char *, int, struct _node **));
X
Xobject *eval_node PROTO((struct _node *, char *, object *, object *));
X
Xobject *run_string PROTO((char *, int, object *, object *));
Xobject *run_file PROTO((FILE *, char *, int, object *, object *));
Xobject *run_err_node PROTO((int, struct _node *, char *, object *, object *));
Xobject *run_node PROTO((struct _node *, char *, object *, object *));
X
Xvoid print_error PROTO((void));
X
Xvoid goaway PROTO((int));
EOF
fi
if test -s 'src/regexp.h'
then echo '*** I will not over-write existing file src/regexp.h'
else
echo 'x - src/regexp.h'
sed 's/^X//' > 'src/regexp.h' << 'EOF'
X/***********************************************************
XCopyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
XNetherlands.
X
X All Rights Reserved
X
XPermission to use, copy, modify, and distribute this software and its
Xdocumentation for any purpose and without fee is hereby granted,
Xprovided that the above copyright notice appear in all copies and that
Xboth that copyright notice and this permission notice appear in
Xsupporting documentation, and that the names of Stichting Mathematisch
XCentrum or CWI not be used in advertising or publicity pertaining to
Xdistribution of the software without specific, written prior permission.
X
XSTICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
XTHIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
XFITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
XFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
XWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
XACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
XOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
X
X******************************************************************/
X
X/*
X * Definitions etc. for regexp(3) routines.
X *
X * Caveat: this is V8 regexp(3) [actually, a reimplementation thereof],
X * not the System V one.
X */
X
X#define MULTILINE
X
X#define NSUBEXP 10
Xtypedef struct regexp {
X char *startp[NSUBEXP];
X char *endp[NSUBEXP];
X char regstart; /* Internal use only. */
X char reganch; /* Internal use only. */
X char *regmust; /* Internal use only. */
X int regmlen; /* Internal use only. */
X char program[1]; /* Unwarranted chumminess with compiler. */
X} regexp;
X
Xextern regexp *regcomp();
Xextern int regexec();
X#ifdef MULTILINE
Xextern int reglexec();
X#endif
Xextern void regsub();
Xextern void regerror();
EOF
fi
if test -s 'src/sigtype.h'
then echo '*** I will not over-write existing file src/sigtype.h'
else
echo 'x - src/sigtype.h'
sed 's/^X//' > 'src/sigtype.h' << 'EOF'
X/***********************************************************
XCopyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
XNetherlands.
X
X All Rights Reserved
X
XPermission to use, copy, modify, and distribute this software and its
Xdocumentation for any purpose and without fee is hereby granted,
Xprovided that the above copyright notice appear in all copies and that
Xboth that copyright notice and this permission notice appear in
Xsupporting documentation, and that the names of Stichting Mathematisch
XCentrum or CWI not be used in advertising or publicity pertaining to
Xdistribution of the software without specific, written prior permission.
X
XSTICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
XTHIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
XFITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
XFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
XWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
XACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
XOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
X
X******************************************************************/
X
X/* The type of signal handlers is somewhat problematic.
X This file encapsulates my knowledge about it:
X - on the Mac (THINK C), it's int for 3.0, void for 4.0
X - on other systems, it's usually void, except it's int on vax Ultrix.
X Pass -DSIGTYPE=... to cc if you know better. */
X
X#ifndef SIGTYPE
X
X#ifdef THINK_C
X
X#ifdef THINK_C_3_0
X#define SIGTYPE int
X#else
X#define SIGTYPE void
X#endif
X
X#else /* !THINK_C */
X
X#if defined(vax) && !defined(AMOEBA)
X#define SIGTYPE int
X#else
X#define SIGTYPE void
X#endif
X
X#endif /* !THINK_C */
X
X#endif /* !SIGTYPE */
EOF
fi
if test -s 'src/token.h'
then echo '*** I will not over-write existing file src/token.h'
else
echo 'x - src/token.h'
sed 's/^X//' > 'src/token.h' << 'EOF'
X/***********************************************************
XCopyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
XNetherlands.
X
X All Rights Reserved
X
XPermission to use, copy, modify, and distribute this software and its
Xdocumentation for any purpose and without fee is hereby granted,
Xprovided that the above copyright notice appear in all copies and that
Xboth that copyright notice and this permission notice appear in
Xsupporting documentation, and that the names of Stichting Mathematisch
XCentrum or CWI not be used in advertising or publicity pertaining to
Xdistribution of the software without specific, written prior permission.
X
XSTICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
XTHIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
XFITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
XFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
XWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
XACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
XOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
X
X******************************************************************/
X
X/* Token types */
X
X#define ENDMARKER 0
X#define NAME 1
X#define NUMBER 2
X#define STRING 3
X#define NEWLINE 4
X#define INDENT 5
X#define DEDENT 6
X#define LPAR 7
X#define RPAR 8
X#define LSQB 9
X#define RSQB 10
X#define COLON 11
X#define COMMA 12
X#define SEMI 13
X#define PLUS 14
X#define MINUS 15
X#define STAR 16
X#define SLASH 17
X#define VBAR 18
X#define AMPER 19
X#define LESS 20
X#define GREATER 21
X#define EQUAL 22
X#define DOT 23
X#define PERCENT 24
X#define BACKQUOTE 25
X#define LBRACE 26
X#define RBRACE 27
X#define OP 28
X#define ERRORTOKEN 29
X#define N_TOKENS 30
X
X/* Special definitions for cooperation with parser */
X
X#define NT_OFFSET 256
X
X#define ISTERMINAL(x) ((x) < NT_OFFSET)
X#define ISNONTERMINAL(x) ((x) >= NT_OFFSET)
X#define ISEOF(x) ((x) == ENDMARKER)
X
X
Xextern char *tok_name[]; /* Token names */
Xextern int tok_1char PROTO((int));
EOF
fi
if test -s 'src/typeobject.c'
then echo '*** I will not over-write existing file src/typeobject.c'
else
echo 'x - src/typeobject.c'
sed 's/^X//' > 'src/typeobject.c' << 'EOF'
X/***********************************************************
XCopyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
XNetherlands.
X
X All Rights Reserved
X
XPermission to use, copy, modify, and distribute this software and its
Xdocumentation for any purpose and without fee is hereby granted,
Xprovided that the above copyright notice appear in all copies and that
Xboth that copyright notice and this permission notice appear in
Xsupporting documentation, and that the names of Stichting Mathematisch
XCentrum or CWI not be used in advertising or publicity pertaining to
Xdistribution of the software without specific, written prior permission.
X
XSTICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
XTHIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
XFITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
XFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
XWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
XACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
XOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
X
X******************************************************************/
X
X/* Type object implementation */
X
X#include "allobjects.h"
X
X/* Type object implementation */
X
Xstatic void
Xtype_print(v, fp, flags)
X typeobject *v;
X FILE *fp;
X int flags;
X{
X fprintf(fp, "<type '%s'>", v->tp_name);
X}
X
Xstatic object *
Xtype_repr(v)
X typeobject *v;
X{
X char buf[100];
X sprintf(buf, "<type '%.80s'>", v->tp_name);
X return newstringobject(buf);
X}
X
Xtypeobject Typetype = {
X OB_HEAD_INIT(&Typetype)
X 0, /* Number of items for varobject */
X "type", /* Name of this type */
X sizeof(typeobject), /* Basic object size */
X 0, /* Item size for varobject */
X 0, /*tp_dealloc*/
X type_print, /*tp_print*/
X 0, /*tp_getattr*/
X 0, /*tp_setattr*/
X 0, /*tp_compare*/
X type_repr, /*tp_repr*/
X};
EOF
fi
echo 'Part 19 out of 21 of pack.out complete.'
exit 0
|