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
6d09cdec
Unverified
Commit
6d09cdec
authored
Oct 07, 2018
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🐛
fixed a bug in the unget function
parent
011b15dd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
16 deletions
+21
-16
include/nlohmann/detail/exceptions.hpp
include/nlohmann/detail/exceptions.hpp
+0
-5
include/nlohmann/detail/input/lexer.hpp
include/nlohmann/detail/input/lexer.hpp
+9
-3
single_include/nlohmann/json.hpp
single_include/nlohmann/json.hpp
+9
-8
test/src/unit-class_parser.cpp
test/src/unit-class_parser.cpp
+3
-0
No files found.
include/nlohmann/detail/exceptions.hpp
View file @
6d09cdec
...
@@ -154,11 +154,6 @@ class parse_error : public exception
...
@@ -154,11 +154,6 @@ class parse_error : public exception
static
std
::
string
position_string
(
const
position_t
&
pos
)
static
std
::
string
position_string
(
const
position_t
&
pos
)
{
{
if
(
pos
.
chars_read_total
==
0
)
{
return
""
;
}
return
" at line "
+
std
::
to_string
(
pos
.
lines_read
+
1
)
+
return
" at line "
+
std
::
to_string
(
pos
.
lines_read
+
1
)
+
", column "
+
std
::
to_string
(
pos
.
chars_read_current_line
);
", column "
+
std
::
to_string
(
pos
.
chars_read_current_line
);
}
}
...
...
include/nlohmann/detail/input/lexer.hpp
View file @
6d09cdec
...
@@ -1278,12 +1278,18 @@ scan_number_done:
...
@@ -1278,12 +1278,18 @@ scan_number_done:
next_unget
=
true
;
next_unget
=
true
;
--
position
.
chars_read_total
;
--
position
.
chars_read_total
;
--
position
.
chars_read_current_line
;
// in case we "unget" a newline, we have to also decrement the lines_read
// in case we "unget" a newline, we have to also decrement the lines_read
if
(
position
.
lines_read
!=
0
and
position
.
chars_read_current_line
==
0
)
if
(
position
.
chars_read_current_line
==
0
)
{
{
--
position
.
lines_read
;
if
(
position
.
lines_read
>
0
)
{
--
position
.
lines_read
;
}
}
else
{
--
position
.
chars_read_current_line
;
}
}
if
(
JSON_LIKELY
(
current
!=
std
::
char_traits
<
char
>::
eof
()))
if
(
JSON_LIKELY
(
current
!=
std
::
char_traits
<
char
>::
eof
()))
...
...
single_include/nlohmann/json.hpp
View file @
6d09cdec
...
@@ -795,11 +795,6 @@ class parse_error : public exception
...
@@ -795,11 +795,6 @@ class parse_error : public exception
static
std
::
string
position_string
(
const
position_t
&
pos
)
static
std
::
string
position_string
(
const
position_t
&
pos
)
{
{
if
(
pos
.
chars_read_total
==
0
)
{
return
""
;
}
return
" at line "
+
std
::
to_string
(
pos
.
lines_read
+
1
)
+
return
" at line "
+
std
::
to_string
(
pos
.
lines_read
+
1
)
+
", column "
+
std
::
to_string
(
pos
.
chars_read_current_line
);
", column "
+
std
::
to_string
(
pos
.
chars_read_current_line
);
}
}
...
@@ -3595,12 +3590,18 @@ scan_number_done:
...
@@ -3595,12 +3590,18 @@ scan_number_done:
next_unget
=
true
;
next_unget
=
true
;
--
position
.
chars_read_total
;
--
position
.
chars_read_total
;
--
position
.
chars_read_current_line
;
// in case we "unget" a newline, we have to also decrement the lines_read
// in case we "unget" a newline, we have to also decrement the lines_read
if
(
position
.
lines_read
!=
0
and
position
.
chars_read_current_line
==
0
)
if
(
position
.
chars_read_current_line
==
0
)
{
if
(
position
.
lines_read
>
0
)
{
--
position
.
lines_read
;
}
}
else
{
{
--
position
.
lines_read
;
--
position
.
chars_read_current_line
;
}
}
if
(
JSON_LIKELY
(
current
!=
std
::
char_traits
<
char
>::
eof
()))
if
(
JSON_LIKELY
(
current
!=
std
::
char_traits
<
char
>::
eof
()))
...
...
test/src/unit-class_parser.cpp
View file @
6d09cdec
...
@@ -1292,6 +1292,9 @@ TEST_CASE("parser class")
...
@@ -1292,6 +1292,9 @@ TEST_CASE("parser class")
CHECK
(
accept_helper
(
"
\"\\
u01"
)
==
false
);
CHECK
(
accept_helper
(
"
\"\\
u01"
)
==
false
);
CHECK
(
accept_helper
(
"
\"\\
u012"
)
==
false
);
CHECK
(
accept_helper
(
"
\"\\
u012"
)
==
false
);
// unget of newline
CHECK
(
parser_helper
(
"
\n
123
\n
"
)
==
123
);
// invalid escapes
// invalid escapes
for
(
int
c
=
1
;
c
<
128
;
++
c
)
for
(
int
c
=
1
;
c
<
128
;
++
c
)
{
{
...
...
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