summaryrefslogtreecommitdiff
path: root/usr.bin/patch
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2003-04-06 04:14:10 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2003-04-06 04:14:10 +0000
commit5b99ce8fbe8dca73e232164f7a5605e9e7312dd2 (patch)
tree3feb6b5874f66067614c45d979973a3d6f9ef953 /usr.bin/patch
parent8fea19bc2c0fc1c5cf2c6e45177ffd1ca7c92517 (diff)
another asprintf() simplifies things further
Diffstat (limited to 'usr.bin/patch')
-rw-r--r--usr.bin/patch/backupfile.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/usr.bin/patch/backupfile.c b/usr.bin/patch/backupfile.c
index f17839de4eb..58561058848 100644
--- a/usr.bin/patch/backupfile.c
+++ b/usr.bin/patch/backupfile.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: backupfile.c,v 1.8 2003/04/05 17:17:53 deraadt Exp $ */
+/* $OpenBSD: backupfile.c,v 1.9 2003/04/06 04:14:09 millert Exp $ */
/* backupfile.c -- make Emacs style backup file names
Copyright (C) 1990 Free Software Foundation, Inc.
@@ -14,7 +14,7 @@
Some algorithms adapted from GNU Emacs. */
#ifndef lint
-static char rcsid[] = "$OpenBSD: backupfile.c,v 1.8 2003/04/05 17:17:53 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: backupfile.c,v 1.9 2003/04/06 04:14:09 millert Exp $";
#endif /* not lint */
#include <stdio.h>
@@ -155,13 +155,9 @@ make_version_name (file, version)
int version;
{
char *backup_name;
- size_t len;
- len = strlen (file) + 16;
- backup_name = malloc (len);
- if (backup_name == 0)
+ if (asprintf (&backup_name, "%s.~%d~", file, version) == -1)
return 0;
- snprintf (backup_name, len, "%s.~%d~", file, version);
return backup_name;
}