Skip to content

Commit 95c2c36

Browse files
committed
Use glib-2.0 features when possible
1 parent 4944b3d commit 95c2c36

File tree

1 file changed

+4
-19
lines changed

1 file changed

+4
-19
lines changed

main/utils.c

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,32 +21,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
2121

2222
#include "./gridinit_internals.h"
2323

24-
#define STR_SKIP_SPACES(s) do {\
25-
register gchar c;\
26-
for (; (c = *s) && g_ascii_isspace(c) ;++s);\
27-
} while (0)
28-
29-
#define STR_TRIM_TRAILING_SPACES(s) do { \
30-
register gchar c, *end; \
31-
for (end = s; *end ;++end); \
32-
-- end; \
33-
for (; end > s && (c = *end) && g_ascii_isspace(c) ;--end) *end = '\0'; \
34-
} while (0)
35-
3624
gboolean
3725
gridinit_group_in_set(const gchar *group, const gchar *set)
3826
{
39-
gchar **tokens, **token, *g;
40-
41-
tokens = g_strsplit_set(set, ",", -1);
27+
gchar **tokens = g_strsplit_set(set, ",", -1);
4228
if (!tokens)
4329
return 0;
44-
for (token=tokens; (g = *token) ;token++) {
45-
STR_SKIP_SPACES(g);
46-
STR_TRIM_TRAILING_SPACES(g);
30+
for (gchar **ptoken=tokens; *ptoken ;ptoken++) {
31+
gchar *g = *ptoken;
4732
if (!*g)
4833
continue;
49-
if (0 == g_ascii_strcasecmp(g, group)) {
34+
if (0 == g_ascii_strcasecmp(g_strstrip(g), group)) {
5035
g_strfreev(tokens);
5136
return TRUE;
5237
}

0 commit comments

Comments
 (0)