View | Details | Raw Unified | Return to bug 243975
Collapse All | Expand All

(-)diff.c (-1 / +27 lines)
Lines 100-105 Link Here
100
};
100
};
101
101
102
void usage(void) __dead2;
102
void usage(void) __dead2;
103
void conflicting_format(void) __dead2;
103
void push_excludes(char *);
104
void push_excludes(char *);
104
void push_ignore_pats(char *);
105
void push_ignore_pats(char *);
105
void read_excludes_file(char *file);
106
void read_excludes_file(char *file);
Lines 141-146 Link Here
141
			break;
142
			break;
142
		case 'C':
143
		case 'C':
143
		case 'c':
144
		case 'c':
145
			if (diff_format != D_NORMAL)
146
				conflicting_format();
144
			cflag = 1;
147
			cflag = 1;
145
			diff_format = D_CONTEXT;
148
			diff_format = D_CONTEXT;
146
			if (optarg != NULL) {
149
			if (optarg != NULL) {
Lines 154-166 Link Here
154
			dflags |= D_MINIMAL;
157
			dflags |= D_MINIMAL;
155
			break;
158
			break;
156
		case 'D':
159
		case 'D':
160
			if (diff_format != D_NORMAL)
161
				conflicting_format();
157
			diff_format = D_IFDEF;
162
			diff_format = D_IFDEF;
158
			ifdefname = optarg;
163
			ifdefname = optarg;
159
			break;
164
			break;
160
		case 'e':
165
		case 'e':
166
			if (diff_format != D_NORMAL)
167
				conflicting_format();
161
			diff_format = D_EDIT;
168
			diff_format = D_EDIT;
162
			break;
169
			break;
163
		case 'f':
170
		case 'f':
171
			if (diff_format != D_NORMAL)
172
				conflicting_format();
164
			diff_format = D_REVERSE;
173
			diff_format = D_REVERSE;
165
			break;
174
			break;
166
		case 'H':
175
		case 'H':
Lines 193-202 Link Here
193
			Nflag = 1;
202
			Nflag = 1;
194
			break;
203
			break;
195
		case 'n':
204
		case 'n':
205
			if (diff_format != D_NORMAL)
206
				conflicting_format();
196
			diff_format = D_NREVERSE;
207
			diff_format = D_NREVERSE;
197
			break;
208
			break;
198
		case 'p':
209
		case 'p':
199
			if (diff_format == 0)
210
			if (diff_format == D_NORMAL)
200
				diff_format = D_CONTEXT;
211
				diff_format = D_CONTEXT;
201
			dflags |= D_PROTOTYPE;
212
			dflags |= D_PROTOTYPE;
202
			break;
213
			break;
Lines 207-212 Link Here
207
			rflag = 1;
218
			rflag = 1;
208
			break;
219
			break;
209
		case 'q':
220
		case 'q':
221
			if (diff_format != D_NORMAL)
222
				conflicting_format();
210
			diff_format = D_BRIEF;
223
			diff_format = D_BRIEF;
211
			break;
224
			break;
212
		case 'S':
225
		case 'S':
Lines 223-228 Link Here
223
			break;
236
			break;
224
		case 'U':
237
		case 'U':
225
		case 'u':
238
		case 'u':
239
			if (diff_format != D_NORMAL)
240
				conflicting_format();
226
			diff_format = D_UNIFIED;
241
			diff_format = D_UNIFIED;
227
			if (optarg != NULL) {
242
			if (optarg != NULL) {
228
				l = strtol(optarg, &ep, 10);
243
				l = strtol(optarg, &ep, 10);
Lines 249-257 Link Here
249
			push_excludes(optarg);
264
			push_excludes(optarg);
250
			break;
265
			break;
251
		case 'y':
266
		case 'y':
267
			if (diff_format != D_NORMAL)
268
				conflicting_format();
252
			diff_format = D_SIDEBYSIDE;
269
			diff_format = D_SIDEBYSIDE;
253
			break;
270
			break;
254
		case OPT_CHANGED_GROUP_FORMAT:
271
		case OPT_CHANGED_GROUP_FORMAT:
272
			if (diff_format != D_NORMAL)
273
				conflicting_format();
255
			diff_format = D_GFORMAT;
274
			diff_format = D_GFORMAT;
256
			group_format = optarg;
275
			group_format = optarg;
257
			break;
276
			break;
Lines 491-493 Link Here
491
510
492
	exit(2);
511
	exit(2);
493
}
512
}
513
514
void
515
conflicting_format(void)
516
{
517
	fprintf(stderr, "error: conflicting output format options.\n");
518
	usage();
519
}
(-)tests/diff_test.sh (-2 / +14 lines)
Lines 11-16 Link Here
11
atf_test_case b230049
11
atf_test_case b230049
12
atf_test_case Bflag
12
atf_test_case Bflag
13
atf_test_case tabsize
13
atf_test_case tabsize
14
atf_test_case conflicting_format
14
15
15
simple_body()
16
simple_body()
16
{
17
{
Lines 49-56 Link Here
49
{
50
{
50
	atf_check -o file:$(atf_get_srcdir)/unified_p.out -s eq:1 \
51
	atf_check -o file:$(atf_get_srcdir)/unified_p.out -s eq:1 \
51
		diff -up -L input_c1.in -L input_c2.in  "$(atf_get_srcdir)/input_c1.in" "$(atf_get_srcdir)/input_c2.in"
52
		diff -up -L input_c1.in -L input_c2.in  "$(atf_get_srcdir)/input_c1.in" "$(atf_get_srcdir)/input_c2.in"
52
	atf_check -o file:$(atf_get_srcdir)/unified_c9999.out -s eq:1 \
53
		diff -u -c9999 -L input_c1.in -L input_c2.in "$(atf_get_srcdir)/input_c1.in" "$(atf_get_srcdir)/input_c2.in"
54
	atf_check -o file:$(atf_get_srcdir)/unified_9999.out -s eq:1 \
53
	atf_check -o file:$(atf_get_srcdir)/unified_9999.out -s eq:1 \
55
		diff -u9999 -L input_c1.in -L input_c2.in "$(atf_get_srcdir)/input_c1.in" "$(atf_get_srcdir)/input_c2.in"
54
		diff -u9999 -L input_c1.in -L input_c2.in "$(atf_get_srcdir)/input_c1.in" "$(atf_get_srcdir)/input_c2.in"
56
}
55
}
Lines 175-180 Link Here
175
	    diff -t --tabsize 1 A B
174
	    diff -t --tabsize 1 A B
176
}
175
}
177
176
177
conflicting_format_body()
178
{
179
	printf "\tA\n" > A
180
	printf "\tB\n" > B
181
	
182
	atf_check -s exit:2 -e ignore diff -c -u A B 
183
	atf_check -s exit:2 -e ignore diff -e -f A B 
184
	atf_check -s exit:2 -e ignore diff -y -q A B 
185
	atf_check -s exit:2 -e ignore diff -q -u A B 
186
	atf_check -s exit:2 -e ignore diff -q -c A B 
187
}
188
178
atf_init_test_cases()
189
atf_init_test_cases()
179
{
190
{
180
	atf_add_test_case simple
191
	atf_add_test_case simple
Lines 188-191 Link Here
188
	atf_add_test_case b230049
199
	atf_add_test_case b230049
189
	atf_add_test_case Bflag
200
	atf_add_test_case Bflag
190
	atf_add_test_case tabsize
201
	atf_add_test_case tabsize
202
	atf_add_test_case conflicting_format 
191
}
203
}

Return to bug 243975