重命名为 xy_run_iter_lines()

This commit is contained in:
Aoran Zeng 2025-08-20 19:52:54 +08:00
parent f195709493
commit 7d230bcf57
No known key found for this signature in database
GPG Key ID: 8F8BA8488E10ED98
2 changed files with 11 additions and 11 deletions

View File

@ -761,20 +761,20 @@ _xy_log_brkt (int level, const char *prompt1, const char *prompt2, const char *c
******************************************************/ ******************************************************/
/** /**
* @brief cmditer_func * @brief `cmd` `func`
* *
* @param cmd * @param cmd
* @param n 0 n (n>0) n行 * @param n 0 n (n>0) n行
* @param iter_func * @param func
* *
* @return n * @return `n`
* *
* @note * @note
* *
* iter_func() * `func`
*/ */
static char * static char *
xy_run_iter (const char *cmd, unsigned long n, void (*iter_func) (const char *)) xy_run_iter_lines (const char *cmd, unsigned long n, void (*func) (const char *))
{ {
const int size = 512; const int size = 512;
char *buf = (char *) malloc (size); char *buf = (char *) malloc (size);
@ -798,9 +798,9 @@ xy_run_iter (const char *cmd, unsigned long n, void (*iter_func) (const char *
count += 1; count += 1;
if (n == count) if (n == count)
break; break;
if (iter_func) if (func)
{ {
iter_func (buf); func (buf);
} }
} }
@ -811,7 +811,7 @@ xy_run_iter (const char *cmd, unsigned long n, void (*iter_func) (const char *
static char * static char *
xy_run (const char *cmd, unsigned long n) xy_run (const char *cmd, unsigned long n)
{ {
return xy_run_iter (cmd, n, NULL); return xy_run_iter_lines (cmd, n, NULL);
} }

View File

@ -76,7 +76,7 @@ pl_ruby_setsrc (char *option)
char *cmd = NULL; char *cmd = NULL;
// step1 // step1
xy_run_iter ("gem sources -l", 0, pl_ruby_remove_gem_source); xy_run_iter_lines ("gem sources -l", 0, pl_ruby_remove_gem_source);
cmd = xy_2strcat ("gem source -a ", source.url); cmd = xy_2strcat ("gem source -a ", source.url);
chsrc_run (cmd, RunOpt_Default); chsrc_run (cmd, RunOpt_Default);