From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) by sourceware.org (Postfix) with ESMTPS id 3334D3858D1E for ; Mon, 18 Apr 2022 19:09:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3334D3858D1E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f49.google.com with SMTP id n126-20020a1c2784000000b0038e8af3e788so87275wmn.1 for ; Mon, 18 Apr 2022 12:09:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=Nsn76nbNqdDIBxxdUreyWnwS4NYV7BebjHtiOBapn8k=; b=mIiwEkD4Ma7jUWiUOs9AJhaLzFgFonfJS2XqMxWMPB7XZshMysJH8FymfuBHK64dqY I+yZ09vhfJ2SD0oPhpTeggvWBw6Coc/t4hV7O3oGiyytwhS3Gh+DbeBkzFuuKPtwYAJF KhqUve7aQoyWyomUDq3YYKPN/5iGLO6CAOd0O76KVFCzw0XmGshCs/Hr2SlyBxsfSmTN oZpVaIhUq+5kNO+9WWWaEnk8SavqIHRzmJCzLLTfvAueYTgQM1OaKtfTlcYjn5BVSD+L TbdTjgZtd3AGF+Fg+j2jzSUphloV9s8EqaHprFSS2A0bzPqWAt0xTbKhsL0KmWKeAQBp lUPQ== X-Gm-Message-State: AOAM5339hMqW5ipBGPblyeMpKOYj4zio0a9UpUYzELyfqWx4YuY/+QJ3 4fSkiQwsR+PnSm3CgwKA2EiNVNOZwgs= X-Google-Smtp-Source: ABdhPJw0ecKV1b/t4qJCzEfWvU3T7e5MuOHx9+oR7LTgZ3o3msP8HQyDj9v+uoy78EwzaGSFWbM8qA== X-Received: by 2002:a05:600c:19c6:b0:392:88e2:7426 with SMTP id u6-20020a05600c19c600b0039288e27426mr12584648wmq.132.1650308944211; Mon, 18 Apr 2022 12:09:04 -0700 (PDT) Received: from ?IPV6:2001:8a0:f924:2600:209d:85e2:409e:8726? ([2001:8a0:f924:2600:209d:85e2:409e:8726]) by smtp.gmail.com with ESMTPSA id u20-20020a05600c19d400b003929c4bf23asm2203164wmq.44.2022.04.18.12.09.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 18 Apr 2022 12:09:03 -0700 (PDT) Message-ID: <1343c861-94b4-d0e6-67af-dd6eb1f870c3@palves.net> Date: Mon, 18 Apr 2022 20:09:02 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH 5/5] gdbsupport: add path_join function Content-Language: en-US To: Simon Marchi , Lancelot SIX Cc: Simon Marchi , gdb-patches@sourceware.org References: <20220414200137.3479373-1-simon.marchi@polymtl.ca> <20220414200137.3479373-5-simon.marchi@polymtl.ca> <20220415143827.t2nlcfhmh2pondev@ubuntu.lan> From: Pedro Alves In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Apr 2022 19:09:06 -0000 On 2022-04-18 19:43, Simon Marchi via Gdb-patches wrote: >> One implementation could be: >> >> /* The real worker can be compiled in a .cc file if you wish. */ >> extern std::string path_join_1 (std::string a, std::string b); >> >> template > std::string >> path_join (std::string a, std::string b, Args... comps) >> { >> return path_join (path_join (a, b), comps...); >> } >> >> template <> >> std::string >> path_join (std::string a, std::string b) >> { >> return path_join_1 (a, b); >> } >> >> I do not pretend this is optimal (it is not). In this POC I pass all >> arguments as std::string and by value, this is probably not what you >> want to do in a production grade implementation, but this just gives the >> overall idea. >> >> What do you think? > If you can make it work using gdb::string_view or const char *, I think > it would be ok. I'll give it a try. But otherwise, I am personally > fine with the sentinel nullptr, given that the compiler gives you a > warning if you forget it. I think it would just work as is you replace std::string with const char * in Lancelot's snippet above. FWIW, I had the same thought as Lancelot about using variable templates instead of varargs. OOC, is there any place in GDB that wants to pass more than two components to path_join? I skimmed the patch and didn't notice one.