Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[Manta] r1894 - in trunk/Core: Containers Thread


Chronological Thread 
  • From: arobison@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [Manta] r1894 - in trunk/Core: Containers Thread
  • Date: Mon, 3 Dec 2007 12:40:06 -0700 (MST)

Author: arobison
Date: Mon Dec  3 12:40:03 2007
New Revision: 1894

Modified:
   trunk/Core/Containers/StringUtil.cc
   trunk/Core/Containers/StringUtil.h
   trunk/Core/Thread/Thread.cc
Log:
Fixing Thread.cc for WIN32 and adding an implementation of strcasecmp for 
systems that do not support is, like WIN32, use StrCaseCmp.

Modified: trunk/Core/Containers/StringUtil.cc
==============================================================================
--- trunk/Core/Containers/StringUtil.cc (original)
+++ trunk/Core/Containers/StringUtil.cc Mon Dec  3 12:40:03 2007
@@ -45,6 +45,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <ctype.h> // for toupper() (at least for linux RH8)
+#include <string.h> // for strcasecmp on *NIX
 
 namespace Manta {
 
@@ -224,9 +225,17 @@
   return str;
 }
 
-  
-
-
+int StrCaseCmp(const char* s1, const char* s2)
+{
+#ifdef _WIN32
+  int i=0;
+  while (tolower(s1[i]) == tolower(s2[i]) && s1[i]!='\0')
+    i++;
+  return (tolower(s1[i]) - tolower(s2[i]));
+#else
+  return strcasecmp(s1,s2);
+#endif
+}
 
 } // End namespace Manta
 

Modified: trunk/Core/Containers/StringUtil.h
==============================================================================
--- trunk/Core/Containers/StringUtil.h  (original)
+++ trunk/Core/Containers/StringUtil.h  Mon Dec  3 12:40:03 2007
@@ -62,6 +62,8 @@
   string string_toupper(string);
   string string_tolower(string);
 
+  int StrCaseCmp(const char* s1, const char* s2);
+
 //////////
 // Remove directory name
   string basename(const string &path);

Modified: trunk/Core/Thread/Thread.cc
==============================================================================
--- trunk/Core/Thread/Thread.cc (original)
+++ trunk/Core/Thread/Thread.cc Mon Dec  3 12:40:03 2007
@@ -47,13 +47,14 @@
 #include <Core/Thread/ThreadError.h>
 #include <Core/Thread/ThreadGroup.h>
 #include <Core/Thread/Time.h>
+#include <Core/Containers/StringUtil.h>
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string>
 
 #if defined(_AIX)
-// Needed for strcasecmp on aix 4.3 (on 5.1 we don't need this.)
+// Needed for StrCaseCmp on aix 4.3 (on 5.1 we don't need this.)
 // currently blue is 4.3.
 #  include <strings.h>
 #endif
@@ -67,7 +68,7 @@
 #include <process.h>
 #include <imagehlp.h>
 #include <psapi.h>
-#include <libexc.h>
+
 #elif defined(__GNUC__) && defined(__linux)
 #include <execinfo.h>
 #endif
@@ -299,7 +300,7 @@
     fprintf(stderr, "With NULL thread pointer.\n");
 
   for (;;) {
-    if (strcasecmp(smode, "ask") == 0) {
+    if (StrCaseCmp(smode, "ask") == 0) {
       char buf[100];
       fprintf(stderr, "resume(r)/dbx(d)/cvd(c)/kill thread(k)/exit(e)? ");
       fflush(stderr);
@@ -332,9 +333,9 @@
       }
     }
 
-    if (strcasecmp(smode, "resume") == 0) {
+    if (StrCaseCmp(smode, "resume") == 0) {
       return;
-    } else if (strcasecmp(smode, "dbx") == 0) {
+    } else if (StrCaseCmp(smode, "dbx") == 0) {
 
 #if defined( REDSTORM )
       printf("Error: running debugger at exception is not supported on 
RedStorm\n");
@@ -352,7 +353,7 @@
       system(command);
       smode = "ask";
 #endif
-    } else if (strcasecmp(smode, "cvd") == 0) {
+    } else if (StrCaseCmp(smode, "cvd") == 0) {
 #if defined( REDSTORM )
       printf("Error: running debugger at exception is not supported on 
RedStorm\n");
 #else
@@ -361,9 +362,9 @@
       system(command);
       smode = "ask";
 #endif
-    } else if (strcasecmp(smode, "kill") == 0) {
+    } else if (StrCaseCmp(smode, "kill") == 0) {
       exit();
-    } else if (strcasecmp(smode, "exit") == 0) {
+    } else if (StrCaseCmp(smode, "exit") == 0) {
       exitAll(1);
     } else {
       fprintf(stderr, "Unrecognized option, exiting\n");




  • [Manta] r1894 - in trunk/Core: Containers Thread, arobison, 12/03/2007

Archive powered by MHonArc 2.6.16.

Top of page