全部使用 xy_strcat() 弃用 xy_strjoin()

This commit is contained in:
Aoran Zeng
2025-08-20 18:32:30 +08:00
parent aabec77833
commit 0d232fba92
65 changed files with 200 additions and 205 deletions

View File

@@ -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))

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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;

View File

@@ -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);

View File

@@ -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);

View File

@@ -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 = \"<Your API Key>\"\n"
char *upload_config = xy_strcat (3, "key = \"<Your API Key>\"\n"
"server = \"", source.url, "\"");
chsrc_note2 ("请手动修改 ~/.luarocks/upload_config.lua 文件 (用于上传):");

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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())

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -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())

View File

@@ -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);
}
}
}

View File

@@ -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 上面的内容

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);