touched up code related to QSE_SIO_IGNOREMBWCERR.

set QSE_SIO_IGNOREMBWCERR to qse_sio_in, qse_sio_out, qse_sio_err by default
This commit is contained in:
hyung-hwan 2011-09-12 06:44:56 +00:00
parent e2affec43b
commit e2a65338c8
6 changed files with 27 additions and 71 deletions

View File

@ -67,7 +67,7 @@ static qse_ssize_t in (
qse_sed_getmmgr(sed),
0,
file,
QSE_SIO_READ
QSE_SIO_READ | QSE_SIO_IGNOREMBWCERR
);
if (arg->handle == QSE_NULL) return -1;
@ -107,7 +107,8 @@ static qse_ssize_t out (
arg->path,
QSE_SIO_WRITE |
QSE_SIO_CREATE |
QSE_SIO_TRUNCATE
QSE_SIO_TRUNCATE |
QSE_SIO_IGNOREMBWCERR
);
if (arg->handle == QSE_NULL) return -1;
@ -247,7 +248,11 @@ qse_char_t* load_script_file (qse_sed_t* sed, const qse_char_t* file)
fp = qse_sio_open (
qse_sed_getmmgr(sed), 0, file,
QSE_SIO_READ | QSE_SIO_IGNOREMBWCERR);
if (fp == QSE_NULL) return QSE_NULL;
if (fp == QSE_NULL)
{
qse_fprintf (QSE_STDERR, QSE_T("ERROR: cannot open %s\n"), file);
return QSE_NULL;
}
if (qse_str_init (&script, QSE_MMGR_GETDFL(), 1024) <= -1)
{

View File

@ -1,5 +1,5 @@
/*
* $Id: sio.c 565 2011-09-11 02:48:21Z hyunghwan.chung $
* $Id: sio.c 566 2011-09-11 12:44:56Z hyunghwan.chung $
*
Copyright 2006-2011 Chung, Hyung-Hwan.
This file is part of QSE.
@ -56,7 +56,7 @@ static qse_sio_t __sio_in =
{
QSE_NULL,
0,
0,
QSE_TIO_IGNOREMBWCERR,
__sio_input,
__sio_output,
@ -98,7 +98,7 @@ static qse_sio_t __sio_out =
{
QSE_NULL,
0,
0,
QSE_TIO_IGNOREMBWCERR,
__sio_input,
__sio_output,
@ -140,7 +140,7 @@ static qse_sio_t __sio_err =
{
QSE_NULL,
0,
0,
QSE_TIO_IGNOREMBWCERR,
__sio_input,
__sio_output,

View File

@ -1,5 +1,5 @@
/*
* $Id: tio-get.c 565 2011-09-11 02:48:21Z hyunghwan.chung $
* $Id: tio-get.c 566 2011-09-11 12:44:56Z hyunghwan.chung $
*
Copyright 2006-2011 Chung, Hyung-Hwan.
This file is part of QSE.
@ -55,7 +55,8 @@ static qse_ssize_t tio_getc (qse_tio_t* tio, qse_char_t* c)
&tio->inbuf[left], QSE_COUNTOF(tio->inbuf)-left);
if (n == 0)
{
if (tio->inbuf_curp < tio->inbuf_len)
if (tio->inbuf_curp < tio->inbuf_len &&
!(tio->flags & QSE_TIO_IGNOREMBWCERR))
{
/* gargage left in the buffer */
tio->errnum = QSE_TIO_EICSEQ;
@ -86,7 +87,9 @@ static qse_ssize_t tio_getc (qse_tio_t* tio, qse_char_t* c)
/* illegal sequence */
if (tio->flags & QSE_TIO_IGNOREMBWCERR)
{
*c = tio->inbuf[tio->inbuf_curp++];
/* *c = tio->inbuf[tio->inbuf_curp++]; */
*c = QSE_WT('?');
tio->inbuf_curp++;
return 1;
}

View File

@ -1,5 +1,5 @@
/*
* $Id: tio-put.c 565 2011-09-11 02:48:21Z hyunghwan.chung $
* $Id: tio-put.c 566 2011-09-11 12:44:56Z hyunghwan.chung $
*
Copyright 2006-2011 Chung, Hyung-Hwan.
This file is part of QSE.
@ -62,6 +62,7 @@ static qse_ssize_t tio_putc (qse_tio_t* tio, qse_char_t c, int* flush_needed)
}
else if (n > QSE_COUNTOF(mc))
{
if (tio->flags & QSE_TIO_IGNOREMBWCERR) return 1;
tio->errnum = QSE_TIO_ENOSPC;
return -1;
}

View File

@ -1,5 +1,5 @@
/*
* $Id: sed.c 564 2011-09-10 16:14:38Z hyunghwan.chung $
* $Id: sed.c 566 2011-09-11 12:44:56Z hyunghwan.chung $
*
Copyright 2006-2011 Chung, Hyung-Hwan.
This file is part of QSE.
@ -145,7 +145,6 @@ int qse_sed_getoption (qse_sed_t* sed)
return sed->option;
}
#ifdef USE_REX
qse_size_t qse_sed_getmaxdepth (qse_sed_t* sed, qse_sed_depth_t id)
{
@ -1015,60 +1014,6 @@ static int get_subst (qse_sed_t* sed, qse_sed_cmd_t* cmd)
if (pickup_rex (sed, delim, 1, cmd, t[0]) <= -1) goto oops;
if (pickup_rex (sed, delim, 0, cmd, t[1]) <= -1) goto oops;
#if 0
/* calling pickup_rex twice above instead of commenting out this part */
for (i = 0; i < 2; i++)
{
c = NXTSC (sed);
while (c != delim)
{
CHECK_CMDIC (sed, cmd, c, goto oops);
if (c == QSE_T('\\'))
{
qse_cint_t nc;
nc = NXTSC (sed);
CHECK_CMDIC_ESCAPED (sed, cmd, nc, goto oops);
if (nc == QSE_T('\n')) c = nc;
else
{
qse_cint_t ec;
/* Escaping a known speical character for the regular expression
* part is done here. However, Escaping a special character for
* the replacement part is done in do_subst() except '\n' because
* it has more special characters like '&'. */
ec = trans_escaped (nc);
if (ec == nc)
{
/* if the character after a backslash is not special at the
* this layer, add the backslash into the regular expression
* buffer as it is. */
if (qse_str_ccat (t[i], QSE_T('\\')) == (qse_size_t)-1)
{
SETERR0 (sed, QSE_SED_ENOMEM, QSE_NULL);
goto oops;
}
}
c = ec;
}
}
if (qse_str_ccat (t[i], c) == (qse_size_t)-1)
{
SETERR0 (sed, QSE_SED_ENOMEM, QSE_NULL);
goto oops;
}
c = NXTSC (sed);
}
}
#endif
/* skip spaces before options */
do { c = NXTSC(sed); } while (IS_SPACE(c));

View File

@ -84,7 +84,7 @@ static qse_ssize_t xin (
sed->mmgr,
0,
xtn->infile,
QSE_SIO_READ
QSE_SIO_READ | QSE_SIO_IGNOREMBWCERR
);
if (sio == QSE_NULL)
{
@ -105,7 +105,7 @@ static qse_ssize_t xin (
sed->mmgr,
0,
arg->path,
QSE_SIO_READ
QSE_SIO_READ | QSE_SIO_IGNOREMBWCERR
);
}
@ -167,7 +167,8 @@ static qse_ssize_t xout (
xtn->outfile,
QSE_SIO_WRITE |
QSE_SIO_CREATE |
QSE_SIO_TRUNCATE
QSE_SIO_TRUNCATE |
QSE_SIO_IGNOREMBWCERR
);
if (sio == QSE_NULL)
{
@ -190,7 +191,8 @@ static qse_ssize_t xout (
arg->path,
QSE_SIO_WRITE |
QSE_SIO_CREATE |
QSE_SIO_TRUNCATE
QSE_SIO_TRUNCATE |
QSE_SIO_IGNOREMBWCERR
);
}