refactored the main function
This commit is contained in:
17
bin/sed.c
17
bin/sed.c
@ -172,12 +172,6 @@ static hawk_mmgr_t debug_mmgr =
|
||||
|
||||
/* ------------------------------------------------------------------- */
|
||||
|
||||
static void print_version (const hawk_bch_t* argv0)
|
||||
{
|
||||
fprintf (stdout, "%s %s\n", hawk_get_base_name_bcstr(argv0), HAWK_PACKAGE_VERSION);
|
||||
fprintf (stdout, "Copyright 2006-2022 Chung, Hyung-Hwan\n");
|
||||
}
|
||||
|
||||
static void print_error (const hawk_bch_t* fmt, ...)
|
||||
{
|
||||
va_list va;
|
||||
@ -206,9 +200,8 @@ static void print_usage (FILE* out, const hawk_bch_t* argv0, const hawk_bch_t* r
|
||||
fprintf (out, " %s%s%s [options] -f script-file [file]\n", b1, b2, b3);
|
||||
fprintf (out, " %s%s%s [options] -e script [file]\n", b1, b2, b3);
|
||||
|
||||
fprintf (out, "options as follows:\n");
|
||||
fprintf (out, "Options as follows:\n");
|
||||
fprintf (out, " -h/--help show this message\n");
|
||||
fprintf (out, " --version show version\n");
|
||||
fprintf (out, " -n disable auto-print\n");
|
||||
fprintf (out, " -e script specify a script\n");
|
||||
fprintf (out, " -f file specify a script file\n");
|
||||
@ -296,7 +289,6 @@ static int handle_args (int argc, hawk_bch_t* argv[], const hawk_bch_t* real_arg
|
||||
{ ":outfile-encoding", '\0' },
|
||||
#endif
|
||||
|
||||
{ "version", '\0' },
|
||||
{ "help", 'h' },
|
||||
{ HAWK_NULL, '\0' }
|
||||
};
|
||||
@ -406,12 +398,7 @@ static int handle_args (int argc, hawk_bch_t* argv[], const hawk_bch_t* real_arg
|
||||
|
||||
case '\0':
|
||||
{
|
||||
if (hawk_comp_bcstr(opt.lngopt, "version", 0) == 0)
|
||||
{
|
||||
print_version (real_argv0? real_argv0: argv[0]);
|
||||
goto done;
|
||||
}
|
||||
else if (hawk_comp_bcstr(opt.lngopt, "script-encoding", 0) == 0)
|
||||
if (hawk_comp_bcstr(opt.lngopt, "script-encoding", 0) == 0)
|
||||
{
|
||||
g_script_cmgr = hawk_get_cmgr_by_bcstr(opt.arg);
|
||||
if (g_script_cmgr == HAWK_NULL)
|
||||
|
Reference in New Issue
Block a user