diff --git a/lib/xy.h b/lib/xy.h index 387eec7..e02dabf 100644 --- a/lib/xy.h +++ b/lib/xy.h @@ -264,8 +264,6 @@ xy_2strcat (const char *str1, const char *str2) return ret; } -/* @deprecated 应迁移到后者 */ -#define xy_2strjoin xy_2strcat /** * @brief 将多个字符串连接成一个字符串 @@ -336,9 +334,6 @@ xy_strcat (unsigned int count, ...) return ret; } -/* @deprecated 应迁移到后者 */ -#define xy_strjoin xy_strcat - /** * @brief 复制一个字符串,返回复制的新字符串 diff --git a/src/chsrc-main.c b/src/chsrc-main.c index 1da4ce2..01b0f57 100644 --- a/src/chsrc-main.c +++ b/src/chsrc-main.c @@ -64,7 +64,7 @@ cli_print_available_mirrors () { { char *msg = ENGLISH ? "To specify a source, use chsrc set " : "指定使用某源,请使用 chsrc set "; - say (bdblue(xy_strjoin (3, msg, "", " \n"))); + say (bdblue(xy_strcat (3, msg, "", " \n"))); } { @@ -246,28 +246,28 @@ cli_print_target_features (Target_t *target, const char *input_target_name) { char *msg = ENGLISH ? " Get: View the current source state " : " Get: 查看当前源状态 "; - char *get_msg = xy_strjoin (3, msg, "| chsrc get ", input_target_name); + char *get_msg = xy_strcat (3, msg, "| chsrc get ", input_target_name); if (target->getfn != NULL) printf (" %s%s\n", bdgreen(YesMark), purple(get_msg)); else printf (" %s%s\n", bdred(NoMark), get_msg);br(); } { char *msg = ENGLISH ? " Reset: Reset to the default source " : " Reset: 重置回默认源 "; - char *reset_msg = xy_strjoin (3, msg, "| chsrc reset ", input_target_name); + char *reset_msg = xy_strcat (3, msg, "| chsrc reset ", input_target_name); if (target->resetfn != NULL) printf (" %s%s\n", bdgreen(YesMark), purple(reset_msg)); else printf (" %s%s\n", bdred(NoMark), reset_msg);br(); } { char *msg = ENGLISH ? " UserDefine: using user-defined source URL " : " UserDefine: 用户自定义换源URL "; - char *user_define_msg = xy_strjoin (5, msg, "| chsrc set ", input_target_name, " https://user-define-url.org/", input_target_name); + char *user_define_msg = xy_strcat (5, msg, "| chsrc set ", input_target_name, " https://user-define-url.org/", input_target_name); if (target->can_user_define) printf (" %s%s\n", bdgreen(YesMark), purple(user_define_msg)); else printf (" %s%s\n", bdred(NoMark), user_define_msg);br(); } { char *msg = ENGLISH ? " Locally: Change source only for this project " : " Locally: 仅对本项目换源 "; - char *locally_msg = xy_strjoin (3, msg, "| chsrc set -local ", input_target_name); + char *locally_msg = xy_strcat (3, msg, "| chsrc set -local ", input_target_name); switch (target->cap_local) { @@ -288,7 +288,7 @@ cli_print_target_features (Target_t *target, const char *input_target_name) { char *msg = ENGLISH ? " English: Output in English " : " English: 英文输出 "; - char *english_msg = xy_strjoin (3, msg, "| chsrc set -en ", input_target_name); + char *english_msg = xy_strcat (3, msg, "| chsrc set -en ", input_target_name); if (target->can_english) printf (" %s%s\n", bdgreen(YesMark), purple(english_msg)); else printf (" %s%s\n", bdred(NoMark), english_msg);br(); } @@ -531,7 +531,7 @@ get_target (const char *input, TargetOp code, char *option) { target->setfn(option); } - else chsrc_error (xy_strjoin (3, "暂未对 ", input, " 实现 set 功能,邀您帮助: chsrc issue")); + else chsrc_error (xy_strcat (3, "暂未对 ", input, " 实现 set 功能,邀您帮助: chsrc issue")); } else if (TargetOp_Reset_Source==code) { @@ -539,7 +539,7 @@ get_target (const char *input, TargetOp code, char *option) { target->resetfn(option); } - else chsrc_error (xy_strjoin (3, "暂未对 ", input, " 实现 reset 功能,邀您帮助: chsrc issue")); + else chsrc_error (xy_strcat (3, "暂未对 ", input, " 实现 reset 功能,邀您帮助: chsrc issue")); } else if (TargetOp_Get_Source==code) { @@ -547,13 +547,13 @@ get_target (const char *input, TargetOp code, char *option) { target->getfn(""); } - else chsrc_error (xy_strjoin (3, "暂未对 ", input, " 实现 get 功能,邀您帮助: chsrc issue")); + else chsrc_error (xy_strcat (3, "暂未对 ", input, " 实现 get 功能,邀您帮助: chsrc issue")); } else if (TargetOp_List_Config==code) { { char *msg = ENGLISH ? "To specify a source, use chsrc set " : "指定使用某源,请使用 chsrc set "; - say (bdblue(xy_strjoin (3, msg, input, " \n"))); + say (bdblue(xy_strcat (3, msg, input, " \n"))); } { @@ -677,7 +677,7 @@ main (int argc, char const *argv[]) else { char *msg = ENGLISH ? "Unknown option: " : "未识别的命令行选项 "; - chsrc_error (xy_2strjoin (msg, argv[i])); return Exit_Unknown; + chsrc_error (xy_2strcat (msg, argv[i])); return Exit_Unknown; } cli_arg_Target_pos++; cli_arg_Mirror_pos++; @@ -860,7 +860,7 @@ main (int argc, char const *argv[]) { char *msg1 = ENGLISH ? "Unknown command `" : "不支持的命令 "; char *msg2 = ENGLISH ? "`. Use `chsrc help` to view usage" : ". 请使用 chsrc help 查看使用方式"; - chsrc_error (xy_strjoin (3, msg1, command, msg2)); + chsrc_error (xy_strcat (3, msg1, command, msg2)); return Exit_Unknown; } diff --git a/src/framework/chef-helper.c b/src/framework/chef-helper.c index 9113f7b..c513aa1 100644 --- a/src/framework/chef-helper.c +++ b/src/framework/chef-helper.c @@ -2,10 +2,10 @@ * SPDX-License-Identifier: GPL-3.0-or-later * ------------------------------------------------------------- * File Name : chef-helper.c - * File Authors : Aoran Zeng - * Contributors : Nul None + * File Authors : 曾奥然 + * Contributors : Nul None * Created On : <2025-07-14> - * Last Modified : <2025-08-09> + * Last Modified : <2025-08-20> * * For chefs (recipe makers) and sometimes framewoker * to do some work not releated to OS operations @@ -40,5 +40,5 @@ chef_ensure_trailing_slash (char *str) if (len == 0 || str[len - 1] == '/') return xy_strdup (str); - return xy_2strjoin (str, "/"); + return xy_2strcat (str, "/"); } diff --git a/src/framework/chef.c b/src/framework/chef.c index 63b64c5..66dd96f 100644 --- a/src/framework/chef.c +++ b/src/framework/chef.c @@ -51,7 +51,7 @@ chef_set_provider_speed_measure_url (SourceProvider_t *provider, char *url) { provider->psmi.skip = NotSkip; provider->psmi.url = xy_strdup (url); - chsrc_debug ("m", xy_strjoin (4, "recipe 重新为 ", provider->code, " 设置测速链接: ", url)); + chsrc_debug ("m", xy_strcat (4, "recipe 重新为 ", provider->code, " 设置测速链接: ", url)); } @@ -62,7 +62,7 @@ void chef_set_provider_speed_measure_accuracy (SourceProvider_t *provider, bool accuracy) { provider->psmi.accurate = accuracy; - chsrc_debug ("m", xy_strjoin (4, "recipe 重新为 ", provider->code, " 设置测速精度: ", accuracy ? "精准" : "粗略")); + chsrc_debug ("m", xy_strcat (4, "recipe 重新为 ", provider->code, " 设置测速精度: ", accuracy ? "精准" : "粗略")); } @@ -99,7 +99,7 @@ chef_set_sources_speed_measure_url_with_func ( void chef_set_sources_speed_measure_url_with_postfix (Target_t *target, char *postfix) { - chef_set_sources_speed_measure_url_with_func (target, xy_2strjoin, postfix); + chef_set_sources_speed_measure_url_with_func (target, xy_2strcat, postfix); } diff --git a/src/framework/core.c b/src/framework/core.c index 0443afb..dcfae7c 100644 --- a/src/framework/core.c +++ b/src/framework/core.c @@ -232,8 +232,8 @@ chsrc_log_backup (const char *filename) { char *msg = ENGLISH ? "BACKUP" : "备份"; - char *bak = xy_2strjoin (filename, ".bak"); - xy_log_brkt (blue(App_Name), bdblue(msg), xy_strjoin (3, bdyellow(filename), " -> ", bdgreen(bak))); + char *bak = xy_2strcat (filename, ".bak"); + xy_log_brkt (blue(App_Name), bdblue(msg), xy_strcat (3, bdyellow(filename), " -> ", bdgreen(bak))); } #define YesMark "✓" @@ -264,12 +264,12 @@ log_check_result (const char *check_what, const char *check_type, bool exist) if (!exist) { - xy_log_brkt (App_Name, bdred (chk_msg), xy_strjoin (5, + xy_log_brkt (App_Name, bdred (chk_msg), xy_strcat (5, red (NoMark " "), check_type, " ", red (check_what), not_exist_msg)); } else { - xy_log_brkt (App_Name, bdgreen (chk_msg), xy_strjoin (5, + xy_log_brkt (App_Name, bdgreen (chk_msg), xy_strcat (5, green (YesMark " "), check_type, " ", green (check_what), exist_msg)); } } @@ -301,7 +301,7 @@ log_cmd_result (bool result, int exit_status) { char buf[8] = {0}; sprintf (buf, "%d", exit_status); - char *log = xy_2strjoin (red (fail_msg), bdred (buf)); + char *log = xy_2strcat (red (fail_msg), bdred (buf)); xy_log_brkt (red (App_Name), bdred (run_msg), log); } } @@ -338,7 +338,7 @@ query_program_exist (char *check_cmd, char *prog_name, int mode) { if (mode & Noisy_When_NonExist) { - // xy_warn (xy_strjoin(4, "× 命令 ", progname, " 不存在,", buf)); + // xy_warn (xy_strcat(4, "× 命令 ", progname, " 不存在,", buf)); log_check_result (prog_name, msg, false); } return false; @@ -364,7 +364,7 @@ cmd_to_check_program (char *prog_name) { char *check_tool = xy_on_windows ? "where " : "command -v "; - char *quiet_cmd = xy_str_to_quietcmd (xy_2strjoin (check_tool, prog_name)); + char *quiet_cmd = xy_str_to_quietcmd (xy_2strcat (check_tool, prog_name)); return quiet_cmd; } @@ -383,7 +383,7 @@ XY_Deprecate_This("Use cmd_to_check_program() instead") static char * cmd_to_check_program2 (char *prog_name) { - char *quiet_cmd = xy_str_to_quietcmd (xy_2strjoin (prog_name, " --version")); + char *quiet_cmd = xy_str_to_quietcmd (xy_2strcat (prog_name, " --version")); return quiet_cmd; } @@ -448,7 +448,7 @@ chsrc_ensure_program (char *prog_name) { char *msg1 = ENGLISH ? "not found " : "未找到 "; char *msg2 = ENGLISH ? " command, please check for existence" : " 命令,请检查是否存在"; - chsrc_error (xy_strjoin (3, msg1, prog_name, msg2)); + chsrc_error (xy_strcat (3, msg1, prog_name, msg2)); exit (Exit_UserCause); } } @@ -493,7 +493,7 @@ query_mirror_exist (Source_t *sources, size_t size, char *target_name, char *inp { char *msg1 = ENGLISH ? "Currently " : "当前 "; char *msg2 = ENGLISH ? " doesn't have any source available. Please contact the maintainers" : " 无任何可用源,请联系维护者"; - chsrc_error (xy_strjoin (3, msg1, target_name, msg2)); + chsrc_error (xy_strcat (3, msg1, target_name, msg2)); exit (Exit_MaintainerCause); } @@ -501,7 +501,7 @@ query_mirror_exist (Source_t *sources, size_t size, char *target_name, char *inp { char *msg1 = ENGLISH ? "Currently " : "当前 "; char *msg2 = ENGLISH ? " only the upstream source exists. Please contact the maintainers" : " 仅存在上游默认源,请联系维护者"; - chsrc_error (xy_strjoin (3, msg1, target_name, msg2)); + chsrc_error (xy_strcat (3, msg1, target_name, msg2)); exit (Exit_MaintainerCause); } @@ -520,7 +520,7 @@ query_mirror_exist (Source_t *sources, size_t size, char *target_name, char *inp : " 目前唯一可用镜像站,感谢他们的慷慨支持"; const char *name = ENGLISH ? sources[1].mirror->abbr : sources[1].mirror->name; - chsrc_succ (xy_strjoin (4, name, msg1, target_name, msg2)); + chsrc_succ (xy_strcat (4, name, msg1, target_name, msg2)); } if (xy_streql ("first", input)) @@ -549,11 +549,11 @@ query_mirror_exist (Source_t *sources, size_t size, char *target_name, char *inp { char *msg1 = ENGLISH ? "Mirror site " : "镜像站 "; char *msg2 = ENGLISH ? " doesn't exist" : " 不存在"; - chsrc_error (xy_strjoin (3, msg1, input, msg2)); + chsrc_error (xy_strcat (3, msg1, input, msg2)); } char *msg = ENGLISH ? "To see available sources, use chsrc list " : "查看可使用源,请使用 chsrc list "; - chsrc_error (xy_2strjoin (msg, target_name)); + chsrc_error (xy_2strcat (msg, target_name)); exit (Exit_UserCause); } return idx; @@ -626,12 +626,12 @@ measure_speed_for_url (void *url) /** * @note 我们用 —L,因为部分链接会跳转到其他地方,比如: RubyChina, npmmirror */ - char *curl_cmd = xy_strjoin (8, "curl -qsL ", ipv6, + char *curl_cmd = xy_strcat (8, "curl -qsL ", ipv6, " -o ", os_devnull, " -w \"%{http_code} %{speed_download}\" -m", time_sec, " -A chsrc/" Chsrc_Version " ", url); - // chsrc_info (xy_2strjoin ("测速命令 ", curl_cmd)); + // chsrc_info (xy_2strcat ("测速命令 ", curl_cmd)); char *curl_buf = xy_run (curl_cmd, 0); @@ -656,8 +656,8 @@ parse_and_say_curl_result (char *curl_buf) if (200!=http_code) { - char *http_code_str = yellow (xy_2strjoin ("HTTP码 ", curl_buf)); - say (xy_strjoin (3, speedstr, " | ", http_code_str)); + char *http_code_str = yellow (xy_2strcat ("HTTP码 ", curl_buf)); + say (xy_strcat (3, speedstr, " | ", http_code_str)); } else { @@ -728,7 +728,7 @@ measure_speed_for_every_source (Source_t sources[], int size, double speed_recor { char *msg1 = ENGLISH ? "Maintainers don't offer " : "维护者未提供 "; char *msg2 = ENGLISH ? " mirror site's speed measure link, so skip it" : " 镜像站测速链接,跳过该站点(需修复)"; - chsrc_warn (xy_strjoin (3, msg1, provider->code, msg2)); + chsrc_warn (xy_strcat (3, msg1, provider->code, msg2)); speed = 0; speed_records[i] = speed; @@ -740,7 +740,7 @@ measure_speed_for_every_source (Source_t sources[], int size, double speed_recor if (chef_is_url (provider_speed_url)) { url = xy_strdup (provider_speed_url); - chsrc_debug ("m", xy_2strjoin ("使用镜像站整体测速链接: ", url)); + chsrc_debug ("m", xy_2strcat ("使用镜像站整体测速链接: ", url)); } } else if (provider_skip) @@ -754,13 +754,13 @@ measure_speed_for_every_source (Source_t sources[], int size, double speed_recor { url = xy_strdup (dedicated_speed_url); has_dedicated_speed_url = true; - chsrc_debug ("m", xy_2strjoin ("使用专用测速链接: ", url)); + chsrc_debug ("m", xy_2strcat ("使用专用测速链接: ", url)); } else { /* 防止维护者没填,这里有一些脏数据,我们软处理:假装该链接URL不存在 */ has_dedicated_speed_url = false; - chsrc_debug ("m", xy_2strjoin ("专用测速链接为脏数据,请修复: ", provider->name)); + chsrc_debug ("m", xy_2strcat ("专用测速链接为脏数据,请修复: ", provider->name)); } } @@ -796,7 +796,7 @@ measure_speed_for_every_source (Source_t sources[], int size, double speed_recor { skip_reason = ENGLISH ? "SKIP for no reason" : "无理由跳过"; } - measure_msgs[i] = xy_strjoin (4, faint(" x "), msg, " ", yellow(faint(skip_reason))); + measure_msgs[i] = xy_strcat (4, faint(" x "), msg, " ", yellow(faint(skip_reason))); println (measure_msgs[i]); /* 下一位 */ @@ -823,11 +823,11 @@ measure_speed_for_every_source (Source_t sources[], int size, double speed_recor if (xy_streql ("upstream", provider->code)) { - measure_msgs[i] = xy_strjoin (7, faint(" ^ "), msg, " (", src.url, ") ", accurate_msg, faint(" ... ")); + measure_msgs[i] = xy_strcat (7, faint(" ^ "), msg, " (", src.url, ") ", accurate_msg, faint(" ... ")); } else { - measure_msgs[i] = xy_strjoin (5, faint(" - "), msg, " ", accurate_msg, faint(" ... ")); + measure_msgs[i] = xy_strcat (5, faint(" - "), msg, " ", accurate_msg, faint(" ... ")); } print (measure_msgs[i]); @@ -867,7 +867,7 @@ auto_select_mirror (Source_t *sources, size_t size, const char *target_name) { char *msg1 = ENGLISH ? "Currently " : "当前 "; char *msg2 = ENGLISH ? "No any source, please contact maintainers: chsrc issue" : " 无任何可用源,请联系维护者: chsrc issue"; - chsrc_error (xy_strjoin (3, msg1, target_name, msg2)); + chsrc_error (xy_strcat (3, msg1, target_name, msg2)); exit (Exit_MaintainerCause); } @@ -932,21 +932,21 @@ auto_select_mirror (Source_t *sources, size_t size, const char *target_name) : " 目前唯一可用镜像站,感谢他们的慷慨支持"; const char *name = ENGLISH ? sources[fast_idx].mirror->abbr : sources[fast_idx].mirror->name; - say (xy_strjoin (5, msg1, bdgreen(name), green(is), green(target_name), green(msg2))); + say (xy_strcat (5, msg1, bdgreen(name), green(is), green(target_name), green(msg2))); } else { char *msg = ENGLISH ? "FASTEST mirror site: " : "最快镜像站: "; const char *name = ENGLISH ? sources[fast_idx].mirror->abbr : sources[fast_idx].mirror->name; - say (xy_2strjoin (msg, green(name))); + say (xy_2strcat (msg, green(name))); } // https://github.com/RubyMetric/chsrc/pull/71 if (in_measure_mode()) { char *msg = ENGLISH ? "URL of above source: " : "镜像源地址: "; - say (xy_2strjoin (msg, green(sources[fast_idx].url))); + say (xy_2strcat (msg, green(sources[fast_idx].url))); } return fast_idx; @@ -1065,7 +1065,7 @@ chsrc_confirm_source (Source_t *source) else { char *msg = ENGLISH ? "SELECT mirror site: " : "选中镜像站: "; - say (xy_strjoin (5, msg, green (source->mirror->abbr), " (", green (source->mirror->code), ")")); + say (xy_strcat (5, msg, green (source->mirror->abbr), " (", green (source->mirror->code), ")")); } hr(); @@ -1110,7 +1110,7 @@ chsrc_determine_chgtype (ChgType_t type) #define MSG_EN_STILL "Still need to operate manually according to the above prompts. " #define MSG_CN_STILL "仍需按上述提示手工操作" -#define thank_mirror(msg) chsrc_log(xy_2strjoin(msg,purple(ENGLISH?source->mirror->abbr:source->mirror->name))) +#define thank_mirror(msg) chsrc_log(xy_2strcat(msg,purple(ENGLISH?source->mirror->abbr:source->mirror->name))) /** * @param source 可为NULL @@ -1345,10 +1345,10 @@ chsrc_make_tmpfile (char *filename, char *postfix, bool loud, char **tmpfilename * 然而 PowerShell 的执行,即使加了 -File 参数,也必须要求你拥有 .ps1 后缀 * 这使得我们在 Windows 上只能创建一个假的临时文件 */ - char *tmpfile = xy_strjoin (3, "chsrc_tmp_", filename, postfix); + char *tmpfile = xy_strcat (3, "chsrc_tmp_", filename, postfix); FILE *f = fopen (tmpfile, "w+"); #else - char *tmpfile = xy_strjoin (5, "/tmp/", "chsrc_tmp_", filename, "_XXXXXX", postfix); + char *tmpfile = xy_strcat (5, "/tmp/", "chsrc_tmp_", filename, "_XXXXXX", postfix); size_t postfix_len = strlen (postfix); /* 和 _mktemp_s() 参数不同,前者是整个缓存区大小,这里的长度是后缀长度 */ @@ -1359,14 +1359,14 @@ chsrc_make_tmpfile (char *filename, char *postfix, bool loud, char **tmpfilename if (!f) { char *msg = CHINESE ? "无法创建临时文件: " : "Unable to create temporary file: "; - msg = xy_2strjoin (msg, tmpfile); + msg = xy_2strcat (msg, tmpfile); chsrc_error2 (msg); exit (Exit_ExternalError); } else if (loud) { char *msg = CHINESE ? "已创建临时文件: " : "Temporary file created: "; - msg = xy_2strjoin (msg, tmpfile); + msg = xy_2strcat (msg, tmpfile); chsrc_succ2 (msg); } @@ -1404,7 +1404,7 @@ chsrc_run_as_bash_file (const char *script_content) char *msg = CHINESE ? "即将执行 Bash 脚本内容:" : "The Bash script content will be executed:"; chsrc_note2 (msg); println (faint(script_content)); - char *cmd = xy_2strjoin ("bash ", tmpfile); + char *cmd = xy_2strcat ("bash ", tmpfile); chsrc_run (cmd, RunOpt_Dont_Abort_On_Failure); remove (tmpfile); } @@ -1424,7 +1424,7 @@ chsrc_run_as_sh_file (const char *script_content) char *msg = CHINESE ? "即将执行 sh 脚本内容:" : "The sh script content will be executed:"; chsrc_note2 (msg); println (faint(script_content)); - char *cmd = xy_2strjoin ("sh ", tmpfile); + char *cmd = xy_2strcat ("sh ", tmpfile); chsrc_run (cmd, RunOpt_Dont_Abort_On_Failure); remove (tmpfile); } @@ -1443,7 +1443,7 @@ chsrc_run_as_pwsh_file (const char *script_content) char *msg = CHINESE ? "即将执行 PowerShell 脚本内容:" : "The PowerShell script content will be executed:"; chsrc_note2 (msg); println (faint(script_content)); - char *cmd = xy_2strjoin ("pwsh ", tmpfile); + char *cmd = xy_2strcat ("pwsh ", tmpfile); chsrc_run (cmd, RunOpt_Dont_Abort_On_Failure); remove (tmpfile); } @@ -1458,7 +1458,7 @@ XY_Deprecate_This("Don't use this function") void chsrc_run_in_inline_bash_shell (const char *cmdline) { - char *cmd = xy_strjoin (3, "bash -c '", cmdline, "'"); + char *cmd = xy_strcat (3, "bash -c '", cmdline, "'"); chsrc_run (cmd, RunOpt_Dont_Abort_On_Failure); } @@ -1472,7 +1472,7 @@ XY_Deprecate_This("Don't use this function") void chsrc_run_in_inline_pwsh_shell (const char *cmdline) { - char *cmd = xy_strjoin (3, "pwsh -Command '", cmdline, "'"); + char *cmd = xy_strcat (3, "pwsh -Command '", cmdline, "'"); chsrc_run (cmd, RunOpt_Dont_Abort_On_Failure); } @@ -1492,22 +1492,22 @@ chsrc_view_env (const char *var1, ...) #ifdef XY_On_Windows if (first) { - cmd = xy_strjoin (3, "set ", var, " "); + cmd = xy_strcat (3, "set ", var, " "); first = false; } else { - cmd = xy_strjoin (4, cmd, "& set ", var, " "); + cmd = xy_strcat (4, cmd, "& set ", var, " "); } #else if (first) { - cmd = xy_strjoin (5, "echo ", var, "=$", var, " "); + cmd = xy_strcat (5, "echo ", var, "=$", var, " "); first = false; } else { - cmd = xy_strjoin (6, cmd, "; echo ", var, "=$", var, " "); + cmd = xy_strcat (6, cmd, "; echo ", var, "=$", var, " "); } #endif var = va_arg (vars, const char *); @@ -1540,11 +1540,11 @@ chsrc_view_file (const char *path) path = xy_normalize_path (path); if (xy_on_windows) { - cmd = xy_2strjoin ("type ", path); + cmd = xy_2strcat ("type ", path); } else { - cmd = xy_2strjoin ("cat ", path); + cmd = xy_2strcat ("cat ", path); } chsrc_run_as_a_service (cmd); @@ -1570,13 +1570,13 @@ chsrc_ensure_dir (const char *dir) { mkdir_cmd = "mkdir -p "; } - char *cmd = xy_2strjoin (mkdir_cmd, dir); + char *cmd = xy_2strcat (mkdir_cmd, dir); cmd = xy_str_to_quietcmd (cmd); chsrc_run_as_a_service (cmd); char *msg = ENGLISH ? "Directory doesn't exist, created automatically " : "目录不存在,已自动创建 "; - chsrc_alert2 (xy_2strjoin (msg, dir)); + chsrc_alert2 (xy_2strcat (msg, dir)); } @@ -1595,8 +1595,8 @@ chsrc_append_to_file (const char *str, const char *filename) FILE *f = fopen (file, "a"); if (NULL==f) { - char *msg = ENGLISH ? xy_2strjoin ("Unable to open file to write: ", file) - : xy_2strjoin ("无法打开文件以写入: ", file); + char *msg = ENGLISH ? xy_2strcat ("Unable to open file to write: ", file) + : xy_2strcat ("无法打开文件以写入: ", file); chsrc_error2 (msg); exit (Exit_UserCause); } @@ -1606,8 +1606,8 @@ chsrc_append_to_file (const char *str, const char *filename) size_t ret = fwrite (str, len, 1, f); if (ret != 1) { - char *msg = ENGLISH ? xy_2strjoin ("Write failed to ", file) - : xy_2strjoin ("写入文件失败: ", file); + char *msg = ENGLISH ? xy_2strcat ("Write failed to ", file) + : xy_2strcat ("写入文件失败: ", file); chsrc_error2 (msg); exit (Exit_UserCause); } @@ -1622,11 +1622,11 @@ log_anyway: char *cmd = NULL; if (xy_on_windows) { - cmd = xy_strjoin (4, "echo ", str, " >> ", file); + cmd = xy_strcat (4, "echo ", str, " >> ", file); } else { - cmd = xy_strjoin (4, "echo '", str, "' >> ", file); + cmd = xy_strcat (4, "echo '", str, "' >> ", file); } chsrc_run_a_service (cmd); */ @@ -1651,7 +1651,7 @@ chsrc_prepend_to_file (const char *str, const char *filename) } else { - cmd = xy_strjoin (4, "sed -i '1i ", str, "' ", file); + cmd = xy_strcat (4, "sed -i '1i ", str, "' ", file); } chsrc_run_as_a_service (cmd); @@ -1675,11 +1675,11 @@ chsrc_overwrite_file (const char *str, const char *filename) char *cmd = NULL; if (xy_on_windows) { - cmd = xy_strjoin (4, "echo ", str, " > ", file); + cmd = xy_strcat (4, "echo ", str, " > ", file); } else { - cmd = xy_strjoin (4, "echo '", str, "' > ", file); + cmd = xy_strcat (4, "echo '", str, "' > ", file); } chsrc_run_as_a_service (cmd); @@ -1702,14 +1702,14 @@ chsrc_backup (const char *path) if (!exist) { char *msg = ENGLISH ? "File doesn't exist, skip backup: " : "文件不存在,跳过备份: "; - chsrc_alert2 (xy_2strjoin (msg, path)); + chsrc_alert2 (xy_2strcat (msg, path)); return; } if (xy_on_bsd || xy_on_macos) { /* BSD 和 macOS 的 cp 不支持 --backup 选项 */ - cmd = xy_strjoin (5, "cp -f ", path, " ", path, ".bak"); + cmd = xy_strcat (5, "cp -f ", path, " ", path, ".bak"); } else if (xy_on_windows) { @@ -1717,7 +1717,7 @@ chsrc_backup (const char *path) * @note /Y 表示覆盖 * @note 默认情况下会输出一个 "已复制 1个文件" */ - cmd = xy_strjoin (5, "copy /Y ", path, " ", path, ".bak 1>nul"); + cmd = xy_strcat (5, "copy /Y ", path, " ", path, ".bak 1>nul"); } else { @@ -1732,12 +1732,12 @@ chsrc_backup (const char *path) /* cp (GNU coreutils) 9.4 */ if (strstr (ver, "GNU coreutils")) { - cmd = xy_strjoin (5, "cp ", path, " ", path, ".bak --backup='t'"); + cmd = xy_strcat (5, "cp ", path, " ", path, ".bak --backup='t'"); } else { /* 非 GNU 的 cp 可能不支持 --backup ,如 busybox cp */ - cmd = xy_strjoin (5, "cp -f ", path, " ", path, ".bak"); + cmd = xy_strcat (5, "cp -f ", path, " ", path, ".bak"); } } diff --git a/src/recipe/lang/Dart/Flutter.c b/src/recipe/lang/Dart/Flutter.c index 0139575..cd9cafe 100644 --- a/src/recipe/lang/Dart/Flutter.c +++ b/src/recipe/lang/Dart/Flutter.c @@ -61,7 +61,7 @@ pl_dart_flutter_setsrc (char *option) char *cmd = NULL; if (xy_on_windows) { - cmd = xy_strjoin (3, "setx FLUTTER_STORAGE_BASE_URL \"", source.url, "\""); + cmd = xy_strcat (3, "setx FLUTTER_STORAGE_BASE_URL \"", source.url, "\""); chsrc_run (cmd, RunOpt_No_Last_New_Line); } else @@ -70,7 +70,7 @@ pl_dart_flutter_setsrc (char *option) char *bashrc = xy_bashrc; chsrc_backup (zshrc); - w = xy_strjoin (3, "export FLUTTER_STORAGE_BASE_URL=\"", source.url, "\"\n"); + w = xy_strcat (3, "export FLUTTER_STORAGE_BASE_URL=\"", source.url, "\"\n"); chsrc_append_to_file (w, zshrc); if (xy_file_exist (bashrc)) diff --git a/src/recipe/lang/Dart/Pub.c b/src/recipe/lang/Dart/Pub.c index e53eee2..d462325 100644 --- a/src/recipe/lang/Dart/Pub.c +++ b/src/recipe/lang/Dart/Pub.c @@ -57,7 +57,7 @@ pl_dart_setsrc (char *option) char *cmd = NULL; if (xy_on_windows) { - cmd = xy_strjoin (3, "setx PUB_HOSTED_URL \"", source.url, "\""); + cmd = xy_strcat (3, "setx PUB_HOSTED_URL \"", source.url, "\""); chsrc_run (cmd, RunOpt_No_Last_New_Line); } else @@ -66,7 +66,7 @@ pl_dart_setsrc (char *option) char *bashrc = xy_bashrc; chsrc_backup (zshrc); - w = xy_strjoin (3, "export PUB_HOSTED_URL=\"", source.url, "\"\n"); + w = xy_strcat (3, "export PUB_HOSTED_URL=\"", source.url, "\"\n"); chsrc_append_to_file (w, zshrc); diff --git a/src/recipe/lang/Go.c b/src/recipe/lang/Go.c index 7fb01e0..72f6cf3 100644 --- a/src/recipe/lang/Go.c +++ b/src/recipe/lang/Go.c @@ -89,7 +89,7 @@ pl_go_setsrc (char *option) char *cmd = "go env -w GO111MODULE=on"; chsrc_run (cmd, RunOpt_Default); - cmd = xy_strjoin (3, "go env -w GOPROXY=", source.url, ",direct"); + cmd = xy_strcat (3, "go env -w GOPROXY=", source.url, ",direct"); chsrc_run (cmd, RunOpt_Default); chsrc_conclude (&source); diff --git a/src/recipe/lang/Haskell.c b/src/recipe/lang/Haskell.c index 60d7983..ccd95cd 100644 --- a/src/recipe/lang/Haskell.c +++ b/src/recipe/lang/Haskell.c @@ -55,12 +55,12 @@ pl_haskell_setsrc (char *option) config = "~/.cabal/config"; } - chsrc_note2 (xy_strjoin (3, "请向 ", config, " 中手动添加:")); + chsrc_note2 (xy_strcat (3, "请向 ", config, " 中手动添加:")); println (content); config = xy_normalize_path ("~/.stack/config.yaml"); content = xy_str_gsub (RAWSTR_pl_haskell_stackage_yaml, "@url@", source.url); - chsrc_note2 (xy_strjoin (3, "请向 ", config, " 中手动添加:")); + chsrc_note2 (xy_strcat (3, "请向 ", config, " 中手动添加:")); println (content); chsrc_conclude (&source); diff --git a/src/recipe/lang/Java.c b/src/recipe/lang/Java.c index 4dd2d9c..c9b1161 100644 --- a/src/recipe/lang/Java.c +++ b/src/recipe/lang/Java.c @@ -56,7 +56,7 @@ pl_java_find_maven_config () char *maven_home = xy_str_delete_prefix (buf, "Maven home: "); maven_home = xy_str_strip (maven_home); - char *maven_config = xy_normalize_path (xy_2strjoin (maven_home, "/conf/settings.xml")); + char *maven_config = xy_normalize_path (xy_2strcat (maven_home, "/conf/settings.xml")); return maven_config; } @@ -67,7 +67,7 @@ pl_java_getsrc (char *option) bool maven_exist, gradle_exist; pl_java_check_cmd (&maven_exist, &gradle_exist); char *maven_config = pl_java_find_maven_config (); - chsrc_note2 (xy_2strjoin ("请查看 ", maven_config)); + chsrc_note2 (xy_2strcat ("请查看 ", maven_config)); } @@ -88,7 +88,7 @@ pl_java_setsrc (char *option) file = xy_str_gsub (file, "@name@", source.mirror->name); file = xy_str_gsub (file, "@url@", source.url); char *maven_config = pl_java_find_maven_config (); - chsrc_note2 (xy_strjoin (3, "请在 maven 配置文件 ", maven_config, " 中添加:")); + chsrc_note2 (xy_strcat (3, "请在 maven 配置文件 ", maven_config, " 中添加:")); println (file); } diff --git a/src/recipe/lang/JavaScript/Bun.c b/src/recipe/lang/JavaScript/Bun.c index 3f3780d..ae7108a 100644 --- a/src/recipe/lang/JavaScript/Bun.c +++ b/src/recipe/lang/JavaScript/Bun.c @@ -62,7 +62,7 @@ pl_js_bun_setsrc (char *option) } else { - chsrc_note2 (xy_strjoin (3, "请手动写入以下内容到 ", xy_normalize_path ("~/.bunfig.toml"), " 文件中")); + chsrc_note2 (xy_strcat (3, "请手动写入以下内容到 ", xy_normalize_path ("~/.bunfig.toml"), " 文件中")); } println (content); diff --git a/src/recipe/lang/JavaScript/Yarn.c b/src/recipe/lang/JavaScript/Yarn.c index d5662be..1d2ff97 100644 --- a/src/recipe/lang/JavaScript/Yarn.c +++ b/src/recipe/lang/JavaScript/Yarn.c @@ -68,9 +68,9 @@ pl_js_yarn_setsrc (char *option) if (pl_js_yarn_get_yarn_version () >= 2) { if (chsrc_in_local_mode()) // Yarn 默认情况下就是基于本项目换源 - cmd = xy_2strjoin ("yarn config set npmRegistryServer ", source.url); + cmd = xy_2strcat ("yarn config set npmRegistryServer ", source.url); else - cmd = xy_2strjoin ("yarn config set npmRegistryServer --home ", source.url); + cmd = xy_2strcat ("yarn config set npmRegistryServer --home ", source.url); chsrc_run (cmd, RunOpt_No_Last_New_Line); } @@ -84,7 +84,7 @@ pl_js_yarn_setsrc (char *option) return; } // 不再阻止换源命令输出到终端,即不再调用 xy_str_to_quietcmd() - cmd = xy_2strjoin ("yarn config set registry ", source.url); + cmd = xy_2strcat ("yarn config set registry ", source.url); chsrc_run (cmd, RunOpt_No_Last_New_Line); } diff --git a/src/recipe/lang/JavaScript/npm.c b/src/recipe/lang/JavaScript/npm.c index c723d6c..a4a4976 100644 --- a/src/recipe/lang/JavaScript/npm.c +++ b/src/recipe/lang/JavaScript/npm.c @@ -50,9 +50,9 @@ pl_js_npm_setsrc (char *option) char *cmd = NULL; if (chsrc_in_local_mode()) - cmd = xy_2strjoin ("npm config --location project set registry ", source.url); + cmd = xy_2strcat ("npm config --location project set registry ", source.url); else - cmd = xy_2strjoin ("npm config set registry ", source.url); + cmd = xy_2strcat ("npm config set registry ", source.url); chsrc_run (cmd, RunOpt_No_Last_New_Line); diff --git a/src/recipe/lang/JavaScript/nvm.c b/src/recipe/lang/JavaScript/nvm.c index 6a81141..02a0954 100644 --- a/src/recipe/lang/JavaScript/nvm.c +++ b/src/recipe/lang/JavaScript/nvm.c @@ -50,7 +50,7 @@ pl_js_nvm_setsrc (char *option) { Source_t source = chsrc_yield_source_and_confirm (&pl_js_nodejs_binary_target, option); - char *w = xy_strjoin (3, "export NVM_NODEJS_ORG_MIRROR=", source.url, "\n"); + char *w = xy_strcat (3, "export NVM_NODEJS_ORG_MIRROR=", source.url, "\n"); char *zshrc = xy_zshrc; char *bashrc = xy_bashrc; diff --git a/src/recipe/lang/JavaScript/pnpm.c b/src/recipe/lang/JavaScript/pnpm.c index 07e597c..895052e 100644 --- a/src/recipe/lang/JavaScript/pnpm.c +++ b/src/recipe/lang/JavaScript/pnpm.c @@ -50,9 +50,9 @@ pl_js_pnpm_setsrc (char *option) char *cmd = NULL; if (chsrc_in_local_mode()) - cmd = xy_2strjoin ("pnpm config --location project set registry ", source.url); + cmd = xy_2strcat ("pnpm config --location project set registry ", source.url); else - cmd = xy_2strjoin ("pnpm config -g set registry ", source.url); + cmd = xy_2strcat ("pnpm config -g set registry ", source.url); chsrc_run (cmd, RunOpt_No_Last_New_Line); diff --git a/src/recipe/lang/Julia.c b/src/recipe/lang/Julia.c index c4e191d..f709632 100644 --- a/src/recipe/lang/Julia.c +++ b/src/recipe/lang/Julia.c @@ -56,7 +56,7 @@ pl_julia_setsrc (char *option) { use_this_source(pl_julia); - char *w = xy_strjoin (3, "ENV[\"JULIA_PKG_SERVER\"] = \"", source.url, "\""); + char *w = xy_strcat (3, "ENV[\"JULIA_PKG_SERVER\"] = \"", source.url, "\""); chsrc_append_to_file (w, PL_Julia_Config); diff --git a/src/recipe/lang/Lua.c b/src/recipe/lang/Lua.c index fcdbd7b..ab18a33 100644 --- a/src/recipe/lang/Lua.c +++ b/src/recipe/lang/Lua.c @@ -53,14 +53,14 @@ pl_lua_setsrc (char *option) use_this(pl_lua); Source_t source = chsrc_yield_source_and_confirm (this, option); - char *config = xy_strjoin (3, "rocks_servers = {\n" + char *config = xy_strcat (3, "rocks_servers = {\n" " \"", source.url, "\"\n" "}"); chsrc_note2 ("请手动修改 ~/.luarocks/config.lua 文件 (用于下载):"); println (config); - char *upload_config = xy_strjoin (3, "key = \"\"\n" + char *upload_config = xy_strcat (3, "key = \"\"\n" "server = \"", source.url, "\""); chsrc_note2 ("请手动修改 ~/.luarocks/upload_config.lua 文件 (用于上传):"); diff --git a/src/recipe/lang/OCaml.c b/src/recipe/lang/OCaml.c index 0b419d7..b41edfa 100644 --- a/src/recipe/lang/OCaml.c +++ b/src/recipe/lang/OCaml.c @@ -55,14 +55,14 @@ pl_ocaml_setsrc (char *option) use_this_source(pl_ocaml); - char *cmd = xy_strjoin (3, "opam repo set-url default ", + char *cmd = xy_strcat (3, "opam repo set-url default ", source.url, " --all --set-default"); chsrc_run (cmd, RunOpt_Default); chsrc_alert2 ("如果是首次使用 opam ,请使用以下命令进行初始化"); - println (xy_2strjoin ("opam init default ", source.url)); + println (xy_2strcat ("opam init default ", source.url)); chsrc_conclude (&source); } diff --git a/src/recipe/lang/PHP.c b/src/recipe/lang/PHP.c index af33dd7..d69d05f 100644 --- a/src/recipe/lang/PHP.c +++ b/src/recipe/lang/PHP.c @@ -66,7 +66,7 @@ pl_php_setsrc (char *option) where = " "; } - char *cmd = xy_strjoin (4, "composer config", where, "repo.packagist composer ", source.url); + char *cmd = xy_strcat (4, "composer config", where, "repo.packagist composer ", source.url); chsrc_run (cmd, RunOpt_Default); chsrc_conclude (&source); diff --git a/src/recipe/lang/Perl.c b/src/recipe/lang/Perl.c index e0bc629..be2f19d 100644 --- a/src/recipe/lang/Perl.c +++ b/src/recipe/lang/Perl.c @@ -61,7 +61,7 @@ pl_perl_setsrc (char *option) { use_this_source(pl_perl); - char *cmd = xy_strjoin (3, + char *cmd = xy_strcat (3, "perl -MCPAN -e \"CPAN::HandleConfig->load(); CPAN::HandleConfig->edit('urllist', 'unshift', '", source.url, "'); CPAN::HandleConfig->commit()\""); chsrc_run (cmd, RunOpt_Default); diff --git a/src/recipe/lang/Python/PDM.c b/src/recipe/lang/Python/PDM.c index ed5084c..fb3d196 100644 --- a/src/recipe/lang/Python/PDM.c +++ b/src/recipe/lang/Python/PDM.c @@ -52,9 +52,9 @@ pl_python_pdm_setsrc (char *option) char *cmd = NULL; if (chsrc_in_local_mode()) - cmd = xy_2strjoin ("pdm config --local pypi.url ", source.url); + cmd = xy_2strcat ("pdm config --local pypi.url ", source.url); else - cmd = xy_2strjoin ("pdm config --global pypi.url ", source.url); + cmd = xy_2strcat ("pdm config --global pypi.url ", source.url); chsrc_run (cmd, RunOpt_No_Last_New_Line); diff --git a/src/recipe/lang/Python/Poetry.c b/src/recipe/lang/Python/Poetry.c index 8392059..10065cc 100644 --- a/src/recipe/lang/Python/Poetry.c +++ b/src/recipe/lang/Python/Poetry.c @@ -50,7 +50,7 @@ pl_python_poetry_setsrc (char *option) if (!chsrc_in_local_mode()) chsrc_alert2 ("Poetry 仅支持项目级换源"); - cmd = xy_2strjoin ("poetry source add my_mirror ", source.url); + cmd = xy_2strcat ("poetry source add my_mirror ", source.url); chsrc_run (cmd, RunOpt_No_Last_New_Line); if (chsrc_in_standalone_mode()) diff --git a/src/recipe/lang/Python/Rye.c b/src/recipe/lang/Python/Rye.c index 26b5050..3623ac7 100644 --- a/src/recipe/lang/Python/Rye.c +++ b/src/recipe/lang/Python/Rye.c @@ -45,7 +45,7 @@ void pl_python_rye_getsrc (char *option) { char *rye_config = pl_python_find_rye_config (); - chsrc_note2 (xy_strjoin (3, "请查看 ", rye_config, " 配置文件中的 [[sources]] 节内容")); + chsrc_note2 (xy_strcat (3, "请查看 ", rye_config, " 配置文件中的 [[sources]] 节内容")); } @@ -64,7 +64,7 @@ pl_python_rye_setsrc (char *option) content = xy_str_gsub (content, "@2@", source.url); char *rye_config = pl_python_find_rye_config (); - chsrc_note2 (xy_strjoin (3, "请在配置文件 ", rye_config, " 中添加:")); + chsrc_note2 (xy_strcat (3, "请在配置文件 ", rye_config, " 中添加:")); println (content); chsrc_determine_chgtype (ChgType_Manual); diff --git a/src/recipe/lang/Python/common.h b/src/recipe/lang/Python/common.h index 9045dd5..cdd68d8 100644 --- a/src/recipe/lang/Python/common.h +++ b/src/recipe/lang/Python/common.h @@ -14,7 +14,7 @@ static char * pl_python_speed_url_constructor (const char *url, const char *user_data) { char *str = xy_str_delete_suffix (url, "/simple"); - str = xy_2strjoin (str, "/packages/56/e4/55aaac2b15af4dad079e5af329a79d961e5206589d0e02b1e8da221472ed/tensorflow-2.18.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl"); + str = xy_2strcat (str, "/packages/56/e4/55aaac2b15af4dad079e5af329a79d961e5206589d0e02b1e8da221472ed/tensorflow-2.18.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl"); return str; } diff --git a/src/recipe/lang/Python/pip.c b/src/recipe/lang/Python/pip.c index 1a2dc41..08f3ca0 100644 --- a/src/recipe/lang/Python/pip.c +++ b/src/recipe/lang/Python/pip.c @@ -35,7 +35,7 @@ pl_python_pip_getsrc (char *option) char *py_prog_name = NULL; pl_python_get_py_program_name (&py_prog_name); - char *cmd = xy_2strjoin (py_prog_name, " -m pip config get global.index-url"); + char *cmd = xy_2strcat (py_prog_name, " -m pip config get global.index-url"); chsrc_run (cmd, RunOpt_Default); } @@ -65,7 +65,7 @@ pl_python_pip_setsrc (char *option) // 这里用的是 config --user,会写入用户目录(而不是项目目录) // https://github.com/RubyMetric/chsrc/issues/39 // 经测试,Windows上调用换源命令,会写入 C:\Users\RubyMetric\AppData\Roaming\pip\pip.ini - char *cmd = xy_2strjoin (py_prog_name, xy_2strjoin (" -m pip config --user set global.index-url ", source.url)); + char *cmd = xy_2strcat (py_prog_name, xy_2strcat (" -m pip config --user set global.index-url ", source.url)); chsrc_run (cmd, RunOpt_No_Last_New_Line); if (chsrc_in_standalone_mode()) diff --git a/src/recipe/lang/Python/uv.c b/src/recipe/lang/Python/uv.c index 89314c1..a8dff93 100644 --- a/src/recipe/lang/Python/uv.c +++ b/src/recipe/lang/Python/uv.c @@ -51,7 +51,7 @@ pl_python_find_uv_config (bool mkdir) { if (chsrc_in_local_mode()) { - return xy_2strjoin (PL_Python_uv_Local_ConfigPath, PL_Python_uv_ConfigFile); + return xy_2strcat (PL_Python_uv_Local_ConfigPath, PL_Python_uv_ConfigFile); } else { @@ -66,12 +66,12 @@ pl_python_find_uv_config (bool mkdir) return NULL; } - char *config_dir = xy_2strjoin(appdata, "\\uv\\"); + char *config_dir = xy_2strcat(appdata, "\\uv\\"); if (mkdir) { chsrc_ensure_dir (config_dir); } - return xy_2strjoin (config_dir, PL_Python_uv_ConfigFile); + return xy_2strcat (config_dir, PL_Python_uv_ConfigFile); } else { @@ -80,7 +80,7 @@ pl_python_find_uv_config (bool mkdir) { chsrc_ensure_dir (PL_Python_uv_User_ConfigPath); } - return xy_2strjoin (PL_Python_uv_User_ConfigPath, PL_Python_uv_ConfigFile); + return xy_2strcat (PL_Python_uv_User_ConfigPath, PL_Python_uv_ConfigFile); } } } diff --git a/src/recipe/lang/R.c b/src/recipe/lang/R.c index 0be2c4a..40ca1fe 100644 --- a/src/recipe/lang/R.c +++ b/src/recipe/lang/R.c @@ -67,12 +67,12 @@ pl_r_setsrc (char *option) use_this_source(pl_r); char *bioconductor_url = xy_str_delete_suffix (xy_str_delete_suffix (source.url, "cran/"), "CRAN/"); - bioconductor_url = xy_2strjoin(bioconductor_url, "bioconductor"); + bioconductor_url = xy_2strcat(bioconductor_url, "bioconductor"); - const char *w1 = xy_strjoin (3, "options(\"repos\" = c(CRAN=\"", source.url, "\"))\n" ); - const char *w2 = xy_strjoin (3, "options(BioC_mirror=\"", bioconductor_url, "\")\n" ); + const char *w1 = xy_strcat (3, "options(\"repos\" = c(CRAN=\"", source.url, "\"))\n" ); + const char *w2 = xy_strcat (3, "options(BioC_mirror=\"", bioconductor_url, "\")\n" ); - char *w = xy_2strjoin (w1, w2); + char *w = xy_2strcat (w1, w2); // 或者我们调用 r.exe --slave -e 上面的内容 diff --git a/src/recipe/lang/Ruby/Ruby.c b/src/recipe/lang/Ruby/Ruby.c index b24cef5..bc7e7d4 100644 --- a/src/recipe/lang/Ruby/Ruby.c +++ b/src/recipe/lang/Ruby/Ruby.c @@ -58,7 +58,7 @@ pl_ruby_remove_gem_source (const char *source) char *cmd = NULL; if (chef_is_url (source)) { - cmd = xy_2strjoin ("gem sources -r ", source); + cmd = xy_2strcat ("gem sources -r ", source); chsrc_run (cmd, RunOpt_Default); } } @@ -78,7 +78,7 @@ pl_ruby_setsrc (char *option) // step1 xy_run_iter ("gem sources -l", 0, pl_ruby_remove_gem_source); - cmd = xy_2strjoin ("gem source -a ", source.url); + cmd = xy_2strcat ("gem source -a ", source.url); chsrc_run (cmd, RunOpt_Default); // 我们在 step1 中,把源全部清空了,但是现在 RubyGems 的行为是: 当清空会自动给你把默认源给加回来 @@ -94,7 +94,7 @@ pl_ruby_setsrc (char *option) where = " --local "; } - cmd = xy_strjoin (4, "bundle config", where, "'mirror.https://rubygems.org' ", source.url); + cmd = xy_strcat (4, "bundle config", where, "'mirror.https://rubygems.org' ", source.url); chsrc_run (cmd, RunOpt_No_Last_New_Line); chsrc_determine_chgtype (ChgType_Auto); diff --git a/src/recipe/lang/Rust/Cargo.c b/src/recipe/lang/Rust/Cargo.c index 43a89cc..eaf743e 100644 --- a/src/recipe/lang/Rust/Cargo.c +++ b/src/recipe/lang/Rust/Cargo.c @@ -72,7 +72,7 @@ pl_rust_cargo_setsrc (char *option) content = xy_str_gsub (content, "@url@", source.url); - chsrc_note2 (xy_strjoin (3, "请手动写入以下内容到 ", xy_normalize_path ("~/.cargo/config.toml"), " 文件中:")); + chsrc_note2 (xy_strcat (3, "请手动写入以下内容到 ", xy_normalize_path ("~/.cargo/config.toml"), " 文件中:")); println (content); chsrc_determine_chgtype (ChgType_Auto); diff --git a/src/recipe/lang/Rust/rustup.c b/src/recipe/lang/Rust/rustup.c index 637c236..7f9fbe2 100644 --- a/src/recipe/lang/Rust/rustup.c +++ b/src/recipe/lang/Rust/rustup.c @@ -64,18 +64,18 @@ pl_rust_rustup_setsrc (char *option) #ifdef XY_On_Windows - char *cmd1 = xy_strjoin (3, "setx RUSTUP_DIST_SERVER \"", source.url, "\""); - char *cmd2 = xy_strjoin (3, "setx RUSTUP_UPDATE_ROOT \"", source.url, "/rustup\""); + char *cmd1 = xy_strcat (3, "setx RUSTUP_DIST_SERVER \"", source.url, "\""); + char *cmd2 = xy_strcat (3, "setx RUSTUP_UPDATE_ROOT \"", source.url, "/rustup\""); - char *cmd = xy_strjoin (3, cmd1, " & ", cmd2); + char *cmd = xy_strcat (3, cmd1, " & ", cmd2); chsrc_run (cmd, RunOpt_Dont_Notify_On_Success|RunOpt_No_Last_New_Line); #else - char *w1 = xy_strjoin (3, "export RUSTUP_DIST_SERVER=\"", source.url, "\"\n"); - char *w2 = xy_strjoin (3, "export RUSTUP_UPDATE_ROOT=\"", source.url, "/rustup\"\n"); + char *w1 = xy_strcat (3, "export RUSTUP_DIST_SERVER=\"", source.url, "\"\n"); + char *w2 = xy_strcat (3, "export RUSTUP_UPDATE_ROOT=\"", source.url, "/rustup\"\n"); - char *w = xy_2strjoin (w1, w2); + char *w = xy_2strcat (w1, w2); char *bashrc = xy_bashrc; if (xy_file_exist (bashrc)) @@ -94,10 +94,10 @@ pl_rust_rustup_setsrc (char *option) char *fishrc = xy_fishrc; if (xy_file_exist (fishrc)) { - char *w1 = xy_strjoin (3, "set -x RUSTUP_DIST_SERVER ", source.url, "\n"); - char *w2 = xy_strjoin (3, "set -x RUSTUP_UPDATE_ROOT ", source.url, "/rustup\n"); + char *w1 = xy_strcat (3, "set -x RUSTUP_DIST_SERVER ", source.url, "\n"); + char *w2 = xy_strcat (3, "set -x RUSTUP_UPDATE_ROOT ", source.url, "/rustup\n"); - char *w = xy_2strjoin (w1, w2); + char *w = xy_2strcat (w1, w2); chsrc_backup (fishrc); chsrc_append_to_file (w, fishrc); diff --git a/src/recipe/os/APT/Armbian.c b/src/recipe/os/APT/Armbian.c index 84220d1..b87595f 100644 --- a/src/recipe/os/APT/Armbian.c +++ b/src/recipe/os/APT/Armbian.c @@ -68,7 +68,7 @@ os_armbian_setsrc (char *option) chsrc_backup (OS_Armbian_SourceList); - char *cmd = xy_strjoin (3, "sed -E -i 's@https?[^ ]*armbian/?[^ ]*@", source.url, + char *cmd = xy_strcat (3, "sed -E -i 's@https?[^ ]*armbian/?[^ ]*@", source.url, "@g' " OS_Armbian_SourceList); chsrc_run (cmd, RunOpt_Default); diff --git a/src/recipe/os/APT/Debian.c b/src/recipe/os/APT/Debian.c index ecb935a..af0d76f 100644 --- a/src/recipe/os/APT/Debian.c +++ b/src/recipe/os/APT/Debian.c @@ -77,7 +77,7 @@ static bool os_debian_does_old_sourcelist_use_cdrom (void) { /* 我们只检查旧版sourcelist,因为 common.h 中的填充只支持旧版 */ - char *cmd = xy_2strjoin ("grep -q '^deb cdrom:' ", OS_Debian_old_SourceList); + char *cmd = xy_2strcat ("grep -q '^deb cdrom:' ", OS_Debian_old_SourceList); int ret = system (cmd); bool use_cdrom = ret == 0; @@ -92,11 +92,11 @@ os_debian_setsrc_for_deb822 (char *option) chsrc_backup (OS_Debian_SourceList_DEB822); - char *cmd = xy_strjoin (3, "sed -E -i 's@https?://.*/debian/?@", source.url, "@g' " OS_Debian_SourceList_DEB822); + char *cmd = xy_strcat (3, "sed -E -i 's@https?://.*/debian/?@", source.url, "@g' " OS_Debian_SourceList_DEB822); chsrc_run (cmd, RunOpt_Default); /* debian-security 源和其他源不一样 */ - cmd = xy_strjoin (3, "sed -E -i 's@https?://.*/debian-security/?@", source.url, "-security@g' " OS_Debian_SourceList_DEB822); + cmd = xy_strcat (3, "sed -E -i 's@https?://.*/debian-security/?@", source.url, "-security@g' " OS_Debian_SourceList_DEB822); chsrc_run (cmd, RunOpt_Default); chsrc_run ("apt update", RunOpt_No_Last_New_Line); @@ -160,7 +160,7 @@ os_debian_setsrc (char *option) chsrc_backup (OS_Debian_old_SourceList); } - char *cmd = xy_strjoin (3, "sed -E -i \'s@https?://.*/debian/?@", source.url, "@g\' " OS_Debian_old_SourceList); + char *cmd = xy_strcat (3, "sed -E -i \'s@https?://.*/debian/?@", source.url, "@g\' " OS_Debian_old_SourceList); chsrc_run (cmd, RunOpt_Default); chsrc_run ("apt update", RunOpt_No_Last_New_Line); diff --git a/src/recipe/os/APT/Kali-Linux.c b/src/recipe/os/APT/Kali-Linux.c index 2f2b6c0..341a7ba 100644 --- a/src/recipe/os/APT/Kali-Linux.c +++ b/src/recipe/os/APT/Kali-Linux.c @@ -55,7 +55,7 @@ os_kali_setsrc (char *option) chsrc_backup (OS_Apt_SourceList); - char *cmd = xy_strjoin (3, "sed -E -i \'s@https?://.*/kali/?@", + char *cmd = xy_strcat (3, "sed -E -i \'s@https?://.*/kali/?@", source.url, "@g\' " OS_Apt_SourceList); diff --git a/src/recipe/os/APT/Linux-Lite.c b/src/recipe/os/APT/Linux-Lite.c index b3c7578..4814c12 100644 --- a/src/recipe/os/APT/Linux-Lite.c +++ b/src/recipe/os/APT/Linux-Lite.c @@ -53,7 +53,7 @@ os_linuxlite_setsrc (char *option) chsrc_backup (OS_Apt_SourceList); - char *cmd = xy_strjoin (3, "sed -E -i 's@https?://.*/.*/?@", source.url, "@g' " OS_Apt_SourceList); + char *cmd = xy_strcat (3, "sed -E -i 's@https?://.*/.*/?@", source.url, "@g' " OS_Apt_SourceList); chsrc_run ("apt update", RunOpt_No_Last_New_Line); diff --git a/src/recipe/os/APT/Linux-Mint.c b/src/recipe/os/APT/Linux-Mint.c index 02dba06..d792935 100644 --- a/src/recipe/os/APT/Linux-Mint.c +++ b/src/recipe/os/APT/Linux-Mint.c @@ -69,7 +69,7 @@ os_linuxmint_setsrc (char *option) // 暂不实现自动替换基于debian或ubuntu的基础源 char *version_codename = xy_run ("sed -nr 's/^VERSION_CODENAME=([^\"]+)/\1/p' " ETC_OS_RELEASE, 0); // sed -i '// s|http[^ ]*||g' OS_LinuxMint_SourceList - char* cmd = xy_strjoin (5, "sed -i '/", + char* cmd = xy_strcat (5, "sed -i '/", version_codename, "/ s|http[^ ]*|", source.url, "|g' " OS_LinuxMint_SourceList); diff --git a/src/recipe/os/APT/ROS.c b/src/recipe/os/APT/ROS.c index 62302a5..3745ba6 100644 --- a/src/recipe/os/APT/ROS.c +++ b/src/recipe/os/APT/ROS.c @@ -64,7 +64,7 @@ os_ros_setsrc (char *option) chsrc_backup (OS_ROS_SourceList); char *cmd = NULL; - cmd = xy_strjoin(3, "sed -E -i \'s@https?://.*/ros/ubuntu/?@", source.url, "/ros/ubuntu@g\' " OS_ROS_SourceList); + cmd = xy_strcat(3, "sed -E -i \'s@https?://.*/ros/ubuntu/?@", source.url, "/ros/ubuntu@g\' " OS_ROS_SourceList); chsrc_run(cmd, RunOpt_Default); cmd = "apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654"; diff --git a/src/recipe/os/APT/Raspberry-Pi-OS.c b/src/recipe/os/APT/Raspberry-Pi-OS.c index 6406925..e7b111c 100644 --- a/src/recipe/os/APT/Raspberry-Pi-OS.c +++ b/src/recipe/os/APT/Raspberry-Pi-OS.c @@ -57,7 +57,7 @@ os_raspberrypi_setsrc (char *option) chsrc_backup (OS_RaspberryPi_SourceList); - char *cmd = xy_strjoin (3, "sed -E -i 's@https?://.*/.*/?@", source.url, + char *cmd = xy_strcat (3, "sed -E -i 's@https?://.*/.*/?@", source.url, "@g' " OS_RaspberryPi_SourceList); chsrc_run (cmd, RunOpt_Default); diff --git a/src/recipe/os/APT/Termux.c b/src/recipe/os/APT/Termux.c index 1ff60c5..0c46a6b 100644 --- a/src/recipe/os/APT/Termux.c +++ b/src/recipe/os/APT/Termux.c @@ -63,7 +63,7 @@ os_termux_setsrc (char *option) use_this_source(os_termux); - char *cmd = xy_strjoin (3, "sed -i 's@^\\(deb.*stable main\\)$@#\\1\\ndeb ", + char *cmd = xy_strcat (3, "sed -i 's@^\\(deb.*stable main\\)$@#\\1\\ndeb ", source.url, "apt/termux-main stable main@' " OS_Termux_SourceList); chsrc_run (cmd, RunOpt_Default); diff --git a/src/recipe/os/APT/Trisquel.c b/src/recipe/os/APT/Trisquel.c index 2b44952..9244764 100644 --- a/src/recipe/os/APT/Trisquel.c +++ b/src/recipe/os/APT/Trisquel.c @@ -57,7 +57,7 @@ os_trisquel_setsrc (char *option) chsrc_backup (OS_Apt_SourceList); - char *cmd = xy_strjoin (3, "sed -E -i 's@https?://.*/trisquel/?@", source.url, "@g' /etc/apt/sources.list"); + char *cmd = xy_strcat (3, "sed -E -i 's@https?://.*/trisquel/?@", source.url, "@g' /etc/apt/sources.list"); chsrc_run (cmd, RunOpt_Default); chsrc_run ("apt update", RunOpt_No_Last_New_Line); diff --git a/src/recipe/os/APT/Ubuntu.c b/src/recipe/os/APT/Ubuntu.c index 2d16f2b..fd748d3 100644 --- a/src/recipe/os/APT/Ubuntu.c +++ b/src/recipe/os/APT/Ubuntu.c @@ -88,11 +88,11 @@ os_ubuntu_setsrc_for_deb822 (char *option) char *cmd = NULL; if (strncmp (arch, "x86_64", 6)==0) { - cmd = xy_strjoin (3, "sed -E -i \'s@https?://.*/ubuntu/?@", source.url, "@g\' " OS_Ubuntu_SourceList_DEB822); + cmd = xy_strcat (3, "sed -E -i \'s@https?://.*/ubuntu/?@", source.url, "@g\' " OS_Ubuntu_SourceList_DEB822); } else { - cmd = xy_strjoin (3, "sed -E -i \'s@https?://.*/ubuntu-ports/?@", source.url, "-ports@g\' " OS_Ubuntu_SourceList_DEB822); + cmd = xy_strcat (3, "sed -E -i \'s@https?://.*/ubuntu-ports/?@", source.url, "-ports@g\' " OS_Ubuntu_SourceList_DEB822); } chsrc_run (cmd, RunOpt_Default); @@ -135,11 +135,11 @@ os_ubuntu_setsrc (char *option) char *cmd = NULL; if (0==strncmp (arch, "x86_64", 6)) { - cmd = xy_strjoin (3, "sed -E -i \'s@https?://.*/ubuntu/?@", source.url, "@g\' " OS_Ubuntu_old_SourceList); + cmd = xy_strcat (3, "sed -E -i \'s@https?://.*/ubuntu/?@", source.url, "@g\' " OS_Ubuntu_old_SourceList); } else { - cmd = xy_strjoin (3, "sed -E -i \'s@https?://.*/ubuntu-ports/?@", source.url, "-ports@g\' " OS_Ubuntu_old_SourceList); + cmd = xy_strcat (3, "sed -E -i \'s@https?://.*/ubuntu-ports/?@", source.url, "-ports@g\' " OS_Ubuntu_old_SourceList); } chsrc_run (cmd, RunOpt_Default); diff --git a/src/recipe/os/APT/deepin.c b/src/recipe/os/APT/deepin.c index 094c76a..0caba9f 100644 --- a/src/recipe/os/APT/deepin.c +++ b/src/recipe/os/APT/deepin.c @@ -60,7 +60,7 @@ os_deepin_setsrc (char *option) chsrc_backup (OS_Apt_SourceList); - char *cmd = xy_strjoin (3, "sed -E -i \'s@https?://.*/deepin/?@", + char *cmd = xy_strcat (3, "sed -E -i \'s@https?://.*/deepin/?@", source.url, "@g\' " OS_Apt_SourceList); diff --git a/src/recipe/os/APT/openKylin.c b/src/recipe/os/APT/openKylin.c index a6aaa50..462fecf 100644 --- a/src/recipe/os/APT/openKylin.c +++ b/src/recipe/os/APT/openKylin.c @@ -51,7 +51,7 @@ os_openkylin_setsrc (char *option) chsrc_backup (OS_Apt_SourceList); - char *cmd = xy_strjoin (3, "sed -E -i 's@https?://.*/openkylin/?@", source.url, "@g'" OS_Apt_SourceList); + char *cmd = xy_strcat (3, "sed -E -i 's@https?://.*/openkylin/?@", source.url, "@g'" OS_Apt_SourceList); chsrc_run (cmd, RunOpt_Default); chsrc_run ("apt update", RunOpt_No_Last_New_Line); diff --git a/src/recipe/os/Alpine-Linux.c b/src/recipe/os/Alpine-Linux.c index f9f7a29..faeb8a9 100644 --- a/src/recipe/os/Alpine-Linux.c +++ b/src/recipe/os/Alpine-Linux.c @@ -59,7 +59,7 @@ os_alpine_setsrc (char *option) use_this_source(os_alpine); - char* cmd = xy_strjoin (3, + char* cmd = xy_strcat (3, "sed -i 's#https\\?://dl-cdn.alpinelinux.org/alpine#", source.url, "#g' /etc/apk/repositories" ); chsrc_run (cmd, RunOpt_Default); diff --git a/src/recipe/os/BSD/FreeBSD.c b/src/recipe/os/BSD/FreeBSD.c index 669a77c..b4abd58 100644 --- a/src/recipe/os/BSD/FreeBSD.c +++ b/src/recipe/os/BSD/FreeBSD.c @@ -57,9 +57,9 @@ os_freebsd_setsrc (char *option) chsrc_log2 ("1. 添加 freebsd-pkg 源 (二进制安装包)"); chsrc_ensure_dir ("/usr/local/etc/pkg/repos"); - char *conf = xy_strjoin (3, "/usr/local/etc/pkg/repos/", source.mirror->code, ".conf"); + char *conf = xy_strcat (3, "/usr/local/etc/pkg/repos/", source.mirror->code, ".conf"); - char *pkg_content = xy_strjoin (4, + char *pkg_content = xy_strcat (4, source.mirror->code, ": { \n" " url: \"http://", source.url, "/freebsd-pkg/${ABI}/latest\",\n" "}\n" @@ -68,7 +68,7 @@ os_freebsd_setsrc (char *option) chsrc_overwrite_file (pkg_content, conf); chsrc_note2 ( - xy_strjoin (3, "若要使用季度分支,请在", conf ,"中将latest改为quarterly")); + xy_strcat (3, "若要使用季度分支,请在", conf ,"中将latest改为quarterly")); chsrc_alert2 ("若要使用HTTPS源,请先安装securtiy/ca_root_ns,并将'http'改成'https',最后使用'pkg update -f'刷新缓存即可\n"); br(); @@ -84,14 +84,14 @@ os_freebsd_setsrc (char *option) { source = this->sources[index-1]; // 使用NJU的前一个源,即USTC源 } - char *git_cmd = xy_strjoin (3, "git clone --depth 1 https://", source.url, "/freebsd-ports/ports.git /usr/ports"); + char *git_cmd = xy_strcat (3, "git clone --depth 1 https://", source.url, "/freebsd-ports/ports.git /usr/ports"); chsrc_run (git_cmd, RunOpt_Default); source = this->sources[index]; // 恢复至选中的源 chsrc_alert2 ("下次更新请使用 git -C /usr/ports pull 而非使用 gitup"); } else { - char *fetch = xy_strjoin (3, "fetch https://", source.url, "/freebsd-ports/ports.tar.gz"); // 70多MB + char *fetch = xy_strcat (3, "fetch https://", source.url, "/freebsd-ports/ports.tar.gz"); // 70多MB char *unzip = "tar -zxvf ports.tar.gz -C /usr/ports"; char *delete = "rm ports.tar.gz"; chsrc_run (fetch, RunOpt_Default); @@ -105,7 +105,7 @@ os_freebsd_setsrc (char *option) // https://help.mirrors.cernet.edu.cn/FreeBSD-ports/ chsrc_backup ("/etc/make.conf"); - char *ports = xy_strjoin (3, "MASTER_SITE_OVERRIDE?=http://", source.url, "/freebsd-ports/distfiles/${DIST_SUBDIR}/\n"); + char *ports = xy_strcat (3, "MASTER_SITE_OVERRIDE?=http://", source.url, "/freebsd-ports/distfiles/${DIST_SUBDIR}/\n"); chsrc_append_to_file (ports, "/etc/make.conf"); @@ -113,7 +113,7 @@ os_freebsd_setsrc (char *option) /* chsrc_backup ("/etc/portsnap.conf"); - char *portsnap =xy_strjoin(3,"s@(.*)SERVERNAME=[\\.|a-z|A-Z]*@\\1SERVERNAME=", source.url, + char *portsnap =xy_strcat(3,"s@(.*)SERVERNAME=[\\.|a-z|A-Z]*@\\1SERVERNAME=", source.url, "@g < /etc/portsnap.conf.bak"); chsrc_overwrite_file (portsnap, "/etc/portsnap.conf"); @@ -131,7 +131,7 @@ os_freebsd_setsrc (char *option) char *update_cp = "cp /etc/freebsd-update.conf /etc/freebsd-update.conf.bak"; chsrc_run (update_cp, RunOpt_Default); - char *update =xy_strjoin (3,"s@(.*)SERVERNAME [\\.|a-z|A-Z]*@\\1SERVERNAME ", + char *update =xy_strcat (3,"s@(.*)SERVERNAME [\\.|a-z|A-Z]*@\\1SERVERNAME ", source.url, "@g < /etc/freebsd-update.conf.bak"); diff --git a/src/recipe/os/BSD/NetBSD.c b/src/recipe/os/BSD/NetBSD.c index c318f2b..1660fae 100644 --- a/src/recipe/os/BSD/NetBSD.c +++ b/src/recipe/os/BSD/NetBSD.c @@ -68,7 +68,7 @@ os_netbsd_setsrc (char *option) char *vercmd = "cat /etc/os-release | grep \"VERSION=\" | grep -Po \"[8-9].[0-9]+\""; char *version = xy_run (vercmd, 0); - char *url = xy_strjoin (5, chef_ensure_trailing_slash (source.url), arch, "/", version, "/All"); + char *url = xy_strcat (5, chef_ensure_trailing_slash (source.url), arch, "/", version, "/All"); chsrc_overwrite_file (url, "/usr/pkg/etc/pkgin/repositories.conf"); chsrc_conclude (&source); diff --git a/src/recipe/os/Gentoo-Linux.c b/src/recipe/os/Gentoo-Linux.c index 7878c01..44685c9 100644 --- a/src/recipe/os/Gentoo-Linux.c +++ b/src/recipe/os/Gentoo-Linux.c @@ -49,12 +49,12 @@ os_gentoo_setsrc (char *option) chsrc_backup ("/etc/portage/repos.conf/gentoo.conf"); - char *cmd = xy_strjoin (3, "sed -i \"s#rsync://.*/gentoo-portage#rsync://", + char *cmd = xy_strcat (3, "sed -i \"s#rsync://.*/gentoo-portage#rsync://", source.url, "gentoo-portage#g"); chsrc_run (cmd, RunOpt_Default); - char *w = xy_strjoin (3, "GENTOO_MIRRORS=\"https://", source.url, "gentoo\"\n"); + char *w = xy_strcat (3, "GENTOO_MIRRORS=\"https://", source.url, "gentoo\"\n"); chsrc_append_to_file (w, "/etc/portage/make.conf"); diff --git a/src/recipe/os/OpenWrt.c b/src/recipe/os/OpenWrt.c index 6f02ba6..2f05ddc 100644 --- a/src/recipe/os/OpenWrt.c +++ b/src/recipe/os/OpenWrt.c @@ -65,7 +65,7 @@ os_openwrt_setsrc (char *option) chsrc_backup (OS_OpenWRT_SourceConfig); - char *cmd = xy_strjoin (3, "sed -E -i 's@https?://.*/releases@", source.url, "/releases@g' " OS_OpenWRT_SourceConfig); + char *cmd = xy_strcat (3, "sed -E -i 's@https?://.*/releases@", source.url, "/releases@g' " OS_OpenWRT_SourceConfig); chsrc_run (cmd, RunOpt_No_Last_New_Line); chsrc_run ("opkg update", RunOpt_No_Last_New_Line); diff --git a/src/recipe/os/Solus.c b/src/recipe/os/Solus.c index 55a3e86..482ddfb 100644 --- a/src/recipe/os/Solus.c +++ b/src/recipe/os/Solus.c @@ -45,7 +45,7 @@ os_solus_setsrc (char *option) use_this_source(os_solus); - char *cmd = xy_2strjoin ("eopkg add-repo Solus ", source.url); + char *cmd = xy_2strcat ("eopkg add-repo Solus ", source.url); chsrc_run (cmd, RunOpt_Default); chsrc_determine_chgtype (ChgType_Auto); diff --git a/src/recipe/os/Void-Linux.c b/src/recipe/os/Void-Linux.c index c984e46..efd8ca9 100644 --- a/src/recipe/os/Void-Linux.c +++ b/src/recipe/os/Void-Linux.c @@ -58,12 +58,12 @@ os_voidlinux_setsrc (char *option) char *cmd = "cp /usr/share/xbps.d/*-repository-*.conf /etc/xbps.d/"; chsrc_run (cmd, RunOpt_Default); - cmd = xy_strjoin (3, + cmd = xy_strcat (3, "sed -i 's|https://repo-default.voidlinux.org|", source.url, "|g' /etc/xbps.d/*-repository-*.conf" ); chsrc_run (cmd, RunOpt_Default); - cmd = xy_strjoin (3, + cmd = xy_strcat (3, "sed -i 's|https://alpha.de.repo.voidlinux.org|", source.url, "|g' /etc/xbps.d/*-repository-*.conf" ); diff --git a/src/recipe/os/YUM/AlmaLinux.c b/src/recipe/os/YUM/AlmaLinux.c index ecfb04c..c36a2a5 100644 --- a/src/recipe/os/YUM/AlmaLinux.c +++ b/src/recipe/os/YUM/AlmaLinux.c @@ -48,7 +48,7 @@ os_almalinux_setsrc (char *option) use_this_source(os_almalinux); - char *cmd = xy_strjoin (3, + char *cmd = xy_strcat (3, "sed -e 's|^mirrorlist=|#mirrorlist=|g' -e 's|^#\\s*baseurl=https://repo.almalinux.org/almalinux|baseurl=", source.url, "|g' -i.bak /etc/yum.repos.d/almalinux*.repo"); chsrc_run (cmd, RunOpt_Default); diff --git a/src/recipe/os/YUM/Anolis-OS.c b/src/recipe/os/YUM/Anolis-OS.c index 706a7af..8624ab1 100644 --- a/src/recipe/os/YUM/Anolis-OS.c +++ b/src/recipe/os/YUM/Anolis-OS.c @@ -43,7 +43,7 @@ os_anolis_setsrc (char *option) use_this_source(os_anolis); - char *cmd = xy_strjoin (3, "sed -i.bak -E 's|https?://(mirrors\\.openanolis\\.cn/anolis)|", source.url, "|g' /etc/yum.repos.d/*.repo"); + char *cmd = xy_strcat (3, "sed -i.bak -E 's|https?://(mirrors\\.openanolis\\.cn/anolis)|", source.url, "|g' /etc/yum.repos.d/*.repo"); chsrc_run (cmd, RunOpt_Default); chsrc_run ("dnf makecache", RunOpt_Default); diff --git a/src/recipe/os/YUM/Fedora-Linux.c b/src/recipe/os/YUM/Fedora-Linux.c index 66c12e5..ec3dc60 100644 --- a/src/recipe/os/YUM/Fedora-Linux.c +++ b/src/recipe/os/YUM/Fedora-Linux.c @@ -63,7 +63,7 @@ os_fedora_setsrc (char *option) chsrc_backup ("/etc/yum.repos.d/fedora-updates.repo"); // 取消对 baseurl 的注释 - char* cmd = xy_strjoin (5, "sed ", + char* cmd = xy_strcat (5, "sed ", "-i 's|^#baseurl=|baseurl=", "|g' ", "/etc/yum.repos.d/fedora.repo ", @@ -73,7 +73,7 @@ os_fedora_setsrc (char *option) // 替换 // (1) baseurl=<>/releases/... // (2) baseurl=<>/updates/... - cmd = xy_strjoin (7, "sed ", + cmd = xy_strcat (7, "sed ", "-i -E 's!^baseurl=.*?/(releases|updates)/!baseurl=", source.url, "/\\1/", diff --git a/src/recipe/os/YUM/Rocky-Linux.c b/src/recipe/os/YUM/Rocky-Linux.c index 146c449..50b3cda 100644 --- a/src/recipe/os/YUM/Rocky-Linux.c +++ b/src/recipe/os/YUM/Rocky-Linux.c @@ -58,7 +58,7 @@ os_rockylinux_setsrc (char *option) if (version < 9) { - cmd = xy_strjoin (3, + cmd = xy_strcat (3, "sed -e 's|^mirrorlist=|#mirrorlist=|g' " "-e 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=", source.url, "|g' " "-i.bak /etc/yum.repos.d/Rocky-*.repo" @@ -70,7 +70,7 @@ os_rockylinux_setsrc (char *option) } else { - cmd = xy_strjoin (3, + cmd = xy_strcat (3, "sed -e 's|^mirrorlist=|#mirrorlist=|g' " "-e 's|^#baseurl=http://dl.rockylinux.org/$contentdir|baseurl=", source.url, "|g' " "-i.bak /etc/yum.repos.d/rocky-extras.repo /etc/yum.repos.d/rocky.repo" diff --git a/src/recipe/os/YUM/openEuler.c b/src/recipe/os/YUM/openEuler.c index 98ddc6e..b53ba11 100644 --- a/src/recipe/os/YUM/openEuler.c +++ b/src/recipe/os/YUM/openEuler.c @@ -73,7 +73,7 @@ os_openeuler_setsrc (char *option) // 替换 baseurl=<>/openEuler-xx.xx/... // openEuler-xx.xx 为 openEuler 版本号 // sed -E 's!^baseurl=.*?/openEuler-([^/]+)!baseurl=$(source.url)/openEuler-\1/!g' OS_openEuler_SourceList - char* cmd = xy_strjoin (6, "sed ", + char* cmd = xy_strcat (6, "sed ", "-i -E 's!^baseurl=.*?/openEuler-([^/]+)!baseurl=", source.url, "openEuler-\\1", diff --git a/src/recipe/os/pacman/Arch-Linux.c b/src/recipe/os/pacman/Arch-Linux.c index a200b26..59d4838 100644 --- a/src/recipe/os/pacman/Arch-Linux.c +++ b/src/recipe/os/pacman/Arch-Linux.c @@ -81,12 +81,12 @@ os_arch_setsrc (char *option) if (strncmp(arch, "x86_64", 6)==0) { is_x86 = true; - to_write = xy_strjoin (3, "Server = ", source.url, "/$repo/os/$arch"); + to_write = xy_strcat (3, "Server = ", source.url, "/$repo/os/$arch"); } else { is_x86 = false; - to_write = xy_strjoin (3, "Server = ", source.url, "arm/$arch/$repo"); + to_write = xy_strcat (3, "Server = ", source.url, "arm/$arch/$repo"); } /* 配置文件中,越前面的优先级越高 */ @@ -181,13 +181,13 @@ os_archlinuxcn_setsrc (char *option) if (ret == 0) { - char *sed_cmd = xy_strjoin (4, "sed -i '/\\[archlinuxcn\\]/{n;s|^Server = .*|Server = ", + char *sed_cmd = xy_strcat (4, "sed -i '/\\[archlinuxcn\\]/{n;s|^Server = .*|Server = ", source.url, "$arch|;}' ", OS_Pacman_ArchLinuxCN_MirrorList); chsrc_run (sed_cmd, RunOpt_Default); } else { - char *archlinuxcn_config = xy_strjoin (3, "\n[archlinuxcn]\nServer = ", source.url, "$arch\n"); + char *archlinuxcn_config = xy_strcat (3, "\n[archlinuxcn]\nServer = ", source.url, "$arch\n"); chsrc_append_to_file (archlinuxcn_config, OS_Pacman_ArchLinuxCN_MirrorList); } diff --git a/src/recipe/os/pacman/MSYS2.c b/src/recipe/os/pacman/MSYS2.c index b5b3406..49456f2 100644 --- a/src/recipe/os/pacman/MSYS2.c +++ b/src/recipe/os/pacman/MSYS2.c @@ -52,12 +52,12 @@ os_msys2_setsrc (char *option) chsrc_backup ("/etc/pacman.d/mirrorlist.mingw64"); chsrc_backup ("/etc/pacman.d/mirrorlist.msys"); - char *prev = xy_strjoin (3, "请针对你的架构下载安装此目录下的文件:", + char *prev = xy_strcat (3, "请针对你的架构下载安装此目录下的文件:", source.url, "distrib/<架构>/"); chsrc_note2 (prev); - char *cmd = xy_strjoin (3, "sed -i \"s#https\?://mirror.msys2.org/#", + char *cmd = xy_strcat (3, "sed -i \"s#https\?://mirror.msys2.org/#", source.url, "#g\" /etc/pacman.d/mirrorlist* "); diff --git a/src/recipe/ware/Anaconda/Anaconda.c b/src/recipe/ware/Anaconda/Anaconda.c index 6ac92a5..f9740fb 100644 --- a/src/recipe/ware/Anaconda/Anaconda.c +++ b/src/recipe/ware/Anaconda/Anaconda.c @@ -61,7 +61,7 @@ wr_anaconda_setsrc (char *option) char *w = xy_str_gsub (RAWSTR_wr_anaconda_condarc, "@1@", source.url); /* Windows 也是在这里 */ - char *configfile = xy_2strjoin (xy_os_home, "/.condarc"); + char *configfile = xy_2strcat (xy_os_home, "/.condarc"); if (xy_on_windows) { @@ -78,7 +78,7 @@ wr_anaconda_setsrc (char *option) } } - chsrc_note2 (xy_strjoin (3, "请向 ", configfile, " 中手动添加:")); + chsrc_note2 (xy_strcat (3, "请向 ", configfile, " 中手动添加:")); println (w); chsrc_note2 ("然后运行 conda clean -i 清除索引缓存,保证用的是镜像站提供的索引"); diff --git a/src/recipe/ware/CocoaPods.c b/src/recipe/ware/CocoaPods.c index 1483dba..3a071da 100644 --- a/src/recipe/ware/CocoaPods.c +++ b/src/recipe/ware/CocoaPods.c @@ -45,12 +45,12 @@ wr_cocoapods_setsrc (char *option) chsrc_note2 ("请手动执行以下命令:"); p("cd ~/.cocoapods/repos"); p("pod repo remove master"); - char *git_cmd = xy_strjoin (3, "git clone ", source.url, " master"); + char *git_cmd = xy_strcat (3, "git clone ", source.url, " master"); p(git_cmd); br(); chsrc_note2 ("最后进入项目工程目录,在Podfile中第一行加入:"); - char *source_str = xy_strjoin (3, "source '", source.url, "'"); + char *source_str = xy_strcat (3, "source '", source.url, "'"); p(source_str); chsrc_determine_chgtype (ChgType_Manual); diff --git a/src/recipe/ware/Docker/Docker.c b/src/recipe/ware/Docker/Docker.c index 8c7d8c8..66b18ae 100644 --- a/src/recipe/ware/Docker/Docker.c +++ b/src/recipe/ware/Docker/Docker.c @@ -118,7 +118,7 @@ wr_docker_setsrc (char *option) /* 不存在 /etc/docker/daemon.json 时可以直接写入文件 */ chsrc_alert2 ("未找到Docker配置文件, 将自动创建"); chsrc_ensure_dir ("/etc/docker"); - chsrc_run ( xy_2strjoin ("touch ", WR_Docker_ConfigFile), RunOpt_Default); + chsrc_run ( xy_2strcat ("touch ", WR_Docker_ConfigFile), RunOpt_Default); chsrc_append_to_file (to_add, WR_Docker_ConfigFile); } diff --git a/src/recipe/ware/Flatpak.c b/src/recipe/ware/Flatpak.c index 7a010d4..9492653 100644 --- a/src/recipe/ware/Flatpak.c +++ b/src/recipe/ware/Flatpak.c @@ -69,7 +69,7 @@ wr_flatpak_setsrc (char *option) use_this_source(wr_flatpak); chsrc_alert2 ("若出现问题,可先调用以下命令:"); - char *note = xy_strjoin (3, + char *note = xy_strcat (3, "wget ", source.url, "/flathub.gpg\n" "flatpak remote-modify --gpg-import=flathub.gpg flathub" ); @@ -80,7 +80,7 @@ wr_flatpak_setsrc (char *option) "尝试运行 flatpak remote-modify flathub --url=https://flathub.org/repo"; say (repo_note); - char *cmd = xy_2strjoin ("flatpak remote-modify flathub --url=", source.url); + char *cmd = xy_2strcat ("flatpak remote-modify flathub --url=", source.url); chsrc_run (cmd, RunOpt_Default); chsrc_determine_chgtype (ChgType_Auto); diff --git a/src/recipe/ware/Guix.c b/src/recipe/ware/Guix.c index ec37298..f5f2f60 100644 --- a/src/recipe/ware/Guix.c +++ b/src/recipe/ware/Guix.c @@ -41,7 +41,7 @@ wr_guix_setsrc (char *option) { use_this_source(wr_guix); - char *file = xy_strjoin (3, "(list (channel\n" + char *file = xy_strcat (3, "(list (channel\n" " (inherit (car %default-channels))\n" " (url \"", source.url, "\")))"); diff --git a/src/recipe/ware/Nix.c b/src/recipe/ware/Nix.c index 1fa010f..83d1dad 100644 --- a/src/recipe/ware/Nix.c +++ b/src/recipe/ware/Nix.c @@ -54,19 +54,19 @@ wr_nix_setsrc (char *option) use_this_source(wr_nix); - char *cmd = xy_strjoin (3, "nix-channel --add ", source.url, "nixpkgs-unstable nixpkgs"); + char *cmd = xy_strcat (3, "nix-channel --add ", source.url, "nixpkgs-unstable nixpkgs"); chsrc_run (cmd, RunOpt_Default); - char *w = xy_strjoin (3, "substituters = ", source.url, "store https://cache.nixos.org/"); + char *w = xy_strcat (3, "substituters = ", source.url, "store https://cache.nixos.org/"); chsrc_append_to_file (w, "~/.config/nix/nix.conf"); chsrc_run ("nix-channel --update", RunOpt_Default); chsrc_note2 ("若你使用的是NixOS,请确认你的系统版本(如22.11),并手动运行:"); - cmd = xy_strjoin (3, "nix-channel --add ", source.url, "nixpkgs- nixpkgs"); + cmd = xy_strcat (3, "nix-channel --add ", source.url, "nixpkgs- nixpkgs"); p(cmd); - cmd = xy_strjoin (3, "nix.settings.substituters = [ \"", source.url, "store\" ];"); + cmd = xy_strcat (3, "nix.settings.substituters = [ \"", source.url, "store\" ];"); chsrc_note2 ("若你使用的是NixOS,请额外添加下述内容至 configuration.nix 中"); p(cmd); diff --git a/src/recipe/ware/TeX-Live.c b/src/recipe/ware/TeX-Live.c index 0bd25d4..800fe39 100644 --- a/src/recipe/ware/TeX-Live.c +++ b/src/recipe/ware/TeX-Live.c @@ -91,14 +91,14 @@ wr_tex_setsrc (char *option) if (tlmgr_exist) { - cmd = xy_2strjoin ("tlmgr option repository ", source.url); + cmd = xy_2strcat ("tlmgr option repository ", source.url); chsrc_run (cmd, RunOpt_Default); } if (mpm_exist) { - char *miktex_url = xy_2strjoin (xy_str_delete_suffix (source.url, "texlive/tlnet"), "win32/miktex/tm/packages/"); - cmd = xy_2strjoin ("mpm --set-repository=", miktex_url); + char *miktex_url = xy_2strcat (xy_str_delete_suffix (source.url, "texlive/tlnet"), "win32/miktex/tm/packages/"); + cmd = xy_2strcat ("mpm --set-repository=", miktex_url); chsrc_run (cmd, RunOpt_Default); } diff --git a/src/recipe/ware/WinGet.c b/src/recipe/ware/WinGet.c index c37328c..4867950 100644 --- a/src/recipe/ware/WinGet.c +++ b/src/recipe/ware/WinGet.c @@ -52,7 +52,7 @@ wr_winget_setsrc (char *option) chsrc_run ("winget source remove winget", RunOpt_Dont_Abort_On_Failure); // 2025.8.18 执行两次相同的命令后继续设置,无报错,换源成功。具体原因不明 chsrc_run ("winget source remove winget", RunOpt_Dont_Abort_On_Failure); - chsrc_run (xy_strjoin (3, "winget source add winget ", source.url, " --trust-level trusted"), RunOpt_Default); + chsrc_run (xy_strcat (3, "winget source add winget ", source.url, " --trust-level trusted"), RunOpt_Default); chsrc_determine_chgtype (ChgType_Auto); chsrc_conclude (&source); diff --git a/test/fw.c b/test/fw.c index efad9af..a391d93 100644 --- a/test/fw.c +++ b/test/fw.c @@ -62,7 +62,7 @@ main (int argc, char const *argv[]) chsrc_overwrite_file ("overwrite", bkup); chsrc_view_file (bkup); - chsrc_log (xy_2strjoin ("CPU arch = ", chsrc_get_cpuarch ())); + chsrc_log (xy_2strcat ("CPU arch = ", chsrc_get_cpuarch ())); print ("chsrc: CPU cores = "); println (chsrc_get_cpucore ());