RISC-V: Support IMM for operand 0 of ussub pattern
[official-gcc.git] / gcc / testsuite / gdc.test / runnable / wc2.d
blob97fcdeef62135af62680da758451d5eff5810e73
1 // RUNNABLE_PHOBOS_TEST
2 // PERMUTE_ARGS:
3 // EXECUTE_ARGS: runnable/wc2.d
5 import std.file;
7 extern(C) int printf(const char*, ...);
9 int main (string[] args)
11 int w_total;
12 int l_total;
13 int c_total;
14 int[string] dictionary;
16 printf(" lines words bytes file\n");
17 foreach (string arg; args[1 .. args.length])
19 string input;
20 int w_cnt, l_cnt, c_cnt;
21 int inword;
22 int wstart;
24 input = cast(string)std.file.read(arg);
26 for (int j = 0; j < input.length; j++)
27 { char c;
29 c = input[j];
30 if (c == '\n')
31 ++l_cnt;
32 if (c >= '0' && c <= '9')
35 else if (c >= 'a' && c <= 'z' ||
36 c >= 'A' && c <= 'Z')
38 if (!inword)
40 wstart = j;
41 inword = 1;
42 ++w_cnt;
45 else if (inword)
46 { string word = input[wstart .. j];
48 dictionary[word]++;
49 inword = 0;
51 ++c_cnt;
53 if (inword)
54 { string w = input[wstart .. input.length];
55 dictionary[w]++;
57 printf("%8u%8u%8u %.*s\n", l_cnt, w_cnt, c_cnt, cast(int)arg.length, arg.ptr);
58 l_total += l_cnt;
59 w_total += w_cnt;
60 c_total += c_cnt;
63 if (args.length > 2)
65 printf("--------------------------------------\n%8u%8u%8u total",
66 l_total, w_total, c_total);
69 printf("--------------------------------------\n");
70 foreach (string word1; dictionary.keys)
72 printf("%3d %.*s\n", dictionary[word1], cast(int)word1.length, word1.ptr);
74 return 0;