cmp.c (f1bb2cd2aa7488657658fbc09aae2ead579049ab) cmp.c (c87180589e5ebca53e3ccd70798eb155ee1c40ef)
1/*
2 * Copyright (c) 1987, 1990, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 102 unchanged lines hidden (view full) ---

111 special = 1;
112 fd1 = 0;
113 file1 = "stdin";
114 }
115 else if ((fd1 = open(file1, O_RDONLY, 0)) < 0) {
116 if (!sflag)
117 err(ERR_EXIT, "%s", file1);
118 else
1/*
2 * Copyright (c) 1987, 1990, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 102 unchanged lines hidden (view full) ---

111 special = 1;
112 fd1 = 0;
113 file1 = "stdin";
114 }
115 else if ((fd1 = open(file1, O_RDONLY, 0)) < 0) {
116 if (!sflag)
117 err(ERR_EXIT, "%s", file1);
118 else
119 exit(1);
119 exit(ERR_EXIT);
120 }
121 if (strcmp(file2 = argv[1], "-") == 0) {
122 if (special)
123 errx(ERR_EXIT,
124 "standard input may only be specified once");
125 special = 1;
126 fd2 = 0;
127 file2 = "stdin";
128 }
129 else if ((fd2 = open(file2, O_RDONLY, 0)) < 0) {
130 if (!sflag)
131 err(ERR_EXIT, "%s", file2);
132 else
120 }
121 if (strcmp(file2 = argv[1], "-") == 0) {
122 if (special)
123 errx(ERR_EXIT,
124 "standard input may only be specified once");
125 special = 1;
126 fd2 = 0;
127 file2 = "stdin";
128 }
129 else if ((fd2 = open(file2, O_RDONLY, 0)) < 0) {
130 if (!sflag)
131 err(ERR_EXIT, "%s", file2);
132 else
133 exit(1);
133 exit(ERR_EXIT);
134 }
135
136 skip1 = argc > 2 ? strtol(argv[2], NULL, 0) : 0;
137 skip2 = argc == 4 ? strtol(argv[3], NULL, 0) : 0;
138
139 if (!special) {
140 if (fstat(fd1, &sb1)) {
141 if (!sflag)
142 err(ERR_EXIT, "%s", file1);
143 else
134 }
135
136 skip1 = argc > 2 ? strtol(argv[2], NULL, 0) : 0;
137 skip2 = argc == 4 ? strtol(argv[3], NULL, 0) : 0;
138
139 if (!special) {
140 if (fstat(fd1, &sb1)) {
141 if (!sflag)
142 err(ERR_EXIT, "%s", file1);
143 else
144 exit(1);
144 exit(ERR_EXIT);
145 }
146 if (!S_ISREG(sb1.st_mode))
147 special = 1;
148 else {
149 if (fstat(fd2, &sb2)) {
150 if (!sflag)
151 err(ERR_EXIT, "%s", file2);
152 else
145 }
146 if (!S_ISREG(sb1.st_mode))
147 special = 1;
148 else {
149 if (fstat(fd2, &sb2)) {
150 if (!sflag)
151 err(ERR_EXIT, "%s", file2);
152 else
153 exit(1);
153 exit(ERR_EXIT);
154 }
155 if (!S_ISREG(sb2.st_mode))
156 special = 1;
157 }
158 }
159
160 if (special)
161 c_special(fd1, file1, skip1, fd2, file2, skip2);

--- 21 unchanged lines hidden ---
154 }
155 if (!S_ISREG(sb2.st_mode))
156 special = 1;
157 }
158 }
159
160 if (special)
161 c_special(fd1, file1, skip1, fd2, file2, skip2);

--- 21 unchanged lines hidden ---