libgfortran/ChangeLog:
[official-gcc.git] / gcc / testsuite / gcc.dg / pr43402.c
blobe6ef2d7d54d287306438affe14741e4f1b4e7277
1 /* { dg-do run } */
2 /* { dg-options "-O1 -fno-inline" } */
3 /* { dg-require-effective-target int32plus } */
5 extern void abort (void);
7 static int something;
9 static int * converterData[2]={
10 &something, &something,
13 static struct {
14 const char *name;
15 int type;
16 } const cnvNameType[] = {
17 { "bocu1", 1 },
18 { "utf7", 1 },
19 { "utf8", 1 }
23 const int * getAlgorithmicTypeFromName(const char *realName);
24 const int *
25 getAlgorithmicTypeFromName(const char *realName)
27 unsigned mid, start, limit;
28 unsigned lastMid;
29 int result;
30 start = 0;
31 limit = sizeof(cnvNameType)/sizeof(cnvNameType[0]);
32 mid = limit;
33 lastMid = 0xffffffff;
35 for (;;) {
36 mid = (start + limit) / 2;
37 if (lastMid == mid) { /* Have we moved? */
38 break; /* We haven't moved, and it wasn't found. */
40 lastMid = mid;
41 result = __builtin_strcmp(realName, cnvNameType[mid].name);
43 if (result < 0) {
44 limit = mid;
45 } else if (result > 0) {
46 start = mid;
47 } else {
48 return converterData[cnvNameType[mid].type];
52 return 0;
55 int main (void)
57 if (!getAlgorithmicTypeFromName ("utf8"))
58 abort ();
59 return 0;