This commit is contained in:
Krzosa Karol
2025-12-25 11:52:02 +01:00
parent b98d14f9dd
commit 2f638c731a
3 changed files with 86 additions and 33 deletions

View File

@@ -350,6 +350,48 @@ API bool Chop(String *string, String ending) {
return false; return false;
} }
API String SkipNumberEx(String *string) {
String col = {string->data, 0};
for (int64_t i = 0; i < string->len; i += 1) {
if (IsDigit(string->data[i])) {
col.len += 1;
} else {
break;
}
}
*string = Skip(*string, col.len);
return col;
}
API Int SkipNumber(String *string) {
String col = SkipNumberEx(string);
if (col.len == 0) return -1;
Int result = strtoll(col.data, NULL, 10);
return result;
}
API String SkipUntil(String *string, String str) {
String begin = *string;
begin.len = 0;
for (; string->len; begin.len += 1) {
String match = GetPrefix(*string, str.len);
if (StartsWith(match, str)) break;
*string = Skip(*string, 1);
}
return begin;
}
API String SkipWhitespace(String *string) {
String begin = {string->data, 0};
for (Int i = 0; i < string->len; i += 1) {
if (!IsWhitespace(string->data[i])) break;
*string = Skip(*string, 1);
begin.len += 1;
}
return begin;
}
API String ChopNumberEx(String *string) { API String ChopNumberEx(String *string) {
String col = {}; String col = {};
for (int64_t i = string->len - 1; i >= 0; i -= 1) { for (int64_t i = string->len - 1; i >= 0; i -= 1) {

View File

@@ -356,7 +356,6 @@ API Int GetSize(Array<String16> array) {
return result; return result;
} }
API String16 SkipNumberEx(String16 *string) { API String16 SkipNumberEx(String16 *string) {
String16 col = {string->data, 0}; String16 col = {string->data, 0};
for (int64_t i = 0; i < string->len; i += 1) { for (int64_t i = 0; i < string->len; i += 1) {

View File

@@ -458,7 +458,11 @@ BSet ExecBuild(String cmd) {
} }
void Command_Build() { void Command_Build() {
#if OS_WINDOWS
ExecBuild("build.bat"); ExecBuild("build.bat");
#else
ExecBuild("./build.sh");
#endif
} RegisterCommand(Command_Build, "f1"); } RegisterCommand(Command_Build, "f1");
void Command_GotoNextInList() { void Command_GotoNextInList() {
@@ -534,7 +538,7 @@ ResolvedOpen ResolveOpen(Allocator scratch, String path, String meta) {
{ {
String p = NormalizePath(scratch, path); String p = NormalizePath(scratch, path);
String pstart = p; String pstart = p;
asd
bool is_absolute = false; bool is_absolute = false;
if (IsAlphabetic(ToLowerCase(At(p, 0))) && At(p, 1) == ':' && At(p, 2) == '/') { if (IsAlphabetic(ToLowerCase(At(p, 0))) && At(p, 1) == ':' && At(p, 2) == '/') {
is_absolute = true; is_absolute = true;
@@ -547,25 +551,25 @@ asd
while (!IsOpenBoundary(At(p, 0))) { while (!IsOpenBoundary(At(p, 0))) {
p = Skip(p, 1); p = Skip(p, 1);
} }
} path = {pstart.data, (Int)(p.data - pstart.data)};
// Parse ":line:column" if (At(p, 0) == ':') {
// { p = Skip(p, 1);
// path = NormalizePath(scratch, path); result.line = SkipNumber(&p);
// String p = path; if (At(p, 0) == ':') {
// Int a = ChopNumber(&p); p = Skip(p, 1);
// if (a != -1 && Chop(&p, ":")) { Int b = SkipNumber(&p);
// path = p; result.col = b;
// Int b = ChopNumber(&p); }
// if (b != -1 && Chop(&p, ":")) { } else if (At(p, 0) == '(') {
// path = p; p = Skip(p, 1);
// result.col = a; result.line = SkipNumber(&p);
// result.line = b; if (At(p, 0) == ',') {
// } else { p = Skip(p, 1);
// result.line = a; Int b = SkipNumber(&p);
// } result.col = b;
// } }
// } }
Buffer *existing_buffer = GetBuffer(path, NULL); Buffer *existing_buffer = GetBuffer(path, NULL);
if (existing_buffer != NULL) { if (existing_buffer != NULL) {
@@ -574,13 +578,18 @@ asd
return result; return result;
} }
if (IsAbsolute(path)) { if (is_absolute && FileExists(path)) {
if (FileExists(path)) {
result.path = path; result.path = path;
result.kind = OpenKind_Goto; result.kind = OpenKind_Goto;
return result; return result;
}
} else { } else {
String workspace_path = Format(scratch, "%S/%S", WorkDir, path);
if (GetBuffer(workspace_path, NULL) || FileExists(workspace_path)) {
result.path = workspace_path;
result.kind = OpenKind_Goto;
return result;
}
String rel_path = Format(scratch, "%S/%S", GetMainDir(), path); String rel_path = Format(scratch, "%S/%S", GetMainDir(), path);
if (GetBuffer(rel_path, NULL) || FileExists(rel_path)) { if (GetBuffer(rel_path, NULL) || FileExists(rel_path)) {
result.path = rel_path; result.path = rel_path;
@@ -589,8 +598,11 @@ asd
} }
} }
}
if (meta == "dont_error") { if (meta == "dont_error") {
result.kind = OpenKind_Skip; result.kind = OpenKind_Skip;
return result;
} }
return result; return result;