cmake: let the argp probe pass where argp-standalone needs strchrnul

On macOS with Homebrew's argp-standalone, Findargp's link test for
argp_parse fails with an undefined strchrnul, because libargp.a itself
references that GNU extension and the platform has none. The module then
stops with "does not have a symbol named argp_parse", which is not what
is wrong.

Probe for strchrnul first (with _GNU_SOURCE, so glibc answers correctly).
Where it exists, the test is unchanged. Where it is missing, run the same
argp_parse test with a local definition of strchrnul, and have ptouch-print
supply that definition for the real build.

On glibc nothing changes: the probe finds strchrnul and the original test
runs. Checked on Debian stable in the same session.
This commit is contained in:
Kevin Bradenstein
2026-09-08 07:16:31 +02:00
committed by Dominic Radermacher
parent 97a9576c6e
commit ef6e6f4925
3 changed files with 40 additions and 1 deletions
+10
View File
@@ -35,6 +35,16 @@
#define _(s) gettext(s)
#ifdef NEED_STRCHRNUL
/* GNU extension. argp-standalone references it, so platforms that need
argp-standalone need this too. Selected by cmake/Findargp.cmake. */
char *strchrnul(const char *s, int c)
{
const char *p = strchr(s, c);
return (char *)(p ? p : s + strlen(s));
}
#endif
#define MAX_LINES 4 /* this should be calculated depending on tape size */
#define P_NAME "ptouch-print"