public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] fnmatch.h: use standard internal defines
@ 2016-11-27  7:04 Mike Frysinger
  2016-11-27 16:31 ` Paul Eggert
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Mike Frysinger @ 2016-11-27  7:04 UTC (permalink / raw)
  To: libc-alpha

Use features.h for the start/end brackets of C code, and switch to using
__USE_GNU/__USE_XOPEN rather than parsing the symbols directly.

We also drop support for exporting the GNU-extensions when _POSIX_C_SOURCE
is defined to 1 as these aren't in POSIX.

2016-11-27  Mike Frysinger  <vapier@gentoo.org>

	* posix/fnmatch.h: Include features.h.  Replace extern "C" with
	__BEGIN_DECLS and __END_DECLS.  Drop _POSIX_C_SOURCE checking.
	Change _GNU_SOURCE to __USE_GNU.  Change _XOPEN_SOURCE to
	__USE_XOPEN.
---
 posix/fnmatch.h | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/posix/fnmatch.h b/posix/fnmatch.h
index fdfaf90ba9b9..60a52d4bc755 100644
--- a/posix/fnmatch.h
+++ b/posix/fnmatch.h
@@ -18,9 +18,9 @@
 #ifndef	_FNMATCH_H
 #define	_FNMATCH_H	1
 
-#ifdef	__cplusplus
-extern "C" {
-#endif
+#include <features.h>
+
+__BEGIN_DECLS
 
 /* We #undef these before defining them because some losing systems
    (HP-UX A.08.07 for example) define these in <unistd.h>.  */
@@ -33,7 +33,7 @@ extern "C" {
 #define	FNM_NOESCAPE	(1 << 1) /* Backslashes don't quote special chars.  */
 #define	FNM_PERIOD	(1 << 2) /* Leading `.' is matched only explicitly.  */
 
-#if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 2 || defined _GNU_SOURCE
+#ifdef __USE_GNU
 # define FNM_FILE_NAME	 FNM_PATHNAME	/* Preferred GNU name.  */
 # define FNM_LEADING_DIR (1 << 3)	/* Ignore `/...' after a match.  */
 # define FNM_CASEFOLD	 (1 << 4)	/* Compare without regard to case.  */
@@ -47,7 +47,7 @@ extern "C" {
    `fnmatch'.  Since this is not the case here it will never be
    returned but the conformance test suites still require the symbol
    to be defined.  */
-#ifdef _XOPEN_SOURCE
+#ifdef __USE_XOPEN
 # define FNM_NOSYS	(-1)
 #endif
 
@@ -55,8 +55,6 @@ extern "C" {
    returning zero if it matches, FNM_NOMATCH if not.  */
 extern int fnmatch (const char *__pattern, const char *__name, int __flags);
 
-#ifdef	__cplusplus
-}
-#endif
+__END_DECLS
 
 #endif /* fnmatch.h */
-- 
2.11.0.rc2

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

* Re: [PATCH] fnmatch.h: use standard internal defines
  2016-11-27  7:04 [PATCH] fnmatch.h: use standard internal defines Mike Frysinger
@ 2016-11-27 16:31 ` Paul Eggert
  2016-11-27 17:12   ` Mike Frysinger
  2016-11-27 17:46 ` Zack Weinberg
  2017-03-17  5:24 ` [PATCH v2] " Mike Frysinger
  2 siblings, 1 reply; 7+ messages in thread
From: Paul Eggert @ 2016-11-27 16:31 UTC (permalink / raw)
  To: Mike Frysinger, libc-alpha

Mike Frysinger wrote:
> Use features.h for the start/end brackets of C code, and switch to using
> __USE_GNU/__USE_XOPEN rather than parsing the symbols directly.

Doesn't this match fnmatch.h unnecessarily harder to share with Gnulib?

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

* Re: [PATCH] fnmatch.h: use standard internal defines
  2016-11-27 16:31 ` Paul Eggert
@ 2016-11-27 17:12   ` Mike Frysinger
  2016-11-28  0:46     ` Paul Eggert
  0 siblings, 1 reply; 7+ messages in thread
From: Mike Frysinger @ 2016-11-27 17:12 UTC (permalink / raw)
  To: Paul Eggert; +Cc: libc-alpha

[-- Attachment #1: Type: text/plain, Size: 452 bytes --]

On 27 Nov 2016 08:31, Paul Eggert wrote:
> Mike Frysinger wrote:
> > Use features.h for the start/end brackets of C code, and switch to using
> > __USE_GNU/__USE_XOPEN rather than parsing the symbols directly.
> 
> Doesn't this match fnmatch.h unnecessarily harder to share with Gnulib?

gnulib already has this problem (and deals with it) with glob.h and regex.h.
maybe it's time to create a new internal gnulib module to unify that ?
-mike

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH] fnmatch.h: use standard internal defines
  2016-11-27  7:04 [PATCH] fnmatch.h: use standard internal defines Mike Frysinger
  2016-11-27 16:31 ` Paul Eggert
@ 2016-11-27 17:46 ` Zack Weinberg
  2016-11-28 18:17   ` Joseph Myers
  2017-03-17  5:24 ` [PATCH v2] " Mike Frysinger
  2 siblings, 1 reply; 7+ messages in thread
From: Zack Weinberg @ 2016-11-27 17:46 UTC (permalink / raw)
  To: GNU C Library

On Sun, Nov 27, 2016 at 2:04 AM, Mike Frysinger <vapier@gentoo.org> wrote:
...
> @@ -47,7 +47,7 @@ extern "C" {
>     `fnmatch'.  Since this is not the case here it will never be
>     returned but the conformance test suites still require the symbol
>     to be defined.  */
> -#ifdef _XOPEN_SOURCE
> +#ifdef __USE_XOPEN
>  # define FNM_NOSYS     (-1)
>  #endif

As long as we're touching this file,
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/fnmatch.h.html
says FNM_NOSYS was deprecated-XSI in Issue 6 and dropped in Issue 7,
which I *think* means this conditional should be

    #if defined __USE_XOPEN && !defined __USE_XOPEN2K8

(I'm not having any luck finding an online copy of Issue 4 - the Open
Group seems to believe nobody needs to look at it anymore.)

zw

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

* Re: [PATCH] fnmatch.h: use standard internal defines
  2016-11-27 17:12   ` Mike Frysinger
@ 2016-11-28  0:46     ` Paul Eggert
  0 siblings, 0 replies; 7+ messages in thread
From: Paul Eggert @ 2016-11-28  0:46 UTC (permalink / raw)
  To: libc-alpha

Mike Frysinger wrote:
> maybe it's time to create a new internal gnulib module to unify that ?

That would be one way; another is to treat fnmatch.h like regex.h etc. i.e. to 
duplicate the "#define _USE_GNU" code.

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

* Re: [PATCH] fnmatch.h: use standard internal defines
  2016-11-27 17:46 ` Zack Weinberg
@ 2016-11-28 18:17   ` Joseph Myers
  0 siblings, 0 replies; 7+ messages in thread
From: Joseph Myers @ 2016-11-28 18:17 UTC (permalink / raw)
  To: Zack Weinberg; +Cc: GNU C Library

On Sun, 27 Nov 2016, Zack Weinberg wrote:

> (I'm not having any luck finding an online copy of Issue 4 - the Open
> Group seems to believe nobody needs to look at it anymore.)

The link I gave in 
<https://sourceware.org/ml/libc-alpha/2015-07/msg00902.html> still works 
for me.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* [PATCH v2] fnmatch.h: use standard internal defines
  2016-11-27  7:04 [PATCH] fnmatch.h: use standard internal defines Mike Frysinger
  2016-11-27 16:31 ` Paul Eggert
  2016-11-27 17:46 ` Zack Weinberg
@ 2017-03-17  5:24 ` Mike Frysinger
  2 siblings, 0 replies; 7+ messages in thread
From: Mike Frysinger @ 2017-03-17  5:24 UTC (permalink / raw)
  To: libc-alpha

Use features.h for the start/end brackets of C code, and switch to
using __USE_GNU/__USE_XOPEN/__USE_XOPEN2K8 rather than parsing the
symbols directly.

We also drop support for exporting the GNU-extensions when
_POSIX_C_SOURCE is defined to 1 as these aren't in POSIX.

2016-11-27  Mike Frysinger  <vapier@gentoo.org>

	* posix/fnmatch.h: Include features.h.  Replace extern "C" with
	__BEGIN_DECLS and __END_DECLS.  Drop _POSIX_C_SOURCE checking.
	Change _GNU_SOURCE to __USE_GNU.  Change _XOPEN_SOURCE to
	__USE_XOPEN && !__USE_XOPEN2K8.
---
v2
	- add __USE_XOPEN2K8 checking

 posix/fnmatch.h | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/posix/fnmatch.h b/posix/fnmatch.h
index 71991617abe5..55031f5b3042 100644
--- a/posix/fnmatch.h
+++ b/posix/fnmatch.h
@@ -18,9 +18,9 @@
 #ifndef	_FNMATCH_H
 #define	_FNMATCH_H	1
 
-#ifdef	__cplusplus
-extern "C" {
-#endif
+#include <features.h>
+
+__BEGIN_DECLS
 
 /* We #undef these before defining them because some losing systems
    (HP-UX A.08.07 for example) define these in <unistd.h>.  */
@@ -33,7 +33,7 @@ extern "C" {
 #define	FNM_NOESCAPE	(1 << 1) /* Backslashes don't quote special chars.  */
 #define	FNM_PERIOD	(1 << 2) /* Leading `.' is matched only explicitly.  */
 
-#if !defined _POSIX_C_SOURCE || _POSIX_C_SOURCE < 2 || defined _GNU_SOURCE
+#ifdef __USE_GNU
 # define FNM_FILE_NAME	 FNM_PATHNAME	/* Preferred GNU name.  */
 # define FNM_LEADING_DIR (1 << 3)	/* Ignore `/...' after a match.  */
 # define FNM_CASEFOLD	 (1 << 4)	/* Compare without regard to case.  */
@@ -47,7 +47,7 @@ extern "C" {
    `fnmatch'.  Since this is not the case here it will never be
    returned but the conformance test suites still require the symbol
    to be defined.  */
-#ifdef _XOPEN_SOURCE
+#if defined __USE_XOPEN && !defined __USE_XOPEN2K8
 # define FNM_NOSYS	(-1)
 #endif
 
@@ -55,8 +55,6 @@ extern "C" {
    returning zero if it matches, FNM_NOMATCH if not.  */
 extern int fnmatch (const char *__pattern, const char *__name, int __flags);
 
-#ifdef	__cplusplus
-}
-#endif
+__END_DECLS
 
 #endif /* fnmatch.h */
-- 
2.12.0

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

end of thread, other threads:[~2017-03-17  5:24 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-27  7:04 [PATCH] fnmatch.h: use standard internal defines Mike Frysinger
2016-11-27 16:31 ` Paul Eggert
2016-11-27 17:12   ` Mike Frysinger
2016-11-28  0:46     ` Paul Eggert
2016-11-27 17:46 ` Zack Weinberg
2016-11-28 18:17   ` Joseph Myers
2017-03-17  5:24 ` [PATCH v2] " Mike Frysinger

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).