Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
googletest
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
googletest
Commits
271fb8ff
Commit
271fb8ff
authored
Jun 22, 2017
by
Zulkarnine Mahmud
Committed by
GitHub
Jun 22, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix a problem when bg_color == fg_color
Invert the intensity bit if the background_color == foreground_color
parent
365df114
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
3 deletions
+24
-3
gtest.cc
googletest/src/gtest.cc
+24
-3
No files found.
googletest/src/gtest.cc
View file @
271fb8ff
...
@@ -2979,16 +2979,37 @@ void ColoredPrintf(GTestColor color, const char* fmt, ...) {
...
@@ -2979,16 +2979,37 @@ void ColoredPrintf(GTestColor color, const char* fmt, ...) {
CONSOLE_SCREEN_BUFFER_INFO
buffer_info
;
CONSOLE_SCREEN_BUFFER_INFO
buffer_info
;
GetConsoleScreenBufferInfo
(
stdout_handle
,
&
buffer_info
);
GetConsoleScreenBufferInfo
(
stdout_handle
,
&
buffer_info
);
const
WORD
old_color_attrs
=
buffer_info
.
wAttributes
;
const
WORD
old_color_attrs
=
buffer_info
.
wAttributes
;
// Let's reuse the BG
// Let's reuse the BG
const
WORD
background_mask
=
BACKGROUND_BLUE
|
BACKGROUND_GREEN
|
BACKGROUND_RED
|
BACKGROUND_INTENSITY
;
const
WORD
background_mask
=
BACKGROUND_BLUE
|
BACKGROUND_GREEN
|
BACKGROUND_RED
|
BACKGROUND_INTENSITY
;
const
WORD
foreground_mask
=
FOREGROUND_BLUE
|
FOREGROUND_GREEN
|
FOREGROUND_RED
|
FOREGROUND_INTENSITY
;
const
WORD
existing_bg
=
old_color_attrs
&
background_mask
;
const
WORD
existing_bg
=
old_color_attrs
&
background_mask
;
WORD
new_color
=
GetColorAttribute
(
color
)
|
existing_bg
|
FOREGROUND_INTENSITY
;
#if 1 // do we really need to waste these cpu cycles every time?
int
bg_bitOffset
=
0
;
WORD
bg_mask
=
background_mask
;
while
((
bg_mask
&
0x01
)
==
0x00
)
{
bg_mask
>>=
1
;
++
bg_bitOffset
;
}
#else
const
int
bg_bitOffset
=
4
;
#endif
if
(((
new_color
&
background_mask
)
>>
bg_bitOffset
)
==
(
new_color
&
foreground_mask
))
{
//revert intensity
new_color
^=
FOREGROUND_INTENSITY
;
}
// We need to flush the stream buffers into the console before each
// We need to flush the stream buffers into the console before each
// SetConsoleTextAttribute call lest it affect the text that is already
// SetConsoleTextAttribute call lest it affect the text that is already
// printed but has not yet reached the console.
// printed but has not yet reached the console.
fflush
(
stdout
);
fflush
(
stdout
);
SetConsoleTextAttribute
(
stdout_handle
,
SetConsoleTextAttribute
(
stdout_handle
,
new_color
);
GetColorAttribute
(
color
)
|
existing_bg
|
FOREGROUND_INTENSITY
);
vprintf
(
fmt
,
args
);
vprintf
(
fmt
,
args
);
fflush
(
stdout
);
fflush
(
stdout
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment