C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[45762] Re:$(patsubst %.c,%.o,$(shell echo *.c)) 이거 아시는분
고황일 [hwangil] 1489 읽음    2006-07-20 20:53

금영이 님이 쓰신 글 :
: make 파일에서요
:
: $(patsubst %.c,%.o,$(shell echo *.c))
:
: 이런 문장이 있는데요 patsubst 가 무슨 동작을 하는거죠?
:
: make파일을 콘솔프로그램으로 대체를 하려 하는데 위의 문장이 무슨 동작을 하는지 알수가 없습니다.
:
: 도와주세요... ^^
: (출처 : '$(patsubst %.c,%.o,$(shell echo *.c))' - 네이버 지식iN)

 

Naver에서 검색해봤습니다.

GNU macro processor - patsubst

Node: patsubst.html">patsubst Next: Format Prev: Translit Up: Text handling


Substituting text by regular expression

Global substitution in a string is done by patsubst :

	patsubst(string, regexp, opt replacement)

which searches string for matches of regexp, and substitutes replacement for each match. The syntax for regular expressions is the same as in GNU Emacs.

The parts of string that are not covered by any match of regexp are copied to the expansion. Whenever a match is found, the search proceeds from the end of the match, so a character from string will never be substituted twice. If regexp matches a string of zero length, the start position for the search is incremented, to avoid infinite loops.

When a replacement is to be made, replacement is inserted into the expansion, with `\n' substituted by the text matched by the nth parenthesized sub-expression of regexp, `\&' being the text the entire regular expression matched.

The replacement argument can be omitted, in which case the text matched by regexp is deleted.

	patsubst(`GNUs not Unix', `^', `OBS: ')
	=>OBS: GNUs not Unix
	patsubst(`GNUs not Unix', `\<', `OBS: ')
	=>OBS: GNUs OBS: not OBS: Unix
	patsubst(`GNUs not Unix', `\w*', `(\&)')
	=>(GNUs)() (not)() (Unix)
	patsubst(`GNUs not Unix', `\w+', `(\&)')
	=>(GNUs) (not) (Unix)
	patsubst(`GNUs not Unix', `[A-Z][a-z]+')
	=>GN not 

Here is a slightly more realistic example, which capitalizes individual word or whole sentences, by substituting calls of the macros upcase and downcase into the strings.

	define(`upcase', `translit(`$*', `a-z', `A-Z')')dnl
	define(`downcase', `translit(`$*', `A-Z', `a-z')')dnl
	define(`capitalize1',
	     `regexp(`$1', `^\(\w\)\(\w*\)', `upcase(`\1')`'downcase(`\2')')')dnl
	define(`capitalize',
	     `patsubst(`$1', `\w+', `capitalize1(`\&')')')dnl
	capitalize(`GNUs not Unix')
	=>Gnus Not Unix

The builtin macro patsubst is recognized only when given arguments.


Next: Format Up: Text handling


+ -

관련 글 리스트
45743 $(patsubst %.c,%.o,$(shell echo *.c)) 이거 아시는분 금영이 1130 2006/07/20
45762     Re:$(patsubst %.c,%.o,$(shell echo *.c)) 이거 아시는분 고황일 1489 2006/07/20
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.