From e5cf6c18f706688008e932a1279bc6ca723cf74c Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Sat, 22 Sep 2012 22:53:11 +0200 Subject: [PATCH] Replace Maxsi::String::Compare with strcmp. --- games/asteroids.cpp | 2 +- libmaxsi/readparamstring.cpp | 3 ++- sortix/fs/devfs.cpp | 12 ++++++------ sortix/fs/ramfs.cpp | 4 ++-- sortix/fs/videofs.cpp | 4 ++-- sortix/initrd.cpp | 6 +++--- sortix/kernelinfo.cpp | 8 ++++---- sortix/mount.cpp | 4 ++-- sortix/video.cpp | 6 +++--- 9 files changed, 25 insertions(+), 24 deletions(-) diff --git a/games/asteroids.cpp b/games/asteroids.cpp index 0889c256..5871601f 100644 --- a/games/asteroids.cpp +++ b/games/asteroids.cpp @@ -1103,7 +1103,7 @@ extern "C" bool ReadParamString(const char* str, ...) while ( (keyname = va_arg(args, const char*)) ) { char** nameptr = va_arg(args, char**); - if ( String::Compare(keyname, name) ) { continue; } + if ( strcmp(keyname, name) ) { continue; } *nameptr = value; break; } diff --git a/libmaxsi/readparamstring.cpp b/libmaxsi/readparamstring.cpp index dfa2edbb..64c1ea20 100644 --- a/libmaxsi/readparamstring.cpp +++ b/libmaxsi/readparamstring.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include using namespace Maxsi; @@ -51,7 +52,7 @@ extern "C" bool ReadParamString(const char* str, ...) while ( (keyname = va_arg(args, const char*)) ) { char** nameptr = va_arg(args, char**); - if ( String::Compare(keyname, name) ) { continue; } + if ( strcmp(keyname, name) ) { continue; } *nameptr = value; break; } diff --git a/sortix/fs/devfs.cpp b/sortix/fs/devfs.cpp index ef4c27cd..82d84760 100644 --- a/sortix/fs/devfs.cpp +++ b/sortix/fs/devfs.cpp @@ -232,7 +232,7 @@ namespace Sortix { for ( size_t i = 0; i < entriesused; i++ ) { - if ( String::Compare(name, deventries[i].name) ) { continue; } + if ( strcmp(name, deventries[i].name) ) { continue; } deventries[i].dev->Refer(); return deventries[i].dev; } @@ -360,10 +360,10 @@ namespace Sortix return new DevDevFSDir(); } - if ( String::Compare(path, "/null") == 0 ) { return new DevNull; } - if ( String::Compare(path, "/tty") == 0 ) { tty->Refer(); return tty; } - if ( String::Compare(path, "/vga") == 0 ) { return new DevVGA; } - if ( String::Compare(path, "/video") == 0 || + if ( strcmp(path, "/null") == 0 ) { return new DevNull; } + if ( strcmp(path, "/tty") == 0 ) { tty->Refer(); return tty; } + if ( strcmp(path, "/vga") == 0 ) { return new DevVGA; } + if ( strcmp(path, "/video") == 0 || String::StartsWith(path, "/video/") ) { return DeviceFS::videofs->Open(path + strlen("/video"), flags, mode); @@ -387,7 +387,7 @@ namespace Sortix bool DevDevFS::Unlink(const char* path) { - if ( String::Compare(path, "/video") == 0 || + if ( strcmp(path, "/video") == 0 || String::StartsWith(path, "/video/") ) { return DeviceFS::videofs->Unlink(path); diff --git a/sortix/fs/ramfs.cpp b/sortix/fs/ramfs.cpp index a5a62b98..db1dcb1d 100644 --- a/sortix/fs/ramfs.cpp +++ b/sortix/fs/ramfs.cpp @@ -235,12 +235,12 @@ namespace Sortix int CompareFiles(DevRAMFSFile* file1, DevRAMFSFile* file2) { - return String::Compare(file1->name, file2->name); + return strcmp(file1->name, file2->name); } int LookupFile(DevRAMFSFile* file, const char* name) { - return String::Compare(file->name, name); + return strcmp(file->name, name); } Device* DevRAMFS::Open(const char* path, int flags, mode_t mode) diff --git a/sortix/fs/videofs.cpp b/sortix/fs/videofs.cpp index efd027a7..2029419f 100644 --- a/sortix/fs/videofs.cpp +++ b/sortix/fs/videofs.cpp @@ -295,7 +295,7 @@ DevVideoFS::~DevVideoFS() Device* DevVideoFS::Open(const char* path, int flags, mode_t mode) { - if ( !String::Compare(path, "") || !String::Compare(path, "/") ) + if ( !strcmp(path, "") || !strcmp(path, "/") ) { if ( (flags & O_LOWERFLAGS) == O_SEARCH ) { return new DevVideoFSDir; } errno = EISDIR; @@ -306,7 +306,7 @@ Device* DevVideoFS::Open(const char* path, int flags, mode_t mode) for ( size_t i = 0; i < NumNodes(); i++ ) { - if ( String::Compare(path, nodes[i].name) ) { continue; } + if ( strcmp(path, nodes[i].name) ) { continue; } return nodes[i].factory(flags, mode); } errno = ENOENT; diff --git a/sortix/initrd.cpp b/sortix/initrd.cpp index e56715d9..90a05dff 100644 --- a/sortix/initrd.cpp +++ b/sortix/initrd.cpp @@ -119,7 +119,7 @@ uint32_t Traverse(uint32_t ino, const char* name) { uint32_t pos = inode->dataoffset + offset; const initrd_dirent* dirent = (const initrd_dirent*) (initrd + pos); - if ( dirent->namelen && !String::Compare(dirent->name, name) ) + if ( dirent->namelen && !strcmp(dirent->name, name) ) { return dirent->inode; } @@ -222,12 +222,12 @@ void Init(addr_t phys, size_t size) "has been passed to the kernel."); } - if ( String::Compare(sb->magic, "sortix-initrd-1") == 0 ) + if ( strcmp(sb->magic, "sortix-initrd-1") == 0 ) { Panic("Sortix initrd format version 1 is no longer supported."); } - if ( String::Compare(sb->magic, "sortix-initrd-2") != 0 ) + if ( strcmp(sb->magic, "sortix-initrd-2") != 0 ) { Panic("The initrd has a format that isn't supported. Perhaps it is " "too new? Try downgrade or regenerate the initrd."); diff --git a/sortix/kernelinfo.cpp b/sortix/kernelinfo.cpp index 6760cf47..cf9b0d61 100644 --- a/sortix/kernelinfo.cpp +++ b/sortix/kernelinfo.cpp @@ -39,10 +39,10 @@ namespace Info { const char* KernelInfo(const char* req) { - if ( String::Compare(req, "name") == 0 ) { return "Sortix"; } - if ( String::Compare(req, "version") == 0 ) { return VERSIONSTR; } - if ( String::Compare(req, "builddate") == 0 ) { return __DATE__; } - if ( String::Compare(req, "buildtime") == 0 ) { return __TIME__; } + if ( strcmp(req, "name") == 0 ) { return "Sortix"; } + if ( strcmp(req, "version") == 0 ) { return VERSIONSTR; } + if ( strcmp(req, "builddate") == 0 ) { return __DATE__; } + if ( strcmp(req, "buildtime") == 0 ) { return __TIME__; } return NULL; } diff --git a/sortix/mount.cpp b/sortix/mount.cpp index bc9f7821..22a2ea1f 100644 --- a/sortix/mount.cpp +++ b/sortix/mount.cpp @@ -105,7 +105,7 @@ namespace Sortix if ( !root ) { root = mp; return true; } - if ( String::Compare(path, root->path) < 0 ) + if ( strcmp(path, root->path) < 0 ) { mp->next = root; root->prev = mp; @@ -115,7 +115,7 @@ namespace Sortix for ( MountPoint* tmp = root; tmp; tmp = tmp->next ) { - if ( tmp->next == NULL || String::Compare(path, tmp->next->path) < 0 ) + if ( tmp->next == NULL || strcmp(path, tmp->next->path) < 0 ) { mp->next = tmp->next; tmp->next = mp; diff --git a/sortix/video.cpp b/sortix/video.cpp index 28baea4d..0ffa2da8 100644 --- a/sortix/video.cpp +++ b/sortix/video.cpp @@ -56,10 +56,10 @@ bool ReadParamString(const char* str, ...) va_start(args, str); while ( (keyname = va_arg(args, const char*)) ) { - if ( String::Compare(keyname, "STOP") == 0 ) + if ( strcmp(keyname, "STOP") == 0 ) break; char** nameptr = va_arg(args, char**); - if ( String::Compare(keyname, name) ) { continue; } + if ( strcmp(keyname, name) ) { continue; } *nameptr = value; break; } @@ -208,7 +208,7 @@ static DriverEntry* GetDriverEntry(const char* drivername) { for ( size_t i = 0; i < numdrivers; i++ ) { - if ( !String::Compare(drivername, drivers[i].name) ) + if ( !strcmp(drivername, drivers[i].name) ) { return drivers + i; }