[Xfce4-commits] <libxfce4util:master> Use some macros and drop unneeded strlen's.
Nick Schermer
noreply at xfce.org
Thu Jan 26 21:44:03 CET 2012
Updating branch refs/heads/master
to e4300b75ae7ff06488241b7bc5c57ce9d9e45093 (commit)
from eef2d3ee83ae11fbaac75f7c0951c40a450d7624 (commit)
commit e4300b75ae7ff06488241b7bc5c57ce9d9e45093
Author: Nick Schermer <nick at xfce.org>
Date: Thu Jan 26 21:40:19 2012 +0100
Use some macros and drop unneeded strlen's.
libxfce4util/xfce-fileutils.c | 6 +++---
libxfce4util/xfce-i18n.c | 2 +-
libxfce4util/xfce-rc-config.c | 5 ++---
libxfce4util/xfce-resource.c | 16 ++++++++--------
4 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/libxfce4util/xfce-fileutils.c b/libxfce4util/xfce-fileutils.c
index 8659860..51d5cb6 100644
--- a/libxfce4util/xfce-fileutils.c
+++ b/libxfce4util/xfce-fileutils.c
@@ -81,14 +81,14 @@ xfce_mkdirhier (const gchar *whole_path,
oumask = 0;
retval = TRUE;
- if (p[0] == '/') /* Skip leading '/'. */
+ if (p[0] == G_DIR_SEPARATOR) /* Skip leading '/'. */
++p;
for (first = 1, last = 0; !last ; ++p)
{
if (p[0] == '\0')
last = 1;
- else if (p[0] != '/')
+ else if (p[0] != G_DIR_SEPARATOR)
continue;
else if (p[1] == '\0')
last = 1;
@@ -137,7 +137,7 @@ xfce_mkdirhier (const gchar *whole_path,
}
if (!last)
- *p = '/';
+ *p = G_DIR_SEPARATOR;
}
if (!first && !last)
diff --git a/libxfce4util/xfce-i18n.c b/libxfce4util/xfce-i18n.c
index 9c7f6d6..83468c1 100644
--- a/libxfce4util/xfce-i18n.c
+++ b/libxfce4util/xfce-i18n.c
@@ -95,7 +95,7 @@ xfce_localize_path_internal (gchar *buffer,
if (G_UNLIKELY (lang == NULL))
lang = getenv ("LANG");
- if (G_LIKELY (lang != NULL && strchr (path, '/') != NULL))
+ if (G_LIKELY (lang != NULL && strchr (path, G_DIR_SEPARATOR) != NULL))
{
/* ok, we will try four things here
* - full locale name: ll_LL at qualifier.encoding
diff --git a/libxfce4util/xfce-rc-config.c b/libxfce4util/xfce-rc-config.c
index 01a2eb9..fe41801 100644
--- a/libxfce4util/xfce-rc-config.c
+++ b/libxfce4util/xfce-rc-config.c
@@ -119,9 +119,8 @@ _xfce_rc_config_new (XfceResourceType type,
gchar **paths;
gchar **p;
- g_return_val_if_fail (resource != NULL, NULL);
- g_return_val_if_fail (strlen (resource) > 0, NULL);
- g_return_val_if_fail (resource[strlen (resource) - 1] != '/', NULL);
+ g_return_val_if_fail (resource != NULL && *resource != '\0', NULL);
+ g_return_val_if_fail (resource[strlen (resource) - 1] != G_DIR_SEPARATOR, NULL);
user = xfce_resource_save_location (type, resource, FALSE);
paths = xfce_resource_lookup_all (type, resource);
diff --git a/libxfce4util/xfce-resource.c b/libxfce4util/xfce-resource.c
index 699790a..8116b6b 100644
--- a/libxfce4util/xfce-resource.c
+++ b/libxfce4util/xfce-resource.c
@@ -143,7 +143,7 @@ _res_remove_trailing_slashes (GList *list)
if (len <= 0)
{
/* A string with slashes only => root directory */
- ll = g_list_append (ll, g_strdup ("/"));
+ ll = g_list_append (ll, g_strdup (G_DIR_SEPARATOR_S));
g_free (lp->data);
}
else if (len < strlen (path))
@@ -287,10 +287,10 @@ _res_splitup_pattern (const gchar *pattern,
{
const gchar *p;
- if (*pattern == '\0' || *pattern == '/')
+ if (*pattern == '\0' || *pattern == G_DIR_SEPARATOR)
return FALSE;
- p = strchr (pattern, '/');
+ p = strchr (pattern, G_DIR_SEPARATOR);
if (p == NULL || *(p + 1) == '\0')
{
@@ -340,7 +340,7 @@ _res_match_path (const gchar *path,
{
guint end = strlen (pattern_this) - 1;
- if (pattern_this[end] == '/')
+ if (pattern_this[end] == G_DIR_SEPARATOR)
{
file_test = G_FILE_TEST_IS_DIR;
pattern_this[end] = '\0';
@@ -363,7 +363,7 @@ _res_match_path (const gchar *path,
{
if (g_file_test (filename, G_FILE_TEST_IS_DIR))
{
- child_relpath = g_strconcat (relpath, entry, "/", NULL);
+ child_relpath = g_strconcat (relpath, entry, G_DIR_SEPARATOR_S, NULL);
list = _res_match_path (filename, child_relpath, pattern_child, list);
g_free (child_relpath);
}
@@ -372,7 +372,7 @@ _res_match_path (const gchar *path,
{
if (file_test == G_FILE_TEST_IS_DIR)
{
- entries = g_list_append (entries, g_strconcat (relpath, entry, "/", NULL));
+ entries = g_list_append (entries, g_strconcat (relpath, entry, G_DIR_SEPARATOR_S, NULL));
}
else
{
@@ -475,7 +475,7 @@ xfce_resource_lookup (XfceResourceType type,
GList *l;
g_return_val_if_fail (TYPE_VALID (type), NULL);
- g_return_val_if_fail (filename != NULL && strlen (filename) > 0, NULL);
+ g_return_val_if_fail (filename != NULL && *filename != '\0', NULL);
_res_init ();
@@ -529,7 +529,7 @@ xfce_resource_lookup_all (XfceResourceType type,
GList *l;
g_return_val_if_fail (TYPE_VALID (type), NULL);
- g_return_val_if_fail (filename != NULL && strlen (filename) > 0, NULL);
+ g_return_val_if_fail (filename != NULL && *filename != '\0', NULL);
_res_init ();
More information about the Xfce4-commits
mailing list