Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
MoReFEM
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MoReFEM
CoreLibrary
MoReFEM
Commits
10cbd9bc
Commit
10cbd9bc
authored
Jul 30, 2019
by
GILLES Sebastien
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#1475 Better error message when unbalanced braces in the input file.
parent
386aae41
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
5 deletions
+26
-5
Sources/Utilities/LuaOptionFile/LuaOptionFile.cpp
Sources/Utilities/LuaOptionFile/LuaOptionFile.cpp
+26
-5
No files found.
Sources/Utilities/LuaOptionFile/LuaOptionFile.cpp
View file @
10cbd9bc
...
...
@@ -392,13 +392,37 @@ namespace MoReFEM
oconv
<<
"Last brace found in the file "
<<
file_
<<
" is an opening one!"
;
throw
Exception
(
oconv
.
str
(),
__FILE__
,
__LINE__
);
}
}
// Check there are an equal number of opening and closing braces.
auto
opening_brace_lbd
=
[](
int
i
)
{
return
i
>
0
;
};
auto
closing_brace_lbd
=
[](
int
i
)
{
return
i
<
0
;
};
const
auto
Nopening_brace
=
std
::
count_if
(
brace_position_list_
.
cbegin
(),
brace_position_list_
.
cend
(),
opening_brace_lbd
);
const
auto
Nclosing_brace
=
std
::
count_if
(
brace_position_list_
.
cbegin
(),
brace_position_list_
.
cend
(),
closing_brace_lbd
);
if
(
Nopening_brace
!=
Nclosing_brace
)
{
std
::
ostringstream
oconv
;
oconv
<<
"Unbalanced braces in the file "
<<
file_
<<
": there is "
<<
Nopening_brace
<<
" '{'"
<<
" and "
<<
Nclosing_brace
<<
" '}' [the ones related to maps or in comments aren't counted]."
;
throw
Exception
(
oconv
.
str
(),
__FILE__
,
__LINE__
);
}
// Pair the braces together.
std
::
vector
<
std
::
pair
<
std
::
size_t
,
std
::
size_t
>>
pair_list
;
auto
copy
=
brace_position_list_
;
...
...
@@ -415,10 +439,7 @@ namespace MoReFEM
// Find first negative value.
auto
it
=
std
::
find_if
(
copy
.
cbegin
(),
copy
.
cend
(),
[](
int
i
)
{
return
i
<
0
;
});
closing_brace_lbd
);
assert
(
it
!=
copy
.
cend
());
assert
(
it
!=
copy
.
cbegin
());
...
...
Write
Preview
Markdown
is supported
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