Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
json
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
json
Commits
3888b164
Unverified
Commit
3888b164
authored
Jul 31, 2020
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🐛
fix lexer to properly cope with repeated comments #2330
parent
1da93173
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
2 deletions
+12
-2
include/nlohmann/detail/input/lexer.hpp
include/nlohmann/detail/input/lexer.hpp
+1
-1
single_include/nlohmann/json.hpp
single_include/nlohmann/json.hpp
+1
-1
test/src/unit-class_lexer.cpp
test/src/unit-class_lexer.cpp
+3
-0
test/src/unit-regression2.cpp
test/src/unit-regression2.cpp
+7
-0
No files found.
include/nlohmann/detail/input/lexer.hpp
View file @
3888b164
...
...
@@ -1511,7 +1511,7 @@ scan_number_done:
skip_whitespace
();
// ignore comments
if
(
ignore_comments
&&
current
==
'/'
)
while
(
ignore_comments
&&
current
==
'/'
)
{
if
(
!
scan_comment
())
{
...
...
single_include/nlohmann/json.hpp
View file @
3888b164
...
...
@@ -7390,7 +7390,7 @@ scan_number_done:
skip_whitespace
();
// ignore comments
if
(ignore_comments && current == '/')
while
(
ignore_comments
&&
current
==
'/'
)
{
if
(
!
scan_comment
())
{
...
...
test/src/unit-class_lexer.cpp
View file @
3888b164
...
...
@@ -241,5 +241,8 @@ TEST_CASE("lexer class")
CHECK
((
scan_string
(
"/* true */"
,
true
)
==
json
::
lexer
::
token_type
::
end_of_input
));
CHECK
((
scan_string
(
"/*/**/"
,
true
)
==
json
::
lexer
::
token_type
::
end_of_input
));
CHECK
((
scan_string
(
"/*/* */"
,
true
)
==
json
::
lexer
::
token_type
::
end_of_input
));
CHECK
((
scan_string
(
"//
\n
//
\n
"
,
true
)
==
json
::
lexer
::
token_type
::
end_of_input
));
CHECK
((
scan_string
(
"/**//**//**/"
,
true
)
==
json
::
lexer
::
token_type
::
end_of_input
));
}
}
test/src/unit-regression2.cpp
View file @
3888b164
...
...
@@ -478,4 +478,11 @@ TEST_CASE("regression tests 2")
CHECK
(
jsonObj
[
"aaaa"
]
==
11
);
CHECK
(
jsonObj
[
"bbb"
]
==
222
);
}
SECTION
(
"issue #2330 - ignore_comment=true fails on multiple consecutive lines starting with comments"
)
{
std
::
string
ss
=
"//
\n
//
\n
{
\n
}
\n
"
;
json
j
=
json
::
parse
(
ss
,
nullptr
,
true
,
true
);
CHECK
(
j
.
dump
()
==
"{}"
);
}
}
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