From af4e630a29e8ddcb11f377d3b0e6f6d580040313 Mon Sep 17 00:00:00 2001
From: Jan Breuer <jan.breuer@jaybee.cz>
Date: 周五, 12 12月 2014 17:50:29 +0800
Subject: [PATCH] Parser refactoring

---
 libscpi/src/utils.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/libscpi/src/utils.c b/libscpi/src/utils.c
index 922b870..0d0a274 100644
--- a/libscpi/src/utils.c
+++ b/libscpi/src/utils.c
@@ -74,8 +74,6 @@
  * @param len   string buffer length
  * @return number of bytes written to str (without '\0')
  */
-// TODO: add support for other bases
-
 size_t longToStr(int32_t val, char * str, size_t len, int8_t base) {
     uint32_t x = 1000000000L;
     int_fast8_t digit;
@@ -90,14 +88,14 @@
         }
 
         while ((val / x) == 0) {
-            x /= 10;
+            x /= base;
         }
 
         do {
             digit = (uint8_t) (val / x);
             if (pos < len) str[pos++] = digit + '0';
             val -= digit * x;
-            x /= 10;
+            x /= base;
         } while (x && (pos < len));
     }
 

--
Gitblit v1.9.1