[Scummvm-cvs-logs] SF.net SVN: scummvm: [28231] scummvm/trunk

eriktorbjorn at users.sourceforge.net eriktorbjorn at users.sourceforge.net
Fri Jul 27 07:15:24 CEST 2007


Revision: 28231
          http://scummvm.svn.sourceforge.net/scummvm/?rev=28231&view=rev
Author:   eriktorbjorn
Date:     2007-07-26 22:15:24 -0700 (Thu, 26 Jul 2007)

Log Message:
-----------
Early in the morning, strrev() looks like a more difficult problem than it
really is. It's actually quite simple. In fact, the only magical thing about
Bob's version was the way it swapped variables without using any temporary
variable. Rewrote the function to use our SWAP() instead, since that actually
makes it readable. Moved it to util.cpp (outside the Common namespace, for
consistency with scumm_stricmp()) since Kirben knew of other places where it
could be used.

Modified Paths:
--------------
    scummvm/trunk/common/util.cpp
    scummvm/trunk/common/util.h
    scummvm/trunk/engines/drascula/drascula.cpp

Modified: scummvm/trunk/common/util.cpp
===================================================================
--- scummvm/trunk/common/util.cpp	2007-07-27 04:23:22 UTC (rev 28230)
+++ scummvm/trunk/common/util.cpp	2007-07-27 05:15:24 UTC (rev 28231)
@@ -592,3 +592,16 @@
 #endif
 #endif
 }
+
+char *scumm_strrev(char *str) {
+	if (!str)
+		return str;
+	int len = strlen(str);
+	if (len < 2)
+		return str;
+	char *p1, *p2;
+	for (p1 = str, p2 = str + len - 1; p1 < p2; p1++, p2--) {
+		SWAP(*p1, *p2);
+	}
+	return str;
+}

Modified: scummvm/trunk/common/util.h
===================================================================
--- scummvm/trunk/common/util.h	2007-07-27 04:23:22 UTC (rev 28230)
+++ scummvm/trunk/common/util.h	2007-07-27 05:15:24 UTC (rev 28231)
@@ -289,5 +289,6 @@
 
 extern int gDebugLevel;
 
+char *scumm_strrev(char *str);
 
 #endif

Modified: scummvm/trunk/engines/drascula/drascula.cpp
===================================================================
--- scummvm/trunk/engines/drascula/drascula.cpp	2007-07-27 04:23:22 UTC (rev 28230)
+++ scummvm/trunk/engines/drascula/drascula.cpp	2007-07-27 05:15:24 UTC (rev 28231)
@@ -18,7 +18,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  *
- * $UR$
+ * $URL$
  * $Id$
  *
  */
@@ -29,6 +29,7 @@
 #include "common/file.h"
 #include "common/savefile.h"
 #include "common/config-manager.h"
+//#include "common/util.h"
 
 #include "base/plugins.h"
 #include "base/version.h"
@@ -2080,22 +2081,6 @@
 	return (valor & 0x3F) * (valor > 0);
 }
 
-// Public domain strrev() function by Bob Stout.
-// Should perhaps be moved to common/util.cpp or similar.
-
-static char *scumm_strrev(char *str) {
-	char *p1, *p2;
-
-	if (!str || !*str)
-		return str;
-	for (p1 = str, p2 = str + strlen(str) - 1; p2 > p1; ++p1, --p2) {
-		*p1 ^= *p2;
-		*p2 ^= *p1;
-		*p1 ^= *p2;
-	}
-	return str;
-}
-
 void DrasculaEngine::centra_texto(char mensaje[], int x_texto, int y_texto) {
 	char bb[190], m2[190], m1[190] ,mb[10][40];
 	char m3[190];


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list