]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/tools/quickbook/src/doc_info_actions.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / tools / quickbook / src / doc_info_actions.cpp
index 14d7a9994fd7c7832fa2846306a4fa7cfb99e150..320f77036308acb080aa571c354ae858ac7dee72 100644 (file)
 #include "quickbook.hpp"
 #include "utils.hpp"
 #include "files.hpp"
-#include "native_text.hpp"
+#include "stream.hpp"
 #include "state.hpp"
 #include "doc_info_tags.hpp"
 #include "document_state.hpp"
-#include "include_paths.hpp"
+#include "path.hpp"
 
 namespace quickbook
 {
@@ -29,7 +29,7 @@ namespace quickbook
     static std::string doc_info_output(value const& p, unsigned version)
     {
         if (qbk_version_n < version) {
-            std::string value = detail::to_s(p.get_quickbook());
+            std::string value = p.get_quickbook().to_s();
             value.erase(value.find_last_not_of(" \t") + 1);
             return value;
         }
@@ -38,6 +38,12 @@ namespace quickbook
         }
     }
 
+    char const* doc_info_attribute_name(value::tag_type tag)
+    {
+        return doc_attributes::is_tag(tag) ? doc_attributes::name(tag) :
+            doc_info_attributes::name(tag);
+    }
+
     // Each docinfo attribute is stored in a value list, these are then stored
     // in a sorted value list. The following convenience methods extract all the
     // values for an attribute tag.
@@ -54,7 +60,7 @@ namespace quickbook
             ++count;
         }
 
-        if(count > 1) duplicates->push_back(doc_info_attributes::name(tag));
+        if(count > 1) duplicates->push_back(doc_info_attribute_name(tag));
 
         return p;
     }
@@ -87,6 +93,14 @@ namespace quickbook
         return values;
     }
 
+    enum version_state { version_unknown, version_stable, version_dev };
+    version_state classify_version(unsigned v) {
+        return v < 100u ? version_unknown :
+            v <= 107u ? version_stable :
+            //v <= 107u ? version_dev :
+            version_unknown;
+    }
+
     unsigned get_version(quickbook::state& state, bool using_docinfo,
             value version)
     {
@@ -104,7 +118,7 @@ namespace quickbook
                 result = ((unsigned) major_verison * 100) +
                     (unsigned) minor_verison;
             
-                if(result < 100 || result > 107)
+                if (classify_version(result) == version_unknown)
                 {
                     detail::outerr(state.current_file->path)
                         << "Unknown version: "
@@ -141,7 +155,7 @@ namespace quickbook
 
         if (values.check(doc_info_tags::type))
         {
-            doc_type = detail::to_s(values.consume(doc_info_tags::type).get_quickbook());
+            doc_type = values.consume(doc_info_tags::type).get_quickbook().to_s();
             doc_title = values.consume(doc_info_tags::title);
             use_doc_info = !nested_file || qbk_version_n >= 106u;
         }
@@ -200,9 +214,9 @@ namespace quickbook
         std::string include_doc_id_, id_;
 
         if (!include_doc_id.empty())
-            include_doc_id_ = detail::to_s(include_doc_id.get_quickbook());
+            include_doc_id_ = include_doc_id.get_quickbook().to_s();
         if (!id.empty())
-            id_ = detail::to_s(id.get_quickbook());
+            id_ = id.get_quickbook().to_s();
 
         // Quickbook version
 
@@ -210,7 +224,7 @@ namespace quickbook
 
         if (new_version != qbk_version_n)
         {
-            if (new_version >= 107u)
+            if (classify_version(new_version) == version_dev)
             {
                 detail::outwarn(state.current_file->path)
                     << "Quickbook " << (new_version / 100) << "." << (new_version % 100)
@@ -487,8 +501,8 @@ namespace quickbook
                 ;
         }
 
-        BOOST_FOREACH(value_consumer values, categories) {
-            value category = values.optional_consume();
+        BOOST_FOREACH(value_consumer category_values, categories) {
+            value category = category_values.optional_consume();
             if(!category.empty()) {
                 tmp << "    <" << doc_type << "category name=\"category:"
                     << doc_info_output(category, 106)
@@ -496,7 +510,7 @@ namespace quickbook
                     << "\n"
                 ;
             }
-            values.finish();
+            category_values.finish();
         }
 
         BOOST_FOREACH(value_consumer biblioid, biblioids)
@@ -550,9 +564,16 @@ namespace quickbook
 
         // Close any open sections.
         if (!doc_type.empty() && state.document.section_level() > 1) {
-            detail::outwarn(state.current_file->path)
-                << "Missing [endsect] detected at end of file."
-                << std::endl;
+            if (state.strict_mode) {
+                detail::outerr(state.current_file->path)
+                    << "Missing [endsect] detected at end of file (strict mode)."
+                    << std::endl;
+                ++state.error_count;
+            } else {
+                detail::outwarn(state.current_file->path)
+                    << "Missing [endsect] detected at end of file."
+                    << std::endl;
+            }
 
             while(state.document.section_level() > 1) {
                 state.out << "</section>";