This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
Re: Re: diag_printf refuses to print ANSI escape sequences?
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Grant Edwards wrote:
> On 2007-05-26, Sergei Gavrikov <w3sg@SoftHome.net> wrote:
>> On Sat, May 26, 2007 at 03:19:42PM +0000, Grant Edwards wrote:
>>> In the "not a big deal" department...
>>>
>>> I'm trying to send ANSI escape sequences using diag_printf, and
>>> diag_printf refuses. If I put the escape character in the format
>>> string it says
>>>
>>> <Bad format string: 8055F18 : 0 0 2 807F0D8 DDD9BFFD FB93FFDC 8055758
>>> FB93FFDC>
>>>
>>> If there's an escape character in a string that is to be printed using
>>> the "%s" format, it says:
>>>
>>> <Not a string: 0x8055F20>
>>>
>>> I understand that it's useful to attempt to avoid printing random
>>> binary garbage, but I would think that ASCII ESC might be allowed in
>>> strings.
>>>
>>> I've found that insterting the escape characters using %c works, but
>>> that's a bit awkward.
>>
>> There are nice diag_dump_buf* functions in the eCos infra layer
>> (cyg/infra/diag.h). I do use that.
>
> I'm aware of the daig_dump_buf fuctions, but I don't see how
> they solve my problem. AFAIR, they dump out buffer contents in
> hex. What I'm trying to do is:
>
> diag_printf("\033[34mBlue Text \033[31mRed Text \033[mNormal Text\n");
>
> diag_printf refuses to do that, so I have to do something like
> this instead:
>
> diag_printf("%c[34mBlue Text %c[31mRed Text %c[mNormal Text\n",033,033,033);
>
> and that seems awkward to me.
>
> One could argue that embedding escape seqences in strings is a
> bit hackish...
>
Why not just make a patch that allows for such escape sequences?
There's nothing to say that we didn't think of everything some 10 years
ago and that today's world could accept some improvements :-) If you're
coy about such changes, make it conditional with some CDL, e.g. spelling
out what non "printable" characters are allowed, etc.
- --
- ------------------------------------------------------------
Gary Thomas | Consulting for the
MLB Associates | Embedded world
- ------------------------------------------------------------
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org
iD8DBQFGWO3jmaKbSsQGV8ARAoLkAJ4hxSqYVCLvGv1gST78UKD86dTS1ACfUW+u
EmdmXl2naFYXaGXYOKPGHB8=
=ZFnw
-----END PGP SIGNATURE-----
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss