bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* filename.h and dosname.h define identical macros
@ 2020-03-17  8:53 Tim Rühsen
  2020-03-28 13:07 ` Bruno Haible
  0 siblings, 1 reply; 6+ messages in thread
From: Tim Rühsen @ 2020-03-17  8:53 UTC (permalink / raw)
  To: bug-gnulib


[-- Attachment #1.1: Type: text/plain, Size: 785 bytes --]

Hi,

dosname.h (included by dirname.h) and filename.h overlap in macro
definition. This currently results in an error here:

In file included from wget.c:61:
In file included from ../lib/dirname.h:24:
../lib/dosname.h:36:10: error: 'FILE_SYSTEM_PREFIX_LEN' macro redefined
[-Werror,-Wmacro-redefined]
# define FILE_SYSTEM_PREFIX_LEN(Filename) 0
         ^
../lib/filename.h:46:10: note: previous definition is here
# define FILE_SYSTEM_PREFIX_LEN(P) 0
         ^
1 error generated.
make[2]: *** [Makefile:1737: wget.o] Error 1


We can easily work-around or even ignore this on our side.
But maybe it's time to consolidate the code, as we have e.g.
_IS_DRIVE_LETTER(C) and HAS_DEVICE(P) doing the same with slightly
different  implementations ?

Regards, Tim


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: filename.h and dosname.h define identical macros
  2020-03-17  8:53 filename.h and dosname.h define identical macros Tim Rühsen
@ 2020-03-28 13:07 ` Bruno Haible
  2020-03-28 14:00   ` dosname: Change IS_RELATIVE_FILE_NAME Bruno Haible
  2020-03-28 18:40   ` filename.h and dosname.h define identical macros Tim Rühsen
  0 siblings, 2 replies; 6+ messages in thread
From: Bruno Haible @ 2020-03-28 13:07 UTC (permalink / raw)
  To: bug-gnulib; +Cc: Tim Rühsen

Hi Tim,

> dosname.h (included by dirname.h) and filename.h overlap in macro
> definition. This currently results in an error here:
> ...
> [-Werror,-Wmacro-redefined]

Please don't say that it's an error, when in fact it's a warning, and
only the build system of your package (or your own way to invoke configure)
turned it into an error.

I process reports about errors with high priority. Reports about warnings
have a lower priority, 1. because you have the option to just ignore the
error, 2. because we cannot avoid warnings on all platforms.

> But maybe it's time to consolidate the code, as we have e.g.
> _IS_DRIVE_LETTER(C) and HAS_DEVICE(P) doing the same with slightly
> different  implementations ?

Yes, you're right. While 'filename' is a better module name than 'dosname'
(because nowadays we care more about Windows than about DOS), some details
in dosname.h are better done than in filename.h. So, let me do it in two steps:
  1. Copy all interesting stuff from dosname.h to filename.h.
  2. Redirect from dosname.h to filename.h.

Part 1:


2020-03-28  Bruno Haible  <bruno@clisp.org>

	filename: Copy some definitions from module 'dosname'.
	* lib/filename.h: Include <string.h>, for IS_FILE_NAME_WITH_DIR.
	(HAS_DEVICE): Document macro.
	(FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE): New macro.
	(IS_ABSOLUTE_FILE_NAME): Consider
	FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE.
	(IS_RELATIVE_FILE_NAME, IS_FILE_NAME_WITH_DIR): New macros.
	(IS_ABSOLUTE_PATH, IS_PATH_WITH_DIR): Define as deprecated aliases.
	* lib/relocatable.c (IS_FILE_NAME_WITH_DIR): Renamed from
	IS_PATH_WITH_DIR.
	(DllMain): Update.
	* lib/progreloc.c (IS_FILE_NAME_WITH_DIR): Renamed from
	IS_PATH_WITH_DIR.
	(find_executable): Update.
	* NEWS: Document the deprecations.

diff --git a/NEWS b/NEWS
index 4b9a983..3ec49f3 100644
--- a/NEWS
+++ b/NEWS
@@ -58,6 +58,11 @@ User visible incompatible changes
 
 Date        Modules         Changes
 
+2020-03-28  filename        The macro IS_ABSOLUTE_PATH is deprecated. Use
+                            IS_ABSOLUTE_FILE_NAME instead.
+                            The macro IS_PATH_WITH_DIR is deprecated. Use
+                            IS_FILE_NAME_WITH_DIR instead.
+
 2020-02-22  fchownat        This module no longer defines the functions
                             'chownat' and 'lchownat'.  Program that need these
                             functions should add the module 'chownat' to the
diff --git a/lib/filename.h b/lib/filename.h
index d4c7020..4598fb1 100644
--- a/lib/filename.h
+++ b/lib/filename.h
@@ -14,38 +14,94 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 
+/* From Paul Eggert and Jim Meyering.  */
+
 #ifndef _FILENAME_H
 #define _FILENAME_H
 
+#include <string.h>
+
 #ifdef __cplusplus
 extern "C" {
 #endif
 
 
-/* Pathname support.
-   ISSLASH(C)           tests whether C is a directory separator character.
-   IS_ABSOLUTE_PATH(P)  tests whether P is an absolute path.  If it is not,
-                        it may be concatenated to a directory pathname.
-   IS_PATH_WITH_DIR(P)  tests whether P contains a directory specification.
+/* Filename support.
+   ISSLASH(C)                  tests whether C is a directory separator
+                               character.
+   HAS_DEVICE(Filename)        tests whether Filename contains a device
+                               specification.
+   FILE_SYSTEM_PREFIX_LEN(Filename)  length of the device specification
+                                     at the beginning of Filename,
+                                     index of the part consisting of
+                                     alternating components and slashes.
+   FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
+                               1 when a non-empty device specification
+                               can be followed by an empty or relative
+                               part,
+                               0 when a non-empty device specification
+                               must be followed by a slash,
+                               0 when device specification don't exist.
+   IS_ABSOLUTE_FILE_NAME(Filename)
+                               tests whether Filename is independent of
+                               any notion of "current directory".
+   IS_RELATIVE_FILE_NAME(Filename)
+                               tests whether Filename may be concatenated
+                               to a directory filename.
+   Note: On native Windows, OS/2, DOS, "c:" is neither an absolute nor a
+   relative file name!
+   IS_FILE_NAME_WITH_DIR(Filename)  tests whether Filename contains a device
+                                    or directory specification.
  */
-#if defined _WIN32 || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
+#if defined _WIN32 || defined __CYGWIN__ \
+    || defined __EMX__ || defined __MSDOS__ || defined __DJGPP__
   /* Native Windows, Cygwin, OS/2, DOS */
 # define ISSLASH(C) ((C) == '/' || (C) == '\\')
-# define HAS_DEVICE(P) \
-    ((((P)[0] >= 'A' && (P)[0] <= 'Z') || ((P)[0] >= 'a' && (P)[0] <= 'z')) \
-     && (P)[1] == ':')
-# define IS_ABSOLUTE_PATH(P) (ISSLASH ((P)[0]) || HAS_DEVICE (P))
-# define IS_PATH_WITH_DIR(P) \
-    (strchr (P, '/') != NULL || strchr (P, '\\') != NULL || HAS_DEVICE (P))
-# define FILE_SYSTEM_PREFIX_LEN(P) (HAS_DEVICE (P) ? 2 : 0)
+  /* Internal macro: Tests whether a character is a drive letter.  */
+# define _IS_DRIVE_LETTER(C) \
+    (((C) >= 'A' && (C) <= 'Z') || ((C) >= 'a' && (C) <= 'z'))
+  /* Help the compiler optimizing it.  This assumes ASCII.  */
+# undef _IS_DRIVE_LETTER
+# define _IS_DRIVE_LETTER(C) \
+    (((unsigned int) (C) | ('a' - 'A')) - 'a' <= 'z' - 'a')
+# define HAS_DEVICE(Filename) \
+    (_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':')
+# define FILE_SYSTEM_PREFIX_LEN(Filename) (HAS_DEVICE (Filename) ? 2 : 0)
+# ifdef __CYGWIN__
+#  define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0
+# else
+   /* On native Windows, OS/2, DOS, the system has the notion of a
+      "current directory" on each drive.  */
+#  define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 1
+# endif
+# if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
+#  define IS_ABSOLUTE_FILE_NAME(Filename) \
+     ISSLASH ((Filename)[FILE_SYSTEM_PREFIX_LEN (Filename)])
+# else
+#  define IS_ABSOLUTE_FILE_NAME(Filename) \
+     (ISSLASH ((Filename)[0]) || HAS_DEVICE (Filename))
+# endif
+# define IS_RELATIVE_FILE_NAME(Filename) \
+    (! (ISSLASH ((Filename)[0]) || HAS_DEVICE (Filename)))
+# define IS_FILE_NAME_WITH_DIR(Filename) \
+    (strchr ((Filename), '/') != NULL || strchr ((Filename), '\\') != NULL \
+     || HAS_DEVICE (Filename))
 #else
   /* Unix */
 # define ISSLASH(C) ((C) == '/')
-# define IS_ABSOLUTE_PATH(P) ISSLASH ((P)[0])
-# define IS_PATH_WITH_DIR(P) (strchr (P, '/') != NULL)
-# define FILE_SYSTEM_PREFIX_LEN(P) 0
+# define HAS_DEVICE(Filename) ((void) (Filename), 0)
+# define FILE_SYSTEM_PREFIX_LEN(Filename) ((void) (Filename), 0)
+# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0
+# define IS_ABSOLUTE_FILE_NAME(Filename) ISSLASH ((Filename)[0])
+# define IS_RELATIVE_FILE_NAME(Filename) (! ISSLASH ((Filename)[0]))
+# define IS_FILE_NAME_WITH_DIR(Filename) (strchr ((Filename), '/') != NULL)
 #endif
 
+/* Deprecated macros.  For backward compatibility with old users of the
+   'filename' module.  */
+#define IS_ABSOLUTE_PATH IS_ABSOLUTE_FILE_NAME
+#define IS_PATH_WITH_DIR IS_FILE_NAME_WITH_DIR
+
 
 #ifdef __cplusplus
 }
diff --git a/lib/progreloc.c b/lib/progreloc.c
index 2acf3fb..b555211 100644
--- a/lib/progreloc.c
+++ b/lib/progreloc.c
@@ -76,8 +76,8 @@
 extern char * canonicalize_file_name (const char *name);
 
 /* Pathname support.
-   ISSLASH(C)           tests whether C is a directory separator character.
-   IS_PATH_WITH_DIR(P)  tests whether P contains a directory specification.
+   ISSLASH(C)                tests whether C is a directory separator character.
+   IS_FILE_NAME_WITH_DIR(P)  tests whether P contains a directory specification.
  */
 #if (defined _WIN32 && !defined __CYGWIN__) || defined __EMX__ || defined __DJGPP__
   /* Native Windows, OS/2, DOS */
@@ -85,13 +85,13 @@ extern char * canonicalize_file_name (const char *name);
 # define HAS_DEVICE(P) \
     ((((P)[0] >= 'A' && (P)[0] <= 'Z') || ((P)[0] >= 'a' && (P)[0] <= 'z')) \
      && (P)[1] == ':')
-# define IS_PATH_WITH_DIR(P) \
+# define IS_FILE_NAME_WITH_DIR(P) \
     (strchr (P, '/') != NULL || strchr (P, '\\') != NULL || HAS_DEVICE (P))
 # define FILE_SYSTEM_PREFIX_LEN(P) (HAS_DEVICE (P) ? 2 : 0)
 #else
   /* Unix */
 # define ISSLASH(C) ((C) == '/')
-# define IS_PATH_WITH_DIR(P) (strchr (P, '/') != NULL)
+# define IS_FILE_NAME_WITH_DIR(P) (strchr (P, '/') != NULL)
 # define FILE_SYSTEM_PREFIX_LEN(P) 0
 #endif
 
@@ -206,7 +206,7 @@ find_executable (const char *argv0)
   int length = GetModuleFileName (NULL, location, sizeof (location));
   if (length < 0)
     return NULL;
-  if (!IS_PATH_WITH_DIR (location))
+  if (!IS_FILE_NAME_WITH_DIR (location))
     /* Shouldn't happen.  */
     return NULL;
   return xstrdup (location);
diff --git a/lib/relocatable.c b/lib/relocatable.c
index 7e81c83..e4b867b 100644
--- a/lib/relocatable.c
+++ b/lib/relocatable.c
@@ -74,8 +74,8 @@
 #define true 1
 
 /* Pathname support.
-   ISSLASH(C)           tests whether C is a directory separator character.
-   IS_PATH_WITH_DIR(P)  tests whether P contains a directory specification.
+   ISSLASH(C)                tests whether C is a directory separator character.
+   IS_FILE_NAME_WITH_DIR(P)  tests whether P contains a directory specification.
  */
 #if (defined _WIN32 && !defined __CYGWIN__) || defined __EMX__ || defined __DJGPP__
   /* Native Windows, OS/2, DOS */
@@ -83,13 +83,13 @@
 # define HAS_DEVICE(P) \
     ((((P)[0] >= 'A' && (P)[0] <= 'Z') || ((P)[0] >= 'a' && (P)[0] <= 'z')) \
      && (P)[1] == ':')
-# define IS_PATH_WITH_DIR(P) \
+# define IS_FILE_NAME_WITH_DIR(P) \
     (strchr (P, '/') != NULL || strchr (P, '\\') != NULL || HAS_DEVICE (P))
 # define FILE_SYSTEM_PREFIX_LEN(P) (HAS_DEVICE (P) ? 2 : 0)
 #else
   /* Unix */
 # define ISSLASH(C) ((C) == '/')
-# define IS_PATH_WITH_DIR(P) (strchr (P, '/') != NULL)
+# define IS_FILE_NAME_WITH_DIR(P) (strchr (P, '/') != NULL)
 # define FILE_SYSTEM_PREFIX_LEN(P) 0
 #endif
 
@@ -333,7 +333,7 @@ DllMain (HINSTANCE module_handle, DWORD event, LPVOID reserved)
         /* Shouldn't happen.  */
         return FALSE;
 
-      if (!IS_PATH_WITH_DIR (location))
+      if (!IS_FILE_NAME_WITH_DIR (location))
         /* Shouldn't happen.  */
         return FALSE;
 



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* dosname: Change IS_RELATIVE_FILE_NAME
  2020-03-28 13:07 ` Bruno Haible
@ 2020-03-28 14:00   ` Bruno Haible
  2020-03-28 14:13     ` dosname: Redirect to 'filename' Bruno Haible
  2020-03-28 18:40   ` filename.h and dosname.h define identical macros Tim Rühsen
  1 sibling, 1 reply; 6+ messages in thread
From: Bruno Haible @ 2020-03-28 14:00 UTC (permalink / raw)
  To: bug-gnulib; +Cc: Tim Rühsen

In the most important GNU package, I can see 3 uses of IS_RELATIVE_FILE_NAME:

libvirt/src/qemu/qemu_domain.c
tar/src/misc.c
coreutils/src/basename.c

In the first two, the code assumes that IS_RELATIVE_FILE_NAME(F) means that
you can append F to a directory and get a meaningful file name. But with the
current definition of IS_RELATIVE_FILE_NAME, this is not true:
IS_RELATIVE_FILE_NAME("c:") returns true, but \foo\bar\c: is not a valid file
name.

Let me fix this.

For the third occurrence, the change does not matter.


2020-03-28  Bruno Haible  <bruno@clisp.org>

	dosname: Change IS_RELATIVE_FILE_NAME.
	* lib/dosname.h (IS_RELATIVE_FILE_NAME): On native Windows, OS/2, DOS,
	change the definition so that IS_RELATIVE_FILE_NAME("c:") is false.
	* NEWS: Mention the change.

diff --git a/NEWS b/NEWS
index 3ec49f3..c9548d5 100644
--- a/NEWS
+++ b/NEWS
@@ -58,6 +58,9 @@ User visible incompatible changes
 
 Date        Modules         Changes
 
+2020-03-28  dosname         On native Windows, OS/2, DOS,
+                            IS_RELATIVE_FILE_NAME("c:") now returns false.
+
 2020-03-28  filename        The macro IS_ABSOLUTE_PATH is deprecated. Use
                             IS_ABSOLUTE_FILE_NAME instead.
                             The macro IS_PATH_WITH_DIR is deprecated. Use
diff --git a/lib/dosname.h b/lib/dosname.h
index 5782960..926a695 100644
--- a/lib/dosname.h
+++ b/lib/dosname.h
@@ -47,6 +47,7 @@
 #  define IS_ABSOLUTE_FILE_NAME(F)                              \
      (ISSLASH ((F)[0]) || FILE_SYSTEM_PREFIX_LEN (F) != 0)
 #endif
-#define IS_RELATIVE_FILE_NAME(F) (! IS_ABSOLUTE_FILE_NAME (F))
+#define IS_RELATIVE_FILE_NAME(F) \
+  (! (ISSLASH ((F)[0]) || FILE_SYSTEM_PREFIX_LEN (F) != 0))
 
 #endif /* DOSNAME_H_ */



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* dosname: Redirect to 'filename'
  2020-03-28 14:00   ` dosname: Change IS_RELATIVE_FILE_NAME Bruno Haible
@ 2020-03-28 14:13     ` Bruno Haible
  2020-03-28 14:58       ` use module 'filename' instead of module 'dosname' Bruno Haible
  0 siblings, 1 reply; 6+ messages in thread
From: Bruno Haible @ 2020-03-28 14:13 UTC (permalink / raw)
  To: bug-gnulib; +Cc: Tim Rühsen

Now we can unify the modules 'dosname' and 'filename'.


2020-03-28  Bruno Haible  <bruno@clisp.org>

	dosname: Redirect to 'filename'.
	Reported by Tim Rühsen <tim.ruehsen@gmx.de> in
	<https://lists.gnu.org/archive/html/bug-gnulib/2020-03/msg00042.html>.
	* lib/dosname.h: Remove all definitions. Just include filename.h.
	* modules/dosname (Status, Notice): Mark as deprecated.
	(Depends-on): Add 'filename'.

diff --git a/lib/dosname.h b/lib/dosname.h
index 926a695..490e0c5 100644
--- a/lib/dosname.h
+++ b/lib/dosname.h
@@ -13,41 +13,6 @@
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program.  If not, see <https://www.gnu.org/licenses/>.
+   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 
-   From Paul Eggert and Jim Meyering.  */
-
-#ifndef _DOSNAME_H
-#define _DOSNAME_H
-
-#if (defined _WIN32 || defined __CYGWIN__ \
-     || defined __EMX__ || defined __MSDOS__ || defined __DJGPP__)
-   /* This internal macro assumes ASCII, but all hosts that support drive
-      letters use ASCII.  */
-# define _IS_DRIVE_LETTER(C) (((unsigned int) (C) | ('a' - 'A')) - 'a'  \
-                              <= 'z' - 'a')
-# define FILE_SYSTEM_PREFIX_LEN(Filename) \
-          (_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':' ? 2 : 0)
-# ifndef __CYGWIN__
-#  define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 1
-# endif
-# define ISSLASH(C) ((C) == '/' || (C) == '\\')
-#else
-# define FILE_SYSTEM_PREFIX_LEN(Filename) 0
-# define ISSLASH(C) ((C) == '/')
-#endif
-
-#ifndef FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
-# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0
-#endif
-
-#if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
-#  define IS_ABSOLUTE_FILE_NAME(F) ISSLASH ((F)[FILE_SYSTEM_PREFIX_LEN (F)])
-# else
-#  define IS_ABSOLUTE_FILE_NAME(F)                              \
-     (ISSLASH ((F)[0]) || FILE_SYSTEM_PREFIX_LEN (F) != 0)
-#endif
-#define IS_RELATIVE_FILE_NAME(F) \
-  (! (ISSLASH ((F)[0]) || FILE_SYSTEM_PREFIX_LEN (F) != 0))
-
-#endif /* DOSNAME_H_ */
+#include "filename.h"
diff --git a/modules/dosname b/modules/dosname
index 0e8703c..e323aa7 100644
--- a/modules/dosname
+++ b/modules/dosname
@@ -1,10 +1,17 @@
 Description:
 Macros for porting to systems with DOS-style file names.
 
+Status:
+deprecated
+
+Notice:
+This module is deprecated. Use the module 'filename' instead.
+
 Files:
 lib/dosname.h
 
 Depends-on:
+filename
 
 configure.ac:
 



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* use module 'filename' instead of module 'dosname'
  2020-03-28 14:13     ` dosname: Redirect to 'filename' Bruno Haible
@ 2020-03-28 14:58       ` Bruno Haible
  0 siblings, 0 replies; 6+ messages in thread
From: Bruno Haible @ 2020-03-28 14:58 UTC (permalink / raw)
  To: bug-gnulib; +Cc: Tim Rühsen

And this patch finally avoids deprecation warnings.


2020-03-28  Bruno Haible  <bruno@clisp.org>

	Use module 'filename' instead of module 'dosname'.

	* lib/at-func.c: Include filename.h instead of dosname.h.
	* lib/unlinkat.c: Likewise.
	* modules/areadlinkat (Depends-on): Add filename. Remove dosname.
	* modules/areadlinkat-with-size (Depends-on): Likewise.
	* modules/faccessat (Depends-on): Likewise.
	* modules/fchmodat (Depends-on): Likewise.
	* modules/fchownat (Depends-on): Likewise.
	* modules/fstatat (Depends-on): Likewise.
	* modules/mkdirat (Depends-on): Likewise.
	* modules/mkfifoat (Depends-on): Likewise.
	* modules/readlinkat (Depends-on): Likewise.
	* modules/selinux-at (Depends-on): Likewise.
	* modules/symlinkat (Depends-on): Likewise.
	* modules/unlinkat (Depends-on): Likewise.
	* modules/utimensat (Depends-on): Likewise.

	* lib/at-func2.c: Include filename.h instead of dosname.h.
	* modules/linkat (Depends-on): Add filename. Remove dosname.
	* modules/renameatu (Depends-on): Likewise.

	* lib/canonicalize.c: Include filename.h instead of dosname.h.
	* lib/canonicalize-lgpl.c: Likewise.
	* modules/canonicalize (Depends-on): Add filename.
	* modules/canonicalize-lgpl (Depends-on): Likewise.

	* lib/dirname.h: Include filename.h instead of dosname.h.
	* modules/dirname-lgpl (Depends-on): Add filename. Remove dosname.

	* lib/fchdir.c: Include filename.h instead of dosname.h.
	* modules/fchdir (Depends-on): Add filename. Remove dosname.

	* lib/openat.c: Include filename.h instead of dosname.h.
	* modules/openat (Depends-on): Add filename. Remove dosname.

	* lib/rmdir.c: Include filename.h instead of dosname.h.
	* modules/rmdir (Depends-on): Add filename. Remove dosname.

	* lib/savewd.c: Include filename.h instead of dosname.h.
	* modules/savewd (Depends-on): Add filename. Remove dosname.

	* lib/unlink.c: Include filename.h instead of dosname.h.
	* modules/unlink (Depends-on): Add filename. Remove dosname.

	* modules/relocatable-prog-wrapper (Depends-on): Add filename.
	* lib/relocwrapper.c: Update comments.

	* modules/lstat (Depends-on): Remove dosname.

diff --git a/lib/at-func.c b/lib/at-func.c
index 4a1c909..90022e0 100644
--- a/lib/at-func.c
+++ b/lib/at-func.c
@@ -16,7 +16,7 @@
 
 /* written by Jim Meyering */
 
-#include "dosname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */
+#include "filename.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */
 
 #ifdef GNULIB_SUPPORT_ONLY_AT_FDCWD
 # include <errno.h>
diff --git a/lib/at-func2.c b/lib/at-func2.c
index bc2e2fa..51baf3d 100644
--- a/lib/at-func2.c
+++ b/lib/at-func2.c
@@ -25,7 +25,7 @@
 #include <string.h>
 #include <unistd.h>
 
-#include "dosname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */
+#include "filename.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */
 #include "filenamecat.h"
 #include "openat.h"
 #include "same-inode.h"
diff --git a/lib/canonicalize-lgpl.c b/lib/canonicalize-lgpl.c
index 7d3c710..9f99098 100644
--- a/lib/canonicalize-lgpl.c
+++ b/lib/canonicalize-lgpl.c
@@ -51,7 +51,7 @@
 # define __realpath realpath
 # include "pathmax.h"
 # include "malloca.h"
-# include "dosname.h"
+# include "filename.h"
 # if HAVE_GETCWD
 #  if IN_RELOCWRAPPER
     /* When building the relocatable program wrapper, use the system's getcwd
diff --git a/lib/canonicalize.c b/lib/canonicalize.c
index 67fc76e..8bb3254 100644
--- a/lib/canonicalize.c
+++ b/lib/canonicalize.c
@@ -30,7 +30,7 @@
 #include "pathmax.h"
 #include "xalloc.h"
 #include "xgetcwd.h"
-#include "dosname.h"
+#include "filename.h"
 
 #define MULTIPLE_BITS_SET(i) (((i) & ((i) - 1)) != 0)
 
diff --git a/lib/dirname.h b/lib/dirname.h
index 8c12d93..5379e8e 100644
--- a/lib/dirname.h
+++ b/lib/dirname.h
@@ -21,7 +21,7 @@
 
 # include <stdbool.h>
 # include <stddef.h>
-# include "dosname.h"
+# include "filename.h"
 
 # ifndef DIRECTORY_SEPARATOR
 #  define DIRECTORY_SEPARATOR '/'
diff --git a/lib/fchdir.c b/lib/fchdir.c
index c27914b..20ecd3c 100644
--- a/lib/fchdir.c
+++ b/lib/fchdir.c
@@ -29,7 +29,7 @@
 #include <sys/stat.h>
 
 #include "assure.h"
-#include "dosname.h"
+#include "filename.h"
 #include "filenamecat.h"
 
 #ifndef REPLACE_OPEN_DIRECTORY
diff --git a/lib/openat.c b/lib/openat.c
index fdbe83f..974f1a8 100644
--- a/lib/openat.c
+++ b/lib/openat.c
@@ -167,7 +167,7 @@ rpl_openat (int dfd, char const *filename, int flags, ...)
 
 #else /* !HAVE_OPENAT */
 
-# include "dosname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */
+# include "filename.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */
 # include "openat-priv.h"
 # include "save-cwd.h"
 
diff --git a/lib/relocwrapper.c b/lib/relocwrapper.c
index 1b29ac0..dfe7e4f 100644
--- a/lib/relocwrapper.c
+++ b/lib/relocwrapper.c
@@ -24,10 +24,11 @@
              -> allocator
           -> readlink
              -> stat
-                -> dosname
+                -> filename
                 -> pathmax
                 -> verify
        -> canonicalize-lgpl
+          -> filename
           -> malloca
           -> lstat
           -> readlink
diff --git a/lib/rmdir.c b/lib/rmdir.c
index 2f517cc..2155224 100644
--- a/lib/rmdir.c
+++ b/lib/rmdir.c
@@ -23,7 +23,7 @@
 #include <errno.h>
 #include <string.h>
 
-#include "dosname.h"
+#include "filename.h"
 
 #undef rmdir
 
diff --git a/lib/savewd.c b/lib/savewd.c
index 2cfdf88..2b68e41 100644
--- a/lib/savewd.c
+++ b/lib/savewd.c
@@ -33,8 +33,8 @@
 #include <unistd.h>
 
 #include "assure.h"
-#include "dosname.h"
 #include "fcntl-safer.h"
+#include "filename.h"
 
 #ifndef FALLTHROUGH
 # if __GNUC__ < 7
diff --git a/lib/unlink.c b/lib/unlink.c
index 5e0f4e1..35463fd 100644
--- a/lib/unlink.c
+++ b/lib/unlink.c
@@ -24,7 +24,7 @@
 #include <string.h>
 #include <sys/stat.h>
 
-#include "dosname.h"
+#include "filename.h"
 
 #undef unlink
 
diff --git a/lib/unlinkat.c b/lib/unlinkat.c
index 7c0302e..4423686 100644
--- a/lib/unlinkat.c
+++ b/lib/unlinkat.c
@@ -28,7 +28,7 @@
 
 #include <stdlib.h>
 
-#include "dosname.h"
+#include "filename.h"
 #include "openat.h"
 
 #if HAVE_UNLINKAT
diff --git a/modules/areadlinkat b/modules/areadlinkat
index a9668cf..3b36f13 100644
--- a/modules/areadlinkat
+++ b/modules/areadlinkat
@@ -11,11 +11,11 @@ areadlink
 careadlinkat
 readlinkat
 at-internal
-dosname
 errno
 extensions
 fchdir
 fcntl-h
+filename
 openat-die
 openat-h
 save-cwd
diff --git a/modules/areadlinkat-with-size b/modules/areadlinkat-with-size
index 2cdd959..51fb1a8 100644
--- a/modules/areadlinkat-with-size
+++ b/modules/areadlinkat-with-size
@@ -11,11 +11,11 @@ areadlink-with-size
 stdint
 readlinkat
 at-internal
-dosname
 errno
 extensions
 fchdir
 fcntl-h
+filename
 openat-die
 openat-h
 save-cwd
diff --git a/modules/canonicalize b/modules/canonicalize
index b8aadb7..233fba9 100644
--- a/modules/canonicalize
+++ b/modules/canonicalize
@@ -12,6 +12,7 @@ areadlink-with-size
 errno
 extensions
 file-set
+filename
 hash-triple
 lstat
 memmove
diff --git a/modules/canonicalize-lgpl b/modules/canonicalize-lgpl
index ad8c028..3526422 100644
--- a/modules/canonicalize-lgpl
+++ b/modules/canonicalize-lgpl
@@ -12,6 +12,7 @@ stdlib
 nocrash
 alloca-opt      [test $HAVE_CANONICALIZE_FILE_NAME = 0 || test $REPLACE_CANONICALIZE_FILE_NAME = 1]
 errno           [test $HAVE_CANONICALIZE_FILE_NAME = 0 || test $REPLACE_CANONICALIZE_FILE_NAME = 1]
+filename        [test $HAVE_CANONICALIZE_FILE_NAME = 0 || test $REPLACE_CANONICALIZE_FILE_NAME = 1]
 lstat           [test $HAVE_CANONICALIZE_FILE_NAME = 0 || test $REPLACE_CANONICALIZE_FILE_NAME = 1]
 malloca         [test $HAVE_CANONICALIZE_FILE_NAME = 0 || test $REPLACE_CANONICALIZE_FILE_NAME = 1]
 memmove         [test $HAVE_CANONICALIZE_FILE_NAME = 0 || test $REPLACE_CANONICALIZE_FILE_NAME = 1]
diff --git a/modules/dirname-lgpl b/modules/dirname-lgpl
index 4b48a3e..d6c3efd 100644
--- a/modules/dirname-lgpl
+++ b/modules/dirname-lgpl
@@ -9,8 +9,8 @@ lib/stripslash.c
 m4/dirname.m4
 
 Depends-on:
-dosname
 double-slash-root
+filename
 malloc-posix
 stdbool
 
diff --git a/modules/faccessat b/modules/faccessat
index 170aa7b..b502137 100644
--- a/modules/faccessat
+++ b/modules/faccessat
@@ -10,10 +10,10 @@ Depends-on:
 unistd
 extensions
 at-internal     [test $HAVE_FACCESSAT = 0 || test $REPLACE_FACCESSAT = 1]
-dosname         [test $HAVE_FACCESSAT = 0 || test $REPLACE_FACCESSAT = 1]
 errno           [test $HAVE_FACCESSAT = 0 || test $REPLACE_FACCESSAT = 1]
 fchdir          [test $HAVE_FACCESSAT = 0 || test $REPLACE_FACCESSAT = 1]
 fcntl-h         [test $HAVE_FACCESSAT = 0 || test $REPLACE_FACCESSAT = 1]
+filename        [test $HAVE_FACCESSAT = 0 || test $REPLACE_FACCESSAT = 1]
 fstatat         [test $HAVE_FACCESSAT = 0 || test $REPLACE_FACCESSAT = 1]
 openat-die      [test $HAVE_FACCESSAT = 0 || test $REPLACE_FACCESSAT = 1]
 openat-h        [test $HAVE_FACCESSAT = 0 || test $REPLACE_FACCESSAT = 1]
diff --git a/modules/fchdir b/modules/fchdir
index 6e95e9a..eb53d25 100644
--- a/modules/fchdir
+++ b/modules/fchdir
@@ -12,10 +12,10 @@ chdir            [test $HAVE_FCHDIR = 0]
 close            [test $HAVE_FCHDIR = 0]
 dirent           [test $HAVE_FCHDIR = 0]
 dirfd            [test $HAVE_FCHDIR = 0]
-dosname          [test $HAVE_FCHDIR = 0]
 dup2             [test $HAVE_FCHDIR = 0]
 fcntl            [test $HAVE_FCHDIR = 0]
 fcntl-h          [test $HAVE_FCHDIR = 0]
+filename         [test $HAVE_FCHDIR = 0]
 filenamecat-lgpl [test $HAVE_FCHDIR = 0]
 fstat            [test $HAVE_FCHDIR = 0]
 getcwd-lgpl      [test $HAVE_FCHDIR = 0]
diff --git a/modules/fchmodat b/modules/fchmodat
index aef184d..83e14ab 100644
--- a/modules/fchmodat
+++ b/modules/fchmodat
@@ -10,11 +10,11 @@ Depends-on:
 sys_stat
 extensions
 at-internal     [test $HAVE_FCHMODAT = 0]
-dosname         [test $HAVE_FCHMODAT = 0]
 errno           [test $HAVE_FCHMODAT = 0 || test $REPLACE_FCHMODAT = 1]
 extern-inline   [test $HAVE_FCHMODAT = 0]
 fchdir          [test $HAVE_FCHMODAT = 0]
 fcntl-h         [test $HAVE_FCHMODAT = 0 || test $REPLACE_FCHMODAT = 1]
+filename        [test $HAVE_FCHMODAT = 0]
 fstatat         [test $REPLACE_FCHMODAT = 1]
 intprops        [test $HAVE_FCHMODAT = 0 || test $REPLACE_FCHMODAT = 1]
 lchmod          [test $HAVE_FCHMODAT = 0]
diff --git a/modules/fchownat b/modules/fchownat
index d29d77e..e14544a 100644
--- a/modules/fchownat
+++ b/modules/fchownat
@@ -10,11 +10,11 @@ Depends-on:
 unistd
 extensions
 at-internal     [test $HAVE_FCHOWNAT = 0 || test $REPLACE_FCHOWNAT = 1]
-dosname         [test $HAVE_FCHOWNAT = 0 || test $REPLACE_FCHOWNAT = 1]
 errno           [test $HAVE_FCHOWNAT = 0 || test $REPLACE_FCHOWNAT = 1]
 extern-inline   [test $HAVE_FCHOWNAT = 0 || test $REPLACE_FCHOWNAT = 1]
 fchdir          [test $HAVE_FCHOWNAT = 0 || test $REPLACE_FCHOWNAT = 1]
 fcntl-h         [test $HAVE_FCHOWNAT = 0 || test $REPLACE_FCHOWNAT = 1]
+filename        [test $HAVE_FCHOWNAT = 0 || test $REPLACE_FCHOWNAT = 1]
 lchown          [test $HAVE_FCHOWNAT = 0 || test $REPLACE_FCHOWNAT = 1]
 openat-die      [test $HAVE_FCHOWNAT = 0 || test $REPLACE_FCHOWNAT = 1]
 openat-h        [test $HAVE_FCHOWNAT = 0 || test $REPLACE_FCHOWNAT = 1]
diff --git a/modules/fstatat b/modules/fstatat
index 14c3f27..985ea0c 100644
--- a/modules/fstatat
+++ b/modules/fstatat
@@ -11,11 +11,11 @@ Depends-on:
 sys_stat
 extensions
 at-internal     [test $HAVE_FSTATAT = 0 || test $REPLACE_FSTATAT = 1]
-dosname         [test $HAVE_FSTATAT = 0 || test $REPLACE_FSTATAT = 1]
 errno           [test $HAVE_FSTATAT = 0 || test $REPLACE_FSTATAT = 1]
 extern-inline   [test $HAVE_FSTATAT = 0 || test $REPLACE_FSTATAT = 1]
 fchdir          [test $HAVE_FSTATAT = 0 || test $REPLACE_FSTATAT = 1]
 fcntl-h         [test $HAVE_FSTATAT = 0 || test $REPLACE_FSTATAT = 1]
+filename        [test $HAVE_FSTATAT = 0 || test $REPLACE_FSTATAT = 1]
 lstat           [test $HAVE_FSTATAT = 0 || test $REPLACE_FSTATAT = 1]
 openat-die      [test $HAVE_FSTATAT = 0 || test $REPLACE_FSTATAT = 1]
 openat-h        [test $HAVE_FSTATAT = 0 || test $REPLACE_FSTATAT = 1]
diff --git a/modules/linkat b/modules/linkat
index a7cbb94..e6f70ff 100644
--- a/modules/linkat
+++ b/modules/linkat
@@ -16,7 +16,7 @@ filenamecat-lgpl [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
 link-follow      [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
 areadlink        [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
 at-internal      [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
-dosname          [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
+filename         [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
 fstat            [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
 getcwd-lgpl      [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
 openat-h         [test $HAVE_LINKAT = 0 || test $REPLACE_LINKAT = 1]
diff --git a/modules/lstat b/modules/lstat
index a5bff51..6173858 100644
--- a/modules/lstat
+++ b/modules/lstat
@@ -8,7 +8,6 @@ m4/lstat.m4
 Depends-on:
 sys_stat
 largefile
-dosname         [test $REPLACE_LSTAT = 1]
 stat            [test $REPLACE_LSTAT = 1]
 stat-time       [test $REPLACE_LSTAT = 1]
 
diff --git a/modules/mkdirat b/modules/mkdirat
index 0fe638a..7b70a0b 100644
--- a/modules/mkdirat
+++ b/modules/mkdirat
@@ -10,10 +10,10 @@ Depends-on:
 sys_stat
 extensions
 at-internal     [test $HAVE_MKDIRAT = 0]
-dosname         [test $HAVE_MKDIRAT = 0]
 errno           [test $HAVE_MKDIRAT = 0]
 fchdir          [test $HAVE_MKDIRAT = 0]
 fcntl-h         [test $HAVE_MKDIRAT = 0]
+filename        [test $HAVE_MKDIRAT = 0]
 mkdir           [test $HAVE_MKDIRAT = 0]
 openat-die      [test $HAVE_MKDIRAT = 0]
 openat-h        [test $HAVE_MKDIRAT = 0]
diff --git a/modules/mkfifoat b/modules/mkfifoat
index bc0c8e3..6c859f3 100644
--- a/modules/mkfifoat
+++ b/modules/mkfifoat
@@ -12,10 +12,10 @@ Depends-on:
 sys_stat
 extensions
 at-internal     [test $HAVE_MKFIFOAT = 0 || test $HAVE_MKNODAT = 0]
-dosname         [test $HAVE_MKFIFOAT = 0 || test $HAVE_MKNODAT = 0]
 errno           [test $HAVE_MKFIFOAT = 0 || test $HAVE_MKNODAT = 0]
 fchdir          [test $HAVE_MKFIFOAT = 0 || test $HAVE_MKNODAT = 0]
 fcntl-h         [test $HAVE_MKFIFOAT = 0 || test $HAVE_MKNODAT = 0]
+filename        [test $HAVE_MKFIFOAT = 0 || test $HAVE_MKNODAT = 0]
 openat-die      [test $HAVE_MKFIFOAT = 0 || test $HAVE_MKNODAT = 0]
 openat-h        [test $HAVE_MKFIFOAT = 0 || test $HAVE_MKNODAT = 0]
 save-cwd        [test $HAVE_MKFIFOAT = 0 || test $HAVE_MKNODAT = 0]
diff --git a/modules/openat b/modules/openat
index 66fa3b4..5ff4e4d 100644
--- a/modules/openat
+++ b/modules/openat
@@ -18,9 +18,9 @@ sys_stat        [test $HAVE_OPENAT = 0 || test $REPLACE_OPENAT = 1]
 cloexec         [test $REPLACE_OPENAT = 1]
 fstat           [test $REPLACE_OPENAT = 1]
 at-internal     [test $HAVE_OPENAT = 0]
-dosname         [test $HAVE_OPENAT = 0]
 errno           [test $HAVE_OPENAT = 0]
 fchdir          [test $HAVE_OPENAT = 0]
+filename        [test $HAVE_OPENAT = 0]
 open            [test $HAVE_OPENAT = 0]
 openat-die      [test $HAVE_OPENAT = 0]
 save-cwd        [test $HAVE_OPENAT = 0]
diff --git a/modules/readlinkat b/modules/readlinkat
index 84dac40..3bc7239 100644
--- a/modules/readlinkat
+++ b/modules/readlinkat
@@ -10,10 +10,10 @@ Depends-on:
 unistd
 extensions
 at-internal     [test $HAVE_READLINKAT = 0]
-dosname         [test $HAVE_READLINKAT = 0]
 errno           [test $HAVE_READLINKAT = 0]
 fchdir          [test $HAVE_READLINKAT = 0]
 fcntl-h         [test $HAVE_READLINKAT = 0]
+filename        [test $HAVE_READLINKAT = 0]
 openat-die      [test $HAVE_READLINKAT = 0]
 openat-h        [test $HAVE_READLINKAT = 0]
 save-cwd        [test $HAVE_READLINKAT = 0]
diff --git a/modules/relocatable-prog-wrapper b/modules/relocatable-prog-wrapper
index 25cc66f..3cc3d76 100644
--- a/modules/relocatable-prog-wrapper
+++ b/modules/relocatable-prog-wrapper
@@ -37,6 +37,7 @@ Depends-on:
 alloca-opt
 double-slash-root
 errno
+filename
 largefile
 pathmax
 ssize_t
diff --git a/modules/renameatu b/modules/renameatu
index d0a123c..5ce8e47 100644
--- a/modules/renameatu
+++ b/modules/renameatu
@@ -16,7 +16,7 @@ openat-h         [test $HAVE_RENAMEAT = 0 || test $REPLACE_RENAMEAT = 1]
 statat           [test $REPLACE_RENAMEAT = 1]
 stdbool          [test $REPLACE_RENAMEAT = 1]
 at-internal      [test $HAVE_RENAMEAT = 0]
-dosname          [test $HAVE_RENAMEAT = 0]
+filename         [test $HAVE_RENAMEAT = 0]
 fstat            [test $HAVE_RENAMEAT = 0]
 getcwd-lgpl      [test $HAVE_RENAMEAT = 0]
 openat-die       [test $HAVE_RENAMEAT = 0]
diff --git a/modules/rmdir b/modules/rmdir
index 59a9dba..85336ba 100644
--- a/modules/rmdir
+++ b/modules/rmdir
@@ -7,7 +7,7 @@ m4/rmdir.m4
 
 Depends-on:
 unistd
-dosname         [test $REPLACE_RMDIR = 1]
+filename        [test $REPLACE_RMDIR = 1]
 sys_stat        [test $REPLACE_RMDIR = 1]
 
 configure.ac:
diff --git a/modules/savewd b/modules/savewd
index a6c8267..935540c 100644
--- a/modules/savewd
+++ b/modules/savewd
@@ -9,12 +9,12 @@ m4/savewd.m4
 Depends-on:
 assure
 chdir
-dosname
 errno
 extern-inline
 fchdir
 fcntl-safer
 fcntl-h
+filename
 raise
 stdbool
 stdlib
diff --git a/modules/selinux-at b/modules/selinux-at
index 29d188e..4de98a6 100644
--- a/modules/selinux-at
+++ b/modules/selinux-at
@@ -9,11 +9,11 @@ lib/at-func.c
 Depends-on:
 selinux-h
 at-internal
-dosname
 errno
 extensions
 fchdir
 fcntl-h
+filename
 openat-die
 openat-h
 save-cwd
diff --git a/modules/symlinkat b/modules/symlinkat
index 3d1f2ac..16d0fcc 100644
--- a/modules/symlinkat
+++ b/modules/symlinkat
@@ -10,10 +10,10 @@ Depends-on:
 unistd
 extensions
 at-internal     [test $HAVE_SYMLINKAT = 0]
-dosname         [test $HAVE_SYMLINKAT = 0]
 errno           [test $HAVE_SYMLINKAT = 0]
 fchdir          [test $HAVE_SYMLINKAT = 0]
 fcntl-h         [test $HAVE_SYMLINKAT = 0]
+filename        [test $HAVE_SYMLINKAT = 0]
 openat-die      [test $HAVE_SYMLINKAT = 0]
 openat-h        [test $HAVE_SYMLINKAT = 0]
 save-cwd        [test $HAVE_SYMLINKAT = 0]
diff --git a/modules/unlink b/modules/unlink
index 5fc84d9..9e57184 100644
--- a/modules/unlink
+++ b/modules/unlink
@@ -7,7 +7,7 @@ m4/unlink.m4
 
 Depends-on:
 unistd
-dosname         [test $REPLACE_UNLINK = 1]
+filename        [test $REPLACE_UNLINK = 1]
 lstat           [test $REPLACE_UNLINK = 1]
 malloc-posix    [test $REPLACE_UNLINK = 1]
 
diff --git a/modules/unlinkat b/modules/unlinkat
index f2094e0..b379a90 100644
--- a/modules/unlinkat
+++ b/modules/unlinkat
@@ -15,9 +15,9 @@ openat-h        [test $HAVE_UNLINKAT = 0 || test $REPLACE_UNLINKAT = 1]
 sys_stat        [test $HAVE_UNLINKAT = 0 || test $REPLACE_UNLINKAT = 1]
 statat          [test $REPLACE_UNLINKAT = 1]
 at-internal     [test $HAVE_UNLINKAT = 0]
-dosname         [test $HAVE_UNLINKAT = 0]
 errno           [test $HAVE_UNLINKAT = 0]
 fchdir          [test $HAVE_UNLINKAT = 0]
+filename        [test $HAVE_UNLINKAT = 0]
 openat-die      [test $HAVE_UNLINKAT = 0]
 rmdir           [test $HAVE_UNLINKAT = 0]
 save-cwd        [test $HAVE_UNLINKAT = 0]
diff --git a/modules/utimensat b/modules/utimensat
index 27e4679..1d8895f 100644
--- a/modules/utimensat
+++ b/modules/utimensat
@@ -10,10 +10,10 @@ Depends-on:
 sys_stat
 extensions
 at-internal     [test $HAVE_UTIMENSAT = 0 || test $REPLACE_UTIMENSAT = 1]
-dosname         [test $HAVE_UTIMENSAT = 0 || test $REPLACE_UTIMENSAT = 1]
 errno           [test $HAVE_UTIMENSAT = 0 || test $REPLACE_UTIMENSAT = 1]
 fchdir          [test $HAVE_UTIMENSAT = 0 || test $REPLACE_UTIMENSAT = 1]
 fcntl-h         [test $HAVE_UTIMENSAT = 0 || test $REPLACE_UTIMENSAT = 1]
+filename        [test $HAVE_UTIMENSAT = 0 || test $REPLACE_UTIMENSAT = 1]
 openat-die      [test $HAVE_UTIMENSAT = 0 || test $REPLACE_UTIMENSAT = 1]
 openat-h        [test $HAVE_UTIMENSAT = 0 || test $REPLACE_UTIMENSAT = 1]
 save-cwd        [test $HAVE_UTIMENSAT = 0 || test $REPLACE_UTIMENSAT = 1]



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: filename.h and dosname.h define identical macros
  2020-03-28 13:07 ` Bruno Haible
  2020-03-28 14:00   ` dosname: Change IS_RELATIVE_FILE_NAME Bruno Haible
@ 2020-03-28 18:40   ` Tim Rühsen
  1 sibling, 0 replies; 6+ messages in thread
From: Tim Rühsen @ 2020-03-28 18:40 UTC (permalink / raw)
  To: Bruno Haible, bug-gnulib

Hi Bruno,

thank you so much for reorganizing the code.

I updated both, Wget and Wget2, to the latest gnulib and it looks good
for me :-)

Regards, Tim

On 3/28/20 2:07 PM, Bruno Haible wrote:
> Hi Tim,
>
>> dosname.h (included by dirname.h) and filename.h overlap in macro
>> definition. This currently results in an error here:
>> ...
>> [-Werror,-Wmacro-redefined]
>
> Please don't say that it's an error, when in fact it's a warning, and
> only the build system of your package (or your own way to invoke configure)
> turned it into an error.
>
> I process reports about errors with high priority. Reports about warnings
> have a lower priority, 1. because you have the option to just ignore the
> error, 2. because we cannot avoid warnings on all platforms.
>
>> But maybe it's time to consolidate the code, as we have e.g.
>> _IS_DRIVE_LETTER(C) and HAS_DEVICE(P) doing the same with slightly
>> different  implementations ?
>
> Yes, you're right. While 'filename' is a better module name than 'dosname'
> (because nowadays we care more about Windows than about DOS), some details
> in dosname.h are better done than in filename.h. So, let me do it in two steps:
>    1. Copy all interesting stuff from dosname.h to filename.h.
>    2. Redirect from dosname.h to filename.h.
>
> Part 1:
>
>
> 2020-03-28  Bruno Haible  <bruno@clisp.org>
>
> 	filename: Copy some definitions from module 'dosname'.
> 	* lib/filename.h: Include <string.h>, for IS_FILE_NAME_WITH_DIR.
> 	(HAS_DEVICE): Document macro.
> 	(FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE): New macro.
> 	(IS_ABSOLUTE_FILE_NAME): Consider
> 	FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE.
> 	(IS_RELATIVE_FILE_NAME, IS_FILE_NAME_WITH_DIR): New macros.
> 	(IS_ABSOLUTE_PATH, IS_PATH_WITH_DIR): Define as deprecated aliases.
> 	* lib/relocatable.c (IS_FILE_NAME_WITH_DIR): Renamed from
> 	IS_PATH_WITH_DIR.
> 	(DllMain): Update.
> 	* lib/progreloc.c (IS_FILE_NAME_WITH_DIR): Renamed from
> 	IS_PATH_WITH_DIR.
> 	(find_executable): Update.
> 	* NEWS: Document the deprecations.
>
> diff --git a/NEWS b/NEWS
> index 4b9a983..3ec49f3 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -58,6 +58,11 @@ User visible incompatible changes
>
>   Date        Modules         Changes
>
> +2020-03-28  filename        The macro IS_ABSOLUTE_PATH is deprecated. Use
> +                            IS_ABSOLUTE_FILE_NAME instead.
> +                            The macro IS_PATH_WITH_DIR is deprecated. Use
> +                            IS_FILE_NAME_WITH_DIR instead.
> +
>   2020-02-22  fchownat        This module no longer defines the functions
>                               'chownat' and 'lchownat'.  Program that need these
>                               functions should add the module 'chownat' to the
> diff --git a/lib/filename.h b/lib/filename.h
> index d4c7020..4598fb1 100644
> --- a/lib/filename.h
> +++ b/lib/filename.h
> @@ -14,38 +14,94 @@
>      You should have received a copy of the GNU General Public License
>      along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
>
> +/* From Paul Eggert and Jim Meyering.  */
> +
>   #ifndef _FILENAME_H
>   #define _FILENAME_H
>
> +#include <string.h>
> +
>   #ifdef __cplusplus
>   extern "C" {
>   #endif
>
>
> -/* Pathname support.
> -   ISSLASH(C)           tests whether C is a directory separator character.
> -   IS_ABSOLUTE_PATH(P)  tests whether P is an absolute path.  If it is not,
> -                        it may be concatenated to a directory pathname.
> -   IS_PATH_WITH_DIR(P)  tests whether P contains a directory specification.
> +/* Filename support.
> +   ISSLASH(C)                  tests whether C is a directory separator
> +                               character.
> +   HAS_DEVICE(Filename)        tests whether Filename contains a device
> +                               specification.
> +   FILE_SYSTEM_PREFIX_LEN(Filename)  length of the device specification
> +                                     at the beginning of Filename,
> +                                     index of the part consisting of
> +                                     alternating components and slashes.
> +   FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
> +                               1 when a non-empty device specification
> +                               can be followed by an empty or relative
> +                               part,
> +                               0 when a non-empty device specification
> +                               must be followed by a slash,
> +                               0 when device specification don't exist.
> +   IS_ABSOLUTE_FILE_NAME(Filename)
> +                               tests whether Filename is independent of
> +                               any notion of "current directory".
> +   IS_RELATIVE_FILE_NAME(Filename)
> +                               tests whether Filename may be concatenated
> +                               to a directory filename.
> +   Note: On native Windows, OS/2, DOS, "c:" is neither an absolute nor a
> +   relative file name!
> +   IS_FILE_NAME_WITH_DIR(Filename)  tests whether Filename contains a device
> +                                    or directory specification.
>    */
> -#if defined _WIN32 || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__
> +#if defined _WIN32 || defined __CYGWIN__ \
> +    || defined __EMX__ || defined __MSDOS__ || defined __DJGPP__
>     /* Native Windows, Cygwin, OS/2, DOS */
>   # define ISSLASH(C) ((C) == '/' || (C) == '\\')
> -# define HAS_DEVICE(P) \
> -    ((((P)[0] >= 'A' && (P)[0] <= 'Z') || ((P)[0] >= 'a' && (P)[0] <= 'z')) \
> -     && (P)[1] == ':')
> -# define IS_ABSOLUTE_PATH(P) (ISSLASH ((P)[0]) || HAS_DEVICE (P))
> -# define IS_PATH_WITH_DIR(P) \
> -    (strchr (P, '/') != NULL || strchr (P, '\\') != NULL || HAS_DEVICE (P))
> -# define FILE_SYSTEM_PREFIX_LEN(P) (HAS_DEVICE (P) ? 2 : 0)
> +  /* Internal macro: Tests whether a character is a drive letter.  */
> +# define _IS_DRIVE_LETTER(C) \
> +    (((C) >= 'A' && (C) <= 'Z') || ((C) >= 'a' && (C) <= 'z'))
> +  /* Help the compiler optimizing it.  This assumes ASCII.  */
> +# undef _IS_DRIVE_LETTER
> +# define _IS_DRIVE_LETTER(C) \
> +    (((unsigned int) (C) | ('a' - 'A')) - 'a' <= 'z' - 'a')
> +# define HAS_DEVICE(Filename) \
> +    (_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] == ':')
> +# define FILE_SYSTEM_PREFIX_LEN(Filename) (HAS_DEVICE (Filename) ? 2 : 0)
> +# ifdef __CYGWIN__
> +#  define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0
> +# else
> +   /* On native Windows, OS/2, DOS, the system has the notion of a
> +      "current directory" on each drive.  */
> +#  define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 1
> +# endif
> +# if FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE
> +#  define IS_ABSOLUTE_FILE_NAME(Filename) \
> +     ISSLASH ((Filename)[FILE_SYSTEM_PREFIX_LEN (Filename)])
> +# else
> +#  define IS_ABSOLUTE_FILE_NAME(Filename) \
> +     (ISSLASH ((Filename)[0]) || HAS_DEVICE (Filename))
> +# endif
> +# define IS_RELATIVE_FILE_NAME(Filename) \
> +    (! (ISSLASH ((Filename)[0]) || HAS_DEVICE (Filename)))
> +# define IS_FILE_NAME_WITH_DIR(Filename) \
> +    (strchr ((Filename), '/') != NULL || strchr ((Filename), '\\') != NULL \
> +     || HAS_DEVICE (Filename))
>   #else
>     /* Unix */
>   # define ISSLASH(C) ((C) == '/')
> -# define IS_ABSOLUTE_PATH(P) ISSLASH ((P)[0])
> -# define IS_PATH_WITH_DIR(P) (strchr (P, '/') != NULL)
> -# define FILE_SYSTEM_PREFIX_LEN(P) 0
> +# define HAS_DEVICE(Filename) ((void) (Filename), 0)
> +# define FILE_SYSTEM_PREFIX_LEN(Filename) ((void) (Filename), 0)
> +# define FILE_SYSTEM_DRIVE_PREFIX_CAN_BE_RELATIVE 0
> +# define IS_ABSOLUTE_FILE_NAME(Filename) ISSLASH ((Filename)[0])
> +# define IS_RELATIVE_FILE_NAME(Filename) (! ISSLASH ((Filename)[0]))
> +# define IS_FILE_NAME_WITH_DIR(Filename) (strchr ((Filename), '/') != NULL)
>   #endif
>
> +/* Deprecated macros.  For backward compatibility with old users of the
> +   'filename' module.  */
> +#define IS_ABSOLUTE_PATH IS_ABSOLUTE_FILE_NAME
> +#define IS_PATH_WITH_DIR IS_FILE_NAME_WITH_DIR
> +
>
>   #ifdef __cplusplus
>   }
> diff --git a/lib/progreloc.c b/lib/progreloc.c
> index 2acf3fb..b555211 100644
> --- a/lib/progreloc.c
> +++ b/lib/progreloc.c
> @@ -76,8 +76,8 @@
>   extern char * canonicalize_file_name (const char *name);
>
>   /* Pathname support.
> -   ISSLASH(C)           tests whether C is a directory separator character.
> -   IS_PATH_WITH_DIR(P)  tests whether P contains a directory specification.
> +   ISSLASH(C)                tests whether C is a directory separator character.
> +   IS_FILE_NAME_WITH_DIR(P)  tests whether P contains a directory specification.
>    */
>   #if (defined _WIN32 && !defined __CYGWIN__) || defined __EMX__ || defined __DJGPP__
>     /* Native Windows, OS/2, DOS */
> @@ -85,13 +85,13 @@ extern char * canonicalize_file_name (const char *name);
>   # define HAS_DEVICE(P) \
>       ((((P)[0] >= 'A' && (P)[0] <= 'Z') || ((P)[0] >= 'a' && (P)[0] <= 'z')) \
>        && (P)[1] == ':')
> -# define IS_PATH_WITH_DIR(P) \
> +# define IS_FILE_NAME_WITH_DIR(P) \
>       (strchr (P, '/') != NULL || strchr (P, '\\') != NULL || HAS_DEVICE (P))
>   # define FILE_SYSTEM_PREFIX_LEN(P) (HAS_DEVICE (P) ? 2 : 0)
>   #else
>     /* Unix */
>   # define ISSLASH(C) ((C) == '/')
> -# define IS_PATH_WITH_DIR(P) (strchr (P, '/') != NULL)
> +# define IS_FILE_NAME_WITH_DIR(P) (strchr (P, '/') != NULL)
>   # define FILE_SYSTEM_PREFIX_LEN(P) 0
>   #endif
>
> @@ -206,7 +206,7 @@ find_executable (const char *argv0)
>     int length = GetModuleFileName (NULL, location, sizeof (location));
>     if (length < 0)
>       return NULL;
> -  if (!IS_PATH_WITH_DIR (location))
> +  if (!IS_FILE_NAME_WITH_DIR (location))
>       /* Shouldn't happen.  */
>       return NULL;
>     return xstrdup (location);
> diff --git a/lib/relocatable.c b/lib/relocatable.c
> index 7e81c83..e4b867b 100644
> --- a/lib/relocatable.c
> +++ b/lib/relocatable.c
> @@ -74,8 +74,8 @@
>   #define true 1
>
>   /* Pathname support.
> -   ISSLASH(C)           tests whether C is a directory separator character.
> -   IS_PATH_WITH_DIR(P)  tests whether P contains a directory specification.
> +   ISSLASH(C)                tests whether C is a directory separator character.
> +   IS_FILE_NAME_WITH_DIR(P)  tests whether P contains a directory specification.
>    */
>   #if (defined _WIN32 && !defined __CYGWIN__) || defined __EMX__ || defined __DJGPP__
>     /* Native Windows, OS/2, DOS */
> @@ -83,13 +83,13 @@
>   # define HAS_DEVICE(P) \
>       ((((P)[0] >= 'A' && (P)[0] <= 'Z') || ((P)[0] >= 'a' && (P)[0] <= 'z')) \
>        && (P)[1] == ':')
> -# define IS_PATH_WITH_DIR(P) \
> +# define IS_FILE_NAME_WITH_DIR(P) \
>       (strchr (P, '/') != NULL || strchr (P, '\\') != NULL || HAS_DEVICE (P))
>   # define FILE_SYSTEM_PREFIX_LEN(P) (HAS_DEVICE (P) ? 2 : 0)
>   #else
>     /* Unix */
>   # define ISSLASH(C) ((C) == '/')
> -# define IS_PATH_WITH_DIR(P) (strchr (P, '/') != NULL)
> +# define IS_FILE_NAME_WITH_DIR(P) (strchr (P, '/') != NULL)
>   # define FILE_SYSTEM_PREFIX_LEN(P) 0
>   #endif
>
> @@ -333,7 +333,7 @@ DllMain (HINSTANCE module_handle, DWORD event, LPVOID reserved)
>           /* Shouldn't happen.  */
>           return FALSE;
>
> -      if (!IS_PATH_WITH_DIR (location))
> +      if (!IS_FILE_NAME_WITH_DIR (location))
>           /* Shouldn't happen.  */
>           return FALSE;
>
>


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-03-28 18:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-17  8:53 filename.h and dosname.h define identical macros Tim Rühsen
2020-03-28 13:07 ` Bruno Haible
2020-03-28 14:00   ` dosname: Change IS_RELATIVE_FILE_NAME Bruno Haible
2020-03-28 14:13     ` dosname: Redirect to 'filename' Bruno Haible
2020-03-28 14:58       ` use module 'filename' instead of module 'dosname' Bruno Haible
2020-03-28 18:40   ` filename.h and dosname.h define identical macros Tim Rühsen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).