From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:470:142:3::10]:37175) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6GBN-0001S7-7P for guix-patches@gnu.org; Mon, 24 Feb 2020 11:02:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j6GBH-0003DI-Oo for guix-patches@gnu.org; Mon, 24 Feb 2020 11:02:09 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:47981) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j6GBF-0003Cy-Pj for guix-patches@gnu.org; Mon, 24 Feb 2020 11:02:01 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1j6GBF-0006JS-O3 for guix-patches@gnu.org; Mon, 24 Feb 2020 11:02:01 -0500 Subject: [bug#39767] [PATCH core-updates] gnu: ld-wrapper: Preserve quoted arguments from response files. Resent-Message-ID: Received: from eggs.gnu.org ([2001:470:142:3::10]:37126) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6GAt-0001H6-SP for guix-patches@gnu.org; Mon, 24 Feb 2020 11:01:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j6GAs-00033u-As for guix-patches@gnu.org; Mon, 24 Feb 2020 11:01:39 -0500 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]:43725) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j6GAr-00033M-UN for guix-patches@gnu.org; Mon, 24 Feb 2020 11:01:38 -0500 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 6141C3CB for ; Mon, 24 Feb 2020 11:01:35 -0500 (EST) Received: from localhost (ti0006q161-2604.bb.online.no [84.202.68.75]) by mail.messagingengine.com (Postfix) with ESMTPA id 87FA13060D1A for ; Mon, 24 Feb 2020 11:01:34 -0500 (EST) From: Marius Bakke Date: Mon, 24 Feb 2020 17:01:32 +0100 Message-Id: <20200224160132.21037-1-mbakke@fastmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: 39767@debbugs.gnu.org * gnu/packages/ld-wrapper.in (expand-arguments): Add TOKENIZE procedure, and use that to parse the response file. --- gnu/packages/ld-wrapper.in | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) Guix, Currently the ld-wrapper will fail inscrutably if a response file contains double quotes. This patch fixes that, and also preserves whitespaces between quotes. diff --git a/gnu/packages/ld-wrapper.in b/gnu/packages/ld-wrapper.in index 16780c58f6..5d5756f6a3 100644 --- a/gnu/packages/ld-wrapper.in +++ b/gnu/packages/ld-wrapper.in @@ -16,6 +16,7 @@ exec @GUILE@ -c "(load-compiled \"@SELF@.go\") (apply $main (cdr (command-line)) !# ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018 Ludovic Courtès +;;; Copyright © 2020 Marius Bakke ;;; ;;; This file is part of GNU Guix. ;;; @@ -35,7 +36,7 @@ exec @GUILE@ -c "(load-compiled \"@SELF@.go\") (apply $main (cdr (command-line)) (define-module (gnu build-support ld-wrapper) #:use-module (srfi srfi-1) #:use-module (ice-9 match) - #:autoload (ice-9 rdelim) (read-string) + #:autoload (ice-9 rdelim) (read-delimited) #:export (ld-wrapper)) ;;; Commentary: @@ -239,13 +240,28 @@ library outside of ~a: ~s~%" ;; Expand ARGS such that "response file" arguments, such as "@args.txt", are ;; expanded (info "(gcc) Overall Options"). (define (response-file-arguments file) + (define (tokenize port) + ;; Return a list of all strings found in PORT. Quote characters are removed, + ;; but whitespaces within quoted strings are preserved. + (let loop ((words '())) + (let* ((word (read-delimited " '\"" port 'split)) + (token (car word)) + (delim (cdr word))) + (if (eof-object? delim) + (reverse words) + (case delim + ((#\") (loop (cons (read-delimited "\"" port) words))) + ((#\') (loop (cons (read-delimited "'" port) words))) + ((#\ ) (if (> 0 (string-length token)) + (loop (cons token words)) + (loop words))) + (else (loop words))))))) + (when %debug? (format (current-error-port) "ld-wrapper: attempting to read arguments from '~a'~%" file)) - ;; FIXME: Options can contain whitespace if they are protected by single - ;; or double quotes; this is not implemented here. - (string-tokenize (call-with-input-file file read-string))) + (call-with-input-file file tokenize)) (define result (fold-right (lambda (arg result) -- 2.25.0