Index: dmake/expand.c =================================================================== RCS file: /cvs/tools/dmake/expand.c,v retrieving revision 1.4.6.5 diff -u -r1.4.6.5 expand.c --- dmake/expand.c 11 Apr 2005 22:16:52 -0000 1.4.6.5 +++ dmake/expand.c 12 Apr 2005 01:22:36 -0000 @@ -37,14 +37,15 @@ -- D or d - Directory portion of token including separator -- F or f - File portion of token including suffix -- B or b - basename portion of token not including suffix --- T or t - for tokenization -- E or e - Suffix portion of name -- L or l - translate to lower case -- U or u - translate to upper case -- I or i - return inferred names -- --- or a single +-- or a single one of: +-- M or M - map escape codes -- S or s - pattern substitution (simple) +-- T or t - for tokenization -- -- NOTE: Modifiers are applied once the macro value has been found. -- Thus the construct $($(test):s/joe/mary/) is defined and @@ -846,6 +847,26 @@ case 'u': case 'U': modifier_list |= TOUPPER_FLAG; break; + + case 'm': + case 'M': + if( modifier_list || ( (*s != edelim) && (*s != ':') ) ) { + Warning( "Map escape modifier must appear alone, ignored"); + modifier_list = 0; + } + else { + /* map the escape codes in the separator string first */ + for(p=result; (p = strchr(p,ESCAPE_CHAR)) != NIL(char); p++) + Map_esc( p ); + } + /* find the end of the macro spec, or the start of a new + * modifier list for further processing of the result */ + + for( ; (*s != edelim) && (*s != ':') && *s; s++ ); + if( !*s ) + Fatal( "Syntax error in macro. [$%s].\n", start ); + if( *s == ':' ) s++; + break; case 'S': case 's': Index: dmake/man/dmake.tf =================================================================== RCS file: /cvs/tools/dmake/man/dmake.tf,v retrieving revision 1.5.2.3 diff -u -r1.5.2.3 dmake.tf --- dmake/man/dmake.tf 11 Apr 2005 03:28:55 -0000 1.5.2.3 +++ dmake/man/dmake.tf 12 Apr 2005 01:22:36 -0000 @@ -784,8 +784,8 @@ .LP where .I modifier_list -is chosen from the set { B or b, D or d, E or e, F or f, I or i, L or l, S or -s, T or t, U or u, ^, +, 1 } and +is chosen from the set { B or b, D or d, E or e, F or f, I or i, L or l, +M or m, S or s, T or t, U or u, ^, +, 1 } and .RS .sp .Is "b " @@ -801,6 +801,8 @@ \- inferred names of targets .Ii "l" \- macro value in lower case +.Ii "m" +\- map escape codes found in macro to their ASCII value .Ii "s" \- simple pattern substitution .Ii "t" @@ -852,12 +854,16 @@ final directory separator string. Thus successive pairs of :d modifiers each remove a level of directory in the token string. .PP -The tokenization modifier takes all white space separated tokens from the -macro value and separates them by the quoted separator string. The separator -string may contain the following escape codes \ea => , +The map escape codes modifier changes the following escape codes \ea => , \&\eb => , \ef => , \en => , \er => , \&\et => , \ev => , \e" => ", and \exxx => where -xxx is the octal representation of a character. Thus the +xxx is the octal representation of a character into the corresponding ASCII +value. +.PP +The tokenization modifier takes all white space separated tokens from the +macro value and separates them by the quoted separator string. The separator +string may contain the same escape that are supported by the map escape codes +modifier. Thus the expansion: .LP .RS @@ -1264,8 +1270,11 @@ .sp .RE then all text contained in the \fIdata\fP expression is expanded and -is written to a temporary file. The return -value of the macro is the name of the temporary file. +is written to a temporary file. The \fIdata\fP in the file will always +be terminated from a new line character. The return +value of the macro is the name of the temporary file unless the \fItext\fP +parameter is defined. In this case the return value is the expanded value +of \fItext\fP. .PP .I data can be any text and must be separated from the 'mktmp' portion of the @@ -1296,16 +1305,14 @@ expansions persist for the duration of the .B dmake run. -The diversion text may contain -the same escape codes as those described in the MACROS section. -Thus if the \fIdata\fP text is to contain new lines they must be inserted -using the \en escape sequence. For example the expression: +If the \fIdata\fP text is to contain new lines the map escape codes macro +expasion can be used. For example the expression: .RS .sp .nf +mytext:=this is a\entest of the text diversion all: - cat $(mktmp this is a\en\e - test of the text diversion\en) + cat $(mktmp $(mytext:m)) .fi .sp .RE @@ -1316,8 +1323,7 @@ .sp .RE where the temporary file contains two lines both of which are terminated -by a new-line. If the \fIdata\fP text spans multiple lines in the makefile -then each line must be continued via the use of a \e. +by a new-line. A second more illustrative example generates a response file to an MSDOS link command: .RS @@ -1325,7 +1331,7 @@ .nf OBJ = fred.obj mary.obj joe.obj all : $(OBJ) - link @$(mktmp $(^:t"+\en")\en) + link @$(mktmp $(^:t"+\en")) .fi .sp .RE @@ -1345,8 +1351,8 @@ .fi .sp .RE -The last line of the file is terminated by a new-line which is inserted -due to the \en found at the end of the \fIdata\fP string. +The last line of the file is terminated by a new-line which is always +inserted at the end of the \fIdata\fP string. .PP If the optional \fIfile\fP specifier is present then its expanded value is the name of the temporary file to create. An example that would be useful