summaryrefslogtreecommitdiff
path: root/tests/basename-lgpl.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff.email>2022-01-08 11:53:52 +0100
committerJörg Frings-Fürst <debian@jff.email>2022-01-08 11:53:52 +0100
commitfa838e76139763f902c7d27cb9e1d393ed6a15e4 (patch)
tree7d0ae09775ea950056193eaa2ca93844299d46f1 /tests/basename-lgpl.c
parentc78359d9542c86b972aac373efcf7bc7a8a560e5 (diff)
parent2959e59fab3bab834368adefd90bd4b1b094366b (diff)
Merge branch 'feature/upstream' into develop
Diffstat (limited to 'tests/basename-lgpl.c')
-rw-r--r--tests/basename-lgpl.c36
1 files changed, 16 insertions, 20 deletions
diff --git a/tests/basename-lgpl.c b/tests/basename-lgpl.c
index 33f9994f..eb07e254 100644
--- a/tests/basename-lgpl.c
+++ b/tests/basename-lgpl.c
@@ -1,37 +1,37 @@
/* basename.c -- return the last element in a file name
- Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2018 Free Software
+ Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2022 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
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
- This program is distributed in the hope that it will be useful,
+ This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
+ GNU Lesser General Public License for more details.
- You should have received a copy of the GNU General Public License
+ You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
-#include "dirname.h"
+/* Specification. */
+#include "basename-lgpl.h"
+#include <stdbool.h>
#include <string.h>
-/* Return the address of the last file name component of NAME. If
- NAME has no relative file name components because it is a file
- system root, return the empty string. */
+#include "filename.h"
char *
last_component (char const *name)
{
char const *base = name + FILE_SYSTEM_PREFIX_LEN (name);
char const *p;
- bool saw_slash = false;
+ bool last_was_slash = false;
while (ISSLASH (*base))
base++;
@@ -39,21 +39,17 @@ last_component (char const *name)
for (p = base; *p; p++)
{
if (ISSLASH (*p))
- saw_slash = true;
- else if (saw_slash)
+ last_was_slash = true;
+ else if (last_was_slash)
{
base = p;
- saw_slash = false;
+ last_was_slash = false;
}
}
return (char *) base;
}
-/* Return the length of the basename NAME. Typically NAME is the
- value returned by base_name or last_component. Act like strlen
- (NAME), except omit all trailing slashes. */
-
size_t
base_len (char const *name)
{