summaryrefslogtreecommitdiffstats
path: root/src/include/util
diff options
context:
space:
mode:
authorDean Sanner <dsanner@us.ibm.com>2013-05-06 10:36:49 -0500
committerA. Patrick Williams III <iawillia@us.ibm.com>2013-06-11 10:04:17 -0500
commit1b4408af313ad567489879c8409f26edb095665d (patch)
treee45308fd217e66fcecabdee208e2aec69aa942aa /src/include/util
parent0f2b871c2b84ccb734f20af0a76594b092360e9b (diff)
downloadtalos-hostboot-1b4408af313ad567489879c8409f26edb095665d.tar.gz
talos-hostboot-1b4408af313ad567489879c8409f26edb095665d.zip
Move sprintf closer to POSIX standard
Change-Id: I87c8abf234bdb1ab96303b14a1a72d9f914e618e Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/4380 Tested-by: Jenkins Server Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src/include/util')
-rw-r--r--src/include/util/sprintf.H80
1 files changed, 46 insertions, 34 deletions
diff --git a/src/include/util/sprintf.H b/src/include/util/sprintf.H
index 776fa090d..1385e9b17 100644
--- a/src/include/util/sprintf.H
+++ b/src/include/util/sprintf.H
@@ -1,25 +1,25 @@
-// IBM_PROLOG_BEGIN_TAG
-// This is an automatically generated prolog.
-//
-// $Source: src/include/util/sprintf.H $
-//
-// IBM CONFIDENTIAL
-//
-// COPYRIGHT International Business Machines Corp. 2011
-//
-// p1
-//
-// Object Code Only (OCO) source materials
-// Licensed Internal Code Source Materials
-// IBM HostBoot Licensed Internal Code
-//
-// The source code for this program is not published or other-
-// wise divested of its trade secrets, irrespective of what has
-// been deposited with the U.S. Copyright Office.
-//
-// Origin: 30
-//
-// IBM_PROLOG_END
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: src/include/util/sprintf.H $ */
+/* */
+/* IBM CONFIDENTIAL */
+/* */
+/* COPYRIGHT International Business Machines Corp. 2011,2013 */
+/* */
+/* p1 */
+/* */
+/* Object Code Only (OCO) source materials */
+/* Licensed Internal Code Source Materials */
+/* IBM HostBoot Licensed Internal Code */
+/* */
+/* The source code for this program is not published or otherwise */
+/* divested of its trade secrets, irrespective of what has been */
+/* deposited with the U.S. Copyright Office. */
+/* */
+/* Origin: 30 */
+/* */
+/* IBM_PROLOG_END_TAG */
#ifndef __UTIL_SPRINTF_H
#define __UTIL_SPRINTF_H
@@ -125,21 +125,33 @@ namespace Util
ALWAYS_INLINE
static size_t display(_F& c, _T value)
{
- size_t length = sizeof(_T) * 2;
- subdisplay(c, value, length);
- return length;
+ size_t count = 0;
+ if (value == 0)
+ {
+ c('0'); count++;
+ }
+ else
+ {
+ count += subdisplay(c, value);
+ }
+ return count;
}
template <typename _F>
- static void subdisplay(_F& c, _T value, size_t length)
- {
- if (length == 0) return;
- subdisplay(c, value / 16, length-1);
- char nibble = value % 16;
- if (nibble >= 0x0a)
- c('A' + (nibble - 0x0a));
- else
- c('0' + nibble);
+ static size_t subdisplay(_F& c, _T value)
+ {
+ size_t count = 0;
+ if (value != 0)
+ {
+ count += subdisplay(c, value / 16);
+ char nibble = value % 16;
+ if (nibble >= 0x0a)
+ c('A' + (nibble - 0x0a));
+ else
+ c('0' + nibble);
+ count++;
+ }
+ return count;
}
};
OpenPOWER on IntegriCloud