Skip to content

Commit 6ded338

Browse files
committed
Add print macro
1 parent 2746fe0 commit 6ded338

File tree

17 files changed

+38
-42
lines changed

17 files changed

+38
-42
lines changed

include/xy.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,11 @@ bool xy_enable_color = true;
7575
void putf (double n) { printf ("%f\n", n); }
7676
void puti (long long n) { printf ("%lld\n", n); }
7777
void putb (bool n) { if (n) puts ("true"); else puts ("false"); }
78-
void print (const char *s) { printf ("%s", s); }
79-
void println (const char *s) { printf ("%s\n", s);}
80-
void say (const char *s) { printf ("%s\n", s);}
81-
void br () { puts ("");}
78+
void print (const char *s) { printf ("%s", s); }
79+
void println (const char *s) { printf ("%s\n", s); }
80+
void say (const char *s) { printf ("%s\n", s); }
81+
void br () { puts (""); }
82+
void p (const char *s) { printf ("%s\n", s); }
8283

8384
#define assert_str(a, b) assert (xy_streql ((a), (b)))
8485

src/framework/core.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -819,11 +819,7 @@ source_has_empty_url (Source_t *source)
819819

820820

821821

822-
static inline void
823-
divide_source_changing_process ()
824-
{
825-
say ("--------------------------------");
826-
}
822+
#define hr() say ("--------------------------------");
827823

828824

829825
/**
@@ -861,7 +857,7 @@ confirm_source (Source_t *source)
861857
say (xy_strjoin (5, msg, green (source->mirror->abbr), " (", green (source->mirror->code), ")"));
862858
}
863859

864-
divide_source_changing_process();
860+
hr();
865861
}
866862

867863
#define chsrc_yield_source_and_confirm(for_what) chsrc_yield_source(for_what);chsrc_confirm_source
@@ -899,7 +895,7 @@ confirm_source (Source_t *source)
899895
void
900896
chsrc_conclude (Source_t *source)
901897
{
902-
divide_source_changing_process();
898+
hr();
903899

904900
// fprintf (stderr, "chsrc: now change type: %d\n", ProgMode_ChgType);
905901

src/recipe/lang/Clojure.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pl_clojure_setsrc (char *option)
2626
chsrc_yield_source_and_confirm (pl_clojure);
2727

2828
chsrc_note2 ("抱歉,Clojure换源较复杂,您可手动查阅并换源:");
29-
say (source.url);
29+
p(source.url);
3030
ProgMode_ChgType = ChgType_Manual;
3131
chsrc_conclude (&source);
3232
}

src/recipe/lang/Haskell.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pl_haskell_setsrc (char *option)
6161
" ignore-expiry: no");
6262

6363
chsrc_note2 (xy_strjoin (3, "请向 ", config, " 中手动添加:"));
64-
say (file);
64+
p(file);
6565
ProgMode_ChgType = ChgType_Manual;
6666
chsrc_conclude (&source);
6767
}

src/recipe/lang/Java.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ pl_java_setsrc (char *option)
9393
"}");
9494

9595
chsrc_note2 ("请在您的 build.gradle 中添加:");
96-
say (file);
96+
p(file);
9797
}
9898
ProgMode_ChgType = ChgType_Manual;
9999
chsrc_conclude (&source);

src/recipe/lang/Lua.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pl_lua_setsrc (char *option)
5252
"server = \"", source.url, "\"");
5353

5454
chsrc_note2 ("请手动修改 ~/.luarocks/upload_config.lua 文件 (用于上传):");
55-
say (upload_config);
55+
p(upload_config);
5656

5757
ProgMode_ChgType = ChgType_Manual;
5858
chsrc_conclude (&source);

src/recipe/lang/Node.js/Bun.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pl_nodejs_bun_setsrc (char *option)
4242
chsrc_note2 (xy_strjoin (3, "请您手动写入以下内容到 ", xy_normalize_path ("~/.bunfig.toml"), " 文件中"));
4343
}
4444

45-
say (file);
45+
p(file);
4646
ProgMode_ChgType = ProgMode_CMD_Reset ? ChgType_Reset : ChgType_Auto;
4747
chsrc_conclude (&source);
4848
}

src/recipe/lang/Node.js/Node.js.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,24 +35,24 @@ pl_nodejs_getsrc (char *option)
3535
bool npm_exist, yarn_exist, pnpm_exist;
3636
pl_nodejs_check_cmd (&npm_exist, &yarn_exist, &pnpm_exist);
3737

38-
divide_source_changing_process();
38+
hr();
3939

4040
if (npm_exist)
4141
{
4242
pl_nodejs_npm_getsrc (option);
43-
say ("");
43+
br();
4444
}
4545

4646
if (yarn_exist)
4747
{
4848
pl_nodejs_yarn_getsrc (option);
49-
say ("");
49+
br();
5050
}
5151

5252
if (pnpm_exist)
5353
{
5454
pl_nodejs_pnpm_getsrc (option);
55-
say ("");
55+
br();
5656
}
5757
}
5858

@@ -80,13 +80,13 @@ pl_nodejs_setsrc (char *option)
8080
if (npm_exist)
8181
{
8282
pl_nodejs_npm_setsrc (option);
83-
say ("");
83+
br();
8484
}
8585

8686
if (yarn_exist)
8787
{
8888
pl_nodejs_yarn_setsrc (option);
89-
say ("");
89+
br();
9090
}
9191

9292
if (pnpm_exist)

src/recipe/lang/OCaml.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pl_ocaml_setsrc(char *option)
4848
chsrc_run (cmd, RunOpt_Default);
4949

5050
chsrc_note2 ("如果是首次使用 opam ,请使用以下命令进行初始化");
51-
say (xy_2strjoin ("opam init default ", source.url));
51+
p(xy_2strjoin ("opam init default ", source.url));
5252

5353
ProgMode_ChgType = ChgType_SemiAuto;
5454
chsrc_conclude (&source);

src/recipe/lang/Perl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pl_perl_setsrc (char *option)
5454
chsrc_run (cmd, RunOpt_Default);
5555

5656
chsrc_note2 ("请您使用 perl -v 以及 cpan -v,若 Perl >= v5.36 或 CPAN >= 2.29,请额外手动调用下面的命令");
57-
say ("perl -MCPAN -e \"CPAN::HandleConfig->load(); CPAN::HandleConfig->edit('pushy_https', 0);; CPAN::HandleConfig->commit()\"");
57+
p("perl -MCPAN -e \"CPAN::HandleConfig->load(); CPAN::HandleConfig->edit('pushy_https', 0);; CPAN::HandleConfig->commit()\"");
5858

5959
ProgMode_ChgType = ChgType_SemiAuto;
6060
chsrc_conclude (&source);

0 commit comments

Comments
 (0)