Skip to content

Commit

Permalink
Drop the reset attributes on newlines
Browse files Browse the repository at this point in the history
  • Loading branch information
radare committed Mar 4, 2020
1 parent b76831c commit bb78ef3
Show file tree
Hide file tree
Showing 10 changed files with 138 additions and 137 deletions.
27 changes: 14 additions & 13 deletions libr/cons/cons.c
Original file line number Diff line number Diff line change
Expand Up @@ -1197,20 +1197,21 @@ R_API void r_cons_strcat(const char *str) {

R_API void r_cons_newline() {
if (!I.null) {
if (I.context->color_mode > 0) {
r_cons_strcat (R_CONS_CLEAR_FROM_CURSOR_TO_END"\n");
} else {
r_cons_strcat ("\n");
}
r_cons_strcat ("\n");
}
// This place is wrong to manage the color reset, can interfire with r2pipe output sending resetchars
// and break json output appending extra chars.
// this code now is managed into output.c:118 at function r_cons_w32_print
// now the console color is reset with each \n (same stuff do it here but in correct place ... i think)
//#if __WINDOWS__
//r_cons_reset_colors();
//#endif
//if (I.is_html) r_cons_strcat ("<br />\n");
#if 0
This place is wrong to manage the color reset, can interfire with r2pipe output sending resetchars
and break json output appending extra chars.
this code now is managed into output.c:118 at function r_cons_w32_print
now the console color is reset with each \n (same stuff do it here but in correct place ... i think)

#if __WINDOWS__
r_cons_reset_colors();
#else
r_cons_strcat (Color_RESET_ALL"\n");
#endif
if (I.is_html) r_cons_strcat ("<br />\n");
#endif
}

/* return the aproximated x,y of cursor before flushing */
Expand Down
2 changes: 1 addition & 1 deletion libr/cons/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ static int r_cons_w32_hprint(DWORD hdl, const char *ptr, int len, bool vmode) {
int ll = 0;
int raw_ll = 0;
int lines, cols = r_cons_get_size (&lines);
if (I->is_wine==-1) {
if (I->is_wine == -1) {
I->is_wine = r_file_is_directory ("/proc")? 1: 0;
}
if (len < 0) {
Expand Down
2 changes: 1 addition & 1 deletion test/new/db/anal/x86_64
Original file line number Diff line number Diff line change
Expand Up @@ -2240,7 +2240,7 @@ RUN
NAME=refs on PIC binary disassembly (color)
FILE=../bins/elf/analysis/xrefpic
EXPECT=<<EOF
| 0x08048432 lea eax, str.Hello_PIC
| 0x08048432 lea eax, str.Hello_PIC
EOF
CMDS=<<EOF
e asm.bytes=false
Expand Down
6 changes: 3 additions & 3 deletions test/new/db/cmd/cmd_ahi
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ RUN
NAME=ahi with colors
FILE=-
EXPECT=<<EOF
0x00000000 4881ec480600. sub rsp, 0x648
0x00000000 4881ec480600. sub rsp, 1608
0x00000000 4881ec480600. sub rsp, 0x648
0x00000000 4881ec480600. sub rsp, 1608
EOF
CMDS=<<EOF
e asm.bits=64
Expand Down Expand Up @@ -321,7 +321,7 @@ NAME=ahi s - pd with colors
FILE=-
EXPECT=<<EOF
0x00000000 mov dword [esp + 0x68], 'm0[\x1b'
0x00000000 mov dword [esp + 0x68], 'm0[\x1b'
0x00000000 mov dword [esp + 0x68], 'm0[\x1b'
EOF
CMDS=<<EOF
e asm.bytes=false
Expand Down
2 changes: 1 addition & 1 deletion test/new/db/cmd/cmd_ec
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ EXPECT=<<EOF
## gui.border
## wordhl
## linehl


## comment
## usrcmt
## args
Expand Down
56 changes: 28 additions & 28 deletions test/new/db/cmd/cmd_pd
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ RUN
NAME=pd pseudo test for issue #7268
FILE=malloc://8
EXPECT=<<EOF
0x00000000 4889e5 rbp = rsp
 0x00000000 4889e5 rbp = rsp
0x00000000 4889e5 rbp = rsp
 0x00000000 4889e5 rbp = rsp
EOF
CMDS=<<EOF
e asm.arch=x86
Expand All @@ -258,7 +258,7 @@ RUN
NAME=pd bits hint
FILE=-
EXPECT=<<EOF
0x00000000 a97e00 lda #0x007e
0x00000000 a97e00 lda #0x007e
EOF
ARGS=-a snes
CMDS=<<EOF
Expand Down Expand Up @@ -818,8 +818,8 @@ RUN
NAME=pd asm.filter color
FILE=../bins/elf/analysis/ls-alxchk
EXPECT=<<EOF
0x0001145f lea rdi, str.A_NULL_argv_0__was_passed_through_an_exec_system_call.
0x0001145f lea rdi, [0x0001b5d8]
0x0001145f lea rdi, str.A_NULL_argv_0__was_passed_through_an_exec_system_call.
0x0001145f lea rdi, [0x0001b5d8]
EOF
CMDS=<<EOF
e asm.bytes=false
Expand Down Expand Up @@ -1193,10 +1193,10 @@ RUN
NAME=no | highlight with asm.cmt.right=false & call statement
FILE=../bins/pe/ConsoleApplication1.exe
EXPECT=<<EOF
| 0x004010e8 push esi
| ; 0x402004
| ; DWORD GetCurrentProcessorNumber(void)
| 0x004010e9 call dword [sym.imp.KERNEL32.dll_GetCurrentProcessorNumber]
| 0x004010e8 push esi
| ; 0x402004
| ; DWORD GetCurrentProcessorNumber(void)
| 0x004010e9 call dword [sym.imp.KERNEL32.dll_GetCurrentProcessorNumber]
EOF
CMDS=<<EOF
e asm.bytes=false
Expand Down Expand Up @@ -1399,7 +1399,7 @@ FILE=../bins/elf/crackme0x00b
EXPECT=<<EOF
0x080484aa b8e1850408 mov eax, 0x80485e1 ; eax=0x80485e1 "%ls"
[{"offset":134513834,"text":" 0x080484aa b8e1850408 mov eax, 0x80485e1 ; eax=0x80485e1 \"%ls\""}]
0x080484aa b8e1850408 mov eax, 0x80485e1 ; eax=0x80485e1 "%ls"
0x080484aa b8e1850408 mov eax, 0x80485e1 ; eax=0x80485e1 "%ls"
[{"offset":134513834,"text":" \u001b[32m0x080484aa\u001b[0m \u001b[37mb8\u001b[37me1\u001b[37m85\u001b[37m04\u001b[37m08\u001b[0m \u001b[37mmov\u001b[36m eax\u001b[0m,\u001b[36m\u001b[36m \u001b[33m0x80485e1\u001b[0m\u001b[0m\u001b[0m\u001b[31m ; eax=0x80485e1 \u001b[7m\"%ls\"\u001b[27m\u001b[0m"}]
EOF
CMDS=<<EOF
Expand Down Expand Up @@ -1716,17 +1716,17 @@ e emu.str.inv=false
pd 1 @ 0x161d
EOF
EXPECT=<<EOF
0x0000161d lea eax, [esi - abcdefghi] ; 0x21f7 ; "abcdefghi" ; "\n Blue Pill" str.Blue_Pill
0x0000161d lea eax, [esi - abcdefghi] ; 0x21f7 ; "abcdefghi" ; "\n Blue Pill" str.Blue_Pill

; 0x21f7
; "abcdefghi"
 ; "\n Blue Pill" str.Blue_Pill
 0x0000161d lea eax, [esi - abcdefghi]
; 0x21f7
; "abcdefghi"
 ; "\n Blue Pill" str.Blue_Pill
 0x0000161d lea eax, [esi - abcdefghi]
0x0000161d lea eax, [esi - abcdefghi] ; 0x21f7 ; "abcdefghi" ; "\n Blue Pill" str.Blue_Pill
0x0000161d lea eax, [esi - abcdefghi] ; 0x21f7 ; "abcdefghi" ; "\n Blue Pill" str.Blue_Pill

; 0x21f7
; "abcdefghi"
 ; "\n Blue Pill" str.Blue_Pill
 0x0000161d lea eax, [esi - abcdefghi]
; 0x21f7
; "abcdefghi"
 ; "\n Blue Pill" str.Blue_Pill
 0x0000161d lea eax, [esi - abcdefghi]
EOF
RUN

Expand Down Expand Up @@ -1842,13 +1842,13 @@ s 0
pd 1 @ 0x1457
EOF
EXPECT=<<EOF
0x00001457 8d8689ddffff lea eax, [esi - 0x2277] ; " Take the Red Pill!! \n"
0x0000145d 50 push eax
0x0000145e 8b86f0ffffff mov eax, dword [esi - 0x10]
0x00001457 8d8689ddffff lea eax, [esi - 0x2277] ; " Take the Red Pill!! \n"
0x00001457 8d8689ddffff lea eax, [esi - 0x2277] ; " Take the Red Pill!! \n"
0x00001457 8d8689ddffff lea eax, [esi - 0x2277] ; " Take the Red Pill!! \n"
0x00001457 8d8689ddffff lea eax, [esi - 0x2277] ; " Take the Red Pill!! \n"
0x00001457 8d8689ddffff lea eax, [esi - 0x2277] ; " Take the Red Pill!! \n"
0x0000145d 50 push eax
0x0000145e 8b86f0ffffff mov eax, dword [esi - 0x10]
0x00001457 8d8689ddffff lea eax, [esi - 0x2277] ; " Take the Red Pill!! \n"
0x00001457 8d8689ddffff lea eax, [esi - 0x2277] ; " Take the Red Pill!! \n"
0x00001457 8d8689ddffff lea eax, [esi - 0x2277] ; " Take the Red Pill!! \n"
0x00001457 8d8689ddffff lea eax, [esi - 0x2277] ; " Take the Red Pill!! \n"
EOF
RUN

Expand Down
Loading

0 comments on commit bb78ef3

Please sign in to comment.