mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-06 13:58:40 +00:00
eliminate radcon, eliminate unused string helpers
This commit is contained in:
+258
-216
@@ -50,7 +50,7 @@ char_is_digit(U8 c, U32 base)
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal U8
|
internal U8
|
||||||
char_to_lower(U8 c)
|
lower_from_char(U8 c)
|
||||||
{
|
{
|
||||||
if(char_is_upper(c))
|
if(char_is_upper(c))
|
||||||
{
|
{
|
||||||
@@ -60,7 +60,7 @@ char_to_lower(U8 c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal U8
|
internal U8
|
||||||
char_to_upper(U8 c)
|
upper_from_char(U8 c)
|
||||||
{
|
{
|
||||||
if(char_is_lower(c))
|
if(char_is_lower(c))
|
||||||
{
|
{
|
||||||
@@ -70,7 +70,7 @@ char_to_upper(U8 c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal U8
|
internal U8
|
||||||
char_to_correct_slash(U8 c)
|
correct_slash_from_char(U8 c)
|
||||||
{
|
{
|
||||||
if(char_is_slash(c))
|
if(char_is_slash(c))
|
||||||
{
|
{
|
||||||
@@ -242,7 +242,7 @@ upper_from_str8(Arena *arena, String8 string)
|
|||||||
string = push_str8_copy(arena, string);
|
string = push_str8_copy(arena, string);
|
||||||
for(U64 idx = 0; idx < string.size; idx += 1)
|
for(U64 idx = 0; idx < string.size; idx += 1)
|
||||||
{
|
{
|
||||||
string.str[idx] = char_to_upper(string.str[idx]);
|
string.str[idx] = upper_from_char(string.str[idx]);
|
||||||
}
|
}
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
@@ -253,7 +253,7 @@ lower_from_str8(Arena *arena, String8 string)
|
|||||||
string = push_str8_copy(arena, string);
|
string = push_str8_copy(arena, string);
|
||||||
for(U64 idx = 0; idx < string.size; idx += 1)
|
for(U64 idx = 0; idx < string.size; idx += 1)
|
||||||
{
|
{
|
||||||
string.str[idx] = char_to_lower(string.str[idx]);
|
string.str[idx] = lower_from_char(string.str[idx]);
|
||||||
}
|
}
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
@@ -292,13 +292,13 @@ str8_match(String8 a, String8 b, StringMatchFlags flags)
|
|||||||
U8 bt = b.str[i];
|
U8 bt = b.str[i];
|
||||||
if(case_insensitive)
|
if(case_insensitive)
|
||||||
{
|
{
|
||||||
at = char_to_upper(at);
|
at = upper_from_char(at);
|
||||||
bt = char_to_upper(bt);
|
bt = upper_from_char(bt);
|
||||||
}
|
}
|
||||||
if(slash_insensitive)
|
if(slash_insensitive)
|
||||||
{
|
{
|
||||||
at = char_to_correct_slash(at);
|
at = correct_slash_from_char(at);
|
||||||
bt = char_to_correct_slash(bt);
|
bt = correct_slash_from_char(bt);
|
||||||
}
|
}
|
||||||
if(at != bt)
|
if(at != bt)
|
||||||
{
|
{
|
||||||
@@ -324,14 +324,14 @@ str8_find_needle(String8 string, U64 start_pos, String8 needle, StringMatchFlags
|
|||||||
U8 needle_first_char_adjusted = needle.str[0];
|
U8 needle_first_char_adjusted = needle.str[0];
|
||||||
if(adjusted_flags & StringMatchFlag_CaseInsensitive)
|
if(adjusted_flags & StringMatchFlag_CaseInsensitive)
|
||||||
{
|
{
|
||||||
needle_first_char_adjusted = char_to_upper(needle_first_char_adjusted);
|
needle_first_char_adjusted = upper_from_char(needle_first_char_adjusted);
|
||||||
}
|
}
|
||||||
for(;p < stop_p; p += 1)
|
for(;p < stop_p; p += 1)
|
||||||
{
|
{
|
||||||
U8 haystack_char_adjusted = *p;
|
U8 haystack_char_adjusted = *p;
|
||||||
if(adjusted_flags & StringMatchFlag_CaseInsensitive)
|
if(adjusted_flags & StringMatchFlag_CaseInsensitive)
|
||||||
{
|
{
|
||||||
haystack_char_adjusted = char_to_upper(haystack_char_adjusted);
|
haystack_char_adjusted = upper_from_char(haystack_char_adjusted);
|
||||||
}
|
}
|
||||||
if(haystack_char_adjusted == needle_first_char_adjusted)
|
if(haystack_char_adjusted == needle_first_char_adjusted)
|
||||||
{
|
{
|
||||||
@@ -397,41 +397,46 @@ str8_is_before(String8 a, String8 b)
|
|||||||
//~ rjf: String Slicing
|
//~ rjf: String Slicing
|
||||||
|
|
||||||
internal String8
|
internal String8
|
||||||
str8_substr(String8 str, Rng1U64 range){
|
str8_substr(String8 str, Rng1U64 range)
|
||||||
|
{
|
||||||
range.min = ClampTop(range.min, str.size);
|
range.min = ClampTop(range.min, str.size);
|
||||||
range.max = ClampTop(range.max, str.size);
|
range.max = ClampTop(range.max, str.size);
|
||||||
str.str += range.min;
|
str.str += range.min;
|
||||||
str.size = dim_1u64(range);
|
str.size = dim_1u64(range);
|
||||||
return(str);
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal String8
|
internal String8
|
||||||
str8_prefix(String8 str, U64 size){
|
str8_prefix(String8 str, U64 size)
|
||||||
|
{
|
||||||
str.size = ClampTop(size, str.size);
|
str.size = ClampTop(size, str.size);
|
||||||
return(str);
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal String8
|
internal String8
|
||||||
str8_skip(String8 str, U64 amt){
|
str8_skip(String8 str, U64 amt)
|
||||||
|
{
|
||||||
amt = ClampTop(amt, str.size);
|
amt = ClampTop(amt, str.size);
|
||||||
str.str += amt;
|
str.str += amt;
|
||||||
str.size -= amt;
|
str.size -= amt;
|
||||||
return(str);
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal String8
|
internal String8
|
||||||
str8_postfix(String8 str, U64 size){
|
str8_postfix(String8 str, U64 size)
|
||||||
|
{
|
||||||
size = ClampTop(size, str.size);
|
size = ClampTop(size, str.size);
|
||||||
str.str = (str.str + str.size) - size;
|
str.str = (str.str + str.size) - size;
|
||||||
str.size = size;
|
str.size = size;
|
||||||
return(str);
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal String8
|
internal String8
|
||||||
str8_chop(String8 str, U64 amt){
|
str8_chop(String8 str, U64 amt)
|
||||||
|
{
|
||||||
amt = ClampTop(amt, str.size);
|
amt = ClampTop(amt, str.size);
|
||||||
str.size -= amt;
|
str.size -= amt;
|
||||||
return(str);
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal String8
|
internal String8
|
||||||
@@ -550,11 +555,13 @@ push_cstr(Arena *arena, String8 str)
|
|||||||
//- rjf: string -> integer
|
//- rjf: string -> integer
|
||||||
|
|
||||||
internal S64
|
internal S64
|
||||||
sign_from_str8(String8 string, String8 *string_tail){
|
sign_from_str8(String8 string, String8 *string_tail)
|
||||||
|
{
|
||||||
// count negative signs
|
// count negative signs
|
||||||
U64 neg_count = 0;
|
U64 neg_count = 0;
|
||||||
U64 i = 0;
|
U64 i = 0;
|
||||||
for (; i < string.size; i += 1){
|
for(; i < string.size; i += 1)
|
||||||
|
{
|
||||||
if (string.str[i] == '-'){
|
if (string.str[i] == '-'){
|
||||||
neg_count += 1;
|
neg_count += 1;
|
||||||
}
|
}
|
||||||
@@ -568,18 +575,23 @@ sign_from_str8(String8 string, String8 *string_tail){
|
|||||||
|
|
||||||
// output integer sign
|
// output integer sign
|
||||||
S64 sign = (neg_count & 1)?-1:+1;
|
S64 sign = (neg_count & 1)?-1:+1;
|
||||||
return(sign);
|
return sign;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal B32
|
internal B32
|
||||||
str8_is_integer(String8 string, U32 radix){
|
str8_is_integer(String8 string, U32 radix)
|
||||||
|
{
|
||||||
B32 result = 0;
|
B32 result = 0;
|
||||||
if (string.size > 0){
|
if(string.size > 0)
|
||||||
if (1 < radix && radix <= 16){
|
{
|
||||||
|
if(1 < radix && radix <= 16)
|
||||||
|
{
|
||||||
result = 1;
|
result = 1;
|
||||||
for (U64 i = 0; i < string.size; i += 1){
|
for(U64 i = 0; i < string.size; i += 1)
|
||||||
|
{
|
||||||
U8 c = string.str[i];
|
U8 c = string.str[i];
|
||||||
if (!(c < 0x80) || integer_symbol_reverse[c] >= radix){
|
if(!(c < 0x80) || integer_symbol_reverse[c] >= radix)
|
||||||
|
{
|
||||||
result = 0;
|
result = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -590,22 +602,26 @@ str8_is_integer(String8 string, U32 radix){
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal U64
|
internal U64
|
||||||
u64_from_str8(String8 string, U32 radix){
|
u64_from_str8(String8 string, U32 radix)
|
||||||
|
{
|
||||||
U64 x = 0;
|
U64 x = 0;
|
||||||
if (1 < radix && radix <= 16){
|
if(1 < radix && radix <= 16)
|
||||||
for (U64 i = 0; i < string.size; i += 1){
|
{
|
||||||
|
for(U64 i = 0; i < string.size; i += 1)
|
||||||
|
{
|
||||||
x *= radix;
|
x *= radix;
|
||||||
x += integer_symbol_reverse[string.str[i]&0x7F];
|
x += integer_symbol_reverse[string.str[i]&0x7F];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return(x);
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal S64
|
internal S64
|
||||||
s64_from_str8(String8 string, U32 radix){
|
s64_from_str8(String8 string, U32 radix)
|
||||||
|
{
|
||||||
S64 sign = sign_from_str8(string, &string);
|
S64 sign = sign_from_str8(string, &string);
|
||||||
S64 x = (S64)u64_from_str8(string, radix) * sign;
|
S64 x = (S64)u64_from_str8(string, radix) * sign;
|
||||||
return(x);
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal U32
|
internal U32
|
||||||
@@ -627,7 +643,10 @@ s32_from_str8(String8 string, U32 radix)
|
|||||||
internal B32
|
internal B32
|
||||||
try_u64_from_str8_c_rules(String8 string, U64 *x)
|
try_u64_from_str8_c_rules(String8 string, U64 *x)
|
||||||
{
|
{
|
||||||
U64 radix, prefix_size;
|
// rjf: unpack radix / prefix size based on string prefix
|
||||||
|
U64 radix = 0;
|
||||||
|
U64 prefix_size = 0;
|
||||||
|
{
|
||||||
// hex
|
// hex
|
||||||
if(str8_match(str8_prefix(string, 2), str8_lit("0x"), StringMatchFlag_CaseInsensitive))
|
if(str8_match(str8_prefix(string, 2), str8_lit("0x"), StringMatchFlag_CaseInsensitive))
|
||||||
{
|
{
|
||||||
@@ -648,7 +667,9 @@ try_u64_from_str8_c_rules(String8 string, U64 *x)
|
|||||||
{
|
{
|
||||||
radix = 10, prefix_size = 0;
|
radix = 10, prefix_size = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// rjf: convert if we can
|
||||||
String8 integer = str8_skip(string, prefix_size);
|
String8 integer = str8_skip(string, prefix_size);
|
||||||
B32 is_integer = str8_is_integer(integer, radix);
|
B32 is_integer = str8_is_integer(integer, radix);
|
||||||
if(is_integer)
|
if(is_integer)
|
||||||
@@ -675,8 +696,8 @@ try_s64_from_str8_c_rules(String8 string, S64 *x)
|
|||||||
internal String8
|
internal String8
|
||||||
str8_from_memory_size(Arena *arena, U64 size)
|
str8_from_memory_size(Arena *arena, U64 size)
|
||||||
{
|
{
|
||||||
String8 result;
|
String8 result = {0};
|
||||||
|
{
|
||||||
if(size < KB(1))
|
if(size < KB(1))
|
||||||
{
|
{
|
||||||
result = push_str8f(arena, "%llu Bytes", size);
|
result = push_str8f(arena, "%llu Bytes", size);
|
||||||
@@ -697,15 +718,15 @@ str8_from_memory_size(Arena *arena, U64 size)
|
|||||||
{
|
{
|
||||||
result = push_str8f(arena, "%llu.%02llu TiB", size / TB(1), ((size * 100) / TB(1)) % 100);
|
result = push_str8f(arena, "%llu.%02llu TiB", size / TB(1), ((size * 100) / TB(1)) % 100);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal String8
|
internal String8
|
||||||
str8_from_count(Arena *arena, U64 count)
|
str8_from_count(Arena *arena, U64 count)
|
||||||
{
|
{
|
||||||
String8 result;
|
String8 result = {0};
|
||||||
|
{
|
||||||
if(count < 1 * 1000)
|
if(count < 1 * 1000)
|
||||||
{
|
{
|
||||||
result = push_str8f(arena, "%llu", count);
|
result = push_str8f(arena, "%llu", count);
|
||||||
@@ -746,7 +767,7 @@ str8_from_count(Arena *arena, U64 count)
|
|||||||
result = push_str8f(arena, "%lluB", count / 1000000000, frac);
|
result = push_str8f(arena, "%lluB", count / 1000000000, frac);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -859,7 +880,7 @@ str8_from_u64(Arena *arena, U64 u64, U32 radix, U8 min_digits, U8 digit_group_se
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
result.str[result.size - idx - 1] = char_to_lower(integer_symbols[u64_reduce%radix]);
|
result.str[result.size - idx - 1] = lower_from_char(integer_symbols[u64_reduce%radix]);
|
||||||
u64_reduce /= radix;
|
u64_reduce /= radix;
|
||||||
}
|
}
|
||||||
digits_until_separator -= 1;
|
digits_until_separator -= 1;
|
||||||
@@ -952,72 +973,73 @@ f64_from_str8(String8 string)
|
|||||||
//~ rjf: String List Construction Functions
|
//~ rjf: String List Construction Functions
|
||||||
|
|
||||||
internal String8Node *
|
internal String8Node *
|
||||||
str8_list_push_node(String8List *list, String8Node *node){
|
str8_list_push_node(String8List *list, String8Node *node)
|
||||||
SLLQueuePush(list->first, list->last, node);
|
|
||||||
list->node_count += 1;
|
|
||||||
list->total_size += node->string.size;
|
|
||||||
return(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal String8Node*
|
|
||||||
str8_list_push_node_set_string(String8List *list, String8Node *node, String8 string){
|
|
||||||
SLLQueuePush(list->first, list->last, node);
|
|
||||||
list->node_count += 1;
|
|
||||||
list->total_size += string.size;
|
|
||||||
node->string = string;
|
|
||||||
return(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal String8Node*
|
|
||||||
str8_list_push_node_front(String8List *list, String8Node *node){
|
|
||||||
SLLQueuePushFront(list->first, list->last, node);
|
|
||||||
list->node_count += 1;
|
|
||||||
list->total_size += node->string.size;
|
|
||||||
return(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal String8Node*
|
|
||||||
str8_list_push_node_front_set_string(String8List *list, String8Node *node, String8 string){
|
|
||||||
SLLQueuePushFront(list->first, list->last, node);
|
|
||||||
list->node_count += 1;
|
|
||||||
list->total_size += string.size;
|
|
||||||
node->string = string;
|
|
||||||
return(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal String8Node*
|
|
||||||
str8_list_push(Arena *arena, String8List *list, String8 string){
|
|
||||||
String8Node *node = push_array_no_zero(arena, String8Node, 1);
|
|
||||||
str8_list_push_node_set_string(list, node, string);
|
|
||||||
return(node);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal String8Node *
|
|
||||||
str8_list_push_cstr(Arena *arena, String8List *list, String8 string)
|
|
||||||
{
|
{
|
||||||
String8Node *node = str8_list_push(arena, list, string);
|
SLLQueuePush(list->first, list->last, node);
|
||||||
local_persist String8 null = str8_lit_comp("\0");
|
list->node_count += 1;
|
||||||
str8_list_push(arena, list, null);
|
list->total_size += node->string.size;
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal String8Node *
|
internal String8Node *
|
||||||
str8_list_push_front(Arena *arena, String8List *list, String8 string){
|
str8_list_push_node_set_string(String8List *list, String8Node *node, String8 string)
|
||||||
|
{
|
||||||
|
SLLQueuePush(list->first, list->last, node);
|
||||||
|
list->node_count += 1;
|
||||||
|
list->total_size += string.size;
|
||||||
|
node->string = string;
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal String8Node *
|
||||||
|
str8_list_push_node_front(String8List *list, String8Node *node)
|
||||||
|
{
|
||||||
|
SLLQueuePushFront(list->first, list->last, node);
|
||||||
|
list->node_count += 1;
|
||||||
|
list->total_size += node->string.size;
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal String8Node *
|
||||||
|
str8_list_push_node_front_set_string(String8List *list, String8Node *node, String8 string)
|
||||||
|
{
|
||||||
|
SLLQueuePushFront(list->first, list->last, node);
|
||||||
|
list->node_count += 1;
|
||||||
|
list->total_size += string.size;
|
||||||
|
node->string = string;
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal String8Node *
|
||||||
|
str8_list_push(Arena *arena, String8List *list, String8 string)
|
||||||
|
{
|
||||||
|
String8Node *node = push_array_no_zero(arena, String8Node, 1);
|
||||||
|
str8_list_push_node_set_string(list, node, string);
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal String8Node *
|
||||||
|
str8_list_push_front(Arena *arena, String8List *list, String8 string)
|
||||||
|
{
|
||||||
String8Node *node = push_array_no_zero(arena, String8Node, 1);
|
String8Node *node = push_array_no_zero(arena, String8Node, 1);
|
||||||
str8_list_push_node_front_set_string(list, node, string);
|
str8_list_push_node_front_set_string(list, node, string);
|
||||||
return(node);
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
str8_list_concat_in_place(String8List *list, String8List *to_push){
|
str8_list_concat_in_place(String8List *list, String8List *to_push)
|
||||||
if(to_push->node_count != 0){
|
{
|
||||||
if (list->last){
|
if(to_push->node_count != 0)
|
||||||
|
{
|
||||||
|
if(list->last)
|
||||||
|
{
|
||||||
list->node_count += to_push->node_count;
|
list->node_count += to_push->node_count;
|
||||||
list->total_size += to_push->total_size;
|
list->total_size += to_push->total_size;
|
||||||
list->last->next = to_push->first;
|
list->last->next = to_push->first;
|
||||||
list->last = to_push->last;
|
list->last = to_push->last;
|
||||||
}
|
}
|
||||||
else{
|
else
|
||||||
|
{
|
||||||
*list = *to_push;
|
*list = *to_push;
|
||||||
}
|
}
|
||||||
MemoryZeroStruct(to_push);
|
MemoryZeroStruct(to_push);
|
||||||
@@ -1048,7 +1070,8 @@ str8_list_push_aligner(Arena *arena, String8List *list, U64 min, U64 align){
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal String8Node*
|
internal String8Node*
|
||||||
str8_list_pushf(Arena *arena, String8List *list, char *fmt, ...){
|
str8_list_pushf(Arena *arena, String8List *list, char *fmt, ...)
|
||||||
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
String8 string = push_str8fv(arena, fmt, args);
|
String8 string = push_str8fv(arena, fmt, args);
|
||||||
@@ -1058,7 +1081,8 @@ str8_list_pushf(Arena *arena, String8List *list, char *fmt, ...){
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal String8Node*
|
internal String8Node*
|
||||||
str8_list_push_frontf(Arena *arena, String8List *list, char *fmt, ...){
|
str8_list_push_frontf(Arena *arena, String8List *list, char *fmt, ...)
|
||||||
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
String8 string = push_str8fv(arena, fmt, args);
|
String8 string = push_str8fv(arena, fmt, args);
|
||||||
@@ -1068,11 +1092,11 @@ str8_list_push_frontf(Arena *arena, String8List *list, char *fmt, ...){
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal String8List
|
internal String8List
|
||||||
str8_list_copy(Arena *arena, String8List *list){
|
str8_list_copy(Arena *arena, String8List *list)
|
||||||
|
{
|
||||||
String8List result = {0};
|
String8List result = {0};
|
||||||
for (String8Node *node = list->first;
|
for(String8Node *node = list->first; node != 0; node = node->next)
|
||||||
node != 0;
|
{
|
||||||
node = node->next){
|
|
||||||
String8Node *new_node = push_array_no_zero(arena, String8Node, 1);
|
String8Node *new_node = push_array_no_zero(arena, String8Node, 1);
|
||||||
String8 new_string = push_str8_copy(arena, node->string);
|
String8 new_string = push_str8_copy(arena, node->string);
|
||||||
str8_list_push_node_set_string(&result, new_node, new_string);
|
str8_list_push_node_set_string(&result, new_node, new_string);
|
||||||
@@ -1080,103 +1104,89 @@ str8_list_copy(Arena *arena, String8List *list){
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
//~ rjf: String Splitting & Joining
|
||||||
|
|
||||||
internal String8List
|
internal String8List
|
||||||
str8_split(Arena *arena, String8 string, U8 *split_chars, U64 split_char_count, StringSplitFlags flags){
|
str8_split(Arena *arena, String8 string, U8 *split_chars, U64 split_char_count, StringSplitFlags flags)
|
||||||
|
{
|
||||||
String8List list = {0};
|
String8List list = {0};
|
||||||
|
|
||||||
B32 keep_empties = (flags & StringSplitFlag_KeepEmpties);
|
B32 keep_empties = (flags & StringSplitFlag_KeepEmpties);
|
||||||
|
|
||||||
U8 *ptr = string.str;
|
U8 *ptr = string.str;
|
||||||
U8 *opl = string.str + string.size;
|
U8 *opl = string.str + string.size;
|
||||||
for (;ptr < opl;){
|
for(;ptr < opl;)
|
||||||
|
{
|
||||||
U8 *first = ptr;
|
U8 *first = ptr;
|
||||||
for (;ptr < opl; ptr += 1){
|
for(;ptr < opl; ptr += 1)
|
||||||
|
{
|
||||||
U8 c = *ptr;
|
U8 c = *ptr;
|
||||||
B32 is_split = 0;
|
B32 is_split = 0;
|
||||||
for (U64 i = 0; i < split_char_count; i += 1){
|
for(U64 i = 0; i < split_char_count; i += 1)
|
||||||
if (split_chars[i] == c){
|
{
|
||||||
|
if(split_chars[i] == c)
|
||||||
|
{
|
||||||
is_split = 1;
|
is_split = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (is_split){
|
if(is_split)
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String8 string = str8_range(first, ptr);
|
String8 string = str8_range(first, ptr);
|
||||||
if (keep_empties || string.size > 0){
|
if(keep_empties || string.size > 0)
|
||||||
|
{
|
||||||
str8_list_push(arena, &list, string);
|
str8_list_push(arena, &list, string);
|
||||||
}
|
}
|
||||||
ptr += 1;
|
ptr += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal String8List
|
|
||||||
str8_split_by_string_chars(Arena *arena, String8 string, String8 split_chars, StringSplitFlags flags){
|
|
||||||
String8List list = str8_split(arena, string, split_chars.str, split_chars.size, flags);
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal String8List
|
internal String8List
|
||||||
str8_list_split_by_string_chars(Arena *arena, String8List list, String8 split_chars, StringSplitFlags flags){
|
str8_split_by_string_chars(Arena *arena, String8 string, String8 split_chars, StringSplitFlags flags)
|
||||||
String8List result = {0};
|
{
|
||||||
for (String8Node *node = list.first; node != 0; node = node->next){
|
String8List list = str8_split(arena, string, split_chars.str, split_chars.size, flags);
|
||||||
String8List split = str8_split_by_string_chars(arena, node->string, split_chars, flags);
|
return list;
|
||||||
str8_list_concat_in_place(&result, &split);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal String8
|
internal String8
|
||||||
str8_list_join(Arena *arena, String8List *list, StringJoin *optional_params){
|
str8_list_join(Arena *arena, String8List *list, StringJoin *optional_params)
|
||||||
|
{
|
||||||
StringJoin join = {0};
|
StringJoin join = {0};
|
||||||
if (optional_params != 0){
|
if(optional_params != 0)
|
||||||
|
{
|
||||||
MemoryCopyStruct(&join, optional_params);
|
MemoryCopyStruct(&join, optional_params);
|
||||||
}
|
}
|
||||||
|
|
||||||
U64 sep_count = 0;
|
U64 sep_count = 0;
|
||||||
if (list->node_count > 0){
|
if(list->node_count > 0)
|
||||||
|
{
|
||||||
sep_count = list->node_count - 1;
|
sep_count = list->node_count - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
String8 result;
|
String8 result;
|
||||||
result.size = join.pre.size + join.post.size + sep_count*join.sep.size + list->total_size;
|
result.size = join.pre.size + join.post.size + sep_count*join.sep.size + list->total_size;
|
||||||
U8 *ptr = result.str = push_array_no_zero(arena, U8, result.size + 1);
|
U8 *ptr = result.str = push_array_no_zero(arena, U8, result.size + 1);
|
||||||
|
|
||||||
MemoryCopy(ptr, join.pre.str, join.pre.size);
|
MemoryCopy(ptr, join.pre.str, join.pre.size);
|
||||||
ptr += join.pre.size;
|
ptr += join.pre.size;
|
||||||
for(String8Node *node = list->first;
|
for(String8Node *node = list->first;
|
||||||
node != 0;
|
node != 0;
|
||||||
node = node->next){
|
node = node->next)
|
||||||
|
{
|
||||||
MemoryCopy(ptr, node->string.str, node->string.size);
|
MemoryCopy(ptr, node->string.str, node->string.size);
|
||||||
ptr += node->string.size;
|
ptr += node->string.size;
|
||||||
if (node->next != 0){
|
if(node->next != 0)
|
||||||
|
{
|
||||||
MemoryCopy(ptr, join.sep.str, join.sep.size);
|
MemoryCopy(ptr, join.sep.str, join.sep.size);
|
||||||
ptr += join.sep.size;
|
ptr += join.sep.size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MemoryCopy(ptr, join.post.str, join.post.size);
|
MemoryCopy(ptr, join.post.str, join.post.size);
|
||||||
ptr += join.post.size;
|
ptr += join.post.size;
|
||||||
|
|
||||||
*ptr = 0;
|
*ptr = 0;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
|
||||||
str8_list_from_flags(Arena *arena, String8List *list,
|
|
||||||
U32 flags, String8 *flag_string_table, U32 flag_string_count){
|
|
||||||
for (U32 i = 0; i < flag_string_count; i += 1){
|
|
||||||
U32 flag = (1 << i);
|
|
||||||
if (flags & flag){
|
|
||||||
str8_list_push(arena, list, flag_string_table[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Basic Data Structure Stringification Helpers
|
//~ rjf: Basic Data Structure Stringification Helpers
|
||||||
|
|
||||||
@@ -1281,7 +1291,7 @@ str8_from_version(Arena *arena, U64 version)
|
|||||||
U64 version_major = MajorFromVersion(version);
|
U64 version_major = MajorFromVersion(version);
|
||||||
U64 version_minor = MinorFromVersion(version);
|
U64 version_minor = MinorFromVersion(version);
|
||||||
U64 version_patch = PatchFromVersion(version);
|
U64 version_patch = PatchFromVersion(version);
|
||||||
String8 result = push_str8f(arena, "%I64d.%I64d.%I64d", version_major, version_minor, version_patch);
|
String8 result = str8f(arena, "%I64d.%I64d.%I64d", version_major, version_minor, version_patch);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1401,6 +1411,12 @@ internal void
|
|||||||
str8_path_list_resolve_dots_in_place(String8List *path, PathStyle style)
|
str8_path_list_resolve_dots_in_place(String8List *path, PathStyle style)
|
||||||
{
|
{
|
||||||
Temp scratch = scratch_begin(0, 0);
|
Temp scratch = scratch_begin(0, 0);
|
||||||
|
typedef struct String8MetaNode String8MetaNode;
|
||||||
|
struct String8MetaNode
|
||||||
|
{
|
||||||
|
String8MetaNode *next;
|
||||||
|
String8Node *node;
|
||||||
|
};
|
||||||
String8MetaNode *stack = 0;
|
String8MetaNode *stack = 0;
|
||||||
String8MetaNode *free_meta_node = 0;
|
String8MetaNode *free_meta_node = 0;
|
||||||
String8Node *first = path->first;
|
String8Node *first = path->first;
|
||||||
@@ -1773,19 +1789,21 @@ internal String8
|
|||||||
path_replace_file_extension(Arena *arena, String8 file_name, String8 ext)
|
path_replace_file_extension(Arena *arena, String8 file_name, String8 ext)
|
||||||
{
|
{
|
||||||
String8 file_name_no_ext = str8_chop_last_dot(file_name);
|
String8 file_name_no_ext = str8_chop_last_dot(file_name);
|
||||||
String8 result = push_str8f(arena, "%S.%S", file_name_no_ext, ext);
|
String8 result = str8f(arena, "%S.%S", file_name_no_ext, ext);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: UTF-8 & UTF-16 Decoding/Encoding
|
//~ rjf: UTF-8 & UTF-16 Decoding/Encoding
|
||||||
|
|
||||||
read_only global U8 utf8_class[32] = {
|
read_only global U8 utf8_class[32] =
|
||||||
|
{
|
||||||
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,2,2,2,2,3,3,4,5,
|
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,2,2,2,2,3,3,4,5,
|
||||||
};
|
};
|
||||||
|
|
||||||
internal UnicodeDecode
|
internal UnicodeDecode
|
||||||
utf8_decode(U8 *str, U64 max){
|
utf8_decode(U8 *str, U64 max)
|
||||||
|
{
|
||||||
UnicodeDecode result = {1, max_U32};
|
UnicodeDecode result = {1, max_U32};
|
||||||
U8 byte = str[0];
|
U8 byte = str[0];
|
||||||
U8 byte_class = utf8_class[byte >> 3];
|
U8 byte_class = utf8_class[byte >> 3];
|
||||||
@@ -1845,11 +1863,13 @@ utf8_decode(U8 *str, U64 max){
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal UnicodeDecode
|
internal UnicodeDecode
|
||||||
utf16_decode(U16 *str, U64 max){
|
utf16_decode(U16 *str, U64 max)
|
||||||
|
{
|
||||||
UnicodeDecode result = {1, max_U32};
|
UnicodeDecode result = {1, max_U32};
|
||||||
result.codepoint = str[0];
|
result.codepoint = str[0];
|
||||||
result.inc = 1;
|
result.inc = 1;
|
||||||
if (max > 1 && 0xD800 <= str[0] && str[0] < 0xDC00 && 0xDC00 <= str[1] && str[1] < 0xE000){
|
if(max > 1 && 0xD800 <= str[0] && str[0] < 0xDC00 && 0xDC00 <= str[1] && str[1] < 0xE000)
|
||||||
|
{
|
||||||
result.codepoint = ((str[0] - 0xD800) << 10) | ((str[1] - 0xDC00) + 0x10000);
|
result.codepoint = ((str[0] - 0xD800) << 10) | ((str[1] - 0xDC00) + 0x10000);
|
||||||
result.inc = 2;
|
result.inc = 2;
|
||||||
}
|
}
|
||||||
@@ -1857,58 +1877,63 @@ utf16_decode(U16 *str, U64 max){
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal U32
|
internal U32
|
||||||
utf8_encode(U8 *str, U32 codepoint){
|
utf8_encode(U8 *str, U32 codepoint)
|
||||||
|
{
|
||||||
U32 inc = 0;
|
U32 inc = 0;
|
||||||
if (codepoint <= 0x7F){
|
if(codepoint <= 0x7F)
|
||||||
|
{
|
||||||
str[0] = (U8)codepoint;
|
str[0] = (U8)codepoint;
|
||||||
inc = 1;
|
inc = 1;
|
||||||
}
|
}
|
||||||
else if (codepoint <= 0x7FF){
|
else if(codepoint <= 0x7FF)
|
||||||
|
{
|
||||||
str[0] = (bitmask2 << 6) | ((codepoint >> 6) & bitmask5);
|
str[0] = (bitmask2 << 6) | ((codepoint >> 6) & bitmask5);
|
||||||
str[1] = bit8 | (codepoint & bitmask6);
|
str[1] = bit8 | (codepoint & bitmask6);
|
||||||
inc = 2;
|
inc = 2;
|
||||||
}
|
}
|
||||||
else if (codepoint <= 0xFFFF){
|
else if(codepoint <= 0xFFFF)
|
||||||
|
{
|
||||||
str[0] = (bitmask3 << 5) | ((codepoint >> 12) & bitmask4);
|
str[0] = (bitmask3 << 5) | ((codepoint >> 12) & bitmask4);
|
||||||
str[1] = bit8 | ((codepoint >> 6) & bitmask6);
|
str[1] = bit8 | ((codepoint >> 6) & bitmask6);
|
||||||
str[2] = bit8 | ( codepoint & bitmask6);
|
str[2] = bit8 | ( codepoint & bitmask6);
|
||||||
inc = 3;
|
inc = 3;
|
||||||
}
|
}
|
||||||
else if (codepoint <= 0x10FFFF){
|
else if(codepoint <= 0x10FFFF)
|
||||||
|
{
|
||||||
str[0] = (bitmask4 << 4) | ((codepoint >> 18) & bitmask3);
|
str[0] = (bitmask4 << 4) | ((codepoint >> 18) & bitmask3);
|
||||||
str[1] = bit8 | ((codepoint >> 12) & bitmask6);
|
str[1] = bit8 | ((codepoint >> 12) & bitmask6);
|
||||||
str[2] = bit8 | ((codepoint >> 6) & bitmask6);
|
str[2] = bit8 | ((codepoint >> 6) & bitmask6);
|
||||||
str[3] = bit8 | ( codepoint & bitmask6);
|
str[3] = bit8 | ( codepoint & bitmask6);
|
||||||
inc = 4;
|
inc = 4;
|
||||||
}
|
}
|
||||||
else{
|
else
|
||||||
|
{
|
||||||
str[0] = '?';
|
str[0] = '?';
|
||||||
inc = 1;
|
inc = 1;
|
||||||
}
|
}
|
||||||
return(inc);
|
return inc;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal U32
|
internal U32
|
||||||
utf16_encode(U16 *str, U32 codepoint){
|
utf16_encode(U16 *str, U32 codepoint)
|
||||||
|
{
|
||||||
U32 inc = 1;
|
U32 inc = 1;
|
||||||
if (codepoint == max_U32){
|
if(codepoint == max_U32)
|
||||||
|
{
|
||||||
str[0] = (U16)'?';
|
str[0] = (U16)'?';
|
||||||
}
|
}
|
||||||
else if (codepoint < 0x10000){
|
else if(codepoint < 0x10000)
|
||||||
|
{
|
||||||
str[0] = (U16)codepoint;
|
str[0] = (U16)codepoint;
|
||||||
}
|
}
|
||||||
else{
|
else
|
||||||
|
{
|
||||||
U32 v = codepoint - 0x10000;
|
U32 v = codepoint - 0x10000;
|
||||||
str[0] = safe_cast_u16(0xD800 + (v >> 10));
|
str[0] = safe_cast_u16(0xD800 + (v >> 10));
|
||||||
str[1] = safe_cast_u16(0xDC00 + (v & bitmask10));
|
str[1] = safe_cast_u16(0xDC00 + (v & bitmask10));
|
||||||
inc = 2;
|
inc = 2;
|
||||||
}
|
}
|
||||||
return(inc);
|
return inc;
|
||||||
}
|
|
||||||
|
|
||||||
internal U32
|
|
||||||
utf8_from_utf32_single(U8 *buffer, U32 character){
|
|
||||||
return(utf8_encode(buffer, character));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
@@ -2010,7 +2035,7 @@ str32_from_8(Arena *arena, String8 in)
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ String -> Enum Conversions
|
//~ rjf: Basic Types & Space Enum -> String Conversions
|
||||||
|
|
||||||
read_only global struct
|
read_only global struct
|
||||||
{
|
{
|
||||||
@@ -2028,42 +2053,45 @@ StaticAssert(ArrayCount(g_os_enum_map) == OperatingSystem_COUNT, g_os_enum_map_c
|
|||||||
internal OperatingSystem
|
internal OperatingSystem
|
||||||
operating_system_from_string(String8 string)
|
operating_system_from_string(String8 string)
|
||||||
{
|
{
|
||||||
for(U64 i = 0; i < ArrayCount(g_os_enum_map); ++i)
|
for EachElement(idx, g_os_enum_map)
|
||||||
{
|
{
|
||||||
if(str8_match(g_os_enum_map[i].string, string, StringMatchFlag_CaseInsensitive))
|
if(str8_match(g_os_enum_map[idx].string, string, StringMatchFlag_CaseInsensitive))
|
||||||
{
|
{
|
||||||
return g_os_enum_map[i].os;
|
return g_os_enum_map[idx].os;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return OperatingSystem_Null;
|
return OperatingSystem_Null;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
|
||||||
//~ rjf: Basic Types & Space Enum -> String Conversions
|
|
||||||
|
|
||||||
internal String8
|
internal String8
|
||||||
string_from_dimension(Dimension dimension){
|
string_from_dimension(Dimension dimension)
|
||||||
local_persist String8 strings[] = {
|
{
|
||||||
|
read_only local_persist String8 strings[] =
|
||||||
|
{
|
||||||
str8_lit_comp("X"),
|
str8_lit_comp("X"),
|
||||||
str8_lit_comp("Y"),
|
str8_lit_comp("Y"),
|
||||||
str8_lit_comp("Z"),
|
str8_lit_comp("Z"),
|
||||||
str8_lit_comp("W"),
|
str8_lit_comp("W"),
|
||||||
};
|
};
|
||||||
String8 result = str8_lit("error");
|
String8 result = str8_lit("error");
|
||||||
if ((U32)dimension < 4){
|
if((U32)dimension < 4)
|
||||||
|
{
|
||||||
result = strings[dimension];
|
result = strings[dimension];
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal String8
|
internal String8
|
||||||
string_from_side(Side side){
|
string_from_side(Side side)
|
||||||
local_persist String8 strings[] = {
|
{
|
||||||
|
local_persist String8 strings[] =
|
||||||
|
{
|
||||||
str8_lit_comp("Min"),
|
str8_lit_comp("Min"),
|
||||||
str8_lit_comp("Max"),
|
str8_lit_comp("Max"),
|
||||||
};
|
};
|
||||||
String8 result = str8_lit("error");
|
String8 result = str8_lit("error");
|
||||||
if ((U32)side < 2){
|
if((U32)side < 2)
|
||||||
|
{
|
||||||
result = strings[side];
|
result = strings[side];
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -2081,27 +2109,27 @@ string_from_operating_system(OperatingSystem os)
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal String8
|
internal String8
|
||||||
string_from_arch(Arch arch){
|
string_from_arch(Arch arch)
|
||||||
local_persist String8 strings[] = {
|
{
|
||||||
str8_lit_comp("Null"),
|
String8 result = {0};
|
||||||
str8_lit_comp("x64"),
|
switch(arch)
|
||||||
str8_lit_comp("x86"),
|
{
|
||||||
str8_lit_comp("arm64"),
|
case Arch_Null: {result = str8_lit("Null");}break;
|
||||||
str8_lit_comp("arm32"),
|
case Arch_x64: {result = str8_lit("x64");}break;
|
||||||
};
|
case Arch_x86: {result = str8_lit("x86");}break;
|
||||||
String8 result = str8_lit("error");
|
case Arch_arm64: {result = str8_lit("arm64");}break;
|
||||||
if (arch < Arch_COUNT){
|
case Arch_arm32: {result = str8_lit("arm32");}break;
|
||||||
result = strings[arch];
|
case Arch_COUNT:
|
||||||
|
{result = str8_lit("Invalid");}break;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
|
||||||
//~ rjf: Time Types -> String
|
|
||||||
|
|
||||||
internal String8
|
internal String8
|
||||||
string_from_week_day(WeekDay week_day){
|
string_from_week_day(WeekDay week_day)
|
||||||
local_persist String8 strings[] = {
|
{
|
||||||
|
read_only local_persist String8 strings[] =
|
||||||
|
{
|
||||||
str8_lit_comp("Sun"),
|
str8_lit_comp("Sun"),
|
||||||
str8_lit_comp("Mon"),
|
str8_lit_comp("Mon"),
|
||||||
str8_lit_comp("Tue"),
|
str8_lit_comp("Tue"),
|
||||||
@@ -2111,15 +2139,18 @@ string_from_week_day(WeekDay week_day){
|
|||||||
str8_lit_comp("Sat"),
|
str8_lit_comp("Sat"),
|
||||||
};
|
};
|
||||||
String8 result = str8_lit("Err");
|
String8 result = str8_lit("Err");
|
||||||
if ((U32)week_day < WeekDay_COUNT){
|
if((U32)week_day < WeekDay_COUNT)
|
||||||
|
{
|
||||||
result = strings[week_day];
|
result = strings[week_day];
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal String8
|
internal String8
|
||||||
string_from_month(Month month){
|
string_from_month(Month month)
|
||||||
local_persist String8 strings[] = {
|
{
|
||||||
|
read_only local_persist String8 strings[] =
|
||||||
|
{
|
||||||
str8_lit_comp("Jan"),
|
str8_lit_comp("Jan"),
|
||||||
str8_lit_comp("Feb"),
|
str8_lit_comp("Feb"),
|
||||||
str8_lit_comp("Mar"),
|
str8_lit_comp("Mar"),
|
||||||
@@ -2134,21 +2165,25 @@ string_from_month(Month month){
|
|||||||
str8_lit_comp("Dec"),
|
str8_lit_comp("Dec"),
|
||||||
};
|
};
|
||||||
String8 result = str8_lit("Err");
|
String8 result = str8_lit("Err");
|
||||||
if ((U32)month < Month_COUNT){
|
if((U32)month < Month_COUNT)
|
||||||
|
{
|
||||||
result = strings[month];
|
result = strings[month];
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal String8
|
internal String8
|
||||||
push_date_time_string(Arena *arena, DateTime *date_time){
|
string_from_date_time(Arena *arena, DateTime *date_time)
|
||||||
|
{
|
||||||
char *mon_str = (char*)string_from_month(date_time->month).str;
|
char *mon_str = (char*)string_from_month(date_time->month).str;
|
||||||
U32 adjusted_hour = date_time->hour%12;
|
U32 adjusted_hour = date_time->hour%12;
|
||||||
if (adjusted_hour == 0){
|
if(adjusted_hour == 0)
|
||||||
|
{
|
||||||
adjusted_hour = 12;
|
adjusted_hour = 12;
|
||||||
}
|
}
|
||||||
char *ampm = "am";
|
char *ampm = "am";
|
||||||
if (date_time->hour >= 12){
|
if(date_time->hour >= 12)
|
||||||
|
{
|
||||||
ampm = "pm";
|
ampm = "pm";
|
||||||
}
|
}
|
||||||
String8 result = push_str8f(arena, "%d %s %d, %02d:%02d:%02d %s",
|
String8 result = push_str8f(arena, "%d %s %d, %02d:%02d:%02d %s",
|
||||||
@@ -2158,26 +2193,33 @@ push_date_time_string(Arena *arena, DateTime *date_time){
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal String8
|
internal String8
|
||||||
push_file_name_date_time_string(Arena *arena, DateTime *date_time){
|
string_from_date_time__file_name(Arena *arena, DateTime *date_time)
|
||||||
|
{
|
||||||
char *mon_str = (char*)string_from_month(date_time->month).str;
|
char *mon_str = (char*)string_from_month(date_time->month).str;
|
||||||
String8 result = push_str8f(arena, "%d-%s-%0d--%02d-%02d-%02d",
|
String8 result = str8f(arena, "%d-%s-%0d--%02d-%02d-%02d",
|
||||||
date_time->year, mon_str, date_time->day,
|
date_time->year, mon_str, date_time->day,
|
||||||
date_time->hour, date_time->min, date_time->sec);
|
date_time->hour, date_time->min, date_time->sec);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal String8
|
internal String8
|
||||||
string_from_elapsed_time(Arena *arena, DateTime dt){
|
string_from_elapsed_time(Arena *arena, DateTime dt)
|
||||||
|
{
|
||||||
Temp scratch = scratch_begin(&arena, 1);
|
Temp scratch = scratch_begin(&arena, 1);
|
||||||
String8List list = {0};
|
String8List list = {0};
|
||||||
if (dt.year){
|
if(dt.year)
|
||||||
|
{
|
||||||
str8_list_pushf(scratch.arena, &list, "%dy", dt.year);
|
str8_list_pushf(scratch.arena, &list, "%dy", dt.year);
|
||||||
str8_list_pushf(scratch.arena, &list, "%um", dt.mon);
|
str8_list_pushf(scratch.arena, &list, "%um", dt.mon);
|
||||||
str8_list_pushf(scratch.arena, &list, "%ud", dt.day);
|
str8_list_pushf(scratch.arena, &list, "%ud", dt.day);
|
||||||
} else if (dt.mon){
|
}
|
||||||
|
else if(dt.mon)
|
||||||
|
{
|
||||||
str8_list_pushf(scratch.arena, &list, "%um", dt.mon);
|
str8_list_pushf(scratch.arena, &list, "%um", dt.mon);
|
||||||
str8_list_pushf(scratch.arena, &list, "%ud", dt.day);
|
str8_list_pushf(scratch.arena, &list, "%ud", dt.day);
|
||||||
} else if (dt.day){
|
}
|
||||||
|
else if (dt.day)
|
||||||
|
{
|
||||||
str8_list_pushf(scratch.arena, &list, "%ud", dt.day);
|
str8_list_pushf(scratch.arena, &list, "%ud", dt.day);
|
||||||
}
|
}
|
||||||
str8_list_pushf(scratch.arena, &list, "%u:%u:%u:%u ms", dt.hour, dt.min, dt.sec, dt.msec);
|
str8_list_pushf(scratch.arena, &list, "%u:%u:%u:%u ms", dt.hour, dt.min, dt.sec, dt.msec);
|
||||||
@@ -2188,12 +2230,12 @@ string_from_elapsed_time(Arena *arena, DateTime dt){
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ Globally UNique Ids
|
//~ rjf: String <-> Globally Unique IDs
|
||||||
|
|
||||||
internal String8
|
internal String8
|
||||||
string_from_guid(Arena *arena, Guid guid)
|
string_from_guid(Arena *arena, Guid guid)
|
||||||
{
|
{
|
||||||
String8 result = push_str8f(arena, "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
|
String8 result = str8f(arena, "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
|
||||||
guid.data1,
|
guid.data1,
|
||||||
guid.data2,
|
guid.data2,
|
||||||
guid.data3,
|
guid.data3,
|
||||||
@@ -2458,7 +2500,7 @@ wrapped_lines_from_string(Arena *arena, String8 string, U64 first_line_max_width
|
|||||||
internal String8
|
internal String8
|
||||||
hex_string_from_rgba_4f32(Arena *arena, Vec4F32 rgba)
|
hex_string_from_rgba_4f32(Arena *arena, Vec4F32 rgba)
|
||||||
{
|
{
|
||||||
String8 hex_string = push_str8f(arena, "%02x%02x%02x%02x", (U8)(rgba.x*255.f), (U8)(rgba.y*255.f), (U8)(rgba.z*255.f), (U8)(rgba.w*255.f));
|
String8 hex_string = str8f(arena, "%02x%02x%02x%02x", (U8)(rgba.x*255.f), (U8)(rgba.y*255.f), (U8)(rgba.z*255.f), (U8)(rgba.w*255.f));
|
||||||
return hex_string;
|
return hex_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2471,7 +2513,7 @@ rgba_from_hex_string_4f32(String8 hex_string)
|
|||||||
{
|
{
|
||||||
if(char_is_digit(hex_string.str[idx], 16))
|
if(char_is_digit(hex_string.str[idx], 16))
|
||||||
{
|
{
|
||||||
byte_text[byte_text_idx] = char_to_lower(hex_string.str[idx]);
|
byte_text[byte_text_idx] = lower_from_char(hex_string.str[idx]);
|
||||||
byte_text_idx += 1;
|
byte_text_idx += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2774,8 +2816,8 @@ str8_compar(String8 a, String8 b, B32 ignore_case)
|
|||||||
U64 size = Min(a.size, b.size);
|
U64 size = Min(a.size, b.size);
|
||||||
if (ignore_case) {
|
if (ignore_case) {
|
||||||
for (U64 i = 0; i < size; ++i) {
|
for (U64 i = 0; i < size; ++i) {
|
||||||
U8 la = char_to_lower(a.str[i]);
|
U8 la = lower_from_char(a.str[i]);
|
||||||
U8 lb = char_to_lower(b.str[i]);
|
U8 lb = lower_from_char(b.str[i]);
|
||||||
if (la < lb) {
|
if (la < lb) {
|
||||||
cmp = -1;
|
cmp = -1;
|
||||||
break;
|
break;
|
||||||
|
|||||||
+9
-26
@@ -38,13 +38,6 @@ struct String8Node
|
|||||||
String8 string;
|
String8 string;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct String8MetaNode String8MetaNode;
|
|
||||||
struct String8MetaNode
|
|
||||||
{
|
|
||||||
String8MetaNode *next;
|
|
||||||
String8Node *node;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct String8List String8List;
|
typedef struct String8List String8List;
|
||||||
struct String8List
|
struct String8List
|
||||||
{
|
{
|
||||||
@@ -59,6 +52,7 @@ struct String8Array
|
|||||||
{
|
{
|
||||||
String8 *v;
|
String8 *v;
|
||||||
U64 count;
|
U64 count;
|
||||||
|
U64 total_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
@@ -152,9 +146,9 @@ internal B32 char_is_lower(U8 c);
|
|||||||
internal B32 char_is_alpha(U8 c);
|
internal B32 char_is_alpha(U8 c);
|
||||||
internal B32 char_is_slash(U8 c);
|
internal B32 char_is_slash(U8 c);
|
||||||
internal B32 char_is_digit(U8 c, U32 base);
|
internal B32 char_is_digit(U8 c, U32 base);
|
||||||
internal U8 char_to_lower(U8 c);
|
internal U8 lower_from_char(U8 c);
|
||||||
internal U8 char_to_upper(U8 c);
|
internal U8 upper_from_char(U8 c);
|
||||||
internal U8 char_to_correct_slash(U8 c);
|
internal U8 correct_slash_from_char(U8 c);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: C-String Measurement
|
//~ rjf: C-String Measurement
|
||||||
@@ -280,9 +274,7 @@ internal String8List str8_list_copy(Arena *arena, String8List *list);
|
|||||||
|
|
||||||
internal String8List str8_split(Arena *arena, String8 string, U8 *split_chars, U64 split_char_count, StringSplitFlags flags);
|
internal String8List str8_split(Arena *arena, String8 string, U8 *split_chars, U64 split_char_count, StringSplitFlags flags);
|
||||||
internal String8List str8_split_by_string_chars(Arena *arena, String8 string, String8 split_chars, StringSplitFlags flags);
|
internal String8List str8_split_by_string_chars(Arena *arena, String8 string, String8 split_chars, StringSplitFlags flags);
|
||||||
internal String8List str8_list_split_by_string_chars(Arena *arena, String8List list, String8 split_chars, StringSplitFlags flags);
|
|
||||||
internal String8 str8_list_join(Arena *arena, String8List *list, StringJoin *optional_params);
|
internal String8 str8_list_join(Arena *arena, String8List *list, StringJoin *optional_params);
|
||||||
internal void str8_list_from_flags(Arena *arena, String8List *list, U32 flags, String8 *flag_string_table, U32 flag_string_count);
|
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Basic Data Stringification Helpers
|
//~ rjf: Basic Data Stringification Helpers
|
||||||
@@ -298,7 +290,7 @@ internal String8Array str8_array_reserve(Arena *arena, U64 count);
|
|||||||
internal String8Array str8_array_copy(Arena *arena, String8Array array);
|
internal String8Array str8_array_copy(Arena *arena, String8Array array);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: String Version Helpers
|
//~ rjf: String <-> Version Helpers
|
||||||
|
|
||||||
internal U64 version_from_str8(String8 string);
|
internal U64 version_from_str8(String8 string);
|
||||||
internal String8 str8_from_version(Arena *arena, U64 version);
|
internal String8 str8_from_version(Arena *arena, U64 version);
|
||||||
@@ -362,7 +354,6 @@ internal UnicodeDecode utf8_decode(U8 *str, U64 max);
|
|||||||
internal UnicodeDecode utf16_decode(U16 *str, U64 max);
|
internal UnicodeDecode utf16_decode(U16 *str, U64 max);
|
||||||
internal U32 utf8_encode(U8 *str, U32 codepoint);
|
internal U32 utf8_encode(U8 *str, U32 codepoint);
|
||||||
internal U32 utf16_encode(U16 *str, U32 codepoint);
|
internal U32 utf16_encode(U16 *str, U32 codepoint);
|
||||||
internal U32 utf8_from_utf32_single(U8 *buffer, U32 character);
|
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Unicode String Conversions
|
//~ rjf: Unicode String Conversions
|
||||||
@@ -373,29 +364,21 @@ internal String8 str8_from_32(Arena *arena, String32 in);
|
|||||||
internal String32 str32_from_8(Arena *arena, String8 in);
|
internal String32 str32_from_8(Arena *arena, String8 in);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ String -> Enum Conversions
|
//~ rjf: Basic Types & Space Enum <-> String Conversions
|
||||||
|
|
||||||
internal OperatingSystem operating_system_from_string(String8 string);
|
internal OperatingSystem operating_system_from_string(String8 string);
|
||||||
|
|
||||||
////////////////////////////////
|
|
||||||
//~ rjf: Basic Types & Space Enum -> String Conversions
|
|
||||||
|
|
||||||
internal String8 string_from_dimension(Dimension dimension);
|
internal String8 string_from_dimension(Dimension dimension);
|
||||||
internal String8 string_from_side(Side side);
|
internal String8 string_from_side(Side side);
|
||||||
internal String8 string_from_operating_system(OperatingSystem os);
|
internal String8 string_from_operating_system(OperatingSystem os);
|
||||||
internal String8 string_from_arch(Arch arch);
|
internal String8 string_from_arch(Arch arch);
|
||||||
|
|
||||||
////////////////////////////////
|
|
||||||
//~ rjf: Time Types -> String
|
|
||||||
|
|
||||||
internal String8 string_from_week_day(WeekDay week_day);
|
internal String8 string_from_week_day(WeekDay week_day);
|
||||||
internal String8 string_from_month(Month month);
|
internal String8 string_from_month(Month month);
|
||||||
internal String8 push_date_time_string(Arena *arena, DateTime *date_time);
|
internal String8 string_from_date_time(Arena *arena, DateTime *date_time);
|
||||||
internal String8 push_file_name_date_time_string(Arena *arena, DateTime *date_time);
|
internal String8 string_from_date_time__file_name(Arena *arena, DateTime *date_time);
|
||||||
internal String8 string_from_elapsed_time(Arena *arena, DateTime dt);
|
internal String8 string_from_elapsed_time(Arena *arena, DateTime dt);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ Globally Unique Ids
|
//~ rjf: String <-> Globally Unique IDs
|
||||||
|
|
||||||
internal String8 string_from_guid(Arena *arena, Guid guid);
|
internal String8 string_from_guid(Arena *arena, Guid guid);
|
||||||
internal B32 try_guid_from_string(String8 string, Guid *guid_out);
|
internal B32 try_guid_from_string(String8 string, Guid *guid_out);
|
||||||
|
|||||||
+1
-1
@@ -472,7 +472,7 @@ coff_string_from_time_stamp(Arena *arena, COFF_TimeStamp time_stamp)
|
|||||||
result = str8_lit("-1");
|
result = str8_lit("-1");
|
||||||
} else {
|
} else {
|
||||||
DateTime dt = date_time_from_unix_time(time_stamp);
|
DateTime dt = date_time_from_unix_time(time_stamp);
|
||||||
result = push_date_time_string(arena, &dt);
|
result = string_from_date_time(arena, &dt);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,8 @@ coff_obj_writer_serialize(Arena *arena, COFF_ObjWriter *obj_writer)
|
|||||||
// long name
|
// long name
|
||||||
if (s->name.size > sizeof(name.short_name)) {
|
if (s->name.size > sizeof(name.short_name)) {
|
||||||
U64 string_table_offset = string_table.total_size;
|
U64 string_table_offset = string_table.total_size;
|
||||||
str8_list_push_cstr(scratch.arena, &string_table, s->name);
|
str8_list_push(scratch.arena, &string.table, s->name);
|
||||||
|
str8_list_push(scratch.arena, &string.table, str8_lit("\0"));
|
||||||
|
|
||||||
name.long_name.zeroes = 0;
|
name.long_name.zeroes = 0;
|
||||||
name.long_name.string_table_offset = safe_cast_u32(string_table_offset);
|
name.long_name.string_table_offset = safe_cast_u32(string_table_offset);
|
||||||
|
|||||||
@@ -3991,8 +3991,8 @@ ctrl_thread__append_resolved_module_user_bp_traps(Arena *arena, CTRL_EvalScope *
|
|||||||
String8 filename_normalized = push_str8_copy(scratch.arena, filename);
|
String8 filename_normalized = push_str8_copy(scratch.arena, filename);
|
||||||
for(U64 idx = 0; idx < filename_normalized.size; idx += 1)
|
for(U64 idx = 0; idx < filename_normalized.size; idx += 1)
|
||||||
{
|
{
|
||||||
filename_normalized.str[idx] = char_to_lower(filename_normalized.str[idx]);
|
filename_normalized.str[idx] = lower_from_char(filename_normalized.str[idx]);
|
||||||
filename_normalized.str[idx] = char_to_correct_slash(filename_normalized.str[idx]);
|
filename_normalized.str[idx] = correct_slash_from_char(filename_normalized.str[idx]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// rjf: filename -> src_id
|
// rjf: filename -> src_id
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ d_hash_from_seed_string__case_insensitive(U64 seed, String8 string)
|
|||||||
U64 result = seed;
|
U64 result = seed;
|
||||||
for(U64 i = 0; i < string.size; i += 1)
|
for(U64 i = 0; i < string.size; i += 1)
|
||||||
{
|
{
|
||||||
result = ((result << 5) + result) + char_to_lower(string.str[i]);
|
result = ((result << 5) + result) + lower_from_char(string.str[i]);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@ di_hash_from_seed_string(U64 seed, String8 string, StringMatchFlags match_flags)
|
|||||||
U64 result = seed;
|
U64 result = seed;
|
||||||
for(U64 i = 0; i < string.size; i += 1)
|
for(U64 i = 0; i < string.size; i += 1)
|
||||||
{
|
{
|
||||||
result = ((result << 5) + result) + ((match_flags & StringMatchFlag_CaseInsensitive) ? char_to_lower(string.str[i]) : string.str[i]);
|
result = ((result << 5) + result) + ((match_flags & StringMatchFlag_CaseInsensitive) ? lower_from_char(string.str[i]) : string.str[i]);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-7
@@ -35,13 +35,9 @@ internal String8List
|
|||||||
os_string_list_from_modifiers(Arena *arena, OS_Modifiers modifiers)
|
os_string_list_from_modifiers(Arena *arena, OS_Modifiers modifiers)
|
||||||
{
|
{
|
||||||
String8List result = {0};
|
String8List result = {0};
|
||||||
String8 modifier_strs[] =
|
if(modifiers & OS_Modifier_Ctrl) { str8_list_push(arena, &result, str8_lit("Ctrl")); }
|
||||||
{
|
if(modifiers & OS_Modifier_Shift) { str8_list_push(arena, &result, str8_lit("Shift")); }
|
||||||
str8_lit("Ctrl"),
|
if(modifiers & OS_Modifier_Alt) { str8_list_push(arena, &result, str8_lit("Alt")); }
|
||||||
str8_lit("Shift"),
|
|
||||||
str8_lit("Alt"),
|
|
||||||
};
|
|
||||||
str8_list_from_flags(arena, &result, modifiers, modifier_strs, ArrayCount(modifier_strs));
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,481 +0,0 @@
|
|||||||
internal String8
|
|
||||||
rc_data_from_file_path(Arena *arena, String8 path)
|
|
||||||
{
|
|
||||||
String8 data = os_data_from_file_path(arena, path);
|
|
||||||
if (data.size == 0) {
|
|
||||||
fprintf(stderr, "error: unable to read file %.*s\n", str8_varg(path));
|
|
||||||
os_abort(1);
|
|
||||||
}
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal RC_Context
|
|
||||||
rc_context_from_cmd_line(Arena *arena, CmdLine *cmdl)
|
|
||||||
{
|
|
||||||
Temp scratch = scratch_begin(&arena, 1);
|
|
||||||
|
|
||||||
if (cmdl->inputs.node_count > 2) {
|
|
||||||
fprintf(stderr, "error: too many input files on the command line.\n");
|
|
||||||
os_abort(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
B32 is_pe_present = 0;
|
|
||||||
B32 is_pdb_present = 0;
|
|
||||||
B32 is_elf_present = 0;
|
|
||||||
B32 is_elf_debug_present = 0;
|
|
||||||
String8 pe_name = {0};
|
|
||||||
String8 pe_data = {0};
|
|
||||||
String8 pdb_name = {0};
|
|
||||||
String8 pdb_data = {0};
|
|
||||||
String8 elf_name = {0};
|
|
||||||
String8 elf_data = {0};
|
|
||||||
String8 elf_debug_name = {0};
|
|
||||||
String8 elf_debug_data = {0};
|
|
||||||
|
|
||||||
//
|
|
||||||
// Set typed inputs
|
|
||||||
//
|
|
||||||
if (cmd_line_has_flag(cmdl, str8_lit("pe"))) {
|
|
||||||
pe_name = cmd_line_string(cmdl, str8_lit("pe"));
|
|
||||||
pe_data = rc_data_from_file_path(arena, pe_name);
|
|
||||||
if (!pe_check_magic(pe_data)) {
|
|
||||||
fprintf(stderr, "error: -pe:%.*s is not of PE format\n", str8_varg(pe_name));
|
|
||||||
os_abort(1);
|
|
||||||
}
|
|
||||||
is_pe_present = 1;
|
|
||||||
}
|
|
||||||
if (cmd_line_has_flag(cmdl, str8_lit("pdb"))) {
|
|
||||||
pdb_name = cmd_line_string(cmdl, str8_lit("pdb"));
|
|
||||||
pdb_data = rc_data_from_file_path(arena, pdb_name);
|
|
||||||
if (!msf_check_magic_20(pdb_data) && !msf_check_magic_70(pdb_data)) {
|
|
||||||
fprintf(stderr, "error: -pdb:%.*s is not of PDB format\n", str8_varg(pdb_name));
|
|
||||||
os_abort(1);
|
|
||||||
}
|
|
||||||
is_pdb_present = 1;
|
|
||||||
}
|
|
||||||
if (cmd_line_has_flag(cmdl, str8_lit("elf"))) {
|
|
||||||
elf_name = cmd_line_string(cmdl, str8_lit("elf"));
|
|
||||||
elf_data = rc_data_from_file_path(arena, elf_name);
|
|
||||||
if (!elf_check_magic(elf_data)) {
|
|
||||||
fprintf(stderr, "error: -elf:%.*s is not of ELF format\n", str8_varg(elf_name));
|
|
||||||
os_abort(1);
|
|
||||||
}
|
|
||||||
is_elf_present = 1;
|
|
||||||
}
|
|
||||||
if (cmd_line_has_flag(cmdl, str8_lit("elf_debug"))) {
|
|
||||||
elf_debug_name = cmd_line_string(cmdl, str8_lit("elf_debug"));
|
|
||||||
elf_debug_data = rc_data_from_file_path(arena, elf_debug_name);
|
|
||||||
if (!elf_check_magic(elf_debug_data)) {
|
|
||||||
fprintf(stderr, "error: -elf_debug:%.*s is not of ELF format\n", str8_varg(elf_debug_name));
|
|
||||||
os_abort(1);
|
|
||||||
}
|
|
||||||
is_elf_debug_present = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Pick conversion driver
|
|
||||||
//
|
|
||||||
RC_Driver driver = RC_Driver_Null;
|
|
||||||
if (cmd_line_has_flag(cmdl, str8_lit("driver"))) {
|
|
||||||
String8 driver_name = cmd_line_string(cmdl, str8_lit("driver"));
|
|
||||||
if (str8_match(driver_name, str8_lit("dwarf"), StringMatchFlag_CaseInsensitive)) {
|
|
||||||
driver = RC_Driver_Dwarf;
|
|
||||||
} else if (str8_match(driver_name, str8_lit("pdb"), StringMatchFlag_CaseInsensitive)) {
|
|
||||||
driver = RC_Driver_Pdb;
|
|
||||||
} else {
|
|
||||||
fprintf(stderr, "error: unknown driver \"%.*s\"\n", str8_varg(driver_name));
|
|
||||||
os_abort(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Load inputs
|
|
||||||
//
|
|
||||||
for (String8Node *input_n = cmdl->inputs.first; input_n != 0; input_n = input_n->next) {
|
|
||||||
String8 input_data = os_data_from_file_path(arena, input_n->string);
|
|
||||||
|
|
||||||
if (input_data.size == 0) {
|
|
||||||
fprintf(stderr, "unable to read input %.*s\n", str8_varg(input_n->string));
|
|
||||||
os_abort(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pe_check_magic(input_data)) {
|
|
||||||
if (is_pe_present) {
|
|
||||||
fprintf(stderr, "error: too many PE files are specified on the command line\n");
|
|
||||||
fprintf(stderr, " selected: %.*s\n", str8_varg(pe_name));
|
|
||||||
fprintf(stderr, " current: %.*s\n", str8_varg(input_n->string));
|
|
||||||
os_abort(1);
|
|
||||||
}
|
|
||||||
pe_data = input_data;
|
|
||||||
pe_name = input_n->string;
|
|
||||||
is_pe_present = 1;
|
|
||||||
} else if (elf_check_magic(input_data)) {
|
|
||||||
ELF_Bin elf = elf_bin_from_data(input_data);
|
|
||||||
B32 is_dwarf_present = dw_is_dwarf_present_from_bin(input_data, &elf);
|
|
||||||
if (is_dwarf_present) {
|
|
||||||
if (is_elf_debug_present) {
|
|
||||||
fprintf(stderr, "error: ambiguous input, both ELFs have DWARF debug sections, please use --elf:<path> --elf_debug:<path> to clarify inputs.\n");
|
|
||||||
os_abort(1);
|
|
||||||
}
|
|
||||||
elf_debug_name = input_n->string;
|
|
||||||
elf_debug_data = input_data;
|
|
||||||
is_elf_debug_present = 1;
|
|
||||||
} else {
|
|
||||||
elf_name = input_n->string;
|
|
||||||
elf_data = input_data;
|
|
||||||
is_elf_present = 1;
|
|
||||||
}
|
|
||||||
} else if (msf_check_magic_20(input_data) || msf_check_magic_70(input_data)) {
|
|
||||||
if (is_pdb_present) {
|
|
||||||
fprintf(stderr, "error: too many PDB files are specified on the command line\n");
|
|
||||||
fprintf(stderr, " selected: %.*s\n", str8_varg(pdb_name));
|
|
||||||
fprintf(stderr, " current: %.*s\n", str8_varg(input_n->string));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
pdb_name = input_n->string;
|
|
||||||
pdb_data = input_data;
|
|
||||||
is_pdb_present = 1;
|
|
||||||
} else {
|
|
||||||
fprintf(stderr, "error: unknown file format %.*s\n", str8_varg(input_n->string));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Validate input combos
|
|
||||||
//
|
|
||||||
if ((is_pe_present || is_pdb_present) && (is_elf_present || is_elf_debug_present)) {
|
|
||||||
fprintf(stderr, "error: invalid combination of inputs provided, we convert only (PE|PDB) or (ELF|ELF_DEBUG) at a time.\n");
|
|
||||||
if (is_pe_present) {
|
|
||||||
fprintf(stderr, " PE: %.*s\n", str8_varg(pe_name));
|
|
||||||
}
|
|
||||||
if (is_pdb_present) {
|
|
||||||
fprintf(stderr, " PDB: %.*s\n", str8_varg(pdb_name));
|
|
||||||
}
|
|
||||||
if (is_elf_present) {
|
|
||||||
fprintf(stderr, " ELF: %.*s\n", str8_varg(elf_name));
|
|
||||||
}
|
|
||||||
if (is_elf_debug_present) {
|
|
||||||
fprintf(stderr, " ELF Debug: %.*s\n", str8_varg(elf_debug_name));
|
|
||||||
}
|
|
||||||
os_abort(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_pe_present && (is_elf_present || is_elf_debug_present)) {
|
|
||||||
fprintf(stderr, "error: command line has too many image types specified.\n");
|
|
||||||
os_abort(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ExecutableImageKind image = ExecutableImageKind_Null;
|
|
||||||
String8 image_name = {0};
|
|
||||||
String8 image_data = {0};
|
|
||||||
String8 debug_name = {0};
|
|
||||||
String8 debug_data = {0};
|
|
||||||
|
|
||||||
B32 check_guid = 0;
|
|
||||||
Guid pe_pdb_guid = {0};
|
|
||||||
|
|
||||||
B32 elf_has_debug_link = 0;
|
|
||||||
ELF_GnuDebugLink debug_link = {0};
|
|
||||||
|
|
||||||
//
|
|
||||||
// Input has PE/COFF
|
|
||||||
//
|
|
||||||
if (is_pe_present) {
|
|
||||||
image = ExecutableImageKind_CoffPe;
|
|
||||||
image_name = pe_name;
|
|
||||||
image_data = pe_data;
|
|
||||||
|
|
||||||
PE_BinInfo pe = pe_bin_info_from_data(scratch.arena, pe_data);
|
|
||||||
String8 raw_debug_dir = str8_substr(pe_data, pe.data_dir_franges[PE_DataDirectoryIndex_DEBUG]);
|
|
||||||
PE_DebugInfoList debug_dir = pe_debug_info_list_from_raw_debug_dir(scratch.arena, pe_data, raw_debug_dir);
|
|
||||||
for (PE_DebugInfoNode *debug_n = debug_dir.first; debug_n != 0; debug_n = debug_n->next) {
|
|
||||||
PE_DebugInfo *debug = &debug_n->v;
|
|
||||||
if (debug->header.type == PE_DebugDirectoryType_CODEVIEW) {
|
|
||||||
if (debug->u.codeview.magic == PE_CODEVIEW_PDB70_MAGIC) {
|
|
||||||
check_guid = 1;
|
|
||||||
pe_pdb_guid = debug->u.codeview.pdb70.header.guid;
|
|
||||||
|
|
||||||
if (!is_pdb_present) {
|
|
||||||
pdb_name = debug->u.codeview.pdb70.path;
|
|
||||||
pdb_data = rc_data_from_file_path(arena, pdb_name);
|
|
||||||
is_pdb_present = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (driver == RC_Driver_Null || driver == RC_Driver_Dwarf) {
|
|
||||||
PE_BinInfo pe = pe_bin_info_from_data(scratch.arena, pe_data);
|
|
||||||
String8 raw_section_table = str8_substr(pe_data, pe.section_table_range);
|
|
||||||
String8 string_table = str8_substr(pe_data, pe.string_table_range);
|
|
||||||
U64 section_count = raw_section_table.size / sizeof(COFF_SectionHeader);
|
|
||||||
COFF_SectionHeader *section_table = (COFF_SectionHeader *)raw_section_table.str;
|
|
||||||
if (dw_is_dwarf_present_coff_section_table(pe_data, string_table, section_count, section_table)) {
|
|
||||||
driver = RC_Driver_Dwarf;
|
|
||||||
debug_name = pe_name;
|
|
||||||
debug_data = pe_data;
|
|
||||||
goto driver_found;
|
|
||||||
} else if (driver == RC_Driver_Dwarf) {
|
|
||||||
fprintf(stderr, "error: image doesn't have DWARF debug sections.\n");
|
|
||||||
os_abort(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_elf_present || is_elf_debug_present) {
|
|
||||||
if (driver != RC_Driver_Null && driver != RC_Driver_Dwarf) {
|
|
||||||
fprintf(stderr, "error: ELF inputs are only supported when using DWARF driver.\n");
|
|
||||||
os_abort(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Load image ELF
|
|
||||||
//
|
|
||||||
ELF_Bin elf = elf_bin_from_data(elf_data);
|
|
||||||
B32 has_elf_dwarf = dw_is_dwarf_present_from_elf_bin(elf_data, &elf);
|
|
||||||
|
|
||||||
//
|
|
||||||
// ELF doesn't have debug info and no .debug was specified on command line,
|
|
||||||
// try to load .debug via debug link
|
|
||||||
//
|
|
||||||
if (is_elf_present && !is_elf_debug_present) {
|
|
||||||
elf_has_debug_link = elf_parse_debug_link(elf_data, &elf, &debug_link);
|
|
||||||
}
|
|
||||||
if (elf_has_debug_link) {
|
|
||||||
elf_debug_data = rc_data_from_file_path(arena, debug_link.path);
|
|
||||||
is_elf_debug_present = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Load .debug ELF
|
|
||||||
//
|
|
||||||
ELF_Bin elf_debug = elf_bin_from_data(elf_debug_data);
|
|
||||||
B32 has_elf_debug_dwarf = dw_is_dwarf_present_from_elf_bin(elf_debug_data, &elf_debug);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Input is image ELF and .debug ELF
|
|
||||||
//
|
|
||||||
B32 is_split_elf = is_elf_present && is_elf_debug_present && !has_elf_dwarf && has_elf_debug_dwarf;
|
|
||||||
if (is_split_elf) {
|
|
||||||
driver = RC_Driver_Dwarf;
|
|
||||||
image = ELF_HdrIs64Bit(elf.hdr.e_ident) ? ExecutableImageKind_Elf64 : ExecutableImageKind_Elf32;
|
|
||||||
image_name = elf_name;
|
|
||||||
image_data = elf_data;
|
|
||||||
debug_name = elf_debug_name;
|
|
||||||
debug_data = elf_debug_data;
|
|
||||||
goto driver_found;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Input ELF is image with debug info
|
|
||||||
//
|
|
||||||
B32 is_monolithic_elf = is_elf_present && !is_elf_debug_present && has_elf_dwarf;
|
|
||||||
if (is_monolithic_elf) {
|
|
||||||
driver = RC_Driver_Dwarf;
|
|
||||||
image = ELF_HdrIs64Bit(elf.hdr.e_ident) ? ExecutableImageKind_Elf64 : ExecutableImageKind_Elf32;
|
|
||||||
image_name = elf_name;
|
|
||||||
image_data = elf_data;
|
|
||||||
debug_name = elf_name;
|
|
||||||
debug_data = elf_data;
|
|
||||||
goto driver_found;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Input ELF is .debug
|
|
||||||
//
|
|
||||||
B32 is_debug_elf = !is_elf_present && is_elf_debug_present && has_elf_debug_dwarf;
|
|
||||||
if (is_debug_elf) {
|
|
||||||
driver = RC_Driver_Dwarf;
|
|
||||||
image = ELF_HdrIs64Bit(elf_debug.hdr.e_ident) ? ExecutableImageKind_Elf64 : ExecutableImageKind_Elf32;
|
|
||||||
debug_name = elf_debug_name;
|
|
||||||
debug_data = elf_debug_data;
|
|
||||||
goto driver_found;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Input is PDB
|
|
||||||
//
|
|
||||||
if (is_pdb_present) {
|
|
||||||
if (driver == RC_Driver_Null || driver == RC_Driver_Pdb) {
|
|
||||||
driver = RC_Driver_Pdb;
|
|
||||||
debug_name = pdb_name;
|
|
||||||
debug_data = pdb_data;
|
|
||||||
goto driver_found;
|
|
||||||
} else if (driver == RC_Driver_Dwarf) {
|
|
||||||
fprintf(stderr, "error: unable to select DWARF conversion driver because convert doesn't support PDB as input format.\n");
|
|
||||||
os_abort(1);
|
|
||||||
} else {
|
|
||||||
InvalidPath;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
driver_found:;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Handle -out param
|
|
||||||
//
|
|
||||||
String8 out_name = {0};
|
|
||||||
if (cmd_line_has_flag(cmdl, str8_lit("out"))) {
|
|
||||||
out_name = cmd_line_string(cmdl, str8_lit("out"));
|
|
||||||
if (out_name.size == 0) {
|
|
||||||
fprintf(stderr, "error: -out parameter doesn't have a value\n");
|
|
||||||
os_abort(1);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (image_name.size) {
|
|
||||||
out_name = path_replace_file_extension(arena, image_name, str8_lit("rdi"));
|
|
||||||
} else {
|
|
||||||
out_name = path_replace_file_extension(arena, debug_name, str8_lit("rdi"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// Validate driver input
|
|
||||||
//
|
|
||||||
if (driver == RC_Driver_Pdb &&
|
|
||||||
!is_pdb_present && (is_elf_present || is_elf_debug_present)) {
|
|
||||||
fprintf(stderr, "error: DWARF is an invalid input for PDB driver\n");
|
|
||||||
os_abort(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
RC_Context ctx = {0};
|
|
||||||
ctx.driver = driver;
|
|
||||||
ctx.image = image;
|
|
||||||
ctx.image_name = image_name;
|
|
||||||
ctx.image_data = image_data;
|
|
||||||
ctx.debug_name = debug_name;
|
|
||||||
ctx.debug_data = debug_data;
|
|
||||||
ctx.flags = RC_Flag_Strings|
|
|
||||||
RC_Flag_IndexRuns|
|
|
||||||
RC_Flag_BinarySections|
|
|
||||||
RC_Flag_Units|
|
|
||||||
RC_Flag_Procedures|
|
|
||||||
RC_Flag_GlobalVariables|
|
|
||||||
RC_Flag_ThreadVariables|
|
|
||||||
RC_Flag_Scopes|
|
|
||||||
RC_Flag_Locals|
|
|
||||||
RC_Flag_Types|
|
|
||||||
RC_Flag_UDTs|
|
|
||||||
RC_Flag_LineInfo|
|
|
||||||
RC_Flag_GlobalVariableNameMap|
|
|
||||||
RC_Flag_ThreadVariableNameMap|
|
|
||||||
RC_Flag_ProcedureNameMap|
|
|
||||||
RC_Flag_TypeNameMap|
|
|
||||||
RC_Flag_LinkNameProcedureNameMap|
|
|
||||||
RC_Flag_NormalSourcePathNameMap;
|
|
||||||
if (check_guid) {
|
|
||||||
ctx.flags |= RC_Flag_CheckPdbGuid;
|
|
||||||
ctx.guid = pe_pdb_guid;
|
|
||||||
}
|
|
||||||
if (elf_has_debug_link) {
|
|
||||||
ctx.flags |= RC_Flag_CheckElfChecksum;
|
|
||||||
ctx.debug_link = debug_link;
|
|
||||||
}
|
|
||||||
ctx.out_name = out_name;
|
|
||||||
|
|
||||||
scratch_end(scratch);
|
|
||||||
return ctx;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal String8List
|
|
||||||
rc_run(Arena *arena, RC_Context *rc)
|
|
||||||
{
|
|
||||||
Temp scratch = scratch_begin(&arena, 1);
|
|
||||||
|
|
||||||
ProfBegin("Convert");
|
|
||||||
RDIM_LocalState *local_state = rdim_local_init();
|
|
||||||
RDIM_BakeParams *convert2bake = 0;
|
|
||||||
switch (rc->driver) {
|
|
||||||
case RC_Driver_Null: break;
|
|
||||||
case RC_Driver_Dwarf: convert2bake = d2r_convert(scratch.arena, local_state, rc); break;
|
|
||||||
case RC_Driver_Pdb: convert2bake = p2r_convert(scratch.arena, local_state, rc); break;
|
|
||||||
}
|
|
||||||
ProfEnd();
|
|
||||||
|
|
||||||
if (rc->errors.node_count) {
|
|
||||||
NotImplemented;
|
|
||||||
}
|
|
||||||
|
|
||||||
ProfBegin("Bake");
|
|
||||||
RDIM_BakeResults bake2srlz = rdim_bake(local_state, convert2bake);
|
|
||||||
ProfEnd();
|
|
||||||
|
|
||||||
ProfBegin("Serialize Bake");
|
|
||||||
RDIM_SerializedSectionBundle srlz2file = rdim_serialized_section_bundle_from_bake_results(&bake2srlz);
|
|
||||||
ProfEnd();
|
|
||||||
|
|
||||||
RDIM_SerializedSectionBundle srlz2file_compressed = srlz2file;
|
|
||||||
if (rc->flags & RC_Flag_Compress) {
|
|
||||||
ProfBegin("Compress");
|
|
||||||
srlz2file_compressed = rdim_compress(scratch.arena, &srlz2file);
|
|
||||||
ProfEnd();
|
|
||||||
}
|
|
||||||
|
|
||||||
ProfBegin("Serialize");
|
|
||||||
String8List raw_rdi = rdim_file_blobs_from_section_bundle(scratch.arena, &srlz2file_compressed);
|
|
||||||
ProfEnd();
|
|
||||||
|
|
||||||
scratch_end(scratch);
|
|
||||||
return raw_rdi;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal String8
|
|
||||||
rc_rdi_from_cmd_line(Arena *arena, CmdLine *cmdl)
|
|
||||||
{
|
|
||||||
Temp scratch = scratch_begin(&arena, 1);
|
|
||||||
RC_Context rc = rc_context_from_cmd_line(scratch.arena, cmdl);
|
|
||||||
String8List raw_rdi = rc_run(scratch.arena, &rc);
|
|
||||||
String8 result = str8_list_join(arena, &raw_rdi, 0);
|
|
||||||
scratch_end(scratch);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void
|
|
||||||
rc_main(CmdLine *cmdl)
|
|
||||||
{
|
|
||||||
B32 do_help = (cmd_line_has_flag(cmdl, str8_lit("help")) ||
|
|
||||||
cmd_line_has_flag(cmdl, str8_lit("h")) ||
|
|
||||||
cmd_line_has_flag(cmdl, str8_lit("?")) ||
|
|
||||||
cmdl->argc == 1);
|
|
||||||
if (do_help) {
|
|
||||||
fprintf(stderr, "--- Help ---------------------------------------------------------------------\n");
|
|
||||||
fprintf(stderr, " %s\n\n", BUILD_TITLE_STRING_LITERAL);
|
|
||||||
fprintf(stderr, " Usage: radcon [Options] [Files]\n\n");
|
|
||||||
fprintf(stderr, " Options:\n");
|
|
||||||
fprintf(stderr, " -pe:<path> Path to Win32 executable image\n");
|
|
||||||
fprintf(stderr, " -pdb:<path> Path to PDB\n");
|
|
||||||
fprintf(stderr, " -elf:<path> Path to ELF\n");
|
|
||||||
fprintf(stderr, " -elf_debug:<path> Path to ELF with debug info\n");
|
|
||||||
fprintf(stderr, " -out:<path> Path at which the output RDI debug info will be written\n");
|
|
||||||
fprintf(stderr, " -driver:<PDB|DWARF> Sets converter for debug info\n");
|
|
||||||
} else {
|
|
||||||
Temp scratch = scratch_begin(0,0);
|
|
||||||
|
|
||||||
// make converter context
|
|
||||||
RC_Context rc = rc_context_from_cmd_line(scratch.arena, cmdl);
|
|
||||||
|
|
||||||
// make RDI from context
|
|
||||||
String8List raw_rdi = rc_run(scratch.arena, &rc);
|
|
||||||
|
|
||||||
// output RDI
|
|
||||||
if (rc.errors.node_count == 0) {
|
|
||||||
if (!os_write_data_list_to_file_path(rc.out_name, raw_rdi)) {
|
|
||||||
str8_list_pushf(scratch.arena, &rc.errors, "no write access to path %.*s", str8_varg(rc.out_name));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// report any errors
|
|
||||||
for (String8Node *error_n = rc.errors.first; error_n != 0; error_n = error_n->next) {
|
|
||||||
fprintf(stderr, "error: %.*s\n", str8_varg(error_n->string));
|
|
||||||
}
|
|
||||||
|
|
||||||
scratch_end(scratch);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
// Copyright (c) Epic Games Tools
|
|
||||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
|
||||||
|
|
||||||
#ifndef RADCON_H
|
|
||||||
#define RADCON_H
|
|
||||||
|
|
||||||
typedef U32 RC_Flags;
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
RC_Flag_Strings = (1 << 0),
|
|
||||||
RC_Flag_IndexRuns = (1 << 1),
|
|
||||||
RC_Flag_BinarySections = (1 << 2),
|
|
||||||
RC_Flag_Units = (1 << 3),
|
|
||||||
RC_Flag_Procedures = (1 << 4),
|
|
||||||
RC_Flag_GlobalVariables = (1 << 5),
|
|
||||||
RC_Flag_ThreadVariables = (1 << 6),
|
|
||||||
RC_Flag_Scopes = (1 << 7),
|
|
||||||
RC_Flag_Locals = (1 << 8),
|
|
||||||
RC_Flag_Types = (1 << 9),
|
|
||||||
RC_Flag_UDTs = (1 << 10),
|
|
||||||
RC_Flag_LineInfo = (1 << 11),
|
|
||||||
RC_Flag_GlobalVariableNameMap = (1 << 12),
|
|
||||||
RC_Flag_ThreadVariableNameMap = (1 << 13),
|
|
||||||
RC_Flag_ProcedureNameMap = (1 << 14),
|
|
||||||
RC_Flag_TypeNameMap = (1 << 15),
|
|
||||||
RC_Flag_LinkNameProcedureNameMap= (1 << 16),
|
|
||||||
RC_Flag_NormalSourcePathNameMap = (1 << 17),
|
|
||||||
RC_Flag_Compress = (1 << 18),
|
|
||||||
RC_Flag_StrictDwarfParse = (1 << 19),
|
|
||||||
RC_Flag_Deterministic = (1 << 20),
|
|
||||||
RC_Flag_CheckPdbGuid = (1 << 21),
|
|
||||||
RC_Flag_CheckElfChecksum = (1 << 22),
|
|
||||||
RC_Flag_All = 0xffffffff,
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
RC_Driver_Null,
|
|
||||||
RC_Driver_Dwarf,
|
|
||||||
RC_Driver_Pdb,
|
|
||||||
} RC_Driver;
|
|
||||||
|
|
||||||
typedef struct RC_Context
|
|
||||||
{
|
|
||||||
ExecutableImageKind image;
|
|
||||||
RC_Driver driver;
|
|
||||||
String8 image_name;
|
|
||||||
String8 image_data;
|
|
||||||
String8 debug_name;
|
|
||||||
String8 debug_data;
|
|
||||||
String8 out_name;
|
|
||||||
RC_Flags flags;
|
|
||||||
Guid guid;
|
|
||||||
ELF_GnuDebugLink debug_link;
|
|
||||||
String8List errors;
|
|
||||||
} RC_Context;
|
|
||||||
|
|
||||||
////////////////////////////////
|
|
||||||
|
|
||||||
internal RC_Context rc_context_from_cmd_line(Arena *arena, CmdLine *cmdl);
|
|
||||||
internal String8List rc_run(Arena *arena, RC_Context *rc);
|
|
||||||
internal String8 rc_rdi_from_cmd_line(Arena *arena, CmdLine *cmdl);
|
|
||||||
internal void rc_main(CmdLine *cmdl);
|
|
||||||
|
|
||||||
#endif // RADCON_H
|
|
||||||
|
|
||||||
@@ -1,94 +0,0 @@
|
|||||||
// Copyright (c) Epic Games Tools
|
|
||||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
|
||||||
|
|
||||||
#define BUILD_TITLE "Epic Games Tools (R) RAD Debug Info Converter"
|
|
||||||
#define BUILD_CONSOLE_INTERFACE 1
|
|
||||||
|
|
||||||
////////////////////////////////
|
|
||||||
// Third Party
|
|
||||||
|
|
||||||
#include "third_party/rad_lzb_simple/rad_lzb_simple.h"
|
|
||||||
#include "third_party/rad_lzb_simple/rad_lzb_simple.c"
|
|
||||||
#define XXH_STATIC_LINKING_ONLY
|
|
||||||
#include "third_party/xxHash/xxhash.c"
|
|
||||||
#include "third_party/xxHash/xxhash.h"
|
|
||||||
#define SINFL_IMPLEMENTATION
|
|
||||||
#include "third_party/sinfl/sinfl.h"
|
|
||||||
#include "third_party/radsort/radsort.h"
|
|
||||||
|
|
||||||
////////////////////////////////
|
|
||||||
// RDI Format Library
|
|
||||||
|
|
||||||
#include "lib_rdi_format/rdi_format.h"
|
|
||||||
#include "lib_rdi_format/rdi_format.c"
|
|
||||||
|
|
||||||
////////////////////////////////
|
|
||||||
// Headers
|
|
||||||
|
|
||||||
#include "base/base_inc.h"
|
|
||||||
#include "os/os_inc.h"
|
|
||||||
#include "async/async.h"
|
|
||||||
#include "rdi_make/rdi_make_local.h"
|
|
||||||
#include "linker/hash_table.h"
|
|
||||||
#include "coff/coff.h"
|
|
||||||
#include "coff/coff_parse.h"
|
|
||||||
#include "pe/pe.h"
|
|
||||||
#include "elf/elf.h"
|
|
||||||
#include "elf/elf_parse.h"
|
|
||||||
#include "codeview/codeview.h"
|
|
||||||
#include "codeview/codeview_parse.h"
|
|
||||||
#include "dwarf/dwarf.h"
|
|
||||||
#include "dwarf/dwarf_parse.h"
|
|
||||||
#include "dwarf/dwarf_coff.h"
|
|
||||||
#include "dwarf/dwarf_elf.h"
|
|
||||||
#include "msf/msf.h"
|
|
||||||
#include "msf/msf_parse.h"
|
|
||||||
#include "pdb/pdb.h"
|
|
||||||
#include "pdb/pdb_parse.h"
|
|
||||||
#include "pdb/pdb_stringize.h"
|
|
||||||
#include "radcon.h"
|
|
||||||
#include "radcon_coff.h"
|
|
||||||
#include "radcon_elf.h"
|
|
||||||
#include "radcon_cv.h"
|
|
||||||
#include "radcon_dwarf.h"
|
|
||||||
#include "radcon_pdb.h"
|
|
||||||
|
|
||||||
////////////////////////////////
|
|
||||||
// Implementations
|
|
||||||
|
|
||||||
#include "base/base_inc.c"
|
|
||||||
#include "os/os_inc.c"
|
|
||||||
#include "async/async.c"
|
|
||||||
#include "rdi_make/rdi_make_local.c"
|
|
||||||
#include "linker/hash_table.c"
|
|
||||||
#include "coff/coff.c"
|
|
||||||
#include "coff/coff_parse.c"
|
|
||||||
#include "pe/pe.c"
|
|
||||||
#include "elf/elf.c"
|
|
||||||
#include "elf/elf_parse.c"
|
|
||||||
#include "codeview/codeview.c"
|
|
||||||
#include "codeview/codeview_parse.c"
|
|
||||||
#include "msf/msf.c"
|
|
||||||
#include "msf/msf_parse.c"
|
|
||||||
#include "pdb/pdb.c"
|
|
||||||
#include "pdb/pdb_parse.c"
|
|
||||||
#include "pdb/pdb_stringize.c"
|
|
||||||
#include "dwarf/dwarf.c"
|
|
||||||
#include "dwarf/dwarf_parse.c"
|
|
||||||
#include "dwarf/dwarf_coff.c"
|
|
||||||
#include "dwarf/dwarf_elf.c"
|
|
||||||
#include "radcon.c"
|
|
||||||
#include "radcon_coff.c"
|
|
||||||
#include "radcon_elf.c"
|
|
||||||
#include "radcon_cv.c"
|
|
||||||
#include "radcon_dwarf.c"
|
|
||||||
#include "radcon_pdb.c"
|
|
||||||
|
|
||||||
////////////////////////////////
|
|
||||||
|
|
||||||
internal void
|
|
||||||
entry_point(CmdLine *cmdl)
|
|
||||||
{
|
|
||||||
rc_main(cmdl);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -275,7 +275,7 @@ rd_format_preamble(Arena *arena, String8List *out, String8 indent, String8 input
|
|||||||
|
|
||||||
DateTime universal_dt = os_now_universal_time();
|
DateTime universal_dt = os_now_universal_time();
|
||||||
DateTime local_dt = os_local_time_from_universal(&universal_dt);
|
DateTime local_dt = os_local_time_from_universal(&universal_dt);
|
||||||
String8 time = push_date_time_string(scratch.arena, &local_dt);
|
String8 time = string_from_date_time(scratch.arena, &local_dt);
|
||||||
String8 full_path = os_full_path_from_path(scratch.arena, input_path);
|
String8 full_path = os_full_path_from_path(scratch.arena, input_path);
|
||||||
rd_printf("# %S, [%S] %S", time, input_type_string, full_path);
|
rd_printf("# %S, [%S] %S", time, input_type_string, full_path);
|
||||||
|
|
||||||
|
|||||||
@@ -266,7 +266,7 @@ entry_point(CmdLine *cmdl)
|
|||||||
// print run info
|
// print run info
|
||||||
DateTime now_time_universal = os_now_universal_time();
|
DateTime now_time_universal = os_now_universal_time();
|
||||||
DateTime now_time_local = os_local_time_from_universal_time(&now_time_universal);
|
DateTime now_time_local = os_local_time_from_universal_time(&now_time_universal);
|
||||||
String8 now_time_str = push_date_time_string(arena, &now_time_local);
|
String8 now_time_str = string_from_date_time(arena, &now_time_local);
|
||||||
fprintf(stdout, "Time: %.*s\n", str8_varg(now_time_str));
|
fprintf(stdout, "Time: %.*s\n", str8_varg(now_time_str));
|
||||||
fprintf(stdout, "File: %.*s\n", str8_varg(pdb_name));
|
fprintf(stdout, "File: %.*s\n", str8_varg(pdb_name));
|
||||||
fprintf(stdout, "Size: %llu (bytes)\n", pdb_data.size);
|
fprintf(stdout, "Size: %llu (bytes)\n", pdb_data.size);
|
||||||
|
|||||||
Reference in New Issue
Block a user