[PATCH 1/9] posix: Sync glob with gnulib [BZ #1062]

Paul Eggert eggert@cs.ucla.edu
Wed Sep 6 02:01:00 GMT 2017


Adhemerval Zanella wrote:
> +/* Any distinct values will do here.
> +   Undef any existing macros out of the way.  */
> +#ifndef DT_UNKNOWN
> +# define DT_UNKNOWN 0
> +#endif
> +#ifndef DT_DIR
> +# define DT_DIR 1
> +#endif
> +#ifndef DT_LNK
> +# define DT_LNK 2
> +#endif

The comment here does not match the code, as nothing is being undeffed. Instead 
of this change, how about the following?

#if !defined _LIBC && !defined HAVE_STRUCT_DIRENT_D_TYPE
/* Any distinct values will do here.
    Undef any existing macros out of the way.  */
# undef DT_UNKNOWN
# undef DT_DIR
# undef DT_LNK
# define DT_UNKNOWN 0
# define DT_DIR 1
# define DT_LNK 2
#endif

This makes it more clear to the casual reader that this code is for use only 
outside glibc. Also, it's more robust for hopefully only-hypothetical non-glibc 
platforms that define some DT_ symbols but not others, because it guarantees 
their uniqueness in that case. I installed the attached patch into Gnulib, along 
these lines.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-glob-fix-for-use-in-glibc.patch
Type: text/x-patch
Size: 1370 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20170906/3f41803f/attachment.bin>


More information about the Libc-alpha mailing list