From patchwork Fri Nov 13 15:44:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Babic X-Patchwork-Id: 1399879 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::33b; helo=mail-wm1-x33b.google.com; envelope-from=swupdate+bncbcxploxj6ikrbvgtxl6qkgqe6j22msq@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20161025 header.b=Ye88XA+W; dkim-atps=neutral Received: from mail-wm1-x33b.google.com (mail-wm1-x33b.google.com [IPv6:2a00:1450:4864:20::33b]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CXjSq28HPz9sT6 for ; Sat, 14 Nov 2020 02:44:24 +1100 (AEDT) Received: by mail-wm1-x33b.google.com with SMTP id 14sf4151595wmg.1 for ; Fri, 13 Nov 2020 07:44:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1605282261; cv=pass; d=google.com; s=arc-20160816; b=oeJEa4DCn3+GoTHfx/anJmxLbyrhs09fZMSTmF0cNL8gpayLK8+/d/SHrIBCVFKUEV JkYyj0ou4o3T2CNQ7zlzS4QvAatPPic61QIEtu1hO/JZsRUn4vO2TEyPpnX1Sqv3d6x7 cNKeckB13PTT4id5lfcYFoG3Ha65uItpuBKaz4JgOx1BqW8x4/K+cPkCv+3DHoposNa7 ogcJYOndAHklj2hnRZZekaiZVuj6leB4a9kNxeYhlgWiZpYHvW2RZvf8tlzEjSnpEUpj /EDNClg41xna3mBrzcf5iQKibx5Zq9qvdxRo7p3xQ7Tf/YZLn1sycMDZStzta3oQrFM/ 2e7Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:message-id:date :subject:cc:to:from:sender:dkim-signature; bh=ZKYiiEoYIskWsZ4SXzVbmg4WeiliR9b+X0hG80hs4Ls=; b=zKvizhlQmqV/rszGd7UXApmmewJXk79zZWKrNamLtGSd/npvc86FmmToh20At/6HEd kUjPigT1GrxmwraaR7AcL5I1Ss5OJRdQPcaUwpYKOv+oiDmHr1xTZjSWprFLMKTtKXOQ F8q/FmViQxtiwjR53BA2Cak17xWfq1fZ/56D8EEPtngYu+If8voA26HGsMQJ3JqHI8qb FebDXWR9ocW8FXnbrmG9cgG4bN69S2BfWQRn57PFBTzHXq+sEu/0I2i5f8ohCJmJQpaJ VZzMldLoL/hwHihu2VacmP6eyCM1NSbzpv0hHveTEQreqLrYbI82BeBwZMqlkAsjE+wb mdSw== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=ZKYiiEoYIskWsZ4SXzVbmg4WeiliR9b+X0hG80hs4Ls=; b=Ye88XA+WtL1SRPDmx02/sQJA+5X4/KsBEOPEgfRiggD3fkuAUm+YNueb8jOKNytMyZ A5ZY+nKRaqPa90dwnbwoJWdvPkW272nP3TFDpAFUZuOwQnWBrc5V91+KmtCFHs4xrbS1 9+vRNYE5lW8a5zhhVxki9KpQPfLFN4egnTXLdA3hlJ4vfzaWy1q3vs+SdXqYxWanHpz3 THW+dOMDTe4u1rC7VxEkJnd2SYmwa9bwr1+n8c83ZKaLZo1Wd87vdgxOkE/WPCtF44gW FwaREqbWWiD2oBqbU5Rmhvvpq/qrced+cBNRG0oxm7dG7gdKBLHLWFdVY5/hMfCf43kg K2aQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=ZKYiiEoYIskWsZ4SXzVbmg4WeiliR9b+X0hG80hs4Ls=; b=tuZyBbV16+4gS9/UujUkvI2MFfPU/AWeoFyqphHHV9R7MqUG99z4uVPGEe8UbuWWfC q37BrS29nSg8zCpVoAyz6g9ewBiPHJZ8gwDkE/nQgSkfgjsYuDPPrkkLs41Jln1ZckA+ bqa3pZgGaWXskSAIiLKFuEv5hRcN8VBXE/NBVNhq5RhejesxroNdRbfo2d40Bpu3l9NB F7+dD4qNIbcY4mZ++9W5bdl5IrIQzh0kFv5u3x6hUHvh1KO0uU+WaG0wllwWfjq33do7 sIFPuauVUkejL4TjN5/1ISSofwwFsZAMEzW+P+j5k7FytSOeQVJ4gmjzem3wMrBx9MTF p84Q== Sender: swupdate@googlegroups.com X-Gm-Message-State: AOAM533bT067M/bK1rnyHbYCKkDgbchkjXCoxNfrN4zuagWGDA3c5Ps3 81ZNm7wPTwkg34OP1xfgClg= X-Google-Smtp-Source: ABdhPJxi0QrT1Ue34qPm4tKJShC5oC7S3eDdBYllxMTKPtY43X3kpi04ACfvQZmvV4qzVk7gog2mjg== X-Received: by 2002:adf:9e48:: with SMTP id v8mr4515757wre.55.1605282260913; Fri, 13 Nov 2020 07:44:20 -0800 (PST) X-BeenThere: swupdate@googlegroups.com Received: by 2002:adf:aa87:: with SMTP id h7ls6036063wrc.2.gmail; Fri, 13 Nov 2020 07:44:19 -0800 (PST) X-Received: by 2002:a5d:52c1:: with SMTP id r1mr4420921wrv.255.1605282259752; Fri, 13 Nov 2020 07:44:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605282259; cv=none; d=google.com; s=arc-20160816; b=e9vbE0nUnfHMGd/zZM/lTa3K3eEMNM5MKQ7HJ0neskaOEH9wPpcZoAnSFYc3angRcf LG9JNYCMfOF6R5agrasYp3RL9HruLLbHYahNgE67WDP5Q1Ee7/KZXS/g5FLorSzZ+bPu 9Lpd018LoQ4CliDE9TovKECtu8z6R7qwwTnH56wDQkcAAawEGvGbIcA7LeMm/3zcO+ra R5U5lCcziuQQSD+vxgZeLpsY0O+wqClf94J8PIDL/vUnb9uSczalIB95f4vd4zhwJxeG YCH3FoWkRIA6cNwUL5Ex32QhWMXOMZwqZJNtP17FkFDRhkcMfP0pTbkaJ7J9vcIrS10V hxvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from; bh=tUxcqujmyzrcS1LtblBdw/qe/iYEeZBPt6y4T+ZCO+A=; b=AKXjgLq8PgnrT0dx5OzgTzqni1S94RJLKFm+URRRhLbI2rQNoVWSCr7GpSMgFVM0Jq 6mtoxP7yOqopZ2J4PkKcHY/IVv6TAnMsSJjFs0yTudQoTpjdBNXxvnbyuoC++czt2Lx5 hdWPbNE2CDo8NWSiTonlZc7ndZoc0Z7QhjhPRa768CLPs6d1eQawQuMC3nPvSXlvOHbf EUK9yX/GM8ta7wEL3j74aAOqyVqk4YuZjx/On34cpLXbe+iAC6JrSLRqUKSOFpc0MkRf 76g2wOaONmk97QVqzfDZo08knqkAuggeuFe1t86RgRXLdLCJ1lAYAXDeVme4zUcQMu0A 19PA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Received: from mail-out.m-online.net (mail-out.m-online.net. [212.18.0.9]) by gmr-mx.google.com with ESMTPS id c20si423743wmd.2.2020.11.13.07.44.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Nov 2020 07:44:19 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) client-ip=212.18.0.9; Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4CXjSg471Vz1qs3l; Fri, 13 Nov 2020 16:44:19 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4CXjSg3pLLz1tYWZ; Fri, 13 Nov 2020 16:44:19 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id Vl3TOr6--t1b; Fri, 13 Nov 2020 16:44:18 +0100 (CET) Received: from babic.homelinux.org (host-88-217-136-221.customer.m-online.net [88.217.136.221]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPS; Fri, 13 Nov 2020 16:44:18 +0100 (CET) Received: from localhost (mail.babic.homelinux.org [127.0.0.1]) by babic.homelinux.org (Postfix) with ESMTP id 657284540445; Fri, 13 Nov 2020 16:44:18 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at babic.homelinux.org Received: from babic.homelinux.org ([127.0.0.1]) by localhost (mail.babic.homelinux.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id UQgRnAzGnVgy; Fri, 13 Nov 2020 16:44:16 +0100 (CET) Received: from paperino.fritz.box (paperino.fritz.box [192.168.178.64]) by babic.homelinux.org (Postfix) with ESMTP id DD86145402C2; Fri, 13 Nov 2020 16:44:15 +0100 (CET) From: Stefano Babic To: swupdate@googlegroups.com Cc: Stefano Babic , Christian Storm Subject: [swupdate] [PATCH] Cosmetic: move lua handler search path in a cleverer way Date: Fri, 13 Nov 2020 16:44:14 +0100 Message-Id: <20201113154414.200642-1-sbabic@denx.de> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Original-Sender: sbabic@denx.de X-Original-Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of sbabic@denx.de) smtp.mailfrom=sbabic@denx.de Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , This implements changes in 38fa97 but in a much more better way as discussed on ML. Signed-off-by: Stefano Babic Signed-off-by: Christian Storm --- corelib/lua_interface.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c index 0f1b4f5..73f5a9c 100644 --- a/corelib/lua_interface.c +++ b/corelib/lua_interface.c @@ -1113,22 +1113,13 @@ int lua_handlers_init(void) #else if ((ret = luaL_dostring(gL, "require (\"swupdate_handlers\")")) != 0) { INFO("No Lua handler(s) found."); - if (luaL_dostring(gL, "return package.path:gsub(';','\\n'):gsub('?','swupdate_handlers')") == 0) { - TRACE("Lua handler search path:"); - lua_pop(gL, 1); - char *s = strdupa(lua_tostring(gL, -1)); - char *s1 = s; - char *lf; - - do { - lf = strchr(s1, '\n'); - if (lf) - *lf = '\0'; - TRACE("\t%s", s1); - if (lf) - s1 = ++lf; - } while (lf); - lua_pop(gL, 1); + if (luaL_dostring(gL, "return package.path:gsub('?','swupdate_handlers'):gsub(';','\\0')") == 0) { + const char *paths = lua_tostring(gL, -2); + for (int i=lua_tonumber(gL, -1); i >= 0; i--) { + TRACE("\t%s", paths); + paths += strlen(paths) + 1; + } + lua_pop(gL, 2); } } else { INFO("Lua handler(s) found.");