From: Richard Hansen Date: Thu, 9 Jun 2022 23:58:56 +0000 (-0400) Subject: bindat (strz): Fix documentation for strz with pre-allocated string X-Git-Tag: emacs-29.0.90~1910^2~100 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=245ca23196792e2ddf7550b0d7bd42c06c1cc618;p=emacs.git bindat (strz): Fix documentation for strz with pre-allocated string * doc/lispref/processes.texi (Bindat Types): Document that a null terminator is not written if `bindat-pack' is given a pre-allocated string. --- diff --git a/doc/lispref/processes.texi b/doc/lispref/processes.texi index 7c37853ecae..55fb93ec5a8 100644 --- a/doc/lispref/processes.texi +++ b/doc/lispref/processes.texi @@ -3490,12 +3490,21 @@ input string will appear in the unpacked output. @item strz &optional @var{len} If @var{len} is not provided: Variable-length null-terminated unibyte string (@pxref{Text Representations}). When packing, the entire input -string is copied to the packed output followed by a null byte. The +string is copied to the packed output. The following byte will be +null (zero) unless a pre-allocated string was provided to +@code{bindat-pack}, in which case that byte is left unmodified. The length of the packed output is the length of the input string plus one -(for the added null byte). The input string must not contain any null +(for the null terminator). The input string must not contain any null bytes. When unpacking, the resulting string contains all bytes up to (but excluding) the null byte. +@quotation Caution +If a pre-allocated string is provided to @code{bindat-pack}, the +packed output will not be properly null-terminated unless the +pre-allocated string already has a null byte at the appropriate +location. +@end quotation + If @var{len} is provided: @code{strz} behaves the same as @code{str} with one difference: When unpacking, the first null byte encountered in the packed string and all subsequent bytes are excluded from the