Merge from mainline (167278:168000).
[official-gcc/graphite-test-results.git] / gcc / testsuite / gcc.dg / pr43402.c
blob82234c74a85789689c8969ba21906a35fc20552d
1 /* { dg-do run } */
2 /* { dg-options "-O1 -fno-inline" } */
3 extern void abort (void);
5 static int something;
7 static int * converterData[2]={
8 &something, &something,
9 };
11 static struct {
12 const char *name;
13 int type;
14 } const cnvNameType[] = {
15 { "bocu1", 1 },
16 { "utf7", 1 },
17 { "utf8", 1 }
21 const int * getAlgorithmicTypeFromName(const char *realName);
22 const int *
23 getAlgorithmicTypeFromName(const char *realName)
25 unsigned mid, start, limit;
26 unsigned lastMid;
27 int result;
28 start = 0;
29 limit = sizeof(cnvNameType)/sizeof(cnvNameType[0]);
30 mid = limit;
31 lastMid = 0xffffffff;
33 for (;;) {
34 mid = (start + limit) / 2;
35 if (lastMid == mid) { /* Have we moved? */
36 break; /* We haven't moved, and it wasn't found. */
38 lastMid = mid;
39 result = __builtin_strcmp(realName, cnvNameType[mid].name);
41 if (result < 0) {
42 limit = mid;
43 } else if (result > 0) {
44 start = mid;
45 } else {
46 return converterData[cnvNameType[mid].type];
50 return 0;
53 int main (void)
55 if (!getAlgorithmicTypeFromName ("utf8"))
56 abort ();
57 return 0;