From 0cd941ed304ebc793916d58f49ab6032f68257e7 Mon Sep 17 00:00:00 2001 From: brain Date: Tue, 13 Dec 2005 22:21:33 +0000 Subject: De-messified GetRevision git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2383 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/inspircd.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 6d664389d..042cad1a7 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -215,14 +215,19 @@ void DeleteOper(userrec* user) std::string GetRevision() { - char Revision[] = "$Revision$"; - char *s1 = Revision; - char *savept; - char *v2 = strtok_r(s1," ",&savept); - s1 = savept; - v2 = strtok_r(s1," ",&savept); - s1 = savept; - return std::string(v2); + /* w00t got me to replace a bunch of strtok_r + * with something nicer, so i did this. Its the + * same thing really, only in C++. It places the + * text into a std::stringstream which is a readable + * and writeable buffer stream, and then pops two + * words off it, space delimited. Because it reads + * into the same variable twice, the first word + * is discarded, and the second one returned. + */ + std::stringstream Revision("$Revision$"); + std::string single; + Revision >> single >> single; + return single; } -- cgit v1.2.3