]> diplodocus.org Git - nmh/blob - sbr/m_backup.c
Reverted commit 9a4b4a3d3b27fe4a7ff6d0b8724ce1c06b5917eb.
[nmh] / sbr / m_backup.c
1
2 /*
3 * m_backup.c -- construct a backup file
4 *
5 * This code is Copyright (c) 2002, by the authors of nmh. See the
6 * COPYRIGHT file in the root directory of the nmh distribution for
7 * complete copyright information.
8 */
9
10 #include <h/mh.h>
11
12
13 char *
14 m_backup (const char *file)
15 {
16 const char *cp;
17 static char buffer[BUFSIZ];
18
19 if ((cp = r1bindex((char *) file, '/')) == file)
20 snprintf(buffer, sizeof(buffer), "%s%s",
21 BACKUP_PREFIX, cp);
22 else
23 snprintf(buffer, sizeof(buffer), "%.*s%s%s", (int)(cp - file), file,
24 BACKUP_PREFIX, cp);
25
26 (void) m_unlink(buffer);
27 return buffer;
28 }