ping [PATCH] early check for PowerPC AIX object mode

2016-03-29 Thread Michael Haubenwallner
any comments at least?
Thanks!
/haubi/

On 03/17/2016 03:34 PM, Michael Haubenwallner wrote:
> Native PowerPC AIX tools do accept only 32 bit objects by default.
> They either need the -X32_64 commandline flag to accept both, or the
> OBJECT_MODE=64 environment variable to switch to accepting 64 bit
> objects only, while the GNU toolchain ignores both the -X32_64 flag
> and the environment variable.  As this affects the whole toolchain, we
> separately set the gl_cv_powerpc_aix_object_mode configure variable to
> either '32' or '64', or to 'no' when not compiling for PowerPC AIX.
> * m4/gnulib-common.m4 (gl_POWERPC_AIX_OBJECT_MODE): New.
> (gl_PROG_AR_RANLIB): Require gl_POWERPC_AIX_OBJECT_MODE.
> Search for AR and RANLIB accepting the -X32_64 flag when
> gl_cv_powerpc_aix_object_mode != no.
> ---
>  ChangeLog   | 16 
>  m4/gnulib-common.m4 | 36 
>  2 files changed, 52 insertions(+)
> 
> diff --git a/ChangeLog b/ChangeLog
> index 49180d9..75cc906 100644
> --- a/ChangeLog
> +++ b/ChangeLog
> @@ -1,3 +1,19 @@
> +2016-03-17  Michael Haubenwallner  
> +
> + early check for PowerPC AIX object mode
> +
> + Native PowerPC AIX tools do accept only 32 bit objects by default.
> + They either need the -X32_64 commandline flag to accept both, or the
> + OBJECT_MODE=64 environment variable to switch to accepting 64 bit
> + objects only, while the GNU toolchain ignores both the -X32_64 flag
> + and the environment variable.  As this affects the whole toolchain, we
> + separately set the gl_cv_powerpc_aix_object_mode configure variable to
> + either '32' or '64', or to 'no' when not compiling for PowerPC AIX.
> + * m4/gnulib-common.m4 (gl_POWERPC_AIX_OBJECT_MODE): New.
> + (gl_PROG_AR_RANLIB): Require gl_POWERPC_AIX_OBJECT_MODE.
> + Search for AR and RANLIB accepting the -X32_64 flag when
> + gl_cv_powerpc_aix_object_mode != no.
> +
>  2016-03-15  Paul Eggert  
>  
>   time_rz: port to clang -Wunused-const-variable
> diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4
> index f8454c8..727b7d6 100644
> --- a/m4/gnulib-common.m4
> +++ b/m4/gnulib-common.m4
> @@ -245,6 +245,37 @@ AC_DEFUN([gl_PROG_CC_C99],
>  [AC_REQUIRE([AC_PROG_CC_STDC])])
>  ])
>  
> +# gl_POWERPC_AIX_OBJECT_MODE
> +# Determines the current object mode used by the compiler for AIX.
> +AC_DEFUN([gl_POWERPC_AIX_OBJECT_MODE],
> +[
> +  AC_CACHE_CHECK([for PowerPC AIX object mode],
> +[gl_cv_powerpc_aix_object_mode],
> +[
> +  dnl like AS_EGREP_CPP but with AS_CASE instead of AS_IF
> +  dnl to run preprocessor once for multiple variants
> +  AC_LANG_PREPROC_REQUIRE()
> +  AC_LANG_CONFTEST([AC_LANG_SOURCE(
> + [
> +#if defined(_AIX) && defined(_POWER)
> +# if defined(__64BIT__)
> +OBJECT_MODE=64
> +# else
> +OBJECT_MODE=32
> +# endif
> +#else
> +OBJECT_MODE=no
> +#endif
> + ])])
> +  AS_CASE(
> + [`(eval "$ac_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD`],
> + [*'OBJECT_MODE=64'*], [gl_cv_powerpc_aix_object_mode=64],
> + [*'OBJECT_MODE=32'*], [gl_cv_powerpc_aix_object_mode=32],
> + [gl_cv_powerpc_aix_object_mode=no])
> +  rm -f conftest*
> +])
> +])
> +
>  # gl_PROG_AR_RANLIB
>  # Determines the values for AR, ARFLAGS, RANLIB that fit with the compiler.
>  # The user can set the variables AR, ARFLAGS, RANLIB if he wants to override
> @@ -256,6 +287,7 @@ AC_DEFUN([gl_PROG_AR_RANLIB],
>dnl library formats. In particular, the GNU binutils programs ar and ranlib
>dnl produce libraries that work only with gcc, not with cc.
>AC_REQUIRE([AC_PROG_CC])
> +  AC_REQUIRE([gl_POWERPC_AIX_OBJECT_MODE])
>AC_BEFORE([$0], [AM_PROG_AR])
>AC_CACHE_CHECK([for Minix Amsterdam compiler], 
> [gl_cv_c_amsterdam_compiler],
>  [
> @@ -278,6 +310,10 @@ Amsterdam
>  if test -z "$ARFLAGS"; then
>ARFLAGS='-o'
>  fi
> +  elif test $gl_cv_powerpc_aix_object_mode != no; then
> +dnl PowerPC AIX toolchain accepts only 32 bit objects by default.
> +AC_CHECK_TOOL([AR], [ar -X32_64], [ar])
> +AC_CHECK_TOOL([RANLIB], [ranlib -X32_64], [ranlib])
>else
>  dnl AM_PROG_AR was added in automake v1.11.2.  AM_PROG_AR does not 
> AC_SUBST
>  dnl ARFLAGS variable (it is filed into Makefile.in directly by automake
> 



[PATCH 3/4] Port tests away from progname

2016-03-29 Thread Pino Toscano
Modules which need the  program name are using getprogname.
* modules/acl-tests (Depends-on): Remove progname.
* modules/argmatch (Depends-on): Likewise.
* modules/argmatch-tests (Depends-on): Likewise.
* modules/argp-tests (Depends-on): Likewise.
* modules/argp-version-etc-tests (Depends-on): Likewise.
* modules/array-list-tests (Depends-on): Likewise.
* modules/array-oset-tests (Depends-on): Likewise.
* modules/avltree-list-tests (Depends-on): Likewise.
* modules/avltree-oset-tests (Depends-on): Likewise.
* modules/avltreehash-list-tests (Depends-on): Likewise.
* modules/carray-list-tests (Depends-on): Likewise.
* modules/copy-file-tests (Depends-on): Likewise.
* modules/exclude-tests (Depends-on): Likewise.
* modules/fchownat-tests (Depends-on): Likewise.
* modules/fdopendir-tests (Depends-on): Likewise.
* modules/filenamecat-tests (Depends-on): Likewise.
* modules/fstatat-tests (Depends-on): Likewise.
* modules/fstrcmp-tests (Depends-on): Likewise.
* modules/linked-list-tests (Depends-on): Likewise.
* modules/linkedhash-list-tests (Depends-on): Likewise.
* modules/mkdirat-tests (Depends-on): Likewise.
* modules/nonblocking-pipe-tests (Depends-on): Likewise.
* modules/nonblocking-socket-tests (Depends-on): Likewise.
* modules/obstack-printf-tests (Depends-on): Likewise.
* modules/openat-tests (Depends-on): Likewise.
* modules/parse-datetime-tests (Depends-on): Likewise.
* modules/pipe-filter-gi-tests (Depends-on): Likewise.
* modules/pipe-filter-ii-tests (Depends-on): Likewise.
* modules/quotearg-simple-tests (Depends-on): Likewise.
* modules/quotearg-tests (Depends-on): Likewise.
* modules/rbtree-list-tests (Depends-on): Likewise.
* modules/rbtree-oset-tests (Depends-on): Likewise.
* modules/rbtreehash-list-tests (Depends-on): Likewise.
* modules/spawn-pipe-tests (Depends-on): Likewise.
* modules/system-quote-tests (Depends-on): Likewise.
* modules/uniname/uniname-tests (Depends-on): Likewise.
* modules/uninorm/nfc-tests (Depends-on): Likewise.
* modules/uninorm/nfd-tests (Depends-on): Likewise.
* modules/uninorm/nfkc-tests (Depends-on): Likewise.
* modules/uninorm/nfkd-tests (Depends-on): Likewise.
* modules/unistdio/u16-vsnprintf-tests (Depends-on): Likewise.
* modules/unistdio/u16-vsprintf-tests (Depends-on): Likewise.
* modules/unistdio/u32-vsnprintf-tests (Depends-on): Likewise.
* modules/unistdio/u32-vsprintf-tests (Depends-on): Likewise.
* modules/unistdio/u8-vsnprintf-tests (Depends-on): Likewise.
* modules/unistdio/u8-vsprintf-tests (Depends-on): Likewise.
* modules/unistdio/ulc-vsnprintf-tests (Depends-on): Likewise.
* modules/unistdio/ulc-vsprintf-tests (Depends-on): Likewise.
* modules/unlinkat-tests (Depends-on): Likewise.
* modules/version-etc-tests (Depends-on): Likewise.
* modules/xalloc-die-tests (Depends-on): Likewise.
* modules/xmemdup0-tests (Depends-on): Likewise.
* modules/xprintf-posix-tests (Depends-on): Likewise.
* modules/xvasprintf-tests (Depends-on): Likewise.
* tests/test-argmatch.c: Do not include progname.h.
(main) Stop calling set_program_name.
* tests/test-argp-version-etc.c: Likewise.
* tests/test-argp.c: Likewise.
* tests/test-argv-iter.c: Likewise.
* tests/test-array_list.c: Likewise.
* tests/test-array_oset.c: Likewise.
* tests/test-avltree_list.c: Likewise.
* tests/test-avltree_oset.c: Likewise.
* tests/test-avltreehash_list.c: Likewise.
* tests/test-carray_list.c: Likewise.
* tests/test-copy-acl.c: Likewise.
* tests/test-copy-file.c: Likewise.
* tests/test-exclude.c: Likewise.
* tests/test-fchownat.c: Likewise.
* tests/test-fdopendir.c: Likewise.
* tests/test-filenamecat.c: Likewise.
* tests/test-fstatat.c: Likewise.
* tests/test-fstrcmp.c: Likewise.
* tests/test-linked_list.c: Likewise.
* tests/test-linkedhash_list.c: Likewise.
* tests/test-mkdirat.c: Likewise.
* tests/test-nonblocking-pipe-main.c: Likewise.
* tests/test-nonblocking-socket-main.c: Likewise.
* tests/test-obstack-printf.c: Likewise.
* tests/test-openat.c: Likewise.
* tests/test-parse-datetime.c: Likewise.
* tests/test-pipe-filter-gi1.c: Likewise.
* tests/test-pipe-filter-gi2-main.c: Likewise.
* tests/test-pipe-filter-ii1.c: Likewise.
* tests/test-pipe-filter-ii2-main.c: Likewise.
* tests/test-quotearg-simple.c: Likewise.
* tests/test-quotearg.c: Likewise.
* tests/test-rbtree_list.c: Likewise.
* tests/test-rbtree_oset.c: Likewise.
* tests/test-rbtreehash_list.c: Likewise.
* tests/test-sameacls.c: Likewise.
* tests/test-set-mode-acl.c: Likewise.
* tests/test-spawn-pipe-main.c: Likewise.
* tests/test-system-quote-main.c: Likewise.
* tests/test-unlinkat.c: Likewise.
* tests/test-version-etc.c: Likewise.
* tests/test-xalloc-die.c: Likewise.
* tests/test-xfprintf-posix.c: Likewise.
* tests/test-xmemdup0.c: Likewise.
* tests/test-xprintf-posix.c: Likewise.
* tests/test-xvasprintf.c: Likewise.
* tests/uniname/test-uninames.c: Likewise.
* tests/uninorm/test-u32-nfc-big.c: Likewise.
* tests/uninorm/test-u32-nfd-big.c: Likewise.
* tests/uninorm/test-u32-nfkc-big.c: Likewise.
* tests/uninorm/test-u32-nfkd-big.

[PATCH 2/4] Port modules to use getprogname explicitly

2016-03-29 Thread Pino Toscano
... instead of requiring progname to be used (or program_name to be
provided).
* lib/argmatch.c: Do not include progname.h.
[TEST] (program_name): Do not define.
[TEST] (main): Call getprogname instead of using program_name.
* lib/c-stack.c: Do not include progname.h.
(program_name): Do not define.
(die): Call getprogname instead of using program_name.
* lib/chdir-long.c: Do not include progname.h.
[TEST_CHDIR] (main): Do not set program_name.
* lib/error.c [!_LIBC]: Include progname.h.
[!_LIBC] (program_name): Define using getprogname.
* lib/euidaccess.c: Do not include progname.h.
[TEST] (main): Do not set program_name.
* lib/git-merge-changelog.c: Include getprogname.h instead of
progname.h.
(usage): Call getprogname instead of using program_name.
(main): Likewise.  Stop calling set_program_name.
* lib/group-member.c: Do not include progname.h.
[TEST] (main): Do not set program_name.
* modules/argmatch (Depends-on): Add getprogname.
* modules/c-stack (Depends-on): Likewise.
* modules/error (Depends-on): Likewise.
* modules/git-merge-changelog (Depends-on): Likewise.
Also remove progname.
---
 ChangeLog   | 26 ++
 lib/argmatch.c  | 12 +++-
 lib/c-stack.c   |  5 ++---
 lib/chdir-long.c|  3 ---
 lib/error.c |  6 +++---
 lib/euidaccess.c|  3 ---
 lib/git-merge-changelog.c   | 11 ---
 lib/group-member.c  |  4 
 modules/argmatch|  1 +
 modules/c-stack |  1 +
 modules/error   |  1 +
 modules/git-merge-changelog |  2 +-
 12 files changed, 42 insertions(+), 33 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index cc37d2a..430d18c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,31 @@
 2016-03-29  Pino Toscano  
 
+   Port modules to use getprogname explicitly, instead of requiring
+   progname to be used (or program_name to be provided).
+   * lib/argmatch.c: Do not include progname.h.
+   [TEST] (program_name): Do not define.
+   [TEST] (main): Call getprogname instead of using program_name.
+   * lib/c-stack.c: Do not include progname.h.
+   (program_name): Do not define.
+   (die): Call getprogname instead of using program_name.
+   * lib/chdir-long.c: Do not include progname.h.
+   [TEST_CHDIR] (main): Do not set program_name.
+   * lib/error.c [!_LIBC]: Include progname.h.
+   [!_LIBC] (program_name): Define using getprogname.
+   * lib/euidaccess.c: Do not include progname.h.
+   [TEST] (main): Do not set program_name.
+   * lib/git-merge-changelog.c: Include getprogname.h instead of
+   progname.h.
+   (usage): Call getprogname instead of using program_name.
+   (main): Likewise.  Stop calling set_program_name.
+   * lib/group-member.c: Do not include progname.h.
+   [TEST] (main): Do not set program_name.
+   * modules/argmatch (Depends-on): Add getprogname.
+   * modules/c-stack (Depends-on): Likewise.
+   * modules/error (Depends-on): Likewise.
+   * modules/git-merge-changelog (Depends-on): Likewise.
+   Also remove progname.
+
getprogname: new module
This provides a LGPL module for getting the name of the current
program, using the same API found on *BSD systems.
diff --git a/lib/argmatch.c b/lib/argmatch.c
index bd1ad71..40a814f 100644
--- a/lib/argmatch.c
+++ b/lib/argmatch.c
@@ -35,6 +35,7 @@
 #include "error.h"
 #include "quotearg.h"
 #include "quote.h"
+#include "getprogname.h"
 
 #if USE_UNLOCKED_IO
 # include "unlocked-io.h"
@@ -206,11 +207,6 @@ argmatch_to_argument (const char *value,
 }
 
 #ifdef TEST
-/*
- * Based on "getversion.c" by David MacKenzie 
- */
-char *program_name;
-
 /* When to make backup files.  */
 enum backup_type
 {
@@ -253,11 +249,9 @@ main (int argc, const char *const *argv)
   const char *cp;
   enum backup_type backup_type = no_backups;
 
-  program_name = (char *) argv[0];
-
   if (argc > 2)
 {
-  fprintf (stderr, "Usage: %s [VERSION_CONTROL]\n", program_name);
+  fprintf (stderr, "Usage: %s [VERSION_CONTROL]\n", getprogname ());
   exit (1);
 }
 
@@ -266,7 +260,7 @@ main (int argc, const char *const *argv)
  backup_args, backup_vals);
 
   if (argc == 2)
-backup_type = XARGMATCH (program_name, argv[1],
+backup_type = XARGMATCH (getprogname (), argv[1],
  backup_args, backup_vals);
 
   printf ("The version control is '%s'\n",
diff --git a/lib/c-stack.c b/lib/c-stack.c
index baace41..5353c08 100644
--- a/lib/c-stack.c
+++ b/lib/c-stack.c
@@ -78,6 +78,7 @@ typedef struct sigaltstack stack_t;
 #include "c-stack.h"
 #include "exitfail.h"
 #include "ignore-value.h"
+#include "getprogname.h"
 
 #if defined SA_ONSTACK && defined SA_SIGINFO
 # define SIGINFO_WORKS 1
@@ -88,8 +89,6 @@ typedef struct sigaltstack stack_t;
 # endif
 #endif
 
-extern char *program_name;
-
 /* The user-specified action to take

[PATCH 4/4] main.mk: remove sc_program_name

2016-03-29 Thread Pino Toscano
There is no more need to use set_program_name in tools (getprogname
is enough for most of the cases).
* cfg.mk (local-checks-to-skip): Remove sc_program_name.
* top/maint.mk (sc_program_name): Remove.
---
 ChangeLog| 6 ++
 cfg.mk   | 1 -
 top/maint.mk | 9 -
 3 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 5277104..7e871c1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2016-03-29  Pino Toscano  
 
+   main.mk: remove sc_program_name, since there is no more need to
+   use set_program_name in tools (getprogname is enough for most
+   of the cases).
+   * cfg.mk (local-checks-to-skip): Remove sc_program_name.
+   * top/maint.mk (sc_program_name): Remove.
+
Port tests away from progname, since modules which need the
program name are using getprogname.
* modules/acl-tests (Depends-on): Remove progname.
diff --git a/cfg.mk b/cfg.mk
index 5b9456b..75d9329 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -27,7 +27,6 @@ local-checks-to-skip =\
   sc_makefile_at_at_check  \
   sc_makefile_path_separator_check \
   sc_obsolete_symbols  \
-  sc_program_name  \
   sc_prohibit_HAVE_MBRTOWC \
   sc_prohibit_S_IS_definition  \
   sc_prohibit_always_true_header_tests \
diff --git a/top/maint.mk b/top/maint.mk
index 9470328..5ba6447 100644
--- a/top/maint.mk
+++ b/top/maint.mk
@@ -709,15 +709,6 @@ sc_changelog:
  $(_sc_search_regexp)
 
 # Ensure that each .c file containing a "main" function also
-# calls set_program_name.
-sc_program_name:
-   @require='set_program_name *\(.*\);'\
-   in_vc_files='\.c$$' \
-   containing='\

[PATCH 0/4] New getprogname module

2016-03-29 Thread Pino Toscano
Hi,

as discussed in [1], this series adds a new getprogname module.
All it does is providing a getprogname function, much like what is
found on e.g. *BSD systems, and using it in gnulib instead of progname.
Also, using it explicitly by modules avoids gnulib users the need of
either use the progname module (GPL), or to provide program_name (and
call set_program_name manually, which is not always doable).

Caveat: the progname is left as it is, so set_program_name will still
affect program_name but not what error will use.

(Please note it's my first big patch to gnulib, so bear with me for
anything wrong/missing.)

[1] http://lists.gnu.org/archive/html/bug-gnulib/2016-03/msg00048.html


Pino Toscano (4):
  getprogname: new module
  Port modules to use getprogname explicitly
  Port tests away from progname
  main.mk: remove sc_program_name

 ChangeLog| 162 +++
 cfg.mk   |   1 -
 lib/argmatch.c   |  12 +--
 lib/c-stack.c|   5 +-
 lib/chdir-long.c |   3 -
 lib/error.c  |   6 +-
 lib/euidaccess.c |   3 -
 lib/getprogname.c|  45 ++
 lib/getprogname.h|  34 
 lib/git-merge-changelog.c|  11 +--
 lib/group-member.c   |   4 -
 m4/getprogname.m4|  13 +++
 modules/acl-tests|   1 -
 modules/argmatch-tests   |   1 -
 modules/argp-tests   |   1 -
 modules/argp-version-etc-tests   |   1 -
 modules/array-list-tests |   1 -
 modules/array-oset-tests |   1 -
 modules/avltree-list-tests   |   1 -
 modules/avltree-oset-tests   |   1 -
 modules/avltreehash-list-tests   |   1 -
 modules/c-stack  |   1 +
 modules/carray-list-tests|   1 -
 modules/copy-file-tests  |   1 -
 modules/error|   1 +
 modules/exclude-tests|   1 -
 modules/fchownat-tests   |   1 -
 modules/fdopendir-tests  |   1 -
 modules/filenamecat-tests|   1 -
 modules/fstatat-tests|   1 -
 modules/fstrcmp-tests|   1 -
 modules/getprogname  |  28 ++
 modules/git-merge-changelog  |   2 +-
 modules/linked-list-tests|   1 -
 modules/linkedhash-list-tests|   1 -
 modules/mkdirat-tests|   1 -
 modules/nonblocking-pipe-tests   |   1 -
 modules/nonblocking-socket-tests |   1 -
 modules/obstack-printf-tests |   1 -
 modules/openat-tests |   1 -
 modules/parse-datetime-tests |   1 -
 modules/pipe-filter-gi-tests |   1 -
 modules/pipe-filter-ii-tests |   1 -
 modules/quotearg-simple-tests|   1 -
 modules/quotearg-tests   |   1 -
 modules/rbtree-list-tests|   1 -
 modules/rbtree-oset-tests|   1 -
 modules/rbtreehash-list-tests|   1 -
 modules/spawn-pipe-tests |   1 -
 modules/system-quote-tests   |   1 -
 modules/uniname/uniname-tests|   1 -
 modules/uninorm/nfc-tests|   1 -
 modules/uninorm/nfd-tests|   1 -
 modules/uninorm/nfkc-tests   |   1 -
 modules/uninorm/nfkd-tests   |   1 -
 modules/unistdio/u16-vsnprintf-tests |   1 -
 modules/unistdio/u16-vsprintf-tests  |   1 -
 modules/unistdio/u32-vsnprintf-tests |   1 -
 modules/unistdio/u32-vsprintf-tests  |   1 -
 modules/unistdio/u8-vsnprintf-tests  |   1 -
 modules/unistdio/u8-vsprintf-tests   |   1 -
 modules/unistdio/ulc-vsnprintf-tests |   1 -
 modules/unistdio/ulc-vsprintf-tests  |   1 -
 modules/unlinkat-tests   |   1 -
 modules/version-etc-tests|   1 -
 modules/xalloc-die-tests |   1 -
 modules/xmemdup0-tests   |   1 -
 modules/xprintf-posix-tests  |   1 -
 modules/xvasprintf-tests |   1 -
 tests/test-argmatch.c|   3 -
 tests/test-argp-version-etc.c|   2 -
 tests/test-argp.c|   3 -
 tests/test-argv-iter.c   |   1 -
 tests/test-array_list.c  |   3 -
 tests/test-array_oset.c  |   3 -
 tests/test-avltree_list.c|   3 -
 tests/test-avltree_oset.c|   3 -
 tests/test-avltreehash_list.c|   3 -
 tests/test-c-stack.c |   3 -
 tests/test-carray_list.c |   3 -
 tests/test-closein.c |   3 -
 tests/test-copy-acl.c|   3 -
 tests/test-copy-file.c   |   3 -
 tests/test-exclude.c |   3 -
 tests/test-fchownat.c|   3 -
 tests/test-fdopendir.c   |   3 -
 tests/test-filenamecat.c |   3 -
 tests/test-fstatat.c |   3 -
 tests/test-fstrcmp.c  

[PATCH 1/4] getprogname: new module

2016-03-29 Thread Pino Toscano
This provides a LGPL module for getting the name of the current
program, using the same API found on *BSD systems.
* lib/getprogname.c, lib/getprogname.h, m4/getprogname.m4:
* modules/getprogname: New files.
---
 ChangeLog   |  8 
 lib/getprogname.c   | 45 +
 lib/getprogname.h   | 34 ++
 m4/getprogname.m4   | 13 +
 modules/getprogname | 28 
 5 files changed, 128 insertions(+)
 create mode 100644 lib/getprogname.c
 create mode 100644 lib/getprogname.h
 create mode 100644 m4/getprogname.m4
 create mode 100644 modules/getprogname

diff --git a/ChangeLog b/ChangeLog
index ca6c36b..cc37d2a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2016-03-29  Pino Toscano  
+
+   getprogname: new module
+   This provides a LGPL module for getting the name of the current
+   program, using the same API found on *BSD systems.
+   * lib/getprogname.c, lib/getprogname.h, m4/getprogname.m4:
+* modules/getprogname: New files.
+
 2016-03-25  Paul Eggert  
 
test-framework-sh: minor cleanups
diff --git a/lib/getprogname.c b/lib/getprogname.c
new file mode 100644
index 000..ab26283
--- /dev/null
+++ b/lib/getprogname.c
@@ -0,0 +1,45 @@
+/* Program name management.
+   Copyright (C) 2016 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see .  */
+
+#include 
+
+/* Specification.  */
+#include "getprogname.h"
+
+#include  /* get program_invocation_name declaration */
+#include 
+
+
+#ifndef HAVE_GETPROGNAME
+const char *
+getprogname (void)
+{
+#if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
+  return program_invocation_short_name;
+#elif HAVE_DECL_PROGRAM_INVOCATION_NAME
+  const char *base = program_invocation_name;
+  const char *slash;
+
+  slash = strrchr (base, '/');
+  if (slash != NULL)
+base = slash + 1;
+
+  return base;
+#else
+ #error "getprogname module not ported to this OS"
+#endif
+}
+#endif
diff --git a/lib/getprogname.h b/lib/getprogname.h
new file mode 100644
index 000..b21e423
--- /dev/null
+++ b/lib/getprogname.h
@@ -0,0 +1,34 @@
+/* Program name management.
+   Copyright (C) 2016 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see .  */
+
+#ifndef _GL_GETPROGNAME_H
+#define _GL_GETPROGNAME_H
+
+#include 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef HAVE_GETPROGNAME
+extern const char *getprogname (void);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/m4/getprogname.m4 b/m4/getprogname.m4
new file mode 100644
index 000..3d30550
--- /dev/null
+++ b/m4/getprogname.m4
@@ -0,0 +1,13 @@
+# getprogname.m4 - check for getprogname or replacements for it
+
+# Copyright (C) 2016 Free Software Foundation, Inc.
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 1
+
+AC_DEFUN([gl_FUNC_GETPROGNAME],
+[
+  AC_CHECK_FUNCS_ONCE([getprogname])
+])
diff --git a/modules/getprogname b/modules/getprogname
new file mode 100644
index 000..efda4fa
--- /dev/null
+++ b/modules/getprogname
@@ -0,0 +1,28 @@
+Description:
+Program name management.
+
+Files:
+lib/getprogname.h
+lib/getprogname.c
+m4/getprogname.m4
+
+Depends-on:
+extensions
+
+configure.ac:
+gl_FUNC_GETPROGNAME
+AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+AC_CHECK_DECLS([program_invocation_name], [], [], [#include ])
+AC_CHECK_DECLS([program_invocation_short_name], [], [], [#include ])
+
+Makefile.am:
+lib_SOURCES += getprogname.h getprogname.c
+
+Include:
+"getprogname.h"
+
+License:
+LGPL
+
+Maintainer:
+All
-- 
2.5.5




Re: Problem with sys_select on Cygwin

2016-03-29 Thread Ken Brown

On 3/21/2016 6:47 PM, Eric Blake wrote:

On 03/21/2016 03:43 PM, Ken Brown wrote:

On 3/21/2016 1:32 PM, Paul Eggert wrote:

Eric Blake wrote:

This feels a bit too broad - it assumes that everyone is compiling with
ONLY the latest newlib headers; remember, the cygwin header changes have
NOT been released yet, but are in beta testing to see what else needs to
change at the same time as the cygwin release.


As far as I know the current version should work OK with older Cygwin,
as the affected #includes are needed only for non-Cygwin systems.


I think that's right.


Okay, I can be convinced on that point.



There's still the question raised by Corinna (on the Cygwin mailing list) as to 
whether we should be testing for __NEWLIB__ rather than __CYGWIN__.  I'm 
inclined to say yes, just for the sake of clarity, since the headers in 
question come from newlib.  In other words, I would suggest the following, if 
Eric agrees:




@@ -102,10 +102,10 @@

  /* Get definition of 'sigset_t'.
 But avoid namespace pollution on glibc systems and "unknown type
-   name" problems on Cygwin.
+   name" problems on newlib systems..


No double '..'; and maybe the comment could say "newlib systems,
including Cygwin", since that is our most common newlib system.

Otherwise, I'm okay with the change.


Could someone install this change (assuming there's no objection)?

Thanks.

Ken




Re: Problem with sys_select on Cygwin

2016-03-29 Thread Paul Eggert

On 03/29/2016 07:00 AM, Ken Brown wrote:

-   name" problems on Cygwin.
+   name" problems on newlib systems..


No double '..'; and maybe the comment could say "newlib systems,
including Cygwin", since that is our most common newlib system.

Otherwise, I'm okay with the change.


Could someone install this change (assuming there's no objection)? 


The ifdef says 'defined __CYGWIN__' and this matches the comment. All 
other Gnulib comments talk about Cygwin not newlib, and it'd be 
confusing to make a special distinction only here.


I suppose that if this code is newlib-specific, not Cygwin-specific, it 
should use 'defined __NEWLIB__' and then the comment should be changed 
as you suggest. But in that case, what other uses of __CYGWIN__ should 
be changed to __NEWLIB__? There are quite a few uses of __CYGWIN__, and 
I don't know which of them apply just to Cygwin and which apply to 
newlib in general.




Re: Problem with sys_select on Cygwin

2016-03-29 Thread Ken Brown

On 3/29/2016 9:10 PM, Paul Eggert wrote:

On 03/29/2016 07:00 AM, Ken Brown wrote:

-   name" problems on Cygwin.
+   name" problems on newlib systems..


No double '..'; and maybe the comment could say "newlib systems,
including Cygwin", since that is our most common newlib system.

Otherwise, I'm okay with the change.


Could someone install this change (assuming there's no objection)?


The ifdef says 'defined __CYGWIN__' and this matches the comment. All
other Gnulib comments talk about Cygwin not newlib, and it'd be
confusing to make a special distinction only here.

I suppose that if this code is newlib-specific, not Cygwin-specific, it
should use 'defined __NEWLIB__' and then the comment should be changed
as you suggest.


I already did change it to 'defined __NEWLIB__' in the patch that I 
suggested 
(http://lists.gnu.org/archive/html/bug-gnulib/2016-03/msg00065.html). 
It wasn't just a change in the comment.



But in that case, what other uses of __CYGWIN__ should
be changed to __NEWLIB__? There are quite a few uses of __CYGWIN__, and
I don't know which of them apply just to Cygwin and which apply to
newlib in general.


Yes, I thought of that too.  Someone would have to look at each of them 
and decide if they apply to newlib in general.  I would be willing to 
take a shot at this.  But I would do it as I have time, not necessarily 
all at once.  Would you rather wait until I've finished this and then 
install all the changes at once?


Ken



Re: Problem with sys_select on Cygwin

2016-03-29 Thread Paul Eggert

Ken Brown wrote:

Yes, I thought of that too.  Someone would have to look at each of them and
decide if they apply to newlib in general.  I would be willing to take a shot at
this.  But I would do it as I have time, not necessarily all at once.  Would you
rather wait until I've finished this and then install all the changes at once?


Yes, thanks, I think that'd be better.  It doesn't appear to be urgent.