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
430f0351
Unverified
Commit
430f0351
authored
Nov 25, 2017
by
Niels Lohmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🚨
fixed some warnings #821
parent
ea5aed07
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
13 deletions
+14
-13
src/json.hpp
src/json.hpp
+11
-10
test/src/unit-conversions.cpp
test/src/unit-conversions.cpp
+2
-2
test/src/unit-regression.cpp
test/src/unit-regression.cpp
+1
-1
No files found.
src/json.hpp
View file @
430f0351
...
...
@@ -533,6 +533,7 @@ enum class value_t : uint8_t
Returns an ordering that is similar to Python:
- order: null < boolean < number < object < array < string
- furthermore, each type is not smaller than itself
- discarded values are not comparable
@since version 1.0.0
*/
...
...
@@ -550,9 +551,9 @@ inline bool operator<(const value_t lhs, const value_t rhs) noexcept
}
};
// discarded values are not comparable
return
lhs
!=
value_t
::
discarded
and
rhs
!=
value_t
::
discarded
and
order
[
static_cast
<
std
::
size_t
>
(
lhs
)]
<
order
[
static_cast
<
std
::
size_t
>
(
rhs
)]
;
const
auto
l_index
=
static_cast
<
std
::
size_t
>
(
lhs
);
const
auto
r_index
=
static_cast
<
std
::
size_t
>
(
rhs
);
return
(
l_index
<
order
.
size
()
and
r_index
<=
order
.
size
()
and
order
[
l_index
]
<
order
[
r_index
])
;
}
...
...
@@ -1741,7 +1742,7 @@ class lexer
{
const
auto
loc
=
localeconv
();
assert
(
loc
!=
nullptr
);
return
(
loc
->
decimal_point
==
nullptr
)
?
'.'
:
loc
->
decimal_point
[
0
]
;
return
(
loc
->
decimal_point
==
nullptr
)
?
'.'
:
*
(
loc
->
decimal_point
)
;
}
/////////////////////
...
...
@@ -1908,8 +1909,8 @@ class lexer
// unicode escapes
case
'u'
:
{
int
codepoint
;
const
int
codepoint1
=
get_codepoint
();
int
codepoint
=
codepoint1
;
// start with codepoint1
if
(
JSON_UNLIKELY
(
codepoint1
==
-
1
))
{
...
...
@@ -1934,6 +1935,7 @@ class lexer
// check if codepoint2 is a low surrogate
if
(
JSON_LIKELY
(
0xDC00
<=
codepoint2
and
codepoint2
<=
0xDFFF
))
{
// overwrite codepoint
codepoint
=
// high surrogate occupies the most significant 22 bits
(
codepoint1
<<
10
)
...
...
@@ -1963,9 +1965,6 @@ class lexer
error_message
=
"invalid string: surrogate U+DC00..U+DFFF must follow U+D800..U+DBFF"
;
return
token_type
::
parse_error
;
}
// only work with first code point
codepoint
=
codepoint1
;
}
// result of the above calculation yields a proper codepoint
...
...
@@ -6090,8 +6089,8 @@ class serializer
*/
serializer
(
output_adapter_t
<
char
>
s
,
const
char
ichar
)
:
o
(
std
::
move
(
s
)),
loc
(
std
::
localeconv
()),
thousands_sep
(
loc
->
thousands_sep
==
nullptr
?
'\0'
:
loc
->
thousands_sep
[
0
]
),
decimal_point
(
loc
->
decimal_point
==
nullptr
?
'\0'
:
loc
->
decimal_point
[
0
]
),
thousands_sep
(
loc
->
thousands_sep
==
nullptr
?
'\0'
:
*
(
loc
->
thousands_sep
)
),
decimal_point
(
loc
->
decimal_point
==
nullptr
?
'\0'
:
*
(
loc
->
decimal_point
)
),
indent_char
(
ichar
),
indent_string
(
512
,
indent_char
)
{}
// delete because of pointer members
...
...
@@ -8046,11 +8045,13 @@ class basic_json
case
value_t
:
:
null
:
{
object
=
nullptr
;
// silence warning, see #821
break
;
}
default:
{
object
=
nullptr
;
// silence warning, see #821
if
(
JSON_UNLIKELY
(
t
==
value_t
::
null
))
{
JSON_THROW
(
other_error
::
create
(
500
,
"961c151d2e87f2686a955a9be24d316f1362bf21 2.1.1"
));
// LCOV_EXCL_LINE
...
...
test/src/unit-conversions.cpp
View file @
430f0351
...
...
@@ -1019,14 +1019,14 @@ TEST_CASE("value conversion")
SECTION
(
"std::array is larger than JSON"
)
{
std
::
array
<
int
,
6
>
arr6
=
{
1
,
2
,
3
,
4
,
5
,
6
};
std
::
array
<
int
,
6
>
arr6
=
{
{
1
,
2
,
3
,
4
,
5
,
6
}
};
CHECK_THROWS_AS
(
arr6
=
j1
,
json
::
out_of_range
);
CHECK_THROWS_WITH
(
arr6
=
j1
,
"[json.exception.out_of_range.401] array index 4 is out of range"
);
}
SECTION
(
"std::array is smaller than JSON"
)
{
std
::
array
<
int
,
2
>
arr2
=
{
8
,
9
};
std
::
array
<
int
,
2
>
arr2
=
{
{
8
,
9
}
};
arr2
=
j1
;
CHECK
(
arr2
[
0
]
==
1
);
CHECK
(
arr2
[
1
]
==
2
);
...
...
test/src/unit-regression.cpp
View file @
430f0351
...
...
@@ -1309,7 +1309,7 @@ TEST_CASE("regression tests")
SECTION
(
"issue #843 - converting to array not working"
)
{
json
j
;
std
::
array
<
int
,
4
>
ar
=
{
1
,
1
,
1
,
1
};
std
::
array
<
int
,
4
>
ar
=
{
{
1
,
1
,
1
,
1
}
};
j
=
ar
;
ar
=
j
;
}
...
...
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