Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
R
rapidjson
Project
Project
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
rapidjson
Commits
813eaf4e
Commit
813eaf4e
authored
Jun 26, 2014
by
Milo Yip
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #25 from miloyip/issue22setjmp
Removal of setjmp()/longjmp()
parents
32b93052
a1a8abd0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
23 deletions
+30
-23
reader.h
include/rapidjson/reader.h
+30
-23
No files found.
include/rapidjson/reader.h
View file @
813eaf4e
...
...
@@ -8,7 +8,6 @@
#include "encodings.h"
#include "internal/pow10.h"
#include "internal/stack.h"
#include <csetjmp>
#ifdef RAPIDJSON_SSE42
#include <nmmintrin.h>
...
...
@@ -21,12 +20,21 @@
#pragma warning(disable : 4127) // conditional expression is constant
#endif
#ifndef RAPIDJSON_PARSE_ERROR_NORETURN
#define RAPIDJSON_PARSE_ERROR_NORETURN(msg, offset) \
RAPIDJSON_MULTILINEMACRO_BEGIN
\
if
(
!
HasParseError
())
{
\
parseError_
=
msg
;
\
errorOffset_
=
offset
;
\
}
\
RAPIDJSON_MULTILINEMACRO_END
#endif
#ifndef RAPIDJSON_PARSE_ERROR
#define RAPIDJSON_PARSE_ERROR(msg, offset) \
RAPIDJSON_MULTILINEMACRO_BEGIN
\
parseError_
=
msg
;
\
errorOffset_
=
offset
;
\
longjmp
(
jmpbuf_
,
1
);
\
RAPIDJSON_PARSE_ERROR_NORETURN
(
msg
,
offset
);
\
return
;
\
RAPIDJSON_MULTILINEMACRO_END
#endif
...
...
@@ -225,35 +233,24 @@ public:
parseError_
=
0
;
errorOffset_
=
0
;
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4611) // interaction between '_setjmp' and C++ object destruction is non-portable
#endif
if
(
setjmp
(
jmpbuf_
))
{
#ifdef _MSC_VER
#pragma warning(pop)
#endif
stack_
.
Clear
();
return
false
;
}
SkipWhitespace
(
is
);
if
(
is
.
Peek
()
==
'\0'
)
RAPIDJSON_PARSE_ERROR
(
"Text only contains white space(s)"
,
is
.
Tell
());
RAPIDJSON_PARSE_ERROR
_NORETURN
(
"Text only contains white space(s)"
,
is
.
Tell
());
else
{
switch
(
is
.
Peek
())
{
case
'{'
:
ParseObject
<
parseFlags
>
(
is
,
handler
);
break
;
case
'['
:
ParseArray
<
parseFlags
>
(
is
,
handler
);
break
;
default
:
RAPIDJSON_PARSE_ERROR
(
"Expect either an object or array at root"
,
is
.
Tell
());
default
:
RAPIDJSON_PARSE_ERROR
_NORETURN
(
"Expect either an object or array at root"
,
is
.
Tell
());
}
SkipWhitespace
(
is
);
if
(
is
.
Peek
()
!=
'\0'
)
RAPIDJSON_PARSE_ERROR
(
"Nothing should follow the root object or array."
,
is
.
Tell
());
RAPIDJSON_PARSE_ERROR
_NORETURN
(
"Nothing should follow the root object or array."
,
is
.
Tell
());
}
return
true
;
stack_
.
Clear
();
return
!
HasParseError
();
}
bool
HasParseError
()
const
{
return
parseError_
!=
0
;
}
...
...
@@ -280,6 +277,9 @@ private:
RAPIDJSON_PARSE_ERROR
(
"Name of an object member must be a string"
,
is
.
Tell
());
ParseString
<
parseFlags
>
(
is
,
handler
);
if
(
HasParseError
())
return
;
SkipWhitespace
(
is
);
if
(
is
.
Take
()
!=
':'
)
...
...
@@ -288,6 +288,9 @@ private:
SkipWhitespace
(
is
);
ParseValue
<
parseFlags
>
(
is
,
handler
);
if
(
HasParseError
())
return
;
SkipWhitespace
(
is
);
++
memberCount
;
...
...
@@ -316,6 +319,9 @@ private:
for
(
SizeType
elementCount
=
0
;;)
{
ParseValue
<
parseFlags
>
(
is
,
handler
);
if
(
HasParseError
())
return
;
++
elementCount
;
SkipWhitespace
(
is
);
...
...
@@ -375,8 +381,10 @@ private:
codepoint
-=
'A'
-
10
;
else
if
(
c
>=
'a'
&&
c
<=
'f'
)
codepoint
-=
'a'
-
10
;
else
RAPIDJSON_PARSE_ERROR
(
"Incorrect hex digit after
\\
u escape"
,
s
.
Tell
()
-
1
);
else
{
RAPIDJSON_PARSE_ERROR_NORETURN
(
"Incorrect hex digit after
\\
u escape"
,
s
.
Tell
()
-
1
);
return
0
;
}
}
is
=
s
;
// Restore is
return
codepoint
;
...
...
@@ -652,7 +660,6 @@ private:
static
const
size_t
kDefaultStackCapacity
=
256
;
//!< Default stack capacity in bytes for storing a single decoded string.
internal
::
Stack
<
Allocator
>
stack_
;
//!< A stack for storing decoded string temporarily during non-destructive parsing.
jmp_buf
jmpbuf_
;
//!< setjmp buffer for fast exit from nested parsing function calls.
const
char
*
parseError_
;
size_t
errorOffset_
;
};
// class GenericReader
...
...
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