> From: Ludovic Courtès <l...@gnu.org> > > Hello, > > The attached patch fixes string ports so that their encoding defaults to > ‘%default-port-encoding’ (as for other ports) instead of UTF-8. > > Mike: can you review it?
Hi Ludovic, It is a bit hard for me to review this as I don't have access to my machine right now, but, let me see what I can do. When you write... + /* Create a copy of STR in the encoding of Z. */ + buf = scm_to_stringn (str, &str_len, pt->encoding, + SCM_FAILED_CONVERSION_ERROR); + /* FIXME: strdup doesn't do the right thing if BUF contains zeros, but we + don't know the size in bytes of STR. */ + c_str = scm_gc_strdup (buf, "strport"); + free (buf); ... isn't the returned value str_len the length in bytes of buf? I think you could avoid the strdup call, since it could fail, for example, for UTF-32 strings of more than one character. Also, in the big scheme of things, I wonder if the name "string port" is misleading now. Strings can contain the whole codepoint range. But string ports can't store the whole range depending on their encoding. (That's what the "UTF-8" hack was about.) Thanks, Mike Gran