Port encodings cannot be NULL
authorAndy Wingo <wingo@pobox.com>
Tue, 15 Jan 2013 14:05:40 +0000 (15:05 +0100)
committerAndy Wingo <wingo@pobox.com>
Tue, 15 Jan 2013 15:32:52 +0000 (16:32 +0100)
* libguile/ports.c (scm_c_read_unlocked, scm_ungetc_unlocked):
* libguile/read.c (scm_read_character):
* libguile/vports.c (sf_fill_input): Port encodings cannot be NULL any
  more, now that encodings are canonicalized, so simplify these.

libguile/ports.c
libguile/read.c
libguile/vports.c

index d147676..22db101 100644 (file)
@@ -1372,7 +1372,8 @@ scm_c_read_unlocked (SCM port, void *buffer, size_t size)
      requested number of bytes.  (Note that a single scm_fill_input
      call does not guarantee to fill the whole of the port's read
      buffer.) */
-  if (pt->read_buf_size <= 1 && pt->encoding == NULL)
+  if (pt->read_buf_size <= 1
+      && pt->encoding_mode == SCM_PORT_ENCODING_MODE_LATIN1)
     {
       /* The port that we are reading from is unbuffered - i.e. does
         not have its own persistent buffer - but we have a buffer,
@@ -1917,17 +1918,11 @@ scm_ungetc_unlocked (scm_t_wchar c, SCM port)
   scm_t_port *pt = SCM_PTAB_ENTRY (port);
   char *result;
   char result_buf[10];
-  const char *encoding;
   size_t len;
   int i;
 
-  if (pt->encoding != NULL)
-    encoding = pt->encoding;
-  else
-    encoding = "ISO-8859-1";
-
   len = sizeof (result_buf);
-  result = u32_conv_to_encoding (encoding,
+  result = u32_conv_to_encoding (pt->encoding,
                                 (enum iconv_ilseq_handler) pt->ilseq_handler,
                                 (uint32_t *) &c, 1, NULL,
                                 result_buf, &len);
index 1e4cbac..7c003b4 100644 (file)
@@ -991,7 +991,9 @@ scm_read_character (scm_t_wchar chr, SCM port, scm_t_read_opts *opts)
   /* Simple ASCII characters can be processed immediately.  Also, simple
      ISO-8859-1 characters can be processed immediately if the encoding for this
      port is ISO-8859-1.  */
-  if (bytes_read == 1 && ((unsigned char) buffer[0] <= 127 || pt->encoding == NULL))
+  if (bytes_read == 1 &&
+      ((unsigned char) buffer[0] <= 127
+       || pt->encoding_mode == SCM_PORT_ENCODING_MODE_LATIN1))
     {
       SCM_COL (port) += 1;
       return SCM_MAKE_CHAR (buffer[0]);
index 4ff13f2..a886e36 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995,1996,1998,1999,2000,2001, 2002, 2003, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1998,1999,2000,2001, 2002, 2003, 2006, 2009, 2010, 2011, 2013 Free Software Foundation, Inc.
  * 
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -94,7 +94,7 @@ sf_fill_input (SCM port)
   SCM_ASSERT (SCM_CHARP (ans), ans, SCM_ARG1, "sf_fill_input");
   pt = SCM_PTAB_ENTRY (port);    
 
-  if (pt->encoding == NULL)
+  if (pt->encoding_mode == SCM_PORT_ENCODING_MODE_LATIN1)
     {
       scm_t_port *pt = SCM_PTAB_ENTRY (port);