diff --git a/4coder_lib/4coder_string.h b/4coder_lib/4coder_string.h index e45c653b..4ecec8c0 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.74 no warranty implied; use at your own risk This software is in the public domain. Where that dedication is not @@ -12,37 +12,6 @@ To use in C mode: #define FSTRING_C // TOP -// 4tech_standard_preamble.h -#if !defined(FTECH_INTEGERS) -#define FTECH_INTEGERS -#include -typedef int8_t i8_4tech; -typedef int16_t i16_4tech; -typedef int32_t i32_4tech; -typedef int64_t i64_4tech; - -typedef uint8_t u8_4tech; -typedef uint16_t u16_4tech; -typedef uint32_t u32_4tech; -typedef uint64_t u64_4tech; - -#if defined(FTECH_32_BIT) -typedef u32_4tech umem_4tech; -#else -typedef u64_4tech umem_4tech; -#endif - -typedef float f32_4tech; -typedef double f64_4tech; - -typedef int8_t b8_4tech; -typedef int32_t b32_4tech; -#endif - -#if !defined(Assert) -# define Assert(n) do{ if (!(n)) *(int*)0 = 0xA11E; }while(0) -#endif -// standard preamble end #if !defined(FSTRING_LINK) @@ -297,7 +266,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 +274,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 +282,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 +298,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 +314,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 +322,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,7 +330,7 @@ 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 == '_'); @@ -369,15 +338,15 @@ char_is_alpha_numeric(char 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'); @@ -385,15 +354,15 @@ char_is_alpha_numeric_true(char c) #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 == '_'); @@ -401,15 +370,15 @@ char_is_alpha(char 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'); @@ -417,15 +386,15 @@ char_is_alpha_true(char c) #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'); @@ -433,15 +402,15 @@ char_is_hex(char c) #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 +418,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 +432,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 +443,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 +454,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 +464,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 +477,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 +489,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 +504,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 +517,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 +530,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 +542,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 +553,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 +563,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 +581,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 +596,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 +613,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 +621,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 +637,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 +652,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 +667,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 +676,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 +685,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 +698,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 +714,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 +730,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 +748,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 +756,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 +773,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 +788,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 +804,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 +813,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 +822,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 +835,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 +851,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 +864,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 +887,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 +896,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 +924,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 +934,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 +944,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 +954,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 +971,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 +988,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 +1017,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 +1046,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 +1077,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 +1111,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 +1147,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 +1155,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 +1163,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 +1171,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 +1183,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 +1197,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 +1210,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 +1228,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 +1243,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 +1262,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 +1281,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 +1299,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 +1307,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 +1315,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 +1323,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 +1337,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 +1348,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 +1359,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 +1372,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 +1380,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 +1399,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 +1422,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 +1434,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 +1445,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 +1463,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 +1476,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 +1487,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 +1505,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 +1518,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 +1548,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 +1564,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 +1611,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 +1623,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 +1675,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 +1710,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 +1719,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 +1737,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 +1748,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 +1763,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 +1778,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 +1797,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 +1815,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 +1832,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 +1858,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 +1887,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 +1912,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 +1923,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 +1945,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 +1964,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 +1982,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 +1994,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 +2010,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 +2025,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 +2042,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 +2050,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 +2064,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 +2089,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 +2120,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/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/meta/4tech_file_moving.h b/meta/4tech_file_moving.h index e461f78f..c13ee36d 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 @@ -281,8 +288,145 @@ 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); +} + +static void +popdir(Temp_Dir temp){ + chdir(temp.dir); +} + +static void +init_time_system(){ + // NOTE(allen): do nothing +} + +static uint64_t +get_time(){ + struct timespec spec; + uint64_t result; + clock_gettime(CLOCK_MONOTONIC, &spec); + result = (spec.tv_sec * (uint64_t)(1000000)) + (spec.tv_nsec / (uint64_t)(1000)); + return(result); +} + +static int32_t +get_current_directory(char *buffer, int32_t max){ + int32_t result = 0; + char *d = getcwd(buffer, max); + if (d == buffer){ + result = strlen(buffer); + } + return(result); +} + +static void +execute_in_dir(char *dir, char *str, char *args){ + if (dir){ + if (args){ + Temp_Dir temp = pushdir(dir); + systemf("%s %s", str, args); + popdir(temp); + } + else{ + Temp_Dir temp = pushdir(dir); + systemf("%s", str); + popdir(temp); + } + } + else{ + if (args){ + systemf("%s %s", str, args); + } + else{ + systemf("%s", str); + } + } +} + +static void +slash_fix(char *path){} + +static void +make_folder_if_missing(char *dir, char *folder){ + if (folder){ + systemf("mkdir -p %s/%s", dir, folder); + } + else{ + systemf("mkdir -p %s", dir); + } +} + +static void +clear_folder(char *folder){ + systemf("rm -rf %s*", folder); +} + +static void +delete_file(char *file){ + systemf("rm %s", file); +} + +static void +copy_file(char *path, char *file, char *folder1, char *folder2, char *newname){ + if (!newname){ + newname = file; + } + + if (path){ + if (folder2){ + systemf("cp %s/%s %s/%s/%s", path, file, folder1, folder2, newname); + } + else{ + systemf("cp %s/%s %s/%s", path, file, folder1, newname); + } + } + else{ + if (folder2){ + systemf("cp %s %s/%s/%s", file, folder1, folder2, newname); + } + else{ + systemf("cp %s %s/%s", file, folder1, newname); + } + } +} + +static void +copy_all(char *source, char *tag, char *folder){ + if (source){ + systemf("cp -f %s/%s %s", source, tag, folder); + } + else{ + systemf("cp -f %s %s", tag, folder); + } +} + +static void +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); +} + +#elif defined(IS_MAC) + +#include +#include + +static Temp_Dir +pushdir(char *dir){ + Temp_Dir temp; + char *result = getcwd(temp.dir, sizeof(temp.dir)); + int32_t chresult = chdir(dir); + if (result == 0 || chresult != 0){ + printf("trying pushdir %s\n", dir); + Assert(result != 0); + Assert(chresult == 0); } return(temp); } diff --git a/string/4coder_string_build_num.txt b/string/4coder_string_build_num.txt index 9fab48ce..37d2f1ab 100644 --- a/string/4coder_string_build_num.txt +++ b/string/4coder_string_build_num.txt @@ -1,5 +1,5 @@ 1 0 -74 +76 diff --git a/string/build.sh b/string/build.sh new file mode 100755 index 00000000..0a380ee1 --- /dev/null +++ b/string/build.sh @@ -0,0 +1,10 @@ +#!/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..85cad789 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 @@ -108,7 +108,7 @@ char_is_alpha_numeric(char 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 @@ -120,7 +120,7 @@ char_is_alpha_numeric_true(char c) 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 @@ -132,7 +132,7 @@ char_is_alpha(char 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 @@ -144,7 +144,7 @@ char_is_alpha_true(char c) 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 @@ -156,7 +156,7 @@ char_is_hex(char c) 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..9dd1d219 100644 --- a/string/string_builder.cpp +++ b/string/string_builder.cpp @@ -481,7 +481,7 @@ int main(){ } #define FTECH_FILE_MOVING_IMPLEMENTATION -#include "..\meta\4tech_file_moving.h" +#include "../meta/4tech_file_moving.h" // BOTTOM