inline getprogname replacement
authorMichael Tokarev <mjt@tls.msk.ru>
Tue, 20 Jan 2026 19:27:54 +0000 (22:27 +0300)
committerMichael Tokarev <mjt@tls.msk.ru>
Tue, 30 Jun 2026 19:37:50 +0000 (22:37 +0300)
Forwarded: not-needed

Inline getprogname() by using program_invocation_short_name
when available (like with glibc).

This makes a lot of binaries to avoid linkage to libreplace.

This is a short and dirty version, proper change for upstream
should clean up #ifdef'fery in replace.c.

Gbp-Pq: Name inline-getprogname.diff

lib/replace/replace.c
lib/replace/replace.h

index 33cbbec14533dd11e81bceaf6a7e5450d1118cab..b0e1edbdf21f091f7b6f33e639e596deedf26e7c 100644 (file)
@@ -1144,7 +1144,7 @@ void *rep_memset_explicit(void *block, int c, size_t size)
 }
 #endif
 
-#ifndef HAVE_GETPROGNAME
+#if !defined(HAVE_GETPROGNAME) && !defined(HAVE_PROGRAM_INVOCATION_SHORT_NAME)
 # ifndef HAVE_PROGRAM_INVOCATION_SHORT_NAME
 # define PROGNAME_SIZE 32
 static char rep_progname[PROGNAME_SIZE];
index 82eab2a6de5da8d371c8ae7a2f2a1754b550e4de..9937230d9a3d5a295d07f143bc2d3cffad918b69 100644 (file)
@@ -1020,9 +1020,13 @@ void *rep_memset_explicit(void *block, int c, size_t size);
 #endif
 
 #ifndef HAVE_GETPROGNAME
+#ifdef HAVE_PROGRAM_INVOCATION_SHORT_NAME
+# define getprogname() (program_invocation_short_name)
+#else
 #define getprogname rep_getprogname
 const char *rep_getprogname(void);
 #endif
+#endif
 
 #ifndef HAVE_COPY_FILE_RANGE
 #define copy_file_range rep_copy_file_range