projects
/
gnulib.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
xreadlink.c (xreadlink): AIX and HP-UX readlink return -1
[gnulib.git]
/
lib
/
backupfile.c
diff --git
a/lib/backupfile.c
b/lib/backupfile.c
index
fe535db
..
26ae204
100644
(file)
--- a/
lib/backupfile.c
+++ b/
lib/backupfile.c
@@
-109,16
+109,16
@@
char const *simple_backup_suffix = "~";
char const *simple_backup_suffix = "~";
-/* If FILE
NAME
(which was of length FILELEN before an extension was
+/* If FILE (which was of length FILELEN before an extension was
appended to it) is too long, replace the extension with the single
char E. If the result is still too long, remove the char just
before E. */
static void
appended to it) is too long, replace the extension with the single
char E. If the result is still too long, remove the char just
before E. */
static void
-check_extension (char *file
name
, size_t filelen, char e)
+check_extension (char *file, size_t filelen, char e)
{
{
- char *base
name = base_name (filenam
e);
- size_t baselen = base_len (base
name
);
+ char *base
= base_name (fil
e);
+ size_t baselen = base_len (base);
size_t baselen_max = HAVE_LONG_FILE_NAMES ? 255 : NAME_MAX_MINIMUM;
if (HAVE_DOS_FILE_NAMES || NAME_MAX_MINIMUM < baselen)
size_t baselen_max = HAVE_LONG_FILE_NAMES ? 255 : NAME_MAX_MINIMUM;
if (HAVE_DOS_FILE_NAMES || NAME_MAX_MINIMUM < baselen)
@@
-129,41
+129,41
@@
check_extension (char *filename, size_t filelen, char e)
/* Temporarily modify the buffer into its parent directory name,
invoke pathconf on the directory, and then restore the buffer. */
char tmp[sizeof "."];
/* Temporarily modify the buffer into its parent directory name,
invoke pathconf on the directory, and then restore the buffer. */
char tmp[sizeof "."];
- memcpy (tmp, base
name
, sizeof ".");
- strcpy (base
name
, ".");
+ memcpy (tmp, base, sizeof ".");
+ strcpy (base, ".");
errno = 0;
errno = 0;
- name_max = pathconf (file
name
, _PC_NAME_MAX);
+ name_max = pathconf (file, _PC_NAME_MAX);
if (0 <= name_max || errno == 0)
{
long size = baselen_max = name_max;
if (name_max != size)
baselen_max = SIZE_MAX;
}
if (0 <= name_max || errno == 0)
{
long size = baselen_max = name_max;
if (name_max != size)
baselen_max = SIZE_MAX;
}
- memcpy (base
name
, tmp, sizeof ".");
+ memcpy (base, tmp, sizeof ".");
}
if (HAVE_DOS_FILE_NAMES && baselen_max <= 12)
{
/* Live within DOS's 8.3 limit. */
}
if (HAVE_DOS_FILE_NAMES && baselen_max <= 12)
{
/* Live within DOS's 8.3 limit. */
- char *dot = strchr (base
name
, '.');
+ char *dot = strchr (base, '.');
if (!dot)
baselen_max = 8;
else
{
char const *second_dot = strchr (dot + 1, '.');
baselen_max = (second_dot
if (!dot)
baselen_max = 8;
else
{
char const *second_dot = strchr (dot + 1, '.');
baselen_max = (second_dot
- ? second_dot - base
name
- : dot + 1 - base
name
+ 3);
+ ? second_dot - base
+ : dot + 1 - base + 3);
}
}
if (baselen_max < baselen)
{
}
}
if (baselen_max < baselen)
{
- baselen = file
name + filelen - basenam
e;
+ baselen = file
+ filelen - bas
e;
if (baselen_max <= baselen)
baselen = baselen_max - 1;
if (baselen_max <= baselen)
baselen = baselen_max - 1;
- base
name
[baselen] = e;
- base
name
[baselen + 1] = '\0';
+ base[baselen] = e;
+ base[baselen + 1] = '\0';
}
}
}
}
@@
-204,18
+204,18
@@
numbered_backup (char **buffer, size_t buffer_size, size_t filelen)
struct dirent *dp;
char *buf = *buffer;
size_t versionlenmax = 1;
struct dirent *dp;
char *buf = *buffer;
size_t versionlenmax = 1;
- char *base
name
= base_name (buf);
- size_t base
name_offset = basenam
e - buf;
- size_t baselen = base_len (base
name
);
+ char *base = base_name (buf);
+ size_t base
_offset = bas
e - buf;
+ size_t baselen = base_len (base);
/* Temporarily modify the buffer into its parent directory name,
open the directory, and then restore the buffer. */
char tmp[sizeof "."];
/* Temporarily modify the buffer into its parent directory name,
open the directory, and then restore the buffer. */
char tmp[sizeof "."];
- memcpy (tmp, base
name
, sizeof ".");
- strcpy (base
name
, ".");
+ memcpy (tmp, base, sizeof ".");
+ strcpy (base, ".");
dirp = opendir (buf);
dirp = opendir (buf);
- memcpy (base
name
, tmp, sizeof ".");
- strcpy (base
name
+ baselen, ".~1~");
+ memcpy (base, tmp, sizeof ".");
+ strcpy (base + baselen, ".~1~");
if (!dirp)
return result;
if (!dirp)
return result;
@@
-231,7
+231,7
@@
numbered_backup (char **buffer, size_t buffer_size, size_t filelen)
if (! REAL_DIR_ENTRY (dp) || NLENGTH (dp) < baselen + 4)
continue;
if (! REAL_DIR_ENTRY (dp) || NLENGTH (dp) < baselen + 4)
continue;
- if (memcmp (buf + base
name
_offset, dp->d_name, baselen + 2) != 0)
+ if (memcmp (buf + base_offset, dp->d_name, baselen + 2) != 0)
continue;
p = dp->d_name + baselen + 2;
continue;
p = dp->d_name + baselen + 2;
@@
-270,7
+270,7
@@
numbered_backup (char **buffer, size_t buffer_size, size_t filelen)
*q = '0';
q += all_9s;
memcpy (q, p, versionlen + 2);
*q = '0';
q += all_9s;
memcpy (q, p, versionlen + 2);
-
+
/* Add 1 to the version number. */
q += versionlen;
/* Add 1 to the version number. */
q += versionlen;
@@
-287,7
+287,7
@@
numbered_backup (char **buffer, size_t buffer_size, size_t filelen)
/* 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.
- Do not call this function if backup_type == no
ne.
*/
+ Do not call this function if backup_type == no
_backups.
*/
char *
find_backup_file_name (char const *file, enum backup_type backup_type)
char *
find_backup_file_name (char const *file, enum backup_type backup_type)
@@
-310,7
+310,7
@@
find_backup_file_name (char const *file, enum backup_type backup_type)
memcpy (s, file, filelen + 1);
#if HAVE_DIR
memcpy (s, file, filelen + 1);
#if HAVE_DIR
- if (backup_type != simple)
+ if (backup_type != simple
_backups
)
switch (numbered_backup (&s, ssize, filelen))
{
case BACKUP_IS_SAME_LENGTH:
switch (numbered_backup (&s, ssize, filelen))
{
case BACKUP_IS_SAME_LENGTH:
@@
-321,7
+321,7
@@
find_backup_file_name (char const *file, enum backup_type backup_type)
break;
case BACKUP_IS_NEW:
break;
case BACKUP_IS_NEW:
- simple = (backup_type == numbered_existing);
+ simple = (backup_type == numbered_existing
_backups
);
break;
}
#endif
break;
}
#endif
@@
-345,14
+345,14
@@
static char const * const backup_args[] =
static const enum backup_type backup_types[] =
{
static const enum backup_type backup_types[] =
{
- no
ne, none
,
- simple
, simple
,
- numbered_existing
, numbered_existing
,
- numbered
, numbered
+ no
_backups, no_backups
,
+ simple
_backups, simple_backups
,
+ numbered_existing
_backups, numbered_existing_backups
,
+ numbered
_backups, numbered_backups
};
/* Return the type of backup specified by VERSION.
};
/* Return the type of backup specified by VERSION.
- If VERSION is NULL or the empty string, return numbered_existing.
+ If VERSION is NULL or the empty string, return numbered_existing
_backups
.
If VERSION is invalid or ambiguous, fail with a diagnostic appropriate
for the specified CONTEXT. Unambiguous abbreviations are accepted. */
If VERSION is invalid or ambiguous, fail with a diagnostic appropriate
for the specified CONTEXT. Unambiguous abbreviations are accepted. */
@@
-360,7
+360,7
@@
enum backup_type
get_version (char const *context, char const *version)
{
if (version == 0 || *version == 0)
get_version (char const *context, char const *version)
{
if (version == 0 || *version == 0)
- return numbered_existing;
+ return numbered_existing
_backups
;
else
return XARGMATCH (context, version, backup_args, backup_types);
}
else
return XARGMATCH (context, version, backup_args, backup_types);
}