summaryrefslogtreecommitdiff
path: root/lang/guile/patches/patch-ak
blob: 367d22418bd2512038317b26d276f34d0d408113 (plain)
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
$NetBSD: patch-ak,v 1.1 2005/10/30 00:56:40 gdt Exp $

--- ice-9/slib.scm.orig	2004-08-11 21:04:21.000000000 -0400
+++ ice-9/slib.scm
@@ -1,390 +1,7 @@
-;;;; slib.scm --- definitions needed to get SLIB to work with Guile
-;;;;
-;;;;	Copyright (C) 1997, 1998, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
-;;;;
-;;;; This file is part of GUILE.
-;;;; 
-;;;; GUILE is free software; you can redistribute it and/or modify it
-;;;; under the terms of the GNU General Public License as published by
-;;;; the Free Software Foundation; either version 2, or (at your
-;;;; option) any later version.
-;;;; 
-;;;; GUILE is distributed in the hope that it will be useful, but
-;;;; WITHOUT ANY WARRANTY; without even the implied warranty of
-;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-;;;; General Public License for more details.
-;;;; 
-;;;; You should have received a copy of the GNU General Public License
-;;;; along with GUILE; see the file COPYING.  If not, write to the
-;;;; Free Software Foundation, Inc., 59 Temple Place, Suite 330,
-;;;; Boston, MA 02111-1307 USA
-;;;;
-;;;; As a special exception, the Free Software Foundation gives permission
-;;;; for additional uses of the text contained in its release of GUILE.
-;;;;
-;;;; The exception is that, if you link the GUILE library with other files
-;;;; to produce an executable, this does not by itself cause the
-;;;; resulting executable to be covered by the GNU General Public License.
-;;;; Your use of that executable is in no way restricted on account of
-;;;; linking the GUILE library code into it.
-;;;;
-;;;; This exception does not however invalidate any other reasons why
-;;;; the executable file might be covered by the GNU General Public License.
-;;;;
-;;;; This exception applies only to the code released by the
-;;;; Free Software Foundation under the name GUILE.  If you copy
-;;;; code from other Free Software Foundation releases into a copy of
-;;;; GUILE, as the General Public License permits, the exception does
-;;;; not apply to the code that you add in this way.  To avoid misleading
-;;;; anyone as to the status of such modified files, you must delete
-;;;; this exception notice from them.
-;;;;
-;;;; If you write modifications of your own for GUILE, it is your choice
-;;;; whether to permit this exception to apply to your modifications.
-;;;; If you do not wish that, delete this exception notice.
-;;;;
-(define-module (ice-9 slib)
-  :export (slib:load
-	   implementation-vicinity
-	   library-vicinity
-	   home-vicinity
-	   scheme-implementation-type
-	   scheme-implementation-version
-	   make-random-state
-	   <? <=? =? >? >=?
-	   require)
-  :no-backtrace)
+;; Load slib's init file directly, implicitly symbols into the current
+;; module.
+(load (string-append (assoc-ref %guile-build-info 'pkgdatadir)
+		     "/slib/guile.init"))
 
-
-
-(define (eval-load <filename> evl)
-  (if (not (file-exists? <filename>))
-      (set! <filename> (string-append <filename> (scheme-file-suffix))))
-  (call-with-input-file <filename>
-    (lambda (port)
-      (let ((old-load-pathname *load-pathname*))
-	(set! *load-pathname* <filename>)
-	(do ((o (read port) (read port)))
-	    ((eof-object? o))
-	  (evl o))
-	(set! *load-pathname* old-load-pathname)))))
-
-
-
-(define-public slib:exit quit)
-(define-public slib:error error)
-(define-public slib:warn warn)
-(define-public slib:eval (lambda (x) (eval x slib-module)))
-(define defmacro:eval (lambda (x) (eval x (interaction-environment))))
-(define logical:logand logand)
-(define logical:logior logior)
-(define logical:logxor logxor)
-(define logical:lognot lognot)
-(define logical:ash ash)
-(define logical:logcount logcount)
-(define logical:integer-length integer-length)
-(define logical:bit-extract bit-extract)
-(define logical:integer-expt integer-expt)
-(define logical:ipow-by-squaring ipow-by-squaring)
-(define-public slib:eval-load eval-load)
-(define-public slib:tab #\tab)
-(define-public slib:form-feed #\page)
-
-(define slib-module (current-module))
-
-(define (defined? symbol)
-  (module-defined? slib-module symbol))
-
-(define slib:features
-  (append '(source
-	    eval
-	    abort
-	    alist
-	    defmacro
-	    delay
-	    dynamic-wind
-	    full-continuation
-	    hash
-	    hash-table
-	    line-i/o
-	    logical
-	    multiarg/and-
-	    multiarg-apply
-	    promise
-	    rev2-procedures
-	    rev4-optional-procedures
-	    string-port
-	    with-file)
-
-	  (if (defined? 'getenv)
-	      '(getenv)
-	      '())
-
-	  (if (defined? 'current-time)
-	      '(current-time)
-	      '())
-
-	  (if (defined? 'system)
-	      '(system)
-	      '())
-
-	  (if (defined? 'char-ready?)
-	      '(char-ready?)
-	      '())
-
-	  (if (and (string->number "0.0") (inexact? (string->number "0.0")))
-	      '(inexact)
-	      '())
-
-	  (if (rational? (string->number "1/19"))
-	      '(rational)
-	      '())
-
-	  (if (real? (string->number "0.0"))
-	      '(real)
-	      ())
-
-	  (if (complex? (string->number "1+i"))
-	      '(complex)
-	      '())
-
-	  (let ((n (string->number "9999999999999999999999999999999")))
-	    (if (and n (exact? n))
-		'(bignum)
-		'()))))
-
-
-;; The array module specified by slib 3a1 is not the same as what guile
-;; provides, so we must remove `array' from the features list.
-;;
-;; The main difference is `create-array' which is similar to
-;; `make-uniform-array', but the `Ac64' etc prototype procedures incorporate
-;; an initial fill element into the prototype.
-;;
-;; Believe the array-for-each module will need to be taken from slib when
-;; the array module is taken from there, since what the array module creates
-;; won't be understood by the guile functions.  So remove `array-for-each'
-;; from the features list too.
-;;
-;; Also, slib 3a1 array-for-each specifies an `array-map' which is not in
-;; guile (but could be implemented quite easily).
-;;
-;; ENHANCE-ME: It'd be nice to implement what's necessary, since the guile
-;; functions should be more efficient than the implementation in slib.
-;;
-;; FIXME: Since the *features* variable is shared by slib and the guile
-;; core, removing these feature symbols has the unhappy effect of making it
-;; look like they aren't in the core either.  Let's assume that arrays have
-;; been present unconditionally long enough that no guile-specific code will
-;; bother to test.  An alternative would be to make a new separate
-;; *features* variable which the slib stuff operated on, leaving the core
-;; mechanism alone.  That might be a good thing anyway.
-;;
-(set! *features* (delq 'array          *features*))
-(set! *features* (delq 'array-for-each *features*))
-
-
-;;; FIXME: Because uers want require to search the path, this uses
-;;; load-from-path, which probably isn't a hot idea.  slib
-;;; doesn't expect this function to search a path, so I expect to get
-;;; bug reports at some point complaining that the wrong file gets
-;;; loaded when something accidentally appears in the path before
-;;; slib, etc. ad nauseum.  However, the right fix seems to involve
-;;; changing catalog:get in slib/require.scm, and I don't expect
-;;; Aubrey will integrate such a change.  So I'm just going to punt
-;;; for the time being.
-(define (slib:load name)
-  (save-module-excursion
-   (lambda ()
-     (set-current-module slib-module)
-     (let ((errinfo (catch 'system-error
-			   (lambda ()
-			     (load-from-path name)
-			     #f)
-			   (lambda args args))))
-       (if (and errinfo
-		(catch 'system-error
-		       (lambda ()
-			 (load-from-path
-			  (string-append name ".scm"))
-			 #f)
-		       (lambda args args)))
-	   (apply throw errinfo))))))
-
-(define-public slib:load-source slib:load)
-(define defmacro:load slib:load)
-
-(define slib-parent-dir
-  (let* ((path (%search-load-path "slib/require.scm")))
-    (if path
-	(substring path 0 (- (string-length path) 17))
-	(error "Could not find slib/require.scm in " %load-path))))
-
-(define (implementation-vicinity)
-  (string-append slib-parent-dir "/"))
-(define (library-vicinity)
-  (string-append (implementation-vicinity) "slib/"))
-(define home-vicinity
-  (let ((home-path (getenv "HOME")))
-    (lambda () home-path)))
-(define (scheme-implementation-type) 'guile)
-(define (scheme-implementation-version) "")
-
-;; legacy from r3rs, but slib says all implementations provide these
-;; ("Legacy" section of the "Miscellany" node in the manual)
-(define-public t   #t)
-(define-public nil #f)
-
-(define-public (output-port-width . arg) 80)
-(define-public (output-port-height . arg) 24)
-(define (identity x) x)
-
-;; slib 3a1 and up, straight from Template.scm
-(define-public (call-with-open-ports . ports)
-  (define proc (car ports))
-  (cond ((procedure? proc) (set! ports (cdr ports)))
-	(else (set! ports (reverse ports))
-	      (set! proc (car ports))
-	      (set! ports (reverse (cdr ports)))))
-  (let ((ans (apply proc ports)))
-    (for-each close-port ports)
-    ans))
-
-;; slib (version 3a1) requires open-file accept a symbol r, rb, w or wb for
-;; MODES, so extend the guile core open-file accordingly.
-;;
-;; slib (version 3a1) also calls open-file with strings "rb" or "wb", not
-;; sure if that's intentional, but in any case this extension continues to
-;; accept strings to make that work.
-;;
-(define-public open-file
-  (let ((guile-core-open-file open-file))
-    (lambda (filename modes)
-      (if (symbol? modes)
-	  (set! modes (symbol->string modes)))
-      (guile-core-open-file filename modes))))
-
-;; returning #t/#f instead of throwing an error for failure
-(define-public delete-file
-  (let ((guile-core-delete-file delete-file))
-    (lambda (filename)
-      (catch 'system-error
-	(lambda () (guile-core-delete-file filename) #t)
-	(lambda args #f)))))
-
-;; Nothing special to do for this, so straight from Template.scm.  Maybe
-;; "sensible-browser" for a debian system would be worth trying too (and
-;; would be good on a tty).
-(define-public (browse-url url)
-  (define (try cmd end) (zero? (system (string-append cmd url end))))
-  (or (try "netscape-remote -remote 'openURL(" ")'")
-      (try "netscape -remote 'openURL(" ")'")
-      (try "netscape '" "'&")
-      (try "netscape '" "'")))
-
-;;; {Random numbers}
-;;;
-(define (make-random-state . args)
-  (let ((seed (if (null? args) *random-state* (car args))))
-    (cond ((string? seed))
-	  ((number? seed) (set! seed (number->string seed)))
-	  (else (let ()
-		  (require 'object->string)
-		  (set! seed (object->limited-string seed 50)))))
-    (seed->random-state seed)))
-
-;;; {rev2-procedures}
-;;;
-
-(define <?  <)
-(define <=? <=)
-(define =?  =)
-(define >?  >)
-(define >=? >=)
-
-;;; {system}
-;;;
-
-;; If the program run is killed by a signal, the shell normally gives an
-;; exit code of 128+signum.  If the shell itself is killed by a signal then
-;; we do the same 128+signum here.
-;;
-;; "stop-sig" shouldn't arise here, since system shouldn't be calling
-;; waitpid with WUNTRACED, but allow for it anyway, just in case.
-;;
-(if (defined? 'system)
-    (define-public system
-      (let ((guile-core-system system))
-	(lambda (str)
-	  (let ((st (guile-core-system str)))
-	    (or (status:exit-val st)
-		(+ 128 (or (status:term-sig st)
-			   (status:stop-sig st)))))))))
-
-;;; {Time}
-;;;
-
-(define-public difftime -)
-(define-public offset-time +)
-
-
-(define %system-define define)
-
-(define define
-  (procedure->memoizing-macro
-   (lambda (exp env)
-     (if (= (length env) 1)
-	 `(define-public ,@(cdr exp))
-	 `(%system-define ,@(cdr exp))))))
-
-;;; Hack to make syncase macros work in the slib module
-(if (nested-ref the-root-module '(app modules ice-9 syncase))
-    (set-object-property! (module-local-variable (current-module) 'define)
-			  '*sc-expander*
-			  '(define)))
-
-(define (software-type)
-  "Return a symbol describing the current platform's operating system.
-This may be one of AIX, VMS, UNIX, COHERENT, WINDOWS, MS-DOS, OS/2,
-THINKC, AMIGA, ATARIST, MACH, or ACORN.
-
-Note that most varieties of Unix are considered to be simply \"UNIX\".
-That is because when a program depends on features that are not present
-on every operating system, it is usually better to test for the presence
-or absence of that specific feature.  The return value of
-@code{software-type} should only be used for this purpose when there is
-no other easy or unambiguous way of detecting such features."
- 'UNIX)
-
-(slib:load (in-vicinity (library-vicinity) "require.scm"))
-
-(define require require:require)
-
-;; {Extensions to the require system so that the user can add new
-;;  require modules easily.}
-
-(define *vicinity-table*
-  (list
-   (cons 'implementation (implementation-vicinity))
-   (cons 'library (library-vicinity))))
-
-(define (install-require-vicinity name vicinity)
-  (let ((entry (assq name *vicinity-table*)))
-    (if entry
-	(set-cdr! entry vicinity)
-	(set! *vicinity-table*
-	      (acons name vicinity *vicinity-table*)))))
-
-(define (install-require-module name vicinity-name file-name)
-  (if (not *catalog*)	     ;Fix which loads catalog in slib
-      (catalog:get 'random)) ;(doesn't load the feature 'random)
-  (let ((entry (assq name *catalog*))
-	(vicinity (cdr (assq vicinity-name *vicinity-table*))))
-    (let ((path-name (in-vicinity vicinity file-name)))
-      (if entry
-	  (set-cdr! entry path-name)
-	  (set! *catalog*
-		(acons name path-name *catalog*))))))
-
-(define (make-exchanger obj)
-  (lambda (rep) (let ((old obj)) (set! obj rep) old)))
+;; use-modules will fail if the file fails to define the module
+(define-module (ice-9 slib))