Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenCV
opencv
提交
4e831108
O
opencv
项目概览
OpenCV
/
opencv
上一次同步 大约 1 年
通知
1005
Star
71102
Fork
55580
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4e831108
编写于
12月 03, 2018
作者:
A
Alexander Alekhin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
core(persistence): fix KW issues
上级
197285d1
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
24 addition
and
7 deletion
+24
-7
modules/core/src/persistence.cpp
modules/core/src/persistence.cpp
+12
-5
modules/core/src/persistence.hpp
modules/core/src/persistence.hpp
+12
-2
未找到文件。
modules/core/src/persistence.cpp
浏览文件 @
4e831108
...
...
@@ -114,9 +114,11 @@ char* floatToString( char* buf, float value, bool halfprecision, bool explicitZe
}
else
{
static
const
char
*
fmt
=
halfprecision
?
"%.4e"
:
"%.8e"
;
char
*
ptr
=
buf
;
sprintf
(
buf
,
fmt
,
value
);
if
(
halfprecision
)
sprintf
(
buf
,
"%.4e"
,
value
);
else
sprintf
(
buf
,
"%.8e"
,
value
);
if
(
*
ptr
==
'+'
||
*
ptr
==
'-'
)
ptr
++
;
for
(
;
cv_isdigit
(
*
ptr
);
ptr
++
)
...
...
@@ -350,6 +352,7 @@ public:
void
init
()
{
flags
=
0
;
buffer
.
clear
();
bufofs
=
0
;
state
=
UNDEFINED
;
...
...
@@ -358,6 +361,7 @@ public:
write_mode
=
false
;
mem_mode
=
false
;
space
=
0
;
wrap_margin
=
71
;
fmt
=
0
;
file
=
0
;
gzfile
=
0
;
...
...
@@ -615,7 +619,8 @@ public:
for
(;;)
{
int
line_offset
=
(
int
)
ftell
(
file
);
char
*
ptr0
=
gets
(
&
xml_buf_
[
0
],
xml_buf_size
),
*
ptr
;
const
char
*
ptr0
=
this
->
gets
(
&
xml_buf_
[
0
],
xml_buf_size
);
const
char
*
ptr
=
NULL
;
if
(
!
ptr0
)
break
;
ptr
=
ptr0
;
...
...
@@ -708,7 +713,7 @@ public:
const
char
*
json_signature
=
"{"
;
const
char
*
xml_signature
=
"<?xml"
;
char
buf
[
16
];
gets
(
buf
,
sizeof
(
buf
)
-
2
);
this
->
gets
(
buf
,
sizeof
(
buf
)
-
2
);
char
*
bufPtr
=
cv_skip_BOM
(
buf
);
size_t
bufOffset
=
bufPtr
-
buf
;
...
...
@@ -861,7 +866,7 @@ public:
char
*
gets
()
{
char
*
ptr
=
gets
(
bufferStart
(),
(
int
)(
bufferEnd
()
-
bufferStart
()));
char
*
ptr
=
this
->
gets
(
bufferStart
(),
(
int
)(
bufferEnd
()
-
bufferStart
()));
if
(
!
ptr
)
{
ptr
=
bufferStart
();
// FIXIT Why do we need this hack? What is about other parsers JSON/YAML?
...
...
@@ -1766,11 +1771,13 @@ public:
};
FileStorage
::
FileStorage
()
:
state
(
0
)
{
p
=
makePtr
<
FileStorage
::
Impl
>
(
this
);
}
FileStorage
::
FileStorage
(
const
String
&
filename
,
int
flags
,
const
String
&
encoding
)
:
state
(
0
)
{
p
=
makePtr
<
FileStorage
::
Impl
>
(
this
);
bool
ok
=
p
->
open
(
filename
.
c_str
(),
flags
,
encoding
.
c_str
());
...
...
modules/core/src/persistence.hpp
浏览文件 @
4e831108
...
...
@@ -96,11 +96,20 @@ int decodeFormat( const char* dt, int* fmt_pairs, int max_len );
int
decodeSimpleFormat
(
const
char
*
dt
);
}
#ifdef CV_STATIC_ANALYSIS
#define CV_PARSE_ERROR_CPP(errmsg) do { (void)fs; abort(); } while (0)
#else
#define CV_PARSE_ERROR_CPP( errmsg ) \
fs->parseError( CV_Func, (errmsg), __FILE__, __LINE__ )
#endif
#define CV_PERSISTENCE_CHECK_END_OF_BUFFER_BUG_CPP() do { \
CV_DbgAssert(ptr); \
if((ptr)[0] == 0 && (ptr) == fs->bufferEnd() - 1) CV_PARSE_ERROR_CPP("OpenCV persistence doesn't support very long lines"); \
} while (0)
#define CV_PERSISTENCE_CHECK_END_OF_BUFFER_BUG_CPP() \
if((ptr)[0] == 0 && (ptr) == fs->bufferEnd() - 1) CV_PARSE_ERROR_CPP("OpenCV persistence doesn't support very long lines")
class
FileStorageParser
;
class
FileStorageEmitter
;
...
...
@@ -151,6 +160,7 @@ public:
virtual
double
strtod
(
char
*
ptr
,
char
**
endptr
)
=
0
;
virtual
char
*
parseBase64
(
char
*
ptr
,
int
indent
,
FileNode
&
collection
)
=
0
;
CV_NORETURN
virtual
void
parseError
(
const
char
*
funcname
,
const
std
::
string
&
msg
,
const
char
*
filename
,
int
lineno
)
=
0
;
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录