summaryrefslogtreecommitdiff
path: root/lib/addext.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2001-05-12 14:13:36 +0000
committerJim Meyering <jim@meyering.net>2001-05-12 14:13:36 +0000
commitd45e530c210ee6d2c33eec7f1c98f7c5f1c8a95f (patch)
treef8f888e07512d5055015fba14ea2a18072071b8e /lib/addext.c
parent1fecbd786316880a6fbbfab2ac4444828a84a578 (diff)
downloadcoreutils-d45e530c210ee6d2c33eec7f1c98f7c5f1c8a95f.tar.xz
(ISSLASH, base_name): Remove; now in dirname.h.
Include <dirname.h> after size_t is defined. (addext): Use base_len to trim redundant trailing slashes instead of doing it ourselves. But do not trim the last slash if it is not redundant.
Diffstat (limited to 'lib/addext.c')
-rw-r--r--lib/addext.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/addext.c b/lib/addext.c
index a075ea3b1..65db258f6 100644
--- a/lib/addext.c
+++ b/lib/addext.c
@@ -1,5 +1,5 @@
/* addext.c -- add an extension to a file name
- Copyright (C) 1990, 1997, 1998, 1999 Free Software Foundation, Inc.
+ Copyright 1990, 1997, 1998, 1999, 2001 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
@@ -29,8 +29,6 @@
# define HAVE_LONG_FILE_NAMES 0
#endif
-#include <backupfile.h>
-
#if HAVE_LIMITS_H
# include <limits.h>
#endif
@@ -49,7 +47,8 @@
# include <unistd.h>
#endif
-char *base_name PARAMS ((char const *));
+#include <backupfile.h>
+#include <dirname.h>
/* Append to FILENAME the extension EXT, unless the result would be too long,
in which case just append the character E. */
@@ -58,7 +57,7 @@ void
addext (char *filename, char const *ext, int e)
{
char *s = base_name (filename);
- size_t slen = strlen (s), extlen = strlen (ext);
+ size_t slen = base_len (s), extlen = strlen (ext);
long slen_max = -1;
#if HAVE_PATHCONF && defined _PC_NAME_MAX
@@ -70,7 +69,8 @@ addext (char *filename, char const *ext, int e)
else
{
char c = *s;
- *s = 0;
+ if (! ISSLASH (c))
+ *s = 0;
slen_max = pathconf (filename, _PC_NAME_MAX);
*s = c;
}