From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id C4784158087 for ; Mon, 13 Dec 2021 08:39:48 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 00DB52BC042; Mon, 13 Dec 2021 08:39:45 +0000 (UTC) Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id C89392BC042 for ; Mon, 13 Dec 2021 08:39:44 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id A5BDA34353F for ; Mon, 13 Dec 2021 08:39:42 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 3A1A223F for ; Mon, 13 Dec 2021 08:39:40 +0000 (UTC) From: "Fabian Groffen" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Fabian Groffen" Message-ID: <1639381535.7820847b2f9c5fc348dbf1991fcfec9b3b4fb5c4.grobian@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: / X-VCS-Repository: proj/portage-utils X-VCS-Files: applets.h main.c X-VCS-Directories: / X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: 7820847b2f9c5fc348dbf1991fcfec9b3b4fb5c4 X-VCS-Branch: master Date: Mon, 13 Dec 2021 08:39:40 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 854117df-1582-468e-8694-52e10dc7ed82 X-Archives-Hash: ff07d3ac7fbf80bf6db25d8945ca990f commit: 7820847b2f9c5fc348dbf1991fcfec9b3b4fb5c4 Author: Fabian Groffen gentoo org> AuthorDate: Mon Dec 13 07:45:35 2021 +0000 Commit: Fabian Groffen gentoo org> CommitDate: Mon Dec 13 07:45:35 2021 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=7820847b main: turn FEATURES into a set Signed-off-by: Fabian Groffen gentoo.org> applets.h | 2 +- main.c | 56 ++++++++++++++++++++++++++++++++++++-------------------- 2 files changed, 37 insertions(+), 21 deletions(-) diff --git a/applets.h b/applets.h index fa53359..6070fe4 100644 --- a/applets.h +++ b/applets.h @@ -170,7 +170,7 @@ extern char *pkg_install_mask; extern char *binhost; extern char *pkgdir; extern char *port_tmpdir; -extern char *features; +extern set *features; extern set *ev_use; extern char *install_mask; extern DEFINE_ARRAY(overlays); diff --git a/main.c b/main.c index 1d78f07..37ba036 100644 --- a/main.c +++ b/main.c @@ -41,7 +41,7 @@ char *pkg_install_mask; char *binhost; char *pkgdir; char *port_tmpdir; -char *features; +set *features; set *ev_use; char *install_mask; DECLARE_ARRAY(overlays); @@ -252,13 +252,27 @@ strincr_var(const char *name, const char *s, char **value, size_t *value_len) char *p; char *nv; char brace; + bool haddashstar; - len = strlen(s); - *value = xrealloc(*value, *value_len + len + 2); - nv = &(*value)[*value_len]; - if (*value_len) - *nv++ = ' '; - memcpy(nv, s, len + 1); + /* find/skip any -* instances */ + nv = (char *)s; + while ((p = strstr(nv, "-*")) != NULL) + nv = p + 2; + + haddashstar = nv != (char *)s; + + len = strlen(nv); + if (haddashstar && len < *value_len) { + p = *value; + *p = '\0'; /* in case len == 0 */ + } else { + *value = xrealloc(*value, + (haddashstar ? (*value_len + 1) : 0) + len + 1); + p = &(*value)[*value_len]; + if (*value_len > 0) + *p++ = ' '; + } + memcpy(p, nv, len + 1); /* This function is mainly used by the startup code for parsing make.conf and stacking variables remove. @@ -275,7 +289,6 @@ strincr_var(const char *name, const char *s, char **value, size_t *value_len) */ len = strlen(name); - p = nv; while ((p = strchr(p, '$')) != NULL) { nv = p; p++; /* skip $ */ @@ -293,9 +306,6 @@ strincr_var(const char *name, const char *s, char **value, size_t *value_len) } } - while ((p = strstr(nv, "-*")) != NULL) - memset(*value, ' ', p - *value + 2); - remove_extra_space(*value); *value_len = strlen(*value); /* we should sort here */ @@ -331,13 +341,15 @@ setincr_var(const char *s, set **vals) makeargv(s, &argc, &argv); for (i = 1 /* skip executable name */; i < argc; i++) { - if (argv[i][0] == '-' && *vals != NULL) { - /* handle negation, when the respective value isn't set, we - * simply ignore/drop it */ - if (argv[i][1] == '*') { - clear_set(*vals); - } else { - del_set(&argv[i][1], *vals, &ignore); + if (argv[i][0] == '-') { + if (*vals != NULL) { + /* handle negation, when the respective value isn't set, we + * simply ignore/drop it */ + if (argv[i][1] == '*') { + clear_set(*vals); + } else { + del_set(&argv[i][1], *vals, &ignore); + } } } else if (argv[i][0] == '$') { /* detect ${var} or $var, simply ignore it completely, for @@ -368,7 +380,11 @@ set_portage_env_var(env_vars *var, const char *value, const char *src) { switch (var->type) { case _Q_BOOL: - *var->value.b = 1; + *var->value.b = 0; + if (strcasecmp(value, "true") == 0 || + strcasecmp(value, "yes") == 0 || + strcmp(value, "1") == 0) + *var->value.b = 1; free(var->src); var->src = xstrdup(src); break; @@ -682,7 +698,7 @@ env_vars vars_to_read[] = { _Q_EVS(ISTR, CONFIG_PROTECT, config_protect, "/etc") _Q_EVS(ISTR, CONFIG_PROTECT_MASK, config_protect_mask, "") _Q_EVB(BOOL, NOCOLOR, nocolor, 0) - _Q_EVS(ISTR, FEATURES, features, "") + _Q_EVT(ISET, FEATURES, features, NULL) _Q_EVT(ISET, USE, ev_use, NULL) _Q_EVS(STR, EPREFIX, eprefix, CONFIG_EPREFIX) _Q_EVS(STR, EMERGE_LOG_DIR, portlogdir, CONFIG_EPREFIX "var/log")