Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
3530cc2d
T
Third Party Harfbuzz
项目概览
OpenHarmony
/
Third Party Harfbuzz
1 年多 前同步成功
通知
0
Star
18
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Harfbuzz
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
3530cc2d
编写于
11月 03, 2015
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[util] Fix option-parsing leaks
上级
642135f3
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
70 addition
and
33 deletion
+70
-33
util/helper-cairo.cc
util/helper-cairo.cc
+5
-2
util/main-font-text.hh
util/main-font-text.hh
+19
-3
util/options.cc
util/options.cc
+11
-10
util/options.hh
util/options.hh
+35
-18
未找到文件。
util/helper-cairo.cc
浏览文件 @
3530cc2d
...
...
@@ -349,10 +349,13 @@ helper_cairo_create_context (double w, double h,
unsigned
int
fr
,
fg
,
fb
,
fa
,
br
,
bg
,
bb
,
ba
;
const
char
*
color
;
br
=
bg
=
bb
=
0
;
ba
=
255
;
sscanf
(
view_opts
->
back
+
(
*
view_opts
->
back
==
'#'
),
"%2x%2x%2x%2x"
,
&
br
,
&
bg
,
&
bb
,
&
ba
);
color
=
view_opts
->
back
?
view_opts
->
back
:
DEFAULT_BACK
;
sscanf
(
color
+
(
*
color
==
'#'
),
"%2x%2x%2x%2x"
,
&
br
,
&
bg
,
&
bb
,
&
ba
);
fr
=
fg
=
fb
=
0
;
fa
=
255
;
sscanf
(
view_opts
->
fore
+
(
*
view_opts
->
fore
==
'#'
),
"%2x%2x%2x%2x"
,
&
fr
,
&
fg
,
&
fb
,
&
fa
);
color
=
view_opts
->
fore
?
view_opts
->
fore
:
DEFAULT_FORE
;
sscanf
(
color
+
(
*
color
==
'#'
),
"%2x%2x%2x%2x"
,
&
fr
,
&
fg
,
&
fb
,
&
fa
);
cairo_content_t
content
;
if
(
!
view_opts
->
annotate
&&
ba
==
255
&&
br
==
bg
&&
bg
==
bb
&&
fr
==
fg
&&
fg
==
fb
)
...
...
util/main-font-text.hh
浏览文件 @
3530cc2d
...
...
@@ -31,6 +31,22 @@
/* main() body for utilities taking font and processing text.*/
static
char
*
locale_to_utf8
(
char
*
s
)
{
char
*
t
;
GError
*
error
=
NULL
;
t
=
g_locale_to_utf8
(
s
,
-
1
,
NULL
,
NULL
,
&
error
);
if
(
!
t
)
{
fail
(
true
,
"Failed converting text to UTF-8"
);
}
return
t
;
}
template
<
typename
consumer_t
,
int
default_font_size
,
int
subpixel_bits
>
struct
main_font_text_t
{
...
...
@@ -46,14 +62,14 @@ struct main_font_text_t
options
.
parse
(
&
argc
,
&
argv
);
argc
--
,
argv
++
;
if
(
argc
&&
!
font_opts
.
font_file
)
font_opts
.
font_file
=
argv
[
0
]
,
argc
--
,
argv
++
;
if
(
argc
&&
!
input
.
text
&&
!
input
.
text_file
)
input
.
text
=
argv
[
0
]
,
argc
--
,
argv
++
;
if
(
argc
&&
!
font_opts
.
font_file
)
font_opts
.
font_file
=
locale_to_utf8
(
argv
[
0
])
,
argc
--
,
argv
++
;
if
(
argc
&&
!
input
.
text
&&
!
input
.
text_file
)
input
.
text
=
locale_to_utf8
(
argv
[
0
])
,
argc
--
,
argv
++
;
if
(
argc
)
fail
(
true
,
"Too many arguments on the command line"
);
if
(
!
font_opts
.
font_file
)
options
.
usage
();
if
(
!
input
.
text
&&
!
input
.
text_file
)
input
.
text_file
=
"-"
;
input
.
text_file
=
g_strdup
(
"-"
)
;
consumer
.
init
(
&
font_opts
);
...
...
util/options.cc
浏览文件 @
3530cc2d
...
...
@@ -601,25 +601,26 @@ const char *
text_options_t
::
get_line
(
unsigned
int
*
len
)
{
if
(
text
)
{
if
(
text_len
==
(
unsigned
int
)
-
1
)
text_len
=
strlen
(
text
);
if
(
!
line
)
line
=
text
;
if
(
line_len
==
(
unsigned
int
)
-
1
)
line_len
=
strlen
(
line
);
if
(
!
text
_len
)
{
if
(
!
line
_len
)
{
*
len
=
0
;
return
NULL
;
}
const
char
*
ret
=
text
;
const
char
*
p
=
(
const
char
*
)
memchr
(
text
,
'\n'
,
text
_len
);
const
char
*
ret
=
line
;
const
char
*
p
=
(
const
char
*
)
memchr
(
line
,
'\n'
,
line
_len
);
unsigned
int
ret_len
;
if
(
!
p
)
{
ret_len
=
text
_len
;
text
+=
ret_len
;
text
_len
=
0
;
ret_len
=
line
_len
;
line
+=
ret_len
;
line
_len
=
0
;
}
else
{
ret_len
=
p
-
ret
;
text
+=
ret_len
+
1
;
text
_len
-=
ret_len
+
1
;
line
+=
ret_len
+
1
;
line
_len
-=
ret_len
+
1
;
}
*
len
=
ret_len
;
...
...
util/options.hh
浏览文件 @
3530cc2d
...
...
@@ -150,19 +150,24 @@ struct view_options_t : option_group_t
{
view_options_t
(
option_parser_t
*
parser
)
{
annotate
=
false
;
fore
=
DEFAULT_FORE
;
back
=
DEFAULT_BACK
;
fore
=
NULL
;
back
=
NULL
;
line_space
=
0
;
margin
.
t
=
margin
.
r
=
margin
.
b
=
margin
.
l
=
DEFAULT_MARGIN
;
add_options
(
parser
);
}
~
view_options_t
(
void
)
{
g_free
(
fore
);
g_free
(
back
);
}
void
add_options
(
option_parser_t
*
parser
);
hb_bool_t
annotate
;
c
onst
c
har
*
fore
;
c
onst
c
har
*
back
;
char
*
fore
;
char
*
back
;
double
line_space
;
struct
margin_t
{
double
t
,
r
,
b
,
l
;
...
...
@@ -188,6 +193,9 @@ struct shape_options_t : option_group_t
}
~
shape_options_t
(
void
)
{
g_free
(
direction
);
g_free
(
language
);
g_free
(
script
);
free
(
features
);
g_strfreev
(
shapers
);
}
...
...
@@ -254,9 +262,9 @@ struct shape_options_t : option_group_t
}
/* Buffer properties */
c
onst
c
har
*
direction
;
c
onst
c
har
*
language
;
c
onst
c
har
*
script
;
char
*
direction
;
char
*
language
;
char
*
script
;
/* Buffer flags */
hb_bool_t
bot
;
...
...
@@ -290,6 +298,8 @@ struct font_options_t : option_group_t
add_options
(
parser
);
}
~
font_options_t
(
void
)
{
g_free
(
font_file
);
g_free
(
font_funcs
);
hb_font_destroy
(
font
);
}
...
...
@@ -297,13 +307,13 @@ struct font_options_t : option_group_t
hb_font_t
*
get_font
(
void
)
const
;
c
onst
c
har
*
font_file
;
char
*
font_file
;
int
face_index
;
int
default_font_size
;
unsigned
int
subpixel_bits
;
mutable
double
font_size_x
;
mutable
double
font_size_y
;
c
onst
c
har
*
font_funcs
;
char
*
font_funcs
;
private:
mutable
hb_font_t
*
font
;
...
...
@@ -321,11 +331,16 @@ struct text_options_t : option_group_t
fp
=
NULL
;
gs
=
NULL
;
text_len
=
(
unsigned
int
)
-
1
;
line
=
NULL
;
line_len
=
(
unsigned
int
)
-
1
;
add_options
(
parser
);
}
~
text_options_t
(
void
)
{
g_free
(
text_before
);
g_free
(
text_after
);
g_free
(
text
);
g_free
(
text_file
);
if
(
gs
)
g_string_free
(
gs
,
true
);
if
(
fp
)
...
...
@@ -339,21 +354,21 @@ struct text_options_t : option_group_t
g_set_error
(
error
,
G_OPTION_ERROR
,
G_OPTION_ERROR_BAD_VALUE
,
"Only one of text and text-file can be set"
);
};
const
char
*
get_line
(
unsigned
int
*
len
);
c
onst
c
har
*
text_before
;
c
onst
c
har
*
text_after
;
char
*
text_before
;
char
*
text_after
;
c
onst
c
har
*
text
;
c
onst
c
har
*
text_file
;
char
*
text
;
char
*
text_file
;
private:
FILE
*
fp
;
GString
*
gs
;
unsigned
int
text_len
;
char
*
line
;
unsigned
int
line_len
;
};
struct
output_options_t
:
option_group_t
...
...
@@ -370,6 +385,8 @@ struct output_options_t : option_group_t
add_options
(
parser
);
}
~
output_options_t
(
void
)
{
g_free
(
output_file
);
g_free
(
output_format
);
if
(
fp
)
fclose
(
fp
);
}
...
...
@@ -393,8 +410,8 @@ struct output_options_t : option_group_t
FILE
*
get_file_handle
(
void
);
c
onst
c
har
*
output_file
;
c
onst
c
har
*
output_format
;
char
*
output_file
;
char
*
output_format
;
const
char
**
supported_formats
;
bool
explicit_output_format
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录