From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62CEFC11F64 for ; Thu, 1 Jul 2021 06:20:53 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D603761607 for ; Thu, 1 Jul 2021 06:20:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D603761607 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 60B2C832C8; Thu, 1 Jul 2021 08:17:31 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="C9TqYK72"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id ABE6783279; Thu, 1 Jul 2021 08:17:08 +0200 (CEST) Received: from mail-qk1-x732.google.com (mail-qk1-x732.google.com [IPv6:2607:f8b0:4864:20::732]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id D7ED083279 for ; Thu, 1 Jul 2021 08:16:34 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=seanga2@gmail.com Received: by mail-qk1-x732.google.com with SMTP id y29so4956611qky.12 for ; Wed, 30 Jun 2021 23:16:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zyGIVF/nzvyXHPb6aW8ATumUqMlTZxB1XjVkFIdJdBM=; b=C9TqYK72LWBKfgIDZLljOG/uS5x2O/QuFoj73XoATnzaRCyKvlUIORuJ0wShAROFzm PJmuSglBen0UWl4jQGyLUw7TzWALGakSdh2dhdXjfpxip6JHZA5tfyHpsQVexkNShOqm JzZlfdX2oFUd8gy9eRJ/ade+JDZb4gEDDUjrpsQ4HwGA7/np0Svo4EtMd09nZzYtTgPf 1tlor7xEg+0zu5cS2y7NBNxIRlfD692RgJfNpkKMRxEEocEYRSK50mQP7BGyG5UD31P6 ChkUTfmY7hrQ4Vr+xGcLGFs2mhyXVk349Jkzx40mJFceNOqvp9Ov443ZxjwJgL8YtVAl L2LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zyGIVF/nzvyXHPb6aW8ATumUqMlTZxB1XjVkFIdJdBM=; b=F+/uG2MUsAw+Z3yxB3p2Pd7ZLUxRdeicSF56oluIlTakUUzc7nxMVkdBMQsadLNaTf mOxHMGJbLxbmRFmKjGoA73FV3qf/ZyycjlClWVzpYu6z43GafMXbZ1H5BpQKMpMxVBGT mrIweSG//zLVZhvQCPBV84PpzbXUAwmdCo9hmEipCLmR77lmrT386cw3QOiCCcSVzEyY eUeWrfS8z2XQmCWd/fYNn1c/Jr5ECnaWkrtxie5p/tsSvKxX0gxpiXpwso5/UtFsoZA+ nEEJpN3Kfue3tS9pTWGl0hlKqGBhKOjQ2NYYtrX4erOL4xdfT7s1OJSIhGVvjINOja3s GRDA== X-Gm-Message-State: AOAM532f3KoEFpGnTOPNkyKshhjnXjy1GRHVU1asxkkDURQN9cbP/w1k b0Y1uLy8G+dCXQEjod8FhxgJ5tiWEnY= X-Google-Smtp-Source: ABdhPJyg8Rrxntu7Sh+gAQBxMHD21+OyTxkh2LXieffFYjt1pJXmwvQWWucWNkNbpnaT0LdRojT0Dg== X-Received: by 2002:a37:5b84:: with SMTP id p126mr39938708qkb.254.1625120193593; Wed, 30 Jun 2021 23:16:33 -0700 (PDT) Received: from godwin.fios-router.home (pool-74-96-87-9.washdc.fios.verizon.net. [74.96.87.9]) by smtp.gmail.com with ESMTPSA id g21sm1684673qts.90.2021.06.30.23.16.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jun 2021 23:16:33 -0700 (PDT) From: Sean Anderson To: u-boot@lists.denx.de, Tom Rini Cc: =?UTF-8?q?Marek=20Beh=C3=BAn?= , Wolfgang Denk , Simon Glass , Roland Gaudig , Heinrich Schuchardt , Kostas Michalopoulos , Sean Anderson Subject: [RFC PATCH 25/28] cli: lil: Always quote items in lil_list_to_value Date: Thu, 1 Jul 2021 02:16:08 -0400 Message-Id: <20210701061611.957918-26-seanga2@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210701061611.957918-1-seanga2@gmail.com> References: <20210701061611.957918-1-seanga2@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean This function took an argument do_quote which determined whether or not to quote an item. All callers set it to true, so remove it and always quote. Signed-off-by: Sean Anderson --- common/cli_lil.c | 34 ++++++++++++++-------------------- include/cli_lil.h | 2 +- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/common/cli_lil.c b/common/cli_lil.c index 1c7c340bda..153c34791b 100644 --- a/common/cli_lil.c +++ b/common/cli_lil.c @@ -2092,7 +2092,7 @@ static struct lil_value *run_cmd(struct lil *lil, struct lil_func *cmd, if (cmd->argnames->c == 1 && !strcmp(lil_to_string(lil_list_get(cmd->argnames, 0)), "args")) { - struct lil_value *args = lil_list_to_value(words, 1); + struct lil_value *args = lil_list_to_value(words); lil_set_var(lil, "args", args, LIL_SETVAR_LOCAL_NEW); lil_free_value(args); @@ -2389,7 +2389,7 @@ braces: return needs; } -struct lil_value *lil_list_to_value(struct lil_list *list, bool do_escape) +struct lil_value *lil_list_to_value(struct lil_list *list) { struct lil_value *val = alloc_value(NULL); size_t i, j; @@ -2397,17 +2397,11 @@ struct lil_value *lil_list_to_value(struct lil_list *list, bool do_escape) for (i = 0; i < list->c; i++) { char q; struct lil_value *item = lil_list_get(list, i); - enum needs needs; - - if (do_escape) - needs = item_needs(lil_to_string(item), item->l); - else - needs = NEEDS_NOTHING; if (i) lil_append_char(val, ' '); - switch (needs) { + switch (item_needs(lil_to_string(item), item->l)) { case NEEDS_NOTHING: if (lil_append_val(val, item)) goto err; @@ -3087,7 +3081,7 @@ static struct lil_value *fnc_reflect(struct lil *lil, size_t argc, func = lil_find_cmd(lil, lil_to_string(argv[1])); if (!func || !func->argnames) return NULL; - return lil_list_to_value(func->argnames, 1); + return lil_list_to_value(func->argnames); } if (!strcmp(type, "body")) { @@ -3111,7 +3105,7 @@ static struct lil_value *fnc_reflect(struct lil *lil, size_t argc, lil_list_append(funcs, lil_alloc_string(lil->cmd[i]->name)); - r = lil_list_to_value(funcs, 1); + r = lil_list_to_value(funcs); lil_free_list(funcs); return r; } @@ -3130,7 +3124,7 @@ static struct lil_value *fnc_reflect(struct lil *lil, size_t argc, env = env->parent; } - r = lil_list_to_value(vars, 1); + r = lil_list_to_value(vars); lil_free_list(vars); return r; } @@ -3145,7 +3139,7 @@ static struct lil_value *fnc_reflect(struct lil *lil, size_t argc, lil_list_append(vars, var); } - r = lil_list_to_value(vars, 1); + r = lil_list_to_value(vars); lil_free_list(vars); return r; } @@ -3513,7 +3507,7 @@ static struct lil_value *fnc_append(struct lil *lil, size_t argc, for (i = base; i < argc; i++) lil_list_append(list, lil_clone_value(argv[i])); - r = lil_list_to_value(list, 1); + r = lil_list_to_value(list); lil_free_list(list); lil_set_var(lil, varname, r, access); return r; @@ -3548,7 +3542,7 @@ static struct lil_value *fnc_slice(struct lil *lil, size_t argc, lil_list_append(slice, lil_clone_value(lil_list_get(list, i))); lil_free_list(list); - r = lil_list_to_value(slice, 1); + r = lil_list_to_value(slice); lil_free_list(slice); return r; } @@ -3586,7 +3580,7 @@ static struct lil_value *fnc_filter(struct lil *lil, size_t argc, } lil_free_list(list); - r = lil_list_to_value(filtered, 1); + r = lil_list_to_value(filtered); lil_free_list(filtered); return r; } @@ -3601,7 +3595,7 @@ static struct lil_value *fnc_list(struct lil *lil, size_t argc, for (i = 0; i < argc; i++) lil_list_append(list, lil_clone_value(argv[i])); - r = lil_list_to_value(list, 1); + r = lil_list_to_value(list); lil_free_list(list); return r; } @@ -3628,7 +3622,7 @@ static struct lil_value *fnc_concat(struct lil *lil, size_t argc, r = lil_alloc_string(""); for (i = 0; i < argc; i++) { list = lil_subst_to_list(lil, argv[i]); - tmp = lil_list_to_value(list, 1); + tmp = lil_list_to_value(list); lil_free_list(list); lil_append_val(r, tmp); lil_free_value(tmp); @@ -3672,7 +3666,7 @@ static struct lil_value *fnc_foreach(struct lil *lil, size_t argc, break; } - r = lil_list_to_value(rlist, 1); + r = lil_list_to_value(rlist); lil_free_list(list); lil_free_list(rlist); return r; @@ -4147,7 +4141,7 @@ static struct lil_value *fnc_split(struct lil *lil, size_t argc, } lil_list_append(list, val); - val = lil_list_to_value(list, 1); + val = lil_list_to_value(list); lil_free_list(list); return val; } diff --git a/include/cli_lil.h b/include/cli_lil.h index 290329372a..6fbc270f1b 100644 --- a/include/cli_lil.h +++ b/include/cli_lil.h @@ -161,7 +161,7 @@ void lil_free_list(struct lil_list *list); int lil_list_append(struct lil_list *list, void *item); size_t lil_list_size(struct lil_list *list); struct lil_value *lil_list_get(struct lil_list *list, size_t index); -struct lil_value *lil_list_to_value(struct lil_list *list, bool do_escape); +struct lil_value *lil_list_to_value(struct lil_list *list); struct lil_list *lil_subst_to_list(struct lil *lil, struct lil_value *code); struct lil_value *lil_subst_to_value(struct lil *lil, struct lil_value *code); -- 2.32.0