1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-10 14:00:21 +02:00

Avoid the use of discouraged or deprecated things.

This commit is contained in:
Marius Vollmer 2004-08-19 17:28:53 +00:00
parent f26b939545
commit ad6dec055f
4 changed files with 39 additions and 32 deletions

View file

@ -165,7 +165,7 @@ SCM_DEFINE (scm_readline, "%readline", 0, 4, 0,
if (!SCM_UNBNDP (text))
{
if (!SCM_STRINGP (text))
if (!scm_is_string (text))
{
--in_readline;
scm_wrong_type_arg (s_scm_readline, SCM_ARG1, text);
@ -253,15 +253,17 @@ internal_readline (SCM text)
{
SCM ret;
char *s;
char *prompt = SCM_UNBNDP (text) ? "" : SCM_STRING_CHARS (text);
char *prompt = SCM_UNBNDP (text) ? "" : scm_to_locale_string (text);
promptp = 1;
s = readline (prompt);
if (s)
ret = scm_makfrom0str (s);
ret = scm_from_locale_string (s);
else
ret = SCM_EOF_VAL;
if (!SCM_UNBNDP (text))
free (prompt);
free (s);
return ret;
@ -326,10 +328,9 @@ SCM_DEFINE (scm_add_history, "add-history", 1, 0, 0,
#define FUNC_NAME s_scm_add_history
{
char* s;
SCM_VALIDATE_STRING (1,text);
s = SCM_STRING_CHARS (text);
add_history (strdup (s));
s = scm_to_locale_string (text);
add_history (s);
return SCM_UNSPECIFIED;
}
@ -341,8 +342,13 @@ SCM_DEFINE (scm_read_history, "read-history", 1, 0, 0,
"")
#define FUNC_NAME s_scm_read_history
{
SCM_VALIDATE_STRING (1,file);
return scm_from_bool (!read_history (SCM_STRING_CHARS (file)));
char *filename;
SCM ret;
filename = scm_to_locale_string (file);
ret = scm_from_bool (!read_history (filename));
free (filename);
return ret;
}
#undef FUNC_NAME
@ -352,8 +358,13 @@ SCM_DEFINE (scm_write_history, "write-history", 1, 0, 0,
"")
#define FUNC_NAME s_scm_write_history
{
SCM_VALIDATE_STRING (1,file);
return scm_from_bool (!write_history (SCM_STRING_CHARS (file)));
char *filename;
SCM ret;
filename = scm_to_locale_string (file);
ret = scm_from_bool (!write_history (filename));
free (filename);
return ret;
}
#undef FUNC_NAME
@ -375,14 +386,14 @@ SCM_DEFINE (scm_filename_completion_function, "filename-completion-function", 2,
{
char *s;
SCM ans;
SCM_VALIDATE_STRING (1,text);
char *c_text = scm_to_locale_string (text);
#ifdef HAVE_RL_FILENAME_COMPLETION_FUNCTION
s = rl_filename_completion_function (SCM_STRING_CHARS (text), scm_is_true (continuep));
s = rl_filename_completion_function (c_text, scm_is_true (continuep));
#else
s = filename_completion_function (SCM_STRING_CHARS (text), scm_is_true (continuep));
s = filename_completion_function (c_text, scm_is_true (continuep));
#endif
ans = scm_makfrom0str (s);
free (s);
ans = scm_take_locale_string (s);
free (c_text);
return ans;
}
#undef FUNC_NAME
@ -404,18 +415,14 @@ completion_function (char *text, int continuep)
return NULL; /* #f => completion disabled */
else
{
SCM t = scm_makfrom0str (text);
SCM t = scm_from_locale_string (text);
SCM c = scm_from_bool (continuep);
res = scm_apply (compfunc, scm_list_2 (t, c), SCM_EOL);
if (scm_is_false (res))
return NULL;
if (!SCM_STRINGP (res))
scm_misc_error (s_scm_readline,
"Completion function returned bogus value: %S",
scm_list_1 (res));
return strdup (SCM_STRING_CHARS (res));
return scm_to_locale_string (res);
}
}

View file

@ -188,19 +188,19 @@ typedef struct {
static SCM
out_of_range_handler (void *data, SCM key, SCM args)
{
return scm_equal_p (key, scm_str2symbol ("out-of-range"));
return scm_equal_p (key, scm_from_locale_symbol ("out-of-range"));
}
static SCM
wrong_type_handler (void *data, SCM key, SCM args)
{
return scm_equal_p (key, scm_str2symbol ("wrong-type-arg"));
return scm_equal_p (key, scm_from_locale_symbol ("wrong-type-arg"));
}
static SCM
misc_error_handler (void *data, SCM key, SCM args)
{
return scm_equal_p (key, scm_str2symbol ("misc-error"));
return scm_equal_p (key, scm_from_locale_symbol ("misc-error"));
}
static SCM

View file

@ -29,8 +29,8 @@ string_equal (SCM str, char *lit)
int len = strlen (lit);
int result;
result = ((SCM_STRING_LENGTH (str) == len)
&& (!memcmp (SCM_STRING_CHARS (str), lit, len)));
result = ((scm_i_string_length (str) == len)
&& (!memcmp (scm_i_string_chars (str), lit, len)));
scm_remember_upto_here_1 (str);
return result;
}
@ -54,14 +54,14 @@ test_gh_set_substr ()
code if you have to copy the string just to look at it. */
/* Copy a substring to an overlapping region to its right. */
gh_set_substr (SCM_STRING_CHARS (string), string, 4, 6);
gh_set_substr (scm_i_string_chars (string), string, 4, 6);
assert (string_equal (string, "FreeFree, it!"));
string = gh_str02scm ("Free, darnit!");
assert (gh_string_p (string));
/* Copy a substring to an overlapping region to its left. */
gh_set_substr (SCM_STRING_CHARS (string) + 6, string, 2, 6);
gh_set_substr (scm_i_string_chars (string) + 6, string, 2, 6);
assert (string_equal (string, "Frdarnitrnit!"));
}

View file

@ -177,8 +177,8 @@ check_ports ()
scm_frame_begin (0);
{
SCM port = scm_open_file (scm_str2string (filename),
scm_str2string ("w"));
SCM port = scm_open_file (scm_from_locale_string (filename),
scm_from_locale_string ("w"));
scm_frame_unwind_handler_with_scm (close_port, port,
SCM_F_WIND_EXPLICITLY);
@ -189,8 +189,8 @@ check_ports ()
scm_frame_begin (0);
{
SCM port = scm_open_file (scm_str2string (filename),
scm_str2string ("r"));
SCM port = scm_open_file (scm_from_locale_string (filename),
scm_from_locale_string ("r"));
SCM res;
scm_frame_unwind_handler_with_scm (close_port, port,
SCM_F_WIND_EXPLICITLY);