Change MAKE-GSTATE to take separate arguments for coding and
authorChris Hanson <org/chris-hanson/cph>
Wed, 14 Dec 2005 05:44:53 +0000 (05:44 +0000)
committerChris Hanson <org/chris-hanson/cph>
Wed, 14 Dec 2005 05:44:53 +0000 (05:44 +0000)
line-ending names.  Initialize string I/O ports to ISO-8859-1 and
NEWLINE, respectively, as TEXT is wrong on non-unix systems.

v7/src/runtime/fileio.scm
v7/src/runtime/genio.scm
v7/src/runtime/strnin.scm
v7/src/runtime/strott.scm
v7/src/runtime/strout.scm
v7/src/runtime/ttyio.scm

index 4fc6c55e32a357d84d2c89fc21c79104760dcb38..c24f4e181ab4bcf165f711c714005877a7f9d518 100644 (file)
@@ -1,6 +1,6 @@
 #| -*-Scheme-*-
 
-$Id: fileio.scm,v 1.26 2005/12/12 21:41:23 cph Exp $
+$Id: fileio.scm,v 1.27 2005/12/14 05:44:31 cph Exp $
 
 Copyright 1991,1993,1994,1995,1996,1999 Massachusetts Institute of Technology
 Copyright 2001,2004,2005 Massachusetts Institute of Technology
@@ -76,7 +76,7 @@ USA.
         (channel (file-open-input-channel (->namestring pathname)))
         (port
          (make-port input-file-type
-                    (make-gstate channel #f 'TEXT pathname))))
+                    (make-gstate channel #f 'TEXT 'TEXT pathname))))
     (set-channel-port! channel port)
     (port/set-line-ending port (file-line-ending pathname))
     port))
@@ -90,7 +90,7 @@ USA.
                (file-open-output-channel filename))))
         (port
          (make-port output-file-type
-                    (make-gstate #f channel 'TEXT pathname))))
+                    (make-gstate #f channel 'TEXT 'TEXT pathname))))
     (set-channel-port! channel port)
     (port/set-line-ending port (file-line-ending pathname))
     port))
@@ -100,7 +100,7 @@ USA.
         (channel (file-open-io-channel (->namestring pathname)))
         (port
          (make-port i/o-file-type
-                    (make-gstate channel channel 'TEXT pathname))))
+                    (make-gstate channel channel 'TEXT 'TEXT pathname))))
     (set-channel-port! channel port)
     (port/set-line-ending port (file-line-ending pathname))
     port))
@@ -110,7 +110,7 @@ USA.
         (channel (file-open-input-channel (->namestring pathname)))
         (port
          (make-port input-file-type
-                    (make-gstate channel #f 'BINARY pathname))))
+                    (make-gstate channel #f 'BINARY 'BINARY pathname))))
     (set-channel-port! channel port)
     port))
 
@@ -123,7 +123,7 @@ USA.
                (file-open-output-channel filename))))
         (port
          (make-port output-file-type
-                    (make-gstate #f channel 'BINARY pathname))))
+                    (make-gstate #f channel 'BINARY 'BINARY pathname))))
     (set-channel-port! channel port)
     port))
 
@@ -132,7 +132,7 @@ USA.
         (channel (file-open-io-channel (->namestring pathname)))
         (port
          (make-port i/o-file-type
-                    (make-gstate channel channel 'BINARY pathname))))
+                    (make-gstate channel channel 'BINARY 'BINARY pathname))))
     (set-channel-port! channel port)
     port))
 \f
index 6b23c1a99dab8f045f8291f4c736cf7f05978f5d..07785de266a9bc6b43ab7c1ae4f13624ebaab57e 100644 (file)
@@ -1,6 +1,6 @@
 #| -*-Scheme-*-
 
-$Id: genio.scm,v 1.35 2005/12/12 21:45:36 cph Exp $
+$Id: genio.scm,v 1.36 2005/12/14 05:44:36 cph Exp $
 
 Copyright 1991,1993,1995,1996,1999,2002 Massachusetts Institute of Technology
 Copyright 2003,2004,2005 Massachusetts Institute of Technology
@@ -35,7 +35,7 @@ USA.
   (let ((port
         (make-port (generic-i/o-port-type (source-type source)
                                           (sink-type sink))
-                   (make-gstate source sink 'TEXT))))
+                   (make-gstate source sink 'TEXT 'TEXT))))
     (let ((ib (port-input-buffer port)))
       (if ib
          ((source/set-port (input-buffer-source ib)) port)))
@@ -80,14 +80,18 @@ USA.
   coding
   line-ending)
 
-(define (make-gstate source sink type . extra)
+(define (make-gstate source sink coder-name normalizer-name . extra)
   (list->vector
    (cons* (and source
-              (make-input-buffer (->source source 'MAKE-GSTATE) type))
+              (make-input-buffer (->source source 'MAKE-GSTATE)
+                                 coder-name
+                                 normalizer-name))
          (and sink
-              (make-output-buffer (->sink sink 'MAKE-GSTATE) type))
-         type
-         type
+              (make-output-buffer (->sink sink 'MAKE-GSTATE)
+                                  coder-name
+                                  normalizer-name))
+         coder-name
+         normalizer-name
          extra)))
 
 (define-integrable (port-input-buffer port)
@@ -394,7 +398,7 @@ USA.
          (and for-output?
               (known-input-line-ending? name)
               (not (known-output-line-ending? name))))
-      (if (and channel (eq? 'TCP-STREAM-SOCKET (channel-type channel)))
+      (if (and channel (eq? (channel-type channel) 'TCP-STREAM-SOCKET))
          'CRLF
          (default-line-ending))
       name))
@@ -623,14 +627,16 @@ USA.
   decode
   normalize)
 
-(define (make-input-buffer source type)
+(define (make-input-buffer source coder-name normalizer-name)
   (%make-input-buffer source
                      (make-string byte-buffer-length)
                      byte-buffer-length
                      byte-buffer-length
-                     (name->decoder type)
+                     (name->decoder coder-name)
                      (name->normalizer
-                      (line-ending ((source/get-channel source)) type #f))))
+                      (line-ending ((source/get-channel source))
+                                   normalizer-name
+                                   #f))))
 
 (define (input-buffer-open? ib)
   ((source/open? (input-buffer-source ib))))
@@ -821,13 +827,15 @@ USA.
   encode
   denormalize)
 
-(define (make-output-buffer sink type)
+(define (make-output-buffer sink coder-name normalizer-name)
   (%make-output-buffer sink
                       (make-string byte-buffer-length)
                       0
-                      (name->encoder type)
+                      (name->encoder coder-name)
                       (name->denormalizer
-                       (line-ending ((sink/get-channel sink)) type #t))))
+                       (line-ending ((sink/get-channel sink))
+                                    normalizer-name
+                                    #t))))
 
 (define (output-buffer-open? ob)
   ((sink/open? (output-buffer-sink ob))))
index 96484d95b70715b15bfebc01bed27e385c488da7..8461fea5ac5bc0ba36bc3e411300002dd2fb2d49 100644 (file)
@@ -1,6 +1,6 @@
 #| -*-Scheme-*-
 
-$Id: strnin.scm,v 14.15 2005/12/12 21:52:35 cph Exp $
+$Id: strnin.scm,v 14.16 2005/12/14 05:44:41 cph Exp $
 
 Copyright 1988,1990,1993,1999,2003,2004 Massachusetts Institute of Technology
 Copyright 2005 Massachusetts Institute of Technology
@@ -44,7 +44,10 @@ USA.
              0
              (guarantee-substring-start-index start end 'OPEN-INPUT-STRING))))
     (make-port input-string-port-type
-              (make-gstate (make-string-source string start end) #f 'TEXT))))
+              (make-gstate (make-string-source string start end)
+                           #f
+                           'ISO-8859-1
+                           'NEWLINE))))
 
 (define (make-string-source string start end)
   (let ((index start))
index 184c7aac6d8999be87f779fda8a3ea076843a302..90c5bccfc0fe7084fa39bf609c4d12e16e6e2370 100644 (file)
@@ -1,6 +1,6 @@
 #| -*-Scheme-*-
 
-$Id: strott.scm,v 14.14 2005/12/12 21:55:23 cph Exp $
+$Id: strott.scm,v 14.15 2005/12/14 05:44:45 cph Exp $
 
 Copyright 1988,1993,1999,2004,2005 Massachusetts Institute of Technology
 
@@ -35,7 +35,12 @@ USA.
            (make-port output-string-port-type
                       (receive (sink extract extract!)
                           (make-accumulator-sink limit k)
-                        (make-gstate #f sink 'TEXT extract extract!)))))
+                        (make-gstate #f
+                                     sink
+                                     'ISO-8859-1
+                                     'NEWLINE
+                                     extract
+                                     extract!)))))
        (generator port)
        (cons #f (get-output-string port))))))
 
index cef6a7ed3353b1c4bfc2524f810b19f4ac2e7766..8ff6df2ed6c74589fb00d0ec83b66ed41a0a754f 100644 (file)
@@ -1,6 +1,6 @@
 #| -*-Scheme-*-
 
-$Id: strout.scm,v 14.22 2005/12/12 21:55:39 cph Exp $
+$Id: strout.scm,v 14.23 2005/12/14 05:44:49 cph Exp $
 
 Copyright 1988,1990,1993,1999,2000,2001 Massachusetts Institute of Technology
 Copyright 2003,2004,2005 Massachusetts Institute of Technology
@@ -32,7 +32,7 @@ USA.
 (define (open-output-string)
   (make-port accumulator-output-port-type
             (receive (sink extract extract!) (make-accumulator-sink)
-              (make-gstate #f sink 'TEXT extract extract!))))
+              (make-gstate #f sink 'ISO-8859-1 'NEWLINE extract extract!))))
 
 (define (get-output-string port)
   ((port/operation port 'EXTRACT-OUTPUT) port))
index 2f6bb6fa7d0f859b364c2e3c2ab00d0dfead2d5d..9b1b5f9478153129f4f079bf6e9c52b28dd24e0d 100644 (file)
@@ -1,6 +1,6 @@
 #| -*-Scheme-*-
 
-$Id: ttyio.scm,v 1.22 2005/12/12 21:55:44 cph Exp $
+$Id: ttyio.scm,v 1.23 2005/12/14 05:44:53 cph Exp $
 
 Copyright 1991,1993,1996,1999,2003,2004 Massachusetts Institute of Technology
 Copyright 2005 Massachusetts Institute of Technology
@@ -83,6 +83,7 @@ USA.
   (make-gstate input-channel
               output-channel
               'TEXT
+              'TEXT
               (channel-type=file? input-channel)))
 
 (define (set-console-i/o-port! port)