Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r75537 - in branches/quickbook-dev/tools/quickbook: src test/include
From: dnljms_at_[hidden]
Date: 2011-11-17 16:06:45


Author: danieljames
Date: 2011-11-17 16:06:44 EST (Thu, 17 Nov 2011)
New Revision: 75537
URL: http://svn.boost.org/trac/boost/changeset/75537

Log:
Quickbook: Fix issue with unbalanced sections.
Added:
   branches/quickbook-dev/tools/quickbook/test/include/include_id_unbalanced-1_6.gold (contents, props changed)
   branches/quickbook-dev/tools/quickbook/test/include/include_id_unbalanced-1_6.quickbook (contents, props changed)
   branches/quickbook-dev/tools/quickbook/test/include/include_id_unbalanced-inc1.qbk (contents, props changed)
   branches/quickbook-dev/tools/quickbook/test/include/include_id_unbalanced-inc1a.qbk (contents, props changed)
   branches/quickbook-dev/tools/quickbook/test/include/include_id_unbalanced-inc2.qbk (contents, props changed)
   branches/quickbook-dev/tools/quickbook/test/include/include_id_unbalanced-inc2a.qbk (contents, props changed)
Text files modified:
   branches/quickbook-dev/tools/quickbook/src/id_manager.cpp | 17 +++++++++++++----
   branches/quickbook-dev/tools/quickbook/test/include/Jamfile.v2 | 1 +
   2 files changed, 14 insertions(+), 4 deletions(-)

Modified: branches/quickbook-dev/tools/quickbook/src/id_manager.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/id_manager.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/id_manager.cpp 2011-11-17 16:06:44 EST (Thu, 17 Nov 2011)
@@ -409,10 +409,19 @@
 
     void id_state::restore_section()
     {
- // TODO: Restore when it's a parent
- if (current_file->switched_section &&
- current_file->switched_section == current_file->document->current_section)
- current_file->document->current_section = current_file->original_section;
+ if (current_file->switched_section) {
+ boost::intrusive_ptr<section_info>* section_ptr =
+ &current_file->document->current_section;
+
+ while (*section_ptr) {
+ if (*section_ptr == current_file->switched_section) {
+ *section_ptr = current_file->original_section;
+ break;
+ }
+
+ section_ptr = &(*section_ptr)->parent;
+ }
+ }
     }
 
     std::string id_state::start_file(

Modified: branches/quickbook-dev/tools/quickbook/test/include/Jamfile.v2
==============================================================================
--- branches/quickbook-dev/tools/quickbook/test/include/Jamfile.v2 (original)
+++ branches/quickbook-dev/tools/quickbook/test/include/Jamfile.v2 2011-11-17 16:06:44 EST (Thu, 17 Nov 2011)
@@ -29,6 +29,7 @@
     [ quickbook-test code-include ]
     [ quickbook-test include-id-1.5 ]
     [ quickbook-test include-id-1.6 ]
+ [ quickbook-test include_id_unbalanced-1_6 ]
     [ quickbook-error-test section-fail1 ]
     [ quickbook-error-test section-fail2 ]
     [ quickbook-test in_section-1_5 ]

Added: branches/quickbook-dev/tools/quickbook/test/include/include_id_unbalanced-1_6.gold
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/include/include_id_unbalanced-1_6.gold 2011-11-17 16:06:44 EST (Thu, 17 Nov 2011)
@@ -0,0 +1,60 @@
+<?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="unbalanced" last-revision="DEBUG MODE Date: 2000/12/20 12:00:00 $" xmlns:xi="http://www.w3.org/2001/XInclude">
+ <title>Test include ids with unbalanced sections</title>
+ <section id="include1.inc1">
+ <title><link linkend="include1.inc1">Include 1</link></title>
+ <bridgehead renderas="sect3" id="include1.inc1.h0">
+ <phrase id="include1.inc1.inc1_1"/><link linkend="include1.inc1.inc1_1">Heading
+ 1</link>
+ </bridgehead>
+ <bridgehead renderas="sect3" id="include1a.h0">
+ <phrase id="include1a.inc1a_1"/><link linkend="include1a.inc1a_1">Heading 1</link>
+ </bridgehead>
+ <section id="include1a.inc1a">
+ <title><link linkend="include1a.inc1a">Include 1a</link></title>
+ <bridgehead renderas="sect4" id="include1a.inc1a.h0">
+ <phrase id="include1a.inc1a.inc1a_2"/><link linkend="include1a.inc1a.inc1a_2">Heading
+ 2</link>
+ </bridgehead>
+ <bridgehead renderas="sect4" id="include1a.inc1a.h1">
+ <phrase id="include1a.inc1a.inc1_2"/><link linkend="include1a.inc1a.inc1_2">Heading
+ 2</link>
+ </bridgehead>
+ <bridgehead renderas="sect4" id="include1a.inc1a.h2">
+ <phrase id="include1a.inc1a.x1"/><link linkend="include1a.inc1a.x1">X1</link>
+ </bridgehead>
+ </section>
+ <bridgehead renderas="sect3" id="include1.inc1.h1">
+ <phrase id="include1.inc1.x2"/><link linkend="include1.inc1.x2">X2</link>
+ </bridgehead>
+ </section>
+ <section id="unbalanced.sect1">
+ <title><link linkend="unbalanced.sect1">Section 1</link></title>
+ <bridgehead renderas="sect3" id="unbalanced.sect1.h0">
+ <phrase id="unbalanced.sect1.x1"/><link linkend="unbalanced.sect1.x1">X1</link>
+ </bridgehead>
+ <section id="unbalanced.sect1.sect2">
+ <title><link linkend="unbalanced.sect1.sect2">Section 2</link></title>
+ <bridgehead renderas="sect4" id="unbalanced.sect1.sect2.h0">
+ <phrase id="unbalanced.sect1.sect2.x2"/><link linkend="unbalanced.sect1.sect2.x2">X2</link>
+ </bridgehead>
+ <bridgehead renderas="sect4" id="include2.h0">
+ <phrase id="include2.inc2_1"/><link linkend="include2.inc2_1">Heading 1</link>
+ </bridgehead>
+ </section>
+ <bridgehead renderas="sect3" id="unbalanced.sect1.h1">
+ <phrase id="unbalanced.sect1.inc2_2"/><link linkend="unbalanced.sect1.inc2_2">Heading
+ 2</link>
+ </bridgehead>
+ <bridgehead renderas="sect3" id="include2a.h0">
+ <phrase id="include2a.inc2a_1"/><link linkend="include2a.inc2a_1">Heading 1</link>
+ </bridgehead>
+ </section>
+ <bridgehead renderas="sect2" id="unbalanced.h0">
+ <phrase id="unbalanced.inc2a_2"/><link linkend="unbalanced.inc2a_2">Heading 2</link>
+ </bridgehead>
+ <bridgehead renderas="sect2" id="unbalanced.h1">
+ <phrase id="unbalanced.inc2_3"/><link linkend="unbalanced.inc2_3">Heading 3</link>
+ </bridgehead>
+</article>

Added: branches/quickbook-dev/tools/quickbook/test/include/include_id_unbalanced-1_6.quickbook
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/include/include_id_unbalanced-1_6.quickbook 2011-11-17 16:06:44 EST (Thu, 17 Nov 2011)
@@ -0,0 +1,19 @@
+[quickbook 1.6]
+[article Test include ids with unbalanced sections
+ [id unbalanced]
+]
+
+[/ Sections start in included files ]
+
+[include:include1 include_id_unbalanced-inc1.qbk]
+[heading:x1 X1]
+[endsect]
+[heading:x2 X2]
+[endsect]
+
+[/ Sections end in included files ]
+[section:sect1 Section 1]
+[heading:x1 X1]
+[section:sect2 Section 2]
+[heading:x2 X2]
+[include:include2 include_id_unbalanced-inc2.qbk]

Added: branches/quickbook-dev/tools/quickbook/test/include/include_id_unbalanced-inc1.qbk
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/include/include_id_unbalanced-inc1.qbk 2011-11-17 16:06:44 EST (Thu, 17 Nov 2011)
@@ -0,0 +1,4 @@
+[section:inc1 Include 1]
+[heading:inc1_1 Heading 1]
+[include:include1a include_id_unbalanced-inc1a.qbk]
+[heading:inc1_2 Heading 2]

Added: branches/quickbook-dev/tools/quickbook/test/include/include_id_unbalanced-inc1a.qbk
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/include/include_id_unbalanced-inc1a.qbk 2011-11-17 16:06:44 EST (Thu, 17 Nov 2011)
@@ -0,0 +1,3 @@
+[heading:inc1a_1 Heading 1]
+[section:inc1a Include 1a]
+[heading:inc1a_2 Heading 2]

Added: branches/quickbook-dev/tools/quickbook/test/include/include_id_unbalanced-inc2.qbk
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/include/include_id_unbalanced-inc2.qbk 2011-11-17 16:06:44 EST (Thu, 17 Nov 2011)
@@ -0,0 +1,5 @@
+[heading:inc2_1 Heading 1]
+[endsect]
+[heading:inc2_2 Heading 2]
+[include:include2a include_id_unbalanced-inc2a.qbk]
+[heading:inc2_3 Heading 3]

Added: branches/quickbook-dev/tools/quickbook/test/include/include_id_unbalanced-inc2a.qbk
==============================================================================
--- (empty file)
+++ branches/quickbook-dev/tools/quickbook/test/include/include_id_unbalanced-inc2a.qbk 2011-11-17 16:06:44 EST (Thu, 17 Nov 2011)
@@ -0,0 +1,3 @@
+[heading:inc2a_1 Heading 1]
+[endsect]
+[heading:inc2a_2 Heading 2]


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