diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-04-01 13:15:01 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-04-01 13:23:32 +0300 |
commit | ee08a14e8d73482297fa603938e0ba04475c092c (patch) | |
tree | 8a3ffbf93a3d4426bac7a5f57072c9a4b9581737 | |
parent | 36226fa2c08235807a34ca448788f6cdaa9cff02 (diff) | |
download | mailutils-ee08a14e8d73482297fa603938e0ba04475c092c.tar.gz mailutils-ee08a14e8d73482297fa603938e0ba04475c092c.tar.bz2 |
Remove the uses of deprecated Guile functions.
* am/guile.m4 (MU_CHECK_GUILE): Check for scm_t_off.
* include/mailutils/guile.h (mu_scm_makenum)
(mu_set_variable): Remove prototypes.
* libmu_scm/mu_address.c: Remove calls to deprecated Guile functions.
* libmu_scm/mu_body.c: Likewise.
* libmu_scm/mu_guile.c: Likewise.
* libmu_scm/mu_mailbox.c: Likewise.
* libmu_scm/mu_message.c: Likewise.
* libmu_scm/mu_mime.c: Likewise.
* libmu_scm/mu_util.c: Likewise.
* libmu_scm/mu_scm.c (mu_scm_makenum): Remove.
(mu_set_variable): Remove. Use scm_c_define instead.
-rw-r--r-- | am/guile.m4 | 3 | ||||
-rw-r--r-- | include/mailutils/guile.h | 3 | ||||
-rw-r--r-- | libmu_scm/mu_address.c | 6 | ||||
-rw-r--r-- | libmu_scm/mu_body.c | 4 | ||||
-rw-r--r-- | libmu_scm/mu_guile.c | 2 | ||||
-rw-r--r-- | libmu_scm/mu_mailbox.c | 12 | ||||
-rw-r--r-- | libmu_scm/mu_message.c | 55 | ||||
-rw-r--r-- | libmu_scm/mu_mime.c | 6 | ||||
-rw-r--r-- | libmu_scm/mu_scm.c | 53 | ||||
-rw-r--r-- | libmu_scm/mu_util.c | 22 |
10 files changed, 64 insertions, 102 deletions
diff --git a/am/guile.m4 b/am/guile.m4 index ff0a54472..f04903739 100644 --- a/am/guile.m4 +++ b/am/guile.m4 @@ -62,7 +62,8 @@ AC_DEFUN([MU_CHECK_GUILE], GUILE_VERSION= GUILE_VERSION_NUMBER= m4_if($3,,[AC_MSG_ERROR(required library libguile not found)], [$3]) - else + else + AC_CHECK_TYPES([scm_t_off],[],[],[#include <libguile.h>]) AC_DEFINE_UNQUOTED(GUILE_VERSION, "$GUILE_VERSION", [Guile version number]) AC_DEFINE_UNQUOTED(GUILE_VERSION_NUMBER, $GUILE_VERSION_NUMBER, diff --git a/include/mailutils/guile.h b/include/mailutils/guile.h index 1c0e6e2c2..1db5b8a43 100644 --- a/include/mailutils/guile.h +++ b/include/mailutils/guile.h @@ -43,8 +43,7 @@ extern "C" { void mu_scm_error (const char *func_name, int status, const char *fmt, SCM args); -extern SCM mu_scm_makenum (unsigned long val); -extern void mu_set_variable (const char *name, SCM value); + extern void mu_scm_init (void); extern void mu_scm_mailbox_init (void); diff --git a/libmu_scm/mu_address.c b/libmu_scm/mu_address.c index ace89c248..a3571700d 100644 --- a/libmu_scm/mu_address.c +++ b/libmu_scm/mu_address.c @@ -66,7 +66,7 @@ _get_address_part (const char *func_name, address_get_fp fun, mu_address_destroy (&addr); if (status == 0) - ret = scm_makfrom0str (str); + ret = scm_from_locale_string (str); else { free (str); @@ -150,7 +150,7 @@ SCM_DEFINE (scm_mu_address_get_count, "mu-address-get-count", 1, 0, 0, mu_address_get_count (addr, &count); mu_address_destroy (&addr); - return mu_scm_makenum (count); + return scm_from_size_t (count); } #undef FUNC_NAME @@ -179,7 +179,7 @@ SCM_DEFINE (scm_mu_username_to_email, "mu-username->email", 0, 1, 0, "Cannot get user email for ~A", scm_list_1 (NAME)); - ret = scm_makfrom0str (email); + ret = scm_from_locale_string (email); free (email); return ret; } diff --git a/libmu_scm/mu_body.c b/libmu_scm/mu_body.c index 435e2c2bc..43ee30b74 100644 --- a/libmu_scm/mu_body.c +++ b/libmu_scm/mu_body.c @@ -19,7 +19,7 @@ #include "mu_scm.h" -long body_tag; +static scm_t_bits body_tag; struct mu_body { @@ -159,7 +159,7 @@ SCM_DEFINE (scm_mu_body_read_line, "mu-body-read-line", 1, 0, 0, if (nread == 0) return SCM_EOF_VAL; - return scm_makfrom0str (mbp->buffer); + return scm_from_locale_string (mbp->buffer); } #undef FUNC_NAME diff --git a/libmu_scm/mu_guile.c b/libmu_scm/mu_guile.c index c2fb89cd3..b5cd26175 100644 --- a/libmu_scm/mu_guile.c +++ b/libmu_scm/mu_guile.c @@ -131,7 +131,7 @@ load_path_handler (void *data) struct load_closure *lp = data; scm_set_program_arguments (lp->argc, lp->argv, (char*)lp->filename); - scm_primitive_load (scm_makfrom0str (lp->filename)); + scm_primitive_load (scm_from_locale_string (lp->filename)); return SCM_UNDEFINED; } diff --git a/libmu_scm/mu_mailbox.c b/libmu_scm/mu_mailbox.c index 4d4eb5549..8a54fda1b 100644 --- a/libmu_scm/mu_mailbox.c +++ b/libmu_scm/mu_mailbox.c @@ -19,7 +19,7 @@ #include "mu_scm.h" -long mailbox_tag; +static scm_t_bits mailbox_tag; /* NOTE: Maybe will have to add some more members. That's why it is a struct, not just a typedef mu_mailbox_t */ @@ -160,7 +160,7 @@ SCM_DEFINE (scm_mu_user_mailbox_url, "mu-user-mailbox-url", 1, 0, 0, mu_scm_error (FUNC_NAME, rc, "Cannot construct mailbox URL for ~A", scm_list_1 (USER)); - ret = scm_makfrom0str (p); + ret = scm_from_locale_string (p); free (p); return ret; } @@ -175,13 +175,13 @@ SCM_DEFINE (scm_mu_folder_directory, "mu-folder-directory", 0, 1, 0, if (!SCM_UNBNDP (URL)) { char *s; - + SCM_ASSERT (scm_is_string (URL), URL, SCM_ARG1, FUNC_NAME); s = scm_to_locale_string (URL); mu_set_folder_directory (s); free (s); } - return scm_makfrom0str (mu_folder_directory ()); + return scm_from_locale_string (mu_folder_directory ()); } #undef FUNC_NAME @@ -288,7 +288,7 @@ SCM_DEFINE (scm_mu_mailbox_get_url, "mu-mailbox-get-url", 1, 0, 0, "Cannot get mailbox url", SCM_BOOL_F); - return scm_makfrom0str (mu_url_to_string (url)); + return scm_from_locale_string (mu_url_to_string (url)); } #undef FUNC_NAME @@ -364,7 +364,7 @@ SCM_DEFINE (scm_mu_mailbox_messages_count, "mu-mailbox-messages-count", 1, 0, 0, mu_scm_error (FUNC_NAME, status, "Cannot count messages in mailbox ~A", scm_list_1 (MBOX)); - return mu_scm_makenum (nmesg); + return scm_from_size_t (nmesg); } #undef FUNC_NAME diff --git a/libmu_scm/mu_message.c b/libmu_scm/mu_message.c index 61d4c7804..4167f963d 100644 --- a/libmu_scm/mu_message.c +++ b/libmu_scm/mu_message.c @@ -19,7 +19,7 @@ #include "mu_scm.h" -long message_tag; +static scm_t_bits message_tag; struct mu_message { @@ -147,13 +147,13 @@ mu_scm_message_add_owner (SCM MESG, SCM owner) struct mu_message *mum = (struct mu_message *) SCM_CDR (MESG); SCM cell; - if (SCM_IMP (mum->mbox) && SCM_BOOLP (mum->mbox)) + if (scm_is_bool (mum->mbox)) { mum->mbox = owner; return; } - if (SCM_NIMP (mum->mbox) && SCM_CONSP (mum->mbox)) + if (scm_is_pair (mum->mbox)) cell = scm_cons (owner, mum->mbox); else cell = scm_cons (owner, scm_cons (mum->mbox, SCM_EOL)); @@ -281,7 +281,7 @@ SCM_DEFINE (scm_mu_message_set_header, "mu-message-set-header", 3, 1, 0, msg = mu_scm_message_get (MESG); SCM_ASSERT (scm_is_string (HEADER), HEADER, SCM_ARG2, FUNC_NAME); - if (SCM_IMP (VALUE) && SCM_BOOLP (VALUE)) + if (scm_is_bool (VALUE)) return SCM_UNSPECIFIED; SCM_ASSERT (scm_is_string (VALUE), VALUE, SCM_ARG2, FUNC_NAME); @@ -317,10 +317,11 @@ SCM_DEFINE (scm_mu_message_get_size, "mu-message-get-size", 1, 0, 0, { mu_message_t msg; size_t size; + SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME); msg = mu_scm_message_get (MESG); mu_message_size (msg, &size); - return mu_scm_makenum (size); + return scm_from_size_t (size); } #undef FUNC_NAME @@ -341,7 +342,7 @@ SCM_DEFINE (scm_mu_message_get_lines, "mu-message-get-lines", 1, 0, 0, "Cannot get number of lines in message ~A", scm_list_1 (MESG)); - return mu_scm_makenum (lines); + return scm_from_size_t (lines); } #undef FUNC_NAME @@ -426,7 +427,7 @@ SCM_DEFINE (scm_mu_message_get_envelope_date, "mu-message-get-envelope-date", 1, status = mu_parse_ctime_date_time (&sdate, &tm, &tz); if (status) mu_scm_error (FUNC_NAME, status, "invalid envelope date", - scm_list_1 (scm_makfrom0str (sdate))); + scm_list_1 (scm_from_locale_string (sdate))); return filltime (&tm, tz.utc_offset, tz.tz_name); } #undef FUNC_NAME @@ -447,7 +448,7 @@ SCM_DEFINE (scm_mu_message_get_sender, "mu-message-get-sender", 1, 0, 0, if (status == 0) { char *p = _get_envelope_sender (env); - ret = scm_makfrom0str (p); + ret = scm_from_locale_string (p); free (p); } else @@ -484,7 +485,7 @@ SCM_DEFINE (scm_mu_message_get_header, "mu-message-get-header", 2, 0, 0, switch (status) { case 0: - ret = scm_makfrom0str (value); + ret = scm_from_locale_string (value); free (value); break; @@ -533,8 +534,7 @@ SCM_DEFINE (scm_mu_message_get_header_fields, "mu-message-get-header-fields", 1, msg = mu_scm_message_get (MESG); if (!SCM_UNBNDP (HEADERS)) { - SCM_ASSERT (SCM_NIMP (HEADERS) && SCM_CONSP (HEADERS), - HEADERS, SCM_ARG2, FUNC_NAME); + SCM_ASSERT (scm_is_pair (HEADERS), HEADERS, SCM_ARG2, FUNC_NAME); headers = HEADERS; } @@ -558,7 +558,7 @@ SCM_DEFINE (scm_mu_message_get_header_fields, "mu-message-get-header-fields", 1, "Cannot get header field ~A, message ~A", scm_list_2 (scm_from_size_t (i), MESG)); - if (headers != SCM_EOL && string_sloppy_member (headers, name) == 0) + if (!scm_is_null (headers) && string_sloppy_member (headers, name) == 0) continue; status = mu_header_aget_field_value (hdr, i, &value); if (status) @@ -566,12 +566,12 @@ SCM_DEFINE (scm_mu_message_get_header_fields, "mu-message-get-header-fields", 1, "Cannot get header value ~A, message ~A", scm_list_2 (scm_from_size_t (i), MESG)); - scm_name = scm_makfrom0str (name); - scm_value = scm_makfrom0str (value); + scm_name = scm_from_locale_string (name); + scm_value = scm_from_locale_string (value); scm_new = scm_cons (scm_cons (scm_name, scm_value), SCM_EOL); - if (scm_first == SCM_EOL) + if (scm_is_null (scm_first)) scm_first = scm_last = scm_new; else { @@ -601,13 +601,11 @@ SCM_DEFINE (scm_mu_message_set_header_fields, "mu-message-set-header-fields", 2, SCM_ASSERT (mu_scm_is_message (MESG), MESG, SCM_ARG1, FUNC_NAME); msg = mu_scm_message_get (MESG); - SCM_ASSERT (((SCM_IMP (LIST) && SCM_EOL == LIST) || - (SCM_NIMP (LIST) && SCM_CONSP (LIST))), + SCM_ASSERT (scm_is_null (LIST) || scm_is_pair (LIST), LIST, SCM_ARG2, FUNC_NAME); if (!SCM_UNBNDP (REPLACE)) { - SCM_ASSERT (SCM_IMP (REPLACE) && SCM_BOOLP (REPLACE), - REPLACE, SCM_ARG3, FUNC_NAME); + SCM_ASSERT (scm_is_bool (REPLACE), REPLACE, SCM_ARG3, FUNC_NAME); replace = REPLACE == SCM_BOOL_T; } @@ -616,14 +614,13 @@ SCM_DEFINE (scm_mu_message_set_header_fields, "mu-message-set-header-fields", 2, mu_scm_error (FUNC_NAME, status, "Cannot get message headers", SCM_BOOL_F); - for (list = LIST; list != SCM_EOL; list = SCM_CDR (list)) + for (list = LIST; !scm_is_null (list); list = SCM_CDR (list)) { SCM cell = SCM_CAR (list); SCM car, cdr; char *hdr_c, *val_c; - SCM_ASSERT (SCM_NIMP (cell) && SCM_CONSP (cell), - cell, SCM_ARGn, FUNC_NAME); + SCM_ASSERT (scm_is_pair (cell), cell, SCM_ARGn, FUNC_NAME); car = SCM_CAR (cell); cdr = SCM_CDR (cell); SCM_ASSERT (scm_is_string (car), car, SCM_ARGn, FUNC_NAME); @@ -659,8 +656,7 @@ SCM_DEFINE (scm_mu_message_delete, "mu-message-delete", 1, 1, 0, msg = mu_scm_message_get (MESG); if (!SCM_UNBNDP (FLAG)) { - SCM_ASSERT (SCM_IMP (FLAG) && SCM_BOOLP (FLAG), - FLAG, SCM_ARG2, FUNC_NAME); + SCM_ASSERT (scm_is_bool (FLAG), FLAG, SCM_ARG2, FUNC_NAME); delete = FLAG == SCM_BOOL_T; } status = mu_message_get_attribute (msg, &attr); @@ -759,8 +755,7 @@ SCM_DEFINE (scm_mu_message_set_flag, "mu-message-set-flag", 2, 1, 0, if (!SCM_UNBNDP (VALUE)) { - SCM_ASSERT (SCM_IMP (VALUE) && SCM_BOOLP (VALUE), - VALUE, SCM_ARG3, FUNC_NAME); + SCM_ASSERT (scm_is_bool (VALUE), VALUE, SCM_ARG3, FUNC_NAME); value = VALUE == SCM_BOOL_T; } @@ -880,8 +875,7 @@ SCM_DEFINE (scm_mu_message_set_user_flag, "mu-message-set-user-flag", 2, 1, 0, if (!SCM_UNBNDP (VALUE)) { - SCM_ASSERT (SCM_IMP (VALUE) && SCM_BOOLP (VALUE), - VALUE, SCM_ARG3, FUNC_NAME); + SCM_ASSERT (scm_is_bool (VALUE), VALUE, SCM_ARG3, FUNC_NAME); set = VALUE == SCM_BOOL_T; } @@ -922,8 +916,7 @@ SCM_DEFINE (scm_mu_message_get_port, "mu-message-get-port", 2, 1, 0, if (!SCM_UNBNDP (FULL)) { - SCM_ASSERT (SCM_IMP (FULL) && SCM_BOOLP (FULL), - FULL, SCM_ARG3, FUNC_NAME); + SCM_ASSERT (scm_is_bool (FULL), FULL, SCM_ARG3, FUNC_NAME); if (FULL == SCM_BOOL_T) { status = mu_message_get_stream (msg, &stream); @@ -1010,7 +1003,7 @@ SCM_DEFINE (scm_mu_message_get_num_parts, "mu-message-get-num-parts", 1, 0, 0, mu_scm_error (FUNC_NAME, status, "Cannot get number of parts in the message ~A", scm_list_1 (MESG)); - return mu_scm_makenum (nparts); + return scm_from_size_t (nparts); } #undef FUNC_NAME diff --git a/libmu_scm/mu_mime.c b/libmu_scm/mu_mime.c index de889edde..ca9f79997 100644 --- a/libmu_scm/mu_mime.c +++ b/libmu_scm/mu_mime.c @@ -19,7 +19,7 @@ #include "mu_scm.h" -long mime_tag; +static scm_t_bits mime_tag; struct mu_mime { @@ -101,7 +101,7 @@ SCM_DEFINE (scm_mu_mime_create, "mu-mime-create", 0, 2, 0, int flags; int status; - if (SCM_IMP (FLAGS) && SCM_BOOLP (FLAGS)) + if (scm_is_bool (FLAGS)) { /*if (FLAGS == SCM_BOOL_F)*/ flags = 0; @@ -152,7 +152,7 @@ SCM_DEFINE (scm_mu_mime_get_num_parts, "mu-mime-get-num-parts", 1, 0, 0, if (status) mu_scm_error (FUNC_NAME, status, "Cannot count MIME parts", SCM_BOOL_F); - return mu_scm_makenum (nparts); + return scm_from_size_t (nparts); } #undef FUNC_NAME diff --git a/libmu_scm/mu_scm.c b/libmu_scm/mu_scm.c index 3b02a86cd..9df955158 100644 --- a/libmu_scm/mu_scm.c +++ b/libmu_scm/mu_scm.c @@ -29,36 +29,11 @@ mu_scm_error (const char *func_name, int status, { scm_error_scm (scm_from_locale_symbol ("mailutils-error"), func_name ? scm_from_locale_string (func_name) : SCM_BOOL_F, - scm_makfrom0str (fmt), + scm_from_locale_string (fmt), args, scm_list_1 (scm_from_int (status))); } -SCM -mu_scm_makenum (unsigned long val) -#ifndef HAVE_SCM_LONG2NUM -{ - if (SCM_FIXABLE ((long) val)) - return scm_from_int (val); - -#ifdef SCM_BIGDIG - return scm_long2big (val); -#else /* SCM_BIGDIG */ - return scm_make_real ((double) val); -#endif /* SCM_BIGDIG */ -} -#else -{ - return scm_long2num (val); -} -#endif - -void -mu_set_variable (const char *name, SCM value) -{ - scm_c_define (name, value); -} - SCM _mu_scm_package_string; /* STRING: PACKAGE_STRING */ SCM _mu_scm_package; /* STRING: PACKAGE */ SCM _mu_scm_version; /* STRING: VERSION */ @@ -133,7 +108,7 @@ SCM_DEFINE (scm_mu_register_format, "mu-register-format", 0, 0, 1, { int status; - if (REST == SCM_EOL) + if (scm_is_null (REST)) { status = register_format (NULL); if (status) @@ -143,7 +118,7 @@ SCM_DEFINE (scm_mu_register_format, "mu-register-format", 0, 0, 1, } else { - for (; REST != SCM_EOL; REST = SCM_CDR (REST)) + for (; !scm_is_null (REST); REST = SCM_CDR (REST)) { char *s; SCM scm = SCM_CAR (REST); @@ -168,7 +143,7 @@ SCM_DEFINE (scm_mu_strerror, "mu-strerror", 1, 0, 0, #define FUNC_NAME s_scm_mu_strerror { SCM_ASSERT (scm_is_integer (ERR), ERR, SCM_ARG1, FUNC_NAME); - return scm_makfrom0str (mu_strerror (scm_to_int (ERR))); + return scm_from_locale_string (mu_strerror (scm_to_int (ERR))); } #undef FUNC_NAME @@ -194,20 +169,20 @@ mu_scm_init () { int i; - _mu_scm_mailer = scm_makfrom0str ("sendmail:" PATH_SENDMAIL); - mu_set_variable ("mu-mailer", _mu_scm_mailer); + _mu_scm_mailer = scm_from_locale_string ("sendmail:" PATH_SENDMAIL); + scm_c_define ("mu-mailer", _mu_scm_mailer); - _mu_scm_debug = mu_scm_makenum(0); - mu_set_variable ("mu-debug", _mu_scm_debug); + _mu_scm_debug = scm_from_int (0); + scm_c_define ("mu-debug", _mu_scm_debug); - _mu_scm_package = scm_makfrom0str (PACKAGE); - mu_set_variable ("mu-package", _mu_scm_package); + _mu_scm_package = scm_from_locale_string (PACKAGE); + scm_c_define ("mu-package", _mu_scm_package); - _mu_scm_version = scm_makfrom0str (VERSION); - mu_set_variable ("mu-version", _mu_scm_version); + _mu_scm_version = scm_from_locale_string (VERSION); + scm_c_define ("mu-version", _mu_scm_version); - _mu_scm_package_string = scm_makfrom0str (PACKAGE_STRING); - mu_set_variable ("mu-package-string", _mu_scm_package_string); + _mu_scm_package_string = scm_from_locale_string (PACKAGE_STRING); + scm_c_define ("mu-package-string", _mu_scm_package_string); /* Create MU- attribute names */ for (i = 0; attr_kw[i].name; i++) diff --git a/libmu_scm/mu_util.c b/libmu_scm/mu_util.c index 2668a76da..22fedc586 100644 --- a/libmu_scm/mu_util.c +++ b/libmu_scm/mu_util.c @@ -56,20 +56,14 @@ SCM_DEFINE (scm_mu_getpwuid, "mu-getpwuid", 1, 0, 0, mu_scm_error (FUNC_NAME, errno, "Cannot get user credentials", SCM_BOOL_F); - ve[0] = scm_makfrom0str (entry->name); - ve[1] = scm_makfrom0str (entry->passwd); - ve[2] = scm_ulong2num ((unsigned long) entry->uid); - ve[3] = scm_ulong2num ((unsigned long) entry->gid); - ve[4] = scm_makfrom0str (entry->gecos); - if (!entry->dir) - ve[5] = scm_makfrom0str (""); - else - ve[5] = scm_makfrom0str (entry->dir); - if (!entry->shell) - ve[6] = scm_makfrom0str (""); - else - ve[6] = scm_makfrom0str (entry->shell); - ve[7] = scm_makfrom0str (entry->mailbox); + ve[0] = scm_from_locale_string (entry->name); + ve[1] = scm_from_locale_string (entry->passwd); + ve[2] = scm_from_ulong ((unsigned long) entry->uid); + ve[3] = scm_from_ulong ((unsigned long) entry->gid); + ve[4] = scm_from_locale_string (entry->gecos); + ve[5] = scm_from_locale_string (entry->dir ? entry->dir : ""); + ve[6] = scm_from_locale_string (entry->shell ? entry->shell : ""); + ve[7] = scm_from_locale_string (entry->mailbox); scm_array_handle_release (&handle); |