util.c (276472) | util.c (281800) |
---|---|
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 276472 2014-12-31 16:30:33Z pfg $ | 27 * $FreeBSD: head/usr.bin/patch/util.c 281800 2015-04-20 22:15:18Z pfg $ |
28 */ 29 | 28 */ 29 |
30#include <sys/param.h> | |
31#include <sys/stat.h> 32 33#include <ctype.h> 34#include <errno.h> 35#include <fcntl.h> 36#include <libgen.h> | 30#include <sys/stat.h> 31 32#include <ctype.h> 33#include <errno.h> 34#include <fcntl.h> 35#include <libgen.h> |
36#include <limits.h> |
|
37#include <paths.h> 38#include <signal.h> 39#include <stdarg.h> 40#include <stdlib.h> 41#include <stdio.h> 42#include <string.h> 43#include <unistd.h> 44 --- 46 unchanged lines hidden (view full) --- 91} 92 93/* Backup the original file. */ 94 95int 96backup_file(const char *orig) 97{ 98 struct stat filestat; | 37#include <paths.h> 38#include <signal.h> 39#include <stdarg.h> 40#include <stdlib.h> 41#include <stdio.h> 42#include <string.h> 43#include <unistd.h> 44 --- 46 unchanged lines hidden (view full) --- 91} 92 93/* Backup the original file. */ 94 95int 96backup_file(const char *orig) 97{ 98 struct stat filestat; |
99 char bakname[MAXPATHLEN], *s, *simplename; | 99 char bakname[PATH_MAX], *s, *simplename; |
100 dev_t orig_device; 101 ino_t orig_inode; 102 103 if (backup_type == none || stat(orig, &filestat) != 0) 104 return 0; /* nothing to do */ 105 /* 106 * If the user used zero prefixes or suffixes, then 107 * he doesn't want backups. Yet we have to remove --- 293 unchanged lines hidden (view full) --- 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{ | 100 dev_t orig_device; 101 ino_t orig_inode; 102 103 if (backup_type == none || stat(orig, &filestat) != 0) 104 return 0; /* nothing to do */ 105 /* 106 * If the user used zero prefixes or suffixes, then 107 * he doesn't want backups. Yet we have to remove --- 293 unchanged lines hidden (view full) --- 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[MAXPATHLEN]; | 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 --- 31 unchanged lines hidden --- | 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 --- 31 unchanged lines hidden --- |