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