Bug 21605

Summary: make(1) lacks :C/// variable modifier (patch included)
Product: Base System Reporter: Hubert Feyrer <feyrer>
Component: binAssignee: Will Andrews <will>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description Hubert Feyrer 2000-09-28 03:10:01 UTC
	make(1) lacks the :C/// variable modifier found in NetBSD and
	OpenBSD: 

        C/pattern/replacement/[1g]
              The C modifier is just like the S modifier except
              that the old and new strings, instead of being simple
              strings, are a regular expression (see regex(3)) and
              an ed(1)-style replacement string.  Normally, the
              first occurrence of the pattern in each word of the
              value is changed.  The `1' modifier causes the sub-
              stitution to apply to at most one word; the `g' modi-
              fier causes the substitution to apply to as many in-
              stances of the search pattern as occur in the word or
              words it is found in.  Note that `1' and `g' are or-
              thogonal; the former specifies whether multiple words
              are potentially affected, the latter whether multiple
              substitutions can potentially occur within each af-
              fected word.

	Useful for string manipulations in bsd.port.mk and others, 
	instead of forking off sed(1) processes. See example below.

	Contributed as a result of discussion on the bsdports mailing
	list to merge the BSD ports/packages collections, see
	http://www.openpackages.org/.

Fix: Apply the following patch:


Patch against FreeBSD-current as of 20000928 to teach it the :C///
variable modifier that's available in NetBSD. :C/// is similar to 
the :S/// modifier, but it allows a regular expression as the
term that's being replaced.

Useful for string manipulations in bsd.port.mk and others, instead
of forking off sed(1) processes. 

Contributed as a result of discussion on the bsdports mailing
list to merge the BSD ports/packages collections, see
http://www.openpackages.org/.


 - Hubert Feyrer <hubertf@netbsd.org>
How-To-Repeat: 
	  $ cat /tmp/m
	  P=      ports/cat/pkg
	  CAT=    ${P:C/^.*\/([^\/]*)\/[^\/]*$/\1/}
	  PKG=    ${P:C/^.*\/([^\/]*)$/\1/}

	  bla:
        	  @echo P=${P}
        	  @echo CAT=${CAT}
        	  @echo PKG=${PKG}
	  $
	  $ make -f /tmp/m
	  P=pkgsrc/cat/pkg
	  Unknown modifier 'C'

	  CAT=
	  Unknown modifier 'C'

	  PKG=
	  $
	  $ nbmake -f /tmp/m
	  P=pkgsrc/cat/pkg
	  CAT=cat
	  PKG=pkg

	  The same thing can be applied in bsd.ports.mk to get first,
	  second and if needed third part of DEPENDS lines.
Comment 1 Will Andrews freebsd_committer freebsd_triage 2000-09-29 20:59:51 UTC
Responsible Changed
From-To: freebsd-bugs->will

Over to MAINTAINER.
Comment 2 Will Andrews freebsd_committer freebsd_triage 2000-10-09 05:32:36 UTC
State Changed
From-To: open->suspended

Committed to 5.0-CURRENT, thanks.  Leaving this suspended 
so it will have adequate time to settle to be later MFC'd 
to RELENG_4 and RELENG_3.
Comment 3 Will Andrews freebsd_committer freebsd_triage 2000-10-23 22:12:50 UTC
State Changed
From-To: suspended->closed

I committed this to RELENG_4 (4.x-STABLE) and RELENG_3 (3.x-STABLE) 
last week.  Thanks for your submission