libs/libc/string/lib_stpncpy.c: Correct the return poineter value for the case where the NUL terminator is transferred.
This commit is contained in:
parent
68d4c1d4ed
commit
3950398841
|
@ -63,8 +63,8 @@
|
||||||
* the string pointed to by the message argument will be written,
|
* the string pointed to by the message argument will be written,
|
||||||
* followed by a colon and a space.
|
* followed by a colon and a space.
|
||||||
*
|
*
|
||||||
* Then the signal description string associated with signum or with the
|
* Then the signal description string associated with signum will be
|
||||||
* signal indicated by pinfo will be written, followed by a newline.
|
* written, followed by a newline.
|
||||||
*
|
*
|
||||||
* Returned Value
|
* Returned Value
|
||||||
* None. The errno value is never set in this implementation.
|
* None. The errno value is never set in this implementation.
|
||||||
|
@ -99,8 +99,8 @@ void psignal(int signum, FAR const char *message)
|
||||||
* the string pointed to by the message argument will be written,
|
* the string pointed to by the message argument will be written,
|
||||||
* followed by a colon and a space.
|
* followed by a colon and a space.
|
||||||
*
|
*
|
||||||
* Then the signal description string associated with signum or with the
|
* Then the signal description string associated with the signal
|
||||||
* signal indicated by pinfo will be written, followed by a newline.
|
* indicated by pinfo will be written, followed by a newline.
|
||||||
*
|
*
|
||||||
* Returned Value
|
* Returned Value
|
||||||
* None. Since no value is returned, an application wishing to check for
|
* None. Since no value is returned, an application wishing to check for
|
||||||
|
@ -121,4 +121,4 @@ void psiginfo(FAR const siginfo_t *pinfo, FAR const char *message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* __KERNEL__ */
|
#endif /* !__KERNEL__ */
|
||||||
|
|
|
@ -78,17 +78,24 @@ FAR char *strncpy(FAR char *dest, FAR const char *src, size_t n)
|
||||||
* encountered.
|
* encountered.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
while ((dest != end) && (*dest++ = *src++) != '\0')
|
while ((dest != end) && (*dest = *src++) != '\0')
|
||||||
{
|
{
|
||||||
|
/* Increment the 'dest' pointer only if it does not refer to the
|
||||||
|
* NUL terminator.
|
||||||
|
*/
|
||||||
|
|
||||||
|
dest++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the pointer to the NUL terminator (or to the end of the buffer
|
/* Return the pointer to the NUL terminator (or to the end of the buffer
|
||||||
* + 1.
|
* + 1).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ret = dest;
|
ret = dest;
|
||||||
|
|
||||||
/* Pad the remainder of the array pointer to 'dest' with NULs */
|
/* Pad the remainder of the array pointer to 'dest' with NULs. This
|
||||||
|
* overwrites any previously copied NUL terminator.
|
||||||
|
*/
|
||||||
|
|
||||||
while (dest != end)
|
while (dest != end)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue