From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:1008:1e59::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id xLlpOXjJ5mVRiwAAbAwnHQ (envelope-from ) for ; Tue, 05 Mar 2024 08:27:53 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id IMaiNXjJ5mVfRAAA62LTzQ (envelope-from ) for ; Tue, 05 Mar 2024 08:27:52 +0100 X-Envelope-To: patches@johnnyrichard.com Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=lists.sr.ht header.s=20240113 header.b=S8hte3fb; dkim=pass header.d=johnnyrichard.com header.s=key1 header.b="BWEFD/ul"; spf=pass (aspmx1.migadu.com: domain of lists@sr.ht designates 46.23.81.152 as permitted sender) smtp.mailfrom=lists@sr.ht; dmarc=pass (policy=quarantine) header.from=johnnyrichard.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=johnnyrichard.com; s=key1; t=1709623672; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-unsubscribe:list-subscribe: list-post:dkim-signature; bh=UGAPf1k07i8yF0/awRYHQ8VS6tE2D/bGStOOnKXMDn4=; b=fpJg5t3w5Hh1WB/hdO2UaJt+yufO18Ndnhwv4r6UHWNSfslrbvguLTHldgSG+LmzFSIi9p nz6+7TVwdt+Rns1ut4k9pBy3sJ1R6uMjzC9GIfCbVlJqU4U9Ce7nVmv3jxPsyjRuYKzgo7 2rLr184DkuqGAuZuJJYPkyJCB3WPkHfTJLmvIlG7Wz6Q4Ymuj20ghwDbkf5lCae1RyvikH ANIDCuc1fhAMz9AiwzFy2VeqPQb+xcqfYr1RFyTfiwo9WXAx21YcZZOELDWzpDGqaZPpE1 rZA6z2ZhhYoMKsNEb2aaW53upqGxEWTIlnU3gTlLRXIimD0bFwayqP5c0d/fjQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=lists.sr.ht header.s=20240113 header.b=S8hte3fb; dkim=pass header.d=johnnyrichard.com header.s=key1 header.b="BWEFD/ul"; spf=pass (aspmx1.migadu.com: domain of lists@sr.ht designates 46.23.81.152 as permitted sender) smtp.mailfrom=lists@sr.ht; dmarc=pass (policy=quarantine) header.from=johnnyrichard.com ARC-Seal: i=1; s=key1; d=johnnyrichard.com; t=1709623672; a=rsa-sha256; cv=none; b=mnPxpAqrQfYzBpnNMs/8TT/0txH41/vfMQifvefB6QjZSQ9Zw+9fbpX9rlcfjV4yiqgRXs ANx596EP30nK9np0APPtxn80Ws9FnIvmUx8HyefT8BoHIFGtMtGPIuLMaofwcwfWIafkF9 0AmZZzJy4w1VbhNxugPhQZVT+phRVi4czTbVfpwhQ8z3WoCTgx71/vW4L79M2cGe8hM/x/ wsm2lUMXZErH43/XncJIOHnDZwsbSaIdcYePH9SygewWb6DSeRu4u06YDqTVjElteyvcCx 5n8hkMw+AZ3UpHQej5+zXGcSiDrCES6lBXhF8X6g7gztLTItMvJktA6wKlNw3A== Received: from mail-a.sr.ht (mail-a.sr.ht [46.23.81.152]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 3E3D610ACE for ; Tue, 5 Mar 2024 08:27:52 +0100 (CET) DKIM-Signature: a=rsa-sha256; bh=Xrx8M0/dFvfLA4OpEkEUhWMxpCMoOJeXkI8NUX3o+zY=; c=simple/simple; d=lists.sr.ht; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-Unsubscribe:List-Subscribe:List-Archive:List-Post:List-ID; q=dns/txt; s=20240113; t=1709623671; v=1; b=S8hte3fbWzNFKn5hCQ7xT9t+R50RTsmd6HbeCccT0oTznYgt4BBItDmjjbDvuTK6bQ1Q1xh2 p4mx6W/N2vy5X7c7YgkyHbdpe702RTFbHnizT1hH0UBPnQ7BV7Cd7FeHyd7AAUUl2tsR3IFZzuj YWtPZj89WfQfgNYUR2Mo1YOGzUNA0Ryz2kDA531zWClAJUBOwqZwip5Tf/CXU4VN1xeYPGGmSv1 Q/dHdO/K3PptDCCpvyLUzftbooVqL9fmZzHEOste9d7VpGiXaqJrzVF6oC7Ba6j5sx6esz3pMJ3 /8IybMlP9+44f71MOfmdCsC4sj4IUHlc4ZyUVh3yZ0WYg== Received: from lists.sr.ht (unknown [46.23.81.154]) by mail-a.sr.ht (Postfix) with ESMTPSA id 9376A2017D for ; Tue, 5 Mar 2024 07:27:51 +0000 (UTC) Received: from out-189.mta1.migadu.com (out-189.mta1.migadu.com [95.215.58.189]) by mail-a.sr.ht (Postfix) with ESMTPS id C0DFF20172 for <~johnnyrichard/olang-devel@lists.sr.ht>; Tue, 5 Mar 2024 07:27:50 +0000 (UTC) Date: Tue, 5 Mar 2024 09:27:58 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=johnnyrichard.com; s=key1; t=1709623669; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=UGAPf1k07i8yF0/awRYHQ8VS6tE2D/bGStOOnKXMDn4=; b=BWEFD/ulzqOAAxlJ5h2TRzise4+izjT2+ADKtHIXh+p3eg8sNCTPHhFszOQyACdFOnyjIq fhtQzaqyghm5S8g+t9ZwZW19NfsmHyWrS3xAT+QpytNZZtjBgPwz8/b+BFNzUaUMrI/LDx n3L0HTt+RdE9fAaqLNqpiCtuz/dwptLFz1zjbOLHZHc73inL+qYSi5k2a0X0WvFASHnAZe 8wQJaECoU1Ngsatq4RL3xI7Y6zYq9JaxxGjsFKlJznPJ9X12YLWJPcEbd1zSwpWGZKiDb1 1Rcw7t8YjpUU9sPWAjhp59PUnSnOW+EQT56KwjXhbD7iM9nUQoEjzvDI6fstvw== X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Johnny Richard To: Carlos Maniero Cc: ~johnnyrichard/olang-devel@lists.sr.ht Subject: Re: [PATCH olang v1 3/3] cli: add compilation -o option with --save-temps Message-ID: X-Sourcehut-Patchset-Update: SUPERSEDED References: <20240304193313.961286-1-johnny@johnnyrichard.com> <20240304193313.961286-4-johnny@johnnyrichard.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Unsubscribe: List-Subscribe: List-Archive: Archived-At: List-Post: List-ID: ~johnnyrichard/olang-devel <~johnnyrichard/olang-devel.lists.sr.ht> Sender: ~johnnyrichard/olang-devel <~johnnyrichard/olang-devel@lists.sr.ht> X-Migadu-Country: NL X-Migadu-Flow: FLOW_IN X-Migadu-Scanner: mx12.migadu.com X-Migadu-Spam-Score: -7.32 X-Spam-Score: -7.32 X-Migadu-Queue-Id: 3E3D610ACE X-TUID: AYZHQy7t2D/u On Mon, Mar 04, 2024 at 11:02:14PM -0300, Carlos Maniero wrote: > > > +typedef enum > > +{ > > + CLI_OPT_DUMP_TOKENS = 1 << 1, > > + CLI_OPT_OUTPUT = 1 << 2, > > + CLI_OPT_SAVE_TEMPS = 1 << 3 > > +} cli_opt; > > nitpick: Any particular reason to avoid using the first bit? no reason, I will fix it! > What is the point of making *file_path* a SV? Ever single place it is > used you are accessing it's char pointer directly - *file_path.chars*. > It looks unsafe to just ignore the SV's size, example: > *print_token(opts->file_path.chars, &token)* I made file_path a string view to keep alined with other string view fields. It was just cosmetic. I agree on keep a cstr instead. > > - char *prog = cli_args_shift(&args); > > + opts.prog = string_view_from_cstr(cli_args_shift(&args)); > > nitpick: Is that a standard calling arg0 as prog? I know it was already > there, but taking a fresh look at this name, I find it hard to > understand. WDYT about *opts.compiler_path*, *opts.the_0c_path* or > *opts.this_path*? The point is that, program can be ambiguos here as it > could be both the compiler's program or the program to be compiled. I will go with **compiler_path** for this one. > > + assert(opts && "args is required"); > > s/opts/args Opss... > > + string_view_t asm_ext = string_view_from_cstr(".s"); > > + char asm_file[opts->output_bin.size + asm_ext.size + 1]; > > + memcpy(asm_file, opts->output_bin.chars, opts->output_bin.size); > > + memcpy(asm_file + opts->output_bin.size, asm_ext.chars, asm_ext.size); > > + asm_file[opts->output_bin.size + asm_ext.size] = 0; > > nitpick: you have achieved the same later at this same file using > *sprintf* which I think reads better. > > + char asm_file[opts->output_bin.size + 3]; > + sprintf(asm_file, "" SV_FMT ".s", SV_ARG(opts->output_bin)); Sure...