From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-4.1 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 631831F487 for ; Sat, 28 Mar 2020 18:40:48 +0000 (UTC) Received: from localhost ([::1]:59108 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jIGNy-0000Mh-Sf for normalperson@yhbt.net; Sat, 28 Mar 2020 14:40:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43399) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jIGNm-0000Mb-F3 for bug-gnulib@gnu.org; Sat, 28 Mar 2020 14:40:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jIGNk-0004eC-Ci for bug-gnulib@gnu.org; Sat, 28 Mar 2020 14:40:34 -0400 Received: from mout.gmx.net ([212.227.17.20]:49275) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jIGNk-0004ZI-3N for bug-gnulib@gnu.org; Sat, 28 Mar 2020 14:40:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1585420830; bh=uGdqf8dpiGOm4JxrBJ9f0CWmZ/A/LsYu1qB226vR7AE=; h=X-UI-Sender-Class:Subject:To:References:From:Date:In-Reply-To; b=JZL8I8pathx3u5nJf6tI7yG999T9epu4EZbqgkYkYQ6HOaGOeurENqKVgyjQtzcP6 7x2X0Jq3upAtqIENt1N1P3ZK6wMk4JDHGKsmEh81HgbAi6pSBbljyPiYoYwzotTQnf i3lQOHA2eomGlRJt05qUfdWOKqwqG8CYXdqaTEsI= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [192.168.178.28] ([93.181.12.113]) by mail.gmx.com (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1N4zAy-1jPvwX3gDk-010wCi; Sat, 28 Mar 2020 19:40:29 +0100 Subject: Re: filename.h and dosname.h define identical macros To: Bruno Haible , bug-gnulib@gnu.org References: <5954c4de-17ba-47f7-90ae-84cd182063f9@gmx.de> <3598668.v44DtDpsti@omega> From: =?UTF-8?Q?Tim_R=c3=bchsen?= Message-ID: Date: Sat, 28 Mar 2020 19:40:29 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <3598668.v44DtDpsti@omega> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:oS+lKuiEFYyWWEzu0rOnJWAyn4AjCPumfSnNaslqs+YomzBM3cW qRqFAFBB07Hcz9g0RtRlhAIQc9EvZ6K8NH4Lgpy72OKkTzqNthsZlbAaIBs4zYCVIng9xsW 5/C2hp06/xjErn4P9Sq1bpv7N13RZk+cDW/Fr3V2mqq9BmvpG8vYyh4u/+DzM/qnck+fd42 Fa3xI4NDtLxuY4d4DUVxg== X-UI-Out-Filterresults: notjunk:1;V03:K0:KkZMLM8eR+c=:XK8lf+wlPnX6fpL/viejMv yscXE5tqY2lVMjqW7/6afo1DpZo00oCNA8n7OiVq5rlFw9d2MbZvArv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wnjom3FC1j8nEbp4isX8kKt3dEyGUJfSVdxzuNHYqb8gdjgls6WEl1WnN EwAYCz9/uZ3fxTzSWXiSjeszjf+U9jMUCtRJ/ddp04Ex6DxwgFG8TmSditFfIvjgWDSGbvuv8 bJjMzVwIjndEiChsm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.17.20 X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "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 configu= re) > turned it into an error. > > I process reports about errors with high priority. Reports about warning= s > 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 'dosnam= e' > (because nowadays we care more about Windows than about DOS), some detai= ls > 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 > > Date Modules Changes > > +2020-03-28 filename The macro IS_ABSOLUTE_PATH is deprecated. U= se > + IS_ABSOLUTE_FILE_NAME instead. > + The macro IS_PATH_WITH_DIR is deprecated. U= se > + IS_FILE_NAME_WITH_DIR instead. > + > 2020-02-22 fchownat This module no longer defines the function= s > 'chownat' and 'lchownat'. Program that ne= ed 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 charac= ter. > - 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 specificat= ion. > +/* 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 concatenat= ed > + 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 d= evice > + 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) =3D=3D '/' || (C) =3D=3D '\\') > -# define HAS_DEVICE(P) \ > - ((((P)[0] >=3D 'A' && (P)[0] <=3D 'Z') || ((P)[0] >=3D 'a' && (P)[0= ] <=3D 'z')) \ > - && (P)[1] =3D=3D ':') > -# define IS_ABSOLUTE_PATH(P) (ISSLASH ((P)[0]) || HAS_DEVICE (P)) > -# define IS_PATH_WITH_DIR(P) \ > - (strchr (P, '/') !=3D NULL || strchr (P, '\\') !=3D NULL || HAS_DEV= ICE (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) >=3D 'A' && (C) <=3D 'Z') || ((C) >=3D 'a' && (C) <=3D 'z')) > + /* Help the compiler optimizing it. This assumes ASCII. */ > +# undef _IS_DRIVE_LETTER > +# define _IS_DRIVE_LETTER(C) \ > + (((unsigned int) (C) | ('a' - 'A')) - 'a' <=3D 'z' - 'a') > +# define HAS_DEVICE(Filename) \ > + (_IS_DRIVE_LETTER ((Filename)[0]) && (Filename)[1] =3D=3D ':') > +# 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), '/') !=3D NULL || strchr ((Filename), '\\') != =3D NULL \ > + || HAS_DEVICE (Filename)) > #else > /* Unix */ > # define ISSLASH(C) ((C) =3D=3D '/') > -# define IS_ABSOLUTE_PATH(P) ISSLASH ((P)[0]) > -# define IS_PATH_WITH_DIR(P) (strchr (P, '/') !=3D 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), '/') !=3D= 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 charac= ter. > - IS_PATH_WITH_DIR(P) tests whether P contains a directory specificat= ion. > + ISSLASH(C) tests whether C is a directory separator c= haracter. > + IS_FILE_NAME_WITH_DIR(P) tests whether P contains a directory speci= fication. > */ > #if (defined _WIN32 && !defined __CYGWIN__) || defined __EMX__ || defi= ned __DJGPP__ > /* Native Windows, OS/2, DOS */ > @@ -85,13 +85,13 @@ extern char * canonicalize_file_name (const char *na= me); > # define HAS_DEVICE(P) \ > ((((P)[0] >=3D 'A' && (P)[0] <=3D 'Z') || ((P)[0] >=3D 'a' && (P)[= 0] <=3D 'z')) \ > && (P)[1] =3D=3D ':') > -# define IS_PATH_WITH_DIR(P) \ > +# define IS_FILE_NAME_WITH_DIR(P) \ > (strchr (P, '/') !=3D NULL || strchr (P, '\\') !=3D NULL || HAS_DE= VICE (P)) > # define FILE_SYSTEM_PREFIX_LEN(P) (HAS_DEVICE (P) ? 2 : 0) > #else > /* Unix */ > # define ISSLASH(C) ((C) =3D=3D '/') > -# define IS_PATH_WITH_DIR(P) (strchr (P, '/') !=3D NULL) > +# define IS_FILE_NAME_WITH_DIR(P) (strchr (P, '/') !=3D NULL) > # define FILE_SYSTEM_PREFIX_LEN(P) 0 > #endif > > @@ -206,7 +206,7 @@ find_executable (const char *argv0) > int length =3D 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 charac= ter. > - IS_PATH_WITH_DIR(P) tests whether P contains a directory specificat= ion. > + ISSLASH(C) tests whether C is a directory separator c= haracter. > + IS_FILE_NAME_WITH_DIR(P) tests whether P contains a directory speci= fication. > */ > #if (defined _WIN32 && !defined __CYGWIN__) || defined __EMX__ || defi= ned __DJGPP__ > /* Native Windows, OS/2, DOS */ > @@ -83,13 +83,13 @@ > # define HAS_DEVICE(P) \ > ((((P)[0] >=3D 'A' && (P)[0] <=3D 'Z') || ((P)[0] >=3D 'a' && (P)[= 0] <=3D 'z')) \ > && (P)[1] =3D=3D ':') > -# define IS_PATH_WITH_DIR(P) \ > +# define IS_FILE_NAME_WITH_DIR(P) \ > (strchr (P, '/') !=3D NULL || strchr (P, '\\') !=3D NULL || HAS_DE= VICE (P)) > # define FILE_SYSTEM_PREFIX_LEN(P) (HAS_DEVICE (P) ? 2 : 0) > #else > /* Unix */ > # define ISSLASH(C) ((C) =3D=3D '/') > -# define IS_PATH_WITH_DIR(P) (strchr (P, '/') !=3D NULL) > +# define IS_FILE_NAME_WITH_DIR(P) (strchr (P, '/') !=3D NULL) > # define FILE_SYSTEM_PREFIX_LEN(P) 0 > #endif > > @@ -333,7 +333,7 @@ DllMain (HINSTANCE module_handle, DWORD event, LPVOI= D reserved) > /* Shouldn't happen. */ > return FALSE; > > - if (!IS_PATH_WITH_DIR (location)) > + if (!IS_FILE_NAME_WITH_DIR (location)) > /* Shouldn't happen. */ > return FALSE; > >