1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 11:50:28 +02:00

Remove locale u8vector functions

Locale u8vector functions deemed harmful.

* libguile/strports.c (scm_strport_to_locale_u8vector)
  (scm_call_with_output_locale_u8vector, scm_open_input_locale_u8vector)
  (scm_get_output_locale_u8vector): removed

* libguile/strports.h: removed declarations for
  scm_strport_to_locale_u8vector,
  scm_call_with_output_u8vector,
  scm_input_locale_u8vector,
  scm_get_output_locale_u8vector

* test-suite/tests/encoding-iso88591.test: display tests removed

* test-suite/tests/encoding-iso88597.test: display tests removed
This commit is contained in:
Michael Gran 2009-09-04 07:34:35 -07:00
parent 25ebc0340d
commit 18d8fcd43c
4 changed files with 0 additions and 117 deletions

View file

@ -386,24 +386,6 @@ SCM scm_strport_to_string (SCM port)
return str; return str;
} }
/* Create a vector containing the locale representation of the string in the
port's buffer. */
SCM scm_strport_to_locale_u8vector (SCM port)
{
scm_t_port *pt = SCM_PTAB_ENTRY (port);
SCM vec;
char *buf;
if (pt->rw_active == SCM_PORT_WRITE)
st_flush (port);
buf = scm_malloc (pt->read_buf_size);
memcpy (buf, pt->read_buf, pt->read_buf_size);
vec = scm_take_u8vector ((unsigned char *) buf, pt->read_buf_size);
scm_remember_upto_here_1 (port);
return vec;
}
SCM_DEFINE (scm_object_to_string, "object->string", 1, 1, 0, SCM_DEFINE (scm_object_to_string, "object->string", 1, 1, 0,
(SCM obj, SCM printer), (SCM obj, SCM printer),
"Return a Scheme string obtained by printing @var{obj}.\n" "Return a Scheme string obtained by printing @var{obj}.\n"
@ -428,25 +410,6 @@ SCM_DEFINE (scm_object_to_string, "object->string", 1, 1, 0,
} }
#undef FUNC_NAME #undef FUNC_NAME
SCM_DEFINE (scm_call_with_output_locale_u8vector, "call-with-output-locale-u8vector", 1, 0, 0,
(SCM proc),
"Calls the one-argument procedure @var{proc} with a newly created output\n"
"port. When the function returns, a vector containing the bytes of a\n"
"locale representation of the characters written into the port is returned\n")
#define FUNC_NAME s_scm_call_with_output_locale_u8vector
{
SCM p;
p = scm_mkstrport (SCM_INUM0,
scm_make_string (SCM_INUM0, SCM_UNDEFINED),
SCM_OPN | SCM_WRTNG,
FUNC_NAME);
scm_call_1 (proc, p);
return scm_get_output_locale_u8vector (p);
}
#undef FUNC_NAME
SCM_DEFINE (scm_call_with_output_string, "call-with-output-string", 1, 0, 0, SCM_DEFINE (scm_call_with_output_string, "call-with-output-string", 1, 0, 0,
(SCM proc), (SCM proc),
"Calls the one-argument procedure @var{proc} with a newly created output\n" "Calls the one-argument procedure @var{proc} with a newly created output\n"
@ -491,27 +454,6 @@ SCM_DEFINE (scm_open_input_string, "open-input-string", 1, 0, 0,
} }
#undef FUNC_NAME #undef FUNC_NAME
SCM_DEFINE (scm_open_input_locale_u8vector, "open-input-locale-u8vector", 1, 0, 0,
(SCM vec),
"Take a u8vector containing the bytes of a string encoded in the\n"
"current locale and return an input port that delivers characters\n"
"from the string. The port can be closed by\n"
"@code{close-input-port}, though its storage will be reclaimed\n"
"by the garbage collector if it becomes inaccessible.")
#define FUNC_NAME s_scm_open_input_locale_u8vector
{
scm_t_array_handle hnd;
ssize_t inc;
size_t len;
const scm_t_uint8 *buf;
buf = scm_u8vector_elements (vec, &hnd, &len, &inc);
SCM p = scm_i_mkstrport(SCM_INUM0, (const char *) buf, len, SCM_OPN | SCM_RDNG, FUNC_NAME);
scm_array_handle_release (&hnd);
return p;
}
#undef FUNC_NAME
SCM_DEFINE (scm_open_output_string, "open-output-string", 0, 0, 0, SCM_DEFINE (scm_open_output_string, "open-output-string", 0, 0, 0,
(void), (void),
"Return an output port that will accumulate characters for\n" "Return an output port that will accumulate characters for\n"
@ -544,19 +486,6 @@ SCM_DEFINE (scm_get_output_string, "get-output-string", 1, 0, 0,
#undef FUNC_NAME #undef FUNC_NAME
SCM_DEFINE (scm_get_output_locale_u8vector, "get-output-locale-u8vector", 1, 0, 0,
(SCM port),
"Given an output port created by @code{open-output-string},\n"
"return a u8 vector containing the characters of the string\n"
"encoded in the current locale.")
#define FUNC_NAME s_scm_get_output_locale_u8vector
{
SCM_VALIDATE_OPOUTSTRPORT (1, port);
return scm_strport_to_locale_u8vector (port);
}
#undef FUNC_NAME
/* Given a null-terminated string EXPR containing a Scheme expression /* Given a null-terminated string EXPR containing a Scheme expression
read it, and return it as an SCM value. */ read it, and return it as an SCM value. */
SCM SCM

View file

@ -47,16 +47,12 @@ SCM_API SCM scm_mkstrport (SCM pos, SCM str, long modes, const char * caller);
SCM_INTERNAL SCM scm_i_mkstrport (SCM pos, const char *locale_str, size_t str_len, SCM_INTERNAL SCM scm_i_mkstrport (SCM pos, const char *locale_str, size_t str_len,
long modes, const char *caller); long modes, const char *caller);
SCM_API SCM scm_strport_to_string (SCM port); SCM_API SCM scm_strport_to_string (SCM port);
SCM_API SCM scm_strport_to_locale_u8vector (SCM port);
SCM_API SCM scm_object_to_string (SCM obj, SCM printer); SCM_API SCM scm_object_to_string (SCM obj, SCM printer);
SCM_API SCM scm_call_with_output_string (SCM proc); SCM_API SCM scm_call_with_output_string (SCM proc);
SCM_API SCM scm_call_with_output_locale_u8vector (SCM proc);
SCM_API SCM scm_call_with_input_string (SCM str, SCM proc); SCM_API SCM scm_call_with_input_string (SCM str, SCM proc);
SCM_API SCM scm_open_input_string (SCM str); SCM_API SCM scm_open_input_string (SCM str);
SCM_API SCM scm_open_input_locale_u8vector (SCM str);
SCM_API SCM scm_open_output_string (void); SCM_API SCM scm_open_output_string (void);
SCM_API SCM scm_get_output_string (SCM port); SCM_API SCM scm_get_output_string (SCM port);
SCM_API SCM scm_get_output_locale_u8vector (SCM port);
SCM_API SCM scm_c_read_string (const char *expr); SCM_API SCM scm_c_read_string (const char *expr);
SCM_API SCM scm_c_eval_string (const char *expr); SCM_API SCM scm_c_eval_string (const char *expr);
SCM_API SCM scm_c_eval_string_in_module (const char *expr, SCM module); SCM_API SCM scm_c_eval_string_in_module (const char *expr, SCM module);

View file

@ -145,27 +145,6 @@
(list= eqv? (string->list s4) (list= eqv? (string->list s4)
(list #\¿ #\C #\ó #\m #\o #\?)))) (list #\¿ #\C #\ó #\m #\o #\?))))
;; Check that the output is in ISO-8859-1 encoding
(with-test-prefix "display"
(pass-if "s1"
(let ((pt (open-output-string)))
(set-port-encoding! pt "ISO-8859-1")
(display s1 pt)
(list= eqv?
(list #xfa #x6c #x74 #x69 #x6d #x61)
(u8vector->list
(get-output-locale-u8vector pt)))))
(pass-if "s2"
(let ((pt (open-output-string)))
(set-port-encoding! pt "ISO-8859-1")
(display s2 pt)
(list= eqv?
(list #x63 #xe9 #x64 #x75 #x6c #x61)
(u8vector->list
(get-output-locale-u8vector pt))))))
(with-test-prefix "symbols == strings" (with-test-prefix "symbols == strings"
(pass-if "última" (pass-if "última"

View file

@ -142,27 +142,6 @@
(list= eqv? (string->list s4) (list= eqv? (string->list s4)
(list #\ê #\á #\é)))) (list #\ê #\á #\é))))
;; Testing that the display of the string is output in the ISO-8859-7
;; encoding
(with-test-prefix "display"
(pass-if "s1"
(let ((pt (open-output-string)))
(set-port-encoding! pt "ISO-8859-7")
(display s1 pt)
(list= eqv?
(list #xd0 #xe5 #xf1 #xdf)
(u8vector->list
(get-output-locale-u8vector pt)))))
(pass-if "s2"
(let ((pt (open-output-string)))
(set-port-encoding! pt "ISO-8859-7")
(display s2 pt)
(list= eqv?
(list #xf4 #xe7 #xf2)
(u8vector->list
(get-output-locale-u8vector pt))))))
(with-test-prefix "symbols == strings" (with-test-prefix "symbols == strings"
(pass-if "Ðåñß" (pass-if "Ðåñß"