Avoid use of static attribute in functions
[anna.git] / source / core / functions.cpp
index 1a6a291..1dd3025 100644 (file)
@@ -1,37 +1,9 @@
-// ANNA - Anna is Not Nothingness Anymore
-//
-// (c) Copyright 2005-2014 Eduardo Ramos Testillano & Francisco Ruiz Rayo
-//
-// http://redmine.teslayout.com/projects/anna-suite
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions
-// are met:
-//
-//     * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-//     * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-//     *  Neither the name of the copyright holder nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Authors: eduardo.ramos.testillano@gmail.com
-//          cisco.tierra@gmail.com
+// ANNA - Anna is Not Nothingness Anymore                                                         //
+//                                                                                                //
+// (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo                         //
+//                                                                                                //
+// See project site at http://redmine.teslayout.com/projects/anna-suite                           //
+// See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
 
 
 #include <stdarg.h>
@@ -65,9 +37,6 @@ using namespace std;
 
 #define PAGE_WIDTH_LENGTH      80
 
-ExclusiveHash <std::string> functions::st_stringExclusiveHash;
-ExclusiveHash <std::string, int> functions::st_string2intExclusiveHash;
-
 string functions::getVersion() throw() {
   static const int version = ANNA_VERSION;
   string result;
@@ -119,21 +88,15 @@ throw() {
   return string(aux);
 }
 
-string functions::asString(const unsigned long number)
-throw() {
-  return asString((U64)number);
-}
-
 string functions::asString(const S64 number)
 throw() {
   char aux [24];
-  sprintf(aux, "%lld", number);
-  /*#ifdef __anna64__
+  //sprintf(aux, "%lld", number);
+  #ifdef __anna64__
      sprintf (aux, "%ld", number);
   #else
      sprintf (aux, "%lld", number);
   #endif
-  */
   return string(aux);
 }
 
@@ -147,14 +110,12 @@ throw() {
 string functions::asString(const U64 number)
 throw() {
   char aux [16];
-  sprintf(aux, "%llu", number);
-  /*
+  //sprintf(aux, "%llu", number);
   #ifdef __anna64__
      sprintf (aux, "%lu", number);
   #else
      sprintf (aux, "%llu", number);
   #endif
-  */
   return string(aux);
 }
 
@@ -201,22 +162,15 @@ throw() {
   return string(aux);
 }
 
-string functions::asHexString(const long number)
-throw() {
-  return asHexString((S64)number);
-}
-
 string functions::asHexString(const S64 number)
 throw() {
   char aux [32];
-  sprintf(aux, "0x%llx", number);
-  /*
+  //sprintf(aux, "0x%llx", number);
   #ifdef __anna64__
      sprintf (aux, "0x%lx", number);
   #else
      sprintf (aux, "0x%llx", number);
   #endif
-  */
   return string(aux);
 }
 
@@ -348,14 +302,12 @@ throw(RuntimeException) {
 S64 functions::asInteger64(const char* str)
 throw() {
   S64 number = 0;
-  sscanf(str, "%lld", &number);
-  /*
+  //sscanf(str, "%lld", &number);
   #ifdef __anna64__
     sscanf (str, "%ld", &number);
   #else
      sscanf (str, "%lld", &number);
   #endif
-  */
   return number;
 }
 
@@ -454,8 +406,8 @@ throw() {
   int r = -1;     // r will be lg(v)
   unsigned int t, tt; // temporaries
 
-  if(tt = v >> 16) {
-    r = (t = tt >> 8) ? 24 + LogTable256[t] : 16 + LogTable256[tt];
+  if((tt = v >> 16)) {
+    r = ((t = tt >> 8)) ? 24 + LogTable256[t] : 16 + LogTable256[tt];
   } else {
     r = (t = v >> 8) ? 8 + LogTable256[t] : LogTable256[v];
   }