r22653 - gnucash/trunk/src - Guile 2 : replace deprecated scm_makfrom0str function

Geert Janssens gjanssens at code.gnucash.org
Sat Dec 15 12:59:14 EST 2012


Author: gjanssens
Date: 2012-12-15 12:59:14 -0500 (Sat, 15 Dec 2012)
New Revision: 22653
Trac: http://svn.gnucash.org/trac/changeset/22653

Modified:
   gnucash/trunk/src/app-utils/gnc-helpers.c
   gnucash/trunk/src/app-utils/guile-util.c
   gnucash/trunk/src/app-utils/option-util.c
   gnucash/trunk/src/app-utils/test/test-print-queries.c
   gnucash/trunk/src/app-utils/test/test-scm-query-string.c
   gnucash/trunk/src/base-typemaps.i
   gnucash/trunk/src/business/business-gnome/gnc-plugin-page-owner-tree.c
   gnucash/trunk/src/engine/engine-helpers.c
   gnucash/trunk/src/engine/glib-helpers.c
   gnucash/trunk/src/engine/kvp-scm.c
   gnucash/trunk/src/gnome-utils/dialog-options.c
   gnucash/trunk/src/gnome/gnc-plugin-page-register.c
   gnucash/trunk/src/gnome/gnc-plugin-page-register2.c
   gnucash/trunk/src/import-export/qif-import/assistant-qif-import.c
   gnucash/trunk/src/import-export/qif-import/dialog-account-picker.c
   gnucash/trunk/src/report/report-gnome/dialog-report-style-sheet.c
   gnucash/trunk/src/report/report-gnome/gnc-plugin-page-report.c
Log:
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.

Modified: gnucash/trunk/src/app-utils/gnc-helpers.c
===================================================================
--- gnucash/trunk/src/app-utils/gnc-helpers.c	2012-12-15 17:58:58 UTC (rev 22652)
+++ gnucash/trunk/src/app-utils/gnc-helpers.c	2012-12-15 17:59:14 UTC (rev 22653)
@@ -125,11 +125,11 @@
                                       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;
 }

Modified: gnucash/trunk/src/app-utils/guile-util.c
===================================================================
--- gnucash/trunk/src/app-utils/guile-util.c	2012-12-15 17:58:58 UTC (rev 22652)
+++ gnucash/trunk/src/app-utils/guile-util.c	2012-12-15 17:59:14 UTC (rev 22653)
@@ -508,7 +508,7 @@
     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 @@
     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 @@
     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 @@
 
         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 @@
     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 @@
     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 @@
     if (notes == NULL)
         return;
 
-    arg = scm_makfrom0str(notes);
+    arg = scm_from_locale_string(notes);
 
     scm_call_2(setters.trans_scm_notes, trans_scm, arg);
 }

Modified: gnucash/trunk/src/app-utils/option-util.c
===================================================================
--- gnucash/trunk/src/app-utils/option-util.c	2012-12-15 17:58:58 UTC (rev 22652)
+++ gnucash/trunk/src/app-utils/option-util.c	2012-12-15 17:59:14 UTC (rev 22653)
@@ -472,7 +472,7 @@
     }
     else
     {
-        arg = scm_makfrom0str(name);
+        arg = scm_from_locale_string(name);
     }
     args = scm_cons(arg, args);
 
@@ -483,7 +483,7 @@
     }
     else
     {
-        arg = scm_makfrom0str(section);
+        arg = scm_from_locale_string(section);
     }
     args = scm_cons(arg, args);
 

Modified: gnucash/trunk/src/app-utils/test/test-print-queries.c
===================================================================
--- gnucash/trunk/src/app-utils/test/test-print-queries.c	2012-12-15 17:58:58 UTC (rev 22652)
+++ gnucash/trunk/src/app-utils/test/test-print-queries.c	2012-12-15 17:59:14 UTC (rev 22653)
@@ -23,7 +23,7 @@
     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);

Modified: gnucash/trunk/src/app-utils/test/test-scm-query-string.c
===================================================================
--- gnucash/trunk/src/app-utils/test/test-scm-query-string.c	2012-12-15 17:58:58 UTC (rev 22652)
+++ gnucash/trunk/src/app-utils/test/test-scm-query-string.c	2012-12-15 17:59:14 UTC (rev 22653)
@@ -27,7 +27,7 @@
     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);

Modified: gnucash/trunk/src/base-typemaps.i
===================================================================
--- gnucash/trunk/src/base-typemaps.i	2012-12-15 17:58:58 UTC (rev 22652)
+++ gnucash/trunk/src/base-typemaps.i	2012-12-15 17:59:14 UTC (rev 22653)
@@ -17,8 +17,10 @@
 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);
   }
 }

Modified: gnucash/trunk/src/business/business-gnome/gnc-plugin-page-owner-tree.c
===================================================================
--- gnucash/trunk/src/business/business-gnome/gnc-plugin-page-owner-tree.c	2012-12-15 17:58:58 UTC (rev 22652)
+++ gnucash/trunk/src/business/business-gnome/gnc-plugin-page-owner-tree.c	2012-12-15 17:59:14 UTC (rev 22653)
@@ -925,7 +925,7 @@
     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

Modified: gnucash/trunk/src/engine/engine-helpers.c
===================================================================
--- gnucash/trunk/src/engine/engine-helpers.c	2012-12-15 17:58:58 UTC (rev 22652)
+++ gnucash/trunk/src/engine/engine-helpers.c	2012-12-15 17:59:14 UTC (rev 22653)
@@ -122,7 +122,7 @@
     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 @@
         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 @@
     SCM value_scm = SCM_EOL;
     KvpValueType value_t;
     SCM scm;
+    const gchar *string;
 
     if (!value) return SCM_BOOL_F;
 
@@ -569,7 +570,8 @@
         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 @@
     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 @@
 
         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 @@
         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))

Modified: gnucash/trunk/src/engine/glib-helpers.c
===================================================================
--- gnucash/trunk/src/engine/glib-helpers.c	2012-12-15 17:58:58 UTC (rev 22652)
+++ gnucash/trunk/src/engine/glib-helpers.c	2012-12-15 17:59:14 UTC (rev 22653)
@@ -99,7 +99,12 @@
     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);
 }

Modified: gnucash/trunk/src/engine/kvp-scm.c
===================================================================
--- gnucash/trunk/src/engine/kvp-scm.c	2012-12-15 17:58:58 UTC (rev 22652)
+++ gnucash/trunk/src/engine/kvp-scm.c	2012-12-15 17:59:14 UTC (rev 22653)
@@ -71,6 +71,7 @@
 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 @@
         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:
     {

Modified: gnucash/trunk/src/gnome/gnc-plugin-page-register.c
===================================================================
--- gnucash/trunk/src/gnome/gnc-plugin-page-register.c	2012-12-15 17:58:58 UTC (rev 22652)
+++ gnucash/trunk/src/gnome/gnc-plugin-page-register.c	2012-12-15 17:59:14 UTC (rev 22653)
@@ -2341,6 +2341,7 @@
     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 @@
     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);
 

Modified: gnucash/trunk/src/gnome/gnc-plugin-page-register2.c
===================================================================
--- gnucash/trunk/src/gnome/gnc-plugin-page-register2.c	2012-12-15 17:58:58 UTC (rev 22652)
+++ gnucash/trunk/src/gnome/gnc-plugin-page-register2.c	2012-12-15 17:59:14 UTC (rev 22653)
@@ -2403,6 +2403,7 @@
     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 @@
     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);
 

Modified: gnucash/trunk/src/gnome-utils/dialog-options.c
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-options.c	2012-12-15 17:58:58 UTC (rev 22652)
+++ gnucash/trunk/src/gnome-utils/dialog-options.c	2012-12-15 17:59:14 UTC (rev 22653)
@@ -2632,7 +2632,7 @@
     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 @@
     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 @@
     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 @@
 
     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;
 }

Modified: gnucash/trunk/src/import-export/qif-import/assistant-qif-import.c
===================================================================
--- gnucash/trunk/src/import-export/qif-import/assistant-qif-import.c	2012-12-15 17:58:58 UTC (rev 22652)
+++ gnucash/trunk/src/import-export/qif-import/assistant-qif-import.c	2012-12-15 17:59:14 UTC (rev 22653)
@@ -1555,7 +1555,7 @@
 
         /* 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_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 @@
     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 @@
                                  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);

Modified: gnucash/trunk/src/import-export/qif-import/dialog-account-picker.c
===================================================================
--- gnucash/trunk/src/import-export/qif-import/dialog-account-picker.c	2012-12-15 17:58:58 UTC (rev 22652)
+++ gnucash/trunk/src/import-export/qif-import/dialog-account-picker.c	2012-12-15 17:59:14 UTC (rev 22653)
@@ -249,7 +249,7 @@
         /* 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 @@
                            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
     {

Modified: gnucash/trunk/src/report/report-gnome/dialog-report-style-sheet.c
===================================================================
--- gnucash/trunk/src/report/report-gnome/dialog-report-style-sheet.c	2012-12-15 17:58:58 UTC (rev 22652)
+++ gnucash/trunk/src/report/report-gnome/dialog-report-style-sheet.c	2012-12-15 17:59:14 UTC (rev 22653)
@@ -243,8 +243,8 @@
         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));
         }
     }
 

Modified: gnucash/trunk/src/report/report-gnome/gnc-plugin-page-report.c
===================================================================
--- gnucash/trunk/src/report/report-gnome/gnc-plugin-page-report.c	2012-12-15 17:58:58 UTC (rev 22652)
+++ gnucash/trunk/src/report/report-gnome/gnc-plugin-page-report.c	2012-12-15 17:59:14 UTC (rev 22653)
@@ -1548,7 +1548,7 @@
         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);
 



More information about the gnucash-changes mailing list