From debbugs-submit-bounces@debbugs.gnu.org Sun Jan 24 20:56:33 2016 Received: (at submit) by debbugs.gnu.org; 25 Jan 2016 01:56:33 +0000 Received: from localhost ([127.0.0.1]:35322 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aNWOO-0004SU-MF for submit@debbugs.gnu.org; Sun, 24 Jan 2016 20:56:32 -0500 Received: from eggs.gnu.org ([208.118.235.92]:59740) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aNVzT-0003t5-Fh for submit@debbugs.gnu.org; Sun, 24 Jan 2016 20:30:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aNVzH-0003ty-GF for submit@debbugs.gnu.org; Sun, 24 Jan 2016 20:30:42 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:45395) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aNVzH-0003tu-AV for submit@debbugs.gnu.org; Sun, 24 Jan 2016 20:30:35 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50686) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aNVzC-0006C6-3N for bug-sed@gnu.org; Sun, 24 Jan 2016 20:30:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aNVz2-0003qs-Hz for bug-sed@gnu.org; Sun, 24 Jan 2016 20:30:29 -0500 Received: from mout2.freenet.de ([195.4.92.92]:39055) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aNVz2-0003oz-C0 for bug-sed@gnu.org; Sun, 24 Jan 2016 20:30:20 -0500 Received: from [195.4.92.140] (helo=mjail0.freenet.de) by mout2.freenet.de with esmtpa (ID th.heymann@freenet.de) (port 25) (Exim 4.85 #1) id 1aNVyz-0000kZ-Bt for bug-sed@gnu.org; Mon, 25 Jan 2016 02:30:17 +0100 Received: from localhost ([::1]:54269 helo=mjail0.freenet.de) by mjail0.freenet.de with esmtpa (ID th.heymann@freenet.de) (Exim 4.85 #1) id 1aNVyz-0006gi-7K for bug-sed@gnu.org; Mon, 25 Jan 2016 02:30:17 +0100 Received: from mx5.freenet.de ([195.4.92.15]:56753) by mjail0.freenet.de with esmtpa (ID th.heymann@freenet.de) (Exim 4.85 #1) id 1aNVwk-0004bB-LJ for bug-sed@gnu.org; Mon, 25 Jan 2016 02:27:58 +0100 Received: from xd933ff49.dyn.telefonica.de ([217.51.255.73]:35156 helo=desktop1.fritz.box) by mx5.freenet.de with esmtpsa (ID th.heymann@freenet.de) (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (port 587) (Exim 4.85 #1) id 1aNVwk-0001ol-Eo for bug-sed@gnu.org; Mon, 25 Jan 2016 02:27:58 +0100 Date: Mon, 25 Jan 2016 02:28:22 +0100 From: Thorsten Heymann To: bug-sed@gnu.org Subject: 'y' command doesn't allow a comment after it one the same line Message-ID: <20160125012822.GB16982@desktop1.fritz.box> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-Originated-At: 217.51.255.73!35156 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Sun, 24 Jan 2016 20:56:31 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) Unlike other commands, the current implementation of the 'y' command does not allow a comment on the same line if the command is not "terminated" by a ';' For example (the comments are part of the program): s/1/a/g # Substitute 1's by a's x # Swapping hold and pattern buffer 1d # Deleting the first line ... works, but y/1/a/ # Substitute 1's by a's produces: sed: -e expression #1, char 8: extra characters after command This patch fixes this. Greets, Thorsten --- sed/compile.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sed/compile.c b/sed/compile.c index 270caaf..442aeb5 100644 --- a/sed/compile.c +++ b/sed/compile.c @@ -1329,7 +1329,10 @@ compile_program(struct vector *vector) cur_cmd->x.translate = translate; } - if ((ch = in_nonblank()) != EOF && ch != '\n' && ch != ';') + ch = in_nonblank(); + if (ch == CLOSE_BRACE || ch == '#') + savchar(ch); + else if (ch != EOF && ch != '\n' && ch != ';') bad_prog(_(EXCESS_JUNK)); free_buffer(b); -- 2.4.10 From debbugs-submit-bounces@debbugs.gnu.org Thu Jan 26 22:05:16 2017 Received: (at 22460) by debbugs.gnu.org; 27 Jan 2017 03:05:16 +0000 Received: from localhost ([127.0.0.1]:46843 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cWwqZ-0005Ob-6X for submit@debbugs.gnu.org; Thu, 26 Jan 2017 22:05:16 -0500 Received: from mail-qt0-f193.google.com ([209.85.216.193]:34319) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cWwqU-0005Nz-I7 for 22460@debbugs.gnu.org; Thu, 26 Jan 2017 22:05:06 -0500 Received: by mail-qt0-f193.google.com with SMTP id w20so9657381qtb.1 for <22460@debbugs.gnu.org>; Thu, 26 Jan 2017 19:05:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=75kkMN4dEHFZoaqaU/Sp2veDSzS03+XZmhTe31yjU7U=; b=T4TeiCX3obl21iUpdxIKzqSnsE537oQZNhH1IVzEwhIUHkiaI239i3XZ+OcX7DW0z/ yXIyb90cb0jXQhH4A7gFvN1tp4UDd+coLZbtjTlQyfR79LtqwB8Jfb2Znj2fcxyF1nzg wcX2wTm8aWG9hOVBxreoiM4GYu7yGXIPkbqlkejaaT1murQdMrhQ2okRoXjd0QivfE4b 1rcTJ5ME60Ccu8ONFlP3/BXnIZ6L8z0prhcmzcMZf/Z7rIv6URutm+nWLvLctR83vJuD s4AB4DfO7vcA61KfJNd6WxsSMdRonCLmwPqG6CPomc87MwhJNHsXnigN04ZUkYG4y6d8 45oQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=75kkMN4dEHFZoaqaU/Sp2veDSzS03+XZmhTe31yjU7U=; b=jvKW4sB7LMQq6SJhi2Q2cCe2WtDLWwlb05PV4qZTliYLsUAymE0JnsBB7zHNxGVYYO hY95hd7jul9Zt/Vtd36rpEEtFn/9c2vkV2uK0PlTv14j1BK3s02+9Yq5CHml5OhAn8vm PRXNU7+yFyp3ULobcH3AwSyQfRtHBOddIUCwYM9IPSKYmPx/BcX5MyicADxEvVshwDgQ DEezlYLXiK8l6wo2kxncK2RoU+FrK5klPNkE7g2c4Up6iMEG0XVAUPNS6CDCIb66DWX9 ZMwlo+f6MpymUZkuYbKT8UcG9CpTcdjbedRDENbmURWI5bOJOpm5BmdK89v4zNJbEJYn 5q9w== X-Gm-Message-State: AIkVDXLB4p3l8sDMRxjYAZnMy6m13PmqXRSFacrB16it6AH+b3AFyxgEpI0osGbAS2qGYA== X-Received: by 10.55.190.129 with SMTP id o123mr6514928qkf.110.1485486297217; Thu, 26 Jan 2017 19:04:57 -0800 (PST) Received: from gmail.com (housegordon.org. [104.236.108.240]) by smtp.gmail.com with ESMTPSA id s75sm2964934qka.36.2017.01.26.19.04.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Jan 2017 19:04:56 -0800 (PST) Date: Fri, 27 Jan 2017 03:04:27 +0000 From: Assaf Gordon To: Thorsten Heymann Subject: Re: bug#22460: 'y' command doesn't allow a comment after it one the same line Message-ID: <20170127030426.GB12674@gmail.com> References: <20160125012822.GB16982@desktop1.fritz.box> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="wzJLGUyc3ArbnUjN" Content-Disposition: inline In-Reply-To: <20160125012822.GB16982@desktop1.fritz.box> User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Score: 1.2 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Hello Thorsten, Sorry for the delayed response. On Mon, Jan 25, 2016 at 02:28:22AM +0100, Thorsten Heymann wrote: >Unlike other commands, the current implementation of the 'y' command does >not allow a comment on the same line if the command is not >"terminated" by a ';' [...] Content analysis details: (1.2 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.5 RCVD_IN_SORBS_SPAM RBL: SORBS: sender is a spam source [209.85.216.193 listed in dnsbl.sorbs.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [209.85.216.193 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (assafgordon[at]gmail.com) -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.216.193 listed in wl.mailspike.net] 0.6 URIBL_SBL Contains an URL's NS IP listed in the SBL blocklist [URIs: init.sh] 0.1 URIBL_SBL_A Contains URL's A record listed in the SBL blocklist [URIs: init.sh] 0.0 T_DKIM_INVALID DKIM-Signature header exists but is not valid -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-Debbugs-Envelope-To: 22460 Cc: 22460@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.8 (/) --wzJLGUyc3ArbnUjN Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline Hello Thorsten, Sorry for the delayed response. On Mon, Jan 25, 2016 at 02:28:22AM +0100, Thorsten Heymann wrote: >Unlike other commands, the current implementation of the 'y' command does >not allow a comment on the same line if the command is not >"terminated" by a ';' That is indeed a bug, and a rather old one. Your suggested fix is correct, but I thought that instead of duplicating the same few lines, it might be better to extract the code to a new function. The attached patch does that and adds a corresponding unit test. Comments welcomed, - assaf --wzJLGUyc3ArbnUjN Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-sed-allow-comments-braces-after-y.patch" >From 4f6e75fab9999a45205266b3b7620f820ae60e43 Mon Sep 17 00:00:00 2001 From: Assaf Gordon Date: Fri, 27 Jan 2017 02:57:32 +0000 Subject: [PATCH] sed: allow comments,braces after y/// sed-4.3 and earlier rejected the following: $ sed 'y/1/a/ #f' sed: -e expression #1, char 8: extra characters after command Reported by Thorsten Heymann in https://bugs.gnu.org/22460 . * sed/compile.c (read_end_of_cmd): New function, consumes sed script input until newline, EOF, semicolon, closing brace or comment is found. (compile_program): Call new function instead of duplicating code. * testsuite/command-endings.sh: New test, including y/// bug. * testsuite/local.mk: Add new test. * NEWS: Mention it. --- NEWS | 5 ++ sed/compile.c | 43 ++++++++------ testsuite/command-endings.sh | 137 +++++++++++++++++++++++++++++++++++++++++++ testsuite/local.mk | 1 + 4 files changed, 167 insertions(+), 19 deletions(-) create mode 100644 testsuite/command-endings.sh diff --git a/NEWS b/NEWS index 473965d..93757a5 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,11 @@ GNU sed NEWS -*- outline -*- * Noteworthy changes in release ?.? (????-??-??) [?] +** Bug fixes + + sed no longer rejects comments and closing braces after y/// commands. + [Bug existed at least since sed-3.02] + * Noteworthy changes in release 4.3 (2016-12-30) [stable] diff --git a/sed/compile.c b/sed/compile.c index 966752b..64ddfa4 100644 --- a/sed/compile.c +++ b/sed/compile.c @@ -274,6 +274,21 @@ in_nonblank(void) return ch; } +/* Consume script input until a valid end of command marker is found: + comment, closing brace, newline, semicolon or EOF. + If any other character is found, die with 'extra characters after command' + error. +*/ +static void +read_end_of_cmd (void) +{ + const int ch = in_nonblank(); + if (ch == CLOSE_BRACE || ch == '#') + savchar(ch); + else if (ch != EOF && ch != '\n' && ch != ';') + bad_prog(_(EXCESS_JUNK)); +} + /* Read an integer value from the program. */ static countT in_integer (int ch) @@ -1103,11 +1118,8 @@ compile_program(struct vector *vector) bad_prog(_(EXCESS_CLOSE_BRACE)); if (cur_cmd->a1) bad_prog(_(NO_CLOSE_BRACE_ADDR)); - ch = in_nonblank(); - if (ch == CLOSE_BRACE || ch == '#') - savchar(ch); - else if (ch != EOF && ch != '\n' && ch != ';') - bad_prog(_(EXCESS_JUNK)); + + read_end_of_cmd (); vector->v[blocks->v_index].x.jump_index = vector->v_length; blocks = release_label(blocks); /* done with this entry */ @@ -1177,16 +1189,14 @@ compile_program(struct vector *vector) if (ISDIGIT(ch) && posixicity != POSIXLY_BASIC) { cur_cmd->x.int_arg = in_integer(ch); - ch = in_nonblank(); } else - cur_cmd->x.int_arg = -1; - - if (ch == CLOSE_BRACE || ch == '#') - savchar(ch); - else if (ch != EOF && ch != '\n' && ch != ';') - bad_prog(_(EXCESS_JUNK)); + { + cur_cmd->x.int_arg = -1; + savchar (ch); + } + read_end_of_cmd (); break; case '=': @@ -1203,11 +1213,7 @@ compile_program(struct vector *vector) case 'P': case 'z': case 'x': - ch = in_nonblank(); - if (ch == CLOSE_BRACE || ch == '#') - savchar(ch); - else if (ch != EOF && ch != '\n' && ch != ';') - bad_prog(_(EXCESS_JUNK)); + read_end_of_cmd (); break; case 'r': @@ -1348,8 +1354,7 @@ compile_program(struct vector *vector) cur_cmd->x.translate = translate; } - if ((ch = in_nonblank()) != EOF && ch != '\n' && ch != ';') - bad_prog(_(EXCESS_JUNK)); + read_end_of_cmd (); free_buffer(b); free_buffer(b2); diff --git a/testsuite/command-endings.sh b/testsuite/command-endings.sh new file mode 100644 index 0000000..41e349c --- /dev/null +++ b/testsuite/command-endings.sh @@ -0,0 +1,137 @@ +#!/bin/sh +# Test command separators and endings + +# Copyright (C) 2017 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +. "${srcdir=.}/testsuite/init.sh"; path_prepend_ ./sed +print_ver_ sed + +# Allowed endings/separators after most commands: +# newline, comment, closing brace, semicolon, EOF +# they are also allowed after opening and closing braces themselves. +# +# Not tested here: +# r/R/w/R/e and s///[we] which use read_filename() and do not +# accept comments or semicolons. + + + +# Test commands and braces followed by: +# closing braces, comment, semicolons, EOF (newlines are tested later). +# +# sed-4.3 wrongly rejected y/// followed by '}' or '#' (bug#22460). +# +# Implementation notes (see compile.c): +# Simple commands, '}', and 'y///' commands use read_end_of_cmd(). +# +# q/Q/l/L have additional check for optional integer, +# then call read_end_of_cmd(). +# +# labels use 'read_label()'. +# +# 's///' has special handling, depending on additional flags +# (with 's///[we]' commands and semicolons are not allowed). +# Implemented in mark_subst_opts(). +# +for p in \ + 'h' \ + 'h;' \ + 'h ;' \ + 'h# foo' \ + 'h # foo' \ + '{h}' \ + '{h } ' \ + '{ h } ' \ + \ + '{h}# foo' \ + '{h} # foo' \ + '{h};' \ + '{h} ;' \ + '{;h;} ' \ + '{{h}}' \ + '{;{h};}' \ + \ + 'y/1/a/' \ + 'y/1/a/;d' \ + 'y/1/a/ ;d' \ + '{y/1/a/}' \ + 'y/1/a/#foo'\ + 'y/1/a/ #fo'\ + \ + 's/1/a/' \ + 's/1/a/;d' \ + 's/1/a/ ;d' \ + '{s/1/a/}' \ + 's/1/a/#foo'\ + 's/1/a/ #fo'\ + \ + 's/1/a/i ;' \ + 's/1/a/i #foo' \ + '{ s/1/a/i }' \ + \ + 'bx; :x' \ + 'bx; :x;' \ + 'bx; :x ;' \ + 'bx; :x#foo' \ + 'bx; :x #foo' \ + '{ bx; :x }' \ + \ + 'l' \ + 'l;' \ + 'l ;' \ + 'l#foo' \ + 'l #foo' \ + '{l}' \ + '{l }' \ + 'l1' \ + 'l1;' \ + 'l1 ;' \ + 'l1#foo' \ + 'l1 #foo' \ + '{l1}' \ + '{l1 }' \ + ; +do + sed -n "$p" < /dev/null >out 2>err || fail=1 + compare /dev/null err || fail=1 + compare /dev/null out || fail=1 +done + + +# Create files to test newlines after commands +# (instead of having to embed newlines in shell variables in a portable way) +printf 'd\n' > nl1 || framework_failure_ +printf '{\nd}' > nl2 || framework_failure_ +printf '{d\n}' > nl3 || framework_failure_ +printf '{d}\n' > nl4 || framework_failure_ +printf 'y/1/a/\n' > nl5 || framework_failure_ +printf 's/1/a/\n' > nl6 || framework_failure_ +printf 'bx\n:x\n' > nl7 || framework_failure_ +printf 'l\n' > nl8 || framework_failure_ +printf 'l1\n' > nl9 || framework_failure_ +# s/// has special allowance for \r in mark_subst_opts(), +# even if not on windows. +# TODO: should other commands allow it ? +printf 's/1/a/\r\n' > nl10 || framework_failure_ + +for i in 1 2 3 4 5 6 7 8 9 10 ; +do + sed -n -f "nl$i" out 2>err || fail=1 + compare /dev/null err || fail=1 + compare /dev/null out || fail=1 +done + + +Exit $fail diff --git a/testsuite/local.mk b/testsuite/local.mk index 2c8c718..732c86d 100644 --- a/testsuite/local.mk +++ b/testsuite/local.mk @@ -29,6 +29,7 @@ T = \ testsuite/compile-errors.sh \ testsuite/compile-tests.sh \ testsuite/convert-number.sh \ + testsuite/command-endings.sh \ testsuite/execute-tests.sh \ testsuite/help-version.sh \ testsuite/in-place-hyphen.sh \ -- 1.9.0 --wzJLGUyc3ArbnUjN-- From debbugs-submit-bounces@debbugs.gnu.org Sat Mar 18 23:35:16 2017 Received: (at 22460) by debbugs.gnu.org; 19 Mar 2017 03:35:16 +0000 Received: from localhost ([127.0.0.1]:34455 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cpRci-0002mo-4L for submit@debbugs.gnu.org; Sat, 18 Mar 2017 23:35:16 -0400 Received: from mail-vk0-f47.google.com ([209.85.213.47]:34166) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cpRcg-0002mY-Dq for 22460@debbugs.gnu.org; Sat, 18 Mar 2017 23:35:14 -0400 Received: by mail-vk0-f47.google.com with SMTP id z204so84041vkd.1 for <22460@debbugs.gnu.org>; Sat, 18 Mar 2017 20:35:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=2XcjLhh2UmmOy6e4L8grJsuHHiRjb19VjfZAZSJl3Ms=; b=A/C4pWnpnkb2cnJaoeL6nuerGf71VCxEkmWHzTx08gxEpMusea4Xgnrg/mPCTP7KK0 IhUG971M+BvlNb6V5asnpv3bM6RYur57onEwUrPfD2SI6VNEI9Q2NAkV9eyOSWnqQqwP dJZQhxGaYtTAOn8duuX9NoXtYUd1JaZAeCfY7luqdMub+xxqJPFpXZdoc6ISVQGFKMZt xB8eYLl1XwllLwoYeroaZkW/d9cHC0FxCzdz7lOozkTNZdp6u+jpRqpDEQJqzsw0v3ng vBu/GzAF0gZv3CCzqME9GR7lsyolJe2s3gMhP4UijaZkMr+CMlDwADU0ylquv1O4vwsW ql7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=2XcjLhh2UmmOy6e4L8grJsuHHiRjb19VjfZAZSJl3Ms=; b=XFOg8YajgMwW8IHrTv5mxC3cnjZzAFS/OjdK/5QCAMsKA2bfv40Pc0571GYCUqxl1M I3qVfjZm6eR7Rm6mMy4/dokZzWPvePwRtG5DfFIKk3+F88zOKxZ/tabnKUdtQ/N/59xz vsl0J6qrUjk2g3Oog+WfwJHke1Kx3kgh4kD9Tv9Y1bLw/mK3L5zeKvwvZMnrJJTQAsF3 rVqiZXFto6i4aHN5Z5kOYKKnZ6wUGScyVF+8LwmKlh0x4e35HInJt9jhexZgt6Lrn6uK zao7UkZbhlnVWBANTfcQFxj2dr9AgWgvwb0mbuU9EsNZ8Zui3epZCCxE6mYObgZZHvnN x53Q== X-Gm-Message-State: AFeK/H2zNihw+dsUzWUuGR279LSVaM2dkiZxGouldAfwn/WRMSh6J4eg1iSuO3LlzoDwroygtrlOmQGI2fFYZA== X-Received: by 10.31.147.11 with SMTP id v11mr9198065vkd.126.1489894508610; Sat, 18 Mar 2017 20:35:08 -0700 (PDT) MIME-Version: 1.0 Received: by 10.159.59.41 with HTTP; Sat, 18 Mar 2017 20:34:48 -0700 (PDT) In-Reply-To: <20170127030426.GB12674@gmail.com> References: <20160125012822.GB16982@desktop1.fritz.box> <20170127030426.GB12674@gmail.com> From: Jim Meyering Date: Sat, 18 Mar 2017 20:34:48 -0700 X-Google-Sender-Auth: 6lHmXa31O6Rlyxz_TbZb_ARfN8M Message-ID: Subject: Re: bug#22460: 'y' command doesn't allow a comment after it one the same line To: Assaf Gordon Content-Type: text/plain; charset=UTF-8 X-Spam-Score: -2.1 (--) X-Debbugs-Envelope-To: 22460 Cc: 22460@debbugs.gnu.org, Thorsten Heymann X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.1 (--) On Thu, Jan 26, 2017 at 7:04 PM, Assaf Gordon wrote: > Hello Thorsten, > > Sorry for the delayed response. > > On Mon, Jan 25, 2016 at 02:28:22AM +0100, Thorsten Heymann wrote: >> >> Unlike other commands, the current implementation of the 'y' command does >> not allow a comment on the same line if the command is not >> "terminated" by a ';' > > > That is indeed a bug, and a rather old one. > > Your suggested fix is correct, but I thought that instead of > duplicating the same few lines, it might be better to extract > the code to a new function. > > The attached patch does that and adds a corresponding unit test. Thank you, Thorsten, for the report and patch. Hi Assaf, Thanks a lot for improving it and adding tests. Would you please separate the factoring-out of your new function and the bug fix into two commits? Maybe even putting the tests in a third. A nit in the commit log, now that 4.4 is out, it should say sed-4.4, not 4.3, of course. From debbugs-submit-bounces@debbugs.gnu.org Tue Mar 21 22:54:15 2017 Received: (at 22460) by debbugs.gnu.org; 22 Mar 2017 02:54:15 +0000 Received: from localhost ([127.0.0.1]:38511 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cqWPf-0005QQ-3v for submit@debbugs.gnu.org; Tue, 21 Mar 2017 22:54:15 -0400 Received: from mail-qk0-f170.google.com ([209.85.220.170]:34081) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cqWPd-0005Py-OM for 22460@debbugs.gnu.org; Tue, 21 Mar 2017 22:54:14 -0400 Received: by mail-qk0-f170.google.com with SMTP id p64so149417795qke.1 for <22460@debbugs.gnu.org>; Tue, 21 Mar 2017 19:54:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc:message-id:references :to; bh=u3kU82jqGicMkSgx/468jxHaom9vvurbRZWwpfOh7fs=; b=dsRV/zNhjf3j+QCKoanDk6JdcN543v/h4thEE+M1GHTDeVcntyVNrJUkQaB9oLHlRx oLb9V/6bSDFqaMB6p0GM7gMmFcvKASMZERHxIozo2J/KUy7nTI6jAkWIop0M+6YkQlKZ YTTFsiK1B2t8t6l7i0zgG8HqFU6E0PzoBO4Pcmv8qk2FFPgFW5mt+HOrXR2j4AApGTCr Iez08i41DI+VamLZwoTbDvGuE9e30h6IMOwpiTe6SdBlx0Ic3yBDPmD5diybQSkMJBMI Q9PK3FqMQG7b4XA+tKBcMrp0pTVsvnr/+o9j7GJmoiCfQ/ZkwE1VYXcOxMIUhhul1iyA oKeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :message-id:references:to; bh=u3kU82jqGicMkSgx/468jxHaom9vvurbRZWwpfOh7fs=; b=imsVCExPn1Y267DLIAyUBiKJ61sVyqTQmMRL1dwc+oFJ7redXxqSZzL7izFEc/zTqr mUh1OesFMEl/vODmsNHp3Z3qdD7nZtnazTcIAs92JhNA74K4qqIy6gSzfC2YpJD7lWgh fpAPI6coE1TmqpwTPc3l60I9+oLMowOCOFVGNuKFpACxe1NLPnJyXJcOG9erDYWxwgKE DXOo76CwHNpj5uCATVqN1m+8qnFVoEhucX7VS5ojcuO4J0a+g8dwHMtjmkvD2A+BrTku SGK53mNUyML6F7c3FC2nZPylMRoSDVeYDlxKFK0U9a6/1K26D9cY88uScEOxaIo+sk/R daxg== X-Gm-Message-State: AFeK/H2e+jNklzkL1C8YOwqisWvOTvy+jI1hMYGux4n6u2v59y5c5bXmmjoD3Up5h4gqfQ== X-Received: by 10.55.110.131 with SMTP id j125mr13758722qkc.106.1490151248067; Tue, 21 Mar 2017 19:54:08 -0700 (PDT) Received: from ix.home (pool-100-37-92-116.nycmny.fios.verizon.net. [100.37.92.116]) by smtp.gmail.com with ESMTPSA id u5sm21029qkd.46.2017.03.21.19.54.07 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 21 Mar 2017 19:54:07 -0700 (PDT) Content-Type: multipart/mixed; boundary="Apple-Mail=_DB021321-A7C4-4E24-A770-80D9C7676990" Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2102\)) Subject: Re: bug#22460: 'y' command doesn't allow a comment after it one the same line From: Assaf Gordon In-Reply-To: Date: Tue, 21 Mar 2017 22:54:05 -0400 Message-Id: <502494E4-51EF-4E25-A3B4-7F562704E2DB@gmail.com> References: <20160125012822.GB16982@desktop1.fritz.box> <20170127030426.GB12674@gmail.com> To: Jim Meyering X-Mailer: Apple Mail (2.2102) X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 22460 Cc: 22460@debbugs.gnu.org, Thorsten Heymann X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.5 (/) --Apple-Mail=_DB021321-A7C4-4E24-A770-80D9C7676990 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii Hello, > On Mar 18, 2017, at 23:34, Jim Meyering wrote: > > Would you please separate the factoring-out of your new function and > the bug fix into two commits? > Maybe even putting the tests in a third. Thanks for the review. Please see attached 3 patches, let me know if that's the right direction. -assaf --Apple-Mail=_DB021321-A7C4-4E24-A770-80D9C7676990 Content-Disposition: attachment; filename=bug22460-2017-03-21.patch Content-Type: application/octet-stream; name="bug22460-2017-03-21.patch" Content-Transfer-Encoding: quoted-printable =46rom=20290d1c5b9ff3e944d71ec211373385245df6adcd=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20Thorsten=20Heymann=20=0A= Date:=20Tue,=2021=20Mar=202017=2022:14:29=20-0400=0ASubject:=20[PATCH=20= 1/3]=20sed:=20allow=20comments,=20braces=20after=20y///=0A=0Ased-4.4=20= and=20earlier=20rejected=20the=20following:=0A=20=20$=20sed=20'y/1/a/=20= #f'=0A=20=20sed:=20-e=20expression=20#1,=20char=208:=20extra=20= characters=20after=20command=0A=0ASee=20https://bugs.gnu.org/22460=20.=0A= =0A*=20sed/compile.c=20(compile_program):=20Handle=20comments,=20braces=20= after=20'y'=20command.=0A*=20NEWS:=20Mention=20it.=0A---=0A=20NEWS=20=20=20= =20=20=20=20=20=20=20|=205=20+++++=0A=20sed/compile.c=20|=205=20++++-=0A=20= 2=20files=20changed,=209=20insertions(+),=201=20deletion(-)=0A=0Adiff=20= --git=20a/NEWS=20b/NEWS=0Aindex=20fbc8c3b..b7656c1=20100644=0A---=20= a/NEWS=0A+++=20b/NEWS=0A@@=20-2,6=20+2,11=20@@=20GNU=20sed=20NEWS=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20-*-=20outline=20-*-=0A=20=0A=20*=20Noteworthy=20= changes=20in=20release=20?.?=20(????-??-??)=20[?]=0A=20=0A+**=20Bug=20= fixes=0A+=0A+=20=20sed=20no=20longer=20rejects=20comments=20and=20= closing=20braces=20after=20y///=20commands.=0A+=20=20[Bug=20existed=20at=20= least=20since=20sed-3.02]=0A+=0A=20=0A=20*=20Noteworthy=20changes=20in=20= release=204.4=20(2017-02-03)=20[stable]=0A=20=0Adiff=20--git=20= a/sed/compile.c=20b/sed/compile.c=0Aindex=20e4fbb44..bd3f7e2=20100644=0A= ---=20a/sed/compile.c=0A+++=20b/sed/compile.c=0A@@=20-1348,7=20+1348,10=20= @@=20compile_program(struct=20vector=20*vector)=0A=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20cur_cmd->x.translate=20=3D=20translate;=0A=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20}=0A=20=0A-=20=20=20=20=20=20=20=20= =20=20=20=20if=20((ch=20=3D=20in_nonblank())=20!=3D=20EOF=20&&=20ch=20!=3D= =20'\n'=20&&=20ch=20!=3D=20';')=0A+=20=20=20=20=20=20=20=20=20=20=20=20= ch=20=3D=20in_nonblank();=0A+=20=20=20=20=20=20=20=20=20=20=20=20if=20= (ch=20=3D=3D=20CLOSE_BRACE=20||=20ch=20=3D=3D=20'#')=0A+=20=20=20=20=20=20= =20=20=20=20=20=20=20=20savchar(ch);=0A+=20=20=20=20=20=20=20=20=20=20=20= =20else=20if=20(ch=20!=3D=20EOF=20&&=20ch=20!=3D=20'\n'=20&&=20ch=20!=3D=20= ';')=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= bad_prog(_(EXCESS_JUNK));=0A=20=0A=20=20=20=20=20=20=20=20=20=20=20=20=20= free_buffer(b);=0A--=20=0A2.10.2=0A=0A=0A=46rom=20= beec9be0371b552fb7113c099b43c2acd87d6e5a=20Mon=20Sep=2017=2000:00:00=20= 2001=0AFrom:=20Assaf=20Gordon=20=0ADate:=20Tue,=20= 21=20Mar=202017=2022:30:17=20-0400=0ASubject:=20[PATCH=202/3]=20sed:=20= refactor=20end-of-line=20parsing=0A=0AFollow-up=20to=20bug#22460:=20= extract=20repeated=20code=20to=20parse=20end=20of=20lines=0A(while=20= savinh=20comments,=20braces)=20into=20a=20new=20function.=0ASee=20= discussion=20in=20https://bugs.gnu.org/22460=20.=0A=0A*=20sec/compile.c=20= (read_end_of_cmd):=20New=20function,=20consumes=20sed=20script=0Ainput=20= until=20newline,=20EOF,=20semicolon,=20closing=20brace=20or=20comment=20= is=20found.=0A(compile_program):=20Call=20new=20function=20instead=20of=20= duplicating=20code.=0A---=0A=20sed/compile.c=20|=2046=20= ++++++++++++++++++++++++----------------------=0A=201=20file=20changed,=20= 24=20insertions(+),=2022=20deletions(-)=0A=0Adiff=20--git=20= a/sed/compile.c=20b/sed/compile.c=0Aindex=20bd3f7e2..99292a3=20100644=0A= ---=20a/sed/compile.c=0A+++=20b/sed/compile.c=0A@@=20-274,6=20+274,21=20= @@=20in_nonblank(void)=0A=20=20=20return=20ch;=0A=20}=0A=20=0A+/*=20= Consume=20script=20input=20until=20a=20valid=20end=20of=20command=20= marker=20is=20found:=0A+=20=20=20=20=20comment,=20closing=20brace,=20= newline,=20semicolon=20or=20EOF.=0A+=20=20=20If=20any=20other=20= character=20is=20found,=20die=20with=20'extra=20characters=20after=20= command'=0A+=20=20=20error.=0A+*/=0A+static=20void=0A+read_end_of_cmd=20= (void)=0A+{=0A+=20=20const=20int=20ch=20=3D=20in_nonblank();=0A+=20=20if=20= (ch=20=3D=3D=20CLOSE_BRACE=20||=20ch=20=3D=3D=20'#')=0A+=20=20=20=20= savchar(ch);=0A+=20=20else=20if=20(ch=20!=3D=20EOF=20&&=20ch=20!=3D=20= '\n'=20&&=20ch=20!=3D=20';')=0A+=20=20=20=20bad_prog(_(EXCESS_JUNK));=0A= +}=0A+=0A=20/*=20Read=20an=20integer=20value=20from=20the=20program.=20=20= */=0A=20static=20countT=0A=20in_integer=20(int=20ch)=0A@@=20-1103,11=20= +1118,8=20@@=20compile_program(struct=20vector=20*vector)=0A=20=20=20=20=20= =20=20=20=20=20=20=20=20bad_prog(_(EXCESS_CLOSE_BRACE));=0A=20=20=20=20=20= =20=20=20=20=20=20if=20(cur_cmd->a1)=0A=20=20=20=20=20=20=20=20=20=20=20=20= =20bad_prog(_(NO_CLOSE_BRACE_ADDR));=0A-=20=20=20=20=20=20=20=20=20=20ch=20= =3D=20in_nonblank();=0A-=20=20=20=20=20=20=20=20=20=20if=20(ch=20=3D=3D=20= CLOSE_BRACE=20||=20ch=20=3D=3D=20'#')=0A-=20=20=20=20=20=20=20=20=20=20=20= =20savchar(ch);=0A-=20=20=20=20=20=20=20=20=20=20else=20if=20(ch=20!=3D=20= EOF=20&&=20ch=20!=3D=20'\n'=20&&=20ch=20!=3D=20';')=0A-=20=20=20=20=20=20= =20=20=20=20=20=20bad_prog(_(EXCESS_JUNK));=0A+=0A+=20=20=20=20=20=20=20=20= =20=20read_end_of_cmd=20();=0A=20=0A=20=20=20=20=20=20=20=20=20=20=20= vector->v[blocks->v_index].x.jump_index=20=3D=20vector->v_length;=0A=20=20= =20=20=20=20=20=20=20=20=20blocks=20=3D=20release_label(blocks);=09/*=20= done=20with=20this=20entry=20*/=0A@@=20-1177,16=20+1189,14=20@@=20= compile_program(struct=20vector=20*vector)=0A=20=20=20=20=20=20=20=20=20=20= =20if=20(ISDIGIT(ch)=20&&=20posixicity=20!=3D=20POSIXLY_BASIC)=0A=20=20=20= =20=20=20=20=20=20=20=20=20=20{=0A=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20cur_cmd->x.int_arg=20=3D=20in_integer(ch);=0A-=20=20=20=20=20=20=20= =20=20=20=20=20=20=20ch=20=3D=20in_nonblank();=0A=20=20=20=20=20=20=20=20= =20=20=20=20=20}=0A=20=20=20=20=20=20=20=20=20=20=20else=0A-=20=20=20=20=20= =20=20=20=20=20=20=20cur_cmd->x.int_arg=20=3D=20-1;=0A-=0A-=20=20=20=20=20= =20=20=20=20=20if=20(ch=20=3D=3D=20CLOSE_BRACE=20||=20ch=20=3D=3D=20'#')=0A= -=20=20=20=20=20=20=20=20=20=20=20=20savchar(ch);=0A-=20=20=20=20=20=20=20= =20=20=20else=20if=20(ch=20!=3D=20EOF=20&&=20ch=20!=3D=20'\n'=20&&=20ch=20= !=3D=20';')=0A-=20=20=20=20=20=20=20=20=20=20=20=20= bad_prog(_(EXCESS_JUNK));=0A+=20=20=20=20=20=20=20=20=20=20=20=20{=0A+=20= =20=20=20=20=20=20=20=20=20=20=20=20=20cur_cmd->x.int_arg=20=3D=20-1;=0A= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20savchar=20(ch);=0A+=20=20=20=20= =20=20=20=20=20=20=20=20}=0A=20=0A+=20=20=20=20=20=20=20=20=20=20= read_end_of_cmd=20();=0A=20=20=20=20=20=20=20=20=20=20=20break;=0A=20=0A=20= =20=20=20=20=20=20=20case=20'=3D':=0A@@=20-1203,11=20+1213,7=20@@=20= compile_program(struct=20vector=20*vector)=0A=20=20=20=20=20=20=20=20=20= case=20'P':=0A=20=20=20=20=20=20=20=20=20case=20'z':=0A=20=20=20=20=20=20= =20=20=20case=20'x':=0A-=20=20=20=20=20=20=20=20=20=20ch=20=3D=20= in_nonblank();=0A-=20=20=20=20=20=20=20=20=20=20if=20(ch=20=3D=3D=20= CLOSE_BRACE=20||=20ch=20=3D=3D=20'#')=0A-=20=20=20=20=20=20=20=20=20=20=20= =20savchar(ch);=0A-=20=20=20=20=20=20=20=20=20=20else=20if=20(ch=20!=3D=20= EOF=20&&=20ch=20!=3D=20'\n'=20&&=20ch=20!=3D=20';')=0A-=20=20=20=20=20=20= =20=20=20=20=20=20bad_prog(_(EXCESS_JUNK));=0A+=20=20=20=20=20=20=20=20=20= =20read_end_of_cmd=20();=0A=20=20=20=20=20=20=20=20=20=20=20break;=0A=20=0A= =20=20=20=20=20=20=20=20=20case=20'r':=0A@@=20-1348,11=20+1354,7=20@@=20= compile_program(struct=20vector=20*vector)=0A=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20cur_cmd->x.translate=20=3D=20translate;=0A=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20}=0A=20=0A-=20=20=20=20=20=20=20=20=20=20= =20=20ch=20=3D=20in_nonblank();=0A-=20=20=20=20=20=20=20=20=20=20=20=20= if=20(ch=20=3D=3D=20CLOSE_BRACE=20||=20ch=20=3D=3D=20'#')=0A-=20=20=20=20= =20=20=20=20=20=20=20=20=20=20savchar(ch);=0A-=20=20=20=20=20=20=20=20=20= =20=20=20else=20if=20(ch=20!=3D=20EOF=20&&=20ch=20!=3D=20'\n'=20&&=20ch=20= !=3D=20';')=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20= bad_prog(_(EXCESS_JUNK));=0A+=20=20=20=20=20=20=20=20=20=20=20=20= read_end_of_cmd=20();=0A=20=0A=20=20=20=20=20=20=20=20=20=20=20=20=20= free_buffer(b);=0A=20=20=20=20=20=20=20=20=20=20=20=20=20= free_buffer(b2);=0A--=20=0A2.10.2=0A=0A=0A=46rom=20= 32c05ba9be81c44a011fccdaaa789e6d38bc2c7a=20Mon=20Sep=2017=2000:00:00=20= 2001=0AFrom:=20Assaf=20Gordon=20=0ADate:=20Tue,=20= 21=20Mar=202017=2022:33:39=20-0400=0ASubject:=20[PATCH=203/3]=20tests:=20= test=20comments,=20braces=20after=20commands=0A=0ATest=20multiple=20= combinations=20of=20comments,=20spaces,=20braces=20after=20commands,=0A= to=20validate=20recently=20added=20function=20'read_end_of_cmd()'.=0ASee=20= discussion=20in=20https://bugs.gnu.org/22460=20.=0A=0A*=20= testsuite/command-endings.sh:=20New=20test,=20including=20y///=20bug.=0A= *=20testsuite/local.mk:=20Add=20new=20test.=0A---=0A=20= testsuite/command-endings.sh=20|=20137=20= +++++++++++++++++++++++++++++++++++++++++++=0A=20testsuite/local.mk=20=20= =20=20=20=20=20=20=20=20=20|=20=20=201=20+=0A=202=20files=20changed,=20= 138=20insertions(+)=0A=20create=20mode=20100644=20= testsuite/command-endings.sh=0A=0Adiff=20--git=20= a/testsuite/command-endings.sh=20b/testsuite/command-endings.sh=0Anew=20= file=20mode=20100644=0Aindex=200000000..41e349c=0A---=20/dev/null=0A+++=20= b/testsuite/command-endings.sh=0A@@=20-0,0=20+1,137=20@@=0A+#!/bin/sh=0A= +#=20Test=20command=20separators=20and=20endings=0A+=0A+#=20Copyright=20= (C)=202017=20Free=20Software=20Foundation,=20Inc.=0A+=0A+#=20This=20= program=20is=20free=20software:=20you=20can=20redistribute=20it=20and/or=20= modify=0A+#=20it=20under=20the=20terms=20of=20the=20GNU=20General=20= Public=20License=20as=20published=20by=0A+#=20the=20Free=20Software=20= Foundation,=20either=20version=203=20of=20the=20License,=20or=0A+#=20(at=20= your=20option)=20any=20later=20version.=0A+=0A+#=20This=20program=20is=20= distributed=20in=20the=20hope=20that=20it=20will=20be=20useful,=0A+#=20= but=20WITHOUT=20ANY=20WARRANTY;=20without=20even=20the=20implied=20= warranty=20of=0A+#=20MERCHANTABILITY=20or=20FITNESS=20FOR=20A=20= PARTICULAR=20PURPOSE.=20=20See=20the=0A+#=20GNU=20General=20Public=20= License=20for=20more=20details.=0A+=0A+#=20You=20should=20have=20= received=20a=20copy=20of=20the=20GNU=20General=20Public=20License=0A+#=20= along=20with=20this=20program.=20=20If=20not,=20see=20= .=0A+.=20"${srcdir=3D.}/testsuite/init.sh";=20= path_prepend_=20./sed=0A+print_ver_=20sed=0A+=0A+#=20Allowed=20= endings/separators=20after=20most=20commands:=0A+#=20=20=20newline,=20= comment,=20closing=20brace,=20semicolon,=20EOF=0A+#=20they=20are=20also=20= allowed=20after=20opening=20and=20closing=20braces=20themselves.=0A+#=0A= +#=20Not=20tested=20here:=0A+#=20=20=20r/R/w/R/e=20and=20s///[we]=20= which=20use=20read_filename()=20and=20do=20not=0A+#=20=20=20accept=20= comments=20or=20semicolons.=0A+=0A+=0A+=0A+#=20Test=20commands=20and=20= braces=20followed=20by:=0A+#=20closing=20braces,=20comment,=20= semicolons,=20EOF=20(newlines=20are=20tested=20later).=0A+#=0A+#=20= sed-4.3=20wrongly=20rejected=20y///=20followed=20by=20'}'=20or=20'#'=20= (bug#22460).=0A+#=0A+#=20Implementation=20notes=20(see=20compile.c):=0A= +#=20=20=20Simple=20commands,=20'}',=20and=20'y///'=20commands=20use=20= read_end_of_cmd().=0A+#=0A+#=20=20=20q/Q/l/L=20have=20additional=20check=20= for=20optional=20integer,=0A+#=20=20=20then=20call=20read_end_of_cmd().=0A= +#=0A+#=20=20=20labels=20use=20'read_label()'.=0A+#=0A+#=20=20=20's///'=20= has=20special=20handling,=20depending=20on=20additional=20flags=0A+#=20=20= =20=20(with=20's///[we]'=20commands=20and=20semicolons=20are=20not=20= allowed).=0A+#=20=20=20Implemented=20in=20mark_subst_opts().=0A+#=0A+for=20= p=20in=20\=0A+=20=20=20=20'h'=20=20=20=20=20=20=20=20=20\=0A+=20=20=20=20= 'h;'=20=20=20=20=20=20=20=20\=0A+=20=20=20=20'h=20;'=20=20=20=20=20=20=20= \=0A+=20=20=20=20'h#=20foo'=20=20=20=20\=0A+=20=20=20=20'h=20#=20foo'=20=20= =20\=0A+=20=20=20=20'{h}'=20=20=20=20=20=20=20\=0A+=20=20=20=20'{h=20}=20= '=20=20=20=20=20\=0A+=20=20=20=20'{=20h=20}=20'=20=20=20=20\=0A+=20=20=20= =20\=0A+=20=20=20=20'{h}#=20foo'=20=20\=0A+=20=20=20=20'{h}=20#=20foo'=20= \=0A+=20=20=20=20'{h};'=20=20=20=20=20=20\=0A+=20=20=20=20'{h}=20;'=20=20= =20=20=20\=0A+=20=20=20=20'{;h;}=20'=20=20=20=20\=0A+=20=20=20=20'{{h}}'=20= =20=20=20=20\=0A+=20=20=20=20'{;{h};}'=20=20=20\=0A+=20=20=20=20\=0A+=20=20= =20=20'y/1/a/'=20=20=20=20\=0A+=20=20=20=20'y/1/a/;d'=20=20\=0A+=20=20=20= =20'y/1/a/=20;d'=20\=0A+=20=20=20=20'{y/1/a/}'=20=20\=0A+=20=20=20=20= 'y/1/a/#foo'\=0A+=20=20=20=20'y/1/a/=20#fo'\=0A+=20=20=20=20\=0A+=20=20=20= =20's/1/a/'=20=20=20=20\=0A+=20=20=20=20's/1/a/;d'=20=20\=0A+=20=20=20=20= 's/1/a/=20;d'=20\=0A+=20=20=20=20'{s/1/a/}'=20=20\=0A+=20=20=20=20= 's/1/a/#foo'\=0A+=20=20=20=20's/1/a/=20#fo'\=0A+=20=20=20=20\=0A+=20=20=20= =20's/1/a/i=20;'=20\=0A+=20=20=20=20's/1/a/i=20#foo'=20\=0A+=20=20=20=20= '{=20s/1/a/i=20}'=20\=0A+=20=20=20=20\=0A+=20=20=20=20'bx;=20:x'=20=20=20= =20=20=20\=0A+=20=20=20=20'bx;=20:x;'=20=20=20=20=20\=0A+=20=20=20=20= 'bx;=20:x=20;'=20=20=20=20\=0A+=20=20=20=20'bx;=20:x#foo'=20=20\=0A+=20=20= =20=20'bx;=20:x=20#foo'=20\=0A+=20=20=20=20'{=20bx;=20:x=20}'=20=20\=0A+=20= =20=20=20\=0A+=20=20=20=20'l'=20=20=20=20=20=20=20=20=20=20=20\=0A+=20=20= =20=20'l;'=20=20=20=20=20=20=20=20=20=20\=0A+=20=20=20=20'l=20;'=20=20=20= =20=20=20=20=20=20\=0A+=20=20=20=20'l#foo'=20=20=20=20=20=20=20\=0A+=20=20= =20=20'l=20#foo'=20=20=20=20=20=20\=0A+=20=20=20=20'{l}'=20=20=20=20=20=20= =20=20=20\=0A+=20=20=20=20'{l=20}'=20=20=20=20=20=20=20=20\=0A+=20=20=20=20= 'l1'=20=20=20=20=20=20=20=20=20=20\=0A+=20=20=20=20'l1;'=20=20=20=20=20=20= =20=20=20\=0A+=20=20=20=20'l1=20;'=20=20=20=20=20=20=20=20\=0A+=20=20=20=20= 'l1#foo'=20=20=20=20=20=20\=0A+=20=20=20=20'l1=20#foo'=20=20=20=20=20\=0A= +=20=20=20=20'{l1}'=20=20=20=20=20=20=20=20\=0A+=20=20=20=20'{l1=20}'=20=20= =20=20=20=20=20\=0A+=20=20=20=20;=0A+do=0A+=20=20sed=20-n=20"$p"=20<=20= /dev/null=20>out=202>err=20||=20fail=3D1=0A+=20=20compare=20/dev/null=20= err=20||=20fail=3D1=0A+=20=20compare=20/dev/null=20out=20||=20fail=3D1=0A= +done=0A+=0A+=0A+#=20Create=20files=20to=20test=20newlines=20after=20= commands=0A+#=20(instead=20of=20having=20to=20embed=20newlines=20in=20= shell=20variables=20in=20a=20portable=20way)=0A+printf=20'd\n'=20=20=20=20= =20=20=20=20=20>=20nl1=20||=20framework_failure_=0A+printf=20'{\nd}'=20=20= =20=20=20=20=20>=20nl2=20||=20framework_failure_=0A+printf=20'{d\n}'=20=20= =20=20=20=20=20>=20nl3=20||=20framework_failure_=0A+printf=20'{d}\n'=20=20= =20=20=20=20=20>=20nl4=20||=20framework_failure_=0A+printf=20'y/1/a/\n'=20= =20=20=20>=20nl5=20||=20framework_failure_=0A+printf=20's/1/a/\n'=20=20=20= =20>=20nl6=20||=20framework_failure_=0A+printf=20'bx\n:x\n'=20=20=20=20>=20= nl7=20||=20framework_failure_=0A+printf=20'l\n'=20=20=20=20=20=20=20=20=20= >=20nl8=20||=20framework_failure_=0A+printf=20'l1\n'=20=20=20=20=20=20=20= =20>=20nl9=20||=20framework_failure_=0A+#=20s///=20has=20special=20= allowance=20for=20\r=20in=20mark_subst_opts(),=0A+#=20even=20if=20not=20= on=20windows.=0A+#=20TODO:=20should=20other=20commands=20allow=20it=20?=0A= +printf=20's/1/a/\r\n'=20=20>=20nl10=20||=20framework_failure_=0A+=0A= +for=20i=20in=201=202=203=204=205=206=207=208=209=2010=20;=0A+do=0A+=20=20= sed=20-n=20-f=20"nl$i"=20out=202>err=20||=20fail=3D1=0A+=20= =20compare=20/dev/null=20err=20||=20fail=3D1=0A+=20=20compare=20= /dev/null=20out=20||=20fail=3D1=0A+done=0A+=0A+=0A+Exit=20$fail=0Adiff=20= --git=20a/testsuite/local.mk=20b/testsuite/local.mk=0Aindex=20= 2c8c718..732c86d=20100644=0A---=20a/testsuite/local.mk=0A+++=20= b/testsuite/local.mk=0A@@=20-29,6=20+29,7=20@@=20T=20=3D=09=09=09=09=09\=0A= =20=20=20testsuite/compile-errors.sh=09=09\=0A=20=20=20= testsuite/compile-tests.sh=09=09\=0A=20=20=20testsuite/convert-number.sh=09= =09\=0A+=20=20testsuite/command-endings.sh=09=09\=0A=20=20=20= testsuite/execute-tests.sh=09=09\=0A=20=20=20testsuite/help-version.sh=09= =09\=0A=20=20=20testsuite/in-place-hyphen.sh=09=09\=0A--=20=0A2.10.2=0A=0A= --Apple-Mail=_DB021321-A7C4-4E24-A770-80D9C7676990-- From debbugs-submit-bounces@debbugs.gnu.org Wed Mar 22 01:00:58 2017 Received: (at 22460) by debbugs.gnu.org; 22 Mar 2017 05:00:58 +0000 Received: from localhost ([127.0.0.1]:38559 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cqYOI-0001ih-1x for submit@debbugs.gnu.org; Wed, 22 Mar 2017 01:00:58 -0400 Received: from mail-vk0-f66.google.com ([209.85.213.66]:33566) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cqYOH-0001iU-1s for 22460@debbugs.gnu.org; Wed, 22 Mar 2017 01:00:57 -0400 Received: by mail-vk0-f66.google.com with SMTP id j64so13834141vkg.0 for <22460@debbugs.gnu.org>; Tue, 21 Mar 2017 22:00:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=R5qXgXeqIy6UXtNcb0/l//9eRce9jV/FNRvvFQOof/M=; b=SOXYbh1DJ7DLtJMYdDmpmGGUo3asKXNzgV56d8EBiiyijFpXqCmqzVOYaxgz5zsVfm //NqGi5y0NgBW0RvpyZYzoR3eBiaVpGIOdfuptvdNw9MFGd1IWoDQB+Dxf1bR+/J8oZH qh7vpb32NoR6xTr/gTxN7uj0orAzPfRTIt3Ce/2+NbjUwwQN3JH/+M2nAw4XCaDhnjSY DVPA4e6UrpVKVhoUOJywtTkog+5g1nII0NE/cvOAfXgPSpmPd+FBuMEnlcS8BOYLzptf Wul+yHOs35bhr6mZWiCD0/c7Ooqm/IaQ3JR/y5k4lV6FdPBDcE39hJ+cxMeu8LRs9hZ+ 08BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=R5qXgXeqIy6UXtNcb0/l//9eRce9jV/FNRvvFQOof/M=; b=RrDwMpUaX7iyzJTcLNw85sa7ju2qPBDoqnp3wOE1Z7rduBpSxYwTQanEWiC837Y6cU cu1Cvorv90cKOsOHTjDk3DiBMZ/VCNA5N3McsDeHYu40a5I9zr2IJq8geZBJegCN2T5f 9XC2ghBD8SKNvYo0QEM9eYzppPc2MRosK/rGbw2OK3b+F8vTAMTiqixdJ9Zj8cG58Wpl nisvR8MGfm1KpzgdNwW1zcxAwp8coj+zyopK1vIXrBhlea0iNFBVEK+FCjiDFDN2har4 pEgX/FwXhh8DazUCsNQxzecywd01yMfZubH8j283jgDpcvw88XM+wgaEpDvIxiyGWjzx 2cmQ== X-Gm-Message-State: AFeK/H17kGF3/u2KM1BRb3+ENRn3ew9gSSu2fznN7jtrfJ/cSaQ/nqrZg9wdL2EBdyuV8Bcj3VqN4JqIlgt2IQ== X-Received: by 10.176.90.137 with SMTP id w9mr13825954uae.0.1490158851391; Tue, 21 Mar 2017 22:00:51 -0700 (PDT) MIME-Version: 1.0 Received: by 10.159.59.41 with HTTP; Tue, 21 Mar 2017 22:00:31 -0700 (PDT) In-Reply-To: <502494E4-51EF-4E25-A3B4-7F562704E2DB@gmail.com> References: <20160125012822.GB16982@desktop1.fritz.box> <20170127030426.GB12674@gmail.com> <502494E4-51EF-4E25-A3B4-7F562704E2DB@gmail.com> From: Jim Meyering Date: Tue, 21 Mar 2017 22:00:31 -0700 X-Google-Sender-Auth: lnYKisFU7bk9ZTivuO3hcT-D_s4 Message-ID: Subject: Re: bug#22460: 'y' command doesn't allow a comment after it one the same line To: Assaf Gordon Content-Type: text/plain; charset=UTF-8 X-Spam-Score: 0.7 (/) X-Debbugs-Envelope-To: 22460 Cc: 22460@debbugs.gnu.org, Thorsten Heymann X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.7 (/) On Tue, Mar 21, 2017 at 7:54 PM, Assaf Gordon wrote: > Hello, > >> On Mar 18, 2017, at 23:34, Jim Meyering wrote: >> >> Would you please separate the factoring-out of your new function and >> the bug fix into two commits? >> Maybe even putting the tests in a third. > > Thanks for the review. > > Please see attached 3 patches, let me know if that's the right direction. Perfect. I spotted only one nit: in the log of the middle patch, s/savinh/saving/ Thanks! From debbugs-submit-bounces@debbugs.gnu.org Fri Mar 24 00:24:52 2017 Received: (at 22460) by debbugs.gnu.org; 24 Mar 2017 04:24:53 +0000 Received: from localhost ([127.0.0.1]:41637 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1crGmS-0000T0-I7 for submit@debbugs.gnu.org; Fri, 24 Mar 2017 00:24:52 -0400 Received: from mail-qk0-f174.google.com ([209.85.220.174]:36152) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1crGmQ-0000Sd-JX; Fri, 24 Mar 2017 00:24:51 -0400 Received: by mail-qk0-f174.google.com with SMTP id p22so2567954qka.3; Thu, 23 Mar 2017 21:24:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:mime-version:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=CxNG2UK9wIcR6ztipeTx2kpo4jPc0yKQzHWBPegyZdg=; b=J3XLWKzjRcezMhpP1d2aUpksvs9mEzOSJP0PCjMM8s85aXEbfGqRTlM4/zbsbX0H9p 2hkE5ufSpoeOkvtpw7EXCwPoTiimUWfxyAQNjcDkNW3zi1qd4Z78IXbsoHteEeQIzemC le/AQKIQXUMMh8oEWOCIuPkw452hVtbBYYL6Nf/OF/MFXEszDKvcnZd7ZtScySFgC0x1 bcvlJooX4Xo4NBWRUeCUPaBqJMF2Zm7Gpo9BHZEIlLQinoG77SeW76onobBC/05ZWJSC samLoeLAIL/dzjiwo3Ch4J3GUj97lXiTG8HI+4HfAlS+3rdvPhSWV4plvrUar0B28Hhl h20Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:mime-version:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=CxNG2UK9wIcR6ztipeTx2kpo4jPc0yKQzHWBPegyZdg=; b=m5vgW8wdJyBhXA/7YqF3TwepQzSpBnIMt8H5y0S/59LiaCpXWRzpxs7aeEfUmCJdiN PDgOK05BSwCrAQTfybWC0CYWqoVCVxOou8yCB0yw6L+Kg9VN8+3So3JuhxvA6lg8VMWH YNa9I+4mOfE0/F3Yj0ZEY7+fkLSOYvaUSPwASIwByh+RyRFdXR43srUE3ncvZf5YvIbd TvcCfHpmC0q9sbylRrdnWo++S+62uvC59pQrktyPXwQPZU4z/7IDo4bCKslZU+766TNL n4uUIJBe16txZiN0m0/uNKJ1Hhf5KdOvqRP6GgCOVWyOu4thHS3cvSiuKRh7bcguTfqG frEA== X-Gm-Message-State: AFeK/H0pwbxjyCqurGVMD67whfjfiZu8EEQdejeQEHKB+/xc1A7c9nXB6k4uFuf85eR5rg== X-Received: by 10.55.215.86 with SMTP id m83mr5312332qki.150.1490329485160; Thu, 23 Mar 2017 21:24:45 -0700 (PDT) Received: from ix.home (pool-100-37-92-116.nycmny.fios.verizon.net. [100.37.92.116]) by smtp.gmail.com with ESMTPSA id r33sm782477qta.19.2017.03.23.21.24.43 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 23 Mar 2017 21:24:44 -0700 (PDT) Subject: Re: bug#22460: 'y' command doesn't allow a comment after it one the same line Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2102\)) Content-Type: text/plain; charset=us-ascii From: Assaf Gordon In-Reply-To: Date: Fri, 24 Mar 2017 00:24:42 -0400 Content-Transfer-Encoding: 7bit Message-Id: <30407BDE-DA47-49A9-A881-5372EE3D3233@gmail.com> References: <20160125012822.GB16982@desktop1.fritz.box> <20170127030426.GB12674@gmail.com> <502494E4-51EF-4E25-A3B4-7F562704E2DB@gmail.com> To: Jim Meyering X-Mailer: Apple Mail (2.2102) X-Spam-Score: 0.5 (/) X-Debbugs-Envelope-To: 22460 Cc: 22460@debbugs.gnu.org, Thorsten Heymann X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.5 (/) tags 22460 fixed close 22460 stop Pushed here: sed: allow comments, braces after y/// https://git.savannah.gnu.org/cgit/sed.git/commit/?id=cf8eb6cb3 sed: refactor end-of-line parsing https://git.savannah.gnu.org/cgit/sed.git/commit/?id=9b26a0651 tests: test comments, braces after commands https://git.savannah.gnu.org/cgit/sed.git/commit/?id=156e6be99f regards, - assaf From unknown Sat Jul 26 22:10:03 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 21 Apr 2017 11:24:04 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator