26.10.2013 19:14, Rainer Gerhards:

It will still fail to display -LLONG_MAX, btw.
you actually mean -LLONG_MAX or LLONG_MIN? -LLONG_MAX is off the long long
range...


Yep, I've got it wrong. -LLONG_MAX is not off the range, though, it will be displayed properly.

LLONG_MIN will be displayed in a wrong way, because -LLONG_MIN is off the range and will overflow to LLONG_MIN again.

It's up to you to deside, it is not of a big value, of course.


--
Pavel Levshin



---
 src/string.c |    7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/string.c b/src/string.c
index 483546d..68b1ca0 100644
--- a/src/string.c
+++ b/src/string.c
@@ -34,6 +34,7 @@
 #include <assert.h>
 #include <ctype.h>
 #include <errno.h>
+#include <limits.h>
 
 #include "libestr.h"
 
@@ -154,7 +155,13 @@ es_newStrFromNumber(long long num)
        char minus = '\0';
        es_str_t *s;
        
+       assert(-9223372036854775808LL == LLONG_MIN);
        if (num < 0) {
+               if (num == LLONG_MIN) {
+                       s = es_newStrFromCStr("-9223372036854775808", 
+                                       sizeof("-9223372036854775808") - 1);
+                       goto done;
+               }
            minus = '-';
            num = -num;
        }
-- 
1.7.9.5

_______________________________________________
rsyslog mailing list
http://lists.adiscon.net/mailman/listinfo/rsyslog
http://www.rsyslog.com/professional-services/
What's up with rsyslog? Follow https://twitter.com/rgerhards
NOTE WELL: This is a PUBLIC mailing list, posts are ARCHIVED by a myriad of 
sites beyond our control. PLEASE UNSUBSCRIBE and DO NOT POST if you DON'T LIKE 
THAT.

Reply via email to