summaryrefslogtreecommitdiff
path: root/manual/string.texi
diff options
context:
space:
mode:
authorThomas Schwinge <thomas@codesourcery.com>2013-12-20 09:29:29 +0100
committerThomas Schwinge <thomas@codesourcery.com>2013-12-20 09:29:29 +0100
commita65dd355fb80a05215e15ae97649de52aec885e3 (patch)
tree81701bb0c6b648630f2bf1729a85d7f5eb49e67b /manual/string.texi
parent296a5732f94abe4d5699dc981e4ccfb950b48cee (diff)
parentb4578bab30f72cddd2cf38abfb39f9c8dc892249 (diff)
Merge branch 'baseline' into refs/top-bases/tschwinge/Roger_Whittaker
Diffstat (limited to 'manual/string.texi')
-rw-r--r--manual/string.texi10
1 files changed, 5 insertions, 5 deletions
diff --git a/manual/string.texi b/manual/string.texi
index 2a164a9523..1e45d9ddbc 100644
--- a/manual/string.texi
+++ b/manual/string.texi
@@ -955,8 +955,8 @@ The @code{strncat} function could be implemented like this:
char *
strncat (char *to, const char *from, size_t size)
@{
- to[strlen (to) + size] = '\0';
- strncpy (to + strlen (to), from, size);
+ memcpy (to + strlen (to), from, strnlen (from, size));
+ to[strlen (to) + strnlen (from, size)] = '\0';
return to;
@}
@end group
@@ -982,8 +982,8 @@ wchar_t *
wcsncat (wchar_t *restrict wto, const wchar_t *restrict wfrom,
size_t size)
@{
- wto[wcslen (to) + size] = L'\0';
- wcsncpy (wto + wcslen (wto), wfrom, size);
+ memcpy (wto + wcslen (wto), wfrom, wcsnlen (wfrom, size) * sizeof (wchar_t));
+ wto[wcslen (to) + wcsnlen (wfrom, size)] = '\0';
return wto;
@}
@end group
@@ -1370,7 +1370,7 @@ int
compare_elements (const void *v1, const void *v2)
@{
char * const *p1 = v1;
- char * const *p1 = v2;
+ char * const *p2 = v2;
return strcoll (*p1, *p2);
@}