Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r75779 - in branches/quickbook-dev: . boost boost/math boost/math/constants boost/random/detail boost/signals2/detail libs libs/math libs/math/doc/sf_and_dist libs/phoenix/doc/starter_kit tools tools/build/v2/engine tools/quickbook tools/quickbook/src tools/quickbook/test tools/quickbook/test/command-line tools/quickbook/test/xinclude
From: dnljms_at_[hidden]
Date: 2011-12-03 04:26:32


Author: danieljames
Date: 2011-12-03 04:26:25 EST (Sat, 03 Dec 2011)
New Revision: 75779
URL: http://svn.boost.org/trac/boost/changeset/75779

Log:
Quickbook: Merge from trunk to quickbook-dev.
Added:
   branches/quickbook-dev/tools/quickbook/test/command-line/basic-1_6.quickbook
      - copied unchanged from r75778, /trunk/tools/quickbook/test/command-line/basic-1_6.quickbook
   branches/quickbook-dev/tools/quickbook/test/xinclude/
      - copied from r75778, /trunk/tools/quickbook/test/xinclude/
Removed:
   branches/quickbook-dev/tools/quickbook/test/xinclude-1_1.gold
   branches/quickbook-dev/tools/quickbook/test/xinclude-1_1.quickbook
   branches/quickbook-dev/tools/quickbook/test/xmlbase-1_6.gold
   branches/quickbook-dev/tools/quickbook/test/xmlbase-1_6.quickbook
Properties modified:
   branches/quickbook-dev/ (props changed)
   branches/quickbook-dev/boost/ (props changed)
   branches/quickbook-dev/boost/math/ (props changed)
   branches/quickbook-dev/libs/ (props changed)
   branches/quickbook-dev/libs/math/ (props changed)
   branches/quickbook-dev/tools/ (props changed)
   branches/quickbook-dev/tools/quickbook/ (props changed)
Text files modified:
   branches/quickbook-dev/boost/math/constants/constants.hpp | 3
   branches/quickbook-dev/boost/random/detail/signed_unsigned_tools.hpp | 2
   branches/quickbook-dev/boost/signals2/detail/auto_buffer.hpp | 2
   branches/quickbook-dev/libs/math/doc/sf_and_dist/roadmap.qbk | 3
   branches/quickbook-dev/libs/phoenix/doc/starter_kit/operator.qbk | 6 +
   branches/quickbook-dev/libs/phoenix/doc/starter_kit/values.qbk | 9
   branches/quickbook-dev/tools/build/v2/engine/filent.c | 33 +++--
   branches/quickbook-dev/tools/build/v2/engine/filesys.c | 4
   branches/quickbook-dev/tools/build/v2/engine/function.c | 216 ++++++++++++++++++++++++++++++++++++++++
   branches/quickbook-dev/tools/build/v2/engine/jam.c | 1
   branches/quickbook-dev/tools/build/v2/engine/pathsys.h | 9 +
   branches/quickbook-dev/tools/build/v2/engine/pathunix.c | 70 ++++++++++++
   branches/quickbook-dev/tools/build/v2/engine/rules.c | 6 -
   branches/quickbook-dev/tools/build/v2/engine/search.c | 12 +
   branches/quickbook-dev/tools/build/v2/engine/timestamp.c | 38 ------
   branches/quickbook-dev/tools/quickbook/src/actions.cpp | 9
   branches/quickbook-dev/tools/quickbook/src/doc_info_actions.cpp | 18 ++
   branches/quickbook-dev/tools/quickbook/src/files.cpp | 3
   branches/quickbook-dev/tools/quickbook/src/quickbook.cpp | 37 ++++++
   branches/quickbook-dev/tools/quickbook/test/Jamfile.v2 | 3
   branches/quickbook-dev/tools/quickbook/test/command-line/Jamfile.v2 | 12 +
   branches/quickbook-dev/tools/quickbook/test/version-0_1-fail.quickbook | 2
   22 files changed, 418 insertions(+), 80 deletions(-)

Modified: branches/quickbook-dev/boost/math/constants/constants.hpp
==============================================================================
--- branches/quickbook-dev/boost/math/constants/constants.hpp (original)
+++ branches/quickbook-dev/boost/math/constants/constants.hpp 2011-12-03 04:26:25 EST (Sat, 03 Dec 2011)
@@ -64,7 +64,8 @@
   BOOST_DEFINE_MATH_CONSTANT(ln_two, 0.693147180559945309417232121458176568075500134360255254, 120680009493393621969694715605863326996418687, 0)
   BOOST_DEFINE_MATH_CONSTANT(ln_ln_two, -0.36651292058166432701243915823266946945426344783710526305367771367056, 16153193527385494558228566989083583025230453648347655663425171940646634, 0)
   BOOST_DEFINE_MATH_CONSTANT(third, 0.3333333333333333333333333333333333333333333333333333333333333333333333, 3333333333333333333333333333333333333333333333333333333333333333333333333, 0)
- BOOST_DEFINE_MATH_CONSTANT(twothirds, 0.66666666666666666666666666666666666666666666666666666666666666666666, 66666666666666666666666666666666666666666666666666666666666666666666667, 0)
+ BOOST_DEFINE_MATH_CONSTANT(twothirds, 0.66666666666666666666666666666666666666666666666666666666666666666666, 66666666666666666666666666666666666666666666666666666666666666666666667, 0) //deprecated, use two_thirds.
+ BOOST_DEFINE_MATH_CONSTANT(two_thirds, 0.66666666666666666666666666666666666666666666666666666666666666666666, 66666666666666666666666666666666666666666666666666666666666666666666667, 0)
   BOOST_DEFINE_MATH_CONSTANT(pi_minus_three, 0.141592653589793238462643383279502884197169399375105820974944, 59230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196, 0)
   BOOST_DEFINE_MATH_CONSTANT(four_minus_pi, 0.85840734641020676153735661672049711580283060062489417902505540769218359, 0, 0)
   BOOST_DEFINE_MATH_CONSTANT(pow23_four_minus_pi, 0.79531676737159754434839533505680658072763917332771320544530223438582161, 0, 0)

Modified: branches/quickbook-dev/boost/random/detail/signed_unsigned_tools.hpp
==============================================================================
--- branches/quickbook-dev/boost/random/detail/signed_unsigned_tools.hpp (original)
+++ branches/quickbook-dev/boost/random/detail/signed_unsigned_tools.hpp 2011-12-03 04:26:25 EST (Sat, 03 Dec 2011)
@@ -73,7 +73,7 @@
     if (y >= 0)
       return T2(x) + y;
     // y < 0
- if (x >= T1(-(y+1))) // result >= 0 after subtraction
+ if (x > T1(-(y+1))) // result >= 0 after subtraction
       // avoid the nasty two's complement edge case for y == min()
       return T2(x - T1(-(y+1)) - 1);
     // abs(x) < abs(y), thus T2 able to represent x

Modified: branches/quickbook-dev/boost/signals2/detail/auto_buffer.hpp
==============================================================================
--- branches/quickbook-dev/boost/signals2/detail/auto_buffer.hpp (original)
+++ branches/quickbook-dev/boost/signals2/detail/auto_buffer.hpp 2011-12-03 04:26:25 EST (Sat, 03 Dec 2011)
@@ -562,7 +562,7 @@
               buffer_( allocate(members_.capacity_) ),
               size_( 0 )
         {
- std::uninitialized_fill( buffer_, buffer_ + size, init_value );
+ std::uninitialized_fill( buffer_, buffer_ + size_arg, init_value );
             size_ = size_arg;
             BOOST_ASSERT( is_valid() );
         }

Modified: branches/quickbook-dev/libs/math/doc/sf_and_dist/roadmap.qbk
==============================================================================
--- branches/quickbook-dev/libs/math/doc/sf_and_dist/roadmap.qbk (original)
+++ branches/quickbook-dev/libs/math/doc/sf_and_dist/roadmap.qbk 2011-12-03 04:26:25 EST (Sat, 03 Dec 2011)
@@ -2,6 +2,9 @@
 
 [h4 Boost-1.49]
 
+* Deprecated wrongly named `twothirds` math constant in favour of `two_thirds` (with underscore separator).
+(issue [@https://svn.boost.org/trac/boost/ticket/6199 #6199]).
+
 Fixed issues
 
 * Corrected CDF complement for Laplace distribution (issue [@https://svn.boost.org/trac/boost/ticket/6151 #6151]).

Modified: branches/quickbook-dev/libs/phoenix/doc/starter_kit/operator.qbk
==============================================================================
--- branches/quickbook-dev/libs/phoenix/doc/starter_kit/operator.qbk (original)
+++ branches/quickbook-dev/libs/phoenix/doc/starter_kit/operator.qbk 2011-12-03 04:26:25 EST (Sat, 03 Dec 2011)
@@ -40,6 +40,12 @@
     x[ref(i)] // illegal (x is not a phoenix primitive or expression)
     ref(x[ref(i)]) // illegal (x is not a phoenix primitive or expression)
 
+Why are the last two expression illegal? Although `operator[]` looks as
+much like a binary operator as `operator=` above it; the difference is
+that the former must be a member (i.e. `x` must have an `operator[]`
+that takes a phoenix primitive or expression as its argument). This will
+most likely not be the case.
+
 [blurb __tip__ Learn more about operators [link phoenix.modules.operator here.]]
 
 [heading First Practical Example]

Modified: branches/quickbook-dev/libs/phoenix/doc/starter_kit/values.qbk
==============================================================================
--- branches/quickbook-dev/libs/phoenix/doc/starter_kit/values.qbk (original)
+++ branches/quickbook-dev/libs/phoenix/doc/starter_kit/values.qbk 2011-12-03 04:26:25 EST (Sat, 03 Dec 2011)
@@ -20,10 +20,11 @@
 
 [heading Lazy Evaluation]
 
-Confused? `val(3)` is a unary function, you say? Yes it is. However, read
-carefully: /"evaluates to a nullary function"/. `val(3)` evaluates to (returns) a
-nullary function. Aha! `val(3)` returns a function! So, since `val(3)` returns a
-function, you can invoke it. Example:
+Confused? `val` is a unary function and `val(3)` invokes it, you say?
+Yes. However, read carefully: /"evaluates to a nullary function"/.
+`val(3)` evaluates to (returns) a nullary function. Aha! `val(3)`
+returns a function! So, since `val(3)` returns a function, you can
+invoke it. Example:
 
     std::cout << val(3)() << std::endl;
 

Modified: branches/quickbook-dev/tools/build/v2/engine/filent.c
==============================================================================
--- branches/quickbook-dev/tools/build/v2/engine/filent.c (original)
+++ branches/quickbook-dev/tools/build/v2/engine/filent.c 2011-12-03 04:26:25 EST (Sat, 03 Dec 2011)
@@ -63,8 +63,6 @@
 
     file_info_t * d = 0;
 
- dir = short_path_to_long_path( dir );
-
     /* First enter directory itself */
 
     d = file_query( dir );
@@ -85,11 +83,15 @@
         int ret;
         struct _finddata_t finfo[ 1 ];
         LIST * files = L0;
- int d_length = strlen( object_str( d->name ) );
+ int d_length;
+
+ dir = short_path_to_long_path( dir );
+
+ d_length = strlen( object_str( dir ) );
 
         memset( (char *)&f, '\0', sizeof( f ) );
 
- f.f_dir.ptr = object_str( d->name );
+ f.f_dir.ptr = object_str( dir );
         f.f_dir.len = d_length;
 
         /* Now enter contents of directory */
@@ -104,8 +106,8 @@
              * its trailing path separator or otherwise we would not support the
              * Windows root folder specified without its drive letter, i.e. '\'.
              */
- char trailingChar = object_str( d->name )[ d_length - 1 ] ;
- string_copy( filespec, object_str( d->name ) );
+ char trailingChar = object_str( dir )[ d_length - 1 ] ;
+ string_copy( filespec, object_str( dir ) );
             if ( ( trailingChar != '\\' ) && ( trailingChar != '/' ) )
                 string_append( filespec, "\\" );
             string_append( filespec, "*" );
@@ -181,6 +183,7 @@
         # endif
         string_free( filename );
         string_free( filespec );
+ object_free( dir );
 
         d->files = files;
     }
@@ -189,11 +192,17 @@
     {
         unsigned long len = strlen( object_str( d->name ) );
         if ( len == 1 && object_str( d->name )[0] == '\\' )
- (*func)( closure, d->name, 1 /* stat()'ed */, d->time );
- else if ( len == 3 && object_str( d->name )[1] == ':' ) {
+ {
+ OBJECT * dir = short_path_to_long_path( d->name );
+ (*func)( closure, dir, 1 /* stat()'ed */, d->time );
+ object_free( dir );
+ }
+ else if ( len == 3 && object_str( d->name )[1] == ':' )
+ {
             char buf[4];
+ OBJECT * dir1 = short_path_to_long_path( d->name );
             OBJECT * dir2;
- (*func)( closure, d->name, 1 /* stat()'ed */, d->time );
+ (*func)( closure, dir1, 1 /* stat()'ed */, d->time );
             /* We've just entered 3-letter drive name spelling (with trailing
                slash), into the hash table. Now enter two-letter variant,
                without trailing slash, so that if we try to check whether
@@ -206,11 +215,12 @@
                There will be no trailing slash in $(p), but there will be one
                in $(p2). But, that seems rather fragile.
             */
- strcpy( buf, object_str( d->name ) );
+ strcpy( buf, object_str( dir1 ) );
             buf[2] = 0;
             dir2 = object_new( buf );
             (*func)( closure, dir2, 1 /* stat()'ed */, d->time );
             object_free( dir2 );
+ object_free( dir1 );
         }
     }
 
@@ -221,12 +231,11 @@
         while ( files )
         {
             file_info_t * ff = file_info( files->value );
- (*func)( closure, ff->name, 1 /* stat()'ed */, ff->time );
+ (*func)( closure, files->value, 1 /* stat()'ed */, ff->time );
             files = list_next( files );
         }
     }
 
- object_free( dir );
     PROFILE_EXIT( FILE_DIRSCAN );
 }
 

Modified: branches/quickbook-dev/tools/build/v2/engine/filesys.c
==============================================================================
--- branches/quickbook-dev/tools/build/v2/engine/filesys.c (original)
+++ branches/quickbook-dev/tools/build/v2/engine/filesys.c 2011-12-03 04:26:25 EST (Sat, 03 Dec 2011)
@@ -43,6 +43,8 @@
     if ( !filecache_hash )
         filecache_hash = hashinit( sizeof( file_info_t ), "file_info" );
 
+ filename = path_as_key( filename );
+
     finfo->name = filename;
     finfo->is_file = 0;
     finfo->is_dir = 0;
@@ -55,6 +57,8 @@
         finfo->name = object_copy( finfo->name );
     }
 
+ object_free( filename );
+
     return finfo;
 }
 

Modified: branches/quickbook-dev/tools/build/v2/engine/function.c
==============================================================================
--- branches/quickbook-dev/tools/build/v2/engine/function.c (original)
+++ branches/quickbook-dev/tools/build/v2/engine/function.c 2011-12-03 04:26:25 EST (Sat, 03 Dec 2011)
@@ -18,6 +18,7 @@
 #include "class.h"
 #include <string.h>
 #include <stdlib.h>
+#include <stdio.h>
 #include <assert.h>
 
 # ifdef OS_CYGWIN
@@ -90,6 +91,9 @@
 #define INSTR_POP_MODULE 51
 #define INSTR_CLASS 52
 
+#define INSTR_APPEND_STRINGS 53
+#define INSTR_WRITE_FILE 54
+
 typedef struct instruction
 {
     unsigned int op_code;
@@ -952,6 +956,26 @@
     return result;
 }
 
+static void combine_strings( STACK * s, int n, string * out )
+{
+ int i;
+ LIST * l;
+ for ( i = 0; i < n; ++i )
+ {
+ LIST * values = stack_pop( s );
+ if ( values )
+ {
+ string_append( out, object_str( values->value ) );
+ for ( l = list_next( values ); l; l = list_next( l ) )
+ {
+ string_push_back( out, ' ' );
+ string_append( out, object_str( l->value ) );
+ }
+ list_free( values );
+ }
+ }
+}
+
 struct dynamic_array
 {
     int size;
@@ -1176,6 +1200,7 @@
 
 #define VAR_PARSE_TYPE_VAR 0
 #define VAR_PARSE_TYPE_STRING 1
+#define VAR_PARSE_TYPE_FILE 2
 
 typedef struct _var_parse
 {
@@ -1196,6 +1221,13 @@
     OBJECT * s;
 } VAR_PARSE_STRING;
 
+typedef struct
+{
+ int type;
+ struct dynamic_array filename[1];
+ struct dynamic_array contents[1];
+} VAR_PARSE_FILE;
+
 static void var_parse_free( VAR_PARSE * );
 
 /*
@@ -1284,6 +1316,31 @@
 }
 
 /*
+ * VAR_PARSE_FILE
+ */
+
+static VAR_PARSE_FILE * var_parse_file_new( void )
+{
+ VAR_PARSE_FILE * result = (VAR_PARSE_FILE *)BJAM_MALLOC( sizeof( VAR_PARSE_FILE ) );
+ result->type = VAR_PARSE_TYPE_FILE;
+ dynamic_array_init( result->filename );
+ dynamic_array_init( result->contents );
+ return result;
+}
+
+static void var_parse_file_free( VAR_PARSE_FILE * file )
+{
+ int i;
+ for( i = 0; i < file->filename->size; ++i )
+ var_parse_group_free( dynamic_array_at( VAR_PARSE_GROUP *, file->filename, i ) );
+ dynamic_array_free( file->filename );
+ for( i = 0; i < file->contents->size; ++i )
+ var_parse_group_free( dynamic_array_at( VAR_PARSE_GROUP *, file->contents, i ) );
+ dynamic_array_free( file->contents );
+ BJAM_FREE( file );
+}
+
+/*
  * VAR_PARSE
  */
 
@@ -1297,6 +1354,10 @@
     {
         var_parse_string_free( (VAR_PARSE_STRING *)parse );
     }
+ else if ( parse->type == VAR_PARSE_TYPE_FILE )
+ {
+ var_parse_file_free( (VAR_PARSE_FILE *)parse );
+ }
     else
     {
         assert(!"Invalid type");
@@ -1395,6 +1456,21 @@
     compile_emit( c, INSTR_PUSH_CONSTANT, compile_emit_constant( c, parse->s ) );
 }
 
+static void var_parse_file_compile( const VAR_PARSE_FILE * parse, compiler * c )
+{
+ int i;
+ for ( i = 0; i < parse->filename->size; ++i )
+ {
+ var_parse_group_compile( dynamic_array_at( VAR_PARSE_GROUP *, parse->filename, parse->filename->size - i - 1 ), c );
+ }
+ compile_emit( c, INSTR_APPEND_STRINGS, parse->filename->size );
+ for ( i = 0; i < parse->contents->size; ++i )
+ {
+ var_parse_group_compile( dynamic_array_at( VAR_PARSE_GROUP *, parse->contents, parse->contents->size - i - 1 ), c );
+ }
+ compile_emit( c, INSTR_WRITE_FILE, parse->contents->size );
+}
+
 static void var_parse_compile( const VAR_PARSE * parse, compiler * c )
 {
     if( parse->type == VAR_PARSE_TYPE_VAR )
@@ -1405,6 +1481,14 @@
     {
         var_parse_string_compile( (const VAR_PARSE_STRING *)parse, c );
     }
+ else if( parse->type == VAR_PARSE_TYPE_FILE )
+ {
+ var_parse_file_compile( (const VAR_PARSE_FILE *)parse, c );
+ }
+ else
+ {
+ assert( !"Unknown var parse type." );
+ }
 }
 
 static void var_parse_group_compile( const VAR_PARSE_GROUP * parse, compiler * c )
@@ -1431,6 +1515,7 @@
  * Parse VAR_PARSE_VAR
  */
 
+static VAR_PARSE * parse_at_file( const char * start, const char * mid, const char * end );
 static VAR_PARSE * parse_variable( const char * * string );
 static int try_parse_variable( const char * * s_, const char * * string, VAR_PARSE_GROUP * out);
 static void balance_parentheses( const char * * s_, const char * * string, VAR_PARSE_GROUP * out);
@@ -1480,6 +1565,41 @@
         *s_ = s;
         return 1;
     }
+ else if(s[0] == '@' && s[1] == '(')
+ {
+ int depth = 1;
+ const char * ine;
+ const char * split = 0;
+ var_parse_group_maybe_add_constant( out, *string, s );
+ s += 2;
+ ine = s;
+
+ /* Scan the content of the response file @() section. */
+ while ( *ine && ( depth > 0 ) )
+ {
+ switch ( *ine )
+ {
+ case '(': ++depth; break;
+ case ')': --depth; break;
+ case ':':
+ if ( ( depth == 1 ) && ( ine[ 1 ] == 'E' ) && ( ine[ 2 ] == '=' ) )
+ split = ine;
+ break;
+ }
+ ++ine;
+ }
+
+ if ( !split || depth != 0 )
+ {
+ return 0;
+ }
+
+ var_parse_group_add( out, parse_at_file( s, split, ine - 1 ) );
+ *string = ine;
+ *s_ = ine;
+
+ return 1;
+ }
     else
     {
         return 0;
@@ -1614,6 +1734,44 @@
     }
 }
 
+static void parse_var_string( const char * first, const char * last, struct dynamic_array * out )
+{
+ const char * saved = first;
+ string buf[1];
+ int state = isspace( *first ) != 0;
+ string_new( buf );
+ for ( ; ; ++first )
+ {
+ if ( first == last || ( isspace( *first ) != 0 ) != state )
+ {
+ VAR_PARSE_GROUP * group;
+ const char * s = buf->value;
+ string_append_range( buf, saved, first );
+ saved = first;
+ group = parse_expansion( &s );
+ string_truncate( buf, 0 );
+ dynamic_array_push( out, group );
+ state = !state;
+ }
+ if ( first == last ) break;
+ }
+ string_free( buf );
+}
+
+/*
+ * start should point to the character immediately following the
+ * opening "@(", mid should point to the ":E=", and end should
+ * point to the closing ")".
+ */
+
+static VAR_PARSE * parse_at_file( const char * start, const char * mid, const char * end )
+{
+ VAR_PARSE_FILE * result = var_parse_file_new();
+ parse_var_string( start, mid, result->filename );
+ parse_var_string( mid + 3, end, result->contents );
+ return (VAR_PARSE *)result;
+}
+
 /*
  * Given that *s_ points to the character after a "(",
  * parses up to the matching ")". *string should
@@ -3007,6 +3165,64 @@
 
             break;
         }
+
+ case INSTR_APPEND_STRINGS:
+ {
+ string buf[1];
+ string_new( buf );
+ combine_strings( s, code->arg, buf );
+ stack_push( s, list_new( L0, object_new( buf->value ) ) );
+ string_free( buf );
+ break;
+ }
+
+ case INSTR_WRITE_FILE:
+ {
+ string buf[1];
+ const char * out;
+ LIST * filename;
+ int out_debug = DEBUG_EXEC ? 1 : 0;
+ FILE * out_file = 0;
+ string_new( buf );
+ combine_strings( s, code->arg, buf );
+ filename = stack_top( s );
+ out = object_str( filename->value );
+ if ( !globs.noexec )
+ {
+ string out_name[1];
+ /* Handle "path to file" filenames. */
+ if ( ( out[ 0 ] == '"' ) && ( out[ strlen( out ) - 1 ] == '"' ) )
+ {
+ string_copy( out_name, out + 1 );
+ string_truncate( out_name, out_name->size - 1 );
+ }
+ else
+ {
+ string_copy( out_name, out );
+ }
+ out_file = fopen( out_name->value, "w" );
+
+ if ( !out_file )
+ {
+ printf( "failed to write output file '%s'!\n", out_name->value );
+ exit( EXITBAD );
+ }
+ string_free( out_name );
+ }
+
+ if ( out_debug ) printf( "\nfile %s\n", out );
+
+ if ( out_file ) fputs( buf->value, out_file );
+ if ( out_debug ) puts( buf->value );
+
+ fflush( out_file );
+ fclose( out_file );
+ string_free( buf );
+
+ if ( out_debug ) fputc( '\n', stdout );
+
+ break;
+ }
 
         }
         ++code;

Modified: branches/quickbook-dev/tools/build/v2/engine/jam.c
==============================================================================
--- branches/quickbook-dev/tools/build/v2/engine/jam.c (original)
+++ branches/quickbook-dev/tools/build/v2/engine/jam.c 2011-12-03 04:26:25 EST (Sat, 03 Dec 2011)
@@ -620,6 +620,7 @@
     regex_done();
     exec_done();
     pwd_done();
+ path_done();
     function_done();
     list_done();
     constants_done();

Modified: branches/quickbook-dev/tools/build/v2/engine/pathsys.h
==============================================================================
--- branches/quickbook-dev/tools/build/v2/engine/pathsys.h (original)
+++ branches/quickbook-dev/tools/build/v2/engine/pathsys.h 2011-12-03 04:26:25 EST (Sat, 03 Dec 2011)
@@ -59,6 +59,13 @@
 
 #endif
 
+/** Given a path, returns an object that can be
+ used as a unique key for that path. Equivalent
+ paths such as a/b, A\B, and a\B on NT all yield the
+ same key.
+ */
+OBJECT * path_as_key( OBJECT * path );
+
 #ifdef USE_PATHUNIX
 /** Returns a static pointer to the system dependent path to the temporary
     directory. NOTE: *without* a trailing path separator.
@@ -83,4 +90,6 @@
 */
 char * executable_path (const char *argv0);
 
+void path_done( void );
+
 #endif

Modified: branches/quickbook-dev/tools/build/v2/engine/pathunix.c
==============================================================================
--- branches/quickbook-dev/tools/build/v2/engine/pathunix.c (original)
+++ branches/quickbook-dev/tools/build/v2/engine/pathunix.c 2011-12-03 04:26:25 EST (Sat, 03 Dec 2011)
@@ -326,6 +326,7 @@
             return len;
         }
         _tcsncpy(ret,path,2);
+ ret[0] = toupper(ret[0]);
     }
 
     /* Expand the path for each subpath, and strip trailing backslashes */
@@ -390,7 +391,74 @@
     if (ret)
         return object_new( buffer2 );
     else
- return object_copy( short_path );
+ return object_copy( short_path );
+}
+
+#endif
+
+#ifdef NT
+
+struct path_key_entry
+{
+ OBJECT * path;
+ OBJECT * key;
+};
+
+static struct hash * path_key_cache;
+
+OBJECT * path_as_key( OBJECT * path )
+{
+ struct path_key_entry e, *result = &e;
+
+ if ( ! path_key_cache )
+ path_key_cache = hashinit( sizeof( struct path_key_entry ), "path to key" );
+
+ result->path = path;
+ if ( hashenter( path_key_cache, (HASHDATA * *)&result ) )
+ {
+ string buf[1];
+ char * s;
+ string_copy( buf, object_str( path ) );
+ for ( s = buf->value; s < buf->value + buf->size; ++s )
+ {
+ if ( *s == '/' )
+ *s = '\\';
+ else
+ *s = tolower( *s );
+ }
+ result->path = object_copy( path );
+ result->key = object_new( buf->value );
+ string_free( buf );
+ }
+
+ return result->key;
+}
+
+static void free_path_key_entry( void * xentry, void * data )
+{
+ struct path_key_entry * entry = (struct path_key_entry *)xentry;
+ object_free( entry->path );
+ object_free( entry->key );
+}
+
+void path_done( void )
+{
+ if ( path_key_cache )
+ {
+ hashenumerate( path_key_cache, &free_path_key_entry, (void *)0 );
+ hashdone( path_key_cache );
+ }
+}
+
+#else
+
+OBJECT * path_as_key( OBJECT * path )
+{
+ return object_copy( path );
+}
+
+void path_done( void )
+{
 }
 
 #endif

Modified: branches/quickbook-dev/tools/build/v2/engine/rules.c
==============================================================================
--- branches/quickbook-dev/tools/build/v2/engine/rules.c (original)
+++ branches/quickbook-dev/tools/build/v2/engine/rules.c 2011-12-03 04:26:25 EST (Sat, 03 Dec 2011)
@@ -164,9 +164,6 @@
     if ( !targethash )
         targethash = hashinit( sizeof( TARGET ), "targets" );
 
-#ifdef NT
- target_name = short_path_to_long_path( target_name );
-#endif
     t->name = target_name;
 
     if ( hashenter( targethash, (HASHDATA * *)&t ) )
@@ -175,9 +172,6 @@
         t->name = object_copy( target_name );
         t->boundname = object_copy( t->name ); /* default for T_FLAG_NOTFILE */
     }
-#ifdef NT
- object_free( target_name );
-#endif
 
     return t;
 }

Modified: branches/quickbook-dev/tools/build/v2/engine/search.c
==============================================================================
--- branches/quickbook-dev/tools/build/v2/engine/search.c (original)
+++ branches/quickbook-dev/tools/build/v2/engine/search.c 2011-12-03 04:26:25 EST (Sat, 03 Dec 2011)
@@ -151,6 +151,7 @@
             BINDING b, *ba = &b;
             file_info_t *ff;
             OBJECT * key;
+ OBJECT * test_path;
 
             f->f_root.ptr = object_str( varlist->value );
             f->f_root.len = strlen( object_str( varlist->value ) );
@@ -161,7 +162,9 @@
             if ( DEBUG_SEARCH )
                 printf( "search %s: %s\n", object_str( target ), buf->value );
 
- key = object_new( buf->value );
+ test_path = object_new( buf->value );
+ key = path_as_key( test_path );
+ object_free( test_path );
             ff = file_query( key );
             timestamp( key, time );
 
@@ -221,14 +224,15 @@
     {
         BINDING b;
         BINDING * ba = &b;
- b.binding = boundname;
+ OBJECT * key = path_as_key( boundname );
+ b.binding = key;
         b.target = target;
         /* CONSIDER: we probably should issue a warning is another file
            is explicitly bound to the same location. This might break
            compatibility, though. */
- if ( hashenter( explicit_bindings, (HASHDATA * *)&ba ) )
+ if ( !hashenter( explicit_bindings, (HASHDATA * *)&ba ) )
         {
- ba->binding = object_copy( boundname );
+ object_free( key );
         }
     }
 

Modified: branches/quickbook-dev/tools/build/v2/engine/timestamp.c
==============================================================================
--- branches/quickbook-dev/tools/build/v2/engine/timestamp.c (original)
+++ branches/quickbook-dev/tools/build/v2/engine/timestamp.c 2011-12-03 04:26:25 EST (Sat, 03 Dec 2011)
@@ -74,28 +74,9 @@
     BINDING binding;
     BINDING * b = &binding;
     string buf[ 1 ];
-#ifdef DOWNSHIFT_PATHS
- string path;
- char * p;
-#endif
-
-#ifdef DOWNSHIFT_PATHS
- string_copy( &path, object_str( target ) );
- p = path.value;
 
- do
- {
- *p = tolower( *p );
-#ifdef NT
- /* On NT, we must use backslashes or the file will not be found. */
- if ( *p == '/' )
- *p = PATH_DELIM;
-#endif
- }
- while ( *p++ );
+ target = path_as_key( target );
 
- target = object_new( path.value );
-#endif /* #ifdef DOWNSHIFT_PATHS */
     string_new( buf );
 
     if ( !bindhash )
@@ -184,10 +165,8 @@
 
     *time = b->progress == BIND_FOUND ? b->time : 0;
         string_free( buf );
-#ifdef DOWNSHIFT_PATHS
- string_free( &path );
+
     object_free( target );
-#endif
 
     PROFILE_EXIT( timestamp );
 }
@@ -199,16 +178,7 @@
     BINDING * b = &binding;
     struct hash * bindhash = (struct hash *)closure;
 
-#ifdef DOWNSHIFT_PATHS
- char path[ MAXJPATH ];
- char * p = path;
- const char * t = object_str( target );
-
- do *p++ = tolower( *t );
- while ( *t++ );
-
- target = object_new( path );
-#endif
+ target = path_as_key( target );
 
     b->name = target;
     b->flags = 0;
@@ -222,9 +192,7 @@
     if ( DEBUG_BINDSCAN )
         printf( "time ( %s ) : %s\n", object_str( target ), time_progress[ b->progress ] );
 
-#ifdef DOWNSHIFT_PATHS
     object_free( target );
-#endif
 }
 
 static void free_timestamps ( void * xbinding, void * data )

Modified: branches/quickbook-dev/tools/quickbook/src/actions.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/actions.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/actions.cpp 2011-12-03 04:26:25 EST (Sat, 03 Dec 2011)
@@ -1716,18 +1716,19 @@
     xinclude_path calculate_xinclude_path(value const& p, quickbook::actions& actions)
     {
         fs::path path = check_path(p, actions);
+ fs::path full_path = path;
 
         // If the path is relative
         if (!path.has_root_directory())
         {
             // Resolve the path from the current file
- path = actions.current_file->path.parent_path() / path;
+ full_path = actions.current_file->path.parent_path() / path;
 
             // Then calculate relative to the current xinclude_base.
- path = path_difference(actions.xinclude_base, path);
+ path = path_difference(actions.xinclude_base, full_path);
         }
 
- return xinclude_path(path, detail::escape_uri(detail::path_to_generic(path)));
+ return xinclude_path(full_path, detail::escape_uri(detail::path_to_generic(path)));
     }
 
     void xinclude_action(quickbook::actions& actions, value xinclude)
@@ -2017,7 +2018,7 @@
                 ++actions.error_count;
 
                 detail::outerr(actions.current_file, first)
- << "Loading file:"
+ << "Loading file "
                     << paths.filename
                     << ": "
                     << detail::utf8(e.what())

Modified: branches/quickbook-dev/tools/quickbook/src/doc_info_actions.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/doc_info_actions.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/doc_info_actions.cpp 2011-12-03 04:26:25 EST (Sat, 03 Dec 2011)
@@ -12,6 +12,7 @@
 #include <boost/bind.hpp>
 #include <boost/algorithm/string/join.hpp>
 #include <boost/foreach.hpp>
+#include <boost/filesystem/v3/operations.hpp>
 #include "quickbook.hpp"
 #include "utils.hpp"
 #include "files.hpp"
@@ -259,8 +260,21 @@
         {
             xinclude_path x = calculate_xinclude_path(xmlbase, actions);
 
- xmlbase_value = x.uri;
- actions.xinclude_base = x.path;
+ if (!fs::is_directory(x.path))
+ {
+ detail::outerr(xmlbase.get_file(), xmlbase.get_position())
+ << "xmlbase \""
+ << detail::utf8(xmlbase.get_quickbook())
+ << "\" isn't a directory."
+ << std::endl;
+
+ ++actions.error_count;
+ }
+ else
+ {
+ xmlbase_value = x.uri;
+ actions.xinclude_base = x.path;
+ }
         }
 
         // Warn about invalid fields

Modified: branches/quickbook-dev/tools/quickbook/src/files.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/files.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/files.cpp 2011-12-03 04:26:25 EST (Sat, 03 Dec 2011)
@@ -120,6 +120,9 @@
                 std::istream_iterator<char>(),
                 std::back_inserter(source));
 
+ if (in.bad())
+ throw load_error("Error reading input file.");
+
             bool inserted;
 
             boost::tie(pos, inserted) = files.emplace(

Modified: branches/quickbook-dev/tools/quickbook/src/quickbook.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/quickbook.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/quickbook.cpp 2011-12-03 04:26:25 EST (Sat, 03 Dec 2011)
@@ -150,6 +150,15 @@
 
             fs::ofstream fileout(fileout_);
 
+ if (fileout.fail()) {
+ ::quickbook::detail::outerr()
+ << "Error opening output file "
+ << fileout_
+ << std::endl;
+
+ return 1;
+ }
+
             if (pretty_print)
             {
                 try
@@ -170,6 +179,15 @@
             {
                 fileout << stage2;
             }
+
+ if (fileout.fail()) {
+ ::quickbook::detail::outerr()
+ << "Error writing to output file "
+ << fileout_
+ << std::endl;
+
+ return 1;
+ }
         }
 
         return result;
@@ -281,6 +299,7 @@
         notify(vm);
 
         bool expect_errors = vm.count("expect-errors");
+ int error_count = 0;
 
         if (vm.count("help"))
         {
@@ -394,6 +413,15 @@
                     xinclude_base = ".";
             }
 
+ if (!fs::is_directory(xinclude_base))
+ {
+ quickbook::detail::outerr()
+ << (vm.count("xinclude-base") ?
+ "xinclude-base is not a directory" :
+ "parent directory not found for output file");
+ ++error_count;
+ }
+
             if (vm.count("image-location"))
             {
                 quickbook::image_location = quickbook::detail::input_to_path(
@@ -408,16 +436,17 @@
                 << quickbook::detail::path_to_stream(fileout)
                 << std::endl;
 
- int r = quickbook::parse_document(filein, fileout, xinclude_base, indent, linewidth, pretty_print);
+ if (!error_count)
+ error_count += quickbook::parse_document(filein, fileout, xinclude_base, indent, linewidth, pretty_print);
 
             if (expect_errors)
             {
- if (!r) quickbook::detail::outerr() << "No errors detected for --expect-errors." << std::endl;
- return !r;
+ if (!error_count) quickbook::detail::outerr() << "No errors detected for --expect-errors." << std::endl;
+ return !error_count;
             }
             else
             {
- return r;
+ return error_count;
             }
         }
         else

Modified: branches/quickbook-dev/tools/quickbook/test/Jamfile.v2
==============================================================================
--- branches/quickbook-dev/tools/quickbook/test/Jamfile.v2 (original)
+++ branches/quickbook-dev/tools/quickbook/test/Jamfile.v2 2011-12-03 04:26:25 EST (Sat, 03 Dec 2011)
@@ -17,6 +17,7 @@
 build-project snippets ;
 build-project "include" ;
 build-project versions ;
+build-project xinclude ;
 
 import quickbook-testing : quickbook-test quickbook-error-test ;
 
@@ -107,8 +108,6 @@
     [ quickbook-error-test version-0_1-fail ]
     [ quickbook-error-test version-1_7-fail ]
     [ quickbook-error-test version-2_0-fail ]
- [ quickbook-test xinclude-1_1 : : : <quickbook-xinclude-base>../src ]
- [ quickbook-test xmlbase-1_6 : : : <quickbook-xinclude-base>../src ]
     [ quickbook-test xml_escape-1_2 ]
     [ quickbook-test xml_escape-1_5 ]
 

Modified: branches/quickbook-dev/tools/quickbook/test/command-line/Jamfile.v2
==============================================================================
--- branches/quickbook-dev/tools/quickbook/test/command-line/Jamfile.v2 (original)
+++ branches/quickbook-dev/tools/quickbook/test/command-line/Jamfile.v2 2011-12-03 04:26:25 EST (Sat, 03 Dec 2011)
@@ -7,14 +7,22 @@
 # http://www.boost.org/LICENSE_1_0.txt)
 #
 
-# Just checking that expect-errors works as advertised.
-
 project quickook/tests/command-line ;
 
 import quickbook-testing : quickbook-test quickbook-fail-test quickbook-error-test ;
 
 test-suite command-line.test :
+ # Check that expect-errors works as advertised.
     [ quickbook-fail-test error-fail : : <testing.arg>--expect-errors ]
     [ quickbook-error-test error1 ]
     [ quickbook-error-test error2 ]
+
+ [ quickbook-error-test
+ non_existent_output :
+ basic-1_6.quickbook :
+ <testing.arg>--output-file=non-existent/basic.xml ]
+ [ quickbook-error-test
+ output_nested_in_file :
+ basic-1_6.quickbook :
+ <testing.arg>--output-file=basic-1_6.quickbook/basic.xml ]
     ;
\ No newline at end of file

Modified: branches/quickbook-dev/tools/quickbook/test/version-0_1-fail.quickbook
==============================================================================
--- branches/quickbook-dev/tools/quickbook/test/version-0_1-fail.quickbook (original)
+++ branches/quickbook-dev/tools/quickbook/test/version-0_1-fail.quickbook 2011-12-03 04:26:25 EST (Sat, 03 Dec 2011)
@@ -1,4 +1,4 @@
-[article Non-existant version of quickbook
+[article Non-existent version of quickbook
     [quickbook 0.1]
 ]
 

Deleted: branches/quickbook-dev/tools/quickbook/test/xinclude-1_1.gold
==============================================================================
--- branches/quickbook-dev/tools/quickbook/test/xinclude-1_1.gold 2011-12-03 04:26:25 EST (Sat, 03 Dec 2011)
+++ (empty file)
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE article PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
-<article id="include" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $" xmlns:xi="http://www.w3.org/2001/XInclude">
- <title>Include</title>
- <xi:include href="../test/stub.xml" />
-</article>

Deleted: branches/quickbook-dev/tools/quickbook/test/xinclude-1_1.quickbook
==============================================================================
--- branches/quickbook-dev/tools/quickbook/test/xinclude-1_1.quickbook 2011-12-03 04:26:25 EST (Sat, 03 Dec 2011)
+++ (empty file)
@@ -1,3 +0,0 @@
-[article Include]
-
-[xinclude stub.xml]

Deleted: branches/quickbook-dev/tools/quickbook/test/xmlbase-1_6.gold
==============================================================================
--- branches/quickbook-dev/tools/quickbook/test/xmlbase-1_6.gold 2011-12-03 04:26:25 EST (Sat, 03 Dec 2011)
+++ (empty file)
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE article PUBLIC "-//Boost//DTD BoostBook XML V1.0//EN" "http://www.boost.org/tools/boostbook/dtd/boostbook.dtd">
-<article id="xinclude_with_xmlbase" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $"
- xml:base="../test" xmlns:xi="http://www.w3.org/2001/XInclude">
- <title>XInclude with xmlbase</title>
- <xi:include href="stub.xml" />
-</article>

Deleted: branches/quickbook-dev/tools/quickbook/test/xmlbase-1_6.quickbook
==============================================================================
--- branches/quickbook-dev/tools/quickbook/test/xmlbase-1_6.quickbook 2011-12-03 04:26:25 EST (Sat, 03 Dec 2011)
+++ (empty file)
@@ -1,6 +0,0 @@
-[article XInclude with xmlbase
-[quickbook 1.6]
-[xmlbase .]
-]
-
-[xinclude stub.xml]


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