Fix broken interaction between readline and Unicode
authorMichael Gran <spk121@yahoo.com>
Tue, 8 Sep 2009 01:42:29 +0000 (18:42 -0700)
committerMichael Gran <spk121@yahoo.com>
Tue, 8 Sep 2009 02:12:34 +0000 (19:12 -0700)
commit7519234547acd3ced5cbe265f0bf1fcd6d6cda06
tree2b37d4cd18e9a6d4d3563d125fc8be1a4cae3159
parenteebff6d7f1055bb59fbad24c23f8db8ce14391d5
Fix broken interaction between readline and Unicode

This requires separate small fixes.

Readline has internal logic to deal with multi-byte characters, so
it wants bytes, not characters.

scm_c_read gets called by the vm when readline is activated, and it was
truncating multi-byte characters because soft ports didn't have the
UCS-4 capability.

Soft ports need the capability to read UCS-4 characters.  Since soft ports
may have a single byte buffer, full characters need to be stored into the
pushback buffer.

This broke the optimizations in scm_c_read for using an alternate buffer
for single-byte-buffered ports, because the opimization wasn't expecting
anything in the pushback buffer.

* libguile/vports.c (sf_fill_input): store complete chars, not single bytes

* libguile/ports.c (scm_c_read): don't use optimized path for non Latin-1.
  Add debug prints.

* libguile/string.h: make scm_i_from_stringn and scm_i_string_ref public
  so that readline can use them

* guile-readline/readline.c: read bytes, not complete chars, from the
  input port.  Convert output to the output port's locale
guile-readline/readline.c
libguile/ports.c
libguile/strings.h
libguile/vports.c