changed pio for changes in mbwc conversion functions
This commit is contained in:
@ -420,11 +420,11 @@ static void print_usage (QSE_FILE* out, const qse_char_t* argv0)
|
||||
qse_fprintf (out, QSE_T(" %s [options] [ -- ] sourcestring [datafile]*\n"), b);
|
||||
qse_fprintf (out, QSE_T("Where options are:\n"));
|
||||
qse_fprintf (out, QSE_T(" -h/--help print this message\n"));
|
||||
qse_fprintf (out, QSE_T(" -d show extra information\n"));
|
||||
qse_fprintf (out, QSE_T(" -D show extra information\n"));
|
||||
qse_fprintf (out, QSE_T(" -c/--call name call a function instead of entering\n"));
|
||||
qse_fprintf (out, QSE_T(" the pattern-action loop\n"));
|
||||
qse_fprintf (out, QSE_T(" -f/--file sourcefile set the source script file\n"));
|
||||
qse_fprintf (out, QSE_T(" -o/--deparsed-file deparsedfile set the deparsing output file\n"));
|
||||
qse_fprintf (out, QSE_T(" -d/--deparsed-file deparsedfile set the deparsing output file\n"));
|
||||
qse_fprintf (out, QSE_T(" -F/--field-separator string set a field separator(FS)\n"));
|
||||
qse_fprintf (out, QSE_T(" -v/--assign var=value add a global variable with a value\n"));
|
||||
qse_fprintf (out, QSE_T(" -m/--memory-limit number limit the memory usage (bytes)\n"));
|
||||
@ -462,8 +462,8 @@ static int comparg (int argc, qse_char_t* argv[], struct arg_t* arg)
|
||||
|
||||
{ QSE_T(":call"), QSE_T('c') },
|
||||
{ QSE_T(":file"), QSE_T('f') },
|
||||
{ QSE_T(":deparsed-file"), QSE_T('d') },
|
||||
{ QSE_T(":field-separator"), QSE_T('F') },
|
||||
{ QSE_T(":deparsed-file"), QSE_T('o') },
|
||||
{ QSE_T(":assign"), QSE_T('v') },
|
||||
{ QSE_T(":memory-limit"), QSE_T('m') },
|
||||
|
||||
@ -474,9 +474,9 @@ static int comparg (int argc, qse_char_t* argv[], struct arg_t* arg)
|
||||
static qse_opt_t opt =
|
||||
{
|
||||
#if defined(QSE_BUILD_DEBUG)
|
||||
QSE_T("dc:f:F:o:v:m:X:h"),
|
||||
QSE_T("Dc:f:d:F:v:m:X:h"),
|
||||
#else
|
||||
QSE_T("dc:f:F:o:v:m:h"),
|
||||
QSE_T("Dc:f:d:F:v:m:h"),
|
||||
#endif
|
||||
lng
|
||||
};
|
||||
@ -529,7 +529,7 @@ static int comparg (int argc, qse_char_t* argv[], struct arg_t* arg)
|
||||
if (gvm != QSE_NULL) qse_htb_close (gvm);
|
||||
return 0;
|
||||
|
||||
case QSE_T('d'):
|
||||
case QSE_T('D'):
|
||||
{
|
||||
app_debug = 1;
|
||||
break;
|
||||
@ -561,15 +561,15 @@ static int comparg (int argc, qse_char_t* argv[], struct arg_t* arg)
|
||||
break;
|
||||
}
|
||||
|
||||
case QSE_T('F'):
|
||||
case QSE_T('d'):
|
||||
{
|
||||
fs = opt.arg;
|
||||
osf = opt.arg;
|
||||
break;
|
||||
}
|
||||
|
||||
case QSE_T('o'):
|
||||
case QSE_T('F'):
|
||||
{
|
||||
osf = opt.arg;
|
||||
fs = opt.arg;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -36,125 +36,6 @@ static const qse_char_t* g_infile = QSE_NULL;
|
||||
static const qse_char_t* g_outfile = QSE_NULL;
|
||||
static int g_option = 0;
|
||||
|
||||
static qse_ssize_t in (
|
||||
qse_cut_t* cut, qse_cut_io_cmd_t cmd,
|
||||
qse_cut_io_arg_t* arg, qse_char_t* buf, qse_size_t size)
|
||||
{
|
||||
switch (cmd)
|
||||
{
|
||||
case QSE_CUT_IO_OPEN:
|
||||
{
|
||||
if (g_infile == QSE_NULL ||
|
||||
(g_infile[0] == QSE_T('-') &&
|
||||
g_infile[1] == QSE_T('\0')))
|
||||
{
|
||||
arg->handle = qse_sio_in;
|
||||
}
|
||||
else
|
||||
{
|
||||
arg->handle = qse_sio_open (
|
||||
qse_cut_getmmgr(cut),
|
||||
0,
|
||||
g_infile,
|
||||
QSE_SIO_READ
|
||||
);
|
||||
|
||||
if (arg->handle == QSE_NULL)
|
||||
{
|
||||
qse_cstr_t ea;
|
||||
ea.ptr = g_infile;
|
||||
ea.len = qse_strlen (g_infile);
|
||||
qse_cut_seterrnum (cut, QSE_CUT_EIOFIL, &ea);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
case QSE_CUT_IO_CLOSE:
|
||||
if (arg->handle != qse_sio_in) qse_sio_close (arg->handle);
|
||||
return 0;
|
||||
|
||||
case QSE_CUT_IO_READ:
|
||||
{
|
||||
qse_ssize_t n = qse_sio_getstrn (arg->handle, buf, size);
|
||||
if (n <= -1)
|
||||
{
|
||||
qse_cstr_t ea;
|
||||
ea.ptr = g_infile;
|
||||
ea.len = qse_strlen (g_infile);
|
||||
qse_cut_seterrnum (cut, QSE_CUT_EIOFIL, &ea);
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static qse_ssize_t out (
|
||||
qse_cut_t* cut, qse_cut_io_cmd_t cmd,
|
||||
qse_cut_io_arg_t* arg, qse_char_t* data, qse_size_t len)
|
||||
{
|
||||
switch (cmd)
|
||||
{
|
||||
case QSE_CUT_IO_OPEN:
|
||||
if (g_outfile == QSE_NULL ||
|
||||
(g_outfile[0] == QSE_T('-') &&
|
||||
g_outfile[1] == QSE_T('\0')))
|
||||
{
|
||||
arg->handle = qse_sio_out;
|
||||
}
|
||||
else
|
||||
{
|
||||
arg->handle = qse_sio_open (
|
||||
qse_cut_getmmgr(cut),
|
||||
0,
|
||||
g_outfile,
|
||||
QSE_SIO_WRITE |
|
||||
QSE_SIO_CREATE |
|
||||
QSE_SIO_TRUNCATE
|
||||
);
|
||||
|
||||
if (arg->handle == QSE_NULL)
|
||||
{
|
||||
/* set the error message explicitly
|
||||
* as the file name is different from
|
||||
* the standard console name (NULL) */
|
||||
qse_cstr_t ea;
|
||||
ea.ptr = g_outfile;
|
||||
ea.len = qse_strlen (g_outfile);
|
||||
qse_cut_seterrnum (cut, QSE_CUT_EIOFIL, &ea);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
|
||||
case QSE_CUT_IO_CLOSE:
|
||||
if (arg->handle != qse_sio_out) qse_sio_close (arg->handle);
|
||||
return 0;
|
||||
|
||||
case QSE_CUT_IO_WRITE:
|
||||
{
|
||||
qse_ssize_t n = qse_sio_putstrn (arg->handle, data, len);
|
||||
if (n <= -1)
|
||||
{
|
||||
qse_cstr_t ea;
|
||||
ea.ptr = g_outfile;
|
||||
ea.len = qse_strlen (g_outfile);
|
||||
qse_cut_seterrnum (cut, QSE_CUT_EIOFIL, &ea);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static void print_usage (QSE_FILE* out, int argc, qse_char_t* argv[])
|
||||
{
|
||||
const qse_char_t* b = qse_basename (argv[0]);
|
||||
@ -363,7 +244,7 @@ int cut_main (int argc, qse_char_t* argv[])
|
||||
|
||||
ret = -1;
|
||||
|
||||
cut = qse_cut_open (QSE_NULL, 0);
|
||||
cut = qse_cut_openstd (0);
|
||||
if (cut == QSE_NULL)
|
||||
{
|
||||
qse_fprintf (QSE_STDERR, QSE_T("cannot open cut\n"));
|
||||
@ -372,7 +253,7 @@ int cut_main (int argc, qse_char_t* argv[])
|
||||
|
||||
qse_cut_setoption (cut, g_option);
|
||||
|
||||
if (qse_cut_comp (cut, g_selector, qse_strlen(g_selector)) == -1)
|
||||
if (qse_cut_compstd (cut, g_selector) <= -1)
|
||||
{
|
||||
qse_fprintf (QSE_STDERR,
|
||||
QSE_T("cannot compile - %s\n"),
|
||||
@ -386,7 +267,8 @@ int cut_main (int argc, qse_char_t* argv[])
|
||||
do
|
||||
{
|
||||
g_infile = argv[g_infile_start];
|
||||
if (qse_cut_exec (cut, in, out) == -1)
|
||||
if (g_infile && g_infile[0] == QSE_T('-') && g_infile[1] == QSE_T('\0')) g_infile = QSE_NULL;
|
||||
if (qse_cut_execstd (cut, g_infile, g_outfile) <= -1)
|
||||
{
|
||||
qse_fprintf (QSE_STDERR,
|
||||
QSE_T("cannot execute - %s\n"),
|
||||
@ -401,7 +283,7 @@ int cut_main (int argc, qse_char_t* argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
if (qse_cut_exec (cut, in, out) == -1)
|
||||
if (qse_cut_execstd (cut, QSE_NULL, g_outfile) <= -1)
|
||||
{
|
||||
qse_fprintf (QSE_STDERR,
|
||||
QSE_T("cannot execute - %s\n"),
|
||||
|
Reference in New Issue
Block a user