home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2814 < prev    next >
Encoding:
Internet Message Format  |  1991-02-20  |  60.7 KB

  1. From: guido@cwi.nl (Guido van Rossum)
  2. Newsgroups: alt.sources
  3. Subject: Python 0.9.1 part 20/21
  4. Message-ID: <2982@charon.cwi.nl>
  5. Date: 19 Feb 91 17:42:54 GMT
  6.  
  7. : This is a shell archive.
  8. : Extract with 'sh this_file'.
  9. :
  10. : Extract part 01 first since it makes all directories
  11. echo 'Start of pack.out, part 20 out of 21:'
  12. if test -s 'demo/scripts/mkreal.py'
  13. then echo '*** I will not over-write existing file demo/scripts/mkreal.py'
  14. else
  15. echo 'x - demo/scripts/mkreal.py'
  16. sed 's/^X//' > 'demo/scripts/mkreal.py' << 'EOF'
  17. X#! /ufs/guido/bin/sgi/python
  18. X
  19. X# mkreal
  20. X#
  21. X# turn a symlink to a directory into a real directory
  22. X
  23. Ximport sys
  24. Ximport posix
  25. Ximport path
  26. Xfrom stat import *
  27. X
  28. Xcat = path.cat
  29. X
  30. Xerror = 'mkreal error'
  31. X
  32. XBUFSIZE = 32*1024
  33. X
  34. Xdef mkrealfile(name):
  35. X    st = posix.stat(name) # Get the mode
  36. X    mode = S_IMODE(st[ST_MODE])
  37. X    linkto = posix.readlink(name) # Make sure again it's a symlink
  38. X    f_in = open(name, 'r') # This ensures it's a file
  39. X    posix.unlink(name)
  40. X    f_out = open(name, 'w')
  41. X    while 1:
  42. X        buf = f_in.read(BUFSIZE)
  43. X        if not buf: break
  44. X        f_out.write(buf)
  45. X    del f_out # Flush data to disk before changing mode
  46. X    posix.chmod(name, mode)
  47. X
  48. Xdef mkrealdir(name):
  49. X    st = posix.stat(name) # Get the mode
  50. X    mode = S_IMODE(st[ST_MODE])
  51. X    linkto = posix.readlink(name)
  52. X    files = posix.listdir(name)
  53. X    posix.unlink(name)
  54. X    posix.mkdir(name, mode)
  55. X    posix.chmod(name, mode)
  56. X    linkto = cat('..', linkto)
  57. X    #
  58. X    for file in files:
  59. X        if file not in ('.', '..'):
  60. X            posix.symlink(cat(linkto, file), cat(name, file))
  61. X
  62. Xdef main():
  63. X    sys.stdout = sys.stderr
  64. X    progname = path.basename(sys.argv[0])
  65. X    args = sys.argv[1:]
  66. X    if not args:
  67. X        print 'usage:', progname, 'path ...'
  68. X        sys.exit(2)
  69. X    status = 0
  70. X    for name in args:
  71. X        if not path.islink(name):
  72. X            print progname+':', name+':', 'not a symlink'
  73. X            status = 1
  74. X        else:
  75. X            if path.isdir(name):
  76. X                mkrealdir(name)
  77. X            else:
  78. X                mkrealfile(name)
  79. X    sys.exit(status)
  80. X
  81. Xmain()
  82. EOF
  83. chmod +x 'demo/scripts/mkreal.py'
  84. fi
  85. if test -s 'demo/scripts/ptags.py'
  86. then echo '*** I will not over-write existing file demo/scripts/ptags.py'
  87. else
  88. echo 'x - demo/scripts/ptags.py'
  89. sed 's/^X//' > 'demo/scripts/ptags.py' << 'EOF'
  90. X#! /ufs/guido/bin/sgi/python
  91. X
  92. X# ptags
  93. X#
  94. XCreate a tags file for Python programs
  95. X# Tagged are:
  96. X# - functions (even inside other defs or classes)
  97. X# - classes
  98. X# - filenames
  99. X# Warns about files it cannot open.
  100. X# No warnings about duplicate tags.
  101. X
  102. Ximport sys
  103. Ximport posix
  104. Ximport path
  105. Ximport string
  106. X
  107. Xkeywords = ['def', 'class']    # If you add keywords, update starts!!!
  108. Xstarts = 'dc'            # Starting characters of keywords
  109. X
  110. Xwhitespace = string.whitespace
  111. Xidentchars = string.letters + string.digits + '_'
  112. X
  113. Xtags = []    # Modified!
  114. X
  115. Xdef main():
  116. X    args = sys.argv[1:]
  117. X    for file in args: treat_file(file)
  118. X    if tags:
  119. X        fp = open('tags', 'w')
  120. X        tags.sort()
  121. X        for s in tags: fp.write(s)
  122. X
  123. Xdef treat_file(file):
  124. X    try:
  125. X        fp = open(file, 'r')
  126. X    except:
  127. X        print 'Cannot open', file
  128. X        return
  129. X    base = path.basename(file)
  130. X    if base[-3:] = '.py': base = base[:-3]
  131. X    s = base + '\t' + file + '\t' + '1\n'
  132. X    tags.append(s)
  133. X    while 1:
  134. X        line = fp.readline()
  135. X        if not line: break
  136. X        maketag(line, file)
  137. X
  138. Xdef maketag(line, file):
  139. X    i = 0
  140. X    while line[i:i+1] in whitespace: i = i+1
  141. X    if line[i:i+1] not in starts: return
  142. X    n = len(line)
  143. X    j = i
  144. X    while i < n and line[i] not in whitespace: i = i+1
  145. X    if line[j:i] not in keywords: return
  146. X    while i < n and line[i] in whitespace: i = i+1
  147. X    j = i
  148. X    while i < n and line[i] in identchars: i = i+1
  149. X    name = line[j:i]
  150. X    while i < n and line[i] in whitespace: i = i+1
  151. X    if i < n and line[i] = '(': i = i+1
  152. X    s = name + '\t' + file + '\t' + '/^' + line[:i] + '/\n'
  153. X    tags.append(s)
  154. X
  155. Xmain()
  156. EOF
  157. chmod +x 'demo/scripts/ptags.py'
  158. fi
  159. if test -s 'demo/sgi/audio/play.py'
  160. then echo '*** I will not over-write existing file demo/sgi/audio/play.py'
  161. else
  162. echo 'x - demo/sgi/audio/play.py'
  163. sed 's/^X//' > 'demo/sgi/audio/play.py' << 'EOF'
  164. X#!/ufs/guido/bin/sgi/python
  165. X
  166. Ximport sys
  167. Ximport audio
  168. X
  169. Ximport string
  170. Ximport getopt
  171. Ximport auds
  172. X
  173. Xdebug = []
  174. X
  175. XDEF_RATE = 3
  176. X
  177. Xdef main():
  178. X    #
  179. X    gain = 100
  180. X    rate = 0
  181. X    starter = audio.write
  182. X    stopper = 0
  183. X    #
  184. X    optlist, args = getopt.getopt(sys.argv[1:], 'adg:r:')
  185. X    #
  186. X    for optname, optarg in optlist:
  187. X        if 0:
  188. X            pass
  189. X        elif optname = '-d':
  190. X            debug.append(1)
  191. X        elif optname = '-g':
  192. X            gain = string.atoi(optarg)
  193. X            if not (0 < gain < 256):
  194. X                raise optarg.error, '-g gain out of range'
  195. X        elif optname = '-r':
  196. X            rate = string.atoi(optarg)
  197. X            if not (1 <= rate <= 3):
  198. X                raise optarg.error, '-r rate out of range'
  199. X        elif optname = '-a':
  200. X            starter = audio.start_playing
  201. X            stopper = audio.wait_playing
  202. X    #
  203. X    audio.setoutgain(gain)
  204. X    audio.setrate(rate)
  205. X    #
  206. X    if not args:
  207. X        play(starter, rate, auds.loadfp(sys.stdin))
  208. X    else:
  209. X        real_stopper = 0
  210. X        for file in args:
  211. X            if real_stopper:
  212. X                real_stopper()
  213. X            play(starter, rate, auds.load(file))
  214. X            real_stopper = stopper
  215. X
  216. Xdef play(starter, rate, data):
  217. X    magic = data[:4]
  218. X    if magic = '0008':
  219. X        mrate = 3
  220. X    elif magic = '0016':
  221. X        mrate = 2
  222. X    elif magic = '0032':
  223. X        mrate = 1
  224. X    else:
  225. X        mrate = 0
  226. X    if mrate:
  227. X        data = data[4:]
  228. X    else:
  229. X        mrate = DEF_RATE
  230. X    if not rate: rate = mrate
  231. X    audio.setrate(rate)
  232. X    starter(data)
  233. X
  234. Xtry:
  235. X    main()
  236. Xfinally:
  237. X    audio.setoutgain(0)
  238. X    audio.done()
  239. EOF
  240. chmod +x 'demo/sgi/audio/play.py'
  241. fi
  242. if test -s 'demo/sgi/gl_panel/flying/data.py'
  243. then echo '*** I will not over-write existing file demo/sgi/gl_panel/flying/data.py'
  244. else
  245. echo 'x - demo/sgi/gl_panel/flying/data.py'
  246. sed 's/^X//' > 'demo/sgi/gl_panel/flying/data.py' << 'EOF'
  247. X
  248. X# two string constants
  249. XARROW = '-> '
  250. XNULL = ''
  251. XZERO = 0
  252. XONE = 1
  253. X
  254. X#
  255. X# the color light-blue
  256. X#
  257. Xlightblue = (43,169,255)
  258. X
  259. X
  260. X#
  261. X# a couple of rotation, translation, scaling vectors
  262. X#
  263. Xrts1 = [[3.0,3.1,2.0],[2.2, 1.2, 2.0], [0.8,0.8,0.8]]
  264. Xrts2 = [[3.2,2.6,1.8],[-1.9, 1.2, 1.6], [0.3,0.3,1.0]]
  265. Xrts3 = [[2.2,3.3,1.4], [-1.0, 1.2,-1.5], [0.6,0.6, 0.6]]
  266. Xrts4 = [[4.2,2.1,3.2],[1.2, 1.3, 1.0],[0.5,0.5,0.8]]
  267. Xrts5 = [[1.2,3.3,2.4], [-2.0, 1.4,-2.1], [0.8, 0.8, 0.2]]
  268. Xrts6 = [[3.2,3.6,2.4], [1.1, 1.6, 2.5], [0.8,0.3,0.1]]
  269. Xrts7 = [[2.3,2.7,3.3], [1.1, 2.3, 1.7], [0.6,0.6,0.5]]
  270. Xrts8 = [[4.2,2.1,3.2], [1.2, 1.3, 0.0], [0.5,0.5,0.5]]
  271. X#
  272. Xrts90 = [[4.2,2.1,3.2], [2.0, 0.0, 0.9], [0.3,0.3,1.0]]
  273. Xrts91 = [[4.2,2.1,3.2], [-2.0, 0.0, 0.9], [0.3,0.3,1.0]]
  274. Xrts92 = [[4.2,2.1,3.2], [0.0, 2.0, 0.9], [0.3,0.3,1.0]]
  275. Xrts93 = [[4.2,2.1,3.2], [0.0, -2.0, 0.9], [0.3,0.3,1.0]]
  276. Xrts10 = [[4.2,2.1,3.2], [0.0, 0.0, 0.0], [2.2,2.2,0.2]]
  277. X
  278. X#
  279. X# (composite) object definitions
  280. X#
  281. Xo1 = [['sphere',rts1, 1]]
  282. Xo2 = [['cylinder', rts2, 4]]
  283. Xo3 = [['cube', rts3, 3]]
  284. Xo4 = [['cone', rts4, 2], ['sphere', rts8, 9]]
  285. Xo5 = [['sphere', rts5, 5]]
  286. Xo6 = [['cube', rts6, 6]]
  287. Xo7 = [['pyramid', rts7, 8]]
  288. Xo8 = [['cube', rts10, 9], ['cylinder', rts90, 2], ['cylinder', rts91, 2], ['cylinder', rts92, 2], ['cylinder', rts93, 2]]
  289. EOF
  290. fi
  291. if test -s 'demo/sgi/gl_panel/nurbs/nurbsdata.py'
  292. then echo '*** I will not over-write existing file demo/sgi/gl_panel/nurbs/nurbsdata.py'
  293. else
  294. echo 'x - demo/sgi/gl_panel/nurbs/nurbsdata.py'
  295. sed 's/^X//' > 'demo/sgi/gl_panel/nurbs/nurbsdata.py' << 'EOF'
  296. X# Data used by fancy nurbs demo.
  297. X
  298. XTRUE = 1
  299. XFALSE = 0
  300. X
  301. XRED = 0xff
  302. XYELLOW = 0xffff
  303. X
  304. X#
  305. X# nurb order
  306. X#
  307. XORDER = 4
  308. X
  309. X#
  310. X# identity matrix
  311. X#
  312. Xidmat = [1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1]
  313. X
  314. X#
  315. X# s and t knots
  316. X#
  317. Xsurfknots = [-1, -1, -1, -1, 1, 1, 1, 1]
  318. X
  319. X#
  320. X# list of list of control points
  321. X#
  322. Xdef make_ctlpoints():
  323. X    c = []
  324. X    #
  325. X    ci = []
  326. X    ci.append(-2.5,  -3.7,  1.0)
  327. X    ci.append(-1.5,  -3.7,  3.0)
  328. X    ci.append(1.5,  -3.7, -2.5)
  329. X    ci.append(2.5,  -3.7,  -0.75)
  330. X    c.append(ci)
  331. X    #
  332. X    ci = []
  333. X    ci.append(-2.5,  -2.0,  3.0)
  334. X    ci.append(-1.5,  -2.0,  4.0)
  335. X    ci.append(1.5,  -2.0,  -3.0)
  336. X    ci.append(2.5,  -2.0,  0.0)
  337. X    c.append(ci)
  338. X    #
  339. X    ci = []
  340. X    ci.append(-2.5, 2.0,  1.0)
  341. X    ci.append(-1.5, 2.0,  0.0)
  342. X    ci.append(1.5,  2.0,  -1.0)
  343. X    ci.append(2.5,  2.0,  2.0)
  344. X    c.append(ci)
  345. X    #
  346. X    ci = []
  347. X    ci.append(-2.5,  2.7,  1.25)
  348. X    ci.append(-1.5,  2.7,  0.1)
  349. X    ci.append(1.5,  2.7,  -0.6)
  350. X    ci.append(2.5,  2.7,  0.2)
  351. X    c.append(ci)
  352. X    #
  353. X    return c
  354. X
  355. Xctlpoints = make_ctlpoints ()
  356. X
  357. X#
  358. X# trim knots
  359. X#
  360. Xtrimknots = [0., 0., 0.,  1., 1.,  2., 2.,  3., 3.,   4., 4., 4.]
  361. X
  362. Xdef make_trimpoints():
  363. X    c = []
  364. X    #
  365. X    c.append(1.0, 0.0, 1.0)
  366. X    c.append(1.0, 1.0, 1.0)
  367. X    c.append(0.0, 2.0, 2.0)
  368. X    c.append(-1.0, 1.0, 1.0)
  369. X    c.append(-1.0, 0.0, 1.0)
  370. X    c.append(-1.0, -1.0, 1.0)
  371. X    c.append(0.0, -2.0, 2.0)
  372. X    c.append(1.0, -1.0, 1.0) 
  373. X    c.append(1.0, 0.0, 1.0)
  374. X    #
  375. X    return c
  376. X
  377. Xtrimpoints = make_trimpoints()
  378. EOF
  379. fi
  380. if test -s 'demo/sgi/gl_panel/twoview/block.py'
  381. then echo '*** I will not over-write existing file demo/sgi/gl_panel/twoview/block.py'
  382. else
  383. echo 'x - demo/sgi/gl_panel/twoview/block.py'
  384. sed 's/^X//' > 'demo/sgi/gl_panel/twoview/block.py' << 'EOF'
  385. X# module 'block' imported by twoview demo.
  386. X
  387. Xfrom gl import n3f, bgnpolygon, varray, endpolygon, lmbind
  388. Xfrom GL import MATERIAL
  389. X
  390. X# Draw a single 2x2x2 block with its center at (0, 0, 0)
  391. X# Arguments are the material indices (0 = don't call lmbind)
  392. X#
  393. Xdef block(m_front, m_back, m_left, m_right, m_top, m_bottom):
  394. X    #
  395. X    # Distances defining the sides
  396. X    #
  397. X    x_left = -1.0
  398. X    x_right = 1.0
  399. X    y_top = 1.0
  400. X    y_bottom = -1.0
  401. X    z_front = 1.0
  402. X    z_back = -1.0
  403. X    #
  404. X    # Top surface points: A, B, C, D
  405. X    #
  406. X    A = x_right, y_top, z_front
  407. X    B = x_right, y_top, z_back
  408. X    C = x_left, y_top, z_back
  409. X    D = x_left, y_top, z_front
  410. X    #
  411. X    # Bottom surface points: E, F, G, H
  412. X    #
  413. X    E = x_right, y_bottom, z_front
  414. X    F = x_right, y_bottom, z_back
  415. X    G = x_left, y_bottom, z_back
  416. X    H = x_left, y_bottom, z_front
  417. X    #
  418. X    # Draw front face
  419. X    #
  420. X    if m_front: lmbind(MATERIAL, m_front)
  421. X    n3f(0.0, 0.0, 1.0)
  422. X    face(H, E, A, D)
  423. X    #
  424. X    # Draw back face
  425. X    #
  426. X    if m_back: lmbind(MATERIAL, m_back)
  427. X    n3f(0.0, 0.0, -1.0)
  428. X    face(G, F, B, C)
  429. X    #
  430. X    # Draw left face
  431. X    #
  432. X    if m_left: lmbind(MATERIAL, m_left)
  433. X    n3f(-1.0, 0.0, 0.0)
  434. X    face(G, H, D, C)
  435. X    #
  436. X    # Draw right face
  437. X    #
  438. X    if m_right: lmbind(MATERIAL, m_right)
  439. X    n3f(1.0, 0.0, 0.0)
  440. X    face(F, E, A, B)
  441. X    #
  442. X    # Draw top face
  443. X    #
  444. X    if m_top: lmbind(MATERIAL, m_top)
  445. X    n3f(0.0, 1.0, 0.0)
  446. X    face(A, B, C, D)
  447. X    #
  448. X    # Draw bottom face
  449. X    #
  450. X    if m_bottom: lmbind(MATERIAL, m_bottom)
  451. X    n3f(0.0, -1.0, 0.0)
  452. X    face(E, F, G, H)
  453. X
  454. Xdef face(points):
  455. X    bgnpolygon()
  456. X    varray(points)
  457. X    endpolygon()
  458. EOF
  459. fi
  460. if test -s 'demo/sgi/gl_panel/twoview/camera.s'
  461. then echo '*** I will not over-write existing file demo/sgi/gl_panel/twoview/camera.s'
  462. else
  463. echo 'x - demo/sgi/gl_panel/twoview/camera.s'
  464. sed 's/^X//' > 'demo/sgi/gl_panel/twoview/camera.s' << 'EOF'
  465. X;;; This file was automatically generated by the panel editor.
  466. X;;; If you read it into gnu emacs, it will automagically format itself.
  467. X
  468. X(panel (prop help creator:user-panel-help)
  469. X(prop user-panel #t)
  470. X(label "Camera Control")
  471. X(x 1010)
  472. X(y 589)
  473. X(al (pnl_wide_button (name "quitbutton")
  474. X(prop help creator:user-act-help)
  475. X(label "quit")
  476. X(x 3.5)
  477. X(y 1)
  478. X(w 0.94)
  479. X(downfunc move-then-resize)
  480. X)
  481. X(pnl_filled_hslider (name "farclip")
  482. X(prop help creator:user-act-help)
  483. X(label "far clipping plane")
  484. X(x 1.25)
  485. X(y 3.5)
  486. X(w 3.3)
  487. X(h 0.4)
  488. X(val 0.752)
  489. X(downfunc move-then-resize)
  490. X)
  491. X(pnl_filled_hslider (name "nearclip")
  492. X(prop help creator:user-act-help)
  493. X(label "near clipping plane")
  494. X(x 1.25)
  495. X(y 4.5)
  496. X(w 3.3)
  497. X(h 0.4)
  498. X(val 0.17)
  499. X(downfunc move-then-resize)
  500. X)
  501. X(pnl_filled_vslider (name "zoom")
  502. X(prop help creator:user-act-help)
  503. X(label "zoom")
  504. X(x 0.2)
  505. X(y 1.25)
  506. X(w 0.4)
  507. X(h 3.9)
  508. X(val 0.344)
  509. X(downfunc move-then-resize)
  510. X)
  511. X)
  512. X)
  513. X;;; Local Variables:
  514. X;;; mode: scheme
  515. X;;; eval: (save-excursion (goto-char (point-min)) (kill-line 3))
  516. X;;; eval: (save-excursion (goto-char (point-min)) (replace-regexp "[ \n]*)" ")"))
  517. X;;; eval: (indent-region (point-min) (point-max) nil)
  518. X;;; eval: (progn (kill-line -3) (delete-backward-char 1) (save-buffer))
  519. X;;; End:
  520. EOF
  521. fi
  522. if test -s 'lib/HVSplit.py'
  523. then echo '*** I will not over-write existing file lib/HVSplit.py'
  524. else
  525. echo 'x - lib/HVSplit.py'
  526. sed 's/^X//' > 'lib/HVSplit.py' << 'EOF'
  527. X# HVSplit contains generic code for HSplit and VSplit.
  528. X# HSplit and VSplit are specializations to either dimension.
  529. X
  530. X# XXX This does not yet stretch/shrink children if there is too much
  531. X# XXX or too little space in the split dimension.
  532. X# XXX (NB There is no interface to ask children for stretch preferences.)
  533. X
  534. Xfrom Split import Split
  535. X
  536. Xclass HVSplit() = Split():
  537. X    #
  538. X    def create(self, (parent, hv)):
  539. X        # hv is 0 or 1 for HSplit or VSplit
  540. X        self = Split.create(self, parent)
  541. X        self.hv = hv
  542. X        return self
  543. X    #
  544. X    def minsize(self, m):
  545. X        hv, vh = self.hv, 1 - self.hv
  546. X        size = [0, 0]
  547. X        for c in self.children:
  548. X            csize = c.minsize(m)
  549. X            if csize[vh] > size[vh]: size[vh] = csize[vh]
  550. X            size[hv] = size[hv] + csize[hv]
  551. X        return size[0], size[1]
  552. X    #
  553. X    def getbounds(self):
  554. X        return self.bounds
  555. X    #
  556. X    def setbounds(self, bounds):
  557. X        self.bounds = bounds
  558. X        hv, vh = self.hv, 1 - self.hv
  559. X        mf = self.parent.beginmeasuring
  560. X        size = self.minsize(mf())
  561. X        # XXX not yet used!  Later for stretching
  562. X        maxsize_hv = bounds[1][hv] - bounds[0][hv]
  563. X        origin = [self.bounds[0][0], self.bounds[0][1]]
  564. X        for c in self.children:
  565. X            size = c.minsize(mf())
  566. X            corner = [0, 0]
  567. X            corner[vh] = bounds[1][vh]
  568. X            corner[hv] = origin[hv] + size[hv]
  569. X            c.setbounds((origin[0], origin[1]), \
  570. X                    (corner[0], corner[1]))
  571. X            origin[hv] = corner[hv]
  572. X            # XXX stretch
  573. X            # XXX too-small
  574. X    #
  575. X
  576. Xclass HSplit() = HVSplit():
  577. X    def create(self, parent):
  578. X        return HVSplit.create(self, (parent, 0))
  579. X
  580. Xclass VSplit() = HVSplit():
  581. X    def create(self, parent):
  582. X        return HVSplit.create(self, (parent, 1))
  583. EOF
  584. fi
  585. if test -s 'lib/dump.py'
  586. then echo '*** I will not over-write existing file lib/dump.py'
  587. else
  588. echo 'x - lib/dump.py'
  589. sed 's/^X//' > 'lib/dump.py' << 'EOF'
  590. X# Module 'dump'
  591. X#
  592. X# Print python code that reconstructs a variable.
  593. X# This only works in certain cases.
  594. X#
  595. X# It works fine for:
  596. X# - ints and floats (except NaNs and other weird things)
  597. X# - strings
  598. X# - compounds and lists, provided it works for all their elements
  599. X# - imported modules, provided their name is the module name
  600. X#
  601. X# It works for top-level dictionaries but not for dictionaries
  602. X# contained in other objects (could be made to work with some hassle
  603. X# though).
  604. X#
  605. X# It does not work for functions (all sorts), classes, class objects,
  606. X# windows, files etc.
  607. X#
  608. X# Finally, objects referenced by more than one name or contained in more
  609. X# than one other object lose their sharing property (this is bad for
  610. X# strings used as exception identifiers, for instance).
  611. X
  612. X# Dump a whole symbol table
  613. X#
  614. Xdef dumpsymtab(dict):
  615. X    for key in dict.keys():
  616. X        dumpvar(key, dict[key])
  617. X
  618. X# Dump a single variable
  619. X#
  620. Xdef dumpvar(name, x):
  621. X    import sys
  622. X    t = type(x)
  623. X    if t = type({}):
  624. X        print name, '= {}'
  625. X        for key in x.keys():
  626. X            item = x[key]
  627. X            if not printable(item):
  628. X                print '#',
  629. X            print name, '[', `key`, '] =', `item`
  630. X    elif t in (type(''), type(0), type(0.0), type([]), type(())):
  631. X        if not printable(x):
  632. X            print '#',
  633. X        print name, '=', `x`
  634. X    elif t = type(sys):
  635. X        print 'import', name, '#', x
  636. X    else:
  637. X        print '#', name, '=', x
  638. X
  639. X# check if a value is printable in a way that can be read back with input()
  640. X#
  641. Xdef printable(x):
  642. X    t = type(x)
  643. X    if t in (type(''), type(0), type(0.0)):
  644. X        return 1
  645. X    if t in (type([]), type(())):
  646. X        for item in x:
  647. X            if not printable(item):
  648. X                return 0
  649. X        return 1
  650. X    if x = {}:
  651. X        return 1
  652. X    return 0
  653. EOF
  654. fi
  655. if test -s 'lib/localtime.py'
  656. then echo '*** I will not over-write existing file lib/localtime.py'
  657. else
  658. echo 'x - lib/localtime.py'
  659. sed 's/^X//' > 'lib/localtime.py' << 'EOF'
  660. X# module localtime -- Time conversions
  661. X
  662. Ximport posix
  663. X
  664. Xepoch = 1970                # 1 jan 00:00:00, UCT
  665. Xday0  = 4                # day 0 was a thursday
  666. X
  667. Xday_names = ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat')
  668. X
  669. Xmonth_names =               ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun')
  670. Xmonth_names = month_names + ('Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec')
  671. X
  672. Xmonth_sizes = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
  673. X
  674. Xdef isleap(year):
  675. X    return year % 4 = 0 and (year % 100 <> 0 or year % 400 = 0)
  676. X
  677. Xdef gmtime(secs):            # decode time into UCT
  678. X    mins, secs = divmod(secs, 60)
  679. X    hours, mins = divmod(mins, 60)
  680. X    days, hours = divmod(hours, 24)
  681. X    wday = (day0 + days) % 7
  682. X    year = epoch
  683. X    lp = isleap(year)
  684. X    dpy = 365 + lp
  685. X    while days >= dpy:
  686. X        days = days - dpy
  687. X        year = year + 1
  688. X        lp = isleap(year)
  689. X        dpy = 365 + lp
  690. X    yday = days
  691. X    month = 0
  692. X    dpm = month_sizes[month] + (lp and month = 1)
  693. X    while days >= dpm:
  694. X        days = days - dpm
  695. X        month = month + 1
  696. X        dpm = month_sizes[month] + (lp and month = 1)
  697. X    return (year, month, days+1, hours, mins, secs, yday, wday)
  698. X
  699. Xdef dd(x):
  700. X    s = `x`
  701. X    while len(s) < 2: s = '0' + s
  702. X    return s
  703. X
  704. Xdef zd(x):
  705. X    s = `x`
  706. X    while len(s) < 2: s = ' ' + s
  707. X    return s
  708. X
  709. Xdef format(year, month, days, hours, mins, secs, yday, wday):
  710. X    s = day_names[wday] + ' ' + zd(days) + ' ' + month_names[month] + ' '
  711. X    s = s + dd(hours) + ':' + dd(mins) + ':' + dd(secs)
  712. X    return s
  713. EOF
  714. fi
  715. if test -s 'lib/poly.py'
  716. then echo '*** I will not over-write existing file lib/poly.py'
  717. else
  718. echo 'x - lib/poly.py'
  719. sed 's/^X//' > 'lib/poly.py' << 'EOF'
  720. X# module 'poly' -- Polynomials
  721. X
  722. X# A polynomial is represented by a list of coefficients, e.g.,
  723. X# [1, 10, 5] represents 1*x**0 + 10*x**1 + 5*x**2 (or 1 + 10x + 5x**2).
  724. X# There is no way to suppress internal zeros; trailing zeros are
  725. X# taken out by normalize().
  726. X
  727. Xdef normalize(p): # Strip unnecessary zero coefficients
  728. X    n = len(p)
  729. X    while p:
  730. X        if p[n-1]: return p[:n]
  731. X        n = n-1
  732. X    return []
  733. X
  734. Xdef plus(a, b):
  735. X    if len(a) < len(b): a, b = b, a # make sure a is the longest
  736. X    res = a[:] # make a copy
  737. X    for i in range(len(b)):
  738. X        res[i] = res[i] + b[i]
  739. X    return normalize(res)
  740. X
  741. Xdef minus(a, b):
  742. X    if len(a) < len(b): a, b = b, a # make sure a is the longest
  743. X    res = a[:] # make a copy
  744. X    for i in range(len(b)):
  745. X        res[i] = res[i] - b[i]
  746. X    return normalize(res)
  747. X
  748. Xdef one(power, coeff): # Representation of coeff * x**power
  749. X    res = []
  750. X    for i in range(power): res.append(0)
  751. X    return res + [coeff]
  752. X
  753. Xdef times(a, b):
  754. X    res = []
  755. X    for i in range(len(a)):
  756. X        for j in range(len(b)):
  757. X            res = plus(res, one(i+j, a[i]*b[j]))
  758. X    return res
  759. X
  760. Xdef power(a, n): # Raise polynomial a to the positive integral power n
  761. X    if n = 0: return [1]
  762. X    if n = 1: return a
  763. X    if n/2*2 = n:
  764. X        b = power(a, n/2)
  765. X        return times(b, b)
  766. X    return times(power(a, n-1), a)
  767. X
  768. Xdef der(a): # First derivative
  769. X    res = a[1:]
  770. X    for i in range(len(res)):
  771. X        res[i] = res[i] * (i+1)
  772. X    return res
  773. X
  774. X# Computing a primitive function would require rational arithmetic...
  775. EOF
  776. fi
  777. if test -s 'lib/shutil.py'
  778. then echo '*** I will not over-write existing file lib/shutil.py'
  779. else
  780. echo 'x - lib/shutil.py'
  781. sed 's/^X//' > 'lib/shutil.py' << 'EOF'
  782. X# Module 'shutil' -- utility functions usable in a shell-like program
  783. X
  784. Ximport posix
  785. Ximport path
  786. X
  787. XMODEBITS = 010000    # Lower 12 mode bits
  788. X# Change this to 01000 (9 mode bits) to avoid copying setuid etc.
  789. X
  790. X# Copy data from src to dst
  791. X#
  792. Xdef copyfile(src, dst):
  793. X    fsrc = open(src, 'r')
  794. X    fdst = open(dst, 'w')
  795. X    while 1:
  796. X        buf = fsrc.read(16*1024)
  797. X        if not buf: break
  798. X        fdst.write(buf)
  799. X
  800. X# Copy mode bits from src to dst
  801. X#
  802. Xdef copymode(src, dst):
  803. X    st = posix.stat(src)
  804. X    mode = divmod(st[0], MODEBITS)[1]
  805. X    posix.chmod(dst, mode)
  806. X
  807. X# Copy all stat info (mode bits, atime and mtime) from src to dst
  808. X#
  809. Xdef copystat(src, dst):
  810. X    st = posix.stat(src)
  811. X    mode = divmod(st[0], MODEBITS)[1]
  812. X    posix.chmod(dst, mode)
  813. X    posix.utimes(dst, st[7:9])
  814. X
  815. X# Copy data and mode bits ("cp src dst")
  816. X#
  817. Xdef copy(src, dst):
  818. X    copyfile(src, dst)
  819. X    copymode(src, dst)
  820. X
  821. X# Copy data and all stat info ("cp -p src dst")
  822. X#
  823. Xdef copy2(src, dst):
  824. X    copyfile(src, dst)
  825. X    copystat(src, dst)
  826. X
  827. X# Recursively copy a directory tree.
  828. X# The destination must not already exist.
  829. X#
  830. Xdef copytree(src, dst):
  831. X    names = posix.listdir(src)
  832. X    posix.mkdir(dst, 0777)
  833. X    dot_dotdot = '.', '..'
  834. X    for name in names:
  835. X        if name not in dot_dotdot:
  836. X            srcname = path.cat(src, name)
  837. X            dstname = path.cat(dst, name)
  838. X            #print 'Copying', srcname, 'to', dstname
  839. X            try:
  840. X                #if path.islink(srcname):
  841. X                #    linkto = posix.readlink(srcname)
  842. X                #    posix.symlink(linkto, dstname)
  843. X                #elif path.isdir(srcname):
  844. X                if path.isdir(srcname):
  845. X                    copytree(srcname, dstname)
  846. X                else:
  847. X                    copy2(srcname, dstname)
  848. X                # XXX What about devices, sockets etc.?
  849. X            except posix.error, why:
  850. X                print 'Could not copy', srcname, 'to', dstname,
  851. X                print '(', why[1], ')'
  852. EOF
  853. fi
  854. if test -s 'lib/stdwinevents.py'
  855. then echo '*** I will not over-write existing file lib/stdwinevents.py'
  856. else
  857. echo 'x - lib/stdwinevents.py'
  858. sed 's/^X//' > 'lib/stdwinevents.py' << 'EOF'
  859. X# Module 'stdwinevents' -- Constants for stdwin event types
  860. X#
  861. X# Suggested usage:
  862. X#    from stdwinevents import *
  863. X
  864. X# The function stdwin.getevent() returns a tuple containing:
  865. X#    (type, window, detail)
  866. X# where detail may be <no value> or a value depending on type, see below:
  867. X
  868. X# Values for type:
  869. X
  870. XWE_NULL       =  0    # not reported -- means 'no event' internally
  871. XWE_ACTIVATE   =  1    # detail is <no object>
  872. XWE_CHAR       =  2    # detail is the character
  873. XWE_COMMAND    =  3    # detail is one of the WC_* constants below
  874. XWE_MOUSE_DOWN =  4    # detail is ((h, v), clicks, button, mask)
  875. XWE_MOUSE_MOVE =  5    # ditto
  876. XWE_MOUSE_UP   =  6    # ditto
  877. XWE_MENU       =  7    # detail is (menu, item)
  878. XWE_SIZE       =  8    # detail is (width, height) [???]
  879. XWE_MOVE       =  9    # not reported -- reserved for future use
  880. XWE_DRAW       = 10    # detail is ((left, top), (right, bottom))
  881. XWE_TIMER      = 11    # detail is <no object>
  882. XWE_DEACTIVATE = 12    # detail is <no object>
  883. XWE_EXTERN     = 13    # detail is <no object>
  884. XWE_KEY        = 14    # detail is ???
  885. XWE_LOST_SEL   = 15    # detail is selection number
  886. XWE_CLOSE      = 16    # detail is <no object>
  887. X
  888. X# Values for detail when type is WE_COMMAND:
  889. X
  890. XWC_CLOSE      =  1    # user hit close box
  891. XWC_LEFT       =  2    # left arrow key
  892. XWC_RIGHT      =  3    # right arrow key
  893. XWC_UP         =  4    # up arrow key
  894. XWC_DOWN       =  5    # down arrow key
  895. XWC_CANCEL     =  6    # not reported -- turned into KeyboardInterrupt
  896. XWC_BACKSPACE  =  7    # backspace key
  897. XWC_TAB        =  8    # tab key
  898. XWC_RETURN     =  9    # return or enter key
  899. X
  900. X# Selection numbers
  901. X
  902. XWS_CLIPBOARD   = 0
  903. XWS_PRIMARY     = 1
  904. XWS_SECONDARY   = 2
  905. EOF
  906. fi
  907. if test -s 'lib/sunaudio.py'
  908. then echo '*** I will not over-write existing file lib/sunaudio.py'
  909. else
  910. echo 'x - lib/sunaudio.py'
  911. sed 's/^X//' > 'lib/sunaudio.py' << 'EOF'
  912. X# Module 'sunaudio' -- interpret sun audio headers
  913. X
  914. Ximport audio
  915. X
  916. XMAGIC = '.snd'
  917. X
  918. Xerror = 'sunaudio sound header conversion error'
  919. X
  920. X
  921. X# convert a 4-char value to integer
  922. X
  923. Xdef c2i(data):
  924. X    if type(data) <> type('') or len(data) <> 4:
  925. X        raise error, 'c2i: bad arg (not string[4])'
  926. X    bytes = audio.chr2num(data)
  927. X    for i in (1, 2, 3):
  928. X        if bytes[i] < 0:
  929. X            bytes[i] = bytes[i] + 256
  930. X    return ((bytes[0]*256 + bytes[1])*256 + bytes[2])*256 + bytes[3]
  931. X
  932. X
  933. X# read a sound header from an open file
  934. X
  935. Xdef gethdr(fp):
  936. X    if fp.read(4) <> MAGIC:
  937. X        raise error, 'gethdr: bad magic word'
  938. X    hdr_size = c2i(fp.read(4))
  939. X    data_size = c2i(fp.read(4))
  940. X    encoding = c2i(fp.read(4))
  941. X    sample_rate = c2i(fp.read(4))
  942. X    channels = c2i(fp.read(4))
  943. X    excess = hdr_size - 24
  944. X    if excess < 0:
  945. X        raise error, 'gethdr: bad hdr_size'
  946. X    if excess > 0:
  947. X        info = fp.read(excess)
  948. X    else:
  949. X        info = ''
  950. X    return (data_size, encoding, sample_rate, channels, info)
  951. X
  952. X
  953. X# read and print the sound header of a named file
  954. X
  955. Xdef printhdr(file):
  956. X    hdr = gethdr(open(file, 'r'))
  957. X    data_size, encoding, sample_rate, channels, info = hdr
  958. X    while info[-1:] = '\0':
  959. X        info = info[:-1]
  960. X    print 'File name:  ', file
  961. X    print 'Data size:  ', data_size
  962. X    print 'Encoding:   ', encoding
  963. X    print 'Sample rate:', sample_rate
  964. X    print 'Channels:   ', channels
  965. X    print 'Info:       ', `info`
  966. EOF
  967. fi
  968. if test -s 'lib/whrandom.py'
  969. then echo '*** I will not over-write existing file lib/whrandom.py'
  970. else
  971. echo 'x - lib/whrandom.py'
  972. sed 's/^X//' > 'lib/whrandom.py' << 'EOF'
  973. X#    WICHMANN-HILL RANDOM NUMBER GENERATOR
  974. X#
  975. X#    Wichmann, B. A. & Hill, I. D. (1982)
  976. X#    Algorithm AS 183: 
  977. X#    An efficient and portable pseudo-random number generator
  978. X#    Applied Statistics 31 (1982) 188-190
  979. X#
  980. X#    see also: 
  981. X#        Correction to Algorithm AS 183
  982. X#        Applied Statistics 33 (1984) 123  
  983. X#
  984. X#        McLeod, A. I. (1985)
  985. X#        A remark on Algorithm AS 183 
  986. X#        Applied Statistics 34 (1985),198-200
  987. X#
  988. X#
  989. X#    USE:
  990. X#    whrandom.random()    yields double precision random numbers 
  991. X#                uniformly distributed between 0 and 1.
  992. X#
  993. X#    whrandom.seed()        must be called before whrandom.random()
  994. X#                to seed the generator
  995. X
  996. X
  997. X#    Translated by Guido van Rossum from C source provided by
  998. X#    Adrian Baddeley.
  999. X
  1000. X
  1001. X# The seed
  1002. X#
  1003. X_seed = [0, 0, 0]
  1004. X
  1005. X
  1006. X# Set the seed
  1007. X#
  1008. Xdef seed(x, y, z):
  1009. X    _seed[:] = [x, y, z]
  1010. X
  1011. X
  1012. X# Return the next random number in the range [0.0 .. 1.0)
  1013. X#
  1014. Xdef random():
  1015. X    from math import floor        # floor() function
  1016. X    #
  1017. X    [x, y, z] = _seed
  1018. X    x = 171 * (x % 177) - 2 * (x/177)
  1019. X    y = 172 * (y % 176) - 35 * (y/176)
  1020. X    z = 170 * (z % 178) - 63 * (z/178)
  1021. X    #
  1022. X    if x < 0: x = x + 30269
  1023. X    if y < 0: y = y + 30307
  1024. X    if z < 0: z = z + 30323
  1025. X    #
  1026. X    _seed[:] = [x, y, z]
  1027. X    #
  1028. X    term = float(x)/30269.0 + float(y)/30307.0 + float(z)/30323.0
  1029. X    rand = term - floor(term)
  1030. X    #
  1031. X    if rand >= 1.0: rand = 0.0    # floor() inaccuracy?
  1032. X    #
  1033. X    return rand
  1034. X
  1035. X
  1036. X# Initialize from the current time
  1037. X#
  1038. Xdef init():
  1039. X    import time
  1040. X    t = time.time()
  1041. X    seed(t%256, t/256%256, t/65536%256)
  1042. X
  1043. X
  1044. X# Make sure the generator is preset to a nonzero value
  1045. X#
  1046. Xinit()
  1047. EOF
  1048. fi
  1049. if test -s 'src/README'
  1050. then echo '*** I will not over-write existing file src/README'
  1051. else
  1052. echo 'x - src/README'
  1053. sed 's/^X//' > 'src/README' << 'EOF'
  1054. XThis directory contains the source for the Python interpreter.
  1055. X
  1056. XTo build the interpreter, edit the Makefile, follow the instructions
  1057. Xthere, and type "make python".
  1058. X
  1059. XTo use the interpreter, you must set the environment variable PYTHONPATH
  1060. Xto point to the directory containing the standard modules.  These are
  1061. Xdistributed as a sister directory called 'lib' of this source directory.
  1062. XTry importing the module 'testall' to see if everything works.
  1063. X
  1064. XGood Luck!
  1065. EOF
  1066. fi
  1067. if test -s 'src/asa.h'
  1068. then echo '*** I will not over-write existing file src/asa.h'
  1069. else
  1070. echo 'x - src/asa.h'
  1071. sed 's/^X//' > 'src/asa.h' << 'EOF'
  1072. X/***********************************************************
  1073. XCopyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
  1074. XNetherlands.
  1075. X
  1076. X                        All Rights Reserved
  1077. X
  1078. XPermission to use, copy, modify, and distribute this software and its 
  1079. Xdocumentation for any purpose and without fee is hereby granted, 
  1080. Xprovided that the above copyright notice appear in all copies and that
  1081. Xboth that copyright notice and this permission notice appear in 
  1082. Xsupporting documentation, and that the names of Stichting Mathematisch
  1083. XCentrum or CWI not be used in advertising or publicity pertaining to
  1084. Xdistribution of the software without specific, written prior permission.
  1085. X
  1086. XSTICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
  1087. XTHIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  1088. XFITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
  1089. XFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  1090. XWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  1091. XACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
  1092. XOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  1093. X
  1094. X******************************************************************/
  1095. X
  1096. X/* Interface for asynchronous audio module */
  1097. X
  1098. Xextern int asa_init(void);
  1099. Xextern void asa_done(void);
  1100. Xextern void asa_start_write(char *, int);
  1101. Xextern void asa_start_read(char *, int);
  1102. Xextern int asa_poll(void);
  1103. Xextern int asa_wait(void);
  1104. Xextern int asa_cancel(void);
  1105. EOF
  1106. fi
  1107. if test -s 'src/ceval.h'
  1108. then echo '*** I will not over-write existing file src/ceval.h'
  1109. else
  1110. echo 'x - src/ceval.h'
  1111. sed 's/^X//' > 'src/ceval.h' << 'EOF'
  1112. X/***********************************************************
  1113. XCopyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
  1114. XNetherlands.
  1115. X
  1116. X                        All Rights Reserved
  1117. X
  1118. XPermission to use, copy, modify, and distribute this software and its 
  1119. Xdocumentation for any purpose and without fee is hereby granted, 
  1120. Xprovided that the above copyright notice appear in all copies and that
  1121. Xboth that copyright notice and this permission notice appear in 
  1122. Xsupporting documentation, and that the names of Stichting Mathematisch
  1123. XCentrum or CWI not be used in advertising or publicity pertaining to
  1124. Xdistribution of the software without specific, written prior permission.
  1125. X
  1126. XSTICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
  1127. XTHIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  1128. XFITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
  1129. XFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  1130. XWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  1131. XACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
  1132. XOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  1133. X
  1134. X******************************************************************/
  1135. X
  1136. X/* Interface to execute compiled code */
  1137. X/* This header depends on "compile.h" */
  1138. X
  1139. Xobject *eval_code PROTO((codeobject *, object *, object *, object *));
  1140. X
  1141. Xobject *getglobals PROTO((void));
  1142. Xobject *getlocals PROTO((void));
  1143. X
  1144. Xvoid printtraceback PROTO((FILE *));
  1145. EOF
  1146. fi
  1147. if test -s 'src/errcode.h'
  1148. then echo '*** I will not over-write existing file src/errcode.h'
  1149. else
  1150. echo 'x - src/errcode.h'
  1151. sed 's/^X//' > 'src/errcode.h' << 'EOF'
  1152. X/***********************************************************
  1153. XCopyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
  1154. XNetherlands.
  1155. X
  1156. X                        All Rights Reserved
  1157. X
  1158. XPermission to use, copy, modify, and distribute this software and its 
  1159. Xdocumentation for any purpose and without fee is hereby granted, 
  1160. Xprovided that the above copyright notice appear in all copies and that
  1161. Xboth that copyright notice and this permission notice appear in 
  1162. Xsupporting documentation, and that the names of Stichting Mathematisch
  1163. XCentrum or CWI not be used in advertising or publicity pertaining to
  1164. Xdistribution of the software without specific, written prior permission.
  1165. X
  1166. XSTICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
  1167. XTHIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  1168. XFITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
  1169. XFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  1170. XWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  1171. XACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
  1172. XOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  1173. X
  1174. X******************************************************************/
  1175. X
  1176. X/* Error codes passed around between file input, tokenizer, parser and
  1177. X   interpreter.  This was necessary so we can turn them into Python
  1178. X   exceptions at a higher level. */
  1179. X
  1180. X#define E_OK        10    /* No error */
  1181. X#define E_EOF        11    /* (Unexpected) EOF read */
  1182. X#define E_INTR        12    /* Interrupted */
  1183. X#define E_TOKEN        13    /* Bad token */
  1184. X#define E_SYNTAX    14    /* Syntax error */
  1185. X#define E_NOMEM        15    /* Ran out of memory */
  1186. X#define E_DONE        16    /* Parsing complete */
  1187. X#define E_ERROR        17    /* Execution error */
  1188. EOF
  1189. fi
  1190. if test -s 'src/fileobject.h'
  1191. then echo '*** I will not over-write existing file src/fileobject.h'
  1192. else
  1193. echo 'x - src/fileobject.h'
  1194. sed 's/^X//' > 'src/fileobject.h' << 'EOF'
  1195. X/***********************************************************
  1196. XCopyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
  1197. XNetherlands.
  1198. X
  1199. X                        All Rights Reserved
  1200. X
  1201. XPermission to use, copy, modify, and distribute this software and its 
  1202. Xdocumentation for any purpose and without fee is hereby granted, 
  1203. Xprovided that the above copyright notice appear in all copies and that
  1204. Xboth that copyright notice and this permission notice appear in 
  1205. Xsupporting documentation, and that the names of Stichting Mathematisch
  1206. XCentrum or CWI not be used in advertising or publicity pertaining to
  1207. Xdistribution of the software without specific, written prior permission.
  1208. X
  1209. XSTICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
  1210. XTHIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  1211. XFITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
  1212. XFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  1213. XWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  1214. XACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
  1215. XOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  1216. X
  1217. X******************************************************************/
  1218. X
  1219. X/* File object interface */
  1220. X
  1221. Xextern typeobject Filetype;
  1222. X
  1223. X#define is_fileobject(op) ((op)->ob_type == &Filetype)
  1224. X
  1225. Xextern object *newfileobject PROTO((char *, char *));
  1226. Xextern object *newopenfileobject PROTO((FILE *, char *, char *));
  1227. Xextern FILE *getfilefile PROTO((object *));
  1228. EOF
  1229. fi
  1230. if test -s 'src/floatobject.h'
  1231. then echo '*** I will not over-write existing file src/floatobject.h'
  1232. else
  1233. echo 'x - src/floatobject.h'
  1234. sed 's/^X//' > 'src/floatobject.h' << 'EOF'
  1235. X/***********************************************************
  1236. XCopyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
  1237. XNetherlands.
  1238. X
  1239. X                        All Rights Reserved
  1240. X
  1241. XPermission to use, copy, modify, and distribute this software and its 
  1242. Xdocumentation for any purpose and without fee is hereby granted, 
  1243. Xprovided that the above copyright notice appear in all copies and that
  1244. Xboth that copyright notice and this permission notice appear in 
  1245. Xsupporting documentation, and that the names of Stichting Mathematisch
  1246. XCentrum or CWI not be used in advertising or publicity pertaining to
  1247. Xdistribution of the software without specific, written prior permission.
  1248. X
  1249. XSTICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
  1250. XTHIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  1251. XFITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
  1252. XFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  1253. XWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  1254. XACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
  1255. XOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  1256. X
  1257. X******************************************************************/
  1258. X
  1259. X/* Float object interface */
  1260. X
  1261. X/*
  1262. Xfloatobject represents a (double precision) floating point number.
  1263. X*/
  1264. X
  1265. Xtypedef struct {
  1266. X    OB_HEAD
  1267. X    double ob_fval;
  1268. X} floatobject;
  1269. X
  1270. Xextern typeobject Floattype;
  1271. X
  1272. X#define is_floatobject(op) ((op)->ob_type == &Floattype)
  1273. X
  1274. Xextern object *newfloatobject PROTO((double));
  1275. Xextern double getfloatvalue PROTO((object *));
  1276. X
  1277. X/* Macro, trading safety for speed */
  1278. X#define GETFLOATVALUE(op) ((op)->ob_fval)
  1279. EOF
  1280. fi
  1281. if test -s 'src/fmod.c'
  1282. then echo '*** I will not over-write existing file src/fmod.c'
  1283. else
  1284. echo 'x - src/fmod.c'
  1285. sed 's/^X//' > 'src/fmod.c' << 'EOF'
  1286. X/***********************************************************
  1287. XCopyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
  1288. XNetherlands.
  1289. X
  1290. X                        All Rights Reserved
  1291. X
  1292. XPermission to use, copy, modify, and distribute this software and its 
  1293. Xdocumentation for any purpose and without fee is hereby granted, 
  1294. Xprovided that the above copyright notice appear in all copies and that
  1295. Xboth that copyright notice and this permission notice appear in 
  1296. Xsupporting documentation, and that the names of Stichting Mathematisch
  1297. XCentrum or CWI not be used in advertising or publicity pertaining to
  1298. Xdistribution of the software without specific, written prior permission.
  1299. X
  1300. XSTICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
  1301. XTHIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  1302. XFITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
  1303. XFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  1304. XWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  1305. XACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
  1306. XOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  1307. X
  1308. X******************************************************************/
  1309. X
  1310. X/* Portable fmod(x, y) implementation for systems that don't have it */
  1311. X
  1312. X#include <math.h>
  1313. X#include <errno.h>
  1314. X
  1315. Xextern int errno;
  1316. X
  1317. Xdouble
  1318. Xfmod(x, y)
  1319. X    double x, y;
  1320. X{
  1321. X    double i, f;
  1322. X    
  1323. X    if (y == 0.0) {
  1324. X        errno = EDOM;
  1325. X        return 0.0;
  1326. X    }
  1327. X    
  1328. X    /* return f such that x = i*y + f for some integer i
  1329. X       such that |f| < |y| and f has the same sign as x */
  1330. X    
  1331. X    i = floor(x/y);
  1332. X    f = x - i*y;
  1333. X    if ((x < 0.0) != (y < 0.0))
  1334. X        f = f-y;
  1335. X    return f;
  1336. X}
  1337. EOF
  1338. fi
  1339. if test -s 'src/funcobject.h'
  1340. then echo '*** I will not over-write existing file src/funcobject.h'
  1341. else
  1342. echo 'x - src/funcobject.h'
  1343. sed 's/^X//' > 'src/funcobject.h' << 'EOF'
  1344. X/***********************************************************
  1345. XCopyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
  1346. XNetherlands.
  1347. X
  1348. X                        All Rights Reserved
  1349. X
  1350. XPermission to use, copy, modify, and distribute this software and its 
  1351. Xdocumentation for any purpose and without fee is hereby granted, 
  1352. Xprovided that the above copyright notice appear in all copies and that
  1353. Xboth that copyright notice and this permission notice appear in 
  1354. Xsupporting documentation, and that the names of Stichting Mathematisch
  1355. XCentrum or CWI not be used in advertising or publicity pertaining to
  1356. Xdistribution of the software without specific, written prior permission.
  1357. X
  1358. XSTICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
  1359. XTHIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  1360. XFITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
  1361. XFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  1362. XWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  1363. XACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
  1364. XOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  1365. X
  1366. X******************************************************************/
  1367. X
  1368. X/* Function object interface */
  1369. X
  1370. Xextern typeobject Functype;
  1371. X
  1372. X#define is_funcobject(op) ((op)->ob_type == &Functype)
  1373. X
  1374. Xextern object *newfuncobject PROTO((object *, object *));
  1375. Xextern object *getfunccode PROTO((object *));
  1376. Xextern object *getfuncglobals PROTO((object *));
  1377. EOF
  1378. fi
  1379. if test -s 'src/import.h'
  1380. then echo '*** I will not over-write existing file src/import.h'
  1381. else
  1382. echo 'x - src/import.h'
  1383. sed 's/^X//' > 'src/import.h' << 'EOF'
  1384. X/***********************************************************
  1385. XCopyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
  1386. XNetherlands.
  1387. X
  1388. X                        All Rights Reserved
  1389. X
  1390. XPermission to use, copy, modify, and distribute this software and its 
  1391. Xdocumentation for any purpose and without fee is hereby granted, 
  1392. Xprovided that the above copyright notice appear in all copies and that
  1393. Xboth that copyright notice and this permission notice appear in 
  1394. Xsupporting documentation, and that the names of Stichting Mathematisch
  1395. XCentrum or CWI not be used in advertising or publicity pertaining to
  1396. Xdistribution of the software without specific, written prior permission.
  1397. X
  1398. XSTICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
  1399. XTHIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  1400. XFITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
  1401. XFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  1402. XWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  1403. XACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
  1404. XOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  1405. X
  1406. X******************************************************************/
  1407. X
  1408. X/* Module definition and import interface */
  1409. X
  1410. Xobject *get_modules PROTO((void));
  1411. Xobject *add_module PROTO((char *name));
  1412. Xobject *import_module PROTO((char *name));
  1413. Xobject *reload_module PROTO((object *m));
  1414. Xvoid doneimport PROTO((void));
  1415. EOF
  1416. fi
  1417. if test -s 'src/metagrammar.h'
  1418. then echo '*** I will not over-write existing file src/metagrammar.h'
  1419. else
  1420. echo 'x - src/metagrammar.h'
  1421. sed 's/^X//' > 'src/metagrammar.h' << 'EOF'
  1422. X/***********************************************************
  1423. XCopyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
  1424. XNetherlands.
  1425. X
  1426. X                        All Rights Reserved
  1427. X
  1428. XPermission to use, copy, modify, and distribute this software and its 
  1429. Xdocumentation for any purpose and without fee is hereby granted, 
  1430. Xprovided that the above copyright notice appear in all copies and that
  1431. Xboth that copyright notice and this permission notice appear in 
  1432. Xsupporting documentation, and that the names of Stichting Mathematisch
  1433. XCentrum or CWI not be used in advertising or publicity pertaining to
  1434. Xdistribution of the software without specific, written prior permission.
  1435. X
  1436. XSTICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
  1437. XTHIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  1438. XFITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
  1439. XFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  1440. XWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  1441. XACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
  1442. XOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  1443. X
  1444. X******************************************************************/
  1445. X
  1446. X#define MSTART 256
  1447. X#define RULE 257
  1448. X#define RHS 258
  1449. X#define ALT 259
  1450. X#define ITEM 260
  1451. X#define ATOM 261
  1452. EOF
  1453. fi
  1454. if test -s 'src/methodobject.h'
  1455. then echo '*** I will not over-write existing file src/methodobject.h'
  1456. else
  1457. echo 'x - src/methodobject.h'
  1458. sed 's/^X//' > 'src/methodobject.h' << 'EOF'
  1459. X/***********************************************************
  1460. XCopyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
  1461. XNetherlands.
  1462. X
  1463. X                        All Rights Reserved
  1464. X
  1465. XPermission to use, copy, modify, and distribute this software and its 
  1466. Xdocumentation for any purpose and without fee is hereby granted, 
  1467. Xprovided that the above copyright notice appear in all copies and that
  1468. Xboth that copyright notice and this permission notice appear in 
  1469. Xsupporting documentation, and that the names of Stichting Mathematisch
  1470. XCentrum or CWI not be used in advertising or publicity pertaining to
  1471. Xdistribution of the software without specific, written prior permission.
  1472. X
  1473. XSTICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
  1474. XTHIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  1475. XFITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
  1476. XFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  1477. XWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  1478. XACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
  1479. XOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  1480. X
  1481. X******************************************************************/
  1482. X
  1483. X/* Method object interface */
  1484. X
  1485. Xextern typeobject Methodtype;
  1486. X
  1487. X#define is_methodobject(op) ((op)->ob_type == &Methodtype)
  1488. X
  1489. Xtypedef object *(*method) FPROTO((object *, object *));
  1490. X
  1491. Xextern object *newmethodobject PROTO((char *, method, object *));
  1492. Xextern method getmethod PROTO((object *));
  1493. Xextern object *getself PROTO((object *));
  1494. X
  1495. Xstruct methodlist {
  1496. X    char *ml_name;
  1497. X    method ml_meth;
  1498. X};
  1499. X
  1500. Xextern object *findmethod PROTO((struct methodlist *, object *, char *));
  1501. EOF
  1502. fi
  1503. if test -s 'src/modsupport.h'
  1504. then echo '*** I will not over-write existing file src/modsupport.h'
  1505. else
  1506. echo 'x - src/modsupport.h'
  1507. sed 's/^X//' > 'src/modsupport.h' << 'EOF'
  1508. X/***********************************************************
  1509. XCopyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
  1510. XNetherlands.
  1511. X
  1512. X                        All Rights Reserved
  1513. X
  1514. XPermission to use, copy, modify, and distribute this software and its 
  1515. Xdocumentation for any purpose and without fee is hereby granted, 
  1516. Xprovided that the above copyright notice appear in all copies and that
  1517. Xboth that copyright notice and this permission notice appear in 
  1518. Xsupporting documentation, and that the names of Stichting Mathematisch
  1519. XCentrum or CWI not be used in advertising or publicity pertaining to
  1520. Xdistribution of the software without specific, written prior permission.
  1521. X
  1522. XSTICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
  1523. XTHIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  1524. XFITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
  1525. XFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  1526. XWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  1527. XACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
  1528. XOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  1529. X
  1530. X******************************************************************/
  1531. X
  1532. X/* Module support interface */
  1533. X
  1534. Xextern object *initmodule PROTO((char *, struct methodlist *));
  1535. EOF
  1536. fi
  1537. if test -s 'src/moduleobject.h'
  1538. then echo '*** I will not over-write existing file src/moduleobject.h'
  1539. else
  1540. echo 'x - src/moduleobject.h'
  1541. sed 's/^X//' > 'src/moduleobject.h' << 'EOF'
  1542. X/***********************************************************
  1543. XCopyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
  1544. XNetherlands.
  1545. X
  1546. X                        All Rights Reserved
  1547. X
  1548. XPermission to use, copy, modify, and distribute this software and its 
  1549. Xdocumentation for any purpose and without fee is hereby granted, 
  1550. Xprovided that the above copyright notice appear in all copies and that
  1551. Xboth that copyright notice and this permission notice appear in 
  1552. Xsupporting documentation, and that the names of Stichting Mathematisch
  1553. XCentrum or CWI not be used in advertising or publicity pertaining to
  1554. Xdistribution of the software without specific, written prior permission.
  1555. X
  1556. XSTICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
  1557. XTHIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  1558. XFITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
  1559. XFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  1560. XWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  1561. XACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
  1562. XOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  1563. X
  1564. X******************************************************************/
  1565. X
  1566. X/* Module object interface */
  1567. X
  1568. Xextern typeobject Moduletype;
  1569. X
  1570. X#define is_moduleobject(op) ((op)->ob_type == &Moduletype)
  1571. X
  1572. Xextern object *newmoduleobject PROTO((char *));
  1573. Xextern object *getmoduledict PROTO((object *));
  1574. Xextern char *getmodulename PROTO((object *));
  1575. EOF
  1576. fi
  1577. if test -s 'src/parsetok.h'
  1578. then echo '*** I will not over-write existing file src/parsetok.h'
  1579. else
  1580. echo 'x - src/parsetok.h'
  1581. sed 's/^X//' > 'src/parsetok.h' << 'EOF'
  1582. X/***********************************************************
  1583. XCopyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
  1584. XNetherlands.
  1585. X
  1586. X                        All Rights Reserved
  1587. X
  1588. XPermission to use, copy, modify, and distribute this software and its 
  1589. Xdocumentation for any purpose and without fee is hereby granted, 
  1590. Xprovided that the above copyright notice appear in all copies and that
  1591. Xboth that copyright notice and this permission notice appear in 
  1592. Xsupporting documentation, and that the names of Stichting Mathematisch
  1593. XCentrum or CWI not be used in advertising or publicity pertaining to
  1594. Xdistribution of the software without specific, written prior permission.
  1595. X
  1596. XSTICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
  1597. XTHIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  1598. XFITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
  1599. XFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  1600. XWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  1601. XACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
  1602. XOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  1603. X
  1604. X******************************************************************/
  1605. X
  1606. X/* Parser-tokenizer link interface */
  1607. X
  1608. Xextern int parsestring PROTO((char *, grammar *, int start, node **n_ret));
  1609. Xextern int parsefile PROTO((FILE *, char *, grammar *, int start,
  1610. X                    char *ps1, char *ps2, node **n_ret));
  1611. EOF
  1612. fi
  1613. if test -s 'src/pgen.h'
  1614. then echo '*** I will not over-write existing file src/pgen.h'
  1615. else
  1616. echo 'x - src/pgen.h'
  1617. sed 's/^X//' > 'src/pgen.h' << 'EOF'
  1618. X/***********************************************************
  1619. XCopyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
  1620. XNetherlands.
  1621. X
  1622. X                        All Rights Reserved
  1623. X
  1624. XPermission to use, copy, modify, and distribute this software and its 
  1625. Xdocumentation for any purpose and without fee is hereby granted, 
  1626. Xprovided that the above copyright notice appear in all copies and that
  1627. Xboth that copyright notice and this permission notice appear in 
  1628. Xsupporting documentation, and that the names of Stichting Mathematisch
  1629. XCentrum or CWI not be used in advertising or publicity pertaining to
  1630. Xdistribution of the software without specific, written prior permission.
  1631. X
  1632. XSTICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
  1633. XTHIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  1634. XFITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
  1635. XFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  1636. XWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  1637. XACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
  1638. XOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  1639. X
  1640. X******************************************************************/
  1641. X
  1642. X/* Parser generator interface */
  1643. X
  1644. Xextern grammar gram;
  1645. X
  1646. Xextern grammar *meta_grammar PROTO((void));
  1647. Xextern grammar *pgen PROTO((struct _node *));
  1648. EOF
  1649. fi
  1650. if test -s 'src/regmagic.h'
  1651. then echo '*** I will not over-write existing file src/regmagic.h'
  1652. else
  1653. echo 'x - src/regmagic.h'
  1654. sed 's/^X//' > 'src/regmagic.h' << 'EOF'
  1655. X/***********************************************************
  1656. XCopyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
  1657. XNetherlands.
  1658. X
  1659. X                        All Rights Reserved
  1660. X
  1661. XPermission to use, copy, modify, and distribute this software and its 
  1662. Xdocumentation for any purpose and without fee is hereby granted, 
  1663. Xprovided that the above copyright notice appear in all copies and that
  1664. Xboth that copyright notice and this permission notice appear in 
  1665. Xsupporting documentation, and that the names of Stichting Mathematisch
  1666. XCentrum or CWI not be used in advertising or publicity pertaining to
  1667. Xdistribution of the software without specific, written prior permission.
  1668. X
  1669. XSTICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
  1670. XTHIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  1671. XFITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
  1672. XFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  1673. XWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  1674. XACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
  1675. XOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  1676. X
  1677. X******************************************************************/
  1678. X
  1679. X/*
  1680. X * The first byte of the regexp internal "program" is actually this magic
  1681. X * number; the start node begins in the second byte.
  1682. X */
  1683. X#define    MAGIC    0234
  1684. EOF
  1685. fi
  1686. if test -s 'src/sc_errors.h'
  1687. then echo '*** I will not over-write existing file src/sc_errors.h'
  1688. else
  1689. echo 'x - src/sc_errors.h'
  1690. sed 's/^X//' > 'src/sc_errors.h' << 'EOF'
  1691. X/***********************************************************
  1692. XCopyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
  1693. XNetherlands.
  1694. X
  1695. X                        All Rights Reserved
  1696. X
  1697. XPermission to use, copy, modify, and distribute this software and its 
  1698. Xdocumentation for any purpose and without fee is hereby granted, 
  1699. Xprovided that the above copyright notice appear in all copies and that
  1700. Xboth that copyright notice and this permission notice appear in 
  1701. Xsupporting documentation, and that the names of Stichting Mathematisch
  1702. XCentrum or CWI not be used in advertising or publicity pertaining to
  1703. Xdistribution of the software without specific, written prior permission.
  1704. X
  1705. XSTICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
  1706. XTHIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  1707. XFITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
  1708. XFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  1709. XWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  1710. XACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
  1711. XOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  1712. X
  1713. X******************************************************************/
  1714. X
  1715. X
  1716. X#define NoBufSize    1
  1717. X#define TwoBufSize    2
  1718. X#define StackOverflow    3
  1719. X#define StackUnderflow    4
  1720. X#define TypeFailure    5
  1721. X#define RangeError    6
  1722. X#define SizeError    7
  1723. X#define BufferOverflow    8
  1724. X#define NoEndLoop    9
  1725. X#define FlagError    10
  1726. X#define ElementIsNull    11
  1727. X#define TransError    12
  1728. X
  1729. Xextern object *err_scerr PROTO((int sc_errno));
  1730. Xextern err_scerrset PROTO((int sc_errno, object *value, char *instr));
  1731. Xextern object *StubcodeError;
  1732. EOF
  1733. fi
  1734. if test -s 'src/stdwinobject.h'
  1735. then echo '*** I will not over-write existing file src/stdwinobject.h'
  1736. else
  1737. echo 'x - src/stdwinobject.h'
  1738. sed 's/^X//' > 'src/stdwinobject.h' << 'EOF'
  1739. X/***********************************************************
  1740. XCopyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
  1741. XNetherlands.
  1742. X
  1743. X                        All Rights Reserved
  1744. X
  1745. XPermission to use, copy, modify, and distribute this software and its 
  1746. Xdocumentation for any purpose and without fee is hereby granted, 
  1747. Xprovided that the above copyright notice appear in all copies and that
  1748. Xboth that copyright notice and this permission notice appear in 
  1749. Xsupporting documentation, and that the names of Stichting Mathematisch
  1750. XCentrum or CWI not be used in advertising or publicity pertaining to
  1751. Xdistribution of the software without specific, written prior permission.
  1752. X
  1753. XSTICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
  1754. XTHIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  1755. XFITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
  1756. XFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  1757. XWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  1758. XACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
  1759. XOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  1760. X
  1761. X******************************************************************/
  1762. X
  1763. X/* Stdwin object interface */
  1764. X
  1765. Xextern typeobject Stdwintype;
  1766. X
  1767. X#define is_stdwinobject(op) ((op)->ob_type == &Stdwintype)
  1768. X
  1769. Xextern object *newstdwinobject PROTO((void));
  1770. EOF
  1771. fi
  1772. if test -s 'src/strdup.c'
  1773. then echo '*** I will not over-write existing file src/strdup.c'
  1774. else
  1775. echo 'x - src/strdup.c'
  1776. sed 's/^X//' > 'src/strdup.c' << 'EOF'
  1777. X/***********************************************************
  1778. XCopyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
  1779. XNetherlands.
  1780. X
  1781. X                        All Rights Reserved
  1782. X
  1783. XPermission to use, copy, modify, and distribute this software and its 
  1784. Xdocumentation for any purpose and without fee is hereby granted, 
  1785. Xprovided that the above copyright notice appear in all copies and that
  1786. Xboth that copyright notice and this permission notice appear in 
  1787. Xsupporting documentation, and that the names of Stichting Mathematisch
  1788. XCentrum or CWI not be used in advertising or publicity pertaining to
  1789. Xdistribution of the software without specific, written prior permission.
  1790. X
  1791. XSTICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
  1792. XTHIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  1793. XFITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
  1794. XFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  1795. XWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  1796. XACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
  1797. XOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  1798. X
  1799. X******************************************************************/
  1800. X
  1801. X#include "PROTO.h"
  1802. X#include "malloc.h"
  1803. X#include "string.h"
  1804. X
  1805. Xchar *
  1806. Xstrdup(str)
  1807. X    const char *str;
  1808. X{
  1809. X    if (str != NULL) {
  1810. X        register char *copy = NEW(char, strlen(str) + 1);
  1811. X        if (copy != NULL)
  1812. X            return strcpy(copy, str);
  1813. X    }
  1814. X    return NULL;
  1815. X}
  1816. EOF
  1817. fi
  1818. if test -s 'src/strerror.c'
  1819. then echo '*** I will not over-write existing file src/strerror.c'
  1820. else
  1821. echo 'x - src/strerror.c'
  1822. sed 's/^X//' > 'src/strerror.c' << 'EOF'
  1823. X/***********************************************************
  1824. XCopyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
  1825. XNetherlands.
  1826. X
  1827. X                        All Rights Reserved
  1828. X
  1829. XPermission to use, copy, modify, and distribute this software and its 
  1830. Xdocumentation for any purpose and without fee is hereby granted, 
  1831. Xprovided that the above copyright notice appear in all copies and that
  1832. Xboth that copyright notice and this permission notice appear in 
  1833. Xsupporting documentation, and that the names of Stichting Mathematisch
  1834. XCentrum or CWI not be used in advertising or publicity pertaining to
  1835. Xdistribution of the software without specific, written prior permission.
  1836. X
  1837. XSTICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
  1838. XTHIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  1839. XFITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
  1840. XFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  1841. XWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  1842. XACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
  1843. XOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  1844. X
  1845. X******************************************************************/
  1846. X
  1847. X/* PD implementation of strerror() for systems that don't have it.
  1848. X   Author: Guido van Rossum, CWI Amsterdam, Oct. 1990, <guido@cwi.nl>. */
  1849. X
  1850. X#include <stdio.h>
  1851. X
  1852. Xextern int sys_nerr;
  1853. Xextern char *sys_errlist[];
  1854. X
  1855. Xchar *
  1856. Xstrerror(err)
  1857. X    int err;
  1858. X{
  1859. X    static char buf[20];
  1860. X    if (err >= 0 && err < sys_nerr)
  1861. X        return sys_errlist[err];
  1862. X    sprintf(buf, "Unknown errno %d", err);
  1863. X    return buf;
  1864. X}
  1865. X
  1866. X#ifdef THINK_C
  1867. Xint sys_nerr = 0;
  1868. Xchar *sys_errlist[1] = 0;
  1869. X#endif
  1870. EOF
  1871. fi
  1872. if test -s 'src/sysmodule.h'
  1873. then echo '*** I will not over-write existing file src/sysmodule.h'
  1874. else
  1875. echo 'x - src/sysmodule.h'
  1876. sed 's/^X//' > 'src/sysmodule.h' << 'EOF'
  1877. X/***********************************************************
  1878. XCopyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
  1879. XNetherlands.
  1880. X
  1881. X                        All Rights Reserved
  1882. X
  1883. XPermission to use, copy, modify, and distribute this software and its 
  1884. Xdocumentation for any purpose and without fee is hereby granted, 
  1885. Xprovided that the above copyright notice appear in all copies and that
  1886. Xboth that copyright notice and this permission notice appear in 
  1887. Xsupporting documentation, and that the names of Stichting Mathematisch
  1888. XCentrum or CWI not be used in advertising or publicity pertaining to
  1889. Xdistribution of the software without specific, written prior permission.
  1890. X
  1891. XSTICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
  1892. XTHIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  1893. XFITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
  1894. XFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  1895. XWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  1896. XACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
  1897. XOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  1898. X
  1899. X******************************************************************/
  1900. X
  1901. X/* System module interface */
  1902. X
  1903. Xobject *sysget PROTO((char *));
  1904. Xint sysset PROTO((char *, object *));
  1905. XFILE *sysgetfile PROTO((char *, FILE *));
  1906. Xvoid initsys PROTO((void));
  1907. EOF
  1908. fi
  1909. if test -s 'src/traceback.h'
  1910. then echo '*** I will not over-write existing file src/traceback.h'
  1911. else
  1912. echo 'x - src/traceback.h'
  1913. sed 's/^X//' > 'src/traceback.h' << 'EOF'
  1914. X/***********************************************************
  1915. XCopyright 1991 by Stichting Mathematisch Centrum, Amsterdam, The
  1916. XNetherlands.
  1917. X
  1918. X                        All Rights Reserved
  1919. X
  1920. XPermission to use, copy, modify, and distribute this software and its 
  1921. Xdocumentation for any purpose and without fee is hereby granted, 
  1922. Xprovided that the above copyright notice appear in all copies and that
  1923. Xboth that copyright notice and this permission notice appear in 
  1924. Xsupporting documentation, and that the names of Stichting Mathematisch
  1925. XCentrum or CWI not be used in advertising or publicity pertaining to
  1926. Xdistribution of the software without specific, written prior permission.
  1927. X
  1928. XSTICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
  1929. XTHIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  1930. XFITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
  1931. XFOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  1932. XWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  1933. XACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
  1934. XOF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  1935. X
  1936. X******************************************************************/
  1937. X
  1938. X/* Traceback interface */
  1939. X
  1940. Xint tb_here PROTO((struct _frame *, int, int));
  1941. Xobject *tb_fetch PROTO((void));
  1942. Xint tb_store PROTO((object *));
  1943. Xint tb_print PROTO((object *, FILE *));
  1944. EOF
  1945. fi
  1946. echo 'Part 20 out of 21 of pack.out complete.'
  1947. exit 0
  1948.