From: Peter Rosin Date: Tue, 1 Mar 2011 07:25:24 +0000 (+0100) Subject: test defs: unindent without temporary file X-Git-Tag: ng-0.5a~228^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=78992b3411196a4e9e66bffed5a6ab96aa9d648f;p=thirdparty%2Fautomake.git test defs: unindent without temporary file * tests/defs.in (commented_sed_unindent_prog): Commented Sed program that strips the "proper" amount of leading whitespace. (unindent): Lazily strip comments from the above program and use it to unindent without using a temporary file. Signed-off-by: Peter Rosin --- diff --git a/ChangeLog b/ChangeLog index 47bc9fcdf..6f67d36cf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2011-03-01 Peter Rosin + + test defs: unindent without temporary file + * tests/defs.in (commented_sed_unindent_prog): Commented Sed program + that strips the "proper" amount of leading whitespace. + (unindent): Lazily strip comments from the above program and use it + to unindent without using a temporary file. + 2011-02-26 Stefano Lattarini libtool: suggest LT_INIT if LTLIBRARIES primary is used diff --git a/tests/defs.in b/tests/defs.in index fd0cc9cd5..2685112ed 100644 --- a/tests/defs.in +++ b/tests/defs.in @@ -440,6 +440,21 @@ AUTOMAKE_fails () AUTOMAKE_run 1 ${1+"$@"} } +commented_sed_unindent_prog=' + /^$/b # Nothing to do for empty lines. + x # Get x into pattern space. + /^$/{ # No prior x, go prepare it. + g # Copy this 1st non-blank line into pattern space. + s/^\(['"$tab"' ]*\).*/x\1/ # Prepare x in pattern space. + } # Now: x in pattern and in hold. + G # Build x\n in pattern space, and + h # duplicate it into hold space. + s/\n.*$// # Restore x in pattern space, and + x # exchange with the above duplicate in hold space. + s/^x\(.*\)\n\1// # Remove leading from . + s/^x.*\n// # Restore when there is no leading . +' + # unindent [input files...] # ------------------------- # Remove the "proper" amount of leading whitespace from the given files, @@ -448,14 +463,10 @@ AUTOMAKE_fails () # files. If no input file is specified, standard input is implied. unindent () { - cat ${1+"$@"} > deindent.tmp - indentation=`sed