Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r84147 - trunk/tools/quickbook/src
From: dnljms_at_[hidden]
Date: 2013-05-05 09:45:22


Author: danieljames
Date: 2013-05-05 09:45:21 EDT (Sun, 05 May 2013)
New Revision: 84147
URL: http://svn.boost.org/trac/boost/changeset/84147

Log:
Add comments to location finding code for indented blocks.
Text files modified:
   trunk/tools/quickbook/src/files.cpp | 15 +++++++++++++--
   1 files changed, 13 insertions(+), 2 deletions(-)

Modified: trunk/tools/quickbook/src/files.cpp
==============================================================================
--- trunk/tools/quickbook/src/files.cpp (original)
+++ trunk/tools/quickbook/src/files.cpp 2013-05-05 09:45:21 EDT (Sun, 05 May 2013)
@@ -293,10 +293,16 @@
             switch (section->section_type) {
                 case mapped_file_section::normal:
                     return pos - section->our_pos + section->original_pos;
+
                 case mapped_file_section::empty:
                     return section->original_pos;
+
                 case mapped_file_section::indented: {
+ // Will contain the start of the current line.
                     boost::string_ref::size_type our_line = section->our_pos;
+
+ // Will contain the number of lines in the block before
+ // the current line.
                     unsigned newline_count = 0;
 
                     for(boost::string_ref::size_type i = section->our_pos;
@@ -307,10 +313,13 @@
                             ++newline_count;
                         }
                     }
-
+
+ // Simple case for the first line, as we already know the
+ // corresponding position for the start of line.
                     if (newline_count == 0)
                         return pos - section->our_pos + section->original_pos;
 
+ // The start of the line in the original source.
                     boost::string_ref::size_type original_line =
                         section->original_pos;
                     
@@ -319,7 +328,8 @@
                             --newline_count;
                         ++original_line;
                     }
-
+
+ // Skip over indentation
                     for(unsigned i = section->indentation; i > 0; --i) {
                         if (original->source()[original_line] == '\n' ||
                             original->source()[original_line] == '\0') break;
@@ -331,6 +341,7 @@
                     assert(original->source()[original_line] ==
                         source()[our_line]);
 
+ // Calculate the position
                     return original_line + (pos - our_line);
                 }
                 default:


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