From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([209.51.188.92]:42189) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hTies-0006Sr-Or for guix-patches@gnu.org; Thu, 23 May 2019 04:01:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hTier-00060K-S0 for guix-patches@gnu.org; Thu, 23 May 2019 04:01:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:58514) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hTier-000607-Pe for guix-patches@gnu.org; Thu, 23 May 2019 04:01:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hTier-0008WU-MB for guix-patches@gnu.org; Thu, 23 May 2019 04:01:01 -0400 Subject: [bug#35846] [PATCH] revised: guix/import/cabal: handle braced descriptions (fixes #35735) References: In-Reply-To: Resent-Message-ID: From: Robert Vollmert Content-Type: multipart/mixed; boundary="Apple-Mail=_2B80B247-4600-42B2-A493-F5B49BCB6160" Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Message-Id: Date: Thu, 23 May 2019 10:00:08 +0200 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 35846@debbugs.gnu.org --Apple-Mail=_2B80B247-4600-42B2-A493-F5B49BCB6160 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii There was a stray debug print left in the previous version. --Apple-Mail=_2B80B247-4600-42B2-A493-F5B49BCB6160 Content-Disposition: attachment; filename=0001-guix-import-cabal-parse-braced-description-propertie.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-guix-import-cabal-parse-braced-description-propertie.patch" Content-Transfer-Encoding: quoted-printable =46rom=2035c2a4740c6f19ca4f0146ef274fb7806fcb72b7=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20Robert=20Vollmert=20=0ADate:=20= Fri,=2017=20May=202019=2014:26:36=20+0200=0ASubject:=20[PATCH]=20guix:=20= import:=20cabal:=20parse=20braced=20description=20properties=0A=0A*=20= guix/import/cabal.scm:=20generalize=20property=20bracing=20to=20both=0A=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= layouted=20and=20simple=20braced=20blocks=0A*=20guix/tests/hackage.scm:=20= test=20braced=20description=20import=0A---=0A=20guix/import/cabal.scm=20= |=2035=20++++++++++++++++++++++++++++-------=0A=20tests/hackage.scm=20=20= =20=20=20|=2020=20++++++++++++++++++++=0A=202=20files=20changed,=2048=20= insertions(+),=207=20deletions(-)=0A=0Adiff=20--git=20= a/guix/import/cabal.scm=20b/guix/import/cabal.scm=0Aindex=20= 13c2f3f48c..3028ed2882=20100644=0A---=20a/guix/import/cabal.scm=0A+++=20= b/guix/import/cabal.scm=0A@@=20-270,6=20+270,10=20@@=20following=20lines=20= with=20indentation=20larger=20than=20MIN-INDENT."=0A=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20(peek-next-line-indent=20port)))=0A=20=20=20= =20=20=20=20=20=20val)))=0A=20=0A+(define*=20(read-braced-value=20port)=0A= +=20=20"Read=20up=20to=20a=20closing=20brace."=0A+=20=20= (string-trim-both=20(read-delimited=20"}"=20port=20'trim)))=0A+=0A=20= (define=20(lex-white-space=20port=20bol)=0A=20=20=20"Consume=20white=20= spaces=20and=20comment=20lines=20on=20PORT.=20=20If=20a=20new=20line=20= is=20started=20return=20#t,=0A=20otherwise=20return=20BOL=20= (beginning-of-line)."=0A@@=20-343,8=20+347,11=20@@=20matching=20a=20= string=20against=20the=20created=20regexp."=0A=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20(make-regexp=20pat))))=0A=20=20=20=20=20(cut=20= regexp-exec=20rx=20<>)))=0A=20=0A-(define=20is-property=20= (make-rx-matcher=20"([a-z0-9-]+)[=20\t]*:[=20\t]*(\\w?.*)$"=0A-=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20regexp/icase))=0A+(define=20is-layout-property=20= (make-rx-matcher=20"([a-z0-9-]+)[=20\t]*:[=20\t]*(\\w?[^\\{\\}]*)$"=0A+=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20regexp/icase))=0A+=0A= +(define=20is-braced-property=20(make-rx-matcher=20"([a-z0-9-]+)[=20= \t]*:[=20\t]*\\{[=20\t]*$"=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20regexp/icase))=0A=20=0A=20(define=20is-flag=20= (make-rx-matcher=20"^flag=20+([a-z0-9_-]+)"=0A=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= regexp/icase))=0A@@=20-435,13=20+442,19=20@@=20string=20with=20the=20= read=20characters."=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20(begin=20(unread-char=20c)=20(list->string=20res)))))=0A=20=20=20=20=20= =20=20=20=20=20=20(else=20(list->string=20res)))))=0A=20=0A-(define=20= (lex-property=20k-v-rx-res=20loc=20port)=0A+(define=20= (lex-layout-property=20k-v-rx-res=20loc=20port)=0A=20=20=20(let=20((key=20= (string-downcase=20(match:substring=20k-v-rx-res=201)))=0A=20=20=20=20=20= =20=20=20=20(value=20(match:substring=20k-v-rx-res=202)))=0A=20=20=20=20=20= (make-lexical-token=0A=20=20=20=20=20=20'PROPERTY=20loc=0A=20=20=20=20=20= =20(list=20key=20`(,(read-value=20port=20value=20= (current-indentation)))))))=0A=20=0A+(define=20(lex-braced-property=20= k-rx-res=20loc=20port)=0A+=20=20(let=20((key=20(string-downcase=20= (match:substring=20k-rx-res=201))))=0A+=20=20=20=20(make-lexical-token=0A= +=20=20=20=20=20'PROPERTY=20loc=0A+=20=20=20=20=20(list=20key=20= `(,(read-braced-value=20port))))))=0A+=0A=20(define=20(lex-rx-res=20= rx-res=20token=20loc)=0A=20=20=20(let=20((name=20(string-downcase=20= (match:substring=20rx-res=201))))=0A=20=20=20=20=20(make-lexical-token=20= token=20loc=20name)))=0A@@=20-552,7=20+565,6=20@@=20LOC=20is=20the=20= current=20port=20location."=0A=20the=20current=20port=20location."=0A=20=20= =20(let*=20((s=20(read-delimited=20"\n{}"=20port=20'peek)))=0A=20=20=20=20= =20(cond=0A-=20=20=20=20=20((is-property=20s)=20=3D>=20(cut=20= lex-property=20<>=20loc=20port))=0A=20=20=20=20=20=20((is-flag=20s)=20=3D>= =20(cut=20lex-flag=20<>=20loc))=0A=20=20=20=20=20=20((is-src-repo=20s)=20= =3D>=20(cut=20lex-src-repo=20<>=20loc))=0A=20=20=20=20=20=20((is-exec=20= s)=20=3D>=20(cut=20lex-exec=20<>=20loc))=0A@@=20-561,13=20+573,22=20@@=20= the=20current=20port=20location."=0A=20=20=20=20=20=20((is-benchmark=20= s)=20=3D>=20(cut=20lex-benchmark=20<>=20loc))=0A=20=20=20=20=20=20= ((is-lib=20s)=20(lex-lib=20loc))=0A=20=20=20=20=20=20((is-else=20s)=20= (lex-else=20loc))=0A-=20=20=20=20=20(else=0A-=20=20=20=20=20=20#f))))=0A= +=20=20=20=20=20(else=20(unread-string=20s=20port)=20#f))))=0A+=0A= +(define=20(lex-property=20port=20loc)=0A+=20=20(let*=20((s=20= (read-delimited=20"\n"=20port=20'peek)))=0A+=20=20=20=20(cond=0A+=20=20=20= =20=20=20((is-braced-property=20s)=20=3D>=20(cut=20lex-braced-property=20= <>=20loc=20port))=0A+=20=20=20=20=20=20((is-layout-property=20s)=20=3D>=20= (cut=20lex-layout-property=20<>=20loc=20port))=0A+=20=20=20=20=20=20= (else=20#f))))=0A=20=0A=20(define=20(lex-token=20port)=0A=20=20=20(let*=20= ((loc=20(make-source-location=20(cabal-file-name)=20(port-line=20port)=0A= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20(port-column=20port)=20-1=20-1)))=0A= -=20=20=20=20(or=20(lex-single-char=20port=20loc)=20(lex-word=20port=20= loc)=20(lex-line=20port=20loc))))=0A+=20=20=20=20(or=20(lex-single-char=20= port=20loc)=0A+=20=20=20=20=20=20=20=20(lex-word=20port=20loc)=0A+=20=20=20= =20=20=20=20=20(lex-line=20port=20loc)=0A+=20=20=20=20=20=20=20=20= (lex-property=20port=20loc))))=0A=20=0A=20;;=20Lexer-=20and=20= error-function=20generators=0A=20=0Adiff=20--git=20a/tests/hackage.scm=20= b/tests/hackage.scm=0Aindex=20e56aa996d6..772ecd5217=20100644=0A---=20= a/tests/hackage.scm=0A+++=20b/tests/hackage.scm=0A@@=20-128,6=20+128,22=20= @@=20library=0A=20=20=20=20=20=20=20mtl=20=20=20=20=20=20=20=20>=3D=20= 2.0=20=20=20=20=20=20&&=20<=203=0A=20")=0A=20=0A+;;=20Check=20braces=20= instead=20of=20layout=0A+(define=20test-cabal-7=0A+=20=20"name:=20foo=0A= +version:=201.0.0=0A+homepage:=20http://test.org=0A+synopsis:=20synopsis=0A= +description:=20{=0A+description=0A+}=0A+license:=20BSD3=0A+executable=20= cabal=0A+=20=20build-depends:=0A+=20=20=20=20HTTP=20=20=20=20=20=20=20>=3D= =204000.2.5=20&&=20<=204000.3,=0A+=20=20=20=20mtl=20=20=20=20=20=20=20=20= >=3D=202.0=20=20=20=20=20=20&&=20<=203=0A+")=0A+=0A=20;;=20A=20fragment=20= of=20a=20real=20Cabal=20file=20with=20minor=20modification=20to=20check=20= precedence=0A=20;;=20of=20'and'=20over=20'or',=20missing=20final=20= newline,=20spaces=20between=20keywords=20and=0A=20;;=20parentheses=20and=20= between=20key=20and=20column.=0A@@=20-243,6=20+259,10=20@@=20library=0A=20= =20=20=20=20=20(x=0A=20=20=20=20=20=20=20(pk=20'fail=20x=20#f)))))=0A=20=0A= +(test-assert=20"hackage->guix-package=20test=207"=0A+=20=20= (eval-test-with-cabal=20test-cabal-7=0A+=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20#:cabal-environment=20'(("impl"=20= .=20"ghc-7.8"))))=0A+=0A=20(test-assert=20"read-cabal=20test=201"=0A=20=20= =20(match=20(call-with-input-string=20test-read-cabal-1=20read-cabal)=0A=20= =20=20=20=20((("name"=20("test-me"))=0A--=20=0A2.21.0=0A=0A= --Apple-Mail=_2B80B247-4600-42B2-A493-F5B49BCB6160--