mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Guile 2 : replace deprecated scm_makfrom0str function
The replacement function (scm_to_locale_string) doesn't deal well when the C string is NULL, so all replacements were adapted to handle this case. Depending on the context the replacement in case of a NULL input string will return SCM_BOOL_F or a sensible default string. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22653 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -125,11 +125,11 @@ gnc_quoteinfo2scm(gnc_commodity *comm)
|
||||
SWIG_TypeQuery("_p_gnc_commodity"), 0);
|
||||
|
||||
if (tz)
|
||||
info_scm = scm_cons (scm_makfrom0str (tz), info_scm);
|
||||
info_scm = scm_cons (scm_from_locale_string (tz), info_scm);
|
||||
else
|
||||
info_scm = scm_cons (SCM_BOOL_F, info_scm);
|
||||
info_scm = scm_cons (def_comm_scm, info_scm);
|
||||
info_scm = scm_cons (comm_scm, info_scm);
|
||||
info_scm = scm_cons (scm_makfrom0str (name), info_scm);
|
||||
info_scm = scm_cons (name ? scm_from_locale_string (name) : SCM_BOOL_F, info_scm);
|
||||
return info_scm;
|
||||
}
|
||||
|
||||
@@ -508,7 +508,7 @@ gnc_split_scm_set_account(SCM split_scm, Account *account)
|
||||
if (guid_string == NULL)
|
||||
return;
|
||||
|
||||
arg = scm_makfrom0str(guid_string);
|
||||
arg = scm_from_locale_string(guid_string);
|
||||
|
||||
scm_call_2(setters.split_scm_account_guid, split_scm, arg);
|
||||
}
|
||||
@@ -534,7 +534,7 @@ gnc_split_scm_set_memo(SCM split_scm, const char *memo)
|
||||
if (memo == NULL)
|
||||
return;
|
||||
|
||||
arg = scm_makfrom0str(memo);
|
||||
arg = scm_from_locale_string(memo);
|
||||
|
||||
scm_call_2(setters.split_scm_memo, split_scm, arg);
|
||||
}
|
||||
@@ -560,7 +560,7 @@ gnc_split_scm_set_action(SCM split_scm, const char *action)
|
||||
if (action == NULL)
|
||||
return;
|
||||
|
||||
arg = scm_makfrom0str(action);
|
||||
arg = scm_from_locale_string(action);
|
||||
|
||||
scm_call_2(setters.split_scm_action, split_scm, arg);
|
||||
}
|
||||
@@ -865,8 +865,8 @@ gnc_copy_trans_scm_onto_trans_swap_accounts(SCM trans_scm,
|
||||
|
||||
args = scm_cons(commit, args);
|
||||
|
||||
from = scm_makfrom0str(guid_to_string(guid_1));
|
||||
to = scm_makfrom0str(guid_to_string(guid_2));
|
||||
from = scm_from_locale_string(guid_to_string(guid_1));
|
||||
to = scm_from_locale_string(guid_to_string(guid_2));
|
||||
|
||||
map = scm_cons(scm_cons(from, to), map);
|
||||
map = scm_cons(scm_cons(to, from), map);
|
||||
@@ -925,7 +925,7 @@ gnc_trans_scm_set_num(SCM trans_scm, const char *num)
|
||||
if (num == NULL)
|
||||
return;
|
||||
|
||||
arg = scm_makfrom0str(num);
|
||||
arg = scm_from_locale_string(num);
|
||||
|
||||
scm_call_2(setters.trans_scm_num, trans_scm, arg);
|
||||
}
|
||||
@@ -951,7 +951,7 @@ gnc_trans_scm_set_description(SCM trans_scm, const char *description)
|
||||
if (description == NULL)
|
||||
return;
|
||||
|
||||
arg = scm_makfrom0str(description);
|
||||
arg = scm_from_locale_string(description);
|
||||
|
||||
scm_call_2(setters.trans_scm_description, trans_scm, arg);
|
||||
}
|
||||
@@ -977,7 +977,7 @@ gnc_trans_scm_set_notes(SCM trans_scm, const char *notes)
|
||||
if (notes == NULL)
|
||||
return;
|
||||
|
||||
arg = scm_makfrom0str(notes);
|
||||
arg = scm_from_locale_string(notes);
|
||||
|
||||
scm_call_2(setters.trans_scm_notes, trans_scm, arg);
|
||||
}
|
||||
|
||||
@@ -472,7 +472,7 @@ gnc_option_db_register_change_callback(GNCOptionDB *odb,
|
||||
}
|
||||
else
|
||||
{
|
||||
arg = scm_makfrom0str(name);
|
||||
arg = scm_from_locale_string(name);
|
||||
}
|
||||
args = scm_cons(arg, args);
|
||||
|
||||
@@ -483,7 +483,7 @@ gnc_option_db_register_change_callback(GNCOptionDB *odb,
|
||||
}
|
||||
else
|
||||
{
|
||||
arg = scm_makfrom0str(section);
|
||||
arg = scm_from_locale_string(section);
|
||||
}
|
||||
args = scm_cons(arg, args);
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ test_query (Query *q, SCM val2str)
|
||||
args = scm_cons (scm_q, SCM_EOL);
|
||||
str_q = scm_apply (val2str, args, SCM_EOL);
|
||||
|
||||
args = scm_cons (scm_makfrom0str ("'"), scm_cons (str_q, SCM_EOL));
|
||||
args = scm_cons (scm_from_locale_string ("'"), scm_cons (str_q, SCM_EOL));
|
||||
str_q = scm_string_append (args);
|
||||
|
||||
scm_display (str_q, SCM_UNDEFINED);
|
||||
|
||||
@@ -27,7 +27,7 @@ test_query (Query *q, SCM val2str)
|
||||
args = scm_cons (scm_q, SCM_EOL);
|
||||
str_q = scm_apply (val2str, args, SCM_EOL);
|
||||
|
||||
args = scm_cons (scm_makfrom0str ("'"), scm_cons (str_q, SCM_EOL));
|
||||
args = scm_cons (scm_from_locale_string ("'"), scm_cons (str_q, SCM_EOL));
|
||||
str_q = scm_string_append (args);
|
||||
|
||||
scm_dynwind_begin (0);
|
||||
|
||||
@@ -17,8 +17,10 @@ typedef void * gpointer;
|
||||
typedef char gchar;
|
||||
|
||||
%typemap (out) char * {
|
||||
$result = scm_makfrom0str((const char *)$1);
|
||||
if (!scm_is_true($result)) {
|
||||
if ($1) {
|
||||
$result = scm_from_locale_string((const char *)$1);
|
||||
}
|
||||
if (!$1 || !scm_is_true($result)) {
|
||||
$result = scm_c_make_string(0, SCM_UNDEFINED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -925,7 +925,7 @@ build_aging_report (GncOwnerType owner_type)
|
||||
g_return_val_if_fail (arg != SCM_UNDEFINED, -1);
|
||||
|
||||
/* Option Report title */
|
||||
arg = scm_makfrom0str (report_title);
|
||||
arg = scm_from_locale_string (report_title);
|
||||
args = scm_cons (arg, args);
|
||||
|
||||
/* Option Account - Using False to select default account
|
||||
|
||||
@@ -122,7 +122,7 @@ gnc_guid2scm(GncGUID guid)
|
||||
if (!guid_to_string_buff(&guid, string))
|
||||
return SCM_BOOL_F;
|
||||
|
||||
return scm_makfrom0str(string);
|
||||
return scm_from_locale_string(string);
|
||||
}
|
||||
|
||||
GncGUID
|
||||
@@ -489,7 +489,7 @@ gnc_query_path2scm (const GSList *path)
|
||||
const char *key = node->data;
|
||||
|
||||
if (key)
|
||||
path_scm = scm_cons (scm_makfrom0str (key), path_scm);
|
||||
path_scm = scm_cons (scm_from_locale_string (key), path_scm);
|
||||
}
|
||||
|
||||
return scm_reverse (path_scm);
|
||||
@@ -551,6 +551,7 @@ gnc_kvp_value2scm (const KvpValue *value)
|
||||
SCM value_scm = SCM_EOL;
|
||||
KvpValueType value_t;
|
||||
SCM scm;
|
||||
const gchar *string;
|
||||
|
||||
if (!value) return SCM_BOOL_F;
|
||||
|
||||
@@ -569,7 +570,8 @@ gnc_kvp_value2scm (const KvpValue *value)
|
||||
break;
|
||||
|
||||
case KVP_TYPE_STRING:
|
||||
scm = scm_makfrom0str (kvp_value_get_string (value));
|
||||
string = kvp_value_get_string (value);
|
||||
scm = string ? scm_from_locale_string (string) : SCM_BOOL_F;
|
||||
break;
|
||||
|
||||
case KVP_TYPE_GUID:
|
||||
@@ -629,7 +631,7 @@ kvp_frame_slot2scm (const char *key, KvpValue *value, gpointer data)
|
||||
SCM key_scm;
|
||||
SCM pair;
|
||||
|
||||
key_scm = scm_makfrom0str (key);
|
||||
key_scm = key ? scm_from_locale_string (key) : SCM_BOOL_F;
|
||||
value_scm = gnc_kvp_value2scm (value);
|
||||
pair = scm_cons (key_scm, value_scm);
|
||||
|
||||
@@ -844,7 +846,7 @@ gnc_queryterm2scm (const QofQueryTerm *qt)
|
||||
|
||||
qt_scm = scm_cons (scm_from_long (pdata->options), qt_scm);
|
||||
qt_scm = scm_cons (SCM_BOOL (pdata->is_regex), qt_scm);
|
||||
qt_scm = scm_cons (scm_makfrom0str (pdata->matchstring), qt_scm);
|
||||
qt_scm = scm_cons (pdata->matchstring ? scm_from_locale_string (pdata->matchstring) : SCM_BOOL_F, qt_scm);
|
||||
|
||||
}
|
||||
else if (!g_strcmp0 (pd->type_name, QOF_TYPE_DATE))
|
||||
@@ -897,7 +899,7 @@ gnc_queryterm2scm (const QofQueryTerm *qt)
|
||||
query_char_t pdata = (query_char_t) pd;
|
||||
|
||||
qt_scm = scm_cons (scm_from_long (pdata->options), qt_scm);
|
||||
qt_scm = scm_cons (scm_makfrom0str (pdata->char_list), qt_scm);
|
||||
qt_scm = scm_cons (pdata->char_list ? scm_from_locale_string (pdata->char_list) : SCM_BOOL_F, qt_scm);
|
||||
|
||||
}
|
||||
else if (!g_strcmp0 (pd->type_name, QOF_TYPE_KVP))
|
||||
|
||||
@@ -99,7 +99,12 @@ gnc_glist_string_to_scm(GList *glist)
|
||||
GList *node;
|
||||
|
||||
for (node = glist; node; node = node->next)
|
||||
list = scm_cons (scm_makfrom0str(node->data), list);
|
||||
{
|
||||
if (node->data)
|
||||
list = scm_cons (scm_from_locale_string(node->data), list);
|
||||
else
|
||||
list = scm_cons (SCM_BOOL_F, list);
|
||||
}
|
||||
|
||||
return scm_reverse (list);
|
||||
}
|
||||
|
||||
@@ -71,6 +71,7 @@ gnc_scm_to_kvp_value_ptr(SCM val)
|
||||
SCM
|
||||
gnc_kvp_value_ptr_to_scm(KvpValue* val)
|
||||
{
|
||||
const gchar *string;
|
||||
switch (kvp_value_get_type(val))
|
||||
{
|
||||
case KVP_TYPE_GINT64:
|
||||
@@ -83,7 +84,8 @@ gnc_kvp_value_ptr_to_scm(KvpValue* val)
|
||||
return gnc_numeric_to_scm(kvp_value_get_numeric(val));
|
||||
break;
|
||||
case KVP_TYPE_STRING:
|
||||
return scm_makfrom0str(kvp_value_get_string(val));
|
||||
string = kvp_value_get_string(val);
|
||||
return string ? scm_from_locale_string(string) : SCM_BOOL_F;
|
||||
break;
|
||||
case KVP_TYPE_GUID:
|
||||
{
|
||||
|
||||
@@ -2632,7 +2632,7 @@ gnc_option_get_ui_value_string (GNCOption *option, GtkWidget *widget)
|
||||
SCM result;
|
||||
|
||||
string = gtk_editable_get_chars(GTK_EDITABLE(widget), 0, -1);
|
||||
result = scm_makfrom0str(string);
|
||||
result = scm_from_locale_string(string ? string : "");
|
||||
g_free(string);
|
||||
return result;
|
||||
}
|
||||
@@ -2644,7 +2644,7 @@ gnc_option_get_ui_value_text (GNCOption *option, GtkWidget *widget)
|
||||
SCM result;
|
||||
|
||||
string = xxxgtk_textview_get_text (GTK_TEXT_VIEW(widget));
|
||||
result = scm_makfrom0str(string);
|
||||
result = scm_from_locale_string(string ? string : "");
|
||||
g_free(string);
|
||||
return result;
|
||||
}
|
||||
@@ -2865,7 +2865,7 @@ gnc_option_get_ui_value_font (GNCOption *option, GtkWidget *widget)
|
||||
const gchar * string;
|
||||
|
||||
string = gtk_font_button_get_font_name(font_button);
|
||||
return (scm_makfrom0str(string));
|
||||
return (string ? scm_from_locale_string(string) : SCM_BOOL_F);
|
||||
}
|
||||
|
||||
static SCM
|
||||
@@ -2876,7 +2876,7 @@ gnc_option_get_ui_value_pixmap (GNCOption *option, GtkWidget *widget)
|
||||
|
||||
string = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget));
|
||||
DEBUG("filename %s", string ? string : "(null)");
|
||||
result = scm_makfrom0str(string ? string : "");
|
||||
result = scm_from_locale_string(string ? string : "");
|
||||
g_free(string);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -2341,6 +2341,7 @@ report_helper (GNCLedgerDisplay *ledger, Split *split, Query *query)
|
||||
SplitRegister *reg = gnc_ledger_display_get_split_register (ledger);
|
||||
Account *account;
|
||||
char *str;
|
||||
const char *tmp;
|
||||
swig_type_info * qtype;
|
||||
SCM args;
|
||||
SCM func;
|
||||
@@ -2351,14 +2352,16 @@ report_helper (GNCLedgerDisplay *ledger, Split *split, Query *query)
|
||||
func = scm_c_eval_string ("gnc:register-report-create");
|
||||
g_return_val_if_fail (scm_is_procedure (func), -1);
|
||||
|
||||
arg = scm_makfrom0str (gnc_split_register_get_credit_string (reg));
|
||||
tmp = gnc_split_register_get_credit_string (reg);
|
||||
arg = scm_from_locale_string (tmp ? tmp : _("Credit"));
|
||||
args = scm_cons (arg, args);
|
||||
|
||||
arg = scm_makfrom0str (gnc_split_register_get_debit_string (reg));
|
||||
tmp = gnc_split_register_get_debit_string (reg);
|
||||
arg = scm_from_locale_string (tmp ? tmp : _("Debit"));
|
||||
args = scm_cons (arg, args);
|
||||
|
||||
str = gnc_reg_get_name (ledger, FALSE);
|
||||
arg = scm_makfrom0str (str);
|
||||
arg = scm_from_locale_string (str ? str : "");
|
||||
args = scm_cons (arg, args);
|
||||
g_free (str);
|
||||
|
||||
|
||||
@@ -2403,6 +2403,7 @@ report_helper (GNCLedgerDisplay2 *ledger, Split *split, Query *query)
|
||||
SplitRegister *reg = gnc_ledger_display2_get_split_register (ledger);
|
||||
Account *account;
|
||||
char *str;
|
||||
const char *tmp;
|
||||
swig_type_info * qtype;
|
||||
SCM args;
|
||||
SCM func;
|
||||
@@ -2413,14 +2414,16 @@ report_helper (GNCLedgerDisplay2 *ledger, Split *split, Query *query)
|
||||
func = scm_c_eval_string ("gnc:register-report-create");
|
||||
g_return_val_if_fail (scm_is_procedure (func), -1);
|
||||
|
||||
arg = scm_makfrom0str (gnc_split_register_get_credit_string (reg));
|
||||
tmp = gnc_split_register_get_credit_string (reg);
|
||||
arg = scm_from_locale_string (tmp ? tmp : _("Credit"));
|
||||
args = scm_cons (arg, args);
|
||||
|
||||
arg = scm_makfrom0str (gnc_split_register_get_debit_string (reg));
|
||||
tmp = gnc_split_register_get_debit_string (reg);
|
||||
arg = scm_from_locale_string (tmp ? tmp : _("Debit"));
|
||||
args = scm_cons (arg, args);
|
||||
|
||||
str = gnc_reg_get_name (ledger, FALSE);
|
||||
arg = scm_makfrom0str (str);
|
||||
arg = scm_from_locale_string (str ? str : "");
|
||||
args = scm_cons (arg, args);
|
||||
g_free (str);
|
||||
|
||||
|
||||
@@ -1555,7 +1555,7 @@ gnc_ui_qif_import_load_file_complete (GtkAssistant *assistant,
|
||||
|
||||
/* See if the file is already loaded. */
|
||||
if (scm_call_2(qif_file_loaded,
|
||||
scm_makfrom0str(path_to_load),
|
||||
scm_from_locale_string(path_to_load ? path_to_load : ""),
|
||||
wind->imported_files) == SCM_BOOL_T)
|
||||
gnc_error_dialog(wind->window, "%s",
|
||||
_("That QIF file is already loaded. "
|
||||
@@ -1756,7 +1756,7 @@ gnc_ui_qif_import_load_progress_start_cb(GtkButton * button,
|
||||
gnc_progress_dialog_push(wind->load_progress, 0.7);
|
||||
load_return = scm_call_4(qif_file_load,
|
||||
SCM_CAR(imported_files),
|
||||
scm_makfrom0str(path_to_load),
|
||||
scm_from_locale_string(path_to_load ? path_to_load : ""),
|
||||
wind->ticker_map,
|
||||
progress);
|
||||
gnc_progress_dialog_pop(wind->load_progress);
|
||||
@@ -2154,7 +2154,7 @@ gnc_ui_qif_import_loaded_files_prepare (GtkAssistant *assistant,
|
||||
SCM fix_default = scm_c_eval_string("qif-import:fix-from-acct");
|
||||
SCM scm_name;
|
||||
|
||||
scm_name = scm_makfrom0str(acct_name);
|
||||
scm_name = scm_from_locale_string(acct_name ? acct_name : "");
|
||||
scm_call_2(fix_default, wind->selected_file, scm_name);
|
||||
|
||||
/* Enable the assistant Buttons */
|
||||
@@ -2865,7 +2865,7 @@ gnc_ui_qif_import_convert_progress_start_cb(GtkButton * button,
|
||||
wind->cat_map_info,
|
||||
wind->memo_map_info,
|
||||
wind->security_hash,
|
||||
scm_makfrom0str(currname),
|
||||
scm_from_locale_string(currname ? currname : ""),
|
||||
wind->transaction_status,
|
||||
progress),
|
||||
SCM_EOL);
|
||||
|
||||
@@ -249,7 +249,7 @@ gnc_ui_qif_account_picker_new_cb(GtkButton * w, gpointer user_data)
|
||||
/* Save the full name and update the map entry. */
|
||||
g_free(wind->selected_name);
|
||||
wind->selected_name = fullname;
|
||||
scm_call_2(name_setter, wind->map_entry, scm_makfrom0str(fullname));
|
||||
scm_call_2(name_setter, wind->map_entry, scm_from_locale_string(fullname));
|
||||
}
|
||||
gtk_widget_destroy(dlg);
|
||||
|
||||
@@ -279,7 +279,7 @@ gnc_ui_qif_account_picker_changed_cb(GtkTreeSelection *selection,
|
||||
ACCOUNT_COL_FULLNAME, &wind->selected_name,
|
||||
-1);
|
||||
scm_call_2(name_setter, wind->map_entry,
|
||||
scm_makfrom0str(wind->selected_name));
|
||||
wind->selected_name ? scm_from_locale_string(wind->selected_name) : SCM_BOOL_F);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -243,8 +243,8 @@ gnc_style_sheet_new (StyleSheetDialog * ssd)
|
||||
if (template_str && name_str)
|
||||
{
|
||||
new_ss = scm_call_2(make_ss,
|
||||
scm_makfrom0str(template_str),
|
||||
scm_makfrom0str(name_str));
|
||||
scm_from_locale_string(template_str),
|
||||
scm_from_locale_string(name_str));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1548,7 +1548,7 @@ gnc_plugin_page_report_export_cb( GtkAction *action, GncPluginPageReport *report
|
||||
SCM res;
|
||||
|
||||
choice = SCM_CDR (choice);
|
||||
file_scm = scm_makfrom0str (filepath);
|
||||
file_scm = scm_from_locale_string (filepath);
|
||||
|
||||
res = scm_call_3 (export_thunk, priv->cur_report, choice, file_scm);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user