blob: 83d0afa1ce3228673b442d90ddc2333cce5b5c93 (
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
/** bug-3730.c : An issue in handling of parameter offsets for z80-ports when using --fomit-frame-pointer.
*/
#include <testfwk.h>
#pragma disable_warning 85
#include <stdarg.h>
const char hexTable[] = "0123456789ABCDEF";
int my_putchar(int c)
{
static const char e[] = "31 32 33 (expected)\n" "31 32 33\n";
static int i;
ASSERT (c == e[i++]);
}
void print_hx4(unsigned char u)
{
u &= 0xf;
my_putchar(hexTable[u]);
}
void print_hx8(unsigned char u)
{
print_hx4(u >> 4);
print_hx4(u);
}
int myprintf(const char *fmt, ...)
{
char *s;
char c;
unsigned int u;
va_list arg;
va_start(arg, fmt);
while ((c = *fmt)) {
if (c == '%') {
++fmt;
for (;;) {
c = *fmt;
if (c < '0' || c > '9')
break;
++fmt;
}
switch (c) {
case 'x':
c = va_arg( arg, int);
print_hx8(c);
break;
default:
break;
}
} else {
my_putchar(c);
}
fmt++;
}
return 0;
}
void
testBug(void)
{
char a, b, c;
myprintf( "31 32 33 (expected)\n");
a = '1'; b = '2'; c = '3';
myprintf( "%x %x %x\n", a, b, c);
}
|