diff options
author | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-01-12 14:01:16 +0000 |
---|---|---|
committer | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-01-12 14:01:16 +0000 |
commit | 4489cc101f1681425f9db184bb3f1cba1b5c7820 (patch) | |
tree | 343e7873c7702fae8ee81494dec614c054a59845 /crawl-ref/source/macro.cc | |
parent | fed7cd6012682b1638463bdc5a0303089c967846 (diff) | |
download | crawl-ref-4489cc101f1681425f9db184bb3f1cba1b5c7820.tar.gz crawl-ref-4489cc101f1681425f9db184bb3f1cba1b5c7820.zip |
Fixed macro bug reported on the antichri^W^W Windows Vista.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3254 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/macro.cc')
-rw-r--r-- | crawl-ref/source/macro.cc | 38 |
1 files changed, 9 insertions, 29 deletions
diff --git a/crawl-ref/source/macro.cc b/crawl-ref/source/macro.cc index e069e630dd..94b640db2b 100644 --- a/crawl-ref/source/macro.cc +++ b/crawl-ref/source/macro.cc @@ -36,6 +36,7 @@ #include <iostream> #include <fstream> #include <string> +#include <sstream> #include <map> #include <deque> #include <vector> @@ -306,8 +307,7 @@ static keyseq parse_keyseq( std::string s ) else { const int key = read_key_code(arg); - if (key) - v.push_back(key); + v.push_back(key); } state = 0; @@ -326,7 +326,7 @@ static keyseq parse_keyseq( std::string s ) */ static std::string vtostr( const keyseq &seq ) { - std::string s; + std::ostringstream s; const keyseq *v = &seq; keyseq dummy; @@ -344,41 +344,21 @@ static std::string vtostr( const keyseq &seq ) { if (*i <= 32 || *i > 127) { if (*i == KEY_MACRO_MORE_PROTECT) - s += "\\{!more}"; + s << "\\{!more}"; else { char buff[20]; snprintf( buff, sizeof(buff), "\\{%d}", *i ); - s += std::string( buff ); + s << buff; } - - // Removing the stringstream code because its highly - // non-portable. For starters, people and compilers - // are supposed to be using the <sstream> implementation - // (with the ostringstream class) not the old <strstream> - // version, but <sstream> is not as available as it should be. - // - // The strstream implementation isn't very standard - // either: some compilers require the "ends" marker, - // others don't (and potentially fatal errors can - // happen if you don't have it correct for the system... - // ie its hard to make portable). It also isn't a very - // good implementation to begin with. - // - // Everyone should have snprintf()... we supply a version - // in libutil.cc to make sure of that! -- bwr - // - // std::ostrstream ss; - // ss << "\\{" << *i << "}" << ends; - // s += ss.str(); } else if (*i == '\\') { - s += "\\\\"; + s << "\\\\"; } else { - s += *i; + s << static_cast<char>(*i); } - } + } - return (s); + return (s.str()); } /* |