From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f68.google.com ([209.85.221.68]) by ewsd; Fri Jan 11 08:10:34 EST 2019 Received: by mail-wr1-f68.google.com with SMTP id c14so15214920wrr.0 for <9front@9front.org>; Fri, 11 Jan 2019 05:10:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=offblast-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=08VQJf6t+d5KMucwkgdu8oWlZrcKmjMWyC6bHqIdILs=; b=UG7pt7Ub45eKpCqtQrFWGEj2K/Mb2NIoe+PptOnCRL8l4WgOvSrz9mVYDKn8ddRtp2 sHcUIa4/2C2YgrcFhJ33/mmzM0eWURaW0o9ebkTUpbxYXKWuNeqG1uF6q3dsuF5NvnZq FKSV5NV7NWhzMdrsR/tYfyJxbt+0I0kzYaM9JoGlcvVVc14BeRm6EPtT5yy6LGYf9pkP e4rzJLtin+G47rwEcs1rDt669hW9cso7Ka37iTMXvGm3drk4kQhjQ7Nqld7v7ZzS60SU UGXr0RNOigXOXuBHTqKtsf/pik6fc0qJ8RyBjNu6SVLIXi90MaC5vpu9LDh6iFrOLChQ xDgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=08VQJf6t+d5KMucwkgdu8oWlZrcKmjMWyC6bHqIdILs=; b=ADcZyzCxf03UMoWNEqWnypc6OB7Bf31NRcyzUNlWDTxWxAejrciLQR5dmLf0Xecwak CHxh5V3hr+0VExgIIky842gQFAGw2PZaYBvP86P7HTRLZaNWZHLwT5wFTsf/oEBbxkTr 30yjjFrW8lB4M2TePIxqWLMjx9m5YXd8u21a3dpDoOZiCuEvP4xddUjy8+ZieqPnGiiD D5pk2jDfrAKCr6s5NPwporSI/SgtBhjQK/lg/ot63oVylUSNEDdmFi2tAQgiS+FZBK4f 8bZDy2G8ZmseXfqJ0GV8atJGpnJjPq2G1aRDl7VUJSYF9uo30u6pDVSqhtrjyOxurTs6 FXEw== X-Gm-Message-State: AJcUukfmMIU1+vsuMu1akU9TQwFDHdjFKVKaIxMF4gegmQWJN9gkZTVs uZDDElCdSy4gEqqeHCsAVF+MHbjTM6Up5it808LHbXpFrPDmLQ== X-Google-Smtp-Source: ALg8bN5ttHKGyj2MoDEdGBeMtKpwWZVfbguiyoe1Zj+SrlgHSDSLgA4EumNvaWlO6JuMlDCukObLipaLJShdLtTvHd0= X-Received: by 2002:adf:fa90:: with SMTP id h16mr14335025wrr.326.1547212230733; Fri, 11 Jan 2019 05:10:30 -0800 (PST) MIME-Version: 1.0 References: <1547204116.2619408.1631744520.03A21CEC@webmail.messagingengine.com> In-Reply-To: From: Nick Owens Date: Fri, 11 Jan 2019 05:10:19 -0800 Message-ID: Subject: Re: [9front] bug in sed To: 9front@9front.org Content-Type: text/plain; charset="UTF-8" List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: encrypted core-aware API app high-performance interface in sed.c:/^substitute, when g is set, sed begins doing match/substitute in a loop. after a substitution it moves the pointer into the current string (called 'loc2') forward and tries to match again. however, when it attempts to match the regexp again, the regexp library is unaware that the string to be matched is not the true beginning of the line. thus the match for ^ always succeeds. compare OpenBSD regexec and sed, which use a REG_NOTBOL flag to indicate that ^ cannot match in subsequent matches https://man.openbsd.org/man3/regex.3 https://github.com/openbsd/src/blob/master/usr.bin/sed/process.c#L334 On Fri, Jan 11, 2019 at 4:58 AM hiro <23hiro@gmail.com> wrote: > > here's another testcase without needing spaces > > cpu% cat > test > asdfasdf > xasdf > cpu% sed 's/^asdf//g' test > > xasdf > cpu% ssam 's/^asdf//g' test > asdf > xasdf