# HG changeset patch # User Bruno Haible # Date 1263155952 -3600 # Node ID b982684dce8f2b7f5e10f88428e3e40c83d838d8 # Parent 032e68fe35520f3abb4ebff39576431673b10aa0 unistr/u*-stpncpy: Fix the return value. diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2010-01-10 Bruno Haible + + 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 unistr/u*-next: Add missing dependencies. diff --git a/lib/unistr.h b/lib/unistr.h --- 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); diff --git a/lib/unistr/u-stpncpy.h b/lib/unistr/u-stpncpy.h --- 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; }