mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Merge branch 'maint'
This commit is contained in:
@@ -428,7 +428,9 @@ gnc_get_current_root_account (void)
|
||||
gnc_commodity_table *
|
||||
gnc_get_current_commodities (void)
|
||||
{
|
||||
return gnc_commodity_table_get_table (gnc_get_current_book ());
|
||||
if (gnc_current_session_exist())
|
||||
return gnc_commodity_table_get_table (gnc_get_current_book ());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gchar *
|
||||
@@ -776,7 +778,8 @@ gnc_default_currency_common (gchar *requested_currency,
|
||||
GNC_COMMODITY_NS_CURRENCY,
|
||||
requested_currency);
|
||||
|
||||
if (gnc_prefs_get_bool (section, GNC_PREF_CURRENCY_CHOICE_OTHER))
|
||||
if (gnc_current_session_exist() &&
|
||||
gnc_prefs_get_bool (section, GNC_PREF_CURRENCY_CHOICE_OTHER))
|
||||
{
|
||||
mnemonic = gnc_prefs_get_string(section, GNC_PREF_CURRENCY_OTHER);
|
||||
currency = gnc_commodity_table_lookup(gnc_get_current_commodities(),
|
||||
@@ -788,11 +791,13 @@ gnc_default_currency_common (gchar *requested_currency,
|
||||
|
||||
if (!currency)
|
||||
currency = gnc_locale_default_currency ();
|
||||
|
||||
if (currency)
|
||||
{
|
||||
mnemonic = requested_currency;
|
||||
g_free(mnemonic);
|
||||
}
|
||||
|
||||
return currency;
|
||||
}
|
||||
|
||||
@@ -2198,7 +2203,7 @@ unichar_is_cntrl (gunichar uc)
|
||||
gchar *
|
||||
gnc_filter_text_for_control_chars (const gchar *text)
|
||||
{
|
||||
gchar *normal_text, *nt;
|
||||
const char *ch;
|
||||
GString *filtered;
|
||||
gboolean cntrl = FALSE;
|
||||
gboolean text_found = FALSE;
|
||||
@@ -2209,20 +2214,18 @@ gnc_filter_text_for_control_chars (const gchar *text)
|
||||
if (!g_utf8_validate (text, -1, NULL))
|
||||
return NULL;
|
||||
|
||||
normal_text = g_utf8_normalize (text, -1, G_NORMALIZE_ALL_COMPOSE);
|
||||
filtered = g_string_sized_new (strlen (text) + 1);
|
||||
|
||||
filtered = g_string_sized_new (strlen (normal_text) + 1);
|
||||
ch = text;
|
||||
|
||||
nt = normal_text;
|
||||
|
||||
while (*nt)
|
||||
while (*ch)
|
||||
{
|
||||
gunichar uc = g_utf8_get_char (nt);
|
||||
gunichar uc = g_utf8_get_char (ch);
|
||||
|
||||
// check for starting with control characters
|
||||
if (unichar_is_cntrl (uc) && !text_found)
|
||||
{
|
||||
nt = g_utf8_next_char (nt);
|
||||
ch = g_utf8_next_char (ch);
|
||||
continue;
|
||||
}
|
||||
// check for alpha, num and punctuation
|
||||
@@ -2235,18 +2238,17 @@ gnc_filter_text_for_control_chars (const gchar *text)
|
||||
if (unichar_is_cntrl (uc))
|
||||
cntrl = TRUE;
|
||||
|
||||
nt = g_utf8_next_char (nt);
|
||||
ch = g_utf8_next_char (ch);
|
||||
|
||||
if (cntrl) // if control characters in text replace with space
|
||||
{
|
||||
gunichar uc2 = g_utf8_get_char (nt);
|
||||
gunichar uc2 = g_utf8_get_char (ch);
|
||||
|
||||
if (!unichar_is_cntrl (uc2))
|
||||
filtered = g_string_append_unichar (filtered, ' ');
|
||||
}
|
||||
cntrl = FALSE;
|
||||
}
|
||||
g_free (normal_text);
|
||||
return g_string_free (filtered, FALSE);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user