Debian Codegraph @

tools/gnulib/basename-lgpl.c

raw symbols SCIP
1 /* basename.c -- return the last element in a file name
2
3 Copyright (C) 1990, 1998-2001, 2003-2006, 2009-2024 Free Software
4 Foundation, Inc.
5
6 This file is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as
8 published by the Free Software Foundation; either version 2.1 of the
9 License, or (at your option) any later version.
10
11 This file is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with this program. If not, see <https://www.gnu.org/licenses/>. */
18
19 #include <config.h>cxx . . $ `<file>/liblouis/config.h`/
20
21 /* Specification. */
22 #include "basename-lgpl.h"cxx . . $ `<file>/tools/gnulib/basename-lgpl.h`/
23
24 #include <string.h>cxx . . $ `<file>/tools/gnulib/string.h`/
25
26 #include "filename.h"cxx . . $ `<file>/tools/gnulib/filename.h`/
27
28 char *
29 last_componentcxx . . $ last_component(a8b8e32347182212). (char const *name)
30 {
31 char const *base = name + FILE_SYSTEM_PREFIX_LENcxx . . $ `tools/gnulib/filename.h:95:10`! (name);
32 char const *p;
33 boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! last_was_slash = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!;
34
35 while (ISSLASHcxx . . $ `tools/gnulib/filename.h:93:10`! (*base))
36 base++;
37
38 for (p = base; *p; p++)
39 {
40 if (ISSLASHcxx . . $ `tools/gnulib/filename.h:93:10`! (*p))
41 last_was_slash = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!;
42 else if (last_was_slash)
43 {
44 base = p;
45 last_was_slash = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!;
46 }
47 }
48
49 return (char *) base;
50 }
51
52 size_tcxx . . $ size_t#
53 base_lencxx . . $ base_len(751346f8406fd082). (char const *name)
54 {
55 size_tcxx . . $ size_t# len;
56 size_tcxx . . $ size_t# prefix_len = FILE_SYSTEM_PREFIX_LENcxx . . $ `tools/gnulib/filename.h:95:10`! (name);
57
58 for (len = strlencxx . . $ strlen(751346f8406fd082). (name); 1 < len && ISSLASHcxx . . $ `tools/gnulib/filename.h:93:10`! (name[len - 1]); len--)
59 continue;
60
61 if (DOUBLE_SLASH_IS_DISTINCT_ROOTcxx . . $ `tools/gnulib/basename-lgpl.h:30:10`! && len == 1
62 && ISSLASHcxx . . $ `tools/gnulib/filename.h:93:10`! (name[0]) && ISSLASHcxx . . $ `tools/gnulib/filename.h:93:10`! (name[1]) && ! name[2])
63 return 2;
64
65 if (FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVEcxx . . $ `tools/gnulib/filename.h:96:10`! && prefix_len
66 && len == prefix_len && ISSLASHcxx . . $ `tools/gnulib/filename.h:93:10`! (name[prefix_len]))
67 return prefix_len + 1;
68
69 return len;
70 }