Deleted Added
full compact
main.c (205992) main.c (217133)
1/*-
2 * Copyright (c) 1992 Diomidis Spinellis.
3 * Copyright (c) 1992, 1993
4 * The Regents of the University of California. All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * Diomidis Spinellis of Imperial College, University of London.
8 *

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

27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1992 Diomidis Spinellis.
3 * Copyright (c) 1992, 1993
4 * The Regents of the University of California. All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * Diomidis Spinellis of Imperial College, University of London.
8 *

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

27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#include <sys/cdefs.h>
35__FBSDID("$FreeBSD: head/usr.bin/sed/main.c 205992 2010-03-31 17:40:13Z imp $");
35__FBSDID("$FreeBSD: head/usr.bin/sed/main.c 217133 2011-01-08 00:03:18Z jilles $");
36
37#ifndef lint
38static const char copyright[] =
39"@(#) Copyright (c) 1992, 1993\n\
40 The Regents of the University of California. All rights reserved.\n";
41#endif
42
43#ifndef lint

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

333 /* If we are here then either eof or no files are open yet */
334 if (infile == stdin) {
335 sp->len = 0;
336 return (0);
337 }
338 if (infile != NULL) {
339 fclose(infile);
340 if (*oldfname != '\0') {
36
37#ifndef lint
38static const char copyright[] =
39"@(#) Copyright (c) 1992, 1993\n\
40 The Regents of the University of California. All rights reserved.\n";
41#endif
42
43#ifndef lint

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

333 /* If we are here then either eof or no files are open yet */
334 if (infile == stdin) {
335 sp->len = 0;
336 return (0);
337 }
338 if (infile != NULL) {
339 fclose(infile);
340 if (*oldfname != '\0') {
341 if (rename(fname, oldfname) != 0) {
341 /* if there was a backup file, remove it */
342 unlink(oldfname);
343 /*
344 * Backup the original. Note that hard links
345 * are not supported on all filesystems.
346 */
347 if ((link(fname, oldfname) != 0) &&
348 (rename(fname, oldfname) != 0)) {
342 warn("rename()");
349 warn("rename()");
343 unlink(tmpfname);
350 if (*tmpfname)
351 unlink(tmpfname);
344 exit(1);
345 }
346 *oldfname = '\0';
347 }
348 if (*tmpfname != '\0') {
349 if (outfile != NULL && outfile != stdout)
352 exit(1);
353 }
354 *oldfname = '\0';
355 }
356 if (*tmpfname != '\0') {
357 if (outfile != NULL && outfile != stdout)
350 fclose(outfile);
358 if (fclose(outfile) != 0) {
359 warn("fclose()");
360 unlink(tmpfname);
361 exit(1);
362 }
351 outfile = NULL;
363 outfile = NULL;
352 rename(tmpfname, fname);
364 if (rename(tmpfname, fname) != 0) {
365 /* this should not happen really! */
366 warn("rename()");
367 unlink(tmpfname);
368 exit(1);
369 }
353 *tmpfname = '\0';
354 }
355 outfname = NULL;
356 }
357 if (firstfile == 0)
358 files = files->next;
359 else
360 firstfile = 0;

--- 110 unchanged lines hidden ---
370 *tmpfname = '\0';
371 }
372 outfname = NULL;
373 }
374 if (firstfile == 0)
375 files = files->next;
376 else
377 firstfile = 0;

--- 110 unchanged lines hidden ---