diff options
author | Denis Kenzior <denkenz@gmail.com> | 2009-09-17 12:18:48 -0500 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2009-09-17 12:18:48 -0500 |
commit | ef5eb6139ad094f5f16dbf29f172735a54b73320 (patch) | |
tree | 7ab05bf57425aafb7222e5d4fda92a7e4355291a /src | |
parent | ee33bc6ab73e396045b2f249242275564b89cc13 (diff) | |
download | ofono-ef5eb6139ad094f5f16dbf29f172735a54b73320.tar.bz2 |
Simplify function logic
Diffstat (limited to 'src')
-rw-r--r-- | src/sim.c | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -631,24 +631,24 @@ static void sim_efli_read_cb(int ok, /* Detect whether the file is in EFli format, as opposed to 51.011 EFlp */ static gboolean sim_efli_format(const unsigned char *ef, int length) { + int i; + if (length & 1) return FALSE; - while (length) { - if (ef[0] != ef[1] && (ef[0] == 0xff || ef[1] == 0xff)) - return FALSE; + for (i = 0; i < length; i += 2) { + if (ef[i] == 0xff && ef[i+1] == 0xff) + continue; /* ISO 639 country codes are each two lower-case SMS 7-bit * characters while CB DCS language codes are in ranges * (0 - 15) or (32 - 47), so the ranges don't overlap */ - if (ef[0] != 0xff && (ef[0] < 'a' || ef[0] > 'z')) - return FALSE; - if (ef[1] != 0xff && (ef[1] < 'a' || ef[1] > 'z')) + if (g_ascii_isalpha(ef[i]) == 0) return FALSE; - ef += 2; - length -= 2; + if (g_ascii_isalpha(ef[i+1]) == 0) + return FALSE; } return TRUE; |