fix: String_IsNull/String_Offset helpers + remove pointer-to-int casts

- Add String_IsNull and String_Offset wrappers in lib/String.bux
- Add bux_str_is_null and bux_str_offset runtime functions in rt/runtime.c
- Update String_Replace to use String_IsNull instead of String_Len(pos)==0
- Replace pointer-to-uint casts (as uint == 0, pointer arithmetic) across apps/
- Parser newline skipping fixes in src/parser.bux
This commit is contained in:
2026-06-08 20:23:30 +03:00
parent 3c7938163c
commit 7d1d722cba
7 changed files with 61 additions and 34 deletions
+11
View File
@@ -232,11 +232,22 @@ const char* bux_strstr(const char* haystack, const char* needle) {
return strstr(haystack, needle);
}
/* String offset: byte offset of pos within base (both must point into same string) */
unsigned int bux_str_offset(const char* pos, const char* base) {
if (!pos || !base) return 0;
return (unsigned int)(pos - base);
}
/* String contains: returns 1 if haystack contains needle, 0 otherwise */
int bux_str_contains(const char* haystack, const char* needle) {
return bux_strstr(haystack, needle) != NULL;
}
/* String is null: returns 1 if string is NULL */
int bux_str_is_null(const char* s) {
return s == NULL;
}
/* String slice: extract substring from start, length len */
char* bux_str_slice(const char* s, unsigned int start, unsigned int len) {
if (!s) return NULL;