Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
json
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
json
Commits
e9bfcf72
Unverified
Commit
e9bfcf72
authored
Jun 17, 2020
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
⚡
improve comment parsing
parent
b53c6e2f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
78 deletions
+62
-78
lexer.hpp
include/nlohmann/detail/input/lexer.hpp
+31
-39
json.hpp
single_include/nlohmann/json.hpp
+31
-39
No files found.
include/nlohmann/detail/input/lexer.hpp
View file @
e9bfcf72
...
...
@@ -835,62 +835,54 @@ class lexer : public lexer_base<BasicJsonType>
*/
bool
scan_comment
()
{
// remember character after '/' to distinguish comment types
const
auto
comment_char
=
get
();
// expect // or /* to start a comment
if
(
comment_char
!=
'/'
and
comment_char
!=
'*'
)
{
return
false
;
}
while
(
true
)
switch
(
get
())
{
switch
(
get
())
case
'/'
:
{
// EOF inside a /* comment is an error, in // it is OK
case
std
:
:
char_traits
<
char_type
>::
eof
()
:
case
'\0'
:
while
(
true
)
{
return
comment_char
==
'/'
;
}
// a newline ends the // comment
case
'\n'
:
case
'\r'
:
{
if
(
comment_char
==
'/'
)
switch
(
get
())
{
return
true
;
case
'\n'
:
case
'\r'
:
return
true
;
default
:
break
;
}
break
;
}
}
// */ ends the /* comment
case
'*'
:
case
'*'
:
{
while
(
true
)
{
if
(
comment_char
==
'*'
)
switch
(
get
()
)
{
switch
(
get
())
case
std
:
:
char_traits
<
char_type
>::
eof
()
:
case
'\0'
:
return
false
;
case
'*'
:
{
case
'/'
:
switch
(
get
())
{
return
true
;
}
case
'/'
:
return
true
;
default
:
{
unget
();
break
;
default
:
{
unget
();
break
;
}
}
}
}
break
;
}
default
:
break
;
}
default
:
return
false
;
}
}
...
...
single_include/nlohmann/json.hpp
View file @
e9bfcf72
...
...
@@ -8902,62 +8902,54 @@ class lexer : public lexer_base<BasicJsonType>
*/
bool
scan_comment
()
{
// remember character after '/' to distinguish comment types
const
auto
comment_char
=
get
();
// expect // or /* to start a comment
if
(
comment_char
!=
'/'
and
comment_char
!=
'*'
)
{
return
false
;
}
while
(
true
)
switch
(
get
())
{
switch
(
get
())
case
'/'
:
{
// EOF inside a /* comment is an error, in // it is OK
case
std
:
:
char_traits
<
char_type
>::
eof
()
:
case
'\0'
:
while
(
true
)
{
return
comment_char
==
'/'
;
}
// a newline ends the // comment
case
'\n'
:
case
'\r'
:
{
if
(
comment_char
==
'/'
)
switch
(
get
())
{
return
true
;
case
'\n'
:
case
'\r'
:
return
true
;
default
:
break
;
}
break
;
}
}
// */ ends the /* comment
case
'*'
:
case
'*'
:
{
while
(
true
)
{
if
(
comment_char
==
'*'
)
switch
(
get
()
)
{
switch
(
get
())
case
std
:
:
char_traits
<
char_type
>::
eof
()
:
case
'\0'
:
return
false
;
case
'*'
:
{
case
'/'
:
switch
(
get
())
{
return
true
;
}
case
'/'
:
return
true
;
default
:
{
unget
();
break
;
default
:
{
unget
();
break
;
}
}
}
}
break
;
}
default
:
break
;
}
default
:
return
false
;
}
}
...
...
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