Mercurial > hg > octave-nkf > gnulib-hg
changeset 12623:b982684dce8f
unistr/u*-stpncpy: Fix the return value.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sun, 10 Jan 2010 21:39:12 +0100 |
parents | 032e68fe3552 |
children | 91e18087c6ac |
files | ChangeLog lib/unistr.h lib/unistr/u-stpncpy.h |
diffstat | 3 files changed, 17 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2010-01-10 Bruno Haible <bruno@clisp.org> + + unistr/u*-stpncpy: Fix the return value. + * lib/unistr.h (u8_stpncpy, u16_stpncpy, u32_stpncpy): Make the + description of the return value consistent with stpncpy in glibc. + * lib/unistr/u-stpncpy.h (FUNC): Return the pointer past the last + written non-NUL unit. + 2010-01-10 Bruno Haible <bruno@clisp.org> unistr/u*-next: Add missing dependencies.
--- a/lib/unistr.h +++ b/lib/unistr.h @@ -529,8 +529,8 @@ extern uint32_t * u32_strncpy (uint32_t *dest, const uint32_t *src, size_t n); -/* Copy no more than N units of SRC to DEST, returning the address of - the last unit written into DEST. */ +/* Copy no more than N units of SRC to DEST. Return a pointer past the last + non-NUL unit written into DEST. */ /* Similar to stpncpy(). */ extern uint8_t * u8_stpncpy (uint8_t *dest, const uint8_t *src, size_t n);
--- a/lib/unistr/u-stpncpy.h +++ b/lib/unistr/u-stpncpy.h @@ -23,8 +23,12 @@ /* This behavior is rarely useful, but it is here for consistency with strncpy and wcsncpy. */ - for (; n > 0; n--) - *dest++ = 0; + { + UNIT *destptr = dest; - return dest - 1; + for (; n > 0; n--) + *destptr++ = 0; + } + + return dest; }