[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: |
Ralf Wildenhues |
Subject: |
Re: [PATCH] test defs: add subroutine for input unindenting |
Date: |
Mon, 21 Feb 2011 06:03:39 +0100 |
User-agent: |
Mutt/1.5.20 (2010-08-04) |
Hi Peter,
* Peter Rosin wrote on Sat, Feb 19, 2011 at 12:28:53AM CET:
> 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.
tab before space, please; or even better, use ...'"$tab"'...
> } # 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>.
> }
I kinda like this. It will be unintelligible without the comments,
however. gnulib-tool has a sed comment removal, search for
$sed_comments. What I wouldn't like is invoking an extra sed in each
test startup just to remove comments from a helper function, that will
noticeably slow down things (it could be removed at config.status
time?); OTOH, this function will be faster than our current unindent.
And I'll defer to Stefano's preference for or against complex code in
the testsuite.
Thanks,
Ralf
- Re: [PATCH] test defs: add subroutine for input unindenting, (continued)
- 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, 2011/02/18
- Re: [PATCH] test defs: add subroutine for input unindenting,
Ralf Wildenhues <=
- 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