[Orxonox-commit 3941] r8615 - in code/branches/presentation/src/libraries: core/command util
landauf at orxonox.net
landauf at orxonox.net
Thu May 26 18:01:35 CEST 2011
Author: landauf
Date: 2011-05-26 18:01:34 +0200 (Thu, 26 May 2011)
New Revision: 8615
Modified:
code/branches/presentation/src/libraries/core/command/Shell.cc
code/branches/presentation/src/libraries/util/Math.h
Log:
turns out the mod(x,y) function was fucked up all the time. we need unit tests! also there was a small bug in the shell history. fixed both.
Modified: code/branches/presentation/src/libraries/core/command/Shell.cc
===================================================================
--- code/branches/presentation/src/libraries/core/command/Shell.cc 2011-05-26 15:40:16 UTC (rev 8614)
+++ code/branches/presentation/src/libraries/core/command/Shell.cc 2011-05-26 16:01:34 UTC (rev 8615)
@@ -264,7 +264,7 @@
if (command == "")
return;
- size_t previous_offset = mod(this->historyOffset_ - 1, this->maxHistoryLength_);
+ size_t previous_offset = mod(static_cast<int>(this->historyOffset_) - 1, this->maxHistoryLength_);
if (previous_offset < this->commandHistory_.size() && command == this->commandHistory_[previous_offset])
return;
Modified: code/branches/presentation/src/libraries/util/Math.h
===================================================================
--- code/branches/presentation/src/libraries/util/Math.h 2011-05-26 15:40:16 UTC (rev 8614)
+++ code/branches/presentation/src/libraries/util/Math.h 2011-05-26 16:01:34 UTC (rev 8615)
@@ -173,7 +173,10 @@
if (x >= 0)
return (x % max);
else
- return ((x % max) + max);
+ {
+ T temp = x % max;
+ return (temp < 0) ? (temp + max) : temp;
+ }
}
/**
More information about the Orxonox-commit
mailing list