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;
}
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) {
String col = {};
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;
}
API String16 SkipNumberEx(String16 *string) {
String16 col = {string->data, 0};
for (int64_t i = 0; i < string->len; i += 1) {

View File

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