summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib
diff options
context:
space:
mode:
author Miodrag Milanovic <mmicko@gmail.com>2011-10-04 09:58:07 +0000
committer Miodrag Milanovic <mmicko@gmail.com>2011-10-04 09:58:07 +0000
commit6730bf8cc77123a52c12cb05f8b6c23730438fc7 (patch)
tree7d0b55907810110677c474bc5e33616ef5efe61e /src/lib
parent9247583a1d71282540e24dbcefb1cb91aec2626d (diff)
Added a way to handle output for debug messages and debugger itself into octal too, and made
a few CPU's to give octal output by default. Note that for now just some functions things return octal, will add more, but since this change required clean compile better to put it sooner then later (no whatsnew)
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/util/corestr.c39
-rw-r--r--src/lib/util/corestr.h3
2 files changed, 40 insertions, 2 deletions
diff --git a/src/lib/util/corestr.c b/src/lib/util/corestr.c
index 7c244e8a8bd..c573694a76d 100644
--- a/src/lib/util/corestr.c
+++ b/src/lib/util/corestr.c
@@ -150,7 +150,7 @@ char *core_strdup(const char *str)
/*-------------------------------------------------
- core_i64_format - i64 format printf helper
+ core_i64_hex_format - i64 format printf helper
-------------------------------------------------*/
char *core_i64_hex_format(UINT64 value, UINT8 mindigits)
@@ -176,3 +176,40 @@ char *core_i64_hex_format(UINT64 value, UINT8 mindigits)
return bufbase;
}
+
+/*-------------------------------------------------
+ core_i64_oct_format - i64 format printf helper
+-------------------------------------------------*/
+
+char *core_i64_oct_format(UINT64 value, UINT8 mindigits)
+{
+ static char buffer[22][64];
+ static int index;
+ char *bufbase = &buffer[index++ % 22][0];
+ char *bufptr = bufbase;
+ INT8 curdigit;
+
+ for (curdigit = 21; curdigit >= 0; curdigit--)
+ {
+ int octdigit = (value >> (curdigit * 3)) & 0x7;
+ if (octdigit != 0 || curdigit < mindigits)
+ {
+ mindigits = curdigit;
+ *bufptr++ = "01234567"[octdigit];
+ }
+ }
+ if (bufptr == bufbase)
+ *bufptr++ = '0';
+ *bufptr = 0;
+
+ return bufbase;
+}
+
+/*-------------------------------------------------
+ core_i64_format - i64 format printf helper
+-------------------------------------------------*/
+
+char *core_i64_format(UINT64 value, UINT8 mindigits, bool is_octal)
+{
+ return is_octal ? core_i64_oct_format(value,mindigits) : core_i64_hex_format(value,mindigits);
+}
diff --git a/src/lib/util/corestr.h b/src/lib/util/corestr.h
index 55a5914cc29..c5c052c9cae 100644
--- a/src/lib/util/corestr.h
+++ b/src/lib/util/corestr.h
@@ -87,7 +87,8 @@ int core_strwildcmp(const char *sp1, const char *sp2);
/* I64 printf helper */
+char *core_i64_format(UINT64 value, UINT8 mindigits, bool is_octal);
char *core_i64_hex_format(UINT64 value, UINT8 mindigits);
-
+char *core_i64_oct_format(UINT64 value, UINT8 mindigits);
#endif /* __CORESTR_H__ */