From patchwork Tue May 21 05:54:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 90520 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 720403858D33 for ; Tue, 21 May 2024 05:54:31 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by sourceware.org (Postfix) with ESMTPS id EF81E3858D1E for ; Tue, 21 May 2024 05:54:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EF81E3858D1E Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org EF81E3858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::62a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716270844; cv=none; b=sTA7ZKiKU3Em1rQ+F1ntaFvumJWLqvKXTorNUpuhNpf+MEr0G63WrpQjRfMxJ5nCKNL9Wp5+ihYJPfXZgbc97TRDfzoCP5Dolt+n0dgaCWnqepeW/HKXlHh/HhNAl8AAMNgIPV14BKH9DSMipLc2+eH26sB8DVX+7CelranhGFE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1716270844; c=relaxed/simple; bh=J3fpyHDNdDKQjm20+zYRaD2Bd1vnHR/gIvFru0RJ6qw=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:From:To; b=oBudvExlf7Ku0UXE2a+vYFR+owXeR02izKlm+G/2dkyOJeoG/iHmVWjBgo3LvYUrkFyb7Wcm3CJHPsYd1DwRGOZzsvGP1vuuYfYXntra2kf8JLXZcJ/VINY2qxP6Gdx0gj28qZxYaG/xgdoIYH6nG4eaep/J+2ZiXteNz0n+WBU= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-a5d67064885so331104866b.1 for ; Mon, 20 May 2024 22:54:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1716270840; x=1716875640; darn=sourceware.org; h=content-transfer-encoding:in-reply-to:autocrypt:references:to:from :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=DjXLzRIbTfLnDVvjqjBkWqks1NSJudVFsSxLOg6fMEw=; b=BalPRUrIDmEHQlBRaPSl67TX1eYah4x+a3OMcQcSg3ELQCkg21Oq376SYoEecgRMTb cjbyEASepAvgSU/u68f0zl7UDLolf9FyhL4+q2FpgBonnHqIGk7HkUK8VK4d2FkxTKCL 6NFokKkO1+iOdpqiulLExjJOx4riDKrPVOGK/S7qYh1uZPbZa/FbSV20zCT0BmqkFoUq NVnvVbwPsxu/y+mGI+W8GimaWVpNbpPs8mQiMcRIiSu9ni7zV8M7iBpNYsnWr7gaVKd3 G+fmfOGoe6RSUhBOQKhkO0Mfyg0x4SINyZZ3u37cAxwKXUYo32aTiskL3rf/W5L8Y19B E2kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716270840; x=1716875640; h=content-transfer-encoding:in-reply-to:autocrypt:references:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=DjXLzRIbTfLnDVvjqjBkWqks1NSJudVFsSxLOg6fMEw=; b=eSchTcsrMGllujjmrWn+MdG3YSR9WFUCeTg2QMO+V7cTmTcYjLbbJwhD0a56fEzW6t g7v8D59oF40hVl/Hh4U8ggOWYNoSVXZJTspZUlFqUph5WxMNowU0wO98vHuM6265Kx0I CLME4s0PhhycxIYO6xd11qOctC7hLrcQDYTg3IDxbgCtButlcCo1QqJgY8PJ7GRjBx1I GJmxoE1JcHfeoPhYmg6a0meWkr9dsA3UKTQcWefYNsth+B3G5ooNELbDQuweBf2HF86D eCUheEY8F+3eekTvqUJ+c1NGuLCeN8tf2Ht2rz4AdYq0i7VxSmsORHiq7P9q1toRRNoh FiEg== X-Gm-Message-State: AOJu0YztYwWWROvUUXc7LS6QDkdhNhwkWNSNzUGlerehXM66PBEt0/T8 SWgUUhLg4PQUXhd+P3U/NXZqRWn8XoQGyybrlpKAZxWY4CX2tQfMJhHzs2dshLwIDQg2kndukVA = X-Google-Smtp-Source: AGHT+IGdkSSul02Qev4NB2zqcp0QqffPvHrW/qhvZ479C3iqdHtwhTNMNcEQBAf3swGkT0BQCMzxRw== X-Received: by 2002:a17:906:d10a:b0:a59:b498:3ae5 with SMTP id a640c23a62f3a-a5a2d676354mr2758737266b.67.1716270840608; Mon, 20 May 2024 22:54:00 -0700 (PDT) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a5a1789240asm1562613366b.48.2024.05.20.22.54.00 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 20 May 2024 22:54:00 -0700 (PDT) Message-ID: <87f925c4-573c-40ae-bf47-4d07415e73c7@suse.com> Date: Tue, 21 May 2024 07:54:03 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: [PATCH 1/2] gas: adjust handling of quotes for .irpc Content-Language: en-US From: Jan Beulich To: Binutils References: <2d6b6832-f385-41ad-8bf5-e2b7dba581c8@suse.com> Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4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0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: <2d6b6832-f385-41ad-8bf5-e2b7dba581c8@suse.com> X-Spam-Status: No, score=-3024.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+patchwork=sourceware.org@sourceware.org The present handling of inner double quotes can lead to very strange diagnostics. Follow one of the two possible interpretations of the doc: @dots{} referring to possibly multiple white space separated @var{values}, each of which may be quoted. The original implementation, prior to 465e5617233f ("PR gas/3856"), hints at the other possible interpretation: When quoted there's only a single @var{values}, with inner quotes taken as ordinary characters. That, however, seems overall less useful to me. While touching the documentation, mirror the (inverse) spelling correction (@section line inconsistent with actual description) to .irp as well. --- The other interpretation of the doc would also require adjustments: in_quotes then would need to be left alone when encountering inner quotes. If quotes need to be possible to specify in a @var{values}, I think they ought to be backslash-escaped, much like elsewhere when quoted entities come into play. Adding support for that ought to be a separate change, though. --- a/gas/doc/as.texi +++ b/gas/doc/as.texi @@ -5859,7 +5859,7 @@ processing must also be performed upon t @end ifset @node Irp -@section @code{.irp @var{symbol},@var{values}}@dots{} +@section @code{.irp @var{symbol},@var{value}}@dots{} @cindex @code{irp} directive Evaluate a sequence of statements assigning different values to @var{symbol}. @@ -5893,12 +5893,13 @@ For some caveats with the spelling of @v @cindex @code{irpc} directive Evaluate a sequence of statements assigning different values to @var{symbol}. -The sequence of statements starts at the @code{.irpc} directive, and is -terminated by an @code{.endr} directive. For each character in @var{value}, -@var{symbol} is set to the character, and the sequence of statements is -assembled. If no @var{value} is listed, the sequence of statements is -assembled once, with @var{symbol} set to the null string. To refer to -@var{symbol} within the sequence of statements, use @var{\symbol}. +The sequence of statements starts at the line following the @code{.irpc} +directive, and is terminated by an @code{.endr} directive. For each character +in each (possibly double quoted) @var{values}, @var{symbol} is set to the +character, and the sequence of statements is assembled. If no @var{values} is +listed, the sequence of statements is assembled once, with @var{symbol} set to +the null string. To refer to @var{symbol} within the sequence of statements, +use @var{\symbol}. For example, assembling --- a/gas/macro.c +++ b/gas/macro.c @@ -1369,12 +1369,6 @@ expand_irp (int irpc, size_t idx, sb *in { bool in_quotes = false; - if (irpc && in->ptr[idx] == '"') - { - in_quotes = true; - ++idx; - } - while (idx < in->len) { if (!irpc) @@ -1383,16 +1377,14 @@ expand_irp (int irpc, size_t idx, sb *in { if (in->ptr[idx] == '"') { - size_t nxt; - - if (irpc) - in_quotes = ! in_quotes; + in_quotes = ! in_quotes; + ++idx; - nxt = sb_skip_white (idx + 1, in); - if (nxt >= in->len) + if (! in_quotes) { - idx = nxt; - break; + idx = sb_skip_white (idx, in); + if (idx >= in->len) + break; } } sb_reset (&f.actual); --- /dev/null +++ b/gas/testsuite/gas/macros/irpc-quote.l @@ -0,0 +1,18 @@ +# This should match the output of gas irpc-quote.s. +#... +> < +>a< +>b< +>c< +>d< +> < +>e< +>f< +>1< +>2< +> < +>3< +>4< +>5< +>6< +> < --- /dev/null +++ b/gas/testsuite/gas/macros/irpc-quote.s @@ -0,0 +1,6 @@ + .irpc c, " ab" cd " ef" + .print ">\c<" + .endr + .irpc c, "12 " 34 "56 " + .print ">\c<" + .endr --- a/gas/testsuite/gas/macros/macros.exp +++ b/gas/testsuite/gas/macros/macros.exp @@ -109,3 +109,5 @@ run_list_test count # AIX targets need an extended regexp to match "\+". setup_xfail "avr-*-*" "cris*-*-*" "msp430-*-*" "z80-*-*" "*-*-aix*" run_list_test irp-count + +run_list_test irpc-quote