From 5e4dadbba021ba9dd34cd3e771b8580a3c4af301 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Sat, 22 Sep 2012 22:40:44 +0200 Subject: [PATCH] Replace Maxsi::String::Length with strlen. --- libmaxsi/format.cpp | 3 ++- sortix/directory.cpp | 8 ++++---- sortix/fs/devfs.cpp | 4 ++-- sortix/fs/initfs.cpp | 2 +- sortix/fs/ramfs.cpp | 4 ++-- sortix/fs/util.cpp | 2 +- sortix/fs/videofs.cpp | 6 +++--- sortix/kernelinfo.cpp | 2 +- sortix/mount.cpp | 4 ++-- sortix/process.cpp | 4 ++-- sortix/serialterminal.cpp | 6 +++--- 11 files changed, 23 insertions(+), 22 deletions(-) diff --git a/libmaxsi/format.cpp b/libmaxsi/format.cpp index d6eca29d..2daa08ff 100644 --- a/libmaxsi/format.cpp +++ b/libmaxsi/format.cpp @@ -25,6 +25,7 @@ #include #include #include +#include namespace Maxsi { @@ -309,7 +310,7 @@ namespace Maxsi { READY_FLUSH(); const char* str = va_arg(parameters, const char*); - size_t len = String::Length(str); + size_t len = strlen(str); if ( callback && callback(user, str, len) != len ) { return SIZE_MAX; } written += len; break; diff --git a/sortix/directory.cpp b/sortix/directory.cpp index 16f229b0..64679e70 100644 --- a/sortix/directory.cpp +++ b/sortix/directory.cpp @@ -95,7 +95,7 @@ namespace Sortix const char* wd = process->workingdir; char* abs = MakeAbsolute(wd, path); if ( !abs ) { errno = ENOMEM; return -1; } - size_t abslen = String::Length(abs); + size_t abslen = strlen(abs); if ( 1 < abslen && abs[abslen-1] == '/' ) { abs[abslen-1] = '\0'; @@ -122,7 +122,7 @@ namespace Sortix Process* process = CurrentProcess(); const char* wd = process->workingdir; if ( !wd ) { wd = "/"; } - size_t wdsize = String::Length(wd) + 1; + size_t wdsize = strlen(wd) + 1; if ( size < wdsize ) { errno = ERANGE; return NULL; } String::Copy(buf, wd); return buf; @@ -142,8 +142,8 @@ namespace Sortix if ( !wd ) { wd = "/"; } // The resulting size won't ever be larger than this. - size_t wdlen = String::Length(wd); - size_t resultsize = wdlen + String::Length(rel) + 2; + size_t wdlen = strlen(wd); + size_t resultsize = wdlen + strlen(rel) + 2; char* result = new char[resultsize + 1]; if ( !result ) { return NULL; } diff --git a/sortix/fs/devfs.cpp b/sortix/fs/devfs.cpp index 1bb727fc..ef4c27cd 100644 --- a/sortix/fs/devfs.cpp +++ b/sortix/fs/devfs.cpp @@ -324,7 +324,7 @@ namespace Sortix if ( available <= sizeof(sortix_dirent) ) { return -1; } - size_t namelen = String::Length(name); + size_t namelen = strlen(name); size_t needed = sizeof(sortix_dirent) + namelen + 1; if ( available < needed ) @@ -366,7 +366,7 @@ namespace Sortix if ( String::Compare(path, "/video") == 0 || String::StartsWith(path, "/video/") ) { - return DeviceFS::videofs->Open(path + String::Length("/video"), flags, mode); + return DeviceFS::videofs->Open(path + strlen("/video"), flags, mode); } Device* dev = DeviceFS::LookUp(path + 1); diff --git a/sortix/fs/initfs.cpp b/sortix/fs/initfs.cpp index 02b8884e..50b554c7 100644 --- a/sortix/fs/initfs.cpp +++ b/sortix/fs/initfs.cpp @@ -188,7 +188,7 @@ namespace Sortix } const char* name = InitRD::GetFilename(dir, position); - size_t namelen = String::Length(name); + size_t namelen = strlen(name); size_t needed = sizeof(sortix_dirent) + namelen + 1; if ( available < needed ) diff --git a/sortix/fs/ramfs.cpp b/sortix/fs/ramfs.cpp index 7d715d7a..a5a62b98 100644 --- a/sortix/fs/ramfs.cpp +++ b/sortix/fs/ramfs.cpp @@ -217,7 +217,7 @@ namespace Sortix const char* name = fs->GetFilename(position); if ( !name ) { return -1; } - size_t namelen = String::Length(name); + size_t namelen = strlen(name); size_t needed = sizeof(sortix_dirent) + namelen + 1; if ( available < needed ) @@ -260,7 +260,7 @@ namespace Sortix if ( *path++ != '/' ) { errno = ENOENT; return NULL; } - size_t pathlen = String::Length(path); + size_t pathlen = strlen(path); for ( size_t i = 0; i < pathlen; i++ ) { if ( path[i] == '/' ) { errno = ENOENT; return NULL; } diff --git a/sortix/fs/util.cpp b/sortix/fs/util.cpp index c07a64ac..b1bd707d 100644 --- a/sortix/fs/util.cpp +++ b/sortix/fs/util.cpp @@ -35,7 +35,7 @@ namespace Sortix { DevStringBuffer::DevStringBuffer(char* str) { this->str = str; - strlength = String::Length(str); + strlength = strlen(str); off = 0; } diff --git a/sortix/fs/videofs.cpp b/sortix/fs/videofs.cpp index 08513e53..c3426c30 100644 --- a/sortix/fs/videofs.cpp +++ b/sortix/fs/videofs.cpp @@ -166,7 +166,7 @@ Device* MakeModes(int flags, mode_t /*mode*/) size_t combinedlen = 0; for ( size_t i = 0; i < nummodes; i++ ) { - combinedlen += String::Length(modes[i]) + 1 /*newline*/; + combinedlen += strlen(modes[i]) + 1 /*newline*/; } size_t sofar = 0; char* modesstr = new char[combinedlen + 1]; @@ -174,7 +174,7 @@ Device* MakeModes(int flags, mode_t /*mode*/) for ( size_t i = 0; i < nummodes; i++ ) { String::Copy(modesstr + sofar, modes[i]); - sofar += String::Length(modes[i]); + sofar += strlen(modes[i]); modesstr[sofar++] = '\n'; } modesstr[sofar] = 0; @@ -269,7 +269,7 @@ int DevVideoFSDir::Read(sortix_dirent* dirent, size_t available) } const char* name = nodes[position].name; - size_t namelen = String::Length(name); + size_t namelen = strlen(name); size_t needed = sizeof(sortix_dirent) + namelen + 1; if ( available < needed ) diff --git a/sortix/kernelinfo.cpp b/sortix/kernelinfo.cpp index 0d368dc9..ec7099dc 100644 --- a/sortix/kernelinfo.cpp +++ b/sortix/kernelinfo.cpp @@ -50,7 +50,7 @@ ssize_t SysKernelInfo(const char* req, char* resp, size_t resplen) { const char* str = KernelInfo(req); if ( !str ) { errno = EINVAL; return -1; } - size_t stringlen = String::Length(str); + size_t stringlen = strlen(str); if ( resplen < stringlen + 1 ) { errno = ERANGE; diff --git a/sortix/mount.cpp b/sortix/mount.cpp index 7a44ad06..bc9f7821 100644 --- a/sortix/mount.cpp +++ b/sortix/mount.cpp @@ -72,7 +72,7 @@ namespace Sortix bool MatchesMountPath(const char* path, const char* mount) { - size_t mountlen = String::Length(mount); + size_t mountlen = strlen(mount); if ( !String::StartsWith(path, mount) ) { return false; } int c = path[mountlen]; return c == '/' || c == '\0'; @@ -88,7 +88,7 @@ namespace Sortix if ( MatchesMountPath(path, tmp->path) ) { result = tmp->fs; - *pathoffset = String::Length(tmp->path); + *pathoffset = strlen(tmp->path); } } diff --git a/sortix/process.cpp b/sortix/process.cpp index b4ff7f5d..f76eb7d4 100644 --- a/sortix/process.cpp +++ b/sortix/process.cpp @@ -529,7 +529,7 @@ namespace Sortix size_t argvsize = 0; for ( int i = 0; i < argc; i++ ) { - size_t len = String::Length(argv[i]) + 1; + size_t len = strlen(argv[i]) + 1; argvsize += len; char* dest = ((char*) argvpos) - argvsize; stackargv[i] = dest; @@ -547,7 +547,7 @@ namespace Sortix size_t envpsize = 0; for ( int i = 0; i < envc; i++ ) { - size_t len = String::Length(envp[i]) + 1; + size_t len = strlen(envp[i]) + 1; envpsize += len; char* dest = ((char*) envppos) - envpsize; stackenvp[i] = dest; diff --git a/sortix/serialterminal.cpp b/sortix/serialterminal.cpp index 9047f986..7c6e8961 100644 --- a/sortix/serialterminal.cpp +++ b/sortix/serialterminal.cpp @@ -41,7 +41,7 @@ namespace Sortix { // Set the cursor to (0,0) and clear the screen. const char InitMessage[] = "\e[37m\e[40m\e[2J\e[H"; - UART::Write(InitMessage, String::Length(InitMessage)); + UART::Write(InitMessage, strlen(InitMessage)); } bool isEsc; @@ -135,7 +135,7 @@ namespace Sortix if ( !cursordisabled ) { const char* msg = "\e[l"; - UART::Write(msg, String::Length(msg)); + UART::Write(msg, strlen(msg)); cursordisabled = true; } UART::RenderVGA((const uint16_t*) 0xB8000); @@ -150,7 +150,7 @@ namespace Sortix if ( cursordisabled ) { const char* msg = "\e[h"; - UART::Write(msg, String::Length(msg)); + UART::Write(msg, strlen(msg)); cursordisabled = false; } UART::Write(string, stringlen);