Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/xy.h
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,8 @@ static char *
_xy_str_to_terminal_style (int style, const char *str)
{
char *color_fmt_str = NULL;
size_t len;
char *buf;

if (!xy.enable_color)
{
Expand Down Expand Up @@ -511,8 +513,8 @@ _xy_str_to_terminal_style (int style, const char *str)

new_str:
// -2 把中间%s减掉
size_t len = strlen (color_fmt_str) - 2;
char *buf = malloc (strlen (str) + len + 1);
len = strlen (color_fmt_str) - 2;
buf = malloc (strlen (str) + len + 1);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我建议把 char *声明还是放到 buf 前面。因为这是第二句了。

编译器要求以及注释这里写明了的是 new_str 标签后的第一句不能为声明,那就按照注释所标注的来,只动第一句,第二句不动。

sprintf (buf, color_fmt_str, str);
return buf;
}
Expand Down
2 changes: 1 addition & 1 deletion src/chsrc-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ cli_print_target_features (Target_t *target, const char *input_target_name)
default:
xy_unreached();
}
char *msg = xy_strcat (3, bdblue (" = "),
char *msg = xy_strcat (2, bdblue (" = "),
purple (xy_strcat (5, "默认作用域 | chsrc set -scope=default ", input_target_name, " (= ", default_scope_name ,")")));
puts (msg);
br();
Expand Down
Loading