This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Merge getopt from gnulib to glibc and vice versa, eliminate __need_getopt


Thanks for doing this, as Gnulib and Glibc should be better-synchronized. In the interests of helping this move along, I installed your proposed changes into Gnulib, with the attached additional minor patches, the first of which I hope you can incorporate into your Glibc proposal (the second patch is Gnulib-only). Perhaps other reviewers will come up with other Gnulib and/or Glibc improvements, but one step at a time. Three thoughts:

* Gnulib lib/getopt_cdefs.in.h, lib/getopt_core.h, lib/getopt_ext.h, lib/getopt_pfx_core.h, and lib/getopt_pfx_ext.h now all have comments saying "Unlike most bits headers, it does not have a protective #error, because the guard macro for getopt.h in gnulib is not fixed." What sort of Gnulib fix did you have in mind? Is this something we can easily fix in Gnulib now?

* From Gnulib's point of view, perhaps it would be better to define a module for sys/cdefs.h, and have the Gnulib getopt-posix module depend on this new module. That way, other Gnulib code could assume a standard GNU system which has sys/cdefs.h. Does this seem like a reasonable way forward to you? It shouldn't affect glibc code, other than perhaps to simplify it a bit.

* Although the Gnulib project prefers to omit leading tabs in .c and .h files, it's OK to put tabs in files shared from glibc, at least while we're doing this merge. I suppose Gnulib developers who prefer to avoid tabs can expand them later, once the merging is done. Personally I would rather let sleeping dogs lie.
From 7903a1e07b2e48d558015195017beac57c82f328 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Thu, 6 Apr 2017 13:15:46 -0700
Subject: [PATCH 1/2] getopt-posix: use angle-bracket include

* lib/getopt1.c: Include <config.h>, not "config.h".
---
 ChangeLog     | 5 +++++
 lib/getopt1.c | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index b019c34..3f7c6f5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2017-04-06  Paul Eggert  <eggert@cs.ucla.edu>
+
+	getopt-posix: use angle-bracket include
+	* lib/getopt1.c: Include <config.h>, not "config.h".
+
 2017-04-06  Zack Weinberg  <zackw@panix.com>
 
 	getopt: annotate files with relationship to glibc
diff --git a/lib/getopt1.c b/lib/getopt1.c
index a1fab22..526dc31 100644
--- a/lib/getopt1.c
+++ b/lib/getopt1.c
@@ -18,7 +18,7 @@
    <http://www.gnu.org/licenses/>.  */
 
 #ifndef _LIBC
-#include "config.h"
+# include <config.h>
 #endif
 
 #include "getopt.h"
-- 
2.9.3

From ec1cb3a41a76c28d22b0174380ca4fed7d57cc80 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Thu, 6 Apr 2017 15:41:05 -0700
Subject: [PATCH 2/2] getopt-gnu: omit some duplicate code
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* m4/getopt.m4 (gl_FUNC_GETOPT_GNU): Don’t require
gl_FUNC_GETOPT_POSIX, as the configure.ac code generated by
gnulib-tool already does this.
* modules/getopt-gnu (configure.ac): Omit code duplicated from
getopt-posix, which we depend on.
---
 ChangeLog          | 7 +++++++
 m4/getopt.m4       | 4 +---
 modules/getopt-gnu | 7 -------
 3 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 3f7c6f5..db893f5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2017-04-06  Paul Eggert  <eggert@cs.ucla.edu>
 
+	getopt-gnu: omit some duplicate code
+	* m4/getopt.m4 (gl_FUNC_GETOPT_GNU): Don’t require
+	gl_FUNC_GETOPT_POSIX, as the configure.ac code generated by
+	gnulib-tool already does this.
+	* modules/getopt-gnu (configure.ac): Omit code duplicated from
+	getopt-posix, which we depend on.
+
 	getopt-posix: use angle-bracket include
 	* lib/getopt1.c: Include <config.h>, not "config.h".
 
diff --git a/m4/getopt.m4 b/m4/getopt.m4
index 139a814..d900769 100644
--- a/m4/getopt.m4
+++ b/m4/getopt.m4
@@ -1,4 +1,4 @@
-# getopt.m4 serial 44
+# getopt.m4 serial 45
 dnl Copyright (C) 2002-2006, 2008-2017 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -33,8 +33,6 @@ AC_DEFUN([gl_FUNC_GETOPT_POSIX],
 AC_DEFUN([gl_FUNC_GETOPT_GNU],
 [
   m4_divert_text([INIT_PREPARE], [gl_getopt_required=GNU])
-
-  AC_REQUIRE([gl_FUNC_GETOPT_POSIX])
 ])
 
 # Determine whether to replace the entire getopt facility.
diff --git a/modules/getopt-gnu b/modules/getopt-gnu
index 9c348ed..974ce14 100644
--- a/modules/getopt-gnu
+++ b/modules/getopt-gnu
@@ -10,13 +10,6 @@ getopt-posix
 
 configure.ac:
 gl_FUNC_GETOPT_GNU
-if test $REPLACE_GETOPT = 1; then
-  AC_LIBOBJ([getopt])
-  AC_LIBOBJ([getopt1])
-  dnl Arrange for unistd.h to include getopt.h.
-  GNULIB_${gl_include_guard_prefix}_UNISTD_H_GETOPT=1
-fi
-AC_SUBST([GNULIB_${gl_include_guard_prefix}_UNISTD_H_GETOPT])
 
 Makefile.am:
 
-- 
2.9.3


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]