summaryrefslogtreecommitdiff
path: root/sdext/source/pdfimport/pdfparse/pdfparse.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sdext/source/pdfimport/pdfparse/pdfparse.cxx')
-rw-r--r--sdext/source/pdfimport/pdfparse/pdfparse.cxx37
1 files changed, 36 insertions, 1 deletions
diff --git a/sdext/source/pdfimport/pdfparse/pdfparse.cxx b/sdext/source/pdfimport/pdfparse/pdfparse.cxx
index b8d0aaca6b74..b3ffa64427dd 100644
--- a/sdext/source/pdfimport/pdfparse/pdfparse.cxx
+++ b/sdext/source/pdfimport/pdfparse/pdfparse.cxx
@@ -108,6 +108,40 @@ public:
iteratorT m_aGlobalBegin;
public:
+ struct pdf_string_parser
+ {
+ typedef nil_t result_t;
+ template <typename ScannerT>
+ std::ptrdiff_t
+ operator()(ScannerT const& scan, result_t& result) const
+ {
+ std::ptrdiff_t len = 0;
+
+ int nBraceLevel = 0;
+ while( ! scan.at_end() )
+ {
+ char c = *scan;
+ if( c == ')' )
+ {
+ nBraceLevel--;
+ if( nBraceLevel < 0 )
+ break;
+ }
+ else if( c == '(' )
+ nBraceLevel++;
+ else if( c == '\\' ) // ignore escaped braces
+ {
+ ++len;
+ ++scan;
+ if( scan.at_end() )
+ break;
+ }
+ ++len;
+ ++scan;
+ }
+ return scan.at_end() ? -1 : len;
+ }
+ };
template< typename ScannerT >
struct definition
@@ -135,7 +169,8 @@ public:
//stringtype = ( confix_p("(",*anychar_p, ")") |
// confix_p("<",*xdigit_p, ">") )
// [boost::bind(&PDFGrammar::pushString,pSelf, _1, _2)];
- stringtype = ( ( ch_p('(') >> *(str_p("\\)")|(anychar_p - ch_p(')'))) >> ch_p(')') ) |
+
+ stringtype = ( ( ch_p('(') >> functor_parser<pdf_string_parser>() >> ch_p(')') ) |
( ch_p('<') >> *xdigit_p >> ch_p('>') ) )
[boost::bind(&PDFGrammar::pushString,pSelf, _1, _2)];