From patchwork Tue Sep 14 18:42:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Xinglu Chen X-Patchwork-Id: 32834 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 57AF427BBE3; Tue, 14 Sep 2021 19:43:10 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,T_DKIM_INVALID,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id A87F727BBE1 for ; Tue, 14 Sep 2021 19:43:09 +0100 (BST) Received: from localhost ([::1]:48268 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQDOe-0004Un-R5 for patchwork@mira.cbaines.net; Tue, 14 Sep 2021 14:43:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59958) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQDOY-0004Uf-V0 for guix-patches@gnu.org; Tue, 14 Sep 2021 14:43:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:38624) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mQDOY-0007ak-NH for guix-patches@gnu.org; Tue, 14 Sep 2021 14:43:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mQDOY-0007eJ-Jh for guix-patches@gnu.org; Tue, 14 Sep 2021 14:43:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50588] [PATCH] import: cabal: Treat identifier names correctly. Resent-From: Xinglu Chen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 14 Sep 2021 18:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 50588 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 50588@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.163164495829367 (code B ref -1); Tue, 14 Sep 2021 18:43:02 +0000 Received: (at submit) by debbugs.gnu.org; 14 Sep 2021 18:42:38 +0000 Received: from localhost ([127.0.0.1]:50170 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mQDO4-0007dV-He for submit@debbugs.gnu.org; Tue, 14 Sep 2021 14:42:38 -0400 Received: from lists.gnu.org ([209.51.188.17]:51626) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mQDO2-0007dN-Mp for submit@debbugs.gnu.org; Tue, 14 Sep 2021 14:42:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59874) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQDO1-0004Qe-CA for guix-patches@gnu.org; Tue, 14 Sep 2021 14:42:30 -0400 Received: from h87-96-130-155.cust.a3fiber.se ([87.96.130.155]:51212 helo=mail.yoctocell.xyz) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQDNz-000736-1Z for guix-patches@gnu.org; Tue, 14 Sep 2021 14:42:29 -0400 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1631644939; bh=BlowU9At9lSp4te1i30eWukhCDhQYk3Z0IS4wdlQJ8s=; h=From:To:Subject:Date; b=fFVcKKIw9g7PlzTN1WS1y12F7aeMJHy2QGnxMwfleXFEOeTDrdAlzU3KxRluqKyT9 lz7ZG4vt85zxmrk0iv0/JkO+fF2x7w8MvXao8Z3EbUUOPRfNxHBM6MjYMiI8LnxYpM ey2OCZaUJo/7U6DKo3zO0eadQLX69Qp8jYqNwhS4= Message-Id: Date: Tue, 14 Sep 2021 20:42:18 +0200 MIME-Version: 1.0 Received-SPF: pass client-ip=87.96.130.155; envelope-from=public@yoctocell.xyz; helo=mail.yoctocell.xyz X-Spam_score_int: 34 X-Spam_score: 3.4 X-Spam_bar: +++ X-Spam_report: (3.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FROM_SUSPICIOUS_NTLD=0.499, FROM_SUSPICIOUS_NTLD_FP=1.999, PDS_OTHER_BAD_TLD=1.999, RDNS_DYNAMIC=0.982, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * guix/import/cabal.scm (is-id): Accept the location as an argument. Don’t check if the identifier name is a reserved keyword unless it is the first word on the line. (lex-word): Adjust accordingly. * tests/hackage ("hackage->guix-package tests flag executable"): Expect it to pass. Fixes: --- ‘guix import hackage darcs’ now works correctly, and it fixes a five year old bug. :-) --8<---------------cut here---------------start------------->8--- $ ./pre-inst-env guix import hackage darcs (package (name "ghc-darcs") (version "2.16.4") (source (origin (method url-fetch) (uri (string-append "https://hackage.haskell.org/package/darcs/darcs-" version ".tar.gz")) (sha256 (base32 "07dygwh6p4fsrlgxmq6r7yvxmf4n2y04izzd30jzqgs0pi9645p4")))) (build-system haskell-build-system) (inputs `(("ghc-regex-compat-tdfa" ,ghc-regex-compat-tdfa) ("ghc-regex-applicative" ,ghc-regex-applicative) ("ghc-fgl" ,ghc-fgl) ("ghc-html" ,ghc-html) ("ghc-memory" ,ghc-memory) ("ghc-cryptonite" ,ghc-cryptonite) ("ghc-base16-bytestring" ,ghc-base16-bytestring) ("ghc-utf8-string" ,ghc-utf8-string) ("ghc-vector" ,ghc-vector) ("ghc-tar" ,ghc-tar) ("ghc-data-ordlist" ,ghc-data-ordlist) ("ghc-attoparsec" ,ghc-attoparsec) ("ghc-zip-archive" ,ghc-zip-archive) ("ghc-async" ,ghc-async) ("ghc-constraints" ,ghc-constraints) ("ghc-unix-compat" ,ghc-unix-compat) ("ghc-old-time" ,ghc-old-time) ("ghc-temporary" ,ghc-temporary) ("ghc-hashable" ,ghc-hashable) ("ghc-mmap" ,ghc-mmap) ("ghc-zlib" ,ghc-zlib) ("ghc-network-uri" ,ghc-network-uri) ("ghc-network" ,ghc-network) ("ghc-conduit" ,ghc-conduit) ("ghc-http-conduit" ,ghc-http-conduit) ("ghc-http-types" ,ghc-http-types))) (native-inputs `(("ghc-cmdargs" ,ghc-cmdargs) ("ghc-findbin" ,ghc-findbin) ("ghc-quickcheck" ,ghc-quickcheck) ("ghc-leancheck" ,ghc-leancheck) ("ghc-hunit" ,ghc-hunit) ("ghc-test-framework" ,ghc-test-framework) ("ghc-test-framework-hunit" ,ghc-test-framework-hunit) ("ghc-test-framework-quickcheck2" ,ghc-test-framework-quickcheck2) ("ghc-test-framework-leancheck" ,ghc-test-framework-leancheck) ("ghc-exceptions" ,ghc-exceptions) ("ghc-monad-control" ,ghc-monad-control) ("ghc-system-filepath" ,ghc-system-filepath) ("ghc-system-fileio" ,ghc-system-fileio) ("ghc-transformers-base" ,ghc-transformers-base))) (home-page "http://darcs.net/") (synopsis "a distributed, interactive, smart revision control system") (description "Darcs is a free, open source revision control system. It is: . * Distributed: Darcs was one of the first revision control systems in which every user has access to the full command set, removing boundaries between server and client or committer and non-committers. . * Interactive: Darcs is easy to learn and efficient to use because it asks you questions in response to simple commands, giving you choices in your work flow. You can choose to record one change in a file, while ignoring another. As you update from upstream, you can review each patch, picking and choosing which patches are appropriate. . * Smart: Darcs is different from most revision control systems in that it is based on the notion of change (or patch), rather than version. An underlying algebra of patches determines whether changes can be re-ordered. The laws of this algebra guarantee that the result of merging depends only on the final set of patches applied in a repository and not on their order. . * Simple: As a consequence, Darcs offers a conceptually simpler view of the state of a repository: it is given by the set of patches it contains. Pulling and pushing patches merely transfers them from one set to another. So called \"cherry-picking\" is the default mode of operation, and it fully preserves the identity of patches.") (license #f)) --8<---------------cut here---------------end--------------->8--- guix/import/cabal.scm | 13 ++++++++++--- tests/hackage.scm | 2 -- 2 files changed, 10 insertions(+), 5 deletions(-) base-commit: ec0e05ff306c950142c9ead7c712c749617069e7 diff --git a/guix/import/cabal.scm b/guix/import/cabal.scm index e9a0179b3d..16e69b9cdd 100644 --- a/guix/import/cabal.scm +++ b/guix/import/cabal.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2015 Federico Beffa ;;; Copyright © 2018 Ricardo Wurmus +;;; Copyright © 2021 Xinglu Chen ;;; ;;; This file is part of GNU Guix. ;;; @@ -399,14 +400,20 @@ matching a string against the created regexp." (define (is-or s) (string=? s "||")) -(define (is-id s port) +(define (is-id s port loc) (let ((cabal-reserved-words '("if" "else" "library" "flag" "executable" "test-suite" "custom-setup" "source-repository" "benchmark" "common")) (spaces (read-while (cut char-set-contains? char-set:blank <>) port)) (c (peek-char port))) (unread-string spaces port) - (and (every (cut string-ci<> s <>) cabal-reserved-words) + ;; Sometimes the name of an identifier is the same as one of the reserved + ;; words, which would normally lead to an error, see + ;; . Unless the word + ;; is at the beginning of a line (excluding whitespace), treat is as just + ;; another identifier instead of a reserved word. + (and (or (not (= (source-location-column loc) (current-indentation))) + (every (cut string-ci<> s <>) cabal-reserved-words)) (and (not (char=? (last (string->list s)) #\:)) (not (char=? #\: c)))))) @@ -568,7 +575,7 @@ LOC is the current port location." ((is-none w) (lex-none loc)) ((is-and w) (lex-and loc)) ((is-or w) (lex-or loc)) - ((is-id w port) (lex-id w loc)) + ((is-id w port loc) (lex-id w loc)) (else (unread-string w port) #f)))) (define (lex-line port loc) diff --git a/tests/hackage.scm b/tests/hackage.scm index 53972fc643..aca807027c 100644 --- a/tests/hackage.scm +++ b/tests/hackage.scm @@ -318,8 +318,6 @@ executable cabal mtl >= 2.0 && < 3 ") -;; Fails: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=25138 -(test-expect-fail 1) (test-assert "hackage->guix-package test flag executable" (eval-test-with-cabal test-cabal-flag-executable match-ghc-foo))