On Tue, Jun 08, 1999 at 03:55:15PM +0200, Niels M�ller wrote:
> What I'd like to see is the scheme-environmental stuff purged from the
> main scheme source files. I.e. keep the main source files without
> things like #!, module system invocations, etc. Then have wrappers
> make_class.guile, make_class.scsh, etc, which loads the source files
> together with any needed modules. 

        I did that, though a bit differently (my solution
        is a bit more work, but I like it the way it is).

        To use this patch, rename make_char_classes to 
        make_char_classes.in and make_class to make_class.in,
        and replace the "#! /usr/bin/scsh \" line with
        "#! @SCHEME@ \". The utilities will be generated from
        the .in files to refer to the correct scheme.

        I created src/scheme-compat to hold the scheme compatibility
        libraries, e.g. src/scheme-compat/guile.scm. You need to mkdir
        this directory.

        Then apply the patch below. Recreate all automake & autoconf
        files. Now running ./configure will search your $PATH for
        possible scheme interpreters and choose one.

        Things to note:

        - I'm not sure if the proper files will be included in distribution
          tarballs and whether the system can clean after itself. Someone
          who knows automake will have to check that.
        - I'd like to see a command line option to configure to force
          use of some certain scheme interpreter; currently the only
          way to use the later of the two is to remove the first one
          temporarily.
        - The makefiles still don't run make_class and make_char_classes
          directly. I would like to see this changed too (it makes things
          look cleaner IMHO), but want to avoid making too many changes
          at once.

        Okay, here's the patch, have fun.
-- 
Havoc Consulting | unix, linux, perl, mail, www, internet, security consulting
+358 50 5486010  | software development, unix administration, training
# This is a patch for lsh-0.1.3 to update it to lsh-0.1.3-tv.
# It was generated by makepatch 1.93 (2.0BETA) on Mon Jul  5 04:33:38 1999.
#
# To apply this patch, chdir to source directory lsh-0.1.3 and enter
#
#     /bin/sh <this-file>
#     patch -p1 -N < <this-file>

rm -f src/make_char_classes
rm -f src/make_class
mkdir src/scheme-compat
touch src/scheme-compat/guile.scm
touch src/scheme-compat/scsh.scm
exit
# End of preamble.

# Patch input follows.
__DATA__
Index: configure.in
Prereq:  1.19 
####### lsh-0.1.3-tv/ => lsh-0.1.3-tv
*** lsh-0.1.3-tv/configure.in   Thu Jul  1 21:18:45 1999
--- lsh-0.1.3-tv/configure.in   Mon Jul  5 03:48:24 1999
***************
*** 106,112 ****
  AC_PROG_RANLIB
  AM_PROG_CC_STDC
  
! AC_PATH_PROG(SCHEME, scsh,, $PATH)
  AC_PATH_PROG(BASH, bash,, $PATH)
  AC_PATH_PROG(GROFF, groff,, $PATH)
  
--- 106,112 ----
  AC_PROG_RANLIB
  AM_PROG_CC_STDC
  
! AC_PATH_PROGS(SCHEME, guile scsh,, $PATH)
  AC_PATH_PROG(BASH, bash,, $PATH)
  AC_PATH_PROG(GROFF, groff,, $PATH)
  
Index: src/Makefile.am.in
####### lsh-0.1.3-tv/ => lsh-0.1.3-tv
*** lsh-0.1.3-tv/src/Makefile.am.in     Tue Jun 29 00:25:26 1999
--- lsh-0.1.3-tv/src/Makefile.am.in     Mon Jul  5 04:03:48 1999
***************
*** 77,84 ****
  
  prime_table_LDADD =
  
  sexp_table.h: sexp_chars.in $(srcdir)/make_char_classes
!       $(SCHEME) -e main -s $(srcdir)/make_char_classes <$< >$@T
        test -s $@T && mv -f $@T $@
  
  digit_table_LDADD =
--- 77,91 ----
  
  prime_table_LDADD =
  
+ MAINTAINERCLEANFILES += make_char_classes
+ 
+ $(srcdir)/make_char_classes: $(srcdir)/make_char_classes.in
+       sed 's{[@]SCHEME@{$(SCHEME){g' <$< >$@T
+       test -s $@T && mv -f $@T $@
+ 
  sexp_table.h: sexp_chars.in $(srcdir)/make_char_classes
!       $(SCHEME) -l $(SCHEMECOMPAT) \
!               -e main -s $(srcdir)/make_char_classes <$< >$@T
        test -s $@T && mv -f $@T $@
  
  digit_table_LDADD =
***************
*** 124,129 ****
--- 131,138 ----
  CLEANFILES = *.hT *.cT *.xT
  MAINTAINERCLEANFILES += $(dist_x_files)
  
+ SCHEMECOMPAT = $(srcdir)/scheme-compat/$(notdir $(SCHEME)).scm
+ 
  # Class files
  # SUFFIXES = .xh .xc
   
***************
*** 150,158 ****
  
  # This is GNU make specific
  
  %.x: % $(srcdir)/make_class $(srcdir)/compiler.scm
!       $(SCHEME) -e main -l $(srcdir)/compiler.scm \
!                 -s $(srcdir)/make_class <$< >$@T
        test -s $@T && mv -f $@T $@
  
  include $(top_srcdir)/misc/ctags.mk
--- 159,174 ----
  
  # This is GNU make specific
  
+ MAINTAINERCLEANFILES += make_class
+ 
+ $(srcdir)/make_class: $(srcdir)/make_class.in
+       sed 's{[@]SCHEME@{$(SCHEME){g' <$< >$@T
+       test -s $@T && mv -f $@T $@
+ 
  %.x: % $(srcdir)/make_class $(srcdir)/compiler.scm
!       $(SCHEME) -l $(SCHEMECOMPAT) \
!               -e main -l $(srcdir)/compiler.scm \
!               -s $(srcdir)/make_class <$< >$@T
        test -s $@T && mv -f $@T $@
  
  include $(top_srcdir)/misc/ctags.mk
Index: src/scheme-compat/guile.scm
####### lsh-0.1.3-tv/ => lsh-0.1.3-tv
*** lsh-0.1.3-tv/src/scheme-compat/guile.scm    Sun Jul  4 17:03:43 1999
--- lsh-0.1.3-tv/src/scheme-compat/guile.scm    Mon Jul  5 03:44:41 1999
***************
*** 0 ****
--- 1,68 ----
+ (use-modules (ice-9 slib))
+ (require 'macro-by-example)
+ (require 'format)
+ 
+ (define error-output-port current-error-port)
+ (define ascii->char integer->char)
+ (define char->ascii char->integer)
+ (define write-string display)
+ 
+ (define (is-in-charset? set n)
+   (not (zero? (char->integer (string-ref set n)))))
+ 
+ (define (char-set-members char-set)
+   (define (helper n)
+     (cond ((>= n 256) '())
+           ((is-in-charset? char-set n) (cons (integer->char n)
+                                              (helper (1+ n))))
+           (else (helper (1+ n)))))
+   (helper 0))
+ 
+ (define (ascii-range->char-set lower upper)
+   (do ((result (make-string 256 (integer->char 0)))
+        (i lower (+ i 1)))
+       ((= i upper) result)
+     (string-set! result i (integer->char 1))))
+ 
+ (define (chars->char-set chars)
+   (do ((result (make-string 256 (integer->char 0)))
+        (chars chars (cdr chars)))
+       ((null? chars) result)
+     (string-set! result (char->integer (car chars)) (integer->char 1))))
+ 
+ (define (string->char-set str)
+   (chars->char-set (string->list str)))
+ 
+ (define (char-set-intersection set1 set2)
+   (do ((result (make-string 256))
+        (i 0 (+ i 1)))
+       ((= i 255) result)
+     (string-set! result i 
+                  (if (and (is-in-charset? set1 i) (is-in-charset? set2 i))
+                      (integer->char 1)
+                      (integer->char 0)))))
+ 
+ (define (char-set-union set1 set2)
+   (do ((result (make-string 256))
+        (i 0 (+ i 1)))
+       ((= i 255) result)
+     (string-set! result i 
+                  (if (or (is-in-charset? set1 i) (is-in-charset? set2 i))
+                      (integer->char 1)
+                      (integer->char 0)))))
+ 
+ (define (char-set-difference set1 set2)
+   (do ((result (make-string 256))
+        (i 0 (+ i 1)))
+       ((= i 255) result)
+     (string-set! result i 
+                  (if (and (is-in-charset? set1 i) 
+                           (not (is-in-charset? set2 i)))
+                      (integer->char 1)
+                      (integer->char 0)))))
+ 
+ (define (nth l n)
+   (cond ((< n 0) (error "nth: negative index not allowed" n))
+         ((null? l) (error "nth: index too big" n))
+         ((= n 0) (car l))
+         (else (nth (cdr l) (-1+ n)))))
Index: src/scheme-compat/scsh.scm
####### lsh-0.1.3-tv/ => lsh-0.1.3-tv
*** lsh-0.1.3-tv/src/scheme-compat/scsh.scm     Sun Jul  4 17:03:43 1999
--- lsh-0.1.3-tv/src/scheme-compat/scsh.scm     Mon Jul  5 02:44:34 1999
***************
*** 0 ****
--- 1 ----
+ (define (current-error-port) 2)


End of Patch.

Reply via email to