aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorTorbjörn Andersson2007-07-27 05:15:24 +0000
committerTorbjörn Andersson2007-07-27 05:15:24 +0000
commitc2516db9ac72c835cd72bafee35bff1743bda81e (patch)
tree4175bd8f92ba6964a315b11136fdca9ad1e33149 /common
parent548a1394e1c3279b7674ac8ab7d8b3206f19e787 (diff)
downloadscummvm-rg350-c2516db9ac72c835cd72bafee35bff1743bda81e.tar.gz
scummvm-rg350-c2516db9ac72c835cd72bafee35bff1743bda81e.tar.bz2
scummvm-rg350-c2516db9ac72c835cd72bafee35bff1743bda81e.zip
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. svn-id: r28231
Diffstat (limited to 'common')
-rw-r--r--common/util.cpp13
-rw-r--r--common/util.h1
2 files changed, 14 insertions, 0 deletions
diff --git a/common/util.cpp b/common/util.cpp
index fc5fe9a4e5..b38dfa6664 100644
--- a/common/util.cpp
+++ b/common/util.cpp
@@ -592,3 +592,16 @@ void CDECL warning(const char *s, ...) {
#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;
+}
diff --git a/common/util.h b/common/util.h
index 2325ba523a..0d63af0878 100644
--- a/common/util.h
+++ b/common/util.h
@@ -289,5 +289,6 @@ void CDECL debugC(int level, uint32 engine_level, const char *s, ...) GCC_PRINTF
extern int gDebugLevel;
+char *scumm_strrev(char *str);
#endif