]> diplodocus.org Git - nmh/blob - sbr/m_backup.c
pending-release-notes: add mhshow's "-prefer", and mh-format's %(kibi/kilo)
[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 (char *file)
15 {
16 char *cp;
17 static char buffer[BUFSIZ];
18
19 if ((cp = r1bindex(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 }