annotate src/libguess/arabic_impl.c @ 4862:7ec3621a9f9b

We only need the results of the stat once, do not bother with a variable at all. From code analysis, unique ID uYRsrf.
author Tony Vroon <chainsaw@gentoo.org>
date Sun, 19 Apr 2009 23:26:48 +0100
parents 6bcfc6561711
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3206
6bcfc6561711 Implement support for Arabic and Turkish.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
1 #include "libguess.h"
6bcfc6561711 Implement support for Arabic and Turkish.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
2
6bcfc6561711 Implement support for Arabic and Turkish.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
3 static const char *_guess_ar(const unsigned char *ptr, int size)
6bcfc6561711 Implement support for Arabic and Turkish.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
4 {
6bcfc6561711 Implement support for Arabic and Turkish.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
5 int i;
6bcfc6561711 Implement support for Arabic and Turkish.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
6
6bcfc6561711 Implement support for Arabic and Turkish.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
7 for (i = 0; i < size; i++)
6bcfc6561711 Implement support for Arabic and Turkish.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
8 {
6bcfc6561711 Implement support for Arabic and Turkish.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
9 if ((ptr[i] >= 0x80 && ptr[i] <= 0x9F) ||
6bcfc6561711 Implement support for Arabic and Turkish.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
10 ptr[i] == 0xA1 || ptr[i] == 0xA2 || ptr[i] == 0xA3 ||
6bcfc6561711 Implement support for Arabic and Turkish.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
11 (ptr[i] >= 0xA5 && ptr[i] <= 0xAB) ||
6bcfc6561711 Implement support for Arabic and Turkish.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
12 (ptr[i] >= 0xAE && ptr[i] <= 0xBA) ||
6bcfc6561711 Implement support for Arabic and Turkish.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
13 ptr[i] == 0xBC || ptr[i] == 0xBD ||
6bcfc6561711 Implement support for Arabic and Turkish.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
14 ptr[i] == 0xBE || ptr[i] == 0xC0 ||
6bcfc6561711 Implement support for Arabic and Turkish.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
15 (ptr[i] >= 0xDB && ptr[i] <= 0xDF) || (ptr[i] >= 0xF3))
6bcfc6561711 Implement support for Arabic and Turkish.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
16 return "CP1256";
6bcfc6561711 Implement support for Arabic and Turkish.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
17 }
6bcfc6561711 Implement support for Arabic and Turkish.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
18
6bcfc6561711 Implement support for Arabic and Turkish.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
19 return "ISO-8859-6";
6bcfc6561711 Implement support for Arabic and Turkish.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
20 }
6bcfc6561711 Implement support for Arabic and Turkish.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
21
6bcfc6561711 Implement support for Arabic and Turkish.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
22 const char *guess_ar(const char *ptr, int size)
6bcfc6561711 Implement support for Arabic and Turkish.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
23 {
6bcfc6561711 Implement support for Arabic and Turkish.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
24 if (dfa_validate_utf8(ptr, size))
6bcfc6561711 Implement support for Arabic and Turkish.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
25 return "UTF-8";
6bcfc6561711 Implement support for Arabic and Turkish.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
26
6bcfc6561711 Implement support for Arabic and Turkish.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
27 return _guess_ar((const unsigned char *)ptr, size);
6bcfc6561711 Implement support for Arabic and Turkish.
William Pitcock <nenolod@atheme-project.org>
parents:
diff changeset
28 }