From d9f58253e30ea80e57d8f54e41e9cd114cc13973 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Mon, 15 Feb 2010 21:27:37 -0800 Subject: Use clamping to more easily normalize input values The kernel has min/max/clamp macros to make range comparisons easier. Clamp is a newer invention, but we can define it for older kernels in terms of min and max. --- runtime/string.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'runtime/string.c') diff --git a/runtime/string.c b/runtime/string.c index 1d4cb255..afef191a 100644 --- a/runtime/string.c +++ b/runtime/string.c @@ -68,10 +68,10 @@ static void _stp_text_str(char *outstr, char *in, int len, int quoted, int user) { char c, *out = outstr; - if (len == 0 || len > MAXSTRINGLEN-1) + if (len <= 0 || len > MAXSTRINGLEN-1) len = MAXSTRINGLEN-1; if (quoted) { - len -= 2; + len = max(len, 5) - 2; *out++ = '"'; } -- cgit