| 1 |
#include <stdlib.h> |
| 2 |
#include <string.h> |
| 3 |
|
| 4 |
#define nul (char)0 |
| 5 |
struct m2string { |
| 6 |
char *contents; |
| 7 |
int HIGH; |
| 8 |
}; |
| 9 |
|
| 10 |
typedef struct m2string STRING; |
| 11 |
static inline int inline StrLen (STRING a) __attribute__ ((always_inline)); |
| 12 |
|
| 13 |
static STRING b; |
| 14 |
|
| 15 |
void init (void) |
| 16 |
{ |
| 17 |
b.contents = "hello"; |
| 18 |
b.HIGH = 4; |
| 19 |
|
| 20 |
if (StrLen(b) == 5) |
| 21 |
write(1, "works\n", 6); |
| 22 |
} |
| 23 |
|
| 24 |
static inline int StrLen (STRING a) |
| 25 |
{ |
| 26 |
int **T20; |
| 27 |
char *T24; |
| 28 |
#if 0 |
| 29 |
char *copy; |
| 30 |
int high, len; |
| 31 |
|
| 32 |
copy = alloca(a.HIGH+1); |
| 33 |
memcpy(a.contents, copy, a.HIGH+1); |
| 34 |
a.contents = copy; |
| 35 |
|
| 36 |
len = 0; |
| 37 |
high = a.HIGH; |
| 38 |
T25 = (char **)&a; |
| 39 |
**T25 = 'a'; |
| 40 |
#endif |
| 41 |
|
| 42 |
#if 0 |
| 43 |
/* (a.contents[len] != nul) */ |
| 44 |
while ((len <= high) && ((*T24)[len] != nul)) |
| 45 |
len++; |
| 46 |
|
| 47 |
return len; |
| 48 |
#endif |
| 49 |
(*(char **)&a)[0] = 'a'; |
| 50 |
|
| 51 |
T20 = &a; |
| 52 |
T24 = *T20; |
| 53 |
*T24 = 'a'; |
| 54 |
return 5; |
| 55 |
} |
| 56 |
|