forked from Imagelibrary/binutils-gdb
Make format_pieces recognize the \e escape sequence
I noticed that the printf command did not recognize the \e escape sequence, used amongst other things to use colors: (gdb) printf "This is \e[32mgreen\e[m!\n" Unrecognized escape character \e in format string. This patch makes format_pieces recognize it, which makes that command print the expected result in glorious color. I wrote a really simple unit test for format_pieces. format_pieces::operator[] is unused so I removed it. I added format_piece::operator==, which is needed to compare vectors of format_piece. gdb/ChangeLog: PR cli/14975 * Makefile.in (SUBDIR_UNITTESTS_SRCS): Add unittests/format_pieces-selftests.c. * common/format.h (format_piece) <operator==>: New. (format_pieces) <operator[]>: Remove. * common/format.c (format_pieces::format_pieces): Handle \e. * unittests/format_pieces-selftests.c: New.
This commit is contained in:
@@ -56,6 +56,9 @@ format_pieces::format_pieces (const char **arg)
|
||||
case 'b':
|
||||
*f++ = '\b';
|
||||
break;
|
||||
case 'e':
|
||||
*f++ = '\e';
|
||||
break;
|
||||
case 'f':
|
||||
*f++ = '\f';
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user