Deleted Added
full compact
util.c (281800) util.c (286795)
1/*-
2 * Copyright 1986, Larry Wall
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following condition is met:
6 * 1. Redistributions of source code must retain the above copyright notice,
7 * this condition and the following disclaimer.
8 *

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

19 * SUCH DAMAGE.
20 *
21 * patch - a program to apply diffs to original files
22 *
23 * -C option added in 1998, original code by Marc Espie, based on FreeBSD
24 * behaviour
25 *
26 * $OpenBSD: util.c,v 1.35 2010/07/24 01:10:12 ray Exp $
1/*-
2 * Copyright 1986, Larry Wall
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following condition is met:
6 * 1. Redistributions of source code must retain the above copyright notice,
7 * this condition and the following disclaimer.
8 *

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

19 * SUCH DAMAGE.
20 *
21 * patch - a program to apply diffs to original files
22 *
23 * -C option added in 1998, original code by Marc Espie, based on FreeBSD
24 * behaviour
25 *
26 * $OpenBSD: util.c,v 1.35 2010/07/24 01:10:12 ray Exp $
27 * $FreeBSD: head/usr.bin/patch/util.c 281800 2015-04-20 22:15:18Z pfg $
27 * $FreeBSD: head/usr.bin/patch/util.c 286795 2015-08-15 00:42:33Z delphij $
28 */
29
30#include <sys/stat.h>
31
32#include <ctype.h>
33#include <errno.h>
34#include <fcntl.h>
35#include <libgen.h>

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

394 }
395 name = savestr(name);
396 free(fullname);
397
398 *exists = stat(name, &filestat) == 0;
399 return name;
400}
401
28 */
29
30#include <sys/stat.h>
31
32#include <ctype.h>
33#include <errno.h>
34#include <fcntl.h>
35#include <libgen.h>

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

394 }
395 name = savestr(name);
396 free(fullname);
397
398 *exists = stat(name, &filestat) == 0;
399 return name;
400}
401
402/*
403 * Takes the name returned by fetchname and looks in RCS/SCCS directories
404 * for a checked in version.
405 */
406char *
407checked_in(char *file)
408{
409 char *filebase, *filedir, tmpbuf[PATH_MAX];
410 struct stat filestat;
411
412 filebase = basename(file);
413 filedir = dirname(file);
414
415#define try(f, a1, a2, a3) \
416(snprintf(tmpbuf, sizeof tmpbuf, f, a1, a2, a3), stat(tmpbuf, &filestat) == 0)
417
418 if (try("%s/RCS/%s%s", filedir, filebase, RCSSUFFIX) ||
419 try("%s/RCS/%s%s", filedir, filebase, "") ||
420 try("%s/%s%s", filedir, filebase, RCSSUFFIX) ||
421 try("%s/SCCS/%s%s", filedir, SCCSPREFIX, filebase) ||
422 try("%s/%s%s", filedir, SCCSPREFIX, filebase))
423 return file;
424
425 return NULL;
426}
427
428void
429version(void)
430{
402void
403version(void)
404{
431 printf("patch 2.0-12u10 FreeBSD\n");
405 printf("patch 2.0-12u11 FreeBSD\n");
432 my_exit(EXIT_SUCCESS);
433}
434
435/*
436 * Exit with cleanup.
437 */
438void
439my_exit(int status)
440{
441 unlink(TMPINNAME);
442 if (!toutkeep)
443 unlink(TMPOUTNAME);
444 if (!trejkeep)
445 unlink(TMPREJNAME);
446 unlink(TMPPATNAME);
447 exit(status);
448}
406 my_exit(EXIT_SUCCESS);
407}
408
409/*
410 * Exit with cleanup.
411 */
412void
413my_exit(int status)
414{
415 unlink(TMPINNAME);
416 if (!toutkeep)
417 unlink(TMPOUTNAME);
418 if (!trejkeep)
419 unlink(TMPREJNAME);
420 unlink(TMPPATNAME);
421 exit(status);
422}