diff options
Diffstat (limited to 'x11/mlterm/patches/patch-ah')
-rw-r--r-- | x11/mlterm/patches/patch-ah | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/x11/mlterm/patches/patch-ah b/x11/mlterm/patches/patch-ah new file mode 100644 index 00000000000..fc9cbbb92f2 --- /dev/null +++ b/x11/mlterm/patches/patch-ah @@ -0,0 +1,39 @@ +$NetBSD: patch-ah,v 1.1 2006/12/19 07:53:57 wiz Exp $ + +safer DIGIT_STR_LEN(). + +http://mlterm.cvs.sourceforge.net/mlterm/mlterm/kiklib/src/kik_util.h?r1=1.4&r2=1.5&view=patch + +--- kiklib/src/kik_util.h.orig 2002/02/02 09:20:27 1.4 ++++ kiklib/src/kik_util.h 2006/10/13 16:13:42 1.5 +@@ -10,19 +10,20 @@ + + #define K_MIN(n1,n2) ((n1) > (n2) ? (n2) : (n1)) + +-/* +- * char : 0 - 256 (3) +- * int16 : 0 - 65536 (5) +- * int32 : 0 - 4294967296 (10) +- * int64 : 0 - 18446744073709551616 (20) ++/* TYPE: MIN(signed) -- MAX(unsigned) (number of bytes needed) ++ * char : -128 -- 256 (4) ++ * int16 : -32768 -- 65536 (6) ++ * int32 : -2147483648 -- 4294967296 (11) ++ * int64 : -9223372036854775808 -- 18446744073709551616 (20) + * +- * 40 is evenly selected in other cases just to be sure. ++ * Since log10(2^8) = 2.4..., (sizeof(n)*3) is large enough ++ * for all n >= 2. + */ + #define DIGIT_STR_LEN(n) \ +- ((sizeof(n) == 1) ? 3 : \ +- (sizeof(n) == 2) ? 5 : \ +- (sizeof(n) == 4) ? 10 : \ +- (sizeof(n) == 8) ? 20 : 40) ++ ((sizeof(n) == 1) ? 4 : \ ++ (sizeof(n) == 2) ? 6 : \ ++ (sizeof(n) == 4) ? 11 : \ ++ (sizeof(n) == 8) ? 20 : (sizeof(n)*3)) + + + #endif |