|
6 | 6 | #include "rust_internal.h"
|
7 | 7 | #include "util/array_list.h"
|
8 | 8 | #include <stdarg.h>
|
| 9 | +#include <stdlib.h> |
| 10 | +#include <string.h> |
| 11 | +#include <alloca.h> |
9 | 12 |
|
10 | 13 | static uint32_t
|
11 | 14 | read_type_bit_mask() {
|
12 | 15 | uint32_t bits = rust_log::ULOG | rust_log::ERR;
|
13 | 16 | char *env_str = getenv("RUST_LOG");
|
14 | 17 | if (env_str) {
|
| 18 | + char *str = (char *)alloca(strlen(env_str) + 2); |
| 19 | + str[0] = ','; |
| 20 | + strcpy(str + 1, env_str); |
| 21 | + |
15 | 22 | bits = 0;
|
16 |
| - bits |= strstr(env_str, "err") ? rust_log::ERR : 0; |
17 |
| - bits |= strstr(env_str, "mem") ? rust_log::MEM : 0; |
18 |
| - bits |= strstr(env_str, "comm") ? rust_log::COMM : 0; |
19 |
| - bits |= strstr(env_str, "task") ? rust_log::TASK : 0; |
20 |
| - bits |= strstr(env_str, "up") ? rust_log::UPCALL : 0; |
21 |
| - bits |= strstr(env_str, "dom") ? rust_log::DOM : 0; |
22 |
| - bits |= strstr(env_str, "ulog") ? rust_log::ULOG : 0; |
23 |
| - bits |= strstr(env_str, "trace") ? rust_log::TRACE : 0; |
24 |
| - bits |= strstr(env_str, "dwarf") ? rust_log::DWARF : 0; |
25 |
| - bits |= strstr(env_str, "cache") ? rust_log::CACHE : 0; |
26 |
| - bits |= strstr(env_str, "timer") ? rust_log::TIMER : 0; |
27 |
| - bits |= strstr(env_str, "gc") ? rust_log::GC : 0; |
28 |
| - bits |= strstr(env_str, "stdlib") ? rust_log::STDLIB : 0; |
29 |
| - bits |= strstr(env_str, "special") ? rust_log::SPECIAL : 0; |
30 |
| - bits |= strstr(env_str, "kern") ? rust_log::KERN : 0; |
31 |
| - bits |= strstr(env_str, "all") ? rust_log::ALL : 0; |
32 |
| - bits = strstr(env_str, "none") ? 0 : bits; |
| 23 | + bits |= strstr(str, ",err") ? rust_log::ERR : 0; |
| 24 | + bits |= strstr(str, ",mem") ? rust_log::MEM : 0; |
| 25 | + bits |= strstr(str, ",comm") ? rust_log::COMM : 0; |
| 26 | + bits |= strstr(str, ",task") ? rust_log::TASK : 0; |
| 27 | + bits |= strstr(str, ",up") ? rust_log::UPCALL : 0; |
| 28 | + bits |= strstr(str, ",dom") ? rust_log::DOM : 0; |
| 29 | + bits |= strstr(str, ",ulog") ? rust_log::ULOG : 0; |
| 30 | + bits |= strstr(str, ",trace") ? rust_log::TRACE : 0; |
| 31 | + bits |= strstr(str, ",dwarf") ? rust_log::DWARF : 0; |
| 32 | + bits |= strstr(str, ",cache") ? rust_log::CACHE : 0; |
| 33 | + bits |= strstr(str, ",timer") ? rust_log::TIMER : 0; |
| 34 | + bits |= strstr(str, ",gc") ? rust_log::GC : 0; |
| 35 | + bits |= strstr(str, ",stdlib") ? rust_log::STDLIB : 0; |
| 36 | + bits |= strstr(str, ",special") ? rust_log::SPECIAL : 0; |
| 37 | + bits |= strstr(str, ",kern") ? rust_log::KERN : 0; |
| 38 | + bits |= strstr(str, ",bt") ? rust_log::BT : 0; |
| 39 | + bits |= strstr(str, ",all") ? rust_log::ALL : 0; |
| 40 | + bits = strstr(str, ",none") ? 0 : bits; |
33 | 41 | }
|
34 | 42 | return bits;
|
35 | 43 | }
|
|
0 commit comments