@@ -3,6 +3,22 @@
33#include <stdlib.h>
44#include <string.h>
55
6+void lazytext(const char *name)
7+{
8+ UFILE *ufp = u_fopen(name, "r", NULL, "UTF-8");
9+ const size_t bufsize = sizeof(UChar) * 32 * 1024;
10+ UChar *str = malloc(bufsize);
11+ long len = 0;
12+ int32_t n;
13+
14+ do {
15+ n = u_file_read(str, bufsize, ufp);
16+ len += n;
17+ } while (n > 0);
18+
19+ printf("%ld\n", len);
20+}
21+
622void text(const char *name)
723{
824 UFILE *ufp = u_fopen(name, "r", NULL, "UTF-8");
@@ -29,7 +45,9 @@ int main(int argc, char **argv)
2945 exit(1);
3046 }
3147
32− if (strcmp(argv[1], "text") == 0)
48+ if (strcmp(argv[1], "lazytext") == 0)
49+ lazytext(argv[2]);
50+ else if (strcmp(argv[1], "text") == 0)
3351 text(argv[2]);
3452 else {
3553 fprintf(stderr, "no matching handler\n");