feat(libkern): strrchr (StringFindLastOccurenceOfCharacter)

fix(OSServiceProcessSpawn): now it uses strrchr to get process name
This commit is contained in:
Karina
2026-02-01 21:02:54 +04:00
parent 4e10985909
commit 2f58f64175
3 changed files with 20 additions and 2 deletions
+2 -1
View File
@@ -10,4 +10,5 @@ Int32 StringCompare(const char* firstString, const char* secondString);
Int32 StringCompareWithLimit(const char* firstString, const char* secondString, UInt64 limit);
char* StringCopy(char* destination, const char* source);
char* StringCopyWithLimit(char* destination, const char* source, UInt64 limit);
UInt64 StringGetLength(const char* string);
UInt64 StringGetLength(const char* string);
const char* StringFindLastOccurrenceOfCharacter(const char* string, char separator);
+9 -1
View File
@@ -7,6 +7,9 @@
#include <OS/Exec/OSLoader.h>
#include <IO/IOConsole.h>
#include <lib/String.h>
Int32 OSServiceProcessExit(Int32 code) {
IOConsoleLog("\n[Dewar] process \"%s\" exited with code %d\n", gOSSchedulerCurrentTask->process->name, code);
OSSchedulerTerminate();
@@ -15,7 +18,12 @@ Int32 OSServiceProcessExit(Int32 code) {
Int32 OSServiceProcessSpawn(const char* path) {
return OSLoaderProcessSpawn(path, path);
const char* name = StringFindLastOccurrenceOfCharacter(path, '/');
if (name) name++;
else name = path;
return OSLoaderProcessSpawn(path, name);
}
Int32 OSServiceProcessWait(UInt64 processID) {
+9
View File
@@ -74,4 +74,13 @@ UInt64 StringGetLength(const char* string) {
UInt64 result = 0;
for (result = 0; string[result]; result++);
return result;
}
const char* StringFindLastOccurrenceOfCharacter(const char* string, char separator) {
const char* lastSeparator = nullptr;
do {
if (*string == separator) lastSeparator = (char*)string;
} while (*string++);
return lastSeparator;
}