Hello Dan and Noah,
I think the following idea is execllent:
On Mon, Jan 17, 2005 at 01:37:03PM -0800, Noah Misch wrote:
> If you wanted to avoid excluding any delimiter, you do something like this:
>
> for ac_var in var1 var2 ... varN
> do
> eval "case \$$ac_var in
> *'
> '*) filter=' | sed '\\''\$q;s/\$/\\\\/'\\' ;;
> *) filter= ;;
> esac"
>
> eval echo \"s,@$ac_var@,\$$ac_var,\;t t\" $filter
> done | existing_cleanup_seds
The code still isn't perfectly correct, though: what if a one line value
happens to end with a backslash? How can you distinguish it from a
multiline value.
And I would use a more readable way to implement it:
for ac_var in var1 var2 ... varN
do
eval ac_val="\"\$$ac_var\""
case $ac_val in
*'
'*) echo "@[EMAIL PROTECTED]" | sed ...encode... ;;
*) echo "[EMAIL PROTECTED]"
esac
done | sed ...
The "encode" sed program would take care to encode things properly,
for example 's/\\/\\x/g;$q;s/$/\\/' .
(The main point is that we have to escape real backslashes somehow.)
The post-processing program would recognize lines starting with @,
and decode them, for example:
/^@/!b ok
s/^@//
:loop
N
/\\$/b loop
s/\\x/\\/g
:ok
s/[\\\\&,]/\\\\&/g
s/[EMAIL PROTECTED]@/s,@&,/
s/$/,;t t/
Thanks to Noah's idea, the value can be any string, yet the performance
is fine.
I'm looking forward to see your code, Dan.
Have a nice day,
Stepan Kasal
_______________________________________________
Autoconf mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/autoconf