Follow-up Comment #2, bug #35384 (project make): diff -u -r make-3.82/doc/make.texi make-3.82-mine/doc/make.texi --- make-3.82/doc/make.texi 2010-07-19 03:10:54.000000000 -0400 +++ make-3.82-mine/doc/make.texi 2012-01-27 10:39:02.221433328 -0500 @@ -7694,6 +7694,32 @@ This function does nothing more than print its (expanded) argument(s) to standard output. No makefile name or line number is added. The result of the expansion of this function is the empty string. + +@item $(writefile @var{file}, @var{text}@dots{}) +@findex writefile +@cindex printing messages +This function prints its (expanded) @var{text} argument(s) +into @var{file}. No makefile name or line number is added. The +result of the expansion of this function is the empty string. + +This is useful if you need to pass the value of a Make variable +through to a program, and the value is either too large to fit +on a command line due to OS limits, or it contains shell control +characters that you would need to escape if you passed the value +as a command line argument. + +For example, + +@example + +KLINGON_NOVEL = Heghlu'meH QaQ jajvam! ... and so on for 100,000 words. + +translate : + $(writefile novel.klingon.txt, $(KLINGON_NOVEL)) + translate.pl -in novel.klingon.txt -out novel.english.txt + +@end example + @end table @node Running, Implicit Rules, Functions, Top diff -u -r make-3.82/function.c make-3.82-mine/function.c --- make-3.82/function.c 2010-07-12 21:20:39.000000000 -0400 +++ make-3.82-mine/function.c 2012-01-27 10:11:10.701434083 -0500 @@ -1117,6 +1117,42 @@ return o; } +/* + write text into a file +*/ +static char * +func_writefile (char *o, char **argv, const char *funcname) +{ + char **argvp; + char *msg, *p; + int len; + + /* The arguments will be broken on commas. Rather than create yet + another special case where function arguments aren't broken up, + just create a format string that puts them back together. */ + for (len=0, argvp=argv+1; *argvp != 0; ++argvp) + len += strlen (*argvp) + 2; + + p = msg = alloca (len + 1); + + for (argvp=argv+1; argvp[1] != 0; ++argvp) + { + strcpy (p, *argvp); + p += strlen (*argvp); + *(p++) = ','; + *(p++) = ' '; + } + strcpy (p, *argvp); + + FILE *fp = fopen( *argv, "w" ); + if( fp == NULL ) + fatal (reading_file, "writefile: unable to open '%s'", *argv ); + fprintf( fp, "%s", msg ); + fclose( fp ); + + /* The writefile function expands to the empty string. */ + return o; +} /* chop argv[0] into words, and sort them. @@ -2125,6 +2161,7 @@ { STRING_SIZE_TUPLE("info"), 0, 1, 1, func_error}, { STRING_SIZE_TUPLE("error"), 0, 1, 1, func_error}, { STRING_SIZE_TUPLE("warning"), 0, 1, 1, func_error}, + { STRING_SIZE_TUPLE("writefile"), 2, 2, 1, func_writefile}, { STRING_SIZE_TUPLE("if"), 2, 3, 0, func_if}, { STRING_SIZE_TUPLE("or"), 1, 0, 0, func_or}, { STRING_SIZE_TUPLE("and"), 1, 0, 0, func_and},
_______________________________________________________ Reply to this item at: <http://savannah.gnu.org/bugs/?35384> _______________________________________________ Message sent via/by Savannah http://savannah.gnu.org/ _______________________________________________ Bug-make mailing list Bug-make@gnu.org https://lists.gnu.org/mailman/listinfo/bug-make