summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.c-torture/compile/950729-1.c
blob: cfdbad9206f5ba31e9c744b8ccee7d9a6dace143 (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
static const char * const lcset = "0123456789abcdef";
static const char * const ucset = "0123456789ABCDEF";

char *
f (char *buffer, long long value, char type)
{
  int base, i;

  i = 128  - 1;
  buffer[i--] = '\0';

  switch (type)
    {
    case 'u':
    case 'o':
    case 'x':
    case 'X':
      if (type == 'u')
	base = 10;
      else if (type == 'o')
	base = 8;
      else
	base = 16;

      while (i >= 0)
	{
	  if (type == 'X')
	    buffer[i--] = ucset[((unsigned long long) value) % base];
	  else
	    buffer[i--] = lcset[((unsigned long long) value) % base];

	  if ((value = ((unsigned long long) value) / base) == 0)
	    break;
	}
      break;
    }

  return &buffer[++i];
}