Page MenuHomeFreeBSD

sed: process \r, \n, and \t
ClosedPublic

Authored by kevans on Dec 10 2019, 4:22 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, May 2, 2:13 PM
Unknown Object (File)
Thu, May 2, 2:13 PM
Unknown Object (File)
Thu, May 2, 2:13 PM
Unknown Object (File)
Thu, May 2, 2:13 PM
Unknown Object (File)
Thu, May 2, 11:12 AM
Unknown Object (File)
Apr 2 2024, 1:57 PM
Unknown Object (File)
Jan 11 2024, 2:32 PM
Unknown Object (File)
Dec 24 2023, 11:53 PM
Subscribers

Details

Summary

This is both reasonable and a common GNUism that a lot of ported software expects.

Universally process \r, \n, and \t into carriage return, newline, and tab respectively. Newline still doesn't function in contexts where it can't (e.g. BRE), but we process it anyways rather than passing UB \n (escaped ordinary) through to the underlying regex engine.

Adding a --posix flag to disable these was considered, but sed.1 already declares this version of sed a super-set of POSIX specification and this behavior is the most likely expected when one attempts to use one of these escape sequences in pattern space.

This differs from pre-rS197362 behavior in that we now honor the three arguably most common escape sequences used with sed(1) and we do so out side of character classes, too.

PR: 229925

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

This revision is now accepted and ready to land.Dec 10 2019, 4:35 PM
emaste added inline comments.
usr.bin/sed/compile.c
398–400 ↗(On Diff #65459)

probably wrap this ==c case in { } ?

  • Improve our bracing game
This revision now requires review to proceed.Dec 10 2019, 6:41 PM
This revision is now accepted and ready to land.Dec 10 2019, 6:44 PM
This revision was automatically updated to reflect the committed changes.