blob: eed8bd0d7e0c980e873199b419c746ce0e6efbcb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
/* { dg-additional-options "-mtune=pentium4" { target ia32 } } */
#include "tree-vect.h"
typedef unsigned char FcChar8;
typedef unsigned short FcChar16;
typedef unsigned int FcChar32;
typedef int FcBool;
#define FcFalse 0
#define FcTrue 1
#define FcDontCare 2
__attribute__((noipa))
static FcBool
FcLooksLikeSJIS (FcChar8 *string, int len)
{
int nhigh = 0, nlow = 0;
while (len-- > 0)
{
if (*string++ & 0x80) nhigh++;
else nlow++;
}
/*
* Heuristic -- if more than 1/3 of the bytes have the high-bit set,
* this is likely to be SJIS and not ROMAN
*/
if (nhigh * 2 > nlow)
return FcTrue;
return FcFalse;
}
int main()
{
check_vect ();
unsigned char* s = "DejaVuMathTeXGyre-Regulardtd!";
if (FcLooksLikeSJIS(s, 29))
abort ();
return 0;
}
|