[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] test defs: add subroutine for input unindenting
From: |
Peter Rosin |
Subject: |
Re: [PATCH] test defs: add subroutine for input unindenting |
Date: |
Sat, 19 Feb 2011 00:28:53 +0100 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101207 Thunderbird/3.1.7 |
Den 2011-02-18 13:12 skrev Peter Rosin:
> Yes, I will try my best not to spam the list with more versions of
> this baby...
Famous last words. Sorry. 18 lines -> 15 lines -> 12 lines
Will be AFK the next week, so with a bit of luck I will have forgotten all
about this when I get back.
Cheers,
Peter (who is aware that comments in sed programs are not portable -> strip)
unindent ()
{
sed '
/^$/b # Nothing to do for empty lines, next line please.
x # Get x<indent> into pattern space.
/^$/{ # No prior x<indent>, go prepare it.
g # Copy this 1st non-blank line into pattern space.
s/^\([ ]*\).*/x\1/ # Prepare x<indent> in pattern space.
} # Now: x<indent> in pattern and <line> in hold.
G # Build x<indent>\n<line> in pattern space, and
h # duplicate it into hold space.
s/\n.*$// # Restore x<indent> in pattern space, and
x # exchange with the above duplicate in hold space.
s/^x\(.*\)\n\1// # Remove leading <indent> from <line>.
s/^.*\n//' # Restore <line> when there's no leading <indent>.
}
- [PATCH] test defs: add subroutine for input unindenting (was: Re: [Ping PATCHES] {master} Optimize tests `instspc-*.test' for speed.), (continued)
- [PATCH] test defs: add subroutine for input unindenting (was: Re: [Ping PATCHES] {master} Optimize tests `instspc-*.test' for speed.), Stefano Lattarini, 2011/02/15
- Re: [PATCH] test defs: add subroutine for input unindenting, Ralf Wildenhues, 2011/02/15
- Re: [PATCH] test defs: add subroutine for input unindenting, Stefano Lattarini, 2011/02/15
- Re: [PATCH] test defs: add subroutine for input unindenting, Ralf Wildenhues, 2011/02/16
- Re: [PATCH] test defs: add subroutine for input unindenting, Stefano Lattarini, 2011/02/16
- Re: [PATCH] test defs: add subroutine for input unindenting, Ralf Wildenhues, 2011/02/17
- Re: [PATCH] test defs: add subroutine for input unindenting, Peter Rosin, 2011/02/17
- Re: [PATCH] test defs: add subroutine for input unindenting, Peter Rosin, 2011/02/17
- Re: [PATCH] test defs: add subroutine for input unindenting, Stefano Lattarini, 2011/02/17
- Re: [PATCH] test defs: add subroutine for input unindenting, Peter Rosin, 2011/02/18
- Re: [PATCH] test defs: add subroutine for input unindenting,
Peter Rosin <=
- Re: [PATCH] test defs: add subroutine for input unindenting, Ralf Wildenhues, 2011/02/21
- Re: [PATCH] test defs: add subroutine for input unindenting, Stefano Lattarini, 2011/02/21
- Re: [PATCH] test defs: add subroutine for input unindenting, Ralf Wildenhues, 2011/02/21
- Re: [PATCH] test defs: add subroutine for input unindenting, Peter Rosin, 2011/02/28
- Re: [PATCH] test defs: add subroutine for input unindenting, Peter Rosin, 2011/02/28
- Re: [PATCH] test defs: add subroutine for input unindenting, Stefano Lattarini, 2011/02/28
- Re: [PATCH] test defs: add subroutine for input unindenting, Ralf Wildenhues, 2011/02/28
- Re: [PATCH] test defs: add subroutine for input unindenting, Peter Rosin, 2011/02/28
Re: [Ping PATCHES] {master} Optimize tests `instspc-*.test' for speed., Ralf Wildenhues, 2011/02/15