From owner-freebsd-bugs@FreeBSD.ORG Wed Jan 21 04:00:42 2004 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0ACE616A4CF for ; Wed, 21 Jan 2004 04:00:42 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2A6ED43D2F for ; Wed, 21 Jan 2004 04:00:32 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) i0LC0WFR080162 for ; Wed, 21 Jan 2004 04:00:32 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.10/8.12.10/Submit) id i0LC0Vcr080156; Wed, 21 Jan 2004 04:00:31 -0800 (PST) (envelope-from gnats) Resent-Date: Wed, 21 Jan 2004 04:00:31 -0800 (PST) Resent-Message-Id: <200401211200.i0LC0Vcr080156@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Oliver Eikemeier Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4B5E116A4CF for ; Wed, 21 Jan 2004 03:58:24 -0800 (PST) Received: from postman.arcor.de (postman4.arcor-online.net [151.189.0.189]) by mx1.FreeBSD.org (Postfix) with ESMTP id 734FE43D64 for ; Wed, 21 Jan 2004 03:58:11 -0800 (PST) (envelope-from eikemeier@fillmore-labs.com) Received: from fillmore.dyndns.org (port-212-202-51-21.reverse.qsc.de [212.202.51.21]) (authenticated bits=0)i0LBw8M4023011 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Wed, 21 Jan 2004 12:58:09 +0100 (MET) Received: from [172.16.0.2] (helo=fillmore-labs.com) by fillmore.dyndns.org with esmtp (TLSv1:AES256-SHA:256) (Exim 4.30; FreeBSD) id 1AjGzo-000Km2-NH for FreeBSD-gnats-submit@FreeBSD.org; Wed, 21 Jan 2004 12:58:08 +0100 Message-Id: <400E694E.3000405@fillmore-labs.com> Date: Wed, 21 Jan 2004 12:58:06 +0100 From: Oliver Eikemeier To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/61673: make(1) word splitting swallows quotes X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Jan 2004 12:00:42 -0000 >Number: 61673 >Category: bin >Synopsis: make(1) word splitting swallows quotes >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Jan 21 04:00:31 PST 2004 >Closed-Date: >Last-Modified: >Originator: Oliver Eikemeier >Release: FreeBSD 4.9-STABLE i386 >Organization: Fillmore Labs - http://www.fillmore-labs.com >Environment: System: FreeBSD nuuk.fillmore-labs.com 4.9-STABLE >Description: Make reduces two (empty) quotes to one if they are not the first word in a string. This work with :S, :C, :M and others and is true for double and single quotes. >How-To-Repeat: * Makefile: QUOTETEST1= "" QUOTETEST2= "" ab QUOTETEST3= ab "" QUOTETEST4= ab "" cd QUOTETEST5= ab "" "cd - ef" "" jk all: @echo 'QUOTETEST1: ${QUOTETEST1:M*}' @echo 'QUOTETEST2: ${QUOTETEST2:M*}' @echo 'QUOTETEST3: ${QUOTETEST3:M*}' @echo 'QUOTETEST4: ${QUOTETEST4:M*}' @echo 'QUOTETEST5a: ${QUOTETEST5:S/^//}' @echo 'QUOTETEST5b: ${QUOTETEST5:S/$/>/:S/^/ <" <"cd> -> ef" <"> QUOTETEST5b: <"> "cd <- "> * Expected result: QUOTETEST1: "" QUOTETEST2: "" ab QUOTETEST3: ab "" QUOTETEST4: ab "" cd QUOTETEST5a: <""> <"cd - ef"> <""> QUOTETEST5b: <""> <"cd - ef"> <""> >Fix: It looks like brk_string in src/usr.bin/make/str.c is responsible for that: inquote = '\0'; for (p = str, start = t = buffer;; ++p) { switch(ch = *p) { case '"': case '\'': if (inquote) { if (inquote == ch) inquote = '\0'; else break; } else { inquote = (char) ch; /* Don't miss "" or '' */ if (start == NULL && p[1] == inquote) { start = t + 1; break; } } if (!expand) { if (!start) start = t; *t++ = ch; } continue; [...] } if (!start) start = t; *t++ = (char) ch; } Essentially the part after /* Don't miss "" or '' */. Maybe something like this will do the trick: inquote = '\0'; start = (char *)NULL; for (p = str, t = buffer;; ++p) { switch(ch = *p) { case '"': case '\'': if (inquote) { if (inquote == ch) inquote = '\0'; else break; } else { inquote = (char) ch; } if (!expand) { if (!start) start = t; *t++ = ch; } continue; [...] } if (!start) start = t; *t++ = (char) ch; } >Release-Note: >Audit-Trail: >Unformatted: