Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party CJSON
提交
f16dd7e0
T
Third Party CJSON
项目概览
OpenHarmony
/
Third Party CJSON
10 个月 前同步成功
通知
4
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,体验更适合开发者的 AI 搜索 >>
提交
f16dd7e0
编写于
2月 20, 2017
作者:
M
Max Bruckner
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
print_array: rename variables
上级
08770fc2
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
42 addition
and
42 deletion
+42
-42
cJSON.c
cJSON.c
+42
-42
未找到文件。
cJSON.c
浏览文件 @
f16dd7e0
...
...
@@ -784,7 +784,7 @@ static unsigned char *print_string(const cJSON * const item, printbuffer * const
static
const
unsigned
char
*
parse_value
(
cJSON
*
const
item
,
const
unsigned
char
*
const
input
,
const
unsigned
char
**
const
ep
);
static
unsigned
char
*
print_value
(
const
cJSON
*
const
item
,
const
size_t
depth
,
const
cjbool
format
,
printbuffer
*
const
output_buffer
);
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
*
item
,
size_t
depth
,
cjbool
fmt
,
printbuffer
*
p
);
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
unsigned
char
*
print_object
(
const
cJSON
*
item
,
size_t
depth
,
cjbool
fmt
,
printbuffer
*
p
);
...
...
@@ -1152,87 +1152,87 @@ fail:
}
/* Render an array to text */
static
unsigned
char
*
print_array
(
const
cJSON
*
item
,
size_t
depth
,
cjbool
fmt
,
printbuffer
*
p
)
static
unsigned
char
*
print_array
(
const
cJSON
*
const
item
,
const
size_t
depth
,
const
cjbool
format
,
printbuffer
*
const
output_buffer
)
{
unsigned
char
*
out
=
NULL
;
unsigned
char
*
pt
r
=
NULL
;
size_t
len
=
5
;
cJSON
*
c
hild
=
item
->
child
;
size_t
numentries
=
0
;
unsigned
char
*
out
put
=
NULL
;
unsigned
char
*
output_pointe
r
=
NULL
;
size_t
len
gth
=
5
;
cJSON
*
c
urrent_element
=
item
->
child
;
size_t
array_length
=
0
;
size_t
i
=
0
;
cjbool
fail
=
false
;
if
(
p
==
NULL
)
if
(
output_buffer
==
NULL
)
{
return
NULL
;
}
/* How many entries in the array? */
while
(
c
hild
)
while
(
c
urrent_element
)
{
numentries
++
;
c
hild
=
child
->
next
;
array_length
++
;
c
urrent_element
=
current_element
->
next
;
}
/* Explicitly handle
numentries == 0
*/
if
(
!
numentries
)
/* Explicitly handle
empty arrays
*/
if
(
array_length
==
0
)
{
out
=
ensure
(
p
,
3
);
if
(
out
!=
NULL
)
out
put
=
ensure
(
output_buffer
,
3
);
if
(
out
put
!=
NULL
)
{
strcpy
((
char
*
)
out
,
"[]"
);
strcpy
((
char
*
)
out
put
,
"[]"
);
}
return
out
;
return
out
put
;
}
/* Compose the output array. */
/* opening square bracket */
i
=
p
->
offset
;
ptr
=
ensure
(
p
,
1
);
if
(
pt
r
==
NULL
)
i
=
output_buffer
->
offset
;
output_pointer
=
ensure
(
output_buffer
,
1
);
if
(
output_pointe
r
==
NULL
)
{
return
NULL
;
}
*
pt
r
=
'['
;
p
->
offset
++
;
*
output_pointe
r
=
'['
;
output_buffer
->
offset
++
;
c
hild
=
item
->
child
;
while
(
c
hild
&&
!
fail
)
c
urrent_element
=
item
->
child
;
while
(
c
urrent_element
&&
!
fail
)
{
if
(
!
print_value
(
c
hild
,
depth
+
1
,
fmt
,
p
))
if
(
!
print_value
(
c
urrent_element
,
depth
+
1
,
format
,
output_buffer
))
{
return
NULL
;
}
p
->
offset
=
update
(
p
);
if
(
c
hild
->
next
)
output_buffer
->
offset
=
update
(
output_buffer
);
if
(
c
urrent_element
->
next
)
{
len
=
fm
t
?
2
:
1
;
ptr
=
ensure
(
p
,
len
+
1
);
if
(
pt
r
==
NULL
)
len
gth
=
forma
t
?
2
:
1
;
output_pointer
=
ensure
(
output_buffer
,
length
+
1
);
if
(
output_pointe
r
==
NULL
)
{
return
NULL
;
}
*
pt
r
++
=
','
;
if
(
f
m
t
)
*
output_pointe
r
++
=
','
;
if
(
f
orma
t
)
{
*
pt
r
++
=
' '
;
*
output_pointe
r
++
=
' '
;
}
*
pt
r
=
'\0'
;
p
->
offset
+=
len
;
*
output_pointe
r
=
'\0'
;
output_buffer
->
offset
+=
length
;
}
c
hild
=
child
->
next
;
c
urrent_element
=
current_element
->
next
;
}
ptr
=
ensure
(
p
,
2
);
if
(
pt
r
==
NULL
)
output_pointer
=
ensure
(
output_buffer
,
2
);
if
(
output_pointe
r
==
NULL
)
{
return
NULL
;
}
*
pt
r
++
=
']'
;
*
pt
r
=
'\0'
;
out
=
(
p
->
buffer
)
+
i
;
*
output_pointe
r
++
=
']'
;
*
output_pointe
r
=
'\0'
;
out
put
=
(
output_buffer
->
buffer
)
+
i
;
return
out
;
return
out
put
;
}
/* Build an object from the text. */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录