/* backupfile.c -- make Emacs style backup file names
Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
/* backupfile.c -- make Emacs style backup file names
Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+ 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software
+ Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
of `digit' even when the host does not conform to POSIX. */
#define ISDIGIT(c) ((unsigned int) (c) - '0' <= 9)
of `digit' even when the host does not conform to POSIX. */
#define ISDIGIT(c) ((unsigned int) (c) - '0' <= 9)
size_t baselen = base_len (base);
size_t baselen_max = HAVE_LONG_FILE_NAMES ? 255 : NAME_MAX_MINIMUM;
size_t baselen = base_len (base);
size_t baselen_max = HAVE_LONG_FILE_NAMES ? 255 : NAME_MAX_MINIMUM;
/* Return the name of the new backup file for the existing file FILE,
allocated with malloc. Report an error and fail if out of memory.
/* Return the name of the new backup file for the existing file FILE,
allocated with malloc. Report an error and fail if out of memory.
size_t simple_backup_suffix_size = strlen (simple_backup_suffix) + 1;
size_t backup_suffix_size_guess = simple_backup_suffix_size;
enum { GUESS = sizeof ".~12345~" };
size_t simple_backup_suffix_size = strlen (simple_backup_suffix) + 1;
size_t backup_suffix_size_guess = simple_backup_suffix_size;
enum { GUESS = sizeof ".~12345~" };
backup_suffix_size_guess = GUESS;
ssize = filelen + backup_suffix_size_guess + 1;
s = xmalloc (ssize);
memcpy (s, file, filelen + 1);
backup_suffix_size_guess = GUESS;
ssize = filelen + backup_suffix_size_guess + 1;
s = xmalloc (ssize);
memcpy (s, file, filelen + 1);
if (backup_type != simple_backups)
switch (numbered_backup (&s, ssize, filelen))
{
if (backup_type != simple_backups)
switch (numbered_backup (&s, ssize, filelen))
{
/* Return the type of backup specified by VERSION.
If VERSION is NULL or the empty string, return numbered_existing_backups.
If VERSION is invalid or ambiguous, fail with a diagnostic appropriate
/* Return the type of backup specified by VERSION.
If VERSION is NULL or the empty string, return numbered_existing_backups.
If VERSION is invalid or ambiguous, fail with a diagnostic appropriate