|
Boost-Commit : |
From: jurko.gospodnetic_at_[hidden]
Date: 2008-01-08 23:05:30
Author: jurko
Date: 2008-01-08 23:05:29 EST (Tue, 08 Jan 2008)
New Revision: 42629
URL: http://svn.boost.org/trac/boost/changeset/42629
Log:
Updated the __ACTION_RULE__ to not return its action command output as a single string but instead split it into a list of output lines. This allows Jam code using this output to work correctly independently of what newline character combinations are in use. This was causing problems with Boost Build unit tests which can now be updated to pass.
Consequences & checks:
* Final __ACTION_RULE__ rule parameter has changed from output ? to output-lines *.
* Updated corresponding Jam documentation.
* Updated the all related Boost Build code.
* No code on the Boost trunk uses this rule except for Boost Build itself.
Text files modified:
trunk/tools/build/v2/build-system.jam | 6 +++---
trunk/tools/jam/doc/bjam.qbk | 8 ++++----
trunk/tools/jam/doc/history.qbk | 14 ++++++++++++++
trunk/tools/jam/src/make1.c | 37 +++++++++++++++++++++++++++++++++----
4 files changed, 54 insertions(+), 11 deletions(-)
Modified: trunk/tools/build/v2/build-system.jam
==============================================================================
--- trunk/tools/build/v2/build-system.jam (original)
+++ trunk/tools/build/v2/build-system.jam 2008-01-08 23:05:29 EST (Tue, 08 Jan 2008)
@@ -764,7 +764,7 @@
# result of @(...) below (the name of the XML file).
#
rule out-xml.generate-action ( args * : xml-file
- : command status start end user system : output ? )
+ : command status start end user system : output-lines * )
{
local contents =
[ on $(xml-file) return $(.header) $(.contents) $(.footer) ] ;
@@ -784,7 +784,7 @@
# target.
#
rule out-xml.collect ( xml-file : target : command status start end user
- system : output ? )
+ system : output-lines * )
{
local nl = "
" ;
@@ -836,7 +836,7 @@
"$(nl) <jam-target><![CDATA[$(target)]]></jam-target>"
"$(nl) <path><![CDATA[$(target:G=:R=$(locate))]]></path>"
"$(nl) <command><![CDATA[$(command)]]></command>"
- "$(nl) <output><![CDATA[$(output)]]></output>" ;
+ "$(nl) <output><![CDATA[$(output-lines:J=$(nl))$(nl)]]></output>" ;
.contents on $(xml-file) +=
"$(nl) </action>" ;
}
Modified: trunk/tools/jam/doc/bjam.qbk
==============================================================================
--- trunk/tools/jam/doc/bjam.qbk (original)
+++ trunk/tools/jam/doc/bjam.qbk 2008-01-08 23:05:29 EST (Tue, 08 Jan 2008)
@@ -1456,7 +1456,7 @@
And =__ACTION_RULE__= is called as:
- rule action-rule ( args * : target : command status start end user system : output ? )
+ rule action-rule ( args * : target : command status start end user system : output-lines * )
The arguments for both are:
@@ -1480,9 +1480,9 @@
[[[^system]]
[The number of system CPU seconds the executed command spent as a floating
point value.]]
- [[[^output]]
- [The output of the command as a single string. The content of the output
- reflects the use of the =-pX= option.]]
+ [[[^output-lines]]
+ [List of lines outputed by the command. The output content reflects the
+ use of the =-pX= option.]]
]
[note
Modified: trunk/tools/jam/doc/history.qbk
==============================================================================
--- trunk/tools/jam/doc/history.qbk (original)
+++ trunk/tools/jam/doc/history.qbk 2008-01-08 23:05:29 EST (Tue, 08 Jan 2008)
@@ -1,5 +1,19 @@
[variablelist
+[[3.1.17] [
+
+In development...
+
+[list
+ [li __ACTION_RULE__ now receives the action output as a list of output lines
+ instead of a single string to work around problems with different
+ newline character combinations.
+ -- ['Jurko Gospodnetic.]
+ ]
+]
+
+]]
+
[[3.1.16] [
This is mostly a bug fix release.
Modified: trunk/tools/jam/src/make1.c
==============================================================================
--- trunk/tools/jam/src/make1.c (original)
+++ trunk/tools/jam/src/make1.c 2008-01-08 23:05:29 EST (Tue, 08 Jan 2008)
@@ -751,10 +751,39 @@
outf_double(time->system) ) );
/* output ? :: the output of the action command */
- if (command_output)
- lol_add(frame->args, list_new(L0, newstr(command_output)));
- else
- lol_add(frame->args, L0);
+ {
+ // Split command output into separate lines. We consider both \n and
+ // \r\n to be valid newline sequences.
+ LIST* output_lines = L0;
+ if ( command_output )
+ {
+ char * line = command_output;
+ char index = 0;
+ while ( line[index] )
+ {
+ if ( line[index] != '\r' )
+ ++index;
+ else
+ {
+ int next = index + 1;
+ if ( line[next] == '\n' ) ++next;
+ {
+ char temp_char = line[index];
+ line[index] = 0;
+ output_lines = list_new(output_lines, newstr(line));
+ line[index] = temp_char;
+ }
+ index = 0;
+ line += next;
+ }
+ }
+ // Check for the case when there is no trailing newline
+ // sequence.
+ if ( index )
+ output_lines = list_new(output_lines, newstr(line));
+ }
+ lol_add(frame->args, output_lines);
+ }
/* Call the rule. */
evaluate_rule( action_rule->string, frame );
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk