3 string[] read_line(file f) {
4 string line = File::fgets(f);
6 return String::parse_csv(line);
10 print_line(file f, string[] bits) {
11 for (int i = 0; i < dim(bits); i++) {
12 string end = i == dim(bits) - 1 ? "\n" : ",";
13 printf ("%s%s", bits[i], end);
23 { .pattern = "RESISTOR", .count = 250 },
24 { .pattern = "CAPACITOR", .count = 100 },
25 { .pattern = "INDUCTOR", .count = 100 },
26 { .pattern = "LED", .count = 100 },
30 fix_em(string[] elts) {
31 for (int f = 0; f < dim(fixes); f++) {
32 if (String::index(elts[2], fixes[f].pattern) >= 0) {
33 elts[0] = sprintf ("%d", fixes[f].count);
42 while (!File::end(stdin)) {
43 string[] elts = read_line(stdin);
45 print_line(stdout, elts);