mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
avoid strlen where possible
if testing emptiness, test *str instead.
This commit is contained in:
parent
f30fcc2ac4
commit
d617129db8
@ -121,13 +121,13 @@ gnc_account_dom_tree_create (Account* act,
|
||||
}
|
||||
|
||||
str = xaccAccountGetCode (act);
|
||||
if (str && strlen (str) > 0)
|
||||
if (str && *str)
|
||||
{
|
||||
xmlAddChild (ret, text_to_dom_tree (act_code_string, str));
|
||||
}
|
||||
|
||||
str = xaccAccountGetDescription (act);
|
||||
if (str && strlen (str) > 0)
|
||||
if (str && *str)
|
||||
{
|
||||
xmlAddChild (ret, text_to_dom_tree (act_description_string, str));
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ const gchar* address_version_string = "2.0.0";
|
||||
static void
|
||||
maybe_add_string (xmlNodePtr ptr, const char* tag, const char* str)
|
||||
{
|
||||
if (str && strlen (str) > 0)
|
||||
if (str && *str)
|
||||
xmlAddChild (ptr, text_to_dom_tree (tag, str));
|
||||
}
|
||||
|
||||
|
@ -85,12 +85,10 @@ gnc_commodity_dom_tree_create (const gnc_commodity* com)
|
||||
gnc_commodity_get_fullname (com)));
|
||||
}
|
||||
|
||||
if (gnc_commodity_get_cusip (com) &&
|
||||
strlen (gnc_commodity_get_cusip (com)) > 0)
|
||||
const char* cusip = gnc_commodity_get_cusip (com);
|
||||
if (cusip && *cusip)
|
||||
{
|
||||
xmlAddChild (ret, text_to_dom_tree (
|
||||
cmdty_xcode,
|
||||
gnc_commodity_get_cusip (com)));
|
||||
xmlAddChild (ret, text_to_dom_tree (cmdty_xcode, cusip));
|
||||
}
|
||||
|
||||
xmlAddChild (ret, int_to_dom_tree (cmdty_fraction,
|
||||
|
@ -66,7 +66,7 @@ const gchar* employee_version_string = "2.0.0";
|
||||
static void
|
||||
maybe_add_string (xmlNodePtr ptr, const char* tag, const char* str)
|
||||
{
|
||||
if (str && strlen (str) > 0)
|
||||
if (str && *str)
|
||||
xmlAddChild (ptr, text_to_dom_tree (tag, str));
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ const gchar* entry_version_string = "2.0.0";
|
||||
static void
|
||||
maybe_add_string (xmlNodePtr ptr, const char* tag, const char* str)
|
||||
{
|
||||
if (str && strlen (str) > 0)
|
||||
if (str && *str)
|
||||
xmlAddChild (ptr, text_to_dom_tree (tag, str));
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ const gchar* invoice_version_string = "2.0.0";
|
||||
static void
|
||||
maybe_add_string (xmlNodePtr ptr, const char* tag, const char* str)
|
||||
{
|
||||
if (str && strlen (str) > 0)
|
||||
if (str && *str)
|
||||
xmlAddChild (ptr, text_to_dom_tree (tag, str));
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ const gchar* order_version_string = "2.0.0";
|
||||
static void
|
||||
maybe_add_string (xmlNodePtr ptr, const char* tag, const char* str)
|
||||
{
|
||||
if (str && strlen (str) > 0)
|
||||
if (str && *str)
|
||||
xmlAddChild (ptr, text_to_dom_tree (tag, str));
|
||||
}
|
||||
|
||||
|
@ -436,14 +436,14 @@ gnc_price_to_dom_tree (const xmlChar* tag, GNCPrice* price)
|
||||
if (!add_child_or_kill_parent (price_xml, tmpnode)) return NULL;
|
||||
|
||||
sourcestr = gnc_price_get_source_string (price);
|
||||
if (sourcestr && (strlen (sourcestr) != 0))
|
||||
if (sourcestr && *sourcestr)
|
||||
{
|
||||
tmpnode = text_to_dom_tree ("price:source", sourcestr);
|
||||
if (!add_child_or_kill_parent (price_xml, tmpnode)) return NULL;
|
||||
}
|
||||
|
||||
typestr = gnc_price_get_typestr (price);
|
||||
if (typestr && (strlen (typestr) != 0))
|
||||
if (typestr && *typestr)
|
||||
{
|
||||
tmpnode = text_to_dom_tree ("price:type", typestr);
|
||||
if (!add_child_or_kill_parent (price_xml, tmpnode)) return NULL;
|
||||
|
@ -775,7 +775,7 @@ GncXmlBackend::remove_old_files ()
|
||||
* juggling, but considering the above tests, this should always
|
||||
* be safe */
|
||||
regex_t pattern;
|
||||
gchar* stamp_start = name + strlen (m_fullpath.c_str());
|
||||
gchar* stamp_start = name + m_fullpath.size();
|
||||
gchar* expression = g_strdup_printf ("^\\.[[:digit:]]{14}(\\%s|\\%s|\\.xac)$",
|
||||
GNC_DATAFILE_EXT, GNC_LOGFILE_EXT);
|
||||
gboolean got_date_stamp = FALSE;
|
||||
|
@ -40,7 +40,7 @@ maybe_add_numeric (xmlNodePtr ptr, const char* tag, gnc_numeric val)
|
||||
static inline void
|
||||
maybe_add_string (xmlNodePtr ptr, const char* tag, const char* str)
|
||||
{
|
||||
if (str && strlen (str) > 0)
|
||||
if (str && *str)
|
||||
xmlAddChild (ptr, text_to_dom_tree (tag, str));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user