Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Aland, Sebastian
amdis
Commits
6e5ebc85
Commit
6e5ebc85
authored
Apr 18, 2013
by
Praetorius, Simon
Browse files
initfile now accepts includes with spaces in the filename
parent
087a863a
Changes
2
Hide whitespace changes
Inline
Side-by-side
AMDiS/src/Initfile.cc
View file @
6e5ebc85
...
...
@@ -16,8 +16,8 @@ namespace AMDiS {
{
size_t
pos
=
line
.
find
(
':'
);
if
(
pos
==
string
::
npos
)
{
//
throw runtime_error("cannot find the delimiter ':' in line "
//
"'" + line + "'");
throw
runtime_error
(
"cannot find the delimiter ':' in line "
"'"
+
line
+
"'"
);
}
name
=
line
.
substr
(
0
,
pos
);
value
=
line
.
substr
(
pos
+
1
,
line
.
length
()
-
(
pos
+
1
));
...
...
@@ -53,8 +53,8 @@ namespace AMDiS {
if
(
fn_include_list
.
find
(
fn
)
==
fn_include_list
.
end
()
||
force
)
{
std
::
ifstream
inputFile
;
inputFile
.
open
(
fn
.
c_str
(),
std
::
ios
::
in
);
//
if (!inputFile.is_open())
//
throw runtime_error("init-file '" + fn + "' cannot be opened for reading");
if
(
!
inputFile
.
is_open
())
throw
runtime_error
(
"init-file '"
+
fn
+
"' cannot be opened for reading"
);
fn_include_list
.
insert
(
fn
);
read
(
inputFile
);
...
...
@@ -70,6 +70,7 @@ namespace AMDiS {
in
.
getline
(
swap
,
line_length
);
while
(
in
.
good
()
||
in
.
gcount
()
>
0
)
{
std
::
string
whitespaces
=
"
\t\r\f\n
"
;
std
::
string
delimiter
=
"
\r\n
"
;
std
::
string
sw
(
swap
);
size_t
pos0
=
sw
.
find_first_not_of
(
whitespaces
);
...
...
@@ -109,18 +110,20 @@ namespace AMDiS {
case
'<'
:
c
=
'>'
;
case
'\"'
:
whitespaces
+=
c
;
epos
=
sw
.
find_first_of
(
whitespaces
,
pos
);
delimiter
+=
c
;
epos
=
sw
.
find_first_of
(
delimiter
,
pos
);
fn
=
sw
.
substr
(
pos
,
epos
-
pos
);
if
(
sw
[
epos
]
!=
c
)
{
errorMsg
<<
"filename in #include not terminated by "
<<
c
;
//
throw std::runtime_error(errorMsg.str());
throw
std
::
runtime_error
(
errorMsg
.
str
());
}
break
;
//
default:
//
throw std::runtime_error("no filename given for #include");
default:
throw
std
::
runtime_error
(
"no filename given for #include"
);
}
read
(
fn
,
forceRead
);
}
...
...
AMDiS/src/Initfile.h
View file @
6e5ebc85
...
...
@@ -415,11 +415,16 @@ namespace AMDiS {
}
std
::
string
valStr
;
try
{
int
error_code
=
singlett
->
checkedGet
(
tag
,
valStr
);
if
(
error_code
==
0
)
{
valStr
=
trim
(
valStr
);
details
::
convert
(
valStr
,
value
);
}
}
catch
(
mu
::
ParserError
&
e
)
{
std
::
string
parser_error
=
"Could not parse: "
+
tag
;
throw
std
::
runtime_error
(
parser_error
);
}
/*
else if(error_code == TAG_NOT_FOUND_BREAK)
throw TagNotFoundBreak("required tag '" + tag + "' not found");
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment