]> git.lyx.org Git - lyx.git/blobdiff - boost/boost/format/parsing.hpp
Don't allow newline characters in document settings.
[lyx.git] / boost / boost / format / parsing.hpp
index bbbf9d480672d44768870def451f056f56362e9f..b14ca82c984699c12fa0dcdb4a8285609aedc85c 100644 (file)
@@ -16,6 +16,7 @@
 
 
 #include <boost/format/format_class.hpp>
+#include <boost/format/exceptions.hpp>
 #include <boost/throw_exception.hpp>
 #include <boost/assert.hpp>
 
@@ -44,9 +45,10 @@ namespace detail {
 
     template<class Ch, class Facet> inline
     bool wrap_isdigit(const Facet& fac, Ch c) {
-#if ! defined( BOOST_NO_LOCALE_ISIDIGIT )
+#if ! defined( BOOST_NO_LOCALE_ISDIGIT )
         return fac.is(std::ctype<Ch>::digit, c);
 # else
+        (void) fac;     // remove "unused parameter" warning
         using namespace std;
         return isdigit(c); 
 #endif 
@@ -130,6 +132,12 @@ namespace detail {
         bool in_brackets=false;
         Iter start0 = start;
         std::size_t fstring_size = last-start0+offset;
+
+        if(start>= last) { // empty directive : this is a trailing %
+                maybe_throw_exception(exceptions, start-start0 + offset, fstring_size);
+                return false;
+        }          
+          
         if(*start== const_or_not(fac).widen( '|')) {
             in_brackets=true;
             if( ++start >= last ) {
@@ -360,7 +368,10 @@ namespace detail {
             if( i1+1 >= buf.size() ) {
                 if(exceptions & bad_format_string_bit)
                     boost::throw_exception(bad_format_string(i1, buf.size() )); // must not end in ".. %"
-                else break; // stop there, ignore last '%'
+                else {
+                  ++num_items;
+                  break;
+                }
             }
             if(buf[i1+1] == buf[i1] ) {// escaped "%%"
                 i1+=2; continue; 
@@ -429,8 +440,10 @@ namespace detail {
             }
             BOOST_ASSERT(  static_cast<unsigned int>(cur_item) < items_.size() || cur_item==0);
 
-            if(i1!=i0)
+            if(i1!=i0) {
                 io::detail::append_string(piece, buf, i0, i1);
+                i0=i1;
+            }
             ++i1;
             it = buf.begin()+i1;
             bool parse_ok = io::detail::parse_printf_directive(