Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party CJSON
提交
b71db93e
T
Third Party CJSON
项目概览
OpenHarmony
/
Third Party CJSON
大约 1 年 前同步成功
通知
6
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party CJSON
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b71db93e
编写于
2月 20, 2017
作者:
M
Max Bruckner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
print_object: rename variables
上级
6d5a7c8c
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
67 addition
and
67 deletion
+67
-67
cJSON.c
cJSON.c
+67
-67
未找到文件。
cJSON.c
浏览文件 @
b71db93e
...
@@ -786,7 +786,7 @@ static unsigned char *print_value(const cJSON * const item, const size_t depth,
...
@@ -786,7 +786,7 @@ static unsigned char *print_value(const cJSON * const item, const size_t depth,
static
const
unsigned
char
*
parse_array
(
cJSON
*
const
item
,
const
unsigned
char
*
input
,
const
unsigned
char
**
const
ep
);
static
const
unsigned
char
*
parse_array
(
cJSON
*
const
item
,
const
unsigned
char
*
input
,
const
unsigned
char
**
const
ep
);
static
unsigned
char
*
print_array
(
const
cJSON
*
const
item
,
const
size_t
depth
,
const
cjbool
format
,
printbuffer
*
const
output_buffer
);
static
unsigned
char
*
print_array
(
const
cJSON
*
const
item
,
const
size_t
depth
,
const
cjbool
format
,
printbuffer
*
const
output_buffer
);
static
const
unsigned
char
*
parse_object
(
cJSON
*
const
item
,
const
unsigned
char
*
input
,
const
unsigned
char
**
const
ep
);
static
const
unsigned
char
*
parse_object
(
cJSON
*
const
item
,
const
unsigned
char
*
input
,
const
unsigned
char
**
const
ep
);
static
unsigned
char
*
print_object
(
const
cJSON
*
item
,
size_t
depth
,
cjbool
fmt
,
printbuffer
*
p
);
static
unsigned
char
*
print_object
(
const
cJSON
*
const
item
,
size_t
depth
,
const
cjbool
format
,
printbuffer
*
const
output_buffer
);
/* Utility to jump whitespace and cr/lf */
/* Utility to jump whitespace and cr/lf */
static
const
unsigned
char
*
skip_whitespace
(
const
unsigned
char
*
in
)
static
const
unsigned
char
*
skip_whitespace
(
const
unsigned
char
*
in
)
...
@@ -1312,152 +1312,152 @@ fail:
...
@@ -1312,152 +1312,152 @@ fail:
}
}
/* Render an object to text. */
/* Render an object to text. */
static
unsigned
char
*
print_object
(
const
cJSON
*
item
,
size_t
depth
,
cjbool
fmt
,
printbuffer
*
p
)
static
unsigned
char
*
print_object
(
const
cJSON
*
const
item
,
size_t
depth
,
const
cjbool
format
,
printbuffer
*
const
output_buffer
)
{
{
unsigned
char
*
out
=
NULL
;
unsigned
char
*
out
put
=
NULL
;
unsigned
char
*
pt
r
=
NULL
;
unsigned
char
*
output_pointe
r
=
NULL
;
size_t
len
=
7
;
size_t
len
gth
=
7
;
size_t
i
=
0
;
size_t
i
=
0
;
size_t
j
=
0
;
size_t
j
=
0
;
cJSON
*
c
hild
=
item
->
child
;
cJSON
*
c
urrent_item
=
item
->
child
;
size_t
numentries
=
0
;
size_t
object_length
=
0
;
if
(
p
==
NULL
)
if
(
output_buffer
==
NULL
)
{
{
return
NULL
;
return
NULL
;
}
}
/* Count the number of entries. */
/* Count the number of entries. */
while
(
c
hild
)
while
(
c
urrent_item
)
{
{
numentries
++
;
object_length
++
;
c
hild
=
child
->
next
;
c
urrent_item
=
current_item
->
next
;
}
}
/* Explicitly handle empty object case */
/* Explicitly handle empty object case */
if
(
!
numentries
)
if
(
!
object_length
)
{
{
out
=
ensure
(
p
,
fm
t
?
depth
+
4
:
3
);
out
put
=
ensure
(
output_buffer
,
forma
t
?
depth
+
4
:
3
);
if
(
out
==
NULL
)
if
(
out
put
==
NULL
)
{
{
return
NULL
;
return
NULL
;
}
}
ptr
=
o
ut
;
output_pointer
=
outp
ut
;
*
pt
r
++
=
'{'
;
*
output_pointe
r
++
=
'{'
;
if
(
f
m
t
)
{
if
(
f
orma
t
)
{
*
pt
r
++
=
'\n'
;
*
output_pointe
r
++
=
'\n'
;
for
(
i
=
0
;
i
<
depth
;
i
++
)
for
(
i
=
0
;
i
<
depth
;
i
++
)
{
{
*
pt
r
++
=
'\t'
;
*
output_pointe
r
++
=
'\t'
;
}
}
}
}
*
pt
r
++
=
'}'
;
*
output_pointe
r
++
=
'}'
;
*
pt
r
++
=
'\0'
;
*
output_pointe
r
++
=
'\0'
;
return
out
;
return
out
put
;
}
}
/* Compose the output: */
/* Compose the output: */
i
=
p
->
offset
;
i
=
output_buffer
->
offset
;
len
=
fm
t
?
2
:
1
;
/* fmt: {\n */
len
gth
=
forma
t
?
2
:
1
;
/* fmt: {\n */
ptr
=
ensure
(
p
,
len
+
1
);
output_pointer
=
ensure
(
output_buffer
,
length
+
1
);
if
(
pt
r
==
NULL
)
if
(
output_pointe
r
==
NULL
)
{
{
return
NULL
;
return
NULL
;
}
}
*
pt
r
++
=
'{'
;
*
output_pointe
r
++
=
'{'
;
if
(
f
m
t
)
if
(
f
orma
t
)
{
{
*
pt
r
++
=
'\n'
;
*
output_pointe
r
++
=
'\n'
;
}
}
*
pt
r
=
'\0'
;
*
output_pointe
r
=
'\0'
;
p
->
offset
+=
len
;
output_buffer
->
offset
+=
length
;
c
hild
=
item
->
child
;
c
urrent_item
=
item
->
child
;
depth
++
;
depth
++
;
while
(
c
hild
)
while
(
c
urrent_item
)
{
{
if
(
f
m
t
)
if
(
f
orma
t
)
{
{
ptr
=
ensure
(
p
,
depth
);
output_pointer
=
ensure
(
output_buffer
,
depth
);
if
(
pt
r
==
NULL
)
if
(
output_pointe
r
==
NULL
)
{
{
return
NULL
;
return
NULL
;
}
}
for
(
j
=
0
;
j
<
depth
;
j
++
)
for
(
j
=
0
;
j
<
depth
;
j
++
)
{
{
*
pt
r
++
=
'\t'
;
*
output_pointe
r
++
=
'\t'
;
}
}
p
->
offset
+=
depth
;
output_buffer
->
offset
+=
depth
;
}
}
/* print key */
/* print key */
if
(
!
print_string_ptr
((
unsigned
char
*
)
c
hild
->
string
,
p
))
if
(
!
print_string_ptr
((
unsigned
char
*
)
c
urrent_item
->
string
,
output_buffer
))
{
{
return
NULL
;
return
NULL
;
}
}
update_offset
(
p
);
update_offset
(
output_buffer
);
len
=
fm
t
?
2
:
1
;
len
gth
=
forma
t
?
2
:
1
;
ptr
=
ensure
(
p
,
len
);
output_pointer
=
ensure
(
output_buffer
,
length
);
if
(
pt
r
==
NULL
)
if
(
output_pointe
r
==
NULL
)
{
{
return
NULL
;
return
NULL
;
}
}
*
pt
r
++
=
':'
;
*
output_pointe
r
++
=
':'
;
if
(
f
m
t
)
if
(
f
orma
t
)
{
{
*
pt
r
++
=
'\t'
;
*
output_pointe
r
++
=
'\t'
;
}
}
p
->
offset
+=
len
;
output_buffer
->
offset
+=
length
;
/* print value */
/* print value */
if
(
!
print_value
(
c
hild
,
depth
,
fmt
,
p
))
if
(
!
print_value
(
c
urrent_item
,
depth
,
format
,
output_buffer
))
{
{
return
NULL
;
return
NULL
;
}
}
update_offset
(
p
);
update_offset
(
output_buffer
);
/* print comma if not last */
/* print comma if not last */
len
=
(
size_t
)
(
fmt
?
1
:
0
)
+
(
child
->
next
?
1
:
0
);
len
gth
=
(
size_t
)
(
format
?
1
:
0
)
+
(
current_item
->
next
?
1
:
0
);
ptr
=
ensure
(
p
,
len
+
1
);
output_pointer
=
ensure
(
output_buffer
,
length
+
1
);
if
(
pt
r
==
NULL
)
if
(
output_pointe
r
==
NULL
)
{
{
return
NULL
;
return
NULL
;
}
}
if
(
c
hild
->
next
)
if
(
c
urrent_item
->
next
)
{
{
*
pt
r
++
=
','
;
*
output_pointe
r
++
=
','
;
}
}
if
(
f
m
t
)
if
(
f
orma
t
)
{
{
*
pt
r
++
=
'\n'
;
*
output_pointe
r
++
=
'\n'
;
}
}
*
pt
r
=
'\0'
;
*
output_pointe
r
=
'\0'
;
p
->
offset
+=
len
;
output_buffer
->
offset
+=
length
;
c
hild
=
child
->
next
;
c
urrent_item
=
current_item
->
next
;
}
}
ptr
=
ensure
(
p
,
fm
t
?
(
depth
+
1
)
:
2
);
output_pointer
=
ensure
(
output_buffer
,
forma
t
?
(
depth
+
1
)
:
2
);
if
(
pt
r
==
NULL
)
if
(
output_pointe
r
==
NULL
)
{
{
return
NULL
;
return
NULL
;
}
}
if
(
f
m
t
)
if
(
f
orma
t
)
{
{
for
(
i
=
0
;
i
<
(
depth
-
1
);
i
++
)
for
(
i
=
0
;
i
<
(
depth
-
1
);
i
++
)
{
{
*
pt
r
++
=
'\t'
;
*
output_pointe
r
++
=
'\t'
;
}
}
}
}
*
pt
r
++
=
'}'
;
*
output_pointe
r
++
=
'}'
;
*
pt
r
=
'\0'
;
*
output_pointe
r
=
'\0'
;
out
=
(
p
->
buffer
)
+
i
;
out
put
=
(
output_buffer
->
buffer
)
+
i
;
return
out
;
return
out
put
;
}
}
/* Get Array size/item / object item. */
/* Get Array size/item / object item. */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录