diff options
author | Will Thompson <will.thompson@collabora.co.uk> | 2009-05-27 23:13:51 +0100 |
---|---|---|
committer | Will Thompson <will.thompson@collabora.co.uk> | 2009-05-27 23:13:51 +0100 |
commit | a3fef5fc1860f8c20e1a8233c620a80495f5fb5e (patch) | |
tree | fe000932f6bc3ab793bf32d4dad38f72fe3f21e6 /src/idle-handles.c | |
parent | a522bed9acfef27e9a21e505e7b39b252a0426a1 (diff) | |
download | telepathy-idle-a3fef5fc1860f8c20e1a8233c620a80495f5fb5e.tar.gz |
Make nickname validation a for loop.
I think this is clearer; it makes the loop's conditions more obvious.
Diffstat (limited to 'src/idle-handles.c')
-rw-r--r-- | src/idle-handles.c | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/src/idle-handles.c b/src/idle-handles.c index 972a090..97c9a63 100644 --- a/src/idle-handles.c +++ b/src/idle-handles.c @@ -36,7 +36,7 @@ * to allow contribute to invalid nicks on IRC, but we want to be able to * handle them if another client allows people to use invalid nicks */ gboolean idle_nickname_is_valid(const gchar *nickname, gboolean strict_mode) { - const gchar *char_pos = nickname; + const gchar *char_pos; IDLE_DEBUG("Validating nickname '%s' with strict mode %d", nickname, strict_mode); @@ -44,8 +44,7 @@ gboolean idle_nickname_is_valid(const gchar *nickname, gboolean strict_mode) { if (!nickname || *nickname == '\0') return FALSE; - while (*char_pos) { - + for (char_pos = nickname; *char_pos; char_pos = g_utf8_find_next_char(char_pos, NULL)) { /* only used for non-strict checks */ gunichar ucs4char = g_utf8_get_char_validated(char_pos, -1); @@ -85,11 +84,6 @@ gboolean idle_nickname_is_valid(const gchar *nickname, gboolean strict_mode) { } break; } - - /* in strict mode, a multi-byte character would have already failed the - * test above, so the following line should be equivalent to ++char, but - * it doesn't seem worthwhile to special-case it */ - char_pos = g_utf8_find_next_char(char_pos, NULL); } return TRUE; |