mirror of
https://git.savannah.gnu.org/git/gnulib.git
synced 2025-08-10 04:43:00 +03:00
* modules/string-h: Renamed from modules/string. * modules/string-h-tests: Renamed from modules/string-tests. * modules/string-h-c++-tests: Renamed from modules/string-c++-tests. * tests/test-string-h.c: Renamed from tests/test-string.c. * tests/test-string-h-c++.cc: Renamed from tests/test-string-c++.cc. * tests/test-string-h-c++2.cc: Renamed from tests/test-string-c++2.cc. * doc/posix-headers/string.texi: Update. * doc/posix-functions/strcat.texi: Update. * doc/posix-functions/strcpy.texi: Update. * doc/posix-functions/strncpy.texi: Update. * modules/* (Depends-on): Update. * modules/string: New file.
31 lines
1.1 KiB
Plaintext
31 lines
1.1 KiB
Plaintext
@node strncpy
|
|
@subsection @code{strncpy}
|
|
@findex strncpy
|
|
|
|
POSIX specification:@* @url{https://pubs.opengroup.org/onlinepubs/9799919799/functions/strncpy.html}
|
|
|
|
Gnulib module: string-h or strncpy
|
|
@mindex string-h
|
|
@mindex strncpy
|
|
|
|
Portability problems fixed by Gnulib module @code{string-h} or Gnulib module @code{strncpy}:
|
|
@itemize
|
|
@item
|
|
This function cannot be called from plain inline or extern inline functions
|
|
on some platforms:
|
|
macOS 10.8.
|
|
@end itemize
|
|
|
|
Portability problems not fixed by Gnulib:
|
|
@itemize
|
|
@end itemize
|
|
|
|
Note: This function was designed for the use-case of filling a fixed-size
|
|
record with a string, before writing it to a file. This function is
|
|
@strong{not} appropriate for copying a string into a bounded memory area,
|
|
because you have no guarantee that the result will be NUL-terminated.
|
|
Even if you add the NUL byte at the end yourself, this function is
|
|
inefficient (as it spends time clearing unused memory) and will allow
|
|
silent truncation to occur, which is not a good behavior for GNU programs.
|
|
For more details, see @url{https://meyering.net/crusade-to-eliminate-strncpy/}.
|