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 gLuNJzh95mXZZQEAbAwnHQ (envelope-from ) for ; Tue, 05 Mar 2024 03:02:32 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id AK9tJDh95mXnNwAA62LTzQ (envelope-from ) for ; Tue, 05 Mar 2024 03:02:32 +0100 X-Envelope-To: patches@johnnyrichard.com Authentication-Results: aspmx1.migadu.com; none 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 88C683D6AF for ; Tue, 5 Mar 2024 03:02:32 +0100 (CET) DKIM-Signature: a=rsa-sha256; bh=gbWBgJsY4rq1O+LMCfqvOdTFLZdrybHsHoB6keG5P9I=; c=simple/simple; d=lists.sr.ht; h=Date:From:To:Subject:References:In-Reply-To:List-Unsubscribe:List-Subscribe:List-Archive:List-Post:List-ID; q=dns/txt; s=20240113; t=1709604151; v=1; b=BxJZ3mYUsL+McyDIbKXGBP0c0TGiAH2PDBOLYhyg+yMD6k7TWLns/WXXNynfOy18x6urOsIZ /f2osa8RZJSvMJ1FKRtYN5MHnmSW0LAiTOaxu1CLgJChrVnUy2QGrNYDsSb2qwhotytsgD2Aog5 RWe5IlYSrEYENG8h+3rt1YcTmkY6ZBOZsLCf0pxonm6vwz705Qe4CZuktPT62gzmmJpXQ2vWbXv veHaFPXzV1pjYGqdBrLiNztKr+9SwWGeJuw7adZY5a2ppbG8pREyJYAYGOlZ9lNbE1j500R4Xws QFYutPxhglOHK6z8AyCmVMHtOZk6+/TWUkAvnZM1eZ7pg== Received: from lists.sr.ht (unknown [46.23.81.154]) by mail-a.sr.ht (Postfix) with ESMTPSA id AA3A420166 for ; Tue, 5 Mar 2024 02:02:31 +0000 (UTC) Received: from dormouse.elm.relay.mailchannels.net (dormouse.elm.relay.mailchannels.net [23.83.212.50]) by mail-a.sr.ht (Postfix) with ESMTPS id 82EC220152 for <~johnnyrichard/olang-devel@lists.sr.ht>; Tue, 5 Mar 2024 02:02:30 +0000 (UTC) X-Sender-Id: hostingeremail|x-authuser|carlos@maniero.me Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id AD4B46C2F45 for <~johnnyrichard/olang-devel@lists.sr.ht>; Tue, 5 Mar 2024 02:02:28 +0000 (UTC) Received: from nl-srv-smtpout4.hostinger.io (unknown [127.0.0.6]) (Authenticated sender: hostingeremail) by relay.mailchannels.net (Postfix) with ESMTPA id 8FD466C2AD5 for <~johnnyrichard/olang-devel@lists.sr.ht>; Tue, 5 Mar 2024 02:02:26 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1709604146; a=rsa-sha256; cv=none; b=PZ07y4Oz3lMBMqaU/WR5SGXwD2Z20B8jEdvEG0tU4bR8iPq6l/Qg+QzB/26P8BNOZyAA0W SjOikbIFYS0HoVhOIV+llUg++GJTvB4T4nawBELU0m6BGQsppiKq8m+hlfHbSHSNwZSmCj iCCGF3waZLy68p1NC46MUmrFxldE5Pu+mqYdeE3kKhUw5YqvMd4ZDhCCulWe3RUcn/1Ojj IY7o1HU4eIeID1W9t/LYnPT1WuFNwYkx6pOwjIJRN9boyBIpgRdl77BOt++j+is/3ck14g e8mbf+9W2GIiXSDzAKbC897jzAwqTNNcwcjSqaBUAc3IBfF/fA9ZvjXHX46bGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1709604146; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Z1814p9nbffFffaSDr6CSORpXWmTSyi9CxbPngZwwZU=; b=ti7ezgKg5yiDkNV1ibsmxqi+Bi6lhZ0J3OAuPm+20Z+TljoEHIrS4lsTZUm21TCOTpRRy/ +W0oAu1jvaaZXGHDthATEO9c3xqagodPigvSrKMAtSCSCkcludovJla6EfBkRZtLBJkilL aTRsR5HhyknJ90q3+bsvTFT4MPLPLzPHstudZWCNPi2QVKJfMpTX7utU3J2FhxYXcV4CM+ BVXpNqQHeXmgFNGk8TRk6fL4ZdT8OthDNMRpaiWauO4JmtpKOe3la01hbqqQTGvA/a88yr qDi6w7ZXjf9OYIpGKwMg4OVGexMeMjjR5nlNyJOw7Y+L4sryPlUYhObarLFAgA== ARC-Authentication-Results: i=1; rspamd-7f9dd9fb96-cdwwq; auth=pass smtp.auth=hostingeremail smtp.mailfrom=carlos@maniero.me X-Sender-Id: hostingeremail|x-authuser|carlos@maniero.me X-MC-Relay: Neutral X-MailChannels-SenderId: hostingeremail|x-authuser|carlos@maniero.me X-MailChannels-Auth-Id: hostingeremail X-Battle-Company: 18f649387a87ad1e_1709604147166_3466654334 X-MC-Loop-Signature: 1709604147166:2541120191 X-MC-Ingress-Time: 1709604147165 Received: from nl-srv-smtpout4.hostinger.io (nl-srv-smtpout4.hostinger.io [145.14.159.45]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.106.138.70 (trex/6.9.2); Tue, 05 Mar 2024 02:02:27 +0000 Mime-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=maniero.me; s=hostingermail1; t=1709604144; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Z1814p9nbffFffaSDr6CSORpXWmTSyi9CxbPngZwwZU=; b=Joag++fbUq/JDOc9H8ZVim0x5VMixYqkwfNZ+CPq0LnVGE2YJh0+H7Vkk7Hc/g7KZ1SEV8 p40q+8vvDlEJDzcfVGzVoOHvwBIg/Y24iJH88c0e7kxiOnGu4armRXkRoozYWFl7oFuY36 trBtp8LN1JgMzMSX9hYq3r2TnYvL6jqf3i3fiVt/GPgZwWAwoD8CFy6hJAKOrXGcOJ9ceQ t7fZf08xMUMFqZVWiJ9WDzDMVmU/+ckJCQTObbIFlMRShGEILIr+hwUriYCz+9JDQ8ByYZ 9FaT3/XEs2j2jxeu+8OhRQyPp0Z42dXwwqrxbn9uID8P3ze0axs7lQRa/3yDKg== Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Mon, 04 Mar 2024 23:02:14 -0300 Message-Id: From: "Carlos Maniero" To: "Johnny Richard" , <~johnnyrichard/olang-devel@lists.sr.ht> Subject: Re: [PATCH olang v1 3/3] cli: add compilation -o option with --save-temps X-Mailer: aerc 0.15.2-211-g37d5fc691aff References: <20240304193313.961286-1-johnny@johnnyrichard.com> <20240304193313.961286-4-johnny@johnnyrichard.com> In-Reply-To: <20240304193313.961286-4-johnny@johnnyrichard.com> X-CM-Envelope: MS4xfIIwCMc6JjLLLdscb3gpIlIcnMemn9T0YWQL5+bPuPRS/YcSHCt61wHWBsTdCV4K5a71abqnW6sx28f0fu5pLO5I6DxAFKgcht4IR4TnIsnbhE+Uj66r srUFjhl0wYXDehwf12gxil0Bkt2cyctBDdiosoIDBz0op2VIxe5xNp+T/mIqe5Vnc207YsVXtMzzkhamnBsOYGZluP3VLe4cE/cPY6UGJvjggk1oiZPWf/HR M/KOjkh6tp8SS9j3pb4HmA== X-CM-Analysis: v=2.4 cv=OrhJyT/t c=1 sm=1 tr=0 ts=65e67d30 a=5+VMC1FZ3J4mVPAKpPmAqg==:117 a=5+VMC1FZ3J4mVPAKpPmAqg==:17 a=IkcTkHD0fZMA:10 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=XQpwUSHf3pvELI0WXrUA:9 a=QEXdDO2ut3YA:10 a=BXDaF_L80NY05PYiAFlV:22 X-AuthUser: carlos@maniero.me 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-Flow: FLOW_IN X-Migadu-Country: NL X-Migadu-Spam-Score: -4.00 X-Spam-Score: -4.00 X-Migadu-Queue-Id: 88C683D6AF X-Migadu-Scanner: mx13.migadu.com X-TUID: FfgSD4O4raAw > +typedef enum > +{ > + CLI_OPT_DUMP_TOKENS =3D 1 << 1, > + CLI_OPT_OUTPUT =3D 1 << 2, > + CLI_OPT_SAVE_TEMPS =3D 1 << 3 > +} cli_opt; nitpick: Any particular reason to avoid using the first bit? typedef enum { CLI_OPT_DUMP_TOKENS =3D 1 << 0, CLI_OPT_OUTPUT =3D 1 << 1, CLI_OPT_SAVE_TEMPS =3D 1 << 2 } cli_opt; > + string_view_t file_path; 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)* > - char *prog =3D cli_args_shift(&args); > + opts.prog =3D 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. > + assert(opts && "args is required"); s/opts/args > + string_view_t asm_ext =3D 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] =3D 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));