diff options
author | Mike Frysinger <vapier@gentoo.org> | 2005-05-12 22:50:12 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2005-05-12 22:50:12 +0000 |
commit | dad4cf7e6307b5b6032d928f0c897235b3e1042d (patch) | |
tree | 7e7366348fe8c8dab7eebad25cfdd1adad8ba460 | |
parent | b3a6ec3e623d120eee39bd003c8efdff85c0497a (diff) | |
download | busybox-w32-dad4cf7e6307b5b6032d928f0c897235b3e1042d.tar.gz busybox-w32-dad4cf7e6307b5b6032d928f0c897235b3e1042d.tar.bz2 busybox-w32-dad4cf7e6307b5b6032d928f0c897235b3e1042d.zip |
use a bunch of if statements since it is a few bytes smaller than a switch; also use bb_xfopen() instead of fopen() so comm doesnt segfault when given non-existant files :(
-rw-r--r-- | coreutils/comm.c | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/coreutils/comm.c b/coreutils/comm.c index 2354bac0b..b0384fe87 100644 --- a/coreutils/comm.c +++ b/coreutils/comm.c | |||
@@ -40,25 +40,21 @@ static int both; | |||
40 | /* writeline outputs the input given, appropriately aligned according to class */ | 40 | /* writeline outputs the input given, appropriately aligned according to class */ |
41 | static void writeline(char *line, int class) | 41 | static void writeline(char *line, int class) |
42 | { | 42 | { |
43 | switch (class) { | 43 | if (class == 1 && !only_file_1) |
44 | case 1: | 44 | return; |
45 | if (!only_file_1) | 45 | else if (class == 2) { |
46 | return; | 46 | if (!only_file_2) |
47 | break; | 47 | return; |
48 | case 2: | 48 | if (only_file_1) |
49 | if (!only_file_2) | 49 | putchar('\t'); |
50 | return; | 50 | } |
51 | if (only_file_1) | 51 | else if (class == 3) { |
52 | putchar('\t'); | 52 | if (!both) |
53 | break; | 53 | return; |
54 | case 3: | 54 | if (only_file_1) |
55 | if (!both) | 55 | putchar('\t'); |
56 | return; | 56 | if (only_file_2) |
57 | if (only_file_1) | 57 | putchar('\t'); |
58 | putchar('\t'); | ||
59 | if (only_file_2) | ||
60 | putchar('\t'); | ||
61 | break; | ||
62 | } | 58 | } |
63 | fputs(line, stdout); | 59 | fputs(line, stdout); |
64 | } | 60 | } |
@@ -71,7 +67,7 @@ static int cmp_files(char **infiles) | |||
71 | int i = 0; | 67 | int i = 0; |
72 | 68 | ||
73 | for (i = 0; i < 2; i++) { | 69 | for (i = 0; i < 2; i++) { |
74 | streams[i] = (strcmp(infiles[i], "=") == 0 ? stdin : fopen(infiles[i], "r")); | 70 | streams[i] = (strcmp(infiles[i], "=") == 0 ? stdin : bb_xfopen(infiles[i], "r")); |
75 | fgets(thisline[i], 100, streams[i]); | 71 | fgets(thisline[i], 100, streams[i]); |
76 | } | 72 | } |
77 | 73 | ||