version 1.9, 2003/04/06 04:14:09 |
version 1.10, 2003/07/18 02:00:09 |
|
|
#define ISDIGIT(c) (isascii (c) && isdigit (c)) |
#define ISDIGIT(c) (isascii (c) && isdigit (c)) |
#endif |
#endif |
|
|
#if defined (HAVE_UNISTD_H) |
|
#include <unistd.h> |
#include <unistd.h> |
#endif |
|
|
|
#if defined (_POSIX_VERSION) |
#if defined (_POSIX_VERSION) |
/* POSIX does not require that the d_ino field be present, and some |
/* POSIX does not require that the d_ino field be present, and some |
|
|
to numbered) backup file name. */ |
to numbered) backup file name. */ |
char *simple_backup_suffix = "~"; |
char *simple_backup_suffix = "~"; |
|
|
static char *concat (); |
static char *concat(char *, char *); |
char *find_backup_file_name (); |
char *find_backup_file_name(char *); |
static char *make_version_name (); |
static char *make_version_name(char *, int); |
static int max_backup_version (); |
static int max_backup_version(char *, char *); |
static int version_number (); |
static int version_number(char *, char *, int); |
|
static int argmatch(char *, char **); |
|
static void invalid_arg(char *, char *, int); |
|
|
#ifndef NODIR |
#ifndef NODIR |
/* Return the name of the new backup file for file FILE, |
/* Return the name of the new backup file for file FILE, |
|
|
int highest_version; |
int highest_version; |
int this_version; |
int this_version; |
int file_name_length; |
int file_name_length; |
|
|
dirp = opendir (dir); |
dirp = opendir (dir); |
if (!dirp) |
if (!dirp) |
return 0; |
return 0; |
|
|
highest_version = 0; |
highest_version = 0; |
file_name_length = strlen (file); |
file_name_length = strlen (file); |
|
|
|
|
{ |
{ |
if (!REAL_DIR_ENTRY (dp) || NLENGTH (dp) <= file_name_length) |
if (!REAL_DIR_ENTRY (dp) || NLENGTH (dp) <= file_name_length) |
continue; |
continue; |
|
|
this_version = version_number (file, dp->d_name, file_name_length); |
this_version = version_number (file, dp->d_name, file_name_length); |
if (this_version > highest_version) |
if (this_version > highest_version) |
highest_version = this_version; |
highest_version = this_version; |
|
|
{ |
{ |
int version; |
int version; |
char *p; |
char *p; |
|
|
version = 0; |
version = 0; |
if (!strncmp (base, backup, base_length) && ISDIGIT (backup[base_length])) |
if (!strncmp (base, backup, base_length) && ISDIGIT (backup[base_length])) |
{ |
{ |
|
|
int arglen; /* Length of ARG. */ |
int arglen; /* Length of ARG. */ |
int matchind = -1; /* Index of first nonexact match. */ |
int matchind = -1; /* Index of first nonexact match. */ |
int ambiguous = 0; /* If nonzero, multiple nonexact match(es). */ |
int ambiguous = 0; /* If nonzero, multiple nonexact match(es). */ |
|
|
arglen = strlen (arg); |
arglen = strlen (arg); |
|
|
/* Test all elements for either exact match or abbreviated matches. */ |
/* Test all elements for either exact match or abbreviated matches. */ |
for (i = 0; optlist[i]; i++) |
for (i = 0; optlist[i]; i++) |
{ |
{ |