emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 245ca23196 1/4: bindat (strz): Fix documentation for strz with pr


From: Lars Ingebrigtsen
Subject: master 245ca23196 1/4: bindat (strz): Fix documentation for strz with pre-allocated string
Date: Fri, 10 Jun 2022 05:54:00 -0400 (EDT)

branch: master
commit 245ca23196792e2ddf7550b0d7bd42c06c1cc618
Author: Richard Hansen <rhansen@rhansen.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    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.
---
 doc/lispref/processes.texi | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/doc/lispref/processes.texi b/doc/lispref/processes.texi
index 7c37853eca..55fb93ec5a 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]