* bug#2878: Acknowledgement (bindat-pack returns unibyte string for emacs 22 but multibyte string for emacs 23)
@ 2009-05-03 14:49 Chong Yidong
2009-05-03 22:28 ` Miles Bader
0 siblings, 1 reply; 3+ messages in thread
From: Chong Yidong @ 2009-05-03 14:49 UTC (permalink / raw)
To: Miles Bader; +Cc: Yee Keat Phuah, 2878
Miles, could I verify that this patch is correct, and should be checked
in?
> snogglethorpe from #emacs have suggested this patch and it worked for
> my elisp code
> --- a/lisp/emacs-lisp/bindat.el
> +++ b/lisp/emacs-lisp/bindat.el
> @@ -609,9 +609,9 @@ Optional fourth arg BINDAT-IDX is the starting
> offset into BINDAT-RAW."
> (let ((no-return bindat-raw))
> (unless bindat-idx (setq bindat-idx 0))
> (unless bindat-raw
> - (setq bindat-raw (make-vector (+ bindat-idx (bindat-length spec struct)) 0)))
> + (setq bindat-raw (make-string (+ bindat-idx (bindat-length spec struct)) 0)))
> (bindat--pack-group struct spec)
> - (if no-return nil (concat bindat-raw))))
> + (if no-return nil bindat-raw)))
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#2878: Acknowledgement (bindat-pack returns unibyte string for emacs 22 but multibyte string for emacs 23)
2009-05-03 14:49 bug#2878: Acknowledgement (bindat-pack returns unibyte string for emacs 22 but multibyte string for emacs 23) Chong Yidong
@ 2009-05-03 22:28 ` Miles Bader
0 siblings, 0 replies; 3+ messages in thread
From: Miles Bader @ 2009-05-03 22:28 UTC (permalink / raw)
To: Chong Yidong; +Cc: Yee Keat Phuah, 2878
2009/5/3 Chong Yidong <cyd@stupidchicken.com>:
> Miles, could I verify that this patch is correct, and should be checked
> in?
>
>> snogglethorpe from #emacs have suggested this patch and it worked for
>> my elisp code
>
>> --- a/lisp/emacs-lisp/bindat.el
>> +++ b/lisp/emacs-lisp/bindat.el
I think it should be checked in. I don't have intimate familiarity
with this code, but I did look at the problem and make the patch.
The other code in the file stores numerical values into the
`bindat-raw' using aset, and then wants to return the whole thing as a
unicode string containing those byte values. The old code made a
vector, stored into it, and turned the vector into a string using
`concat' -- however that ends up making a _multibyte_ string (I don't
know whether this is a bug in concat or not). The new method of
making a string initially and storing directly into it results in a
unibyte string, which is what is desired (this method is also more
efficient).
-Miles
--
Do not taunt Happy Fun Ball.
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#2878: bindat-pack returns unibyte string for emacs 22 but multibyte string for emacs 23
@ 2009-04-03 15:20 Yee Keat Phuah
[not found] ` <handler.2878.B.123877206328398.ack@emacsbugs.donarmstrong.com>
0 siblings, 1 reply; 3+ messages in thread
From: Yee Keat Phuah @ 2009-04-03 15:20 UTC (permalink / raw)
To: emacs-pretest-bug
Hi,
This piece of code returned nil on emacs 22 and t on emacs 23.
(let* ((spec `((:method-id vec 4)))
(data `((:ref-type . ,(vector #x00 #x00 #x00 #x00 #x00 #x00 #x00 #x39))
(:method-id . ,(vector #x09 #x90 #xec #xd8))))
(packed (bindat-pack spec data)))
(multibyte-string-p packed))
And because of it being multibyte, when i want to send it over the
wire to a sub process in a binary data format, it gets transformed and
the sub process does not get a byte-by-byte equivalent of the
concatenation of the 2 vectors above. I have tried using
string-as-unibyte and the effect is still the same.
--
Cheers,
Phuah Yee Keat
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-05-03 22:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-03 14:49 bug#2878: Acknowledgement (bindat-pack returns unibyte string for emacs 22 but multibyte string for emacs 23) Chong Yidong
2009-05-03 22:28 ` Miles Bader
-- strict thread matches above, loose matches on Subject: below --
2009-04-03 15:20 bug#2878: bindat-pack returns unibyte string for emacs 22 but multibyte string for emacs 23 Yee Keat Phuah
[not found] ` <handler.2878.B.123877206328398.ack@emacsbugs.donarmstrong.com>
2009-04-03 16:01 ` bug#2878: Acknowledgement (bindat-pack returns unibyte string for emacs 22 but multibyte string for emacs 23) Yee Keat Phuah
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).