argp: [!_LIBC]: remove __argp_basename()

Message ID 20220704225108.6nr5573awh4fgjck@yandex.com
State New
Headers
Series argp: [!_LIBC]: remove __argp_basename() |

Checks

Context Check Description
dj/TryBot-apply_patch success Patch applied to master at the time it was sent
dj/TryBot-32bit success Build for i686

Commit Message

Guilherme Janczak July 4, 2022, 10:51 p.m. UTC
  This function was added in commit
f39941e4127085f2120e40ffefc287f8c4a9548a to make argp portable for usage
in gnulib around 19 years ago, but gnulib's current master patches it
out and uses its own solution:
https://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob;f=lib/argp-namefrob.h;h=9c82ac79c215540f986c3e04398edba3ba1b7234;hb=HEAD#l157
https://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob;f=lib/argp-help.c;h=39d71685208ad296fc2c3cb6f8a176d406d41f07;hb=HEAD#l1829
---
 argp/argp-help.c     | 8 --------
 argp/argp-namefrob.h | 2 --
 2 files changed, 10 deletions(-)
  

Comments

Guilherme Janczak July 14, 2022, 5:59 p.m. UTC | #1
Ping.
  
Adhemerval Zanella Netto July 14, 2022, 6:23 p.m. UTC | #2
On 04/07/22 19:51, Guilherme Janczak via Libc-alpha wrote:
> This function was added in commit
> f39941e4127085f2120e40ffefc287f8c4a9548a to make argp portable for usage
> in gnulib around 19 years ago, but gnulib's current master patches it
> out and uses its own solution:
> https://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob;f=lib/argp-namefrob.h;h=9c82ac79c215540f986c3e04398edba3ba1b7234;hb=HEAD#l157
> https://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob;f=lib/argp-help.c;h=39d71685208ad296fc2c3cb6f8a176d406d41f07;hb=HEAD#l1829

Looks ok, what prevents us to just sync with current gnulib version?

> ---
>  argp/argp-help.c     | 8 --------
>  argp/argp-namefrob.h | 2 --
>  2 files changed, 10 deletions(-)
> 
> diff --git a/argp/argp-help.c b/argp/argp-help.c
> index 90a2795cef..c22d09a6cb 100644
> --- a/argp/argp-help.c
> +++ b/argp/argp-help.c
> @@ -1808,19 +1808,11 @@ weak_alias (__argp_help, argp_help)
>  #endif
>  
>  #ifndef _LIBC
> -char *__argp_basename (char *name)
> -{
> -  char *short_name = strrchr (name, '/');
> -  return short_name ? short_name + 1 : name;
> -}
> -
>  char *
>  __argp_short_program_name (void)
>  {
>  # if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
>    return program_invocation_short_name;
> -# elif HAVE_DECL_PROGRAM_INVOCATION_NAME
> -  return __argp_basename (program_invocation_name);
>  # else
>    /* FIXME: What now? Miles suggests that it is better to use NULL,
>       but currently the value is passed on directly to fputs_unlocked,
> diff --git a/argp/argp-namefrob.h b/argp/argp-namefrob.h
> index baed8f1999..c36d741c87 100644
> --- a/argp/argp-namefrob.h
> +++ b/argp/argp-namefrob.h
> @@ -134,8 +134,6 @@
>  # define putchar_unlocked(x) putchar (x)
>  # endif
>  
> -extern char *__argp_basename (char *name);
> -
>  #endif /* !_LIBC */
>  
>  #ifndef __set_errno
  
Guilherme Janczak July 14, 2022, 6:37 p.m. UTC | #3
On Thu, Jul 14, 2022 at 03:23:01PM -0300, Adhemerval Zanella Netto via Libc-alpha wrote:
> Looks ok, what prevents us to just sync with current gnulib version?

Nothing, it's just not the approach I took. I'd like to eventually
migrate to removing the definition of __argp_short_program_name() (the
only place __argp_basename() was used) entirely so downstreams can
provide their own in a separate source file: it's less #ifdef, less
lines of code, and more flexible.

I'm a maintainer on a downstream (argp-standalone) and if all goes well,
I could probably try to sync uClibc-ng which is another downstream.
  
Adhemerval Zanella Netto July 14, 2022, 6:54 p.m. UTC | #4
On 14/07/22 15:37, Guilherme Janczak wrote:
> On Thu, Jul 14, 2022 at 03:23:01PM -0300, Adhemerval Zanella Netto via Libc-alpha wrote:
>> Looks ok, what prevents us to just sync with current gnulib version?
> 
> Nothing, it's just not the approach I took. I'd like to eventually
> migrate to removing the definition of __argp_short_program_name() (the
> only place __argp_basename() was used) entirely so downstreams can
> provide their own in a separate source file: it's less #ifdef, less
> lines of code, and more flexible.
> 
> I'm a maintainer on a downstream (argp-standalone) and if all goes well,
> I could probably try to sync uClibc-ng which is another downstream.

Usually if there is no regression with glibv testcase, the usual approach
is just to snc with gnulib code (with commit message note which commit id
was used).  I wonder if it would better than send unrelated small changes.
  

Patch

diff --git a/argp/argp-help.c b/argp/argp-help.c
index 90a2795cef..c22d09a6cb 100644
--- a/argp/argp-help.c
+++ b/argp/argp-help.c
@@ -1808,19 +1808,11 @@  weak_alias (__argp_help, argp_help)
 #endif
 
 #ifndef _LIBC
-char *__argp_basename (char *name)
-{
-  char *short_name = strrchr (name, '/');
-  return short_name ? short_name + 1 : name;
-}
-
 char *
 __argp_short_program_name (void)
 {
 # if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
   return program_invocation_short_name;
-# elif HAVE_DECL_PROGRAM_INVOCATION_NAME
-  return __argp_basename (program_invocation_name);
 # else
   /* FIXME: What now? Miles suggests that it is better to use NULL,
      but currently the value is passed on directly to fputs_unlocked,
diff --git a/argp/argp-namefrob.h b/argp/argp-namefrob.h
index baed8f1999..c36d741c87 100644
--- a/argp/argp-namefrob.h
+++ b/argp/argp-namefrob.h
@@ -134,8 +134,6 @@ 
 # define putchar_unlocked(x) putchar (x)
 # endif
 
-extern char *__argp_basename (char *name);
-
 #endif /* !_LIBC */
 
 #ifndef __set_errno