hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/tools/perf/util/color.c
....@@ -1,52 +1,14 @@
11 // SPDX-License-Identifier: GPL-2.0
22 #include <linux/kernel.h>
3
-#include "cache.h"
4
-#include "config.h"
3
+#include <subcmd/pager.h>
54 #include <stdlib.h>
65 #include <stdio.h>
6
+#include <string.h>
77 #include "color.h"
88 #include <math.h>
99 #include <unistd.h>
1010
1111 int perf_use_color_default = -1;
12
-
13
-int perf_config_colorbool(const char *var, const char *value, int stdout_is_tty)
14
-{
15
- if (value) {
16
- if (!strcasecmp(value, "never"))
17
- return 0;
18
- if (!strcasecmp(value, "always"))
19
- return 1;
20
- if (!strcasecmp(value, "auto"))
21
- goto auto_color;
22
- }
23
-
24
- /* Missing or explicit false to turn off colorization */
25
- if (!perf_config_bool(var, value))
26
- return 0;
27
-
28
- /* any normal truth value defaults to 'auto' */
29
- auto_color:
30
- if (stdout_is_tty < 0)
31
- stdout_is_tty = isatty(1);
32
- if (stdout_is_tty || pager_in_use()) {
33
- char *term = getenv("TERM");
34
- if (term && strcmp(term, "dumb"))
35
- return 1;
36
- }
37
- return 0;
38
-}
39
-
40
-int perf_color_default_config(const char *var, const char *value,
41
- void *cb __maybe_unused)
42
-{
43
- if (!strcmp(var, "color.ui")) {
44
- perf_use_color_default = perf_config_colorbool(var, value, -1);
45
- return 0;
46
- }
47
-
48
- return 0;
49
-}
5012
5113 static int __color_vsnprintf(char *bf, size_t size, const char *color,
5214 const char *fmt, va_list args, const char *trail)