aboutsummaryrefslogtreecommitdiff
path: root/xsd-frontend
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2010-06-04 16:20:15 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2010-06-04 16:20:15 +0200
commitd86fa2e9a6dff3a907549ef2b3e485517dca359e (patch)
treedda64c10c573f9054c4c64d458dfc2764d10ee49 /xsd-frontend
parent57e013aad01bfd2ef0969fba8d7fc4edb05a263f (diff)
Use normalized base path to construct absolute path
This prevents us from hitting a system limit on path lengths with path moving up and down with '..'.
Diffstat (limited to 'xsd-frontend')
-rw-r--r--xsd-frontend/parser.cxx38
1 files changed, 30 insertions, 8 deletions
diff --git a/xsd-frontend/parser.cxx b/xsd-frontend/parser.cxx
index 0f71fa3..576a7ca 100644
--- a/xsd-frontend/parser.cxx
+++ b/xsd-frontend/parser.cxx
@@ -1683,12 +1683,28 @@ namespace XSDFrontend
// Path stack for diagnostic.
//
- Cult::Containers::Stack<SemanticGraph::Path> file_stack_;
+ struct PathPair
+ {
+ PathPair (SemanticGraph::Path const& r, SemanticGraph::Path const& a)
+ : rel (r), abs (a)
+ {
+ }
+
+ SemanticGraph::Path rel, abs;
+ };
+
+ Cult::Containers::Stack<PathPair> file_stack_;
SemanticGraph::Path const&
file ()
{
- return file_stack_.top ();
+ return file_stack_.top ().rel;
+ }
+
+ SemanticGraph::Path const&
+ abs_file ()
+ {
+ return file_stack_.top ().abs;
}
// Members with default/fixed values (needed for QName handling).
@@ -1914,7 +1930,7 @@ namespace XSDFrontend
s_ = cur_ = rs.get ();
{
- file_stack_.push (tu);
+ file_stack_.push (PathPair (tu, abs_path));
{
push_scope (
@@ -2156,7 +2172,7 @@ namespace XSDFrontend
cur_ = &s;
{
- file_stack_.push (tu);
+ file_stack_.push (PathPair (tu, abs_path));
{
push_scope (
@@ -2433,8 +2449,11 @@ namespace XSDFrontend
}
else
{
+ // Use abs_file to construct the absolute path to avoid
+ // hitting system path limits with '..' directories.
+ //
rel_path = file ().branch_path () / path;
- abs_path = system_complete (rel_path);
+ abs_path = system_complete (abs_file ().branch_path () / path);
}
abs_path.normalize ();
@@ -2481,7 +2500,7 @@ namespace XSDFrontend
cur_chameleon_ = false;
{
- file_stack_.push (rel_path);
+ file_stack_.push (PathPair (rel_path, abs_path));
{
push_scope (
@@ -2537,8 +2556,11 @@ namespace XSDFrontend
}
else
{
+ // Use abs_file to construct the absolute path to avoid
+ // hitting system path limits with '..' directories.
+ //
rel_path = file ().branch_path () / path;
- abs_path = system_complete (rel_path);
+ abs_path = system_complete (abs_file ().branch_path () / path);
}
abs_path.normalize ();
@@ -2613,7 +2635,7 @@ namespace XSDFrontend
cur_chameleon_ = chameleon;
{
- file_stack_.push (rel_path);
+ file_stack_.push (PathPair (rel_path, abs_path));
{
push_scope (