diff --git a/4coder_build_commands.cpp b/4coder_build_commands.cpp index a3896a87..054a6fc2 100644 --- a/4coder_build_commands.cpp +++ b/4coder_build_commands.cpp @@ -119,9 +119,9 @@ execute_standard_build_search(Application_Links *app, View_Summary *view, return(result); } -#elif defined(__linux__) +#elif defined(__linux__) || (defined(__APPLE__) && defined(__MACH__)) -// NOTE(allen): Build search rule for linux. +// NOTE(allen): Build search rule for linux and mac. static int32_t execute_standard_build_search(Application_Links *app, View_Summary *view, Buffer_Summary *active_buffer, String *dir, String *command, bool32 perform_backup){ char dir_space[512]; diff --git a/4coder_lib/4coder_string.h b/4coder_lib/4coder_string.h index e45c653b..4d856f1d 100644 --- a/4coder_lib/4coder_string.h +++ b/4coder_lib/4coder_string.h @@ -1,5 +1,5 @@ /* -4coder_string.h - Version 1.0.72 +4coder_string.h - Version 1.0.80 no warranty implied; use at your own risk This software is in the public domain. Where that dedication is not @@ -44,7 +44,6 @@ typedef int32_t b32_4tech; #endif // standard preamble end - #if !defined(FSTRING_LINK) # define FSTRING_LINK static #endif @@ -297,7 +296,7 @@ FSTRING_LINK b32_4tech string_set_match(void *str_set, i32_4tech ite // #if !defined(FSTRING_GUARD) -FSTRING_INLINE b32_4tech + FSTRING_INLINE b32_4tech char_is_slash(char c) { return (c == '\\' || c == '/'); @@ -305,7 +304,7 @@ char_is_slash(char c) #endif #if !defined(FSTRING_GUARD) -FSTRING_INLINE b32_4tech + FSTRING_INLINE b32_4tech char_is_upper(char c) { return (c >= 'A' && c <= 'Z'); @@ -313,15 +312,15 @@ char_is_upper(char c) #endif #if !defined(FSTRING_GUARD) -FSTRING_INLINE b32_4tech + FSTRING_INLINE b32_4tech char_is_upper_utf8(char c) { - return (c >= 'A' && c <= 'Z' || c >= 128); + return ((c >= 'A' && c <= 'Z') || (unsigned char)c >= 128); } #endif #if !defined(FSTRING_GUARD) -FSTRING_INLINE b32_4tech + FSTRING_INLINE b32_4tech char_is_lower(char c) { return (c >= 'a' && c <= 'z'); @@ -329,15 +328,15 @@ char_is_lower(char c) #endif #if !defined(FSTRING_GUARD) -FSTRING_INLINE b32_4tech + FSTRING_INLINE b32_4tech char_is_lower_utf8(u8_4tech c) { - return (c >= 'a' && c <= 'z' || c >= 128); + return ((c >= 'a' && c <= 'z') || (unsigned char)c >= 128); } #endif #if !defined(FSTRING_GUARD) -FSTRING_INLINE char + FSTRING_INLINE char char_to_upper(char c) { return (c >= 'a' && c <= 'z') ? c + (char)('A' - 'a') : c; @@ -345,7 +344,7 @@ char_to_upper(char c) #endif #if !defined(FSTRING_GUARD) -FSTRING_INLINE char + FSTRING_INLINE char char_to_lower(char c) { return (c >= 'A' && c <= 'Z') ? c - (char)('A' - 'a') : c; @@ -353,7 +352,7 @@ char_to_lower(char c) #endif #if !defined(FSTRING_GUARD) -FSTRING_INLINE b32_4tech + FSTRING_INLINE b32_4tech char_is_whitespace(char c) { return (c == ' ' || c == '\n' || c == '\r' || c == '\t'); @@ -361,87 +360,87 @@ char_is_whitespace(char c) #endif #if !defined(FSTRING_GUARD) -FSTRING_INLINE b32_4tech + FSTRING_INLINE b32_4tech char_is_alpha_numeric(char c) { - return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' || c == '_'); + return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_'); } #endif #if !defined(FSTRING_GUARD) -FSTRING_INLINE b32_4tech + FSTRING_INLINE b32_4tech char_is_alpha_numeric_utf8(u8_4tech c) { - return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' || c == '_' || c >= 128); + return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_' || (unsigned char)c >= 128); } #endif #if !defined(FSTRING_GUARD) -FSTRING_INLINE b32_4tech + FSTRING_INLINE b32_4tech char_is_alpha_numeric_true(char c) { - return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9'); + return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9')); } #endif #if !defined(FSTRING_GUARD) -FSTRING_INLINE b32_4tech + FSTRING_INLINE b32_4tech char_is_alpha_numeric_true_utf8(u8_4tech c) { - return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' || c >= 128); + return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || (unsigned char)c >= 128); } #endif #if !defined(FSTRING_GUARD) -FSTRING_INLINE b32_4tech + FSTRING_INLINE b32_4tech char_is_alpha(char c) { - return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '_'); + return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_'); } #endif #if !defined(FSTRING_GUARD) -FSTRING_INLINE b32_4tech + FSTRING_INLINE b32_4tech char_is_alpha_utf8(u8_4tech c) { - return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '_' || c >= 128); + return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' || (unsigned char)c >= 128); } #endif #if !defined(FSTRING_GUARD) -FSTRING_INLINE b32_4tech + FSTRING_INLINE b32_4tech char_is_alpha_true(char c) { - return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z'); + return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')); } #endif #if !defined(FSTRING_GUARD) -FSTRING_INLINE b32_4tech + FSTRING_INLINE b32_4tech char_is_alpha_true_utf8(u8_4tech c) { - return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= 128); + return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (unsigned char)c >= 128); } #endif #if !defined(FSTRING_GUARD) -FSTRING_INLINE b32_4tech + FSTRING_INLINE b32_4tech char_is_hex(char c) { - return (c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f'); + return ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f')); } #endif #if !defined(FSTRING_GUARD) -FSTRING_INLINE b32_4tech + FSTRING_INLINE b32_4tech char_is_hex_utf8(u8_4tech c) { - return (c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f' || c >= 128); + return ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f') || (unsigned char)c >= 128); } #endif #if !defined(FSTRING_GUARD) -FSTRING_INLINE b32_4tech + FSTRING_INLINE b32_4tech char_is_numeric(char c) { return (c >= '0' && c <= '9'); @@ -449,10 +448,10 @@ char_is_numeric(char c) #endif #if !defined(FSTRING_GUARD) -FSTRING_INLINE b32_4tech + FSTRING_INLINE b32_4tech char_is_numeric_utf8(u8_4tech c) { - return (c >= '0' && c <= '9' || c >= 128); + return ((c >= '0' && c <= '9') || (unsigned char)c >= 128); } #endif @@ -463,7 +462,7 @@ char_is_numeric_utf8(u8_4tech c) #if !defined(FSTRING_GUARD) -FSTRING_INLINE String + FSTRING_INLINE String make_string_cap(void *str, i32_4tech size, i32_4tech mem_size){ String result; result.str = (char*)str; @@ -474,7 +473,7 @@ make_string_cap(void *str, i32_4tech size, i32_4tech mem_size){ #endif #if !defined(FSTRING_GUARD) -FSTRING_INLINE String + FSTRING_INLINE String make_string(void *str, i32_4tech size){ String result; result.str = (char*)str; @@ -485,7 +484,7 @@ make_string(void *str, i32_4tech size){ #endif #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK i32_4tech + FSTRING_LINK i32_4tech str_size(char *str) { i32_4tech i = 0; @@ -495,7 +494,7 @@ str_size(char *str) #endif #if !defined(FSTRING_GUARD) -FSTRING_INLINE String + FSTRING_INLINE String make_string_slowly(void *str) { String result; @@ -508,7 +507,7 @@ make_string_slowly(void *str) #if !defined(FSTRING_GUARD) -FSTRING_INLINE String + FSTRING_INLINE String substr_tail(String str, i32_4tech start) { String result; @@ -520,7 +519,7 @@ substr_tail(String str, i32_4tech start) #endif #if !defined(FSTRING_GUARD) -FSTRING_INLINE String + FSTRING_INLINE String substr(String str, i32_4tech start, i32_4tech size) { String result; @@ -535,7 +534,7 @@ substr(String str, i32_4tech start, i32_4tech size) #endif #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK String + FSTRING_LINK String skip_whitespace(String str) { String result = {0}; @@ -548,7 +547,7 @@ skip_whitespace(String str) #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK String + FSTRING_LINK String skip_whitespace_measure(String str, i32_4tech *skip_length) { String result = {0}; @@ -561,7 +560,7 @@ skip_whitespace_measure(String str, i32_4tech *skip_length) #endif #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK String + FSTRING_LINK String chop_whitespace(String str) { String result = {0}; @@ -573,7 +572,7 @@ chop_whitespace(String str) #endif #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK String + FSTRING_LINK String skip_chop_whitespace(String str) { str = skip_whitespace(str); @@ -584,7 +583,7 @@ skip_chop_whitespace(String str) #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK String + FSTRING_LINK String skip_chop_whitespace_measure(String str, i32_4tech *skip_length) { str = skip_whitespace_measure(str, skip_length); @@ -594,7 +593,7 @@ skip_chop_whitespace_measure(String str, i32_4tech *skip_length) #endif #if !defined(FSTRING_GUARD) -FSTRING_INLINE String + FSTRING_INLINE String tailstr(String str) { String result; @@ -612,7 +611,7 @@ tailstr(String str) #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK b32_4tech + FSTRING_LINK b32_4tech match_cc(char *a, char *b){ for (i32_4tech i = 0;; ++i){ if (a[i] != b[i]){ @@ -627,7 +626,7 @@ match_cc(char *a, char *b){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK b32_4tech + FSTRING_LINK b32_4tech match_sc(String a, char *b){ i32_4tech i = 0; for (; i < a.size; ++i){ @@ -644,7 +643,7 @@ match_sc(String a, char *b){ #if !defined(FSTRING_GUARD) -FSTRING_INLINE b32_4tech + FSTRING_INLINE b32_4tech match_cs(char *a, String b){ return(match_sc(b,a)); } @@ -652,7 +651,7 @@ match_cs(char *a, String b){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK b32_4tech + FSTRING_LINK b32_4tech match_ss(String a, String b){ if (a.size != b.size){ return 0; @@ -668,7 +667,7 @@ match_ss(String a, String b){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK b32_4tech + FSTRING_LINK b32_4tech match_part_ccl(char *a, char *b, i32_4tech *len){ i32_4tech i; for (i = 0; b[i] != 0; ++i){ @@ -683,7 +682,7 @@ match_part_ccl(char *a, char *b, i32_4tech *len){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK b32_4tech + FSTRING_LINK b32_4tech match_part_scl(String a, char *b, i32_4tech *len){ i32_4tech i; for (i = 0; b[i] != 0; ++i){ @@ -698,7 +697,7 @@ match_part_scl(String a, char *b, i32_4tech *len){ #if !defined(FSTRING_GUARD) -FSTRING_INLINE b32_4tech + FSTRING_INLINE b32_4tech match_part_cc(char *a, char *b){ i32_4tech x; return match_part_ccl(a,b,&x); @@ -707,7 +706,7 @@ match_part_cc(char *a, char *b){ #if !defined(FSTRING_GUARD) -FSTRING_INLINE b32_4tech + FSTRING_INLINE b32_4tech match_part_sc(String a, char *b){ i32_4tech x; return match_part_scl(a,b,&x); @@ -716,7 +715,7 @@ match_part_sc(String a, char *b){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK b32_4tech + FSTRING_LINK b32_4tech match_part_cs(char *a, String b){ for (i32_4tech i = 0; i != b.size; ++i){ if (a[i] != b.str[i]){ @@ -729,7 +728,7 @@ match_part_cs(char *a, String b){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK b32_4tech + FSTRING_LINK b32_4tech match_part_ss(String a, String b){ if (a.size < b.size){ return 0; @@ -745,7 +744,7 @@ match_part_ss(String a, String b){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK b32_4tech + FSTRING_LINK b32_4tech match_insensitive_cc(char *a, char *b){ for (i32_4tech i = 0;; ++i){ if (char_to_upper(a[i]) != @@ -761,7 +760,7 @@ match_insensitive_cc(char *a, char *b){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK b32_4tech + FSTRING_LINK b32_4tech match_insensitive_sc(String a, char *b){ i32_4tech i = 0; for (; i < a.size; ++i){ @@ -779,7 +778,7 @@ match_insensitive_sc(String a, char *b){ #if !defined(FSTRING_GUARD) -FSTRING_INLINE b32_4tech + FSTRING_INLINE b32_4tech match_insensitive_cs(char *a, String b){ return match_insensitive_sc(b,a); } @@ -787,7 +786,7 @@ match_insensitive_cs(char *a, String b){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK b32_4tech + FSTRING_LINK b32_4tech match_insensitive_ss(String a, String b){ if (a.size != b.size){ return 0; @@ -804,7 +803,7 @@ match_insensitive_ss(String a, String b){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK b32_4tech + FSTRING_LINK b32_4tech match_part_insensitive_ccl(char *a, char *b, i32_4tech *len){ i32_4tech i; for (i = 0; b[i] != 0; ++i){ @@ -819,7 +818,7 @@ match_part_insensitive_ccl(char *a, char *b, i32_4tech *len){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK b32_4tech + FSTRING_LINK b32_4tech match_part_insensitive_scl(String a, char *b, i32_4tech *len){ i32_4tech i; for (i = 0; b[i] != 0; ++i){ @@ -835,7 +834,7 @@ match_part_insensitive_scl(String a, char *b, i32_4tech *len){ #if !defined(FSTRING_GUARD) -FSTRING_INLINE b32_4tech + FSTRING_INLINE b32_4tech match_part_insensitive_cc(char *a, char *b){ i32_4tech x; return match_part_insensitive_ccl(a,b,&x); @@ -844,7 +843,7 @@ match_part_insensitive_cc(char *a, char *b){ #if !defined(FSTRING_GUARD) -FSTRING_INLINE b32_4tech + FSTRING_INLINE b32_4tech match_part_insensitive_sc(String a, char *b){ i32_4tech x; return match_part_insensitive_scl(a,b,&x); @@ -853,7 +852,7 @@ match_part_insensitive_sc(String a, char *b){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK b32_4tech + FSTRING_LINK b32_4tech match_part_insensitive_cs(char *a, String b){ for (i32_4tech i = 0; i != b.size; ++i){ if (char_to_upper(a[i]) != char_to_upper(b.str[i])){ @@ -866,7 +865,7 @@ match_part_insensitive_cs(char *a, String b){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK b32_4tech + FSTRING_LINK b32_4tech match_part_insensitive_ss(String a, String b){ if (a.size < b.size){ return(0); @@ -882,7 +881,7 @@ match_part_insensitive_ss(String a, String b){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK i32_4tech + FSTRING_LINK i32_4tech compare_cc(char *a, char *b){ i32_4tech i = 0, r = 0; while (a[i] == b[i] && a[i] != 0){ @@ -895,7 +894,7 @@ compare_cc(char *a, char *b){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK i32_4tech + FSTRING_LINK i32_4tech compare_sc(String a, char *b){ i32_4tech i = 0, r = 0; while (i < a.size && a.str[i] == b[i]){ @@ -918,7 +917,7 @@ compare_sc(String a, char *b){ #if !defined(FSTRING_GUARD) -FSTRING_INLINE i32_4tech + FSTRING_INLINE i32_4tech compare_cs(char *a, String b){ i32_4tech r = -compare_sc(b,a); return(r); @@ -927,7 +926,7 @@ compare_cs(char *a, String b){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK i32_4tech + FSTRING_LINK i32_4tech compare_ss(String a, String b){ i32_4tech i = 0, r = 0; i32_4tech m = a.size; @@ -955,7 +954,7 @@ compare_ss(String a, String b){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK i32_4tech + FSTRING_LINK i32_4tech find_c_char(char *str, i32_4tech start, char character){ i32_4tech i = start; while (str[i] != character && str[i] != 0) ++i; @@ -965,7 +964,7 @@ find_c_char(char *str, i32_4tech start, char character){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK i32_4tech + FSTRING_LINK i32_4tech find_s_char(String str, i32_4tech start, char character){ i32_4tech i = start; while (i < str.size && str.str[i] != character) ++i; @@ -975,7 +974,7 @@ find_s_char(String str, i32_4tech start, char character){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK i32_4tech + FSTRING_LINK i32_4tech rfind_s_char(String str, i32_4tech start, char character){ i32_4tech i = start; while (i >= 0 && str.str[i] != character) --i; @@ -985,7 +984,7 @@ rfind_s_char(String str, i32_4tech start, char character){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK i32_4tech + FSTRING_LINK i32_4tech find_c_chars(char *str, i32_4tech start, char *characters){ i32_4tech i = start, j; while (str[i] != 0){ @@ -1002,7 +1001,7 @@ find_c_chars(char *str, i32_4tech start, char *characters){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK i32_4tech + FSTRING_LINK i32_4tech find_s_chars(String str, i32_4tech start, char *characters){ i32_4tech i = start, j; while (i < str.size){ @@ -1019,7 +1018,7 @@ find_s_chars(String str, i32_4tech start, char *characters){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK i32_4tech + FSTRING_LINK i32_4tech find_substr_c(char *str, i32_4tech start, String seek){ i32_4tech i, j, k; b32_4tech hit; @@ -1048,7 +1047,7 @@ find_substr_c(char *str, i32_4tech start, String seek){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK i32_4tech + FSTRING_LINK i32_4tech find_substr_s(String str, i32_4tech start, String seek){ i32_4tech stop_at, i, j, k; b32_4tech hit; @@ -1077,7 +1076,7 @@ find_substr_s(String str, i32_4tech start, String seek){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK i32_4tech + FSTRING_LINK i32_4tech rfind_substr_s(String str, i32_4tech start, String seek){ i32_4tech i, j, k; b32_4tech hit; @@ -1108,7 +1107,7 @@ rfind_substr_s(String str, i32_4tech start, String seek){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK i32_4tech + FSTRING_LINK i32_4tech find_substr_insensitive_c(char *str, i32_4tech start, String seek){ i32_4tech i, j, k; b32_4tech hit; @@ -1142,7 +1141,7 @@ find_substr_insensitive_c(char *str, i32_4tech start, String seek){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK i32_4tech + FSTRING_LINK i32_4tech find_substr_insensitive_s(String str, i32_4tech start, String seek){ i32_4tech i, j, k; i32_4tech stop_at; @@ -1178,7 +1177,7 @@ find_substr_insensitive_s(String str, i32_4tech start, String seek){ #if !defined(FSTRING_GUARD) -FSTRING_INLINE b32_4tech + FSTRING_INLINE b32_4tech has_substr_c(char *s, String seek){ return (s[find_substr_c(s, 0, seek)] != 0); } @@ -1186,7 +1185,7 @@ has_substr_c(char *s, String seek){ #if !defined(FSTRING_GUARD) -FSTRING_INLINE b32_4tech + FSTRING_INLINE b32_4tech has_substr_s(String s, String seek){ return (find_substr_s(s, 0, seek) < s.size); } @@ -1194,7 +1193,7 @@ has_substr_s(String s, String seek){ #if !defined(FSTRING_GUARD) -FSTRING_INLINE b32_4tech + FSTRING_INLINE b32_4tech has_substr_insensitive_c(char *s, String seek){ return (s[find_substr_insensitive_c(s, 0, seek)] != 0); } @@ -1202,7 +1201,7 @@ has_substr_insensitive_c(char *s, String seek){ #if !defined(FSTRING_GUARD) -FSTRING_INLINE b32_4tech + FSTRING_INLINE b32_4tech has_substr_insensitive_s(String s, String seek){ return (find_substr_insensitive_s(s, 0, seek) < s.size); } @@ -1214,7 +1213,7 @@ has_substr_insensitive_s(String s, String seek){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK i32_4tech + FSTRING_LINK i32_4tech copy_fast_unsafe_cc(char *dest, char *src){ char *start = dest; while (*src != 0){ @@ -1228,7 +1227,7 @@ copy_fast_unsafe_cc(char *dest, char *src){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK i32_4tech + FSTRING_LINK i32_4tech copy_fast_unsafe_cs(char *dest, String src){ i32_4tech i = 0; while (i != src.size){ @@ -1241,7 +1240,7 @@ copy_fast_unsafe_cs(char *dest, String src){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK b32_4tech + FSTRING_LINK b32_4tech copy_checked_ss(String *dest, String src){ char *dest_str; i32_4tech i; @@ -1259,7 +1258,7 @@ copy_checked_ss(String *dest, String src){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK b32_4tech + FSTRING_LINK b32_4tech copy_checked_cs(char *dest, i32_4tech dest_cap, String src){ i32_4tech i; if (dest_cap < src.size){ @@ -1274,7 +1273,7 @@ copy_checked_cs(char *dest, i32_4tech dest_cap, String src){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK b32_4tech + FSTRING_LINK b32_4tech copy_partial_sc(String *dest, char *src){ i32_4tech i = 0; i32_4tech memory_size = dest->memory_size; @@ -1293,7 +1292,7 @@ copy_partial_sc(String *dest, char *src){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK b32_4tech + FSTRING_LINK b32_4tech copy_partial_ss(String *dest, String src){ char *dest_str = dest->str; i32_4tech memory_size = dest->memory_size; @@ -1312,7 +1311,7 @@ copy_partial_ss(String *dest, String src){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK b32_4tech + FSTRING_LINK b32_4tech copy_partial_cs(char *dest, i32_4tech dest_cap, String src){ b32_4tech result = 0; i32_4tech copy_size = dest_cap; @@ -1330,7 +1329,7 @@ copy_partial_cs(char *dest, i32_4tech dest_cap, String src){ #if !defined(FSTRING_GUARD) -FSTRING_INLINE i32_4tech + FSTRING_INLINE i32_4tech copy_cc(char *dest, char *src){ return copy_fast_unsafe_cc(dest, src); } @@ -1338,7 +1337,7 @@ copy_cc(char *dest, char *src){ #if !defined(FSTRING_GUARD) -FSTRING_INLINE void + FSTRING_INLINE void copy_ss(String *dest, String src){ copy_checked_ss(dest, src); } @@ -1346,7 +1345,7 @@ copy_ss(String *dest, String src){ #if !defined(FSTRING_GUARD) -FSTRING_INLINE void + FSTRING_INLINE void copy_sc(String *dest, char *src){ copy_partial_sc(dest, src); } @@ -1354,7 +1353,7 @@ copy_sc(String *dest, char *src){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK b32_4tech + FSTRING_LINK b32_4tech append_checked_ss(String *dest, String src){ String end; end = tailstr(*dest); @@ -1368,7 +1367,7 @@ append_checked_ss(String *dest, String src){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK b32_4tech + FSTRING_LINK b32_4tech append_partial_sc(String *dest, char *src){ String end = tailstr(*dest); b32_4tech result = copy_partial_sc(&end, src); @@ -1379,7 +1378,7 @@ append_partial_sc(String *dest, char *src){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK b32_4tech + FSTRING_LINK b32_4tech append_partial_ss(String *dest, String src){ String end = tailstr(*dest); b32_4tech result = copy_partial_ss(&end, src); @@ -1390,7 +1389,7 @@ append_partial_ss(String *dest, String src){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK b32_4tech + FSTRING_LINK b32_4tech append_s_char(String *dest, char c){ b32_4tech result = 0; if (dest->size < dest->memory_size){ @@ -1403,7 +1402,7 @@ append_s_char(String *dest, char c){ #if !defined(FSTRING_GUARD) -FSTRING_INLINE b32_4tech + FSTRING_INLINE b32_4tech append_ss(String *dest, String src){ return append_partial_ss(dest, src); } @@ -1411,14 +1410,14 @@ append_ss(String *dest, String src){ #if !defined(FSTRING_GUARD) -FSTRING_INLINE b32_4tech + FSTRING_INLINE b32_4tech append_sc(String *dest, char *src){ return append_partial_sc(dest, src); } #endif #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK b32_4tech + FSTRING_LINK b32_4tech terminate_with_null(String *str){ b32_4tech result = 0; if (str->size < str->memory_size){ @@ -1430,7 +1429,7 @@ terminate_with_null(String *str){ #endif #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK b32_4tech + FSTRING_LINK b32_4tech append_padding(String *dest, char c, i32_4tech target_size){ b32_4tech result = 1; i32_4tech offset = target_size - dest->size; @@ -1453,7 +1452,7 @@ append_padding(String *dest, char c, i32_4tech target_size){ // #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK void + FSTRING_LINK void replace_char(String *str, char replace, char with){ char *s = str->str; i32_4tech i = 0; @@ -1465,7 +1464,7 @@ replace_char(String *str, char replace, char with){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK void + FSTRING_LINK void to_lower_cc(char *src, char *dst){ for (; *src != 0; ++src){ *dst++ = char_to_lower(*src); @@ -1476,7 +1475,7 @@ to_lower_cc(char *src, char *dst){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK void + FSTRING_LINK void to_lower_ss(String *dst, String src){ i32_4tech i = 0; i32_4tech size = src.size; @@ -1494,7 +1493,7 @@ to_lower_ss(String *dst, String src){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK void + FSTRING_LINK void to_lower_s(String *str){ i32_4tech i = 0; i32_4tech size = str->size; @@ -1507,7 +1506,7 @@ to_lower_s(String *str){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK void + FSTRING_LINK void to_upper_cc(char *src, char *dst){ for (; *src != 0; ++src){ *dst++ = char_to_upper(*src); @@ -1518,7 +1517,7 @@ to_upper_cc(char *src, char *dst){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK void + FSTRING_LINK void to_upper_ss(String *dst, String src){ i32_4tech i = 0; i32_4tech size = src.size; @@ -1536,7 +1535,7 @@ to_upper_ss(String *dst, String src){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK void + FSTRING_LINK void to_upper_s(String *str){ i32_4tech i = 0; i32_4tech size = str->size; @@ -1549,7 +1548,7 @@ to_upper_s(String *str){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK void + FSTRING_LINK void to_camel_cc(char *src, char *dst){ char *c, ch; i32_4tech is_first = 1; @@ -1579,7 +1578,7 @@ to_camel_cc(char *src, char *dst){ // #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK i32_4tech + FSTRING_LINK i32_4tech int_to_str_size(i32_4tech x){ i32_4tech size = 1; if (x < 0){ @@ -1595,7 +1594,7 @@ int_to_str_size(i32_4tech x){ #endif #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK b32_4tech + FSTRING_LINK b32_4tech int_to_str(String *dest, i32_4tech x){ b32_4tech result = 1; char *str = dest->str; @@ -1642,7 +1641,7 @@ int_to_str(String *dest, i32_4tech x){ #endif #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK b32_4tech + FSTRING_LINK b32_4tech append_int_to_str(String *dest, i32_4tech x){ String last_part = tailstr(*dest); b32_4tech result = int_to_str(&last_part, x); @@ -1654,26 +1653,20 @@ append_int_to_str(String *dest, i32_4tech x){ #endif #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK i32_4tech + FSTRING_LINK i32_4tech u64_to_str_size(uint64_t x){ - i32_4tech size; - if (x < 0){ - size = 0; - } - else{ - size = 1; + i32_4tech size = 1; + x /= 10; + while (x != 0){ x /= 10; - while (x != 0){ - x /= 10; - ++size; - } + ++size; } return(size); } #endif #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK b32_4tech + FSTRING_LINK b32_4tech u64_to_str(String *dest, uint64_t x){ b32_4tech result = 1; char *str = dest->str; @@ -1712,7 +1705,7 @@ u64_to_str(String *dest, uint64_t x){ #endif #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK b32_4tech + FSTRING_LINK b32_4tech append_u64_to_str(String *dest, uint64_t x){ String last_part = tailstr(*dest); b32_4tech result = u64_to_str(&last_part, x); @@ -1747,7 +1740,7 @@ get_float_vars(float x){ #endif #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK i32_4tech + FSTRING_LINK i32_4tech float_to_str_size(float x){ Float_To_Str_Variables vars = get_float_vars(x); i32_4tech size = vars.negative + int_to_str_size(vars.int_part) + 1 + int_to_str_size(vars.dec_part); @@ -1756,7 +1749,7 @@ float_to_str_size(float x){ #endif #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK b32_4tech + FSTRING_LINK b32_4tech append_float_to_str(String *dest, float x){ b32_4tech result = 1; Float_To_Str_Variables vars = get_float_vars(x); @@ -1774,7 +1767,7 @@ append_float_to_str(String *dest, float x){ #endif #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK b32_4tech + FSTRING_LINK b32_4tech float_to_str(String *dest, float x){ b32_4tech result = 1; dest->size = 0; @@ -1785,7 +1778,7 @@ float_to_str(String *dest, float x){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK i32_4tech + FSTRING_LINK i32_4tech str_is_int_c(char *str){ b32_4tech result = 1; for (; *str; ++str){ @@ -1800,7 +1793,7 @@ str_is_int_c(char *str){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK b32_4tech + FSTRING_LINK b32_4tech str_is_int_s(String str){ b32_4tech result = 1; for (i32_4tech i = 0; i < str.size; ++i){ @@ -1815,7 +1808,7 @@ str_is_int_s(String str){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK i32_4tech + FSTRING_LINK i32_4tech str_to_int_c(char *str){ i32_4tech x = 0; for (; *str; ++str){ @@ -1834,7 +1827,7 @@ str_to_int_c(char *str){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK i32_4tech + FSTRING_LINK i32_4tech str_to_int_s(String str){ i32_4tech x, i; if (str.size == 0){ @@ -1852,7 +1845,7 @@ str_to_int_s(String str){ #endif #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK i32_4tech + FSTRING_LINK i32_4tech hexchar_to_int(char c){ i32_4tech x = 0; if (c >= '0' && c <= '9'){ @@ -1869,14 +1862,14 @@ hexchar_to_int(char c){ #endif #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK char + FSTRING_LINK char int_to_hexchar(i32_4tech x){ return (x<10)?((char)x+'0'):((char)x+'a'-10); } #endif #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK u32_4tech + FSTRING_LINK u32_4tech hexstr_to_int(String str){ u32_4tech x; i32_4tech i; @@ -1895,7 +1888,7 @@ hexstr_to_int(String str){ #endif #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK b32_4tech + FSTRING_LINK b32_4tech color_to_hexstr(String *s, u32_4tech color){ b32_4tech result = 0; i32_4tech i; @@ -1924,7 +1917,7 @@ color_to_hexstr(String *s, u32_4tech color){ #endif #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK b32_4tech + FSTRING_LINK b32_4tech hexstr_to_color(String s, u32_4tech *out){ b32_4tech result = 0; u32_4tech color = 0; @@ -1949,7 +1942,7 @@ hexstr_to_color(String s, u32_4tech *out){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK i32_4tech + FSTRING_LINK i32_4tech reverse_seek_slash_pos(String str, i32_4tech pos){ i32_4tech i = str.size - 1 - pos; while (i >= 0 && !char_is_slash(str.str[i])){ @@ -1960,21 +1953,21 @@ reverse_seek_slash_pos(String str, i32_4tech pos){ #endif #if !defined(FSTRING_GUARD) -FSTRING_INLINE i32_4tech + FSTRING_INLINE i32_4tech reverse_seek_slash(String str){ return(reverse_seek_slash_pos(str, 0)); } #endif #if !defined(FSTRING_GUARD) -FSTRING_INLINE String + FSTRING_INLINE String front_of_directory(String dir){ return substr_tail(dir, reverse_seek_slash(dir) + 1); } #endif #if !defined(FSTRING_GUARD) -FSTRING_INLINE String + FSTRING_INLINE String path_of_directory(String dir){ return substr(dir, 0, reverse_seek_slash(dir) + 1); } @@ -1982,7 +1975,7 @@ path_of_directory(String dir){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK b32_4tech + FSTRING_LINK b32_4tech set_last_folder_sc(String *dir, char *folder_name, char slash){ b32_4tech result = 0; i32_4tech size = reverse_seek_slash(*dir) + 1; @@ -2001,7 +1994,7 @@ set_last_folder_sc(String *dir, char *folder_name, char slash){ #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK b32_4tech + FSTRING_LINK b32_4tech set_last_folder_ss(String *dir, String folder_name, char slash){ b32_4tech result = 0; i32_4tech size = reverse_seek_slash(*dir) + 1; @@ -2019,7 +2012,7 @@ set_last_folder_ss(String *dir, String folder_name, char slash){ #endif #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK String + FSTRING_LINK String file_extension(String str){ i32_4tech i; for (i = str.size - 1; i >= 0; --i){ @@ -2031,7 +2024,7 @@ file_extension(String str){ #endif #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK b32_4tech + FSTRING_LINK b32_4tech remove_extension(String *str){ b32_4tech result = 0; i32_4tech i; @@ -2047,7 +2040,7 @@ remove_extension(String *str){ #endif #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK b32_4tech + FSTRING_LINK b32_4tech remove_last_folder(String *str){ b32_4tech result = 0; i32_4tech end = reverse_seek_slash_pos(*str, 1); @@ -2062,7 +2055,7 @@ remove_last_folder(String *str){ // TODO(allen): Add hash-table extension to string sets. #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK b32_4tech + FSTRING_LINK b32_4tech string_set_match_table(void *str_set, i32_4tech item_size, i32_4tech count, String str, i32_4tech *match_index){ b32_4tech result = 0; i32_4tech i = 0; @@ -2079,7 +2072,7 @@ string_set_match_table(void *str_set, i32_4tech item_size, i32_4tech count, Stri #endif #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK b32_4tech + FSTRING_LINK b32_4tech string_set_match(String *str_set, i32_4tech count, String str, i32_4tech *match_index){ b32_4tech result = string_set_match_table(str_set, sizeof(String), count, str, match_index); return(result); @@ -2087,7 +2080,7 @@ string_set_match(String *str_set, i32_4tech count, String str, i32_4tech *match_ #endif #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK String + FSTRING_LINK String get_first_double_line(String source){ String line = {0}; i32_4tech pos0 = find_substr_s(source, 0, make_lit_string("\n\n")); @@ -2101,7 +2094,7 @@ get_first_double_line(String source){ #endif #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK String + FSTRING_LINK String get_next_double_line(String source, String line){ String next = {0}; i32_4tech pos = (i32_4tech)(line.str - source.str) + line.size; @@ -2126,7 +2119,7 @@ get_next_double_line(String source, String line){ #endif #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK String + FSTRING_LINK String get_next_word(String source, String prev_word){ String word = {0}; @@ -2157,7 +2150,7 @@ get_next_word(String source, String prev_word){ #endif #if defined(FSTRING_IMPLEMENTATION) -FSTRING_LINK String + FSTRING_LINK String get_first_word(String source){ String start_str = make_string(source.str, 0); String word = get_next_word(source, start_str); diff --git a/4coder_project_commands.cpp b/4coder_project_commands.cpp index 3876b581..ab502d50 100644 --- a/4coder_project_commands.cpp +++ b/4coder_project_commands.cpp @@ -252,11 +252,13 @@ load_project_from_config_data(Application_Links *app, Partition *part, char *con { #if defined(_WIN32) -#define FKEY_COMMAND "fkey_command_win" +# define FKEY_COMMAND "fkey_command_win" #elif defined(__linux__) -#define FKEY_COMMAND "fkey_command_linux" +# define FKEY_COMMAND "fkey_command_linux" +#elif defined(__APPLE__) && defined(__MACH__) +# define FKEY_COMMAND "fkey_command_mac" #else -#error no project configuration names for this platform +# error no project configuration names for this platform #endif int32_t index = 0; diff --git a/4ed_os_comp_cracking.h b/4ed_os_comp_cracking.h index b52edcb2..cb695ded 100644 --- a/4ed_os_comp_cracking.h +++ b/4ed_os_comp_cracking.h @@ -34,7 +34,9 @@ # if defined(__gnu_linux__) # define IS_LINUX -# else +# elif defined(__APPLE__) && defined(__MACH__) +# define IS_MAC +#else # error This compiler/platform combo is not supported yet # endif diff --git a/build.sh b/build.sh index b3acb3e9..ca9d55e4 100755 --- a/build.sh +++ b/build.sh @@ -5,7 +5,7 @@ if [ -z "$BUILD_MODE" ]; then BUILD_MODE="-DDEV_BUILD" fi -WARNINGS="-Wno-write-strings" +WARNINGS="-Wno-write-strings -Wno-comment -Wno-logical-op-parentheses -Wno-null-dereference -Wno-switch" FLAGS="-D_GNU_SOURCE -fPIC -fpermissive $BUILD_MODE" g++ $WARNINGS $FLAGS meta/build.cpp -g -o ../build/build diff --git a/buildsuper.sh b/buildsuper.sh index db6ef1ba..bd9a20ec 100755 --- a/buildsuper.sh +++ b/buildsuper.sh @@ -1,19 +1,43 @@ #!/bin/bash -# NOTE(allen): This code here is pulled from stack exchange, it could totally be wrong -# but I just don't know. The goal is to get the path to the buildsuper.sh script so that -# path can be used as an include path which allows a file in any folder to be built in place. -SCRIPT_FILE=$(readlink -f "$0") +echo "Building custom_4coders.so from $SOURCE ..." + +# Find the code home folder + +# NOTE(allen): Copied from stack exchange, hope it's reasonable -- readlink doesn't work on mac +TARGET_FILE="$0" +cd `dirname $TARGET_FILE` +TARGET_FILE=`basename $TARGET_FILE` +while [ -L "$TARGET_FILE" ] +do + TARGET_FILE=`readlink $TARGET_FILE` + cd `dirname $TARGET_FILE` + TARGET_FILE=`basename $TARGET_FILE` +done +PHYS_DIR=`pwd -P` +SCRIPT_FILE=$PHYS_DIR/$TARGET_FILE CODE_HOME=$(dirname "$SCRIPT_FILE") +# Find the most reasonable candidate build file + SOURCE="$1" if [ -z "$SOURCE" ]; then SOURCE="$CODE_HOME/4coder_default_bindings.cpp" fi -echo "Building custom_4coders.so from $SOURCE ..." +# NOTE(allen): Copied from stack exchange, hope it's reasonable -- readlink doesn't work on mac +TARGET_FILE="$SOURCE" +cd `dirname $TARGET_FILE` +TARGET_FILE=`basename $TARGET_FILE` +while [ -L "$TARGET_FILE" ] +do + TARGET_FILE=`readlink $TARGET_FILE` + cd `dirname $TARGET_FILE` + TARGET_FILE=`basename $TARGET_FILE` +done +PHYS_DIR=`pwd -P` +SOURCE=$PHYS_DIR/$TARGET_FILE -SOURCE=$(readlink -f "$SOURCE") - -g++ -I"$CODE_HOME" -Wno-write-strings -std=gnu++0x "$SOURCE" -shared -o custom_4coder.so -fPIC +FLAGS="-Wno-write-strings -Wno-null-dereference -Wno-comment -Wno-switch -Wno-writable-strings" +g++ -I"$CODE_HOME" $FLAGS -std=gnu++0x "$SOURCE" -shared -o custom_4coder.so -fPIC diff --git a/meta/4ed_metagen.cpp b/meta/4ed_metagen.cpp index 776f0d67..b1eb6f9d 100644 --- a/meta/4ed_metagen.cpp +++ b/meta/4ed_metagen.cpp @@ -317,7 +317,6 @@ generate_style(){ ////////////////////////////////////////////////////////////////////////////////////////////////// - // // Meta Parse Rules // diff --git a/meta/4tech_file_moving.h b/meta/4tech_file_moving.h index e461f78f..370a9350 100644 --- a/meta/4tech_file_moving.h +++ b/meta/4tech_file_moving.h @@ -28,6 +28,13 @@ static char platform_correct_slash = '\\'; #define SLASH "/" static char platform_correct_slash = '/'; +#elif defined(IS_MAC) +# define ONLY_WINDOWS(x) (void)0 +# define ONLY_LINUX(x) (void)0 + +#define SLASH "/" +static char platform_correct_slash = '/'; + #else # define ONLY_WINDOWS(x) (void)0 # define ONLY_LINUX(x) (void)0 @@ -209,8 +216,7 @@ make_folder_if_missing(char *dir, char *folder){ static void clear_folder(char *folder){ - systemf("del /S /Q /F %s\\* & rmdir /S /Q %s & mkdir %s", - folder, folder, folder); + systemf("del /S /Q /F %s\\* & rmdir /S /Q %s & mkdir %s", folder, folder, folder); } static void @@ -269,7 +275,7 @@ zip(char *parent, char *folder, char *dest){ systemf("copy %s\\4tech_gobble.zip %s & del %s\\4tech_gobble.zip", cdir, dest, cdir); } -#elif defined(IS_LINUX) +#elif defined(IS_LINUX) || defined(IS_MAC) #include #include @@ -281,8 +287,8 @@ pushdir(char *dir){ int32_t chresult = chdir(dir); if (result == 0 || chresult != 0){ printf("trying pushdir %s\n", dir); - assert(result != 0); - assert(chresult == 0); + Assert(result != 0); + Assert(chresult == 0); } return(temp); } @@ -402,6 +408,7 @@ zip(char *parent, char *folder, char *file){ Temp_Dir temp = pushdir(parent); printf("PARENT DIR: %s\n", parent); systemf("zip -r %s %s", file, folder); + popdir(temp); } diff --git a/meta/build.cpp b/meta/build.cpp index 903e3262..2b405803 100644 --- a/meta/build.cpp +++ b/meta/build.cpp @@ -32,7 +32,7 @@ #if defined(IS_WINDOWS) #define EXE ".exe" -#elif defined(IS_LINUX) +#elif defined(IS_LINUX) || defined(IS_MAC) #define EXE "" #else #error No EXE format specified for this OS @@ -40,26 +40,26 @@ #if defined(IS_WINDOWS) #define PDB ".pdb" -#elif defined(IS_LINUX) +#elif defined(IS_LINUX) || defined(IS_MAC) #define PDB "" #else -#error No EXE format specified for this OS +#error No PDB format specified for this OS #endif #if defined(IS_WINDOWS) #define DLL ".dll" -#elif defined(IS_LINUX) +#elif defined(IS_LINUX) || defined(IS_MAC) #define DLL ".so" #else -#error No EXE format specified for this OS +#error No DLL format specified for this OS #endif #if defined(IS_WINDOWS) #define BAT ".bat" -#elif defined(IS_LINUX) +#elif defined(IS_LINUX) || defined(IS_MAC) #define BAT ".sh" #else -#error No EXE format specified for this OS +#error No BAT format specified for this OS #endif static void @@ -246,8 +246,10 @@ build_cl(u32 flags, char *code_path, char *code_file, char *out_path, char *out_ } -#define GCC_OPTS \ -"-Wno-write-strings -D_GNU_SOURCE -fPIC " \ +#define GCC_OPTS \ +"-Wno-write-strings -Wno-comment -Wno-switch " \ +"-Wno-null-dereference " \ +"-D_GNU_SOURCE -fPIC " \ "-fno-threadsafe-statics -pthread" #define GCC_X86 "-m32" @@ -327,7 +329,8 @@ build_gcc(u32 flags, char *code_path, char *code_file, char *out_path, char *out build_ap(line, "-DFRED_KEEP_ASSERT"); } - build_ap(line, "%s/%s", code_path, code_file); + build_ap(line, "-I\"%s\"", code_path); + build_ap(line, "\"%s/%s\"", code_path, code_file); if (flags & LIBS){ build_ap(line, GCC_LIBS); @@ -380,6 +383,8 @@ buildsuper(char *code_path, char *out_path, char *filename, b32 x86_build){ #define PLAT_LAYER "win32_4ed.cpp" #elif defined(IS_LINUX) #define PLAT_LAYER "linux_4ed.cpp" +#elif defined(IS_MAC) +#define PLAT_LAYER "mac_4ed.m" #else #error No platform layer defined for this OS. #endif @@ -560,6 +565,8 @@ get_4coder_dist_name(String *zip_file, b32 OS_specific, char *folder, char *tier append_sc(zip_file, "-win"); #elif defined(IS_LINUX) && defined(IS_64BIT) append_sc(zip_file, "-linux"); +#elif defined(IS_MAC) && defined(IS_64BIT) + append_sc(zip_file, "-mac"); #else #error No OS string for zips on this OS #endif diff --git a/meta/fsm_table_generator.cpp b/meta/fsm_table_generator.cpp index 6ed167c7..3ee4d6d2 100644 --- a/meta/fsm_table_generator.cpp +++ b/meta/fsm_table_generator.cpp @@ -572,7 +572,7 @@ main_fsm(Cpp_Lex_FSM fsm, uint8_t pp_state, uint8_t c, bool32 ignore_string_deli case LS_hex: { - int is_hex = c >= '0' && c <= '9' || c >= 'a' && c <= 'f' || c >= 'A' && c <= 'F' || c >= 128; + int is_hex = (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F') || c >= 128; if (!is_hex){ fsm.emit_token = true; } diff --git a/power/custom_4coder.so b/power/custom_4coder.so new file mode 100755 index 00000000..3339169f Binary files /dev/null and b/power/custom_4coder.so differ diff --git a/readlink_f_simulator.sh b/readlink_f_simulator.sh new file mode 100755 index 00000000..13f47935 --- /dev/null +++ b/readlink_f_simulator.sh @@ -0,0 +1,2 @@ +#!/bin/sh + diff --git a/string/4coder_string_build_num.txt b/string/4coder_string_build_num.txt index 9fab48ce..5017890a 100644 --- a/string/4coder_string_build_num.txt +++ b/string/4coder_string_build_num.txt @@ -1,5 +1,5 @@ 1 0 -74 +86 diff --git a/string/build.sh b/string/build.sh new file mode 100755 index 00000000..b56cb914 --- /dev/null +++ b/string/build.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +WARNINGS="-Wno-write-strings -Wno-comment -Wno-logical-op-parentheses -Wno-null-dereference -Wno-switch" +FLAGS="-D_GNU_SOURCE -fPIC -fpermissive" + +g++ $WARNINGS $FLAGS ../code/string/string_builder.cpp -g -o ../build/string_builder + +pushd string +../../build/string_builder +popd + diff --git a/string/internal_4coder_string.cpp b/string/internal_4coder_string.cpp index 4d6b13b7..5758b559 100644 --- a/string/internal_4coder_string.cpp +++ b/string/internal_4coder_string.cpp @@ -66,7 +66,7 @@ char_is_upper(char c) API_EXPORT_INLINE FSTRING_INLINE b32_4tech char_is_upper_utf8(char c) /* DOC(If c is an uppercase letter this call returns true.) */{ - return (c >= 'A' && c <= 'Z' || c >= 128); + return ((c >= 'A' && c <= 'Z') || (unsigned char)c >= 128); } API_EXPORT_INLINE FSTRING_INLINE b32_4tech @@ -78,7 +78,7 @@ char_is_lower(char c) API_EXPORT_INLINE FSTRING_INLINE b32_4tech char_is_lower_utf8(u8_4tech c) /* DOC(If c is a lower letter this call returns true.) */{ - return (c >= 'a' && c <= 'z' || c >= 128); + return ((c >= 'a' && c <= 'z') || (unsigned char)c >= 128); } API_EXPORT_INLINE FSTRING_INLINE char @@ -102,61 +102,61 @@ char_is_whitespace(char c) API_EXPORT_INLINE FSTRING_INLINE b32_4tech char_is_alpha_numeric(char c) /* DOC(This call returns non-zero if c is any alphanumeric character including underscore.) */{ - return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' || c == '_'); + return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_'); } API_EXPORT_INLINE FSTRING_INLINE b32_4tech char_is_alpha_numeric_utf8(u8_4tech c) /* DOC(This call returns non-zero if c is any alphanumeric character including underscore, or is a part of a UTF8 sequence outside of ASCII.) */{ - return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' || c == '_' || c >= 128); + return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_' || (unsigned char)c >= 128); } API_EXPORT_INLINE FSTRING_INLINE b32_4tech char_is_alpha_numeric_true(char c) /* DOC(This call returns non-zero if c is any alphanumeric character no including underscore.) */{ - return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9'); + return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9')); } API_EXPORT_INLINE FSTRING_INLINE b32_4tech char_is_alpha_numeric_true_utf8(u8_4tech c) /* DOC(This call returns non-zero if c is any alphanumeric character no including underscore.) */{ - return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= '0' && c <= '9' || c >= 128); + return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || (unsigned char)c >= 128); } API_EXPORT_INLINE FSTRING_INLINE b32_4tech char_is_alpha(char c) /* DOC(This call returns non-zero if c is any alphabetic character including underscore.) */{ - return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '_'); + return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_'); } API_EXPORT_INLINE FSTRING_INLINE b32_4tech char_is_alpha_utf8(u8_4tech c) /* DOC(This call returns non-zero if c is any alphabetic character including underscore, or is a part of a UTF8 sequence outside of ASCII.) */{ - return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '_' || c >= 128); + return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' || (unsigned char)c >= 128); } API_EXPORT_INLINE FSTRING_INLINE b32_4tech char_is_alpha_true(char c) /* DOC(This call returns non-zero if c is any alphabetic character.) */{ - return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z'); + return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')); } API_EXPORT_INLINE FSTRING_INLINE b32_4tech char_is_alpha_true_utf8(u8_4tech c) /* DOC(This call returns non-zero if c is any alphabetic character, or is a part of a UTF8 sequence outside of ASCII.) */{ - return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c >= 128); + return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (unsigned char)c >= 128); } API_EXPORT_INLINE FSTRING_INLINE b32_4tech char_is_hex(char c) /* DOC(This call returns non-zero if c is any valid hexadecimal digit.) */{ - return (c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f'); + return ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f')); } API_EXPORT_INLINE FSTRING_INLINE b32_4tech char_is_hex_utf8(u8_4tech c) /* DOC(This call returns non-zero if c is any valid hexadecimal digit, or is a part of a UTF8 sequence outside of ASCII.) */{ - return (c >= '0' && c <= '9' || c >= 'A' && c <= 'F' || c >= 'a' && c <= 'f' || c >= 128); + return ((c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f') || (unsigned char)c >= 128); } API_EXPORT_INLINE FSTRING_INLINE b32_4tech @@ -168,7 +168,7 @@ char_is_numeric(char c) API_EXPORT_INLINE FSTRING_INLINE b32_4tech char_is_numeric_utf8(u8_4tech c) /* DOC(This call returns non-zero if c is any valid decimal digit, or is a part of a UTF8 sequence outside of ASCII.) */{ - return (c >= '0' && c <= '9' || c >= 128); + return ((c >= '0' && c <= '9') || (unsigned char)c >= 128); } @@ -1452,17 +1452,11 @@ space in dest this call returns non-zero.) */{ API_EXPORT FSTRING_LINK i32_4tech u64_to_str_size(uint64_t x)/* DOC(This call returns the number of bytes required to represent x as a string.) */{ - i32_4tech size; - if (x < 0){ - size = 0; - } - else{ - size = 1; + i32_4tech size = 1; + x /= 10; + while (x != 0){ x /= 10; - while (x != 0){ - x /= 10; - ++size; - } + ++size; } return(size); } diff --git a/string/string_builder.cpp b/string/string_builder.cpp index f589d8ab..88b7d69a 100644 --- a/string/string_builder.cpp +++ b/string/string_builder.cpp @@ -425,9 +425,8 @@ int main(){ else if (token->type == CPP_PP_INCLUDE){ token = get_next_token(&pcontext); - if (token && token->type == CPP_PP_INCLUDE_FILE){ - lexeme = get_lexeme(*token, pcontext.data);; + lexeme = get_lexeme(*token, pcontext.data); lexeme.size -= 2; lexeme.str += 1; @@ -481,7 +480,7 @@ int main(){ } #define FTECH_FILE_MOVING_IMPLEMENTATION -#include "..\meta\4tech_file_moving.h" +#include "../meta/4tech_file_moving.h" // BOTTOM