From ac440aa321225dfe49d9fcdad0d8fd3af9fdb7f1 Mon Sep 17 00:00:00 2001 From: Kent Williams Date: Fri, 11 Apr 2003 16:22:57 -0400 Subject: [PATCH] remove redundant function and eliminate need for strcasecmp --- Source/kwsys/SystemTools.cxx | 58 +++++++-------------------------- Source/kwsys/SystemTools.hxx.in | 5 --- 2 files changed, 12 insertions(+), 51 deletions(-) diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx index 5f6b93f9e..624df6d43 100644 --- a/Source/kwsys/SystemTools.cxx +++ b/Source/kwsys/SystemTools.cxx @@ -1032,14 +1032,18 @@ unsigned long SystemTools::FileLength(const char* filename) int SystemTools::Strucmp(const char *s1, const char *s2) { -#if defined(_WIN32) -#ifdef __BORLANDC__ - return stricmp(s1,s2); -#else - return _stricmp(s1,s2); -#endif -#else - return strcasecmp(s1,s2); +// return strcasecmp(s1,s2); +// +// lifted from Graphvis http://www.graphviz.org + while ((*s1 != '\0') + && (tolower(*(unsigned char *)s1) == tolower(*(unsigned char *)s2))) + { + s1++; + s2++; + } + + return tolower(*(unsigned char *) s1) - tolower(*(unsigned char *) s2); + #endif } @@ -1069,44 +1073,6 @@ bool SystemTools::RemoveFile(const char* source) return unlink(source) != 0 ? false : true; } -char *SystemTools -::RealPath(const char *path, char *resolved_path) -{ -#if defined(_WIN32) - char pathpart[4096]; - strcpy(pathpart,path); - char fnamepart[4096]; - char *slash; - - if((slash = strrchr(pathpart,'/')) == NULL) - { - slash = strrchr(pathpart,'\\'); - } - - if(slash == NULL) // no path part, so just use current dir. - { - Getcwd(pathpart,sizeof(pathpart)); - strcpy(fnamepart,path); - } - else // change directory to path part, getcwd to find OS resolved path - { - *slash = '\0'; - strcpy(fnamepart,slash+1); - - char savedir[4096]; - Getcwd(savedir,sizeof(savedir)); - Chdir(pathpart); - Getcwd(pathpart,sizeof(pathpart)); - Chdir(savedir); - } - strcpy(resolved_path,pathpart); - strcat(resolved_path,"/"); - strcat(resolved_path,fnamepart); - return resolved_path; -#else - return realpath(path,resolved_path); -#endif -} /** * Find the file the given name. Searches the given path and then diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in index 82e162703..7c7d30255 100644 --- a/Source/kwsys/SystemTools.hxx.in +++ b/Source/kwsys/SystemTools.hxx.in @@ -129,11 +129,6 @@ public: static bool FileExists(const char* filename); static unsigned long FileLength(const char *filename); - /** - * given a (possibly) relative path, return the completely - * qualified path to a file system entity - */ - static char *RealPath(const char *path, char *resolved_path); /** * Add the paths from the environment variable PATH to the * string vector passed in.