From ef5eb6139ad094f5f16dbf29f172735a54b73320 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Thu, 17 Sep 2009 12:18:48 -0500 Subject: Simplify function logic --- src/sim.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/sim.c b/src/sim.c index 70742c93..6ff76d2f 100644 --- a/src/sim.c +++ b/src/sim.c @@ -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; -- cgit v1.2.3