From patchwork Tue May 27 16:36:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Vivien Kraus X-Patchwork-Id: 113065 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 84720385274A for ; Tue, 27 May 2025 18:18:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 84720385274A Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=planete-kraus.eu header.i=@planete-kraus.eu header.a=rsa-sha1 header.s=albinoniA header.b=CKei80Dx X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from planete-kraus.eu (planete-kraus.eu [IPv6:2a00:5881:4008:2810::309]) by sourceware.org (Postfix) with ESMTPS id B17BC3857C6C for ; Tue, 27 May 2025 18:17:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B17BC3857C6C Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=planete-kraus.eu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=planete-kraus.eu ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B17BC3857C6C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:5881:4008:2810::309 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1748369862; cv=none; b=cg9G+Tcx0ayOEZ1lCdWnSzOjcJTYSFM84VF74jDFfPd49pmIbkYYJ8IHrI/w1+GI2wmeZpvGJjZxD9RsI8p2MOoHBJS/qf9nivrIshH3oIxAdgRHA4zF4iy9RsqWgtsG6sKge/N0xQLShuA+DIzGDO1zTR9P+sh8+AsCBQLSIwk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1748369862; c=relaxed/simple; bh=XpmstBPBGJll/TH3yVdY7V7DoEmLlDoWuOc3IRpX4Tk=; h=DKIM-Signature:Message-ID:From:Date:Subject:MIME-Version:To; b=woYvQKZ1pub4IRGyhdsFR+4Etw4tDIFGR19n3XCESILOh2SxB79EFIic6oSm/34WDBMhh/okRsnyjg9no/sQfo8bTv72Ig0w0pw6QnyCYdu0tx+GSMEv0ufGWnBbXK36KN/74Xjz1gbatKatzMAvDulBfNBFCQmMCs8gS3WwkVs= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B17BC3857C6C Received: from planete-kraus.eu (localhost [127.0.0.1]) by planete-kraus.eu (OpenSMTPD) with ESMTP id 6b9d2dc0; Tue, 27 May 2025 18:17:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=planete-kraus.eu; h= message-id:from:date:subject:mime-version:content-type :content-transfer-encoding:to:cc; s=albinoniA; bh=VHs3j8lqh/SQgr H/7ifT0DiKF6Y=; b=CKei80Dx4zptcjAuRlbRMyybmebDYpbdBtiPwGqDoo9lI1 dp1BhESn4wTlm1cJ+6a8sd1JjfaixoR1hixRAEBDdpK/kBw5iNOuc0lmVHTivbVg D8O2mrIGG0cYTt2WBiR5N9GKS1HSeUve4M0NRk0PNxCDxFQygpnIfxM3Uy+rOhi/ R/ugcO4jmIXtwYQzHJ4FIRRPDsEf/VgO/6w+p/R3x2faztlwzDb7zdxLzl+TAgg4 3M0J1eLf8CUmp4iftX6bsgd/DJx7AWQVBNi81zPLzRZ8a97CPOUcK2kwmlpqDZnl gmc7DieGT/sYeXTdDlAzXhhh1OTEyR82WbkgdhPg== Received: by planete-kraus.eu (OpenSMTPD) with ESMTPSA id 6abba0af (TLSv1.3:TLS_CHACHA20_POLY1305_SHA256:256:NO); Tue, 27 May 2025 18:17:30 +0000 (UTC) Message-ID: <68a758ae45c064bad35bfec73c3d5ffd050398e3.1748369494.git.vivien@planete-kraus.eu> From: Vivien Kraus Date: Tue, 27 May 2025 18:36:54 +0200 Subject: [PATCH] getopt: Allow getopt_long to match translated option names MIME-Version: 1.0 To: libc-alpha@sourceware.org Cc: bug-standards@gnu.org User-Agent: Evolution 3.54.3 X-Spam-Status: No, score=-13.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, PROLO_LEO1, SCC_10_SHORT_WORD_LINES, SCC_20_SHORT_WORD_LINES, SCC_5_SHORT_WORD_LINES, SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org It is possible to support translated long option names in a program by adding new option records with the translated names in the options array. However, it is significant work for all packages. More importantly, some higher-level systems such as autoopts or guile’s (ice-9 getopt-long) support required options, i.e. option that must be set in the command-line. Developers who want to have translated option names cannot use these systems. The discussion was started on bug-standards and support in glibc may be desirable [1]. With this change, getopt will try and match both the name of each option and its translation. Abbreviations will only match the untranslated names. This change would be better if it could match translated option names by calling pgettext instead of gettext, but as far as I understand, pgettext is not available in libintl. A potential drawback is that translator should be careful not to use a perfect homonym for another long option name. [1]: https://lists.gnu.org/archive/html/bug-standards/2025-05/msg00000.html Sign-off-by: Vivien Kraus --- Dear Glibc developers, This patch tries to implement support for translated long option names in getopt. I hope it is not too controversial, though I expect the work to achieve this will involve more discussion than code. I started by first contacting the GNU Coding Standards for advice, and it seems that recognizing both translated option names and non-translated option names could keep a stable interface for scripts calling programs, as well as providing better user interface. This is my first contribution to glibc. Best regards, Vivien manual/getopt.texi | 16 ++-- posix/Makefile | 2 + posix/getopt.c | 52 ++++++++--- posix/tstgetoptl.c | 211 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 265 insertions(+), 16 deletions(-) create mode 100644 posix/tstgetoptl.c base-commit: 08d7243a6179d5a1f3f65a53aba1ec0803895aeb diff --git a/manual/getopt.texi b/manual/getopt.texi index 79a942307c..d70959e1fe 100644 --- a/manual/getopt.texi +++ b/manual/getopt.texi @@ -213,7 +213,9 @@ The @code{struct option} structure has these fields: @table @code @item const char *name -This field is the name of the option. It is a string. +This field is the name of the option. It is a string. In order for +@command{getopt_long} to accept either the long option name or its +translated form, you should mark this string for translation. @item int has_arg This field says whether the option takes an argument. It is an integer, @@ -248,10 +250,14 @@ When @code{getopt_long} encounters a short option, it does the same thing that @code{getopt} would do: it returns the character code for the option, and stores the option's argument (if it has one) in @code{optarg}. -When @code{getopt_long} encounters a long option, it takes actions based -on the @code{flag} and @code{val} fields of the definition of that -option. The option name may be abbreviated as long as the abbreviation is -unique. +When @code{getopt_long} encounters a long option or its translation in +the current textdomain, it takes actions based on the @code{flag} and +@code{val} fields of the definition of that option. The translation +for the long option name is retrieved via @code{gettext}. Due to the +lack of support for contexts in libintl, it is unfortunately not +possible to use @code{pgettext}. The english name of the option name +may be abbreviated as long as the abbreviation is unique. No +abbreviation of the translated option name is recognized. If @code{flag} is a null pointer, then @code{getopt_long} returns the contents of @code{val} to indicate which option it found. You should diff --git a/posix/Makefile b/posix/Makefile index c0e224236a..d1f99dc2d2 100644 --- a/posix/Makefile +++ b/posix/Makefile @@ -327,6 +327,7 @@ tests := \ tst-waitid \ tst-wordexp-nocmd \ tstgetopt \ + tstgetoptl \ # tests # Test for the glob symbol version that was replaced in glibc 2.27. @@ -599,6 +600,7 @@ CFLAGS-fork.c = $(libio-mtsafe) $(config-cflags-wno-ignored-attributes) tstgetopt-ARGS = -a -b -cfoobar --required foobar --optional=bazbug \ --none random --col --color --colour +tstgetoptl-ARGS = $(tstgetopt-ARGS) tst-exec-ARGS = -- $(host-test-program-cmd) tst-exec-static-ARGS = $(tst-exec-ARGS) diff --git a/posix/getopt.c b/posix/getopt.c index 66b43850ee..ef82b49723 100644 --- a/posix/getopt.c +++ b/posix/getopt.c @@ -208,10 +208,13 @@ process_long_option (int argc, char **argv, const char *optstring, namelen = nameend - d->__nextchar; /* First look for an exact match, counting the options as a side - effect. */ + effect. Translated long option names can be matched. */ for (p = longopts, n_options = 0; p->name; p++, n_options++) - if (!strncmp (p->name, d->__nextchar, namelen) - && namelen == strlen (p->name)) + if ((!strncmp (p->name, d->__nextchar, namelen) + && namelen == strlen (p->name)) + /* FIXME: use pgettext instead of gettext. */ + || (!strncmp (gettext (p->name), d->__nextchar, namelen) + && namelen == strlen (gettext (p->name)))) { /* Exact match found. */ pfound = p; @@ -221,7 +224,8 @@ process_long_option (int argc, char **argv, const char *optstring, if (pfound == NULL) { - /* Didn't find an exact match, so look for abbreviations. */ + /* Didn't find an exact match, so look for abbreviations, but + only for the option name in the C locale. */ unsigned char *ambig_set = NULL; int ambig_malloced = 0; int ambig_fallback = 0; @@ -341,10 +345,23 @@ process_long_option (int argc, char **argv, const char *optstring, else { if (print_errors) - fprintf (stderr, - _("%s: option '%s%s' doesn't allow an argument\n"), - argv[0], prefix, pfound->name); - + { + if (strcmp (gettext (pfound->name), pfound->name) != 0) + { + /* Print both names of the option. */ + fprintf (stderr, + _("%s: option '%s%s' / '%s%s' doesn't allow an argument\n"), + argv[0], prefix, gettext (pfound->name), prefix, pfound->name); + } + else + { + /* Either the option name is not translated, or its + translation is the same as the option name. */ + fprintf (stderr, + _("%s: option '%s%s' doesn't allow an argument\n"), + argv[0], prefix, pfound->name); + } + } d->optopt = pfound->val; return '?'; } @@ -356,9 +373,22 @@ process_long_option (int argc, char **argv, const char *optstring, else { if (print_errors) - fprintf (stderr, - _("%s: option '%s%s' requires an argument\n"), - argv[0], prefix, pfound->name); + { + /* Same dichotomy as when the option does not allow an + argument. */ + if (strcmp (gettext (pfound->name), pfound->name) != 0) + { + fprintf (stderr, + _("%s: option '%s%s' / '%s%s' requires an argument\n"), + argv[0], prefix, gettext (pfound->name), prefix, pfound->name); + } + else + { + fprintf (stderr, + _("%s: option '%s%s' requires an argument\n"), + argv[0], prefix, pfound->name); + } + } d->optopt = pfound->val; return optstring[0] == ':' ? ':' : '?'; diff --git a/posix/tstgetoptl.c b/posix/tstgetoptl.c new file mode 100644 index 0000000000..f37dea11cd --- /dev/null +++ b/posix/tstgetoptl.c @@ -0,0 +1,211 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +/* This is a modified copy of tstgetopt.c, but instead of having two + different options with the same short name, it has only one, and + the other one is a translation. */ + +/* FIXME: it would be better to use pgettext, but libintl does not + have it. */ + +/* This uses the en_GB locale so that colour means color. The PO file + is: + +# English translations for tstgetoptl. +# Copyright (C) 2025 THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the glibc package. +# Vivien Kraus , 2025. +# +msgid "" +msgstr "" +"Project-Id-Version: tstgetoptl 0.0.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-05-27 19:29+0200\n" +"PO-Revision-Date: 2025-05-27 19:30+0200\n" +"Last-Translator: Vivien Kraus \n" +"Language-Team: English (British) <(nothing)>\n" +"Language: en_GB\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=ASCII\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: xxx.c:yy +msgid "color" +msgstr "colour" +*/ + +// I got the MO file content by doing: +// hexdump -C en_GB.mo | cut -b 10-58 | sed 's/ */\\x/g' + +static const char *mo_file_content = "" + "\xde\x12\x04\x95\x00\x00\x00\x00\x02\x00\x00\x00\x1c\x00\x00\x00" + "\x2c\x00\x00\x00\x05\x00\x00\x00\x3c\x00\x00\x00\x00\x00\x00\x00" + "\x50\x00\x00\x00\x05\x00\x00\x00\x51\x00\x00\x00\x5e\x01\x00\x00" + "\x57\x00\x00\x00\x06\x00\x00\x00\xb6\x01\x00\x00\x01\x00\x00\x00" + "\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00" + "\x00\x63\x6f\x6c\x6f\x72\x00\x50\x72\x6f\x6a\x65\x63\x74\x2d\x49" + "\x64\x2d\x56\x65\x72\x73\x69\x6f\x6e\x3a\x20\x74\x73\x74\x67\x65" + "\x74\x6f\x70\x74\x6c\x20\x30\x2e\x30\x2e\x30\x0a\x52\x65\x70\x6f" + "\x72\x74\x2d\x4d\x73\x67\x69\x64\x2d\x42\x75\x67\x73\x2d\x54\x6f" + "\x3a\x20\x0a\x50\x4f\x2d\x52\x65\x76\x69\x73\x69\x6f\x6e\x2d\x44" + "\x61\x74\x65\x3a\x20\x32\x30\x32\x35\x2d\x30\x35\x2d\x32\x37\x20" + "\x31\x39\x3a\x33\x30\x2b\x30\x32\x30\x30\x0a\x4c\x61\x73\x74\x2d" + "\x54\x72\x61\x6e\x73\x6c\x61\x74\x6f\x72\x3a\x20\x56\x69\x76\x69" + "\x65\x6e\x20\x4b\x72\x61\x75\x73\x20\x3c\x76\x69\x76\x69\x65\x6e" + "\x40\x70\x6c\x61\x6e\x65\x74\x65\x2d\x6b\x72\x61\x75\x73\x2e\x65" + "\x75\x3e\x0a\x4c\x61\x6e\x67\x75\x61\x67\x65\x2d\x54\x65\x61\x6d" + "\x3a\x20\x45\x6e\x67\x6c\x69\x73\x68\x20\x28\x42\x72\x69\x74\x69" + "\x73\x68\x29\x20\x3c\x28\x6e\x6f\x74\x68\x69\x6e\x67\x29\x3e\x0a" + "\x4c\x61\x6e\x67\x75\x61\x67\x65\x3a\x20\x65\x6e\x5f\x47\x42\x0a" + "\x4d\x49\x4d\x45\x2d\x56\x65\x72\x73\x69\x6f\x6e\x3a\x20\x31\x2e" + "\x30\x0a\x43\x6f\x6e\x74\x65\x6e\x74\x2d\x54\x79\x70\x65\x3a\x20" + "\x74\x65\x78\x74\x2f\x70\x6c\x61\x69\x6e\x3b\x20\x63\x68\x61\x72" + "\x73\x65\x74\x3d\x41\x53\x43\x49\x49\x0a\x43\x6f\x6e\x74\x65\x6e" + "\x74\x2d\x54\x72\x61\x6e\x73\x66\x65\x72\x2d\x45\x6e\x63\x6f\x64" + "\x69\x6e\x67\x3a\x20\x38\x62\x69\x74\x0a\x50\x6c\x75\x72\x61\x6c" + "\x2d\x46\x6f\x72\x6d\x73\x3a\x20\x6e\x70\x6c\x75\x72\x61\x6c\x73" + "\x3d\x32\x3b\x20\x70\x6c\x75\x72\x61\x6c\x3d\x28\x6e\x20\x21\x3d" + "\x20\x31\x29\x3b\x0a\x00\x63\x6f\x6c\x6f\x75\x72\x00"; + +static const size_t mo_file_size = 445; + +/* FIXME: create the tstgetoptl-localedir in the build directory. */ + +static void +cleanup_localedir (void) +{ + remove ("tstgetoptl-localedir/en_GB/LC_MESSAGES/tstgetoptl.mo"); + remove ("tstgetoptl-localedir/en_GB/LC_MESSAGES"); + remove ("tstgetoptl-localedir/en_GB"); + remove ("tstgetoptl-localedir"); +} + +static int +prepare_localedir (void) +{ + cleanup_localedir (); + if (mkdir ("tstgetoptl-localedir", S_IRWXU) != 0 + || mkdir ("tstgetoptl-localedir/en_GB", S_IRWXU) != 0 + || mkdir ("tstgetoptl-localedir/en_GB/LC_MESSAGES", S_IRWXU) != 0) + { + fputs ("Cannot initialize the localedir.\n", stderr); + return -1; + } + FILE *mo_file = fopen ("tstgetoptl-localedir/en_GB/LC_MESSAGES/tstgetoptl.mo", "wb"); + if (mo_file == NULL) + { + fputs ("Cannot create the mo file.\n", stderr); + return -1; + } + if (fwrite (mo_file_content, 1, mo_file_size, mo_file) != mo_file_size) + { + fputs ("Cannot write the mo file.\n", stderr); + fclose (mo_file); + return -1; + } + fclose (mo_file); + unsetenv ("LANGUAGE"); + setlocale (LC_ALL, "en_GB.UTF-8"); + if (bindtextdomain ("tstgetoptl", "tstgetoptl-localedir") == NULL) + { + fputs ("Cannot call bindtextdomain.\n", stderr); + return -1; + } + if (textdomain ("tstgetoptl") == NULL) + { + fputs ("Cannot call textdomain.\n", stderr); + return -1; + } + /* Check that the catalog is OK: */ + if (strcmp (gettext ("color"), "colour") != 0) + { + fputs ("The mo file does not work.\n", stderr); + return -1; + } + return 0; +} + +int +main (int argc, char **argv) +{ + static const struct option options[] = + { + {"required", required_argument, NULL, 'r'}, + {"optional", optional_argument, NULL, 'o'}, + {"none", no_argument, NULL, 'n'}, + {"color", no_argument, NULL, 'C'}, + /* Now colour is handled as a translation of color */ + {NULL, 0, NULL, 0 } + }; + + int aflag = 0; + int bflag = 0; + char *cvalue = NULL; + int Cflag = 0; + int nflag = 0; + int index; + int c; + int result = 0; + + if (prepare_localedir () != 0) + { + fputs ("Error while setting up localedir.\n", stderr); + return 1; + } + while ((c = getopt_long (argc, argv, "abc:", options, NULL)) >= 0) + switch (c) + { + case 'a': + aflag = 1; + break; + case 'b': + bflag = 1; + break; + case 'c': + cvalue = optarg; + break; + case 'C': + ++Cflag; + break; + case '?': + fputs ("Unknown option.\n", stderr); + return 1; + default: + fprintf (stderr, "This should never happen!\n"); + return 1; + + case 'r': + printf ("--required %s\n", optarg); + result |= strcmp (optarg, "foobar") != 0; + break; + case 'o': + printf ("--optional %s\n", optarg); + result |= optarg == NULL || strcmp (optarg, "bazbug") != 0; + break; + case 'n': + puts ("--none"); + nflag = 1; + break; + } + + printf ("aflag = %d, bflag = %d, cvalue = %s, Cflags = %d, nflag = %d\n", + aflag, bflag, cvalue, Cflag, nflag); + + result |= (aflag != 1 || bflag != 1 || cvalue == NULL + || strcmp (cvalue, "foobar") != 0 || Cflag != 3 || nflag != 1); + + for (index = optind; index < argc; index++) + printf ("Non-option argument %s\n", argv[index]); + + result |= optind + 1 != argc || strcmp (argv[optind], "random") != 0; + + cleanup_localedir (); + return result; +} From patchwork Sun Nov 23 17:07:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivien Kraus X-Patchwork-Id: 125090 X-Patchwork-Delegate: azanella@linux.vnet.ibm.com Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8B7E93858425 for ; Sun, 23 Nov 2025 17:11:32 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from planete-kraus.eu (planete-kraus.eu [89.234.140.182]) by sourceware.org (Postfix) with ESMTPS id C24B53858C62 for ; Sun, 23 Nov 2025 17:10:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C24B53858C62 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=planete-kraus.eu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=planete-kraus.eu ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C24B53858C62 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=89.234.140.182 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1763917810; cv=none; b=ZksLXK8k1emODLnu+YPSqxGV1zHEm74M00E65jC48O96metqYodS5bNZb1uYk++OhnZvwkLZYZCu5Cs3U5SgSy1uEBPah3jnJoajU4Op36teq8ul3PDpvWl1MjG4efqUYuVbDAzhLfK6SkWwC0/YzhPXcN34DHDI7I1Sn8rLFM4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1763917810; c=relaxed/simple; bh=KoULIAE0ps1SblD+r2RPSOVLBafskWYdzoLN6P4gqS4=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=NciiM42MAVUTSoVdzUqbckTUHPG+ieRzy25qupG2Gw/ZaGBEo5EKzESiYvbLtGfqh36clf+s+HksbE90y8uiqLwi1xWa8CkQAaCzMTNtnTi3QNqxLIRZtoojA82I6xV2viDfsgsJkpzkbjoPuG2m6xKkpgJBg+D8EuA7FYQhKT4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C24B53858C62 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=planete-kraus.eu header.i=@planete-kraus.eu header.a=rsa-sha1 header.s=albinoniB header.b=dWt0q0Bv Received: from planete-kraus.eu (localhost [127.0.0.1]) by planete-kraus.eu (OpenSMTPD) with ESMTP id ac4895a2; Sun, 23 Nov 2025 17:10:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=planete-kraus.eu; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=albinoniB; bh=6fVZOvf gLqCzj+EGUXBQzL28Nns=; b=dWt0q0BvVAB2mqOCl2KsjUDypZo2vEqJyxTM6WU GD66/FnFqgvFkaqHDiogM938nzY/GaW0umreUF+CNbjj9Dlz/1vc6NxZNVqy50zD jfDig1KtL4jO2uK3Q748+iNb/5m4Euq1v8wTwcUzQ+XmCzsbNdJ3Y5m4DlSuJ94K 1U5CYrMBTXm8OjJ5hLv0cVPGxyrc7j2G2v8rYQCoVyUTvwkLFuB/85wrgW62Eku+ Hcsz8TEbDtyS6EAlOu+APrm7Hl9mMI22fxXQwy37Bcc/Flats6kskjroTxJsNUth coudi9suNyfjpJ/O1TZi3Zw4ws3F0k+xfBwgiBkFIkv/WWA== Received: by planete-kraus.eu (OpenSMTPD) with ESMTPSA id b930dca6 (TLSv1.3:TLS_CHACHA20_POLY1305_SHA256:256:NO); Sun, 23 Nov 2025 17:09:59 +0000 (UTC) From: Vivien Kraus To: adhemerval.zanella@linaro.org Cc: Vivien Kraus , libc-alpha@sourceware.org Subject: [PATCH v18 04/11] posix: let the getopt caller choose the textdomain for translation Date: Sun, 23 Nov 2025 18:07:31 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: <68a758ae45c064bad35bfec73c3d5ffd050398e3.1748369494.git.vivien@planete-kraus.eu> MIME-Version: 1.0 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org Using the same solution as for the option translation context, a new opttextdomain variable is defined. Note that all options in the call to getopt_long are looked up in the same domain. --- manual/argp.texi | 7 +++-- manual/getopt.texi | 11 +++++-- posix/Versions | 2 +- posix/bits/getopt_ext.h | 5 ++++ posix/getopt.c | 30 ++++++++++++------- posix/getopt1.c | 15 +++++++--- posix/getopt_int.h | 11 ++++--- posix/tstgetoptl.c | 4 ++- sysdeps/mach/hurd/i386/libc.abilist | 1 + sysdeps/mach/hurd/x86_64/libc.abilist | 1 + sysdeps/unix/sysv/linux/aarch64/libc.abilist | 1 + sysdeps/unix/sysv/linux/alpha/libc.abilist | 1 + sysdeps/unix/sysv/linux/arc/libc.abilist | 1 + sysdeps/unix/sysv/linux/arm/be/libc.abilist | 1 + sysdeps/unix/sysv/linux/arm/le/libc.abilist | 1 + sysdeps/unix/sysv/linux/csky/libc.abilist | 1 + sysdeps/unix/sysv/linux/hppa/libc.abilist | 1 + sysdeps/unix/sysv/linux/i386/libc.abilist | 1 + .../sysv/linux/loongarch/lp64/libc.abilist | 1 + .../sysv/linux/m68k/coldfire/libc.abilist | 1 + .../unix/sysv/linux/m68k/m680x0/libc.abilist | 1 + .../sysv/linux/microblaze/be/libc.abilist | 1 + .../sysv/linux/microblaze/le/libc.abilist | 1 + .../sysv/linux/mips/mips32/fpu/libc.abilist | 1 + .../sysv/linux/mips/mips32/nofpu/libc.abilist | 1 + .../sysv/linux/mips/mips64/n32/libc.abilist | 1 + .../sysv/linux/mips/mips64/n64/libc.abilist | 1 + sysdeps/unix/sysv/linux/or1k/libc.abilist | 1 + .../linux/powerpc/powerpc32/fpu/libc.abilist | 1 + .../powerpc/powerpc32/nofpu/libc.abilist | 1 + .../linux/powerpc/powerpc64/be/libc.abilist | 1 + .../linux/powerpc/powerpc64/le/libc.abilist | 1 + .../unix/sysv/linux/riscv/rv32/libc.abilist | 1 + .../unix/sysv/linux/riscv/rv64/libc.abilist | 1 + .../unix/sysv/linux/s390/s390-32/libc.abilist | 1 + .../unix/sysv/linux/s390/s390-64/libc.abilist | 1 + sysdeps/unix/sysv/linux/sh/be/libc.abilist | 1 + sysdeps/unix/sysv/linux/sh/le/libc.abilist | 1 + .../sysv/linux/sparc/sparc32/libc.abilist | 1 + .../sysv/linux/sparc/sparc64/libc.abilist | 1 + .../unix/sysv/linux/x86_64/64/libc.abilist | 1 + .../unix/sysv/linux/x86_64/x32/libc.abilist | 1 + 42 files changed, 94 insertions(+), 25 deletions(-) diff --git a/manual/argp.texi b/manual/argp.texi index 97456ef20e..50d67b6c55 100644 --- a/manual/argp.texi +++ b/manual/argp.texi @@ -208,8 +208,11 @@ messages. @xref{Argp Help Filtering}. If non-zero, the strings used in the argp library are translated using the domain described by this string. If zero, the current default domain is used. The long option names are always translated with the -current default domain, and with the @samp{"command-line option"} -disambiguation string. +current default domain (not this one), and with the +@samp{"command-line option"} disambiguation string. This is because +all the option names, including those defined in sub-parsers, must be +in the same textdomain for @command{getopt} to process the options +correctly. @end table @end deftp diff --git a/manual/getopt.texi b/manual/getopt.texi index 4276c9b5e8..16fa608418 100644 --- a/manual/getopt.texi +++ b/manual/getopt.texi @@ -59,8 +59,15 @@ names in the current textdomain. Since option names may be short words instead of long sentences, they may have different translations in other places of the program. @xref{Contexts, , Using contexts for solving ambiguities, gettext, the GNU Gettext manual}, for more -information. If this is @code{NULL}, then the translated option names -will not be processed. +information. If this is @code{NULL} (the default), then the +translated option names will not be processed. +@end deftypevar + +@deftypevar {const char *} opttextdomain +Option names may be translated in a textdomain that is not currently +the default (@pxref{Interface to gettext, , The Interface, gettext, +the GNU Gettext manual}). If this is @code{NULL} (the default), the +translation will be searched in the current text domain. @end deftypevar @deftypefun int getopt (int @var{argc}, char *const *@var{argv}, const char *@var{options}) diff --git a/posix/Versions b/posix/Versions index 5873e8ec56..d1c2cffcf9 100644 --- a/posix/Versions +++ b/posix/Versions @@ -160,7 +160,7 @@ libc { posix_spawn_file_actions_addtcsetpgrp_np; } GLIBC_2.43 { - optctxt; + optctxt; opttextdomain; } GLIBC_PRIVATE { __libc_fork; __libc_pread; __libc_pwrite; diff --git a/posix/bits/getopt_ext.h b/posix/bits/getopt_ext.h index fa72124cad..0fbfffa2f5 100644 --- a/posix/bits/getopt_ext.h +++ b/posix/bits/getopt_ext.h @@ -31,6 +31,11 @@ __BEGIN_DECLS names. If unset, the option names will not be translated. */ extern const char *optctxt; + +/* Callers store the textdomain to use to retrieve option names, or + NULL to use the current textdomain. */ + +extern const char *opttextdomain; #endif /* Describe the long-named options requested by the application. diff --git a/posix/getopt.c b/posix/getopt.c index 1f7e6e4216..f0af983cf5 100644 --- a/posix/getopt.c +++ b/posix/getopt.c @@ -185,16 +185,20 @@ exchange (char **argv, struct _getopt_data *d) /* Return 1 iff translation_context is not NULL, a translation for opt_name has been found and it matches the substring from argument, length argument_length. + + The translate function pointer is like dpgettext. */ static const int -match_translated_option_name (char *(*translate) (const char *, const char *), +match_translated_option_name (char *(*translate) (const char *, const char *, + const char *), const char *argument, size_t argument_length, const char *translation_context, + const char *opt_textdomain, const char *opt_name) { const char *translated = opt_name; if (translate != NULL) - translated = translate (translation_context, opt_name); + translated = translate (opt_textdomain, translation_context, opt_name); return (!strncmp (translated, argument, argument_length) && argument_length == strlen (translated)); } @@ -212,7 +216,8 @@ process_long_option (int argc, char **argv, const char *optstring, const struct option *longopts, int *longind, int long_only, struct _getopt_data *d, int print_errors, const char *prefix, - char *(*translate) (const char *, const char *)) + char *(*translate) (const char *, const char *, + const char *)) { char *nameend; size_t namelen; @@ -243,9 +248,9 @@ process_long_option (int argc, char **argv, const char *optstring, /* Didn't find an exact match, try with translated option names. */ for (p = longopts, option_index = 0; p->name; p++, option_index++) - if (match_translated_option_name (translate, - d->__nextchar, namelen, - d->optctxt, p->name)) + if (match_translated_option_name (translate, d->__nextchar, namelen, + d->optctxt, d->opttextdomain, + p->name)) { /* Exact match found with translation. */ pfound = p; @@ -369,7 +374,7 @@ process_long_option (int argc, char **argv, const char *optstring, /* We have found a matching long option. Consume it. */ d->optind++; d->__nextchar = NULL; - translated_option_name = translate (d->optctxt, pfound->name); + translated_option_name = translate (d->opttextdomain, d->optctxt, pfound->name); if (*nameend) { /* Don't test has_arg with >, because some C compilers don't @@ -531,7 +536,8 @@ int _getopt_internal_r (int argc, char **argv, const char *optstring, const struct option *longopts, int *longind, int long_only, struct _getopt_data *d, int posixly_correct, - char *(*translate) (const char *, const char *)) + char *(*translate) (const char *, const char *, + const char *)) { int print_errors = d->opterr; @@ -767,14 +773,16 @@ int _getopt_internal (int argc, char **argv, const char *optstring, const struct option *longopts, int *longind, int long_only, int posixly_correct, - char *(*translate) (const char *, const char *), - const char *ctxt) + char *(*translate) (const char *, const char *, const char *), + const char *ctxt, + const char *domain) { int result; getopt_data.optind = optind; getopt_data.opterr = opterr; getopt_data.optctxt = ctxt; + getopt_data.opttextdomain = domain; result = _getopt_internal_r (argc, argv, optstring, longopts, longind, long_only, &getopt_data, @@ -797,7 +805,7 @@ _getopt_internal (int argc, char **argv, const char *optstring, { \ return _getopt_internal (argc, (char **)argv, optstring, \ NULL, NULL, 0, POSIXLY_CORRECT, \ - NULL, NULL); \ + NULL, NULL, NULL); \ } #ifdef _LIBC diff --git a/posix/getopt1.c b/posix/getopt1.c index 60d516403c..af287cfb33 100644 --- a/posix/getopt1.c +++ b/posix/getopt1.c @@ -35,9 +35,14 @@ const char *optctxt = NULL; +/* Callers store the textdomain in which the option names are to be + looked up. */ + +const char *opttextdomain = NULL; + /* FIXME: use pgettext_expr. */ static char * -do_translate (const char *context, const char *msgid) +do_translate (const char *domain, const char *context, const char *msgid) { char *full_msgid; const char *translated = msgid; @@ -48,7 +53,7 @@ do_translate (const char *context, const char *msgid) output_length = __asprintf (&full_msgid, "%s\004%s", context, msgid); if (output_length >= 0) { - translated = __dcgettext (NULL, full_msgid, LC_MESSAGES); + translated = __dcgettext (domain, full_msgid, LC_MESSAGES); if (strcmp (translated, full_msgid) == 0) { /* No translation for this context and message, so drop @@ -70,7 +75,8 @@ getopt_long (int argc, char *__getopt_argv_const *argv, const char *options, const struct option *long_options, int *opt_index) { return _getopt_internal (argc, (char **) argv, options, long_options, - opt_index, 0, 0, do_translate, optctxt); + opt_index, 0, 0, do_translate, + optctxt, opttextdomain); } int @@ -93,7 +99,8 @@ getopt_long_only (int argc, char *__getopt_argv_const *argv, const struct option *long_options, int *opt_index) { return _getopt_internal (argc, (char **) argv, options, long_options, - opt_index, 1, 0, do_translate, optctxt); + opt_index, 1, 0, do_translate, + optctxt, opttextdomain); } int diff --git a/posix/getopt_int.h b/posix/getopt_int.h index a2f3c60c25..74e18a7b07 100644 --- a/posix/getopt_int.h +++ b/posix/getopt_int.h @@ -24,13 +24,14 @@ /* The translate argument here is optional (can be NULL), it is used to avoid depending on the gettext functions in the posix getopt - function. */ + function. It is like dpgettext. */ extern int _getopt_internal (int ___argc, char **___argv, const char *__shortopts, const struct option *__longopts, int *__longind, int __long_only, int __posixly_correct, - char *(*translate) (const char *, const char *), - const char *__optctxt); + char *(*translate) (const char *, const char *, + const char *), + const char *__optctxt, const char *__optdomain); /* Reentrant versions which can handle parsing multiple argument @@ -73,6 +74,7 @@ struct _getopt_data int optopt; char *optarg; const char *optctxt; + const char *opttextdomain; /* Internal members. */ @@ -109,7 +111,8 @@ extern int _getopt_internal_r (int ___argc, char **___argv, const struct option *__longopts, int *__longind, int __long_only, struct _getopt_data *__data, int __posixly_correct, - char *(*translate) (const char *, const char *)); + char *(*translate) (const char *, const char *, + const char *)); extern int _getopt_long_r (int ___argc, char **___argv, const char *__shortopts, diff --git a/posix/tstgetoptl.c b/posix/tstgetoptl.c index 3d8aa44f1d..2e9720f73f 100644 --- a/posix/tstgetoptl.c +++ b/posix/tstgetoptl.c @@ -44,7 +44,7 @@ prepare_localedir (void) TEST_VERIFY_EXIT (bindtextdomain ("tstgetoptl", OBJPFX "domaindir") != NULL); TEST_VERIFY_EXIT (textdomain ("tstgetoptl") != NULL); /* Check that the catalog is OK: */ - TEST_COMPARE_STRING (gettext (TRANSLATION_CONTEXT "\004" "color"), "colour"); + TEST_COMPARE_STRING (dgettext ("tstgetoptl", TRANSLATION_CONTEXT "\004" "color"), "colour"); } static char ** @@ -64,6 +64,7 @@ static void do_my_test (int with_optctxt) { static const char *translation_context = TRANSLATION_CONTEXT; + static const char *translation_textdomain = "tstgetoptl"; int argc; char **argv = prepare_argv (&argc); static const struct option options[] = @@ -85,6 +86,7 @@ do_my_test (int with_optctxt) optctxt = translation_context; else optctxt = NULL; + opttextdomain = translation_textdomain; optind = 0; while ((c = getopt_long (argc, argv, "", options, NULL)) >= 0) switch (c) diff --git a/sysdeps/mach/hurd/i386/libc.abilist b/sysdeps/mach/hurd/i386/libc.abilist index 68c4385301..2177e6e100 100644 --- a/sysdeps/mach/hurd/i386/libc.abilist +++ b/sysdeps/mach/hurd/i386/libc.abilist @@ -2716,6 +2716,7 @@ GLIBC_2.43 mtx_timedlock F GLIBC_2.43 mtx_trylock F GLIBC_2.43 mtx_unlock F GLIBC_2.43 optctxt D 0x4 +GLIBC_2.43 opttextdomain D 0x4 GLIBC_2.43 pthread_cancel F GLIBC_2.43 pthread_clockjoin_np F GLIBC_2.43 pthread_create F diff --git a/sysdeps/mach/hurd/x86_64/libc.abilist b/sysdeps/mach/hurd/x86_64/libc.abilist index d5fdb20fe1..18a2d8092d 100644 --- a/sysdeps/mach/hurd/x86_64/libc.abilist +++ b/sysdeps/mach/hurd/x86_64/libc.abilist @@ -2393,6 +2393,7 @@ GLIBC_2.43 mtx_timedlock F GLIBC_2.43 mtx_trylock F GLIBC_2.43 mtx_unlock F GLIBC_2.43 optctxt D 0x8 +GLIBC_2.43 opttextdomain D 0x8 GLIBC_2.43 pthread_cancel F GLIBC_2.43 pthread_clockjoin_np F GLIBC_2.43 pthread_create F diff --git a/sysdeps/unix/sysv/linux/aarch64/libc.abilist b/sysdeps/unix/sysv/linux/aarch64/libc.abilist index b5eaa54c18..932d752b7b 100644 --- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist +++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist @@ -2774,4 +2774,5 @@ GLIBC_2.43 memalignment F GLIBC_2.43 memset_explicit F GLIBC_2.43 mseal F GLIBC_2.43 optctxt D 0x8 +GLIBC_2.43 opttextdomain D 0x8 GLIBC_2.43 umaxabs F diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist index 9d38721287..21698c1c71 100644 --- a/sysdeps/unix/sysv/linux/alpha/libc.abilist +++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist @@ -3121,6 +3121,7 @@ GLIBC_2.43 memalignment F GLIBC_2.43 memset_explicit F GLIBC_2.43 mseal F GLIBC_2.43 optctxt D 0x8 +GLIBC_2.43 opttextdomain D 0x8 GLIBC_2.43 umaxabs F GLIBC_2.5 __readlinkat_chk F GLIBC_2.5 inet6_opt_append F diff --git a/sysdeps/unix/sysv/linux/arc/libc.abilist b/sysdeps/unix/sysv/linux/arc/libc.abilist index 3d4a038e25..b99f73e5ca 100644 --- a/sysdeps/unix/sysv/linux/arc/libc.abilist +++ b/sysdeps/unix/sysv/linux/arc/libc.abilist @@ -2535,4 +2535,5 @@ GLIBC_2.43 memalignment F GLIBC_2.43 memset_explicit F GLIBC_2.43 mseal F GLIBC_2.43 optctxt D 0x4 +GLIBC_2.43 opttextdomain D 0x4 GLIBC_2.43 umaxabs F diff --git a/sysdeps/unix/sysv/linux/arm/be/libc.abilist b/sysdeps/unix/sysv/linux/arm/be/libc.abilist index 5a231c61bc..78e695b2a9 100644 --- a/sysdeps/unix/sysv/linux/arm/be/libc.abilist +++ b/sysdeps/unix/sysv/linux/arm/be/libc.abilist @@ -2827,6 +2827,7 @@ GLIBC_2.43 memalignment F GLIBC_2.43 memset_explicit F GLIBC_2.43 mseal F GLIBC_2.43 optctxt D 0x4 +GLIBC_2.43 opttextdomain D 0x4 GLIBC_2.43 umaxabs F GLIBC_2.5 __readlinkat_chk F GLIBC_2.5 inet6_opt_append F diff --git a/sysdeps/unix/sysv/linux/arm/le/libc.abilist b/sysdeps/unix/sysv/linux/arm/le/libc.abilist index 75105c3e38..79eef121d1 100644 --- a/sysdeps/unix/sysv/linux/arm/le/libc.abilist +++ b/sysdeps/unix/sysv/linux/arm/le/libc.abilist @@ -2824,6 +2824,7 @@ GLIBC_2.43 memalignment F GLIBC_2.43 memset_explicit F GLIBC_2.43 mseal F GLIBC_2.43 optctxt D 0x4 +GLIBC_2.43 opttextdomain D 0x4 GLIBC_2.43 umaxabs F GLIBC_2.5 __readlinkat_chk F GLIBC_2.5 inet6_opt_append F diff --git a/sysdeps/unix/sysv/linux/csky/libc.abilist b/sysdeps/unix/sysv/linux/csky/libc.abilist index 8bb4ed2926..89bd8e19a8 100644 --- a/sysdeps/unix/sysv/linux/csky/libc.abilist +++ b/sysdeps/unix/sysv/linux/csky/libc.abilist @@ -2811,4 +2811,5 @@ GLIBC_2.43 memalignment F GLIBC_2.43 memset_explicit F GLIBC_2.43 mseal F GLIBC_2.43 optctxt D 0x4 +GLIBC_2.43 opttextdomain D 0x4 GLIBC_2.43 umaxabs F diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist index e88a350c36..331c8f4379 100644 --- a/sysdeps/unix/sysv/linux/hppa/libc.abilist +++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist @@ -2848,6 +2848,7 @@ GLIBC_2.43 memalignment F GLIBC_2.43 memset_explicit F GLIBC_2.43 mseal F GLIBC_2.43 optctxt D 0x4 +GLIBC_2.43 opttextdomain D 0x4 GLIBC_2.43 umaxabs F GLIBC_2.5 __readlinkat_chk F GLIBC_2.5 inet6_opt_append F diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist index 9233d17385..05e6e67523 100644 --- a/sysdeps/unix/sysv/linux/i386/libc.abilist +++ b/sysdeps/unix/sysv/linux/i386/libc.abilist @@ -3031,6 +3031,7 @@ GLIBC_2.43 memalignment F GLIBC_2.43 memset_explicit F GLIBC_2.43 mseal F GLIBC_2.43 optctxt D 0x4 +GLIBC_2.43 opttextdomain D 0x4 GLIBC_2.43 umaxabs F GLIBC_2.5 __readlinkat_chk F GLIBC_2.5 inet6_opt_append F diff --git a/sysdeps/unix/sysv/linux/loongarch/lp64/libc.abilist b/sysdeps/unix/sysv/linux/loongarch/lp64/libc.abilist index 35ed82fb7c..64d8c64388 100644 --- a/sysdeps/unix/sysv/linux/loongarch/lp64/libc.abilist +++ b/sysdeps/unix/sysv/linux/loongarch/lp64/libc.abilist @@ -2295,4 +2295,5 @@ GLIBC_2.43 memalignment F GLIBC_2.43 memset_explicit F GLIBC_2.43 mseal F GLIBC_2.43 optctxt D 0x8 +GLIBC_2.43 opttextdomain D 0x8 GLIBC_2.43 umaxabs F diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist index 8bcba20577..4ebdf65512 100644 --- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist +++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist @@ -2807,6 +2807,7 @@ GLIBC_2.43 memalignment F GLIBC_2.43 memset_explicit F GLIBC_2.43 mseal F GLIBC_2.43 optctxt D 0x4 +GLIBC_2.43 opttextdomain D 0x4 GLIBC_2.43 umaxabs F GLIBC_2.5 __readlinkat_chk F GLIBC_2.5 inet6_opt_append F diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist index fea62ef3ac..6a5a305d3f 100644 --- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist +++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist @@ -2974,6 +2974,7 @@ GLIBC_2.43 memalignment F GLIBC_2.43 memset_explicit F GLIBC_2.43 mseal F GLIBC_2.43 optctxt D 0x4 +GLIBC_2.43 opttextdomain D 0x4 GLIBC_2.43 umaxabs F GLIBC_2.5 __readlinkat_chk F GLIBC_2.5 inet6_opt_append F diff --git a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist index 792d82a8cd..8d3d5d067b 100644 --- a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist +++ b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist @@ -2860,4 +2860,5 @@ GLIBC_2.43 memalignment F GLIBC_2.43 memset_explicit F GLIBC_2.43 mseal F GLIBC_2.43 optctxt D 0x4 +GLIBC_2.43 opttextdomain D 0x4 GLIBC_2.43 umaxabs F diff --git a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist index f56268954d..206783ce68 100644 --- a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist +++ b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist @@ -2857,4 +2857,5 @@ GLIBC_2.43 memalignment F GLIBC_2.43 memset_explicit F GLIBC_2.43 mseal F GLIBC_2.43 optctxt D 0x4 +GLIBC_2.43 opttextdomain D 0x4 GLIBC_2.43 umaxabs F diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist index ce6fdb0368..cf93c9294a 100644 --- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist @@ -2937,6 +2937,7 @@ GLIBC_2.43 memalignment F GLIBC_2.43 memset_explicit F GLIBC_2.43 mseal F GLIBC_2.43 optctxt D 0x4 +GLIBC_2.43 opttextdomain D 0x4 GLIBC_2.43 umaxabs F GLIBC_2.5 __readlinkat_chk F GLIBC_2.5 inet6_opt_append F diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist index 45676efa7b..1cc38c4c89 100644 --- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist @@ -2935,6 +2935,7 @@ GLIBC_2.43 memalignment F GLIBC_2.43 memset_explicit F GLIBC_2.43 mseal F GLIBC_2.43 optctxt D 0x4 +GLIBC_2.43 opttextdomain D 0x4 GLIBC_2.43 umaxabs F GLIBC_2.5 __readlinkat_chk F GLIBC_2.5 inet6_opt_append F diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist index b2557cf712..3e51c7f31d 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist @@ -2943,6 +2943,7 @@ GLIBC_2.43 memalignment F GLIBC_2.43 memset_explicit F GLIBC_2.43 mseal F GLIBC_2.43 optctxt D 0x4 +GLIBC_2.43 opttextdomain D 0x4 GLIBC_2.43 umaxabs F GLIBC_2.5 __readlinkat_chk F GLIBC_2.5 inet6_opt_append F diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist index 3c51ddb219..bc03f55d4d 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist @@ -2845,6 +2845,7 @@ GLIBC_2.43 memalignment F GLIBC_2.43 memset_explicit F GLIBC_2.43 mseal F GLIBC_2.43 optctxt D 0x8 +GLIBC_2.43 opttextdomain D 0x8 GLIBC_2.43 umaxabs F GLIBC_2.5 __readlinkat_chk F GLIBC_2.5 inet6_opt_append F diff --git a/sysdeps/unix/sysv/linux/or1k/libc.abilist b/sysdeps/unix/sysv/linux/or1k/libc.abilist index 6fdbaf4335..1ae3b9d128 100644 --- a/sysdeps/unix/sysv/linux/or1k/libc.abilist +++ b/sysdeps/unix/sysv/linux/or1k/libc.abilist @@ -2285,4 +2285,5 @@ GLIBC_2.43 memalignment F GLIBC_2.43 memset_explicit F GLIBC_2.43 mseal F GLIBC_2.43 optctxt D 0x4 +GLIBC_2.43 opttextdomain D 0x4 GLIBC_2.43 umaxabs F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist index 6ce0ec58a3..21a37b0f9f 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist @@ -3164,6 +3164,7 @@ GLIBC_2.43 memalignment F GLIBC_2.43 memset_explicit F GLIBC_2.43 mseal F GLIBC_2.43 optctxt D 0x4 +GLIBC_2.43 opttextdomain D 0x4 GLIBC_2.43 umaxabs F GLIBC_2.5 __readlinkat_chk F GLIBC_2.5 inet6_opt_append F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist index 7979c7e481..82e33b1ba8 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist @@ -3209,6 +3209,7 @@ GLIBC_2.43 memalignment F GLIBC_2.43 memset_explicit F GLIBC_2.43 mseal F GLIBC_2.43 optctxt D 0x4 +GLIBC_2.43 opttextdomain D 0x4 GLIBC_2.43 umaxabs F GLIBC_2.5 __readlinkat_chk F GLIBC_2.5 inet6_opt_append F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist index 9a9caec7ac..e8ed9cda80 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist @@ -2918,6 +2918,7 @@ GLIBC_2.43 memalignment F GLIBC_2.43 memset_explicit F GLIBC_2.43 mseal F GLIBC_2.43 optctxt D 0x8 +GLIBC_2.43 opttextdomain D 0x8 GLIBC_2.43 umaxabs F GLIBC_2.5 __readlinkat_chk F GLIBC_2.5 inet6_opt_append F diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist index 4091a4b381..9144ba40a3 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist @@ -2994,4 +2994,5 @@ GLIBC_2.43 memalignment F GLIBC_2.43 memset_explicit F GLIBC_2.43 mseal F GLIBC_2.43 optctxt D 0x8 +GLIBC_2.43 opttextdomain D 0x8 GLIBC_2.43 umaxabs F diff --git a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist index c87b4b6743..a2c2af42ef 100644 --- a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist +++ b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist @@ -2538,4 +2538,5 @@ GLIBC_2.43 memalignment F GLIBC_2.43 memset_explicit F GLIBC_2.43 mseal F GLIBC_2.43 optctxt D 0x4 +GLIBC_2.43 opttextdomain D 0x4 GLIBC_2.43 umaxabs F diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist index 1c16f324db..68b3b66a8e 100644 --- a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist +++ b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist @@ -2738,4 +2738,5 @@ GLIBC_2.43 memalignment F GLIBC_2.43 memset_explicit F GLIBC_2.43 mseal F GLIBC_2.43 optctxt D 0x8 +GLIBC_2.43 opttextdomain D 0x8 GLIBC_2.43 umaxabs F diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist index dfd6b1fb98..87e772b11b 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist +++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist @@ -3162,6 +3162,7 @@ GLIBC_2.43 memalignment F GLIBC_2.43 memset_explicit F GLIBC_2.43 mseal F GLIBC_2.43 optctxt D 0x4 +GLIBC_2.43 opttextdomain D 0x4 GLIBC_2.43 umaxabs F GLIBC_2.5 __readlinkat_chk F GLIBC_2.5 inet6_opt_append F diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist index 62d732eb52..ac381d1439 100644 --- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist +++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist @@ -2955,6 +2955,7 @@ GLIBC_2.43 memalignment F GLIBC_2.43 memset_explicit F GLIBC_2.43 mseal F GLIBC_2.43 optctxt D 0x8 +GLIBC_2.43 opttextdomain D 0x8 GLIBC_2.43 umaxabs F GLIBC_2.5 __readlinkat_chk F GLIBC_2.5 inet6_opt_append F diff --git a/sysdeps/unix/sysv/linux/sh/be/libc.abilist b/sysdeps/unix/sysv/linux/sh/be/libc.abilist index 2515068b65..0a1e8da204 100644 --- a/sysdeps/unix/sysv/linux/sh/be/libc.abilist +++ b/sysdeps/unix/sysv/linux/sh/be/libc.abilist @@ -2854,6 +2854,7 @@ GLIBC_2.43 memalignment F GLIBC_2.43 memset_explicit F GLIBC_2.43 mseal F GLIBC_2.43 optctxt D 0x4 +GLIBC_2.43 opttextdomain D 0x4 GLIBC_2.43 umaxabs F GLIBC_2.5 __readlinkat_chk F GLIBC_2.5 inet6_opt_append F diff --git a/sysdeps/unix/sysv/linux/sh/le/libc.abilist b/sysdeps/unix/sysv/linux/sh/le/libc.abilist index adb5760390..0753830332 100644 --- a/sysdeps/unix/sysv/linux/sh/le/libc.abilist +++ b/sysdeps/unix/sysv/linux/sh/le/libc.abilist @@ -2851,6 +2851,7 @@ GLIBC_2.43 memalignment F GLIBC_2.43 memset_explicit F GLIBC_2.43 mseal F GLIBC_2.43 optctxt D 0x4 +GLIBC_2.43 opttextdomain D 0x4 GLIBC_2.43 umaxabs F GLIBC_2.5 __readlinkat_chk F GLIBC_2.5 inet6_opt_append F diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist index fd9acd46a0..27b25f02f9 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist @@ -3185,6 +3185,7 @@ GLIBC_2.43 memalignment F GLIBC_2.43 memset_explicit F GLIBC_2.43 mseal F GLIBC_2.43 optctxt D 0x4 +GLIBC_2.43 opttextdomain D 0x4 GLIBC_2.43 umaxabs F GLIBC_2.5 __readlinkat_chk F GLIBC_2.5 inet6_opt_append F diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist index ae03fe7b28..cde2c7998e 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist @@ -2821,6 +2821,7 @@ GLIBC_2.43 memalignment F GLIBC_2.43 memset_explicit F GLIBC_2.43 mseal F GLIBC_2.43 optctxt D 0x8 +GLIBC_2.43 opttextdomain D 0x8 GLIBC_2.43 umaxabs F GLIBC_2.5 __readlinkat_chk F GLIBC_2.5 inet6_opt_append F diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist index 54fef75839..cc1c0d0b68 100644 --- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist +++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist @@ -2770,6 +2770,7 @@ GLIBC_2.43 memalignment F GLIBC_2.43 memset_explicit F GLIBC_2.43 mseal F GLIBC_2.43 optctxt D 0x8 +GLIBC_2.43 opttextdomain D 0x8 GLIBC_2.43 umaxabs F GLIBC_2.5 __readlinkat_chk F GLIBC_2.5 inet6_opt_append F diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist index 339bf09fd9..39eadde8c1 100644 --- a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist +++ b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist @@ -2789,4 +2789,5 @@ GLIBC_2.43 memalignment F GLIBC_2.43 memset_explicit F GLIBC_2.43 mseal F GLIBC_2.43 optctxt D 0x4 +GLIBC_2.43 opttextdomain D 0x4 GLIBC_2.43 umaxabs F From patchwork Tue Jan 27 19:18:10 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivien Kraus X-Patchwork-Id: 129064 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id B462A4BA2E36 for ; Tue, 27 Jan 2026 19:24:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B462A4BA2E36 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=planete-kraus.eu header.i=@planete-kraus.eu header.a=rsa-sha1 header.s=albinoniB header.b=sR2oyyBn X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from planete-kraus.eu (planete-kraus.eu [89.234.140.182]) by sourceware.org (Postfix) with ESMTPS id C9BFF4BA9024 for ; Tue, 27 Jan 2026 19:23:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C9BFF4BA9024 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=planete-kraus.eu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=planete-kraus.eu ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C9BFF4BA9024 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=89.234.140.182 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1769541811; cv=none; b=XVKRvYdZczQzwbfw9V2BSCWrG7ND+6yuoRQ0l/8vTPpKOFVH2ssDREOyNCMK7MYi9bCoSG3f9tSlbwBR/FOHHjxXpHVLOE/DJxNJEDxcUzx6GvxLaO2G1WgnpHOik+svZgN5Y9W9RgastVZ7jlDGNb2XK7e7M4FMzMVIA6dFh0s= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1769541811; c=relaxed/simple; bh=uIlnIFodbmyG+dJ7vr37VBkXXzD5/Rk7WfkXFuDHvhM=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=PClVX6zTix4ww1A3K1Aojl+QJCnNVjxibRJxQS31OnMu762W1SxsOLusB5nqIMM26b+qXJbR3VP7dClylXyPTaGgEAbGzgti92aNaC3FSFFzxJdkLDIHmOZY7MDIqbpOD62gLTPxC5ZwYfSUcafn1LYbQCbXYQ9Ga4aCZpsscIQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C9BFF4BA9024 Received: from planete-kraus.eu (localhost [127.0.0.1]) by planete-kraus.eu (OpenSMTPD) with ESMTP id a91cc875; Tue, 27 Jan 2026 19:23:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=planete-kraus.eu; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=albinoniB; bh=/6WX7gF FzueUGHq9yqEYVFS6Hys=; b=sR2oyyBnDDPFaxO+FsmHtAcLsjRU7oKWSiSRXzS /LRO5SighO39kf7FpR7tsDBzSjjKkeQxxCoZanwBdt3XEgOzvSv5YnXsHc+QW1kc p2o/OyxGiQBAKxvckgA9VgQoqARzWbF5iNi8l+6V2+s6rNWR7G0lUCSwoJkUhSTd 5y3b2nWKLMiY2lw148K0VEza4Y5or1JsmgNUdVudMrrbCy6xeyTTjFznmRCVqDT7 kxY7HaXWHpi9GrmLcFbqc2qSJidf3r62W2Oe5P2BPGOB0cPAAttntkymda1mqomv FPmfob5spa0IL/D+yywzLpdpl06ETgLijhKmYsgYC46w2CQ== Received: by planete-kraus.eu (OpenSMTPD) with ESMTPSA id effbf067 (TLSv1.3:TLS_CHACHA20_POLY1305_SHA256:256:NO); Tue, 27 Jan 2026 19:23:21 +0000 (UTC) From: Vivien Kraus To: libc-alpha@sourceware.org, adhemerval.zanella@linaro.org Cc: Vivien Kraus Subject: [PATCH v20 05/11] posix: do not allow option name translations for secure programs Date: Tue, 27 Jan 2026 20:18:10 +0100 Message-Id: <5cccc8dd552778e8bcd2a668e6a033fa83e6be64.1769539987.git.vivien@planete-kraus.eu> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: <68a758ae45c064bad35bfec73c3d5ffd050398e3.1748369494.git.vivien@planete-kraus.eu> MIME-Version: 1.0 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS, SPF_PASS, TXREP, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org SETUID / SETGID / AT_SECURE programs should not accept translated names, so that the programmer knows exactly how the program can be invoked. --- posix/getopt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/posix/getopt.c b/posix/getopt.c index 82f0968f8e..aec2bbd48a 100644 --- a/posix/getopt.c +++ b/posix/getopt.c @@ -199,7 +199,7 @@ match_translated_option_name (char *(*translate) (const char *, const char *, const char *translated = opt_name; char *translation_buffer = NULL; bool matches = false; - if (translate != NULL) + if (translate != NULL && !__libc_enable_secure) translated = translate (opt_textdomain, translation_context, opt_name, &translation_buffer); From patchwork Sun Nov 23 17:07:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vivien Kraus X-Patchwork-Id: 125091 X-Patchwork-Delegate: azanella@linux.vnet.ibm.com Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 87CF0385841D for ; Sun, 23 Nov 2025 17:11:43 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from planete-kraus.eu (planete-kraus.eu [89.234.140.182]) by sourceware.org (Postfix) with ESMTPS id 6C7A43858C66 for ; Sun, 23 Nov 2025 17:10:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6C7A43858C66 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=planete-kraus.eu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=planete-kraus.eu ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6C7A43858C66 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=89.234.140.182 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1763917813; cv=none; b=nZnrDfw13bFn09BzDIniucq0ML0b3PdxnEBt34pQ1YULjjXog02ppxPyHm2OLWdCS3PxIXK5IFv9Sb58g85zck9k8KbvaRx91wjSPY44G+asEbJWJgESlKLD7PZ7GogAiD1MluKboFgo8vtZ5sTZ5E+vmrI8N0XMukhyJNtA3Vs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1763917813; c=relaxed/simple; bh=/gZh2/5xU/ElWXyn68Noi1YKcHu/qD46jIy5V07+OeE=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=An9ncd99uRKn+7X/Pfrv6uhZSHiMRK2XbUHnYYxpJ32OFMnopzoqspNdmeOrjiNC8fzTO/FBMiuPYCu8IAqGyVCzwe9Guw1JY1jzGaY5k7GNqqNFll5vwRN/PHkvERSmkb5tl4c7ozNPSdLdOBsyuIEIr/XhCtFwo7ju6tMuqiM= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6C7A43858C66 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=planete-kraus.eu header.i=@planete-kraus.eu header.a=rsa-sha1 header.s=albinoniB header.b=HZv6wJDz Received: from planete-kraus.eu (localhost [127.0.0.1]) by planete-kraus.eu (OpenSMTPD) with ESMTP id 9379f50e; Sun, 23 Nov 2025 17:10:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=planete-kraus.eu; h=from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=albinoniB; bh=pgtEz1S x8WUVID1ddIvknewOv3A=; b=HZv6wJDzdCloRpp+8Nqr/bXjI3Nh7mnMgX2SktT 8Wonne4jEnadnkp3hOFLt76ZqtjnzMVllCgrAHLZlFkzCwOl9DkZMTzNpZqC5uJ/ eVIF9Z7q2wBXsGvucr+ytSZ1HipFCsXS3fCJ7/GNaew6NPmmoyMEwCpuAy0TeXXG NjR2FgMpkCqif/wULXQTebYDWwDHVOJlCOLephRwQaGMXW0KQkgMtHl6x4pUl107 Zf9cGK+MR3pwsSceq3vqeg+ck28bbMZSXznfpAhYsm8sVcEqFGFABPT59wGvWpFv WI1ZRoUnKwez4N27dfHk+hQ/LiT19MEh2tPRJp1K6lq+CPA== Received: by planete-kraus.eu (OpenSMTPD) with ESMTPSA id e550e698 (TLSv1.3:TLS_CHACHA20_POLY1305_SHA256:256:NO); Sun, 23 Nov 2025 17:10:00 +0000 (UTC) From: Vivien Kraus To: adhemerval.zanella@linaro.org Cc: Vivien Kraus , libc-alpha@sourceware.org Subject: [PATCH v18 07/11] argp: do not display option name translations if __libc_enable_secure Date: Sun, 23 Nov 2025 18:07:34 +0100 Message-Id: <9e3ead7a8566c7238d1aa7d9532bbf511e13eaf0.1763912300.git.vivien@planete-kraus.eu> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: <68a758ae45c064bad35bfec73c3d5ffd050398e3.1748369494.git.vivien@planete-kraus.eu> MIME-Version: 1.0 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org --- argp/argp-help.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/argp/argp-help.c b/argp/argp-help.c index 34ecc19b38..7557c4dbb2 100644 --- a/argp/argp-help.c +++ b/argp/argp-help.c @@ -1218,6 +1218,9 @@ canonical_option_translation (const char *name, char *full_msgid = NULL; const char *all_names = NULL; *allocated = NULL; + if (__libc_enable_secure) + /* Translations are disabled. */ + return name; if (__asprintf (&full_msgid, "command-line option\004%s", name) == -1) { /* *allocated is NULL */