aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPaul Eggert2020-03-28 13:50:02 -0700
committerPaul Eggert2020-03-28 14:08:11 -0700
commita775dca449ca8da2e2619ea608a3849f70fa951e (patch)
tree3fa6063075ef683bba7f5a4074c7d92b4080042f /lib
parentdceba13ce57ed0cb726e89566197f77359a38d91 (diff)
downloademacs-a775dca449ca8da2e2619ea608a3849f70fa951e.tar.gz
emacs-a775dca449ca8da2e2619ea608a3849f70fa951e.zip
Update from Gnulib
This incorporates: 2020-03-28 Use module 'filename' instead of module 'dosname' 2020-03-28 dosname: Redirect to 'filename' * lib/at-func.c, lib/canonicalize-lgpl.c, lib/dosname.h: Copy from Gnulib. * lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate. * lib/filename.h: New file, copied from Gnulib.
Diffstat (limited to 'lib')
-rw-r--r--lib/at-func.c2
-rw-r--r--lib/canonicalize-lgpl.c2
-rw-r--r--lib/dosname.h38
-rw-r--r--lib/filename.h110
-rw-r--r--lib/gnulib.mk.in9
5 files changed, 123 insertions, 38 deletions
diff --git a/lib/at-func.c b/lib/at-func.c
index 4a1c909d38e..90022e05787 100644
--- a/lib/at-func.c
+++ b/lib/at-func.c
@@ -16,7 +16,7 @@
16 16
17/* written by Jim Meyering */ 17/* written by Jim Meyering */
18 18
19#include "dosname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */ 19#include "filename.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */
20 20
21#ifdef GNULIB_SUPPORT_ONLY_AT_FDCWD 21#ifdef GNULIB_SUPPORT_ONLY_AT_FDCWD
22# include <errno.h> 22# include <errno.h>
diff --git a/lib/canonicalize-lgpl.c b/lib/canonicalize-lgpl.c
index 7d3c710f10f..9f990988393 100644
--- a/lib/canonicalize-lgpl.c
+++ b/lib/canonicalize-lgpl.c
@@ -51,7 +51,7 @@
51# define __realpath realpath 51# define __realpath realpath
52# include "pathmax.h" 52# include "pathmax.h"
53# include "malloca.h" 53# include "malloca.h"
54# include "dosname.h" 54# include "filename.h"
55# if HAVE_GETCWD 55# if HAVE_GETCWD
56# if IN_RELOCWRAPPER 56# if IN_RELOCWRAPPER
57 /* When building the relocatable program wrapper, use the system's getcwd 57 /* When building the relocatable program wrapper, use the system's getcwd
diff --git a/lib/dosname.h b/lib/dosname.h
index 57829600948..490e0c5a7dd 100644
--- a/lib/dosname.h
+++ b/lib/dosname.h
@@ -13,40 +13,6 @@
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. 16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17 17
18 From Paul Eggert and Jim Meyering. */ 18#include "filename.h"
19
20#ifndef _DOSNAME_H
21#define _DOSNAME_H
22
23#if (defined _WIN32 || defined __CYGWIN__ \
24 || defined __EMX__ || defined __MSDOS__ || defined __DJGPP__)
25 /* This internal macro assumes ASCII, but all hosts that support drive
26 letters use ASCII. */
27# define _IS_DRIVE_LETTER(C) (((unsigned int) (C) | ('a' - 'A')) - 'a' \
28 <= 'z' - 'a')
29# define FILE_SYSTEM_PREFIX_LEN(Filename) \
30 (_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':' ? 2 : 0)
31# ifndef __CYGWIN__
32# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 1
33# endif
34# define ISSLASH(C) ((C) == '/' || (C) == '\\')
35#else
36# define FILE_SYSTEM_PREFIX_LEN(Filename) 0
37# define ISSLASH(C) ((C) == '/')
38#endif
39
40#ifndef FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
41# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0
42#endif
43
44#if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
45# define IS_ABSOLUTE_FILE_NAME(F) ISSLASH ((F)[FILE_SYSTEM_PREFIX_LEN (F)])
46# else
47# define IS_ABSOLUTE_FILE_NAME(F) \
48 (ISSLASH ((F)[0]) || FILE_SYSTEM_PREFIX_LEN (F) != 0)
49#endif
50#define IS_RELATIVE_FILE_NAME(F) (! IS_ABSOLUTE_FILE_NAME (F))
51
52#endif /* DOSNAME_H_ */
diff --git a/lib/filename.h b/lib/filename.h
new file mode 100644
index 00000000000..4598fb1d638
--- /dev/null
+++ b/lib/filename.h
@@ -0,0 +1,110 @@
1/* Basic filename support macros.
2 Copyright (C) 2001-2004, 2007-2020 Free Software Foundation, Inc.
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <https://www.gnu.org/licenses/>. */
16
17/* From Paul Eggert and Jim Meyering. */
18
19#ifndef _FILENAME_H
20#define _FILENAME_H
21
22#include <string.h>
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28
29/* Filename support.
30 ISSLASH(C) tests whether C is a directory separator
31 character.
32 HAS_DEVICE(Filename) tests whether Filename contains a device
33 specification.
34 FILE_SYSTEM_PREFIX_LEN(Filename) length of the device specification
35 at the beginning of Filename,
36 index of the part consisting of
37 alternating components and slashes.
38 FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
39 1 when a non-empty device specification
40 can be followed by an empty or relative
41 part,
42 0 when a non-empty device specification
43 must be followed by a slash,
44 0 when device specification don't exist.
45 IS_ABSOLUTE_FILE_NAME(Filename)
46 tests whether Filename is independent of
47 any notion of "current directory".
48 IS_RELATIVE_FILE_NAME(Filename)
49 tests whether Filename may be concatenated
50 to a directory filename.
51 Note: On native Windows, OS/2, DOS, "c:" is neither an absolute nor a
52 relative file name!
53 IS_FILE_NAME_WITH_DIR(Filename) tests whether Filename contains a device
54 or directory specification.
55 */
56#if defined _WIN32 || defined __CYGWIN__ \
57 || defined __EMX__ || defined __MSDOS__ || defined __DJGPP__
58 /* Native Windows, Cygwin, OS/2, DOS */
59# define ISSLASH(C) ((C) == '/' || (C) == '\\')
60 /* Internal macro: Tests whether a character is a drive letter. */
61# define _IS_DRIVE_LETTER(C) \
62 (((C) >= 'A' && (C) <= 'Z') || ((C) >= 'a' && (C) <= 'z'))
63 /* Help the compiler optimizing it. This assumes ASCII. */
64# undef _IS_DRIVE_LETTER
65# define _IS_DRIVE_LETTER(C) \
66 (((unsigned int) (C) | ('a' - 'A')) - 'a' <= 'z' - 'a')
67# define HAS_DEVICE(Filename) \
68 (_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':')
69# define FILE_SYSTEM_PREFIX_LEN(Filename) (HAS_DEVICE (Filename) ? 2 : 0)
70# ifdef __CYGWIN__
71# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0
72# else
73 /* On native Windows, OS/2, DOS, the system has the notion of a
74 "current directory" on each drive. */
75# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 1
76# endif
77# if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
78# define IS_ABSOLUTE_FILE_NAME(Filename) \
79 ISSLASH ((Filename)[FILE_SYSTEM_PREFIX_LEN (Filename)])
80# else
81# define IS_ABSOLUTE_FILE_NAME(Filename) \
82 (ISSLASH ((Filename)[0]) || HAS_DEVICE (Filename))
83# endif
84# define IS_RELATIVE_FILE_NAME(Filename) \
85 (! (ISSLASH ((Filename)[0]) || HAS_DEVICE (Filename)))
86# define IS_FILE_NAME_WITH_DIR(Filename) \
87 (strchr ((Filename), '/') != NULL || strchr ((Filename), '\\') != NULL \
88 || HAS_DEVICE (Filename))
89#else
90 /* Unix */
91# define ISSLASH(C) ((C) == '/')
92# define HAS_DEVICE(Filename) ((void) (Filename), 0)
93# define FILE_SYSTEM_PREFIX_LEN(Filename) ((void) (Filename), 0)
94# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0
95# define IS_ABSOLUTE_FILE_NAME(Filename) ISSLASH ((Filename)[0])
96# define IS_RELATIVE_FILE_NAME(Filename) (! ISSLASH ((Filename)[0]))
97# define IS_FILE_NAME_WITH_DIR(Filename) (strchr ((Filename), '/') != NULL)
98#endif
99
100/* Deprecated macros. For backward compatibility with old users of the
101 'filename' module. */
102#define IS_ABSOLUTE_PATH IS_ABSOLUTE_FILE_NAME
103#define IS_PATH_WITH_DIR IS_FILE_NAME_WITH_DIR
104
105
106#ifdef __cplusplus
107}
108#endif
109
110#endif /* _FILENAME_H */
diff --git a/lib/gnulib.mk.in b/lib/gnulib.mk.in
index e90d2e39049..256bda7752e 100644
--- a/lib/gnulib.mk.in
+++ b/lib/gnulib.mk.in
@@ -1672,6 +1672,15 @@ EXTRA_DIST += filemode.h
1672endif 1672endif
1673## end gnulib module filemode 1673## end gnulib module filemode
1674 1674
1675## begin gnulib module filename
1676ifeq (,$(OMIT_GNULIB_MODULE_filename))
1677
1678
1679EXTRA_DIST += filename.h
1680
1681endif
1682## end gnulib module filename
1683
1675## begin gnulib module filevercmp 1684## begin gnulib module filevercmp
1676ifeq (,$(OMIT_GNULIB_MODULE_filevercmp)) 1685ifeq (,$(OMIT_GNULIB_MODULE_filevercmp))
1677 1686