[gimp] Pulled in final changes from 1.40 release of the separate TinyScheme project.
- From: Kevin Cozens <kcozens src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Pulled in final changes from 1.40 release of the separate TinyScheme project.
- Date: Mon, 7 Feb 2011 20:57:08 +0000 (UTC)
commit fac7d4dd64602b051cadb0ab0de001a5c23025ff
Author: Kevin Cozens <kcozens cvs gnome org>
Date: Mon Feb 7 15:29:31 2011 -0500
Pulled in final changes from 1.40 release of the separate TinyScheme project.
With this commit, the TinyScheme component of Script-Fu now has all changes
and bug fixes that have been applied to the separate TinyScheme project.
plug-ins/script-fu/scripts/script-fu.init | 229 +++++++-------
plug-ins/script-fu/tinyscheme/CHANGES | 502 +++++++++++++++++------------
plug-ins/script-fu/tinyscheme/Manual.txt | 51 ++--
plug-ins/script-fu/tinyscheme/init.scm | 113 ++++----
plug-ins/script-fu/tinyscheme/scheme.c | 4 +-
5 files changed, 498 insertions(+), 401 deletions(-)
---
diff --git a/plug-ins/script-fu/scripts/script-fu.init b/plug-ins/script-fu/scripts/script-fu.init
index 4d97156..f0d5d14 100644
--- a/plug-ins/script-fu/scripts/script-fu.init
+++ b/plug-ins/script-fu/scripts/script-fu.init
@@ -1,4 +1,4 @@
-; Initialization file for TinySCHEME 1.38
+; Initialization file for TinySCHEME 1.40
; Per R5RS, up to four deep compositions should be defined
(define (caar x) (car (car x)))
@@ -30,6 +30,18 @@
(define (cdddar x) (cdr (cdr (cdr (car x)))))
(define (cddddr x) (cdr (cdr (cdr (cdr x)))))
+;;;; Utility to ease macro creation
+(define (macro-expand form)
+ ((eval (get-closure-code (eval (car form)))) form))
+
+(define (macro-expand-all form)
+ (if (macro? form)
+ (macro-expand-all (macro-expand form))
+ form))
+
+(define *compile-hook* macro-expand-all)
+
+
(macro (unless form)
`(if (not ,(cadr form)) (begin ,@(cddr form))))
@@ -69,7 +81,7 @@
(if (null? a)
0
(let ((aa (abs (car a)))
- (bb (abs (cadr a))))
+ (bb (abs (cadr a))))
(if (= bb 0)
aa
(gcd bb (remainder aa bb)))))))
@@ -78,12 +90,11 @@
(if (null? a)
1
(let ((aa (abs (car a)))
- (bb (abs (cadr a))))
+ (bb (abs (cadr a))))
(if (or (= aa 0) (= bb 0))
0
(abs (* (quotient aa (gcd aa bb)) bb)))))))
-(define call/cc call-with-current-continuation)
(define (string . charlist)
(list->string charlist))
@@ -115,12 +126,12 @@
(define (string-copy str)
(string-append str))
-(define (string->anyatom str pred . radix)
+(define (string->anyatom str pred)
(let* ((a (string->atom str)))
(if (pred a) a
- (error "string->xxx: not a xxx" a))))
+ (error "string->xxx: not a xxx" a))))
-(define (string->number str . radix) (string->anyatom str number? radix))
+(define (string->number str) (string->anyatom str number?))
(define (anyatom->string n pred)
(if (pred n)
@@ -188,31 +199,31 @@
(if (null? lists)
(cons cars cdrs)
(let ((car1 (caar lists))
- (cdr1 (cdar lists)))
- (unzip1-with-cdr-iterative
- (cdr lists)
- (append cars (list car1))
- (append cdrs (list cdr1))))))
+ (cdr1 (cdar lists)))
+ (unzip1-with-cdr-iterative
+ (cdr lists)
+ (append cars (list car1))
+ (append cdrs (list cdr1))))))
(define (map proc . lists)
(if (null? lists)
(apply proc)
(if (null? (car lists))
- '()
- (let* ((unz (apply unzip1-with-cdr lists))
- (cars (car unz))
- (cdrs (cdr unz)))
- (cons (apply proc cars) (apply map (cons proc cdrs)))))))
+ '()
+ (let* ((unz (apply unzip1-with-cdr lists))
+ (cars (car unz))
+ (cdrs (cdr unz)))
+ (cons (apply proc cars) (apply map (cons proc cdrs)))))))
(define (for-each proc . lists)
(if (null? lists)
(apply proc)
(if (null? (car lists))
- #t
- (let* ((unz (apply unzip1-with-cdr lists))
- (cars (car unz))
- (cdrs (cdr unz)))
- (apply proc cars) (apply map (cons proc cdrs))))))
+ #t
+ (let* ((unz (apply unzip1-with-cdr lists))
+ (cars (car unz))
+ (cdrs (cdr unz)))
+ (apply proc cars) (apply map (cons proc cdrs))))))
(define (list-tail x k)
(if (zero? k)
@@ -317,22 +328,22 @@
;;;;;Helper for the dynamic-wind definition. By Tom Breton (Tehom)
(define (shared-tail x y)
(let ( (len-x (length x))
- (len-y (length y)))
+ (len-y (length y)))
(define (shared-tail-helper x y)
- (if
- (eq? x y)
- x
- (shared-tail-helper (cdr x) (cdr y))))
+ (if
+ (eq? x y)
+ x
+ (shared-tail-helper (cdr x) (cdr y))))
(cond
- ((> len-x len-y)
- (shared-tail-helper
- (list-tail x (- len-x len-y))
- y))
- ((< len-x len-y)
- (shared-tail-helper
- x
- (list-tail y (- len-y len-x))))
- (#t (shared-tail-helper x y)))))
+ ((> len-x len-y)
+ (shared-tail-helper
+ (list-tail x (- len-x len-y))
+ y))
+ ((< len-x len-y)
+ (shared-tail-helper
+ x
+ (list-tail y (- len-y len-x))))
+ (#t (shared-tail-helper x y)))))
;;;;;Dynamic-wind by Tom Breton (Tehom)
@@ -343,9 +354,9 @@
;;These functions are defined in the context of a private list of
;;pairs of before/after procs.
( (*active-windings* '())
- ;;We'll define some functions into the larger environment, so
- ;;we need to know it.
- (outer-env (current-environment)))
+ ;;We'll define some functions into the larger environment, so
+ ;;we need to know it.
+ (outer-env (current-environment)))
;;Poor-man's structure operations
(define before-func car)
@@ -354,72 +365,72 @@
;;Manage active windings
(define (activate-winding! new)
- ((before-func new))
- (set! *active-windings* (cons new *active-windings*)))
+ ((before-func new))
+ (set! *active-windings* (cons new *active-windings*)))
(define (deactivate-top-winding!)
- (let ((old-top (car *active-windings*)))
- ;;Remove it from the list first so it's not active during its
- ;;own exit.
- (set! *active-windings* (cdr *active-windings*))
- ((after-func old-top))))
+ (let ((old-top (car *active-windings*)))
+ ;;Remove it from the list first so it's not active during its
+ ;;own exit.
+ (set! *active-windings* (cdr *active-windings*))
+ ((after-func old-top))))
(define (set-active-windings! new-ws)
- (unless (eq? new-ws *active-windings*)
- (let ((shared (shared-tail new-ws *active-windings*)))
-
- ;;Define the looping functions.
- ;;Exit the old list. Do deeper ones last. Don't do
- ;;any shared ones.
- (define (pop-many)
- (unless (eq? *active-windings* shared)
- (deactivate-top-winding!)
- (pop-many)))
- ;;Enter the new list. Do deeper ones first so that the
- ;;deeper windings will already be active. Don't do any
- ;;shared ones.
- (define (push-many new-ws)
- (unless (eq? new-ws shared)
- (push-many (cdr new-ws))
- (activate-winding! (car new-ws))))
-
- ;;Do it.
- (pop-many)
- (push-many new-ws))))
+ (unless (eq? new-ws *active-windings*)
+ (let ((shared (shared-tail new-ws *active-windings*)))
+
+ ;;Define the looping functions.
+ ;;Exit the old list. Do deeper ones last. Don't do
+ ;;any shared ones.
+ (define (pop-many)
+ (unless (eq? *active-windings* shared)
+ (deactivate-top-winding!)
+ (pop-many)))
+ ;;Enter the new list. Do deeper ones first so that the
+ ;;deeper windings will already be active. Don't do any
+ ;;shared ones.
+ (define (push-many new-ws)
+ (unless (eq? new-ws shared)
+ (push-many (cdr new-ws))
+ (activate-winding! (car new-ws))))
+
+ ;;Do it.
+ (pop-many)
+ (push-many new-ws))))
;;The definitions themselves.
(eval
- `(define call-with-current-continuation
- ;;It internally uses the built-in call/cc, so capture it.
- ,(let ((old-c/cc call-with-current-continuation))
- (lambda (func)
- ;;Use old call/cc to get the continuation.
- (old-c/cc
- (lambda (continuation)
- ;;Call func with not the continuation itself
- ;;but a procedure that adjusts the active
- ;;windings to what they were when we made
- ;;this, and only then calls the
- ;;continuation.
- (func
- (let ((current-ws *active-windings*))
- (lambda (x)
- (set-active-windings! current-ws)
- (continuation x)))))))))
- outer-env)
+ `(define call-with-current-continuation
+ ;;It internally uses the built-in call/cc, so capture it.
+ ,(let ((old-c/cc call-with-current-continuation))
+ (lambda (func)
+ ;;Use old call/cc to get the continuation.
+ (old-c/cc
+ (lambda (continuation)
+ ;;Call func with not the continuation itself
+ ;;but a procedure that adjusts the active
+ ;;windings to what they were when we made
+ ;;this, and only then calls the
+ ;;continuation.
+ (func
+ (let ((current-ws *active-windings*))
+ (lambda (x)
+ (set-active-windings! current-ws)
+ (continuation x)))))))))
+ outer-env)
;;We can't just say "define (dynamic-wind before thunk after)"
;;because the lambda it's defined to lives in this environment,
;;not in the global environment.
(eval
- `(define dynamic-wind
- ,(lambda (before thunk after)
- ;;Make a new winding
- (activate-winding! (make-winding before after))
- (let ((result (thunk)))
- ;;Get rid of the new winding.
- (deactivate-top-winding!)
- ;;The return value is that of thunk.
- result)))
- outer-env)))
+ `(define dynamic-wind
+ ,(lambda (before thunk after)
+ ;;Make a new winding
+ (activate-winding! (make-winding before after))
+ (let ((result (thunk)))
+ ;;Get rid of the new winding.
+ (deactivate-top-winding!)
+ ;;The return value is that of thunk.
+ result)))
+ outer-env)))
(define call/cc call-with-current-continuation)
@@ -502,10 +513,6 @@
(define (acons x y z) (cons (cons x y) z))
-;;;; Utility to ease macro creation
-(define (macro-expand form)
- ((eval (get-closure-code (eval (car form)))) form))
-
;;;; Handy for imperative programs
;;;; Used as: (define-with-return (foo x y) .... (return z) ...)
(macro (define-with-return form)
@@ -570,8 +577,8 @@
(let* ((env (if (null? envl) (current-environment) (eval (car envl))))
(xval (eval x env)))
(if (closure? xval)
- (make-closure (get-closure-code xval) env)
- xval)))
+ (make-closure (get-closure-code xval) env)
+ xval)))
; Redefine this if you install another package infrastructure
; Also redefine 'package'
@@ -679,15 +686,15 @@
(define (cond-eval condition)
(cond ((symbol? condition)
- (if (member condition *features*) #t #f))
- ((eq? condition #t) #t)
- ((eq? condition #f) #f)
- (else (case (car condition)
- ((and) (cond-eval-and (cdr condition)))
- ((or) (cond-eval-or (cdr condition)))
- ((not) (if (not (null? (cddr condition)))
- (error "cond-expand : 'not' takes 1 argument")
- (not (cond-eval (cadr condition)))))
- (else (error "cond-expand : unknown operator" (car condition)))))))
+ (if (member condition *features*) #t #f))
+ ((eq? condition #t) #t)
+ ((eq? condition #f) #f)
+ (else (case (car condition)
+ ((and) (cond-eval-and (cdr condition)))
+ ((or) (cond-eval-or (cdr condition)))
+ ((not) (if (not (null? (cddr condition)))
+ (error "cond-expand : 'not' takes 1 argument")
+ (not (cond-eval (cadr condition)))))
+ (else (error "cond-expand : unknown operator" (car condition)))))))
(gc-verbose #f)
diff --git a/plug-ins/script-fu/tinyscheme/CHANGES b/plug-ins/script-fu/tinyscheme/CHANGES
index e2a06d0..fcbe942 100644
--- a/plug-ins/script-fu/tinyscheme/CHANGES
+++ b/plug-ins/script-fu/tinyscheme/CHANGES
@@ -1,207 +1,295 @@
-Change Log
-----------
-
-Version 1.38
- Interim release until the rewrite, mostly incorporating modifications
- from Kevin Cozens. Small addition for Cygwin in the makefile, and
- modifications by Andrew Guenther for Apple platforms.
-Version 1.37
- Joe Buehler submitted reserve_cells.
-Version 1.36
- Joe Buehler fixed a patch in the allocator.
- Alexander Shendi moved the comment handling in the scanner, which
- fixed an obscure bug for which Mike E had provided a patch as well.
- Kevin Cozens has submitted some fixes and modifications which have
- not been incorporated yet in their entirety.
-Version 1.35
- Todd Showalter discovered that the number of free cells reported
- after GC was incorrect, which could also cause unnecessary allocations.
-Version 1.34
- Long missing version. Lots of bugfixes have accumulated in my email, so
- I had to start using them. In this version, Keenan Pepper has submitted
- a bugfix for the string comparison library procedure, Wouter Boeke
- modified some code that was casting to the wrong type and crashed on
- some machines, "SheppardCo" submitted a replacement "modulo" code and
- Scott Fenton submitted lots of corrections that shut up some compiler
- warnings. Brian Maher submitted instructions on how to build on OS-X.
- I have to dig deeper into my mailbox and find earlier emails, too.
-Version 1.33
- Charles Hayden fixed a nasty GC bug of the new stack frame, while in
- the process of porting TinyScheme to C++. He also submitted other
- changes, and other people also had comments or requests, but the GC
- bug was so important that this version is put through the door to
- correct it.
-Version 1.32
- Stephen Gildea put some quality time on TinyScheme again, and made
- a whole lot of changes to the interpreter that made it noticeably
- faster.
-Version 1.31
- Patches to the hastily-done version 1.30. Stephen Gildea fixed
- some things done wrongly, and Richard Russo fixed the makefile
- for building on Windows. Property lists (heritage from MiniScheme)
- are now optional and have dissappeared from the interface. They
- should be considered as deprecated.
-Version 1.30
- After many months, I followed Preston Bannister's advice of
- using macros and a single source text to keep the enums and the
- dispatch table in sync, and I used his contributed "opdefines.h".
- Timothy Downs contributed a helpful function, "scheme_call".
- Stephen Gildea contributed new versions of the makefile and
- practically all other sources. He created a built-in STRING-APPEND,
- and fixed a lot of other bugs.
- Ruhi Bloodworth reported fixes necessary for OS X and a small
- bug in dynload.c.
-Version 1.29
- The previous version contained a lot of corrections, but there
- were a lot more that still wait on a sheet of paper lost in a
- carton someplace after my house move... Manuel Heras-Gilsanz
- noticed this and resent his own contribution, which relies on
- another bugfix that v.1.28 was missing: a problem with string
- output, that this version fixes. I hope other people will take
- the time to resend their contributions, if they didn't make it
- to v.1.28.
-Version 1.28
- Many people have contacted me with bugfixes or remarks in
- the three months I was inactive. A lot of them spotted that
- scheme_deinit crashed while reporting gc results. They suggested
- that sc->outport be set to NIL in scheme_deinit, which I did.
- Dennis Taylor remarked that OP_VALUEPRINT reset sc->value instead
- of preserving it. He submitted a modification which I adopted
- partially. David Hovemeyer sent me many little changes, that you
- will find in version 1.28, and Partice Stoessel modified the
- float reader to conform to R5RS.
-Version 1.27
- Version 1.27 is the successor of 1.25. Bug fixes only, but I had to
- release them so that everybody can profit. 'Backchar' tried to write
- back to the string, which obviously didn't work for const strings.
- 'Substring' didn't check for crossed start and end indices. Defines
- changed to restore the ability to compile under MSVC.
-Version 1.26
- Version 1.26 was never released. I changed a lot of things, in fact
- too much, even the garbage collector, and hell broke loose. I'll
- try a more gradual approach next time.
-Version 1.25
- Types have been homogenized to be able to accomodate a different
- representation. Plus, promises are no longer closures. Unfortunately,
- I discovered that continuations and force/delay do not pass the SCM
- test (and never did)... However, on the bright side, what little
- modifications I did had a large impact on the footprint:
- USE_NO_FEATURES now produces an object file of 63960 bytes on Linux!
-Version 1.24
- SCM tests now pass again after change in atom2str.
-Version 1.23
- Finally I managed to mess it up with my version control. Version
- 1.22 actually lacked some of the things I have been fixing in the
- meantime. This should be considered as a complete replacement for
- 1.22.
-Version 1.22
- The new ports had a bug in LOAD. MK_CLOSURE is introduced.
- Shawn Wagner inquired about string->number and number->string.
- I added string->atom and atom->string and defined the number
- functions from them. Doing that, I fixed WRITE applied to symbols
- (it didn't quote them). Unfortunately, minimum build is now
- slightly larger than 64k... I postpone action because Jason's idea
- might solve it elegantly.
-Version 1.21
- Jason Felice submitted a radically different datatype representation
- which he had implemented. While discussing its pros and cons, it
- became apparent that the current implementation of ports suffered
- from a grave fault: ports were not garbage-collected. I changed the
- ports to be heap-allocated, which enabled the use of string ports
- for loading. Jason also fixed errors in the garbage collection of
- vectors. USE_VERBATIM is gone. "ssp_compiler.c" has a better solution
- on HTML generation. A bug involving backslash notation in strings
- has been fixed. '-c' flag now executes next argument as a stream of
- Scheme commands. Foreign functions are now also heap allocated,
- and scheme_define is used to define everything.
-Version 1.20
- Tracing has been added. The toplevel loop has been slightly
- rearranged. Backquote reading for vector templates has been
- sanitized. Symbol interning is now correct. Arithmetic functions
- have been corrected. APPLY, MAP, FOR-EACH, numeric comparison
- functions fixed. String reader/writer understands \xAA notation.
-Version 1.19
- Carriage Return now delimits identifiers. DOS-formatted Scheme files
- can be used by Unix. Random number generator added to library.
- Fixed some glitches of the new type-checking scheme. Fixed erroneous
- (append '() 'a) behavior. Will continue with r4rstest.scm to
- fix errors.
-Version 1.18
- The FFI has been extended. USE_VERBOSE_GC has gone. Anyone wanting
- the same functionality can put (gcverbose #t) in init.scm.
- print-width was removed, along with three corresponding op-codes.
- Extended character constants with ASCII names were added.
- mk_counted_string paves the way for full support of binary strings.
- As much as possible of the type-checking chores were delegated
- to the inner loop, thus reducing the code size to less than 4200 loc!
-Version 1.17
- Dynamically-loaded extensions are more fully integrated.
- TinyScheme is now distributed under the BSD open-source license.
-Version 1.16
- Dynamically-loaded extensions introduced (USE_DL).
- Santeri Paavolainen found a race condition: When a cons is executed,
- and each of the two arguments is a constructing function, GC could
- happen before all arguments are evaluated and cons() is called, and
- the evaluated arguments would all be reclaimed!
- Fortunately, such a case was rare in the code, although it is
- a pitfall in new code and code in foreign functions. Currently, only
- one such case remains, when COLON_HOOK is defined.
-Version 1.15
- David Gould also contributed some changes that speed up operation.
- Kirk Zurell fixed HASPROP.
- The Garbage Collection didn't collect all the garbage...fixed.
-Version 1.14
- Unfortunately, after Andre fixed the GC it became obvious that the
- algorithm was too slow... Fortunately, David Gould found a way to
- speed it up.
-Version 1.13
- Silly bug involving division by zero resolved by Roland Kaufman.
- Macintoch support from Shmulik Regev.
- Float parser bug fixed by Alexander Shendi.
- GC bug from Andru Luvisi.
-Version 1.12
- Cis* incorrectly called isalpha() instead of isascii()
- Added USE_CHAR_CLASSIFIERS, USE_STRING_PORTS.
-Version 1.11
- BSDI defines isnumber... changed all similar functions to is_*
- EXPT now has correct definition. Added FLOOR,CEILING,TRUNCATE
- and ROUND, courtesy of Bengt Kleberg. Preprocessor symbols now
- have values 1 or 0, and can be set as compiler defines (proposed
- by Andy Ganor *months* ago). 'prompt' and 'InitFile' can now be
- defined during compilation, too.
-Version 1.10
- Another bug when file ends with comment!
- Added DEFINE-MACRO in init.scm, courtesy of Andy Gaynor.
-Version 1.09
- Removed bug when READ met EOF. lcm.
-Version 1.08
- quotient,remainder and modulo. gcd.
-Version 1.07
- '=>' in cond now exists
- list? now checks for circularity
- some reader bugs removed
- Reader is more consistent wrt vectors
- Quote and Quasiquote work with vectors
-Version 1.06
- #! is now skipped
- generic-assoc bug removed
- strings are now managed differently, hack.txt is removed
- various delicate points fixed
-Version 1.05
- Support for scripts, *args*, "-1" option.
- Various R5RS procedures.
- *sharp-hook*
- Handles unmatched parentheses.
- New architecture for procedures.
-Version 1.04
- Added missing T_ATOM bits...
- Added vectors
- Free-list is sorted by address, since vectors need consecutive cells.
- (quit <exitcode>) for use with scripts
-Version 1.03 (26 Aug 1998):
- Extended .h with useful functions for FFI
- Library: with-input-* etc.
- Finished R5RS I/O, added string ports.
-Version 1.02 (25 Aug 1998):
- First part of R5RS I/O.
-
+Change Log
+----------
+
+Version 1.40
+ Bugs fixed:
+ #1964950 - Stop core dumps due to bad syntax in LET (and variants)
+ #2826594 - allow reverse to work on empty list (Tony Garnock-Jones)
+ Potential problem of arglist to foreign calls being wrongly GC'ed.
+ Fixed bug that read could loop forever (tehom).
+
+ API changes:
+ Exposed is_list and list_length.
+ Added scheme_register_foreign_func_list and declarations for it (tehom)
+ Defined *compile-hook* (tehom)
+
+ Other changes:
+ Updated is_list and list_length to handle circular lists.
+ Nested calling thru C has been made now safer (tehom)
+ Peter Michaux cleaned up port_rep_from_file
+ Added unwind-protect (tehom)
+ Some cleanups to in/outport and Eval_Cycle by Peter Michaux
+ Report error line number (Mostly by Sanel Zukan, back-compatibility by Tehom)
+
+ Contributors:
+ Kevin Cozens, Dimitrios Souflis, Tom Breton, Peter Michaux, Sanel Zukan,
+ and Tony Garnock-Jones.
+
+Version 1.39
+ Bugs fixed:
+ Fix for the load bug
+ Fixed parsing of octal coded characters. Fixes bug #1818018.
+ Added tests for when mk_vector is out of memory. Can't rely on sc->sink.
+ Fix for bug #1794369
+ Finished feature-request 1599947: scheme_apply0 etc return values.
+ Partly provided feature-request 1599947: Expose list_length, eqv, etc
+ Provided feature-request 1599945, Scheme->C->Scheme calling.
+ Fix for bug 1593861 (behavior of is_integer)
+ Fix for bug 1589711
+ Error checking of binding spec syntax in LET and LETREC. The bad syntax
+ was causing a segmentation fault in Linux. Complete fixes for bug #1817986.
+ Error checking of binding spec syntax in LET*
+ Bad syntax was causing core dump in Linux.
+ Fix for nasty gc bug
+
+ R5RS changes:
+ R5RS requires numbers to be of equal value AND of the same type (ie. both
+ exact or inexact) in order to return #t from eqv?. R5RS compliance fix.
+ String output ports now conform to SRFI-6
+
+ Other changes:
+ Drew Yao fixed buffer overflow problems in mk_sharp_const.
+ put OP_T0LVL in charge of reacting to EOF
+ file_push checks array bounds (patch from Ray Lehtiniemi)
+ Changed to always use snprintf (Patch due to Ramiro bsd1628)
+ Updated usage information using text from the Manual.txt file.
+
+Version 1.38
+ Interim release until the rewrite, mostly incorporating modifications
+ from Kevin Cozens. Small addition for Cygwin in the makefile, and
+ modifications by Andrew Guenther for Apple platforms.
+
+Version 1.37
+ Joe Buehler submitted reserve_cells.
+
+Version 1.36
+ Joe Buehler fixed a patch in the allocator.
+ Alexander Shendi moved the comment handling in the scanner, which
+ fixed an obscure bug for which Mike E had provided a patch as well.
+ Kevin Cozens has submitted some fixes and modifications which have
+ not been incorporated yet in their entirety.
+
+Version 1.35
+ Todd Showalter discovered that the number of free cells reported
+ after GC was incorrect, which could also cause unnecessary allocations.
+
+Version 1.34
+ Long missing version. Lots of bugfixes have accumulated in my email, so
+ I had to start using them. In this version, Keenan Pepper has submitted
+ a bugfix for the string comparison library procedure, Wouter Boeke
+ modified some code that was casting to the wrong type and crashed on
+ some machines, "SheppardCo" submitted a replacement "modulo" code and
+ Scott Fenton submitted lots of corrections that shut up some compiler
+ warnings. Brian Maher submitted instructions on how to build on OS-X.
+ I have to dig deeper into my mailbox and find earlier emails, too.
+
+Version 1.33
+ Charles Hayden fixed a nasty GC bug of the new stack frame, while in
+ the process of porting TinyScheme to C++. He also submitted other
+ changes, and other people also had comments or requests, but the GC
+ bug was so important that this version is put through the door to
+ correct it.
+
+Version 1.32
+ Stephen Gildea put some quality time on TinyScheme again, and made
+ a whole lot of changes to the interpreter that made it noticeably
+ faster.
+
+Version 1.31
+ Patches to the hastily-done version 1.30. Stephen Gildea fixed
+ some things done wrongly, and Richard Russo fixed the makefile
+ for building on Windows. Property lists (heritage from MiniScheme)
+ are now optional and have dissappeared from the interface. They
+ should be considered as deprecated.
+
+Version 1.30
+ After many months, I followed Preston Bannister's advice of
+ using macros and a single source text to keep the enums and the
+ dispatch table in sync, and I used his contributed "opdefines.h".
+ Timothy Downs contributed a helpful function, "scheme_call".
+ Stephen Gildea contributed new versions of the makefile and
+ practically all other sources. He created a built-in STRING-APPEND,
+ and fixed a lot of other bugs.
+ Ruhi Bloodworth reported fixes necessary for OS X and a small
+ bug in dynload.c.
+
+Version 1.29
+ The previous version contained a lot of corrections, but there
+ were a lot more that still wait on a sheet of paper lost in a
+ carton someplace after my house move... Manuel Heras-Gilsanz
+ noticed this and resent his own contribution, which relies on
+ another bugfix that v.1.28 was missing: a problem with string
+ output, that this version fixes. I hope other people will take
+ the time to resend their contributions, if they didn't make it
+ to v.1.28.
+
+Version 1.28
+ Many people have contacted me with bugfixes or remarks in
+ the three months I was inactive. A lot of them spotted that
+ scheme_deinit crashed while reporting gc results. They suggested
+ that sc->outport be set to NIL in scheme_deinit, which I did.
+ Dennis Taylor remarked that OP_VALUEPRINT reset sc->value instead
+ of preserving it. He submitted a modification which I adopted
+ partially. David Hovemeyer sent me many little changes, that you
+ will find in version 1.28, and Partice Stoessel modified the
+ float reader to conform to R5RS.
+
+Version 1.27
+ Version 1.27 is the successor of 1.25. Bug fixes only, but I had to
+ release them so that everybody can profit. 'Backchar' tried to write
+ back to the string, which obviously didn't work for const strings.
+ 'Substring' didn't check for crossed start and end indices. Defines
+ changed to restore the ability to compile under MSVC.
+
+Version 1.26
+ Version 1.26 was never released. I changed a lot of things, in fact
+ too much, even the garbage collector, and hell broke loose. I'll
+ try a more gradual approach next time.
+
+Version 1.25
+ Types have been homogenized to be able to accomodate a different
+ representation. Plus, promises are no longer closures. Unfortunately,
+ I discovered that continuations and force/delay do not pass the SCM
+ test (and never did)... However, on the bright side, what little
+ modifications I did had a large impact on the footprint:
+ USE_NO_FEATURES now produces an object file of 63960 bytes on Linux!
+
+Version 1.24
+ SCM tests now pass again after change in atom2str.
+
+Version 1.23
+ Finally I managed to mess it up with my version control. Version
+ 1.22 actually lacked some of the things I have been fixing in the
+ meantime. This should be considered as a complete replacement for
+ 1.22.
+
+Version 1.22
+ The new ports had a bug in LOAD. MK_CLOSURE is introduced.
+ Shawn Wagner inquired about string->number and number->string.
+ I added string->atom and atom->string and defined the number
+ functions from them. Doing that, I fixed WRITE applied to symbols
+ (it didn't quote them). Unfortunately, minimum build is now
+ slightly larger than 64k... I postpone action because Jason's idea
+ might solve it elegantly.
+
+Version 1.21
+ Jason Felice submitted a radically different datatype representation
+ which he had implemented. While discussing its pros and cons, it
+ became apparent that the current implementation of ports suffered
+ from a grave fault: ports were not garbage-collected. I changed the
+ ports to be heap-allocated, which enabled the use of string ports
+ for loading. Jason also fixed errors in the garbage collection of
+ vectors. USE_VERBATIM is gone. "ssp_compiler.c" has a better solution
+ on HTML generation. A bug involving backslash notation in strings
+ has been fixed. '-c' flag now executes next argument as a stream of
+ Scheme commands. Foreign functions are now also heap allocated,
+ and scheme_define is used to define everything.
+
+Version 1.20
+ Tracing has been added. The toplevel loop has been slightly
+ rearranged. Backquote reading for vector templates has been
+ sanitized. Symbol interning is now correct. Arithmetic functions
+ have been corrected. APPLY, MAP, FOR-EACH, numeric comparison
+ functions fixed. String reader/writer understands \xAA notation.
+
+Version 1.19
+ Carriage Return now delimits identifiers. DOS-formatted Scheme files
+ can be used by Unix. Random number generator added to library.
+ Fixed some glitches of the new type-checking scheme. Fixed erroneous
+ (append '() 'a) behavior. Will continue with r4rstest.scm to
+ fix errors.
+
+Version 1.18
+ The FFI has been extended. USE_VERBOSE_GC has gone. Anyone wanting
+ the same functionality can put (gcverbose #t) in init.scm.
+ print-width was removed, along with three corresponding op-codes.
+ Extended character constants with ASCII names were added.
+ mk_counted_string paves the way for full support of binary strings.
+ As much as possible of the type-checking chores were delegated
+ to the inner loop, thus reducing the code size to less than 4200 loc!
+
+Version 1.17
+ Dynamically-loaded extensions are more fully integrated.
+ TinyScheme is now distributed under the BSD open-source license.
+
+Version 1.16
+ Dynamically-loaded extensions introduced (USE_DL).
+ Santeri Paavolainen found a race condition: When a cons is executed,
+ and each of the two arguments is a constructing function, GC could
+ happen before all arguments are evaluated and cons() is called, and
+ the evaluated arguments would all be reclaimed!
+ Fortunately, such a case was rare in the code, although it is
+ a pitfall in new code and code in foreign functions. Currently, only
+ one such case remains, when COLON_HOOK is defined.
+
+Version 1.15
+ David Gould also contributed some changes that speed up operation.
+ Kirk Zurell fixed HASPROP.
+ The Garbage Collection didn't collect all the garbage...fixed.
+
+Version 1.14
+ Unfortunately, after Andre fixed the GC it became obvious that the
+ algorithm was too slow... Fortunately, David Gould found a way to
+ speed it up.
+
+Version 1.13
+ Silly bug involving division by zero resolved by Roland Kaufman.
+ Macintoch support from Shmulik Regev.
+ Float parser bug fixed by Alexander Shendi.
+ GC bug from Andru Luvisi.
+
+Version 1.12
+ Cis* incorrectly called isalpha() instead of isascii()
+ Added USE_CHAR_CLASSIFIERS, USE_STRING_PORTS.
+
+Version 1.11
+ BSDI defines isnumber... changed all similar functions to is_*
+ EXPT now has correct definition. Added FLOOR,CEILING,TRUNCATE
+ and ROUND, courtesy of Bengt Kleberg. Preprocessor symbols now
+ have values 1 or 0, and can be set as compiler defines (proposed
+ by Andy Ganor *months* ago). 'prompt' and 'InitFile' can now be
+ defined during compilation, too.
+
+Version 1.10
+ Another bug when file ends with comment!
+ Added DEFINE-MACRO in init.scm, courtesy of Andy Gaynor.
+
+Version 1.09
+ Removed bug when READ met EOF. lcm.
+
+Version 1.08
+ quotient,remainder and modulo. gcd.
+
+Version 1.07
+ '=>' in cond now exists
+ list? now checks for circularity
+ some reader bugs removed
+ Reader is more consistent wrt vectors
+ Quote and Quasiquote work with vectors
+
+Version 1.06
+ #! is now skipped
+ generic-assoc bug removed
+ strings are now managed differently, hack.txt is removed
+ various delicate points fixed
+
+Version 1.05
+ Support for scripts, *args*, "-1" option.
+ Various R5RS procedures.
+ *sharp-hook*
+ Handles unmatched parentheses.
+ New architecture for procedures.
+
+Version 1.04
+ Added missing T_ATOM bits...
+ Added vectors
+ Free-list is sorted by address, since vectors need consecutive cells.
+ (quit <exitcode>) for use with scripts
+
+Version 1.03 (26 Aug 1998):
+ Extended .h with useful functions for FFI
+ Library: with-input-* etc.
+ Finished R5RS I/O, added string ports.
+
+Version 1.02 (25 Aug 1998):
+ First part of R5RS I/O.
diff --git a/plug-ins/script-fu/tinyscheme/Manual.txt b/plug-ins/script-fu/tinyscheme/Manual.txt
index 7091a37..e395e79 100644
--- a/plug-ins/script-fu/tinyscheme/Manual.txt
+++ b/plug-ins/script-fu/tinyscheme/Manual.txt
@@ -1,12 +1,12 @@
- TinySCHEME Version 1.38
+ TinySCHEME Version 1.40
"Safe if used as prescribed"
-- Philip K. Dick, "Ubik"
This software is open source, covered by a BSD-style license.
-Please read accompanying file COPYING.
+Please read accompanying file COPYING.
-------------------------------------------------------------------------------
This Scheme interpreter is based on MiniSCHEME version 0.85k4
@@ -31,7 +31,7 @@ Please read accompanying file COPYING.
coexist in the same program, without any interference between them.
Programmatically, foreign functions in C can be added and values
can be defined in the Scheme environment. Being a quite small program,
- it is easy to comprehend, get to grips with, and use.
+ it is easy to comprehend, get to grips with, and use.
Known bugs
----------
@@ -47,7 +47,7 @@ Please read accompanying file COPYING.
Maybe (a subset of) SLIB will work with TinySCHEME...
- Decent debugging facilities are missing. Only tracing is supported
+ Decent debugging facilities are missing. Only tracing is supported
natively.
@@ -158,7 +158,7 @@ Please read accompanying file COPYING.
14 #\so 31 #\us
15 #\si
16 #\dle 127 #\del
-
+
Numeric literals support #x #o #b and #d. Flonums are currently read only
in decimal notation. Full grammar will be supported soon.
@@ -180,7 +180,7 @@ Please read accompanying file COPYING.
Also open-input-output-file, set-input-port, set-output-port (not R5RS)
Library: call-with-input-file, call-with-output-file,
with-input-from-file, with-output-from-file and
- with-input-output-from-to-files, close-port and input-output-port?
+ with-input-output-from-to-files, close-port and input-output-port?
(not R5RS).
String Ports: open-input-string, open-output-string, get-output-string,
open-input-output-string. Strings can be used with I/O routines.
@@ -227,8 +227,11 @@ Please read accompanying file COPYING.
Dynamically-loaded extensions
(load-extension <filename without extension>)
- Loads a DLL declaring foreign procedures.
-
+ Loads a DLL declaring foreign procedures. On Unix/Linux, one can make use
+ of the ld.so.conf file or the LD_RUN_PATH system variable in order to place
+ the library in a directory other than the current one. Please refer to the
+ appropriate 'man' page.
+
Esoteric procedures
(oblist)
Returns the oblist, an immutable list of all the symbols.
@@ -253,23 +256,23 @@ Please read accompanying file COPYING.
Makes a new closure in the given environment.
Obsolete procedures
- (print-width <object>)
-
+ (print-width <object>)
+
Programmer's Reference
----------------------
The interpreter state is initialized with "scheme_init".
Custom memory allocation routines can be installed with an alternate
- initialization function: "scheme_init_custom_alloc".
+ initialization function: "scheme_init_custom_alloc".
Files can be loaded with "scheme_load_file". Strings containing Scheme
- code can be loaded with "scheme_load_string". It is a good idea to
+ code can be loaded with "scheme_load_string". It is a good idea to
"scheme_load" init.scm before anything else.
External data for keeping external state (of use to foreign functions)
can be installed with "scheme_set_external_data".
- Foreign functions are installed with "assign_foreign". Additional
- definitions can be added to the interpreter state, with "scheme_define"
- (this is the way HTTP header data and HTML form data are passed to the
+ Foreign functions are installed with "assign_foreign". Additional
+ definitions can be added to the interpreter state, with "scheme_define"
+ (this is the way HTTP header data and HTML form data are passed to the
Scheme script in the Altera SQL Server). If you wish to define the
foreign function in a specific environment (to enhance modularity),
use "assign_foreign_env".
@@ -292,7 +295,7 @@ Please read accompanying file COPYING.
established standard, this library is supposed to be installed in
a directory mirroring its name under the TinyScheme location.
-
+
Foreign Functions
-----------------
@@ -309,13 +312,13 @@ Please read accompanying file COPYING.
return sc->NIL;
}
- Foreign functions are now defined as closures:
+ Foreign functions are now defined as closures:
- sc->interface->scheme_define(
- sc,
- sc->global_env,
- sc->interface->mk_symbol(sc,"square"),
- sc->interface->mk_foreign_func(sc, square));
+ sc->interface->scheme_define(
+ sc,
+ sc->global_env,
+ sc->interface->mk_symbol(sc,"square"),
+ sc->interface->mk_foreign_func(sc, square));
Foreign functions can use the external data in the "scheme" struct
@@ -330,8 +333,8 @@ Please read accompanying file COPYING.
Standalone
----------
- Usage: tinyscheme -?
- or: tinyscheme [<file1> <file2> ...]
+ Usage: tinyscheme -?
+ or: tinyscheme [<file1> <file2> ...]
followed by
-1 <file> [<arg1> <arg2> ...]
-c <Scheme commands> [<arg1> <arg2> ...]
diff --git a/plug-ins/script-fu/tinyscheme/init.scm b/plug-ins/script-fu/tinyscheme/init.scm
index e062a4a..f0d5d14 100644
--- a/plug-ins/script-fu/tinyscheme/init.scm
+++ b/plug-ins/script-fu/tinyscheme/init.scm
@@ -1,4 +1,4 @@
-; Initialization file for TinySCHEME 1.39
+; Initialization file for TinySCHEME 1.40
; Per R5RS, up to four deep compositions should be defined
(define (caar x) (car (car x)))
@@ -96,7 +96,6 @@
(abs (* (quotient aa (gcd aa bb)) bb)))))))
-
(define (string . charlist)
(list->string charlist))
@@ -130,7 +129,7 @@
(define (string->anyatom str pred)
(let* ((a (string->atom str)))
(if (pred a) a
- (error "string->xxx: not a xxx" a))))
+ (error "string->xxx: not a xxx" a))))
(define (string->number str) (string->anyatom str number?))
@@ -200,31 +199,31 @@
(if (null? lists)
(cons cars cdrs)
(let ((car1 (caar lists))
- (cdr1 (cdar lists)))
- (unzip1-with-cdr-iterative
- (cdr lists)
- (append cars (list car1))
- (append cdrs (list cdr1))))))
+ (cdr1 (cdar lists)))
+ (unzip1-with-cdr-iterative
+ (cdr lists)
+ (append cars (list car1))
+ (append cdrs (list cdr1))))))
(define (map proc . lists)
(if (null? lists)
(apply proc)
(if (null? (car lists))
- '()
- (let* ((unz (apply unzip1-with-cdr lists))
- (cars (car unz))
- (cdrs (cdr unz)))
- (cons (apply proc cars) (apply map (cons proc cdrs)))))))
+ '()
+ (let* ((unz (apply unzip1-with-cdr lists))
+ (cars (car unz))
+ (cdrs (cdr unz)))
+ (cons (apply proc cars) (apply map (cons proc cdrs)))))))
(define (for-each proc . lists)
(if (null? lists)
(apply proc)
(if (null? (car lists))
- #t
- (let* ((unz (apply unzip1-with-cdr lists))
- (cars (car unz))
- (cdrs (cdr unz)))
- (apply proc cars) (apply map (cons proc cdrs))))))
+ #t
+ (let* ((unz (apply unzip1-with-cdr lists))
+ (cars (car unz))
+ (cdrs (cdr unz)))
+ (apply proc cars) (apply map (cons proc cdrs))))))
(define (list-tail x k)
(if (zero? k)
@@ -383,16 +382,16 @@
;;Exit the old list. Do deeper ones last. Don't do
;;any shared ones.
(define (pop-many)
- (unless (eq? *active-windings* shared)
- (deactivate-top-winding!)
- (pop-many)))
+ (unless (eq? *active-windings* shared)
+ (deactivate-top-winding!)
+ (pop-many)))
;;Enter the new list. Do deeper ones first so that the
;;deeper windings will already be active. Don't do any
;;shared ones.
(define (push-many new-ws)
- (unless (eq? new-ws shared)
- (push-many (cdr new-ws))
- (activate-winding! (car new-ws))))
+ (unless (eq? new-ws shared)
+ (push-many (cdr new-ws))
+ (activate-winding! (car new-ws))))
;;Do it.
(pop-many)
@@ -403,20 +402,20 @@
`(define call-with-current-continuation
;;It internally uses the built-in call/cc, so capture it.
,(let ((old-c/cc call-with-current-continuation))
- (lambda (func)
- ;;Use old call/cc to get the continuation.
- (old-c/cc
- (lambda (continuation)
- ;;Call func with not the continuation itself
- ;;but a procedure that adjusts the active
- ;;windings to what they were when we made
- ;;this, and only then calls the
- ;;continuation.
- (func
- (let ((current-ws *active-windings*))
- (lambda (x)
- (set-active-windings! current-ws)
- (continuation x)))))))))
+ (lambda (func)
+ ;;Use old call/cc to get the continuation.
+ (old-c/cc
+ (lambda (continuation)
+ ;;Call func with not the continuation itself
+ ;;but a procedure that adjusts the active
+ ;;windings to what they were when we made
+ ;;this, and only then calls the
+ ;;continuation.
+ (func
+ (let ((current-ws *active-windings*))
+ (lambda (x)
+ (set-active-windings! current-ws)
+ (continuation x)))))))))
outer-env)
;;We can't just say "define (dynamic-wind before thunk after)"
;;because the lambda it's defined to lives in this environment,
@@ -424,13 +423,13 @@
(eval
`(define dynamic-wind
,(lambda (before thunk after)
- ;;Make a new winding
- (activate-winding! (make-winding before after))
- (let ((result (thunk)))
- ;;Get rid of the new winding.
- (deactivate-top-winding!)
- ;;The return value is that of thunk.
- result)))
+ ;;Make a new winding
+ (activate-winding! (make-winding before after))
+ (let ((result (thunk)))
+ ;;Get rid of the new winding.
+ (deactivate-top-winding!)
+ ;;The return value is that of thunk.
+ result)))
outer-env)))
(define call/cc call-with-current-continuation)
@@ -578,8 +577,8 @@
(let* ((env (if (null? envl) (current-environment) (eval (car envl))))
(xval (eval x env)))
(if (closure? xval)
- (make-closure (get-closure-code xval) env)
- xval)))
+ (make-closure (get-closure-code xval) env)
+ xval)))
; Redefine this if you install another package infrastructure
; Also redefine 'package'
@@ -687,15 +686,15 @@
(define (cond-eval condition)
(cond ((symbol? condition)
- (if (member condition *features*) #t #f))
- ((eq? condition #t) #t)
- ((eq? condition #f) #f)
- (else (case (car condition)
- ((and) (cond-eval-and (cdr condition)))
- ((or) (cond-eval-or (cdr condition)))
- ((not) (if (not (null? (cddr condition)))
- (error "cond-expand : 'not' takes 1 argument")
- (not (cond-eval (cadr condition)))))
- (else (error "cond-expand : unknown operator" (car condition)))))))
+ (if (member condition *features*) #t #f))
+ ((eq? condition #t) #t)
+ ((eq? condition #f) #f)
+ (else (case (car condition)
+ ((and) (cond-eval-and (cdr condition)))
+ ((or) (cond-eval-or (cdr condition)))
+ ((not) (if (not (null? (cddr condition)))
+ (error "cond-expand : 'not' takes 1 argument")
+ (not (cond-eval (cadr condition)))))
+ (else (error "cond-expand : unknown operator" (car condition)))))))
(gc-verbose #f)
diff --git a/plug-ins/script-fu/tinyscheme/scheme.c b/plug-ins/script-fu/tinyscheme/scheme.c
index d4575c6..946808c 100644
--- a/plug-ins/script-fu/tinyscheme/scheme.c
+++ b/plug-ins/script-fu/tinyscheme/scheme.c
@@ -1,4 +1,4 @@
-/* T I N Y S C H E M E 1 . 3 9
+/* T I N Y S C H E M E 1 . 4 0
* Dimitrios Souflis (dsouflis acm org)
* Based on MiniScheme (original credits follow)
* (MINISCM) coded by Atsushi Moriwaki (11/5/1989)
@@ -103,7 +103,7 @@ ts_output_string (TsOutputType type,
* Basic memory allocation units
*/
-#define banner "TinyScheme 1.39 (with UTF-8 support)"
+#define banner "TinyScheme 1.40 (with UTF-8 support)"
#include <string.h>
#include <stdlib.h>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]