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
99e0d8b3
Unverified
Commit
99e0d8b3
authored
Mar 26, 2017
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🔨
fixed \uxxxx parsing
parent
f47cf152
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
88 additions
and
60 deletions
+88
-60
src/json.hpp
src/json.hpp
+16
-21
test/src/unit-class_parser.cpp
test/src/unit-class_parser.cpp
+72
-39
No files found.
src/json.hpp
View file @
99e0d8b3
...
@@ -42,6 +42,7 @@ SOFTWARE.
...
@@ -42,6 +42,7 @@ SOFTWARE.
#include <forward_list> // forward_list
#include <forward_list> // forward_list
#include <functional> // function, hash, less
#include <functional> // function, hash, less
#include <initializer_list> // initializer_list
#include <initializer_list> // initializer_list
#include <iomanip> // hex
#include <iostream> // istream, ostream
#include <iostream> // istream, ostream
#include <iterator> // advance, begin, back_inserter, bidirectional_iterator_tag, distance, end, inserter, iterator, iterator_traits, next, random_access_iterator_tag, reverse_iterator
#include <iterator> // advance, begin, back_inserter, bidirectional_iterator_tag, distance, end, inserter, iterator, iterator_traits, next, random_access_iterator_tag, reverse_iterator
#include <limits> // numeric_limits
#include <limits> // numeric_limits
...
@@ -10542,36 +10543,30 @@ class basic_json
...
@@ -10542,36 +10543,30 @@ class basic_json
// must be called after \u was read; returns following xxxx as hex or -1 when error
// must be called after \u was read; returns following xxxx as hex or -1 when error
int
get_codepoint
()
int
get_codepoint
()
{
{
// read xxxx of \uxxxx
// a mapping to discover hex numbers
std
::
vector
<
char
>
buffer
(
5
,
'\0'
);
static
int8_t
ascii_to_hex
[
256
]
=
{
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
10
,
11
,
12
,
13
,
14
,
15
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
10
,
11
,
12
,
13
,
14
,
15
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
,
-
1
};
int
codepoint
=
0
;
for
(
size_t
i
=
0
;
i
<
4
;
++
i
)
for
(
size_t
i
=
0
;
i
<
4
;
++
i
)
{
{
get
()
;
const
int8_t
digit
=
ascii_to_hex
[
static_cast
<
unsigned
char
>
(
get
())]
;
if
(
JSON_UNLIKELY
(
current
!=
std
::
char_traits
<
char
>::
eof
()
))
if
(
JSON_UNLIKELY
(
digit
==
-
1
))
{
{
buffer
[
i
]
=
static_cast
<
char
>
(
current
)
;
return
-
1
;
}
}
else
else
{
{
// error message will be created by caller
codepoint
+=
digit
;
return
-
1
;
}
}
}
char
*
endptr
;
errno
=
0
;
const
int
codepoint
=
static_cast
<
int
>
(
std
::
strtoul
(
buffer
.
data
(),
&
endptr
,
16
));
if
(
JSON_LIKELY
(
errno
==
0
and
endptr
==
buffer
.
data
()
+
4
))
if
(
i
!=
3
)
{
{
return
codepoint
;
codepoint
<<=
4
;
}
}
else
{
// conversion incomplete or failure
return
-
1
;
}
}
return
codepoint
;
}
}
token_type
scan_string
()
token_type
scan_string
()
...
...
test/src/unit-class_parser.cpp
View file @
99e0d8b3
This diff is collapsed.
Click to expand it.
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