=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/patch/util.c,v retrieving revision 1.19 retrieving revision 1.20 diff -c -r1.19 -r1.20 *** src/usr.bin/patch/util.c 2003/07/28 16:13:53 1.19 --- src/usr.bin/patch/util.c 2003/07/28 18:35:36 1.20 *************** *** 1,7 **** ! /* $OpenBSD: util.c,v 1.19 2003/07/28 16:13:53 millert Exp $ */ #ifndef lint ! static const char rcsid[] = "$OpenBSD: util.c,v 1.19 2003/07/28 16:13:53 millert Exp $"; #endif /* not lint */ #include --- 1,7 ---- ! /* $OpenBSD: util.c,v 1.20 2003/07/28 18:35:36 otto Exp $ */ #ifndef lint ! static const char rcsid[] = "$OpenBSD: util.c,v 1.20 2003/07/28 18:35:36 otto Exp $"; #endif /* not lint */ #include *************** *** 14,25 **** #include #include #include #include #include - #include "EXTERN.h" #include "common.h" - #include "INTERN.h" #include "util.h" #include "backupfile.h" --- 14,24 ---- #include #include #include + #include #include #include #include "common.h" #include "util.h" #include "backupfile.h" *************** *** 27,35 **** /* Rename a file, copying it if necessary. */ int ! move_file(char *from, char *to) { ! int i, fromfd; /* to stdout? */ --- 26,35 ---- /* Rename a file, copying it if necessary. */ int ! move_file(const char *from, const char *to) { ! int fromfd; ! ssize_t i; /* to stdout? */ *************** *** 69,79 **** /* Backup the original file. */ int ! backup_file(char *orig) { ! char bakname[MAXPATHLEN], *s, *simplename; ! dev_t orig_device; ! ino_t orig_inode; if (backup_type == none || stat(orig, &filestat) != 0) return 0; /* nothing to do */ --- 69,80 ---- /* Backup the original file. */ int ! backup_file(const char *orig) { ! struct stat filestat; ! char bakname[MAXPATHLEN], *s, *simplename; ! dev_t orig_device; ! ino_t orig_inode; if (backup_type == none || stat(orig, &filestat) != 0) return 0; /* nothing to do */ *************** *** 128,136 **** * Copy a file. */ int ! copy_file(char *from, char *to) { ! int tofd, fromfd, i; tofd = open(to, O_CREAT|O_TRUNC|O_WRONLY, 0666); if (tofd < 0) --- 129,138 ---- * Copy a file. */ int ! copy_file(const char *from, const char *to) { ! int tofd, fromfd; ! ssize_t i; tofd = open(to, O_CREAT|O_TRUNC|O_WRONLY, 0666); if (tofd < 0) *************** *** 150,174 **** * Allocate a unique area for a string. */ char * ! savestr(char *s) { ! char *rv, *t; if (!s) s = "Oops"; ! t = s; ! while (*t++) ! ; ! rv = malloc((size_t) (t - s)); if (rv == NULL) { if (using_plan_a) out_of_mem = TRUE; else fatal("out of memory\n"); - } else { - t = rv; - while ((*t++ = *s++)) - ; } return rv; } --- 152,169 ---- * Allocate a unique area for a string. */ char * ! savestr(const char *s) { ! char *rv; if (!s) s = "Oops"; ! rv = strdup(s); if (rv == NULL) { if (using_plan_a) out_of_mem = TRUE; else fatal("out of memory\n"); } return rv; } *************** *** 177,183 **** * Vanilla terminal output (buffered). */ void ! say(char *fmt, ...) { va_list ap; --- 172,178 ---- * Vanilla terminal output (buffered). */ void ! say(const char *fmt, ...) { va_list ap; *************** *** 191,197 **** * Terminal output, pun intended. */ void ! fatal(char *fmt, ...) { va_list ap; --- 186,192 ---- * Terminal output, pun intended. */ void ! fatal(const char *fmt, ...) { va_list ap; *************** *** 206,212 **** * Say something from patch, something from the system, then silence . . . */ void ! pfatal(char *fmt, ...) { va_list ap; int errnum = errno; --- 201,207 ---- * Say something from patch, something from the system, then silence . . . */ void ! pfatal(const char *fmt, ...) { va_list ap; int errnum = errno; *************** *** 223,232 **** * Get a response from the user, somehow or other. */ void ! ask(char *fmt, ...) { va_list ap; ! int ttyfd, r; bool tty2 = isatty(2); va_start(ap, fmt); --- 218,228 ---- * Get a response from the user, somehow or other. */ void ! ask(const char *fmt, ...) { va_list ap; ! int ttyfd; ! ssize_t r; bool tty2 = isatty(2); va_start(ap, fmt); *************** *** 298,304 **** */ void ! makedirs(char *filename, bool striplast) { char *tmpbuf; --- 294,300 ---- */ void ! makedirs(const char *filename, bool striplast) { char *tmpbuf; *************** *** 323,334 **** * Make filenames more reasonable. */ char * ! fetchname(char *at, int strip_leading, int assume_exists) { ! char *fullname, *name, *t, tmpbuf[200]; ! int sleading = strip_leading; ! if (!at || *at == '\0') return NULL; while (isspace(*at)) at++; --- 319,331 ---- * Make filenames more reasonable. */ char * ! fetchname(const char *at, int strip_leading, int assume_exists) { ! char *fullname, *name, *t, tmpbuf[200]; ! int sleading = strip_leading; ! struct stat filestat; ! if (at == NULL || *at == '\0') return NULL; while (isspace(*at)) at++;