From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Amirouche Boubekki Newsgroups: gmane.lisp.guile.devel Subject: Re: make-c-struct and pointer->string Date: Thu, 28 Mar 2019 16:15:11 +0100 Message-ID: References: <20190326101419.340081fc@capac> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000eba7a60585290530" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="227512"; mail-complaints-to="usenet@blaine.gmane.org" Cc: guile-devel To: David Pirotte Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Thu Mar 28 16:15:46 2019 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h9Wks-000x2o-7d for guile-devel@m.gmane.org; Thu, 28 Mar 2019 16:15:46 +0100 Original-Received: from localhost ([127.0.0.1]:37889 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h9Wkr-0002Dq-8c for guile-devel@m.gmane.org; Thu, 28 Mar 2019 11:15:45 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:36966) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h9WkX-0002Aw-I9 for guile-devel@gnu.org; Thu, 28 Mar 2019 11:15:26 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h9WkW-00017u-CS for guile-devel@gnu.org; Thu, 28 Mar 2019 11:15:25 -0400 Original-Received: from mail-vs1-xe2a.google.com ([2607:f8b0:4864:20::e2a]:41212) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h9WkW-00017m-2v for guile-devel@gnu.org; Thu, 28 Mar 2019 11:15:24 -0400 Original-Received: by mail-vs1-xe2a.google.com with SMTP id g187so12332281vsc.8 for ; Thu, 28 Mar 2019 08:15:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=d0geHNLx76hj27OXoeqrebn7cINSjewhHJP+qcG5OKk=; b=FmErK/SVY7TgXQtlwbFqcJU+ZeOgFtHq3A510/IUf0Oqx9AX07HIinTdpzAvH28g4S 3JdRu80JjwA+ByM45DE0eQ/oux7sn6A4W9RJyboLNPx8aJ93LZoezDrWonVdRm8XvwmR 08pEp/j0GL2LGDajGAYY3rRQs1LcpGpt9kHIuMwg9u7MpY8WMu8EThxhxfo8EUkI3UOb OxlM3nH4y1CeMEweLJlOkIzYHW0CMh606raihk8jgaQuSiccdSRC2bo/mmNicbMCBIOl i4ON4cDHGpU+PcxCO27qZA4uRVfvaiWkywHVXcbDPlSg3/yn3FtAp+66pIz/f7/T+Eau Y/Og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=d0geHNLx76hj27OXoeqrebn7cINSjewhHJP+qcG5OKk=; b=h878cD4G4IMj0NDKs0oi2r70DujuDYFF2KYdEkxJvrPDa488wxtDMe1vIqglIi913X TbAeaQgam2o6Tuc/iFA4bmLbe8qu1h6TqXpRHzOtYlAJxaEIBabiGR7wGtnjg61uE0/g hKDuSolJ7lkkNh42+PoxGsSQVc7WhtNfI2llHon99Tz/VGHhtJ1ibSr8YMfKvj33LZo6 y2cX8OjckFuTZDsAr7WAGXSPWlUZ5BchMXjppKa0FiN/NnkWOh2DN6hFX3Oq7wMrv68m 6Wpo5HLBNQNNUuofDdBNjVHzaXtIN72hPpIFy6uhhtFbZBF2kqLmYqN7AMsfWWvdXYKz PaNA== X-Gm-Message-State: APjAAAVMESTVnlV2nxaitDVvTWiyXcsMLnqCk9s1kBHtIXoOtZoFd4BP gY4AfSsWg1wxaZVB5feGblMzlK+SmdQ5D7DUi9p8UKFG X-Google-Smtp-Source: APXvYqxxisFRQM1hFe8M96lOX/Qs1mPcpW5xSkgnTneAnmamnrj0/+WvRBuKjdC/OcOgEzRUS7jeVnc6TqWhEfheu3c= X-Received: by 2002:a67:e407:: with SMTP id d7mr25511748vsf.212.1553786123033; Thu, 28 Mar 2019 08:15:23 -0700 (PDT) In-Reply-To: <20190326101419.340081fc@capac> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::e2a X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.org gmane.lisp.guile.devel:19864 Archived-At: --000000000000eba7a60585290530 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Eventually, I can reproduced the issue with guile-next from guix: scheme@(guile-user) [1]> (make-c-struct (list '* '*) (list (string->pointer "hello ") (string->pointer "there!"))) $5 =3D # scheme@(guile-user) [1]> (parse-c-struct $5 (list '* '*)) $6 =3D (# #) scheme@(guile-user) [1]> (map pointer->string $6) $7 =3D ("hello " "there!") scheme@(guile-user) [1]> (make-c-struct (list '* '*) (list (string->pointer "hello") (string->pointer "there!"))) $8 =3D # scheme@(guile-user) [1]> (parse-c-struct $8 (list '* '*)) $9 =3D (# #) scheme@(guile-user) [1]> (map pointer->string $9) $10 =3D ("hello" "there!") scheme@(guile-user) [1]> (make-c-struct (list '* '*) (list (string->pointer "hello") (string->pointer "there!"))) $11 =3D # scheme@(guile-user) [1]> (parse-c-struct $11 (list '* '*)) $12 =3D (# #) scheme@(guile-user) [1]> (map pointer->string $12) $13 =3D ("?<\"?\x0e\x7f" "@?f\x01") scheme@(guile-user) [1]> scheme@(guile-user)> Le mar. 26 mars 2019 =C3=A0 14:19, David Pirotte a =C3=A9= crit : > Hello, > > guile 2.2.4.1-cdb19 > > ,use (system foreign) > > ;; this fails > > scheme@(guile-user)> (make-c-struct (list '* '*) (list (string->pointer > "hello ") (string->pointer "there!"))) > $16 =3D # > scheme@(guile-user)> (parse-c-struct $16 (list '* '*)) > $17 =3D (# #) > scheme@(guile-user)> (map pointer->string $17) > $18 =3D ("?g?=D5=A3U" "`!?=D5=A3U") > > ;; but this works > > scheme@(guile-user)> (map pointer->string (parse-c-struct (make-c-struct > (list '* '*) (list (string->pointer "hello ") (string->pointer "there!"))= ) > (list '* '*))) > $19 =3D ("hello " "there!") > > > David > --000000000000eba7a60585290530 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Eventually, I can reproduced the iss= ue with guile-next from guix:

scheme@(guile-user) = [1]> (make-c-struct (list '* '*) (list (string->pointer "= ;hello ") (string->pointer "there!")))
$5 =3D #<poi= nter 0x1d1ca70>
scheme@(guile-user) [1]> (parse-c-struct $5 (list = '* '*))
$6 =3D (#<pointer 0x166a950> #<pointer 0x166a9f= 0>)
scheme@(guile-user) [1]> (map pointer->string $6)
$7 =3D= ("hello " "there!")
scheme@(guile-user) [1]> (ma= ke-c-struct (list '* '*) (list (string->pointer "hello"= ;) (string->pointer "there!")))
$8 =3D #<pointer 0x1ce2a= 40>
scheme@(guile-user) [1]> (parse-c-struct $8 (list '* '= *))
$9 =3D (#<pointer 0x166a810> #<pointer 0x166a910>)
sc= heme@(guile-user) [1]> (map pointer->string $9)
$10 =3D ("hel= lo" "there!")
scheme@(guile-user) [1]> (make-c-struct = (list '* '*) (list (string->pointer "hello") (string-&= gt;pointer "there!")))
$11 =3D #<pointer 0x1ce2a10>
s= cheme@(guile-user) [1]> (parse-c-struct $11 (list '* '*))
$12= =3D (#<pointer 0x166a850> #<pointer 0x166a690>)
scheme@(gui= le-user) [1]> (map pointer->string $12)
$13 =3D ("?<\"= ;?\x0e\x7f" "@?f\x01")
scheme@(guile-user) [1]>
sc= heme@(guile-user)>


Le=C2=A0mar. 26 mars 2019 =C3=A0= =C2=A014:19, David Pirotte <david@alt= osw.be> a =C3=A9crit=C2=A0:
Hello,

=C2=A0 =C2=A0 =C2=A0 =C2=A0 guile 2.2.4.1-cdb19

,use (system foreign)

;; this fails

scheme@(guile-user)> (make-c-struct (list '* '*) (list (string-&= gt;pointer "hello ") (string->pointer "there!"))) $16 =3D #<pointer 0x55a3d54d54d0>
scheme@(guile-user)> (parse-c-struct $16 (list '* '*))
$17 =3D (#<pointer 0x55a3d5d12170> #<pointer 0x55a3d5d0a640>) scheme@(guile-user)> (map pointer->string $17)
$18 =3D ("?g?=D5=A3U" "`!?=D5=A3U")

;; but this works

scheme@(guile-user)> (map pointer->string (parse-c-struct (make-c-str= uct (list '* '*) (list (string->pointer "hello ") (str= ing->pointer "there!"))) (list '* '*)))
$19 =3D ("hello " "there!")


David
--000000000000eba7a60585290530--