filename.h and dosname.h define identical macros

2020-03-17 Thread Tim Rühsen
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



signature.asc
Description: OpenPGP digital signature


Re: filename.h and dosname.h define identical macros

2020-03-28 Thread Bruno Haible
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  

filename: Copy some definitions from module 'dosname'.
* lib/filename.h: Include , 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
 
 DateModules Changes
 
+2020-03-28  filenameThe 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  fchownatThis 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 .  */
 
+/* From Paul Eggert and Jim Meyering.  */
+
 #ifndef _FILENAME_H
 #define _FILENAME_H
 
+#include 
+
 #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__ || def

Re: filename.h and dosname.h define identical macros

2020-03-28 Thread Tim Rühsen

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  

filename: Copy some definitions from module 'dosname'.
* lib/filename.h: Include , 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

  DateModules Changes

+2020-03-28  filenameThe 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  fchownatThis 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 .  */

+/* From Paul Eggert and Jim Meyering.  */
+
  #ifndef _FILENAME_H
  #define _FILENAME_H

+#include 
+
  #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
+