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 A7B34C11F64 for ; Thu, 1 Jul 2021 06:17:00 +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 31E5661461 for ; Thu, 1 Jul 2021 06:17:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 31E5661461 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 42E8283275; Thu, 1 Jul 2021 08:16: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="kTKKDpva"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DEB668326F; Thu, 1 Jul 2021 08:16:28 +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 0DF208320A for ; Thu, 1 Jul 2021 08:16:19 +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 y29so4956079qky.12 for ; Wed, 30 Jun 2021 23:16:18 -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=90YfR0LP5TFiDKzfZwBM/49yhqrZT3qiPN/l7r+cWeo=; b=kTKKDpvabZoBB+/msDe1YPgs/sXtB840DDVgtff/lO8qC7cC0qRsRD5lc1K5NMzLmp DxIWeto46RxyrMTjNSOfE+3j4LAJ6s2rXpHV6uOIhzhX87fJNj2dZh97kEXu0AA4aFSQ omPzkxrfUKXccKnCGvqL8TCMJB6gdY0uavlAf1RaWnQ54n1cTiLXM0wWz6Wo7AaHsFmV t8HPNQTlCwKKNSarB2W3TsMG77oEYCqDAOw18lVKjNaEVHV1zJkcmqxjfFTrdUeOTgO5 uQEojF+hb+yYykpc+ADTkZvSxiBE7i3SlPeN8k0J+/9m1Lh7D2o0kPVLTzNCU1jLBeIG TnuQ== 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=90YfR0LP5TFiDKzfZwBM/49yhqrZT3qiPN/l7r+cWeo=; b=lg9h+uqvMZz7DUPnarvtia4LsXjjRlcnl6Q084oJtkacEn5YQS0/4Fyh8dmIgArzkB ehMFyInuwmhqEVnAE731e/H8iptVD0+htqGQGbOufHI0M3SOSEtJ1vvEAr8bURzjV/4A RYs5MsdCFFdD3minohG8APzAsyJQ2niPaiBKbRaCE4iINTKjD21JJss9JI9HJHCpVqHb bF34bc1Frr3qcpvByHz7VvqJW56f22iCQTxfZ5PAqySAOacMj7IvBhWA923rkardZLSZ WTbdj8gxldcyrSEDtkuClJvhHNi/qjiAWbxDy54lMgXrbQZPt+9MyxU/fTbgt6gtMmGw /nAw== X-Gm-Message-State: AOAM531n8Y1GgrgxOHLKPK1u9hDb4MSeRfWLZj86xIb5+ivA2VHKVQP6 khRgMf/CorWWx3kJ6KBqZs6HFw8kIuU= X-Google-Smtp-Source: ABdhPJxdDzJ+KxjyK44CsyjIhE2M30YD4RdqaCJ3iYFN8LmQDuGpq+tAqBIBK7rGN1k1rt48JkNu2A== X-Received: by 2002:a37:84c3:: with SMTP id g186mr39446610qkd.276.1625120177697; Wed, 30 Jun 2021 23:16:17 -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.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jun 2021 23:16:17 -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 04/28] cli: lil: Remove most functions by default Date: Thu, 1 Jul 2021 02:15:47 -0400 Message-Id: <20210701061611.957918-5-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 helps reduce the size impact of LIL to approximately that of hush. The builtin functions have been chosen to roughly match the functionality present in hush. In addition, arithmetic is removed from expr to reduce size further. Signed-off-by: Sean Anderson --- cmd/Kconfig | 10 ++++++ common/cli_lil.c | 83 +++++++++++++++++++++++++++--------------------- 2 files changed, 57 insertions(+), 36 deletions(-) diff --git a/cmd/Kconfig b/cmd/Kconfig index 8bccc572af..0a7b73cb6d 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -32,6 +32,16 @@ config LIL like `proc name {args} {body}' functions or `echo [some command]` command substitution ("tcl scripts"). +if LIL + +config LIL_FULL + bool "Enable all LIL features" + help + This enables all LIL builtin functions, as well as expression support + for arithmetic and bitwise operations. + +endif + config CMDLINE_EDITING bool "Enable command line editing" depends on CMDLINE diff --git a/common/cli_lil.c b/common/cli_lil.c index 294d79e86e..a2e5cdf35a 100644 --- a/common/cli_lil.c +++ b/common/cli_lil.c @@ -1321,7 +1321,7 @@ static void ee_unary(struct expreval *ee) static void ee_muldiv(struct expreval *ee) { ee_unary(ee); - if (ee->error) + if (ee->error || !IS_ENABLED(CONFIG_LIL_FULL)) return; ee_skip_spaces(ee); @@ -1382,8 +1382,10 @@ static void ee_muldiv(struct expreval *ee) static void ee_addsub(struct expreval *ee) { ee_muldiv(ee); - ee_skip_spaces(ee); + if (!IS_ENABLED(CONFIG_LIL_FULL)) + return; + ee_skip_spaces(ee); while (ee->head < ee->len && !ee->error && !ee_invalidpunct(ee->code[ee->head + 1]) && (ee->code[ee->head] == '+' || ee->code[ee->head] == '-')) { @@ -1415,8 +1417,10 @@ static void ee_addsub(struct expreval *ee) static void ee_shift(struct expreval *ee) { ee_addsub(ee); - ee_skip_spaces(ee); + if (!IS_ENABLED(CONFIG_LIL_FULL)) + return; + ee_skip_spaces(ee); while (ee->head < ee->len && !ee->error && ((ee->code[ee->head] == '<' && ee->code[ee->head + 1] == '<') || (ee->code[ee->head] == '>' && ee->code[ee->head + 1] == '>'))) { @@ -1545,8 +1549,10 @@ static void ee_equals(struct expreval *ee) static void ee_bitand(struct expreval *ee) { ee_equals(ee); - ee_skip_spaces(ee); + if (!IS_ENABLED(CONFIG_LIL_FULL)) + return; + ee_skip_spaces(ee); while (ee->head < ee->len && !ee->error && (ee->code[ee->head] == '&' && !ee_invalidpunct(ee->code[ee->head + 1]))) { @@ -1566,8 +1572,10 @@ static void ee_bitand(struct expreval *ee) static void ee_bitor(struct expreval *ee) { ee_bitand(ee); - ee_skip_spaces(ee); + if (!IS_ENABLED(CONFIG_LIL_FULL)) + return; + ee_skip_spaces(ee); while (ee->head < ee->len && !ee->error && (ee->code[ee->head] == '|' && !ee_invalidpunct(ee->code[ee->head + 1]))) { @@ -2932,49 +2940,52 @@ static struct lil_value *fnc_lmap(struct lil *lil, size_t argc, static void register_stdcmds(struct lil *lil) { - lil_register(lil, "append", fnc_append); - lil_register(lil, "char", fnc_char); - lil_register(lil, "charat", fnc_charat); - lil_register(lil, "codeat", fnc_codeat); - lil_register(lil, "concat", fnc_concat); - lil_register(lil, "count", fnc_count); lil_register(lil, "dec", fnc_dec); - lil_register(lil, "downeval", fnc_downeval); - lil_register(lil, "error", fnc_error); lil_register(lil, "eval", fnc_eval); lil_register(lil, "expr", fnc_expr); - lil_register(lil, "filter", fnc_filter); lil_register(lil, "for", fnc_for); lil_register(lil, "foreach", fnc_foreach); lil_register(lil, "func", fnc_func); lil_register(lil, "if", fnc_if); lil_register(lil, "inc", fnc_inc); - lil_register(lil, "index", fnc_index); - lil_register(lil, "indexof", fnc_indexof); - lil_register(lil, "length", fnc_length); - lil_register(lil, "list", fnc_list); - lil_register(lil, "lmap", fnc_lmap); lil_register(lil, "local", fnc_local); - lil_register(lil, "ltrim", fnc_ltrim); - lil_register(lil, "quote", fnc_quote); - lil_register(lil, "reflect", fnc_reflect); - lil_register(lil, "rename", fnc_rename); - lil_register(lil, "repstr", fnc_repstr); - lil_register(lil, "result", fnc_result); lil_register(lil, "return", fnc_return); - lil_register(lil, "rtrim", fnc_rtrim); lil_register(lil, "set", fnc_set); - lil_register(lil, "slice", fnc_slice); - lil_register(lil, "split", fnc_split); lil_register(lil, "strcmp", fnc_strcmp); - lil_register(lil, "streq", fnc_streq); - lil_register(lil, "strpos", fnc_strpos); - lil_register(lil, "subst", fnc_subst); - lil_register(lil, "substr", fnc_substr); - lil_register(lil, "topeval", fnc_topeval); - lil_register(lil, "trim", fnc_trim); lil_register(lil, "try", fnc_try); - lil_register(lil, "unusedname", fnc_unusedname); - lil_register(lil, "upeval", fnc_upeval); lil_register(lil, "while", fnc_while); + + if (IS_ENABLED(CONFIG_LIL_FULL)) { + lil_register(lil, "append", fnc_append); + lil_register(lil, "char", fnc_char); + lil_register(lil, "charat", fnc_charat); + lil_register(lil, "codeat", fnc_codeat); + lil_register(lil, "concat", fnc_concat); + lil_register(lil, "count", fnc_count); + lil_register(lil, "downeval", fnc_downeval); + lil_register(lil, "error", fnc_error); + lil_register(lil, "filter", fnc_filter); + lil_register(lil, "index", fnc_index); + lil_register(lil, "indexof", fnc_indexof); + lil_register(lil, "length", fnc_length); + lil_register(lil, "list", fnc_list); + lil_register(lil, "lmap", fnc_lmap); + lil_register(lil, "ltrim", fnc_ltrim); + lil_register(lil, "quote", fnc_quote); + lil_register(lil, "reflect", fnc_reflect); + lil_register(lil, "rename", fnc_rename); + lil_register(lil, "repstr", fnc_repstr); + lil_register(lil, "result", fnc_result); + lil_register(lil, "rtrim", fnc_rtrim); + lil_register(lil, "slice", fnc_slice); + lil_register(lil, "split", fnc_split); + lil_register(lil, "streq", fnc_streq); + lil_register(lil, "strpos", fnc_strpos); + lil_register(lil, "subst", fnc_subst); + lil_register(lil, "substr", fnc_substr); + lil_register(lil, "topeval", fnc_topeval); + lil_register(lil, "trim", fnc_trim); + lil_register(lil, "unusedname", fnc_unusedname); + lil_register(lil, "upeval", fnc_upeval); + } } -- 2.32.0