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
#include <ctype.h>
#include <fcntl.h>
#include <unistd.h>

int main(int argc, char* argv) {
  char buf[16*1024];

  int fd = open("file", O_RDONLY);

  int got, i, ignore;
  goto read_in_space;

done_in_space:
  ignore = write(1, buf, got);
read_in_space:
  got = read(fd, buf, sizeof(buf));
  if (got == 0) return 0;
  i = 0;
in_space:
  if (!isspace(buf[i])) {
    buf[i] = toupper(buf[i]);
    goto advance_word;
  }
advance_space:
  ++i;
  if (i < got) {
    goto in_space;
  } else {
    goto done_in_space;
  }

done_in_word:
  ignore = write(1, buf, got);
  got = read(fd, buf, sizeof(buf));
  if (got == 0) return 0;
  i = 0;
in_word:
  if (isspace(buf[i])) {
    goto advance_space;
  }
advance_word:
  ++i;
  if (i < got)
    goto in_word;
  else
    goto done_in_word;
}