From 1775b972583588e562c1e6f614da60806c720168 Mon Sep 17 00:00:00 2001 From: brolley Date: Mon, 10 Mar 2008 18:45:03 +0000 Subject: 2008-03-10 Dave Brolley PR5189 * vsprintf.c (_stp_vsnprintf): Arguments for dynamic width and precision are of type 'int' again. * loc2c-runtime.h (deref_string): Copy the data only if dst is not NULL. (deref_buffer): New macro. --- runtime/loc2c-runtime.h | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'runtime/loc2c-runtime.h') diff --git a/runtime/loc2c-runtime.h b/runtime/loc2c-runtime.h index 4674e399..7ea1b1e4 100644 --- a/runtime/loc2c-runtime.h +++ b/runtime/loc2c-runtime.h @@ -623,8 +623,26 @@ for (_len = (maxbytes), _addr = (uintptr_t)(addr); \ _len > 1 && (_c = deref (1, _addr)) != '\0'; \ --_len, ++_addr) \ - *_d++ = _c; \ - *_d = '\0'; \ + if (_d) \ + *_d++ = _c; \ + if (_d) \ + *_d = '\0'; \ + (dst); \ + }) + +#define deref_buffer(dst, addr, numbytes) \ + ({ \ + uintptr_t _addr; \ + size_t _len; \ + unsigned char _c; \ + char *_d = (dst); \ + for (_len = (numbytes), _addr = (uintptr_t)(addr); \ + _len >= 1; \ + --_len, ++_addr) { \ + _c = deref (1, _addr); \ + if (_d) \ + *_d++ = _c; \ + } \ (dst); \ }) -- cgit