restored self wildcard expansion in sed and cut
This commit is contained in:
27
bin/sed.c
27
bin/sed.c
@ -30,6 +30,7 @@
|
||||
#include <hawk-fmt.h>
|
||||
#include <hawk-utl.h>
|
||||
#include <hawk-std.h>
|
||||
#include <hawk-glob.h>
|
||||
#include <hawk-xma.h>
|
||||
|
||||
#if !defined(_GNU_SOURCE)
|
||||
@ -641,7 +642,7 @@ static void purge_xarg (xarg_t* xarg)
|
||||
}
|
||||
}
|
||||
|
||||
static int expand_wildcards (int argc, hawk_bch_t* argv[], int glob, xarg_t* xarg)
|
||||
static int expand_wildcard (int argc, hawk_bch_t* argv[], int do_glob, xarg_t* xarg)
|
||||
{
|
||||
int i;
|
||||
hawk_bcs_t tmp;
|
||||
@ -650,23 +651,22 @@ static int expand_wildcards (int argc, hawk_bch_t* argv[], int glob, xarg_t* xar
|
||||
{
|
||||
int x;
|
||||
|
||||
#if 0
|
||||
if (glob)
|
||||
if (do_glob)
|
||||
{
|
||||
int glob_flags;
|
||||
hawk_gem_t fake_gem; /* guly to use this fake gem here */
|
||||
|
||||
glob_flags = HAWK_GLOB_TOLERANT | HAWK_GLOB_PERIOD;
|
||||
#if defined(_WIN32) || defined(__OS2__) || defined(__DOS__)
|
||||
int glob_flags = HAWK_GLOB_TOLERANT | HAWK_GLOB_PERIOD | HAWK_GLOB_NOESCAPE | HAWK_GLOB_IGNORECASE;
|
||||
#else
|
||||
int glob_flags = HAWK_GLOB_TOLERANT | HAWK_GLOB_PERIOD;
|
||||
glob_flags |= HAWK_GLOB_NOESCAPE | HAWK_GLOB_IGNORECASE;
|
||||
#endif
|
||||
|
||||
x = hawk_glob(argv[i], collect_into_xarg, xarg, glob_flags, xarg->mmgr, hawk_getdflcmgr());
|
||||
|
||||
fake_gem.mmgr = hawk_get_sys_mmgr();
|
||||
fake_gem.cmgr = hawk_get_cmgr_by_id(HAWK_CMGR_UTF8); /* TODO: system default? */
|
||||
x = hawk_gem_bglob(&fake_gem, argv[i], collect_into_xarg, xarg, glob_flags);
|
||||
if (x <= -1) return -1;
|
||||
}
|
||||
else x = 0;
|
||||
#else
|
||||
x = 0;
|
||||
#endif
|
||||
|
||||
if (x == 0)
|
||||
{
|
||||
@ -677,6 +677,7 @@ static int expand_wildcards (int argc, hawk_bch_t* argv[], int glob, xarg_t* xar
|
||||
}
|
||||
}
|
||||
|
||||
xarg->ptr[xarg->size] = HAWK_NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -796,7 +797,7 @@ int main_sed(int argc, hawk_bch_t* argv[], const hawk_bch_t* real_argv0)
|
||||
}
|
||||
|
||||
/* perform wild-card expansions for non-unix platforms */
|
||||
if (expand_wildcards(argc - arg.infile_pos, &argv[arg.infile_pos], arg.wildcard, &xarg) <= -1)
|
||||
if (expand_wildcard(argc - arg.infile_pos, &argv[arg.infile_pos], arg.wildcard, &xarg) <= -1)
|
||||
{
|
||||
hawk_main_print_error("out of memory\n");
|
||||
goto oops;
|
||||
@ -917,7 +918,7 @@ int main_sed(int argc, hawk_bch_t* argv[], const hawk_bch_t* real_argv0)
|
||||
/* input files are specified on the command line */
|
||||
|
||||
/* perform wild-card expansions for non-unix platforms */
|
||||
if (expand_wildcards(argc - arg.infile_pos, &argv[arg.infile_pos], arg.wildcard, &xarg) <= -1)
|
||||
if (expand_wildcard(argc - arg.infile_pos, &argv[arg.infile_pos], arg.wildcard, &xarg) <= -1)
|
||||
{
|
||||
hawk_main_print_error("out of memory\n");
|
||||
goto oops;
|
||||
|
Reference in New Issue
Block a user