View | Details | Raw Unified | Return to issue 46987
Collapse All | Expand All

(-)dmake/expand.c (-2 / +23 lines)
Lines 37-50 Link Here
37
--               D or d      - Directory portion of token including separator
37
--               D or d      - Directory portion of token including separator
38
--               F or f      - File portion of token including suffix
38
--               F or f      - File portion of token including suffix
39
--               B or b      - basename portion of token not including suffix
39
--               B or b      - basename portion of token not including suffix
40
--		 T or t      - for tokenization
41
--		 E or e      - Suffix portion of name
40
--		 E or e      - Suffix portion of name
42
--		 L or l	     - translate to lower case
41
--		 L or l	     - translate to lower case
43
--	         U or u      - translate to upper case
42
--	         U or u      - translate to upper case
44
--		 I or i	     - return inferred names
43
--		 I or i	     - return inferred names
45
--
44
--
46
--	  or a single
45
--	  or a single one of:
46
--               M or M      - map escape codes
47
--               S or s      - pattern substitution (simple)
47
--               S or s      - pattern substitution (simple)
48
--               T or t      - for tokenization
48
--               
49
--               
49
--        NOTE:  Modifiers are applied once the macro value has been found.
50
--        NOTE:  Modifiers are applied once the macro value has been found.
50
--               Thus the construct $($(test):s/joe/mary/) is defined and
51
--               Thus the construct $($(test):s/joe/mary/) is defined and
Lines 846-851 Link Here
846
847
847
	       case 'u':
848
	       case 'u':
848
	       case 'U': modifier_list |= TOUPPER_FLAG; break;
849
	       case 'U': modifier_list |= TOUPPER_FLAG; break;
850
851
	       case 'm':
852
	       case 'M':
853
		  if( modifier_list || ( (*s != edelim) && (*s != ':') ) ) {
854
		     Warning( "Map escape modifier must appear alone, ignored");
855
		     modifier_list = 0;
856
		  }
857
		  else {
858
		     /* map the escape codes in the separator string first */
859
		     for(p=result; (p = strchr(p,ESCAPE_CHAR)) != NIL(char); p++)
860
		        Map_esc( p );
861
		  }
862
		  /* find the end of the macro spec, or the start of a new
863
		   * modifier list for further processing of the result */
864
865
		  for( ; (*s != edelim) && (*s != ':') && *s; s++ );
866
		  if( !*s )
867
		     Fatal( "Syntax error in macro. [$%s].\n", start );
868
		  if( *s == ':' ) s++;
869
		  break;
849
870
850
	       case 'S':
871
	       case 'S':
851
	       case 's':
872
	       case 's':
(-)dmake/man/dmake.tf (-19 / +25 lines)
Lines 784-791 Link Here
784
.LP
784
.LP
785
where
785
where
786
.I modifier_list
786
.I modifier_list
787
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
787
is chosen from the set { B or b, D or d, E or e, F or f, I or i, L or l,
788
s, T or t, U or u, ^, +, 1 } and
788
M or m, S or s, T or t, U or u, ^, +, 1 } and
789
.RS
789
.RS
790
.sp
790
.sp
791
.Is "b  "
791
.Is "b  "
Lines 801-806 Link Here
801
\- inferred names of targets
801
\- inferred names of targets
802
.Ii "l"
802
.Ii "l"
803
\- macro value in lower case
803
\- macro value in lower case
804
.Ii "m"
805
\- map escape codes found in macro to their ASCII value
804
.Ii "s"
806
.Ii "s"
805
\- simple pattern substitution
807
\- simple pattern substitution
806
.Ii "t"
808
.Ii "t"
Lines 852-863 Link Here
852
final directory separator string.  Thus successive pairs of :d modifiers
854
final directory separator string.  Thus successive pairs of :d modifiers
853
each remove a level of directory in the token string.
855
each remove a level of directory in the token string.
854
.PP
856
.PP
855
The tokenization modifier takes all white space separated tokens from the
857
The map escape codes modifier changes the following escape codes \ea => <bel>,
856
macro value and separates them by the quoted separator string.  The separator
857
string may contain the following escape codes \ea => <bel>,
858
\&\eb => <backspace>, \ef => <formfeed>, \en => <nl>, \er => <cr>,
858
\&\eb => <backspace>, \ef => <formfeed>, \en => <nl>, \er => <cr>,
859
\&\et => <tab>, \ev => <vertical tab>, \e" => ", and \exxx => <xxx> where
859
\&\et => <tab>, \ev => <vertical tab>, \e" => ", and \exxx => <xxx> where
860
xxx is the octal representation of a character.  Thus the
860
xxx is the octal representation of a character into the corresponding ASCII
861
value.
862
.PP
863
The tokenization modifier takes all white space separated tokens from the
864
macro value and separates them by the quoted separator string.  The separator
865
string may contain the same escape that are supported by the map escape codes
866
modifier.  Thus the
861
expansion:
867
expansion:
862
.LP
868
.LP
863
.RS
869
.RS
Lines 1264-1271 Link Here
1264
.sp
1270
.sp
1265
.RE
1271
.RE
1266
then all text contained in the \fIdata\fP expression is expanded and
1272
then all text contained in the \fIdata\fP expression is expanded and
1267
is written to a temporary file.  The return
1273
is written to a temporary file.  The \fIdata\fP in the file will always
1268
value of the macro is the name of the temporary file.
1274
be terminated from a new line character.  The return
1275
value of the macro is the name of the temporary file unless the \fItext\fP
1276
parameter is defined. In this case the return value is the expanded value
1277
of \fItext\fP.
1269
.PP
1278
.PP
1270
.I data
1279
.I data
1271
can be any text and must be separated from the 'mktmp' portion of the
1280
can be any text and must be separated from the 'mktmp' portion of the
Lines 1296-1311 Link Here
1296
expansions persist for the duration of the
1305
expansions persist for the duration of the
1297
.B dmake
1306
.B dmake
1298
run.
1307
run.
1299
The diversion text may contain
1308
If the \fIdata\fP text is to contain new lines the map escape codes macro
1300
the same escape codes as those described in the MACROS section.
1309
expasion can be used.  For example the expression:
1301
Thus if the \fIdata\fP text is to contain new lines they must be inserted
1302
using the \en escape sequence.  For example the expression:
1303
.RS
1310
.RS
1304
.sp
1311
.sp
1305
.nf
1312
.nf
1313
mytext:=this is a\entest of the text diversion
1306
all:
1314
all:
1307
	cat $(mktmp this is a\en\e
1315
	cat $(mktmp $(mytext:m))
1308
	test of the text diversion\en)
1309
.fi
1316
.fi
1310
.sp
1317
.sp
1311
.RE
1318
.RE
Lines 1316-1323 Link Here
1316
.sp
1323
.sp
1317
.RE
1324
.RE
1318
where the temporary file contains two lines both of which are terminated
1325
where the temporary file contains two lines both of which are terminated
1319
by a new-line.  If the \fIdata\fP text spans multiple lines in the makefile
1326
by a new-line.
1320
then each line must be continued via the use of a \e.
1321
A second more illustrative example generates a response file to an MSDOS
1327
A second more illustrative example generates a response file to an MSDOS
1322
link command:
1328
link command:
1323
.RS
1329
.RS
Lines 1325-1331 Link Here
1325
.nf
1331
.nf
1326
OBJ = fred.obj mary.obj joe.obj
1332
OBJ = fred.obj mary.obj joe.obj
1327
all : $(OBJ)
1333
all : $(OBJ)
1328
	link @$(mktmp $(^:t"+\en")\en)
1334
	link @$(mktmp $(^:t"+\en"))
1329
.fi
1335
.fi
1330
.sp
1336
.sp
1331
.RE
1337
.RE
Lines 1345-1352 Link Here
1345
.fi
1351
.fi
1346
.sp
1352
.sp
1347
.RE
1353
.RE
1348
The last line of the file is terminated by a new-line which is inserted
1354
The last line of the file is terminated by a new-line which is always
1349
due to the \en found at the end of the \fIdata\fP string.
1355
inserted at the end of the \fIdata\fP string.
1350
.PP
1356
.PP
1351
If the optional \fIfile\fP specifier is present then its expanded value
1357
If the optional \fIfile\fP specifier is present then its expanded value
1352
is the name of the temporary file to create.  An example that would be useful
1358
is the name of the temporary file to create.  An example that would be useful

Return to issue 46987