Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
8 changes: 5 additions & 3 deletions lib/xy.h
Original file line number Diff line number Diff line change
Expand Up @@ -508,11 +508,13 @@ _xy_str_to_terminal_style (int style, const char *str)
color_fmt_str = "\e[9m%s\e[0m"; break;
}


// 标签后第一句必须为statement,否则会编译不通过
size_t len;
char *buf;
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