From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ricardo Wurmus Subject: bug#34531: Guix profile fails on Overdrive 1000 Date: Sat, 23 Feb 2019 12:20:06 +0100 Message-ID: <87ef7y3g61.fsf@elephly.net> References: <20190218200552.GB1881@jurong> <87mumsom9l.fsf@fastmail.com> <20190219082728.GA5650@jurong> <87lg2bvrne.fsf@elephly.net> <20190219161954.47234638@scratchpost.org> <20190220115136.422bdf5b@scratchpost.org> <87va1eu1gp.fsf@elephly.net> <20190220142634.56868dba@scratchpost.org> <87k1hutpvw.fsf@elephly.net> <20190220172603.1a675f61@scratchpost.org> <87a7iq5gh8.fsf@elephly.net> <20190220230857.2282d9b1@scratchpost.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([209.51.188.92]:34154) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gxVXV-0007kl-1X for bug-guix@gnu.org; Sat, 23 Feb 2019 06:32:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gxVMc-0002Rs-Oo for bug-guix@gnu.org; Sat, 23 Feb 2019 06:21:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:35394) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gxVMc-0002Q2-CY for bug-guix@gnu.org; Sat, 23 Feb 2019 06:21:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gxVMc-0008MQ-7z for bug-guix@gnu.org; Sat, 23 Feb 2019 06:21:02 -0500 Sender: "Debbugs-submit" Resent-Message-ID: In-reply-to: <20190220230857.2282d9b1@scratchpost.org> List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: "bug-Guix" To: Danny Milosavljevic Cc: 34531@debbugs.gnu.org Danny Milosavljevic writes: > (define (skip-comments text) > (replace (string-append "//[^\n]*?|" > "/[*].*?[*]/|" > "'([.]|[^'])*?'|" > "\"([.]|[^\"])*?\"") This last part will remove anything between double quotes, such as every string. Another problem seems to be the handling of /* comments */. It=E2=80=99s a greedy regex that will swallow any character until it finally hits */ =E2=80=94 even if the characters in between may have been */. I would not use regular expressions here but a read loop such as this: --8<---------------cut here---------------start------------->8--- (define (strip-comments port) (let loop ((char (get-char port)) (balance 0) (chars '())) (cond ;; done! ((eof-object? char) (list->string (reverse chars))) ;; line comment ((and (equal? char #\/) (equal? #\/ (peek-char port))) (begin (read-line port) (loop (get-char port) balance chars))) ;; begin of block comment ((and (equal? char #\/) (equal? #\* (peek-char port))) (begin (read-char port) (loop (get-char port) (1+ balance) chars))) ;; end of block comment ((and (positive? balance) (equal? char #\*) (equal? #\/ (peek-char port))) (begin (read-char port) (loop (get-char port) (1- balance) chars))) ;; inside block comment ((positive? balance) (loop (get-char port) balance chars)) ;; just a plain ol=E2=80=99 character (else (loop (get-char port) balance (cons char chars)))))) ;; Strip all comments from the file =E2=80=9Cfname=E2=80=9D and show the re= sult. (display (call-with-input-file fname strip-comments)) --8<---------------cut here---------------end--------------->8--- -- Ricardo