2828#include < stdio.h>
2929#include < cstdlib> // exit
3030#include < filesystem>
31+ #include < string_view>
3132#include < tcl.h>
3233#if TCL_READLINE
3334 #include < tclreadline.h>
@@ -58,14 +59,14 @@ static char **cmd_argv;
5859static const char *init_filename = " .sta" ;
5960
6061static void
61- showUsage (const char * prog,
62- const char * init_filename);
62+ showUsage (std::string_view prog,
63+ std::string_view init_filename);
6364static int
6465tclAppInit (Tcl_Interp *interp);
6566static int
6667staTclAppInit (int argc,
6768 char *argv[],
68- const char * init_filename,
69+ std::string_view init_filename,
6970 Tcl_Interp *interp);
7071static void
7172initStaApp (int &argc,
@@ -105,7 +106,7 @@ tclAppInit(Tcl_Interp *interp)
105106static int
106107staTclAppInit (int argc,
107108 char *argv[],
108- const char * init_filename,
109+ std::string_view init_filename,
109110 Tcl_Interp *interp)
110111{
111112 // source init.tcl
@@ -130,7 +131,7 @@ staTclAppInit(int argc,
130131 if (home) {
131132 std::string init_path = home;
132133 init_path += " /" ;
133- init_path += init_filename;
134+ init_path. append ( init_filename) ;
134135 if (std::filesystem::is_regular_file (init_path.c_str ()))
135136 sourceTclFile (init_path.c_str (), true , true , interp);
136137 }
@@ -183,15 +184,17 @@ initStaApp(int &argc,
183184}
184185
185186static void
186- showUsage (const char * prog,
187- const char * init_filename)
187+ showUsage (std::string_view prog,
188+ std::string_view init_filename)
188189{
189- printf (" Usage: %s [-help] [-version] [-no_init] [-exit] cmd_file\n " , prog);
190- printf (" -help show help and exit\n " );
191- printf (" -version show version and exit\n " );
192- printf (" -no_init do not read %s init file\n " , init_filename);
193- printf (" -threads count|max use count threads\n " );
194- printf (" -no_splash do not show the license splash at startup\n " );
195- printf (" -exit exit after reading cmd_file\n " );
196- printf (" cmd_file source cmd_file\n " );
190+ sta::print (stdout, " Usage: {} [-help] [-version] [-no_init] [-exit] cmd_file\n " ,
191+ prog);
192+ sta::print (stdout, " -help show help and exit\n " );
193+ sta::print (stdout, " -version show version and exit\n " );
194+ sta::print (stdout, " -no_init do not read {} init file\n " ,
195+ init_filename);
196+ sta::print (stdout, " -threads count|max use count threads\n " );
197+ sta::print (stdout, " -no_splash do not show the license splash at startup\n " );
198+ sta::print (stdout, " -exit exit after reading cmd_file\n " );
199+ sta::print (stdout, " cmd_file source cmd_file\n " );
197200}
0 commit comments