Den 26-09-2013 15:42, Mike Moreton skrev:
If you display an object which has a negative small value, and a
DISPLAY-HINT of something like d-3, then you can get results like:
.0-7
The attached patch is a bit cleaner, and should also fix it. Could you
please try that?
/Niels
--
Niels Baggesen - @home - Ã…rhus - Denmark - [email protected]
The purpose of computing is insight, not numbers --- R W Hamming
diff --git a/snmplib/mib.c b/snmplib/mib.c
index ec45d73..8973b8c 100644
--- a/snmplib/mib.c
+++ b/snmplib/mib.c
@@ -1222,7 +1222,7 @@ sprint_realloc_hinted_integer(u_char ** buf, size_t * buf_len,
const char *hint, const char *units)
{
char fmt[10] = "%l@", tmp[256];
- int shift, len;
+ int shift, len, negative = 0;
if (hint[1] == '-') {
shift = atoi(hint + 2);
@@ -1235,6 +1235,10 @@ sprint_realloc_hinted_integer(u_char ** buf, size_t * buf_len,
* We might *actually* want a 'u' here.
*/
fmt[2] = decimaltype;
+ if (val < 0) {
+ negative = 1;
+ val = -val;
+ }
} else {
/*
* DISPLAY-HINT character is 'b', 'o', or 'x'.
@@ -1275,6 +1279,14 @@ sprint_realloc_hinted_integer(u_char ** buf, size_t * buf_len,
}
tmp[0] = '.';
}
+ if (negative) {
+ len = strlen(tmp)+1;
+ while (len) {
+ tmp[len] = tmp[len-1];
+ len--;
+ }
+ tmp[0] = '-';
+ }
}
return snmp_strcat(buf, buf_len, out_len, allow_realloc, (u_char *)tmp);
}
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders