fixed a bug in awk's built-in function fflush().
added the mb8 conversion routines for raw byte conversion
This commit is contained in:
@ -45,6 +45,7 @@ libqsecmn_la_SOURCES = \
|
||||
ipad.c \
|
||||
lda.c \
|
||||
main.c \
|
||||
mb8.c \
|
||||
mbwc.c \
|
||||
mbwc-str.c \
|
||||
mem.c \
|
||||
|
@ -88,15 +88,15 @@ libqsecmn_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
|
||||
am__libqsecmn_la_SOURCES_DIST = alg-base64.c alg-rand.c alg-search.c \
|
||||
alg-sort.c assert.c chr.c dir.c dll.c env.c gdl.c htb.c fio.c \
|
||||
fma.c fmt.c fs.c fs-err.c fs-move.c glob.c hton.c ipad.c lda.c \
|
||||
main.c mbwc.c mbwc-str.c mem.c mux.c nwad.c nwad-skad.c nwif.c \
|
||||
nwif-cfg.c nwio.c oht.c opt.c path-basename.c path-canon.c \
|
||||
pio.c pma.c rbt.c rex.c sio.c sll.c slmb.c stdio.c str-beg.c \
|
||||
str-cat.c str-chr.c str-cnv.c str-cmp.c str-cpy.c str-del.c \
|
||||
str-dup.c str-dynm.c str-dynw.c str-end.c str-excl.c \
|
||||
str-fcpy.c str-fnmat.c str-incl.c str-len.c str-pac.c \
|
||||
str-pbrk.c str-put.c str-rev.c str-rot.c str-set.c str-spl.c \
|
||||
str-spn.c str-str.c str-subst.c str-tok.c str-trm.c str-word.c \
|
||||
task.c time.c tio.c tre.c tre-ast.c tre-compile.c \
|
||||
main.c mb8.c mbwc.c mbwc-str.c mem.c mux.c nwad.c nwad-skad.c \
|
||||
nwif.c nwif-cfg.c nwio.c oht.c opt.c path-basename.c \
|
||||
path-canon.c pio.c pma.c rbt.c rex.c sio.c sll.c slmb.c \
|
||||
stdio.c str-beg.c str-cat.c str-chr.c str-cnv.c str-cmp.c \
|
||||
str-cpy.c str-del.c str-dup.c str-dynm.c str-dynw.c str-end.c \
|
||||
str-excl.c str-fcpy.c str-fnmat.c str-incl.c str-len.c \
|
||||
str-pac.c str-pbrk.c str-put.c str-rev.c str-rot.c str-set.c \
|
||||
str-spl.c str-spn.c str-str.c str-subst.c str-tok.c str-trm.c \
|
||||
str-word.c task.c time.c tio.c tre.c tre-ast.c tre-compile.c \
|
||||
tre-match-backtrack.c tre-match-parallel.c tre-parse.c \
|
||||
tre-stack.c uri.c utf8.c xma.c uni.c cp949.c cp950.c
|
||||
@ENABLE_BUNDLED_UNICODE_TRUE@am__objects_1 = uni.lo
|
||||
@ -104,17 +104,17 @@ am__libqsecmn_la_SOURCES_DIST = alg-base64.c alg-rand.c alg-search.c \
|
||||
am_libqsecmn_la_OBJECTS = alg-base64.lo alg-rand.lo alg-search.lo \
|
||||
alg-sort.lo assert.lo chr.lo dir.lo dll.lo env.lo gdl.lo \
|
||||
htb.lo fio.lo fma.lo fmt.lo fs.lo fs-err.lo fs-move.lo glob.lo \
|
||||
hton.lo ipad.lo lda.lo main.lo mbwc.lo mbwc-str.lo mem.lo \
|
||||
mux.lo nwad.lo nwad-skad.lo nwif.lo nwif-cfg.lo nwio.lo oht.lo \
|
||||
opt.lo path-basename.lo path-canon.lo pio.lo pma.lo rbt.lo \
|
||||
rex.lo sio.lo sll.lo slmb.lo stdio.lo str-beg.lo str-cat.lo \
|
||||
str-chr.lo str-cnv.lo str-cmp.lo str-cpy.lo str-del.lo \
|
||||
str-dup.lo str-dynm.lo str-dynw.lo str-end.lo str-excl.lo \
|
||||
str-fcpy.lo str-fnmat.lo str-incl.lo str-len.lo str-pac.lo \
|
||||
str-pbrk.lo str-put.lo str-rev.lo str-rot.lo str-set.lo \
|
||||
str-spl.lo str-spn.lo str-str.lo str-subst.lo str-tok.lo \
|
||||
str-trm.lo str-word.lo task.lo time.lo tio.lo tre.lo \
|
||||
tre-ast.lo tre-compile.lo tre-match-backtrack.lo \
|
||||
hton.lo ipad.lo lda.lo main.lo mb8.lo mbwc.lo mbwc-str.lo \
|
||||
mem.lo mux.lo nwad.lo nwad-skad.lo nwif.lo nwif-cfg.lo nwio.lo \
|
||||
oht.lo opt.lo path-basename.lo path-canon.lo pio.lo pma.lo \
|
||||
rbt.lo rex.lo sio.lo sll.lo slmb.lo stdio.lo str-beg.lo \
|
||||
str-cat.lo str-chr.lo str-cnv.lo str-cmp.lo str-cpy.lo \
|
||||
str-del.lo str-dup.lo str-dynm.lo str-dynw.lo str-end.lo \
|
||||
str-excl.lo str-fcpy.lo str-fnmat.lo str-incl.lo str-len.lo \
|
||||
str-pac.lo str-pbrk.lo str-put.lo str-rev.lo str-rot.lo \
|
||||
str-set.lo str-spl.lo str-spn.lo str-str.lo str-subst.lo \
|
||||
str-tok.lo str-trm.lo str-word.lo task.lo time.lo tio.lo \
|
||||
tre.lo tre-ast.lo tre-compile.lo tre-match-backtrack.lo \
|
||||
tre-match-parallel.lo tre-parse.lo tre-stack.lo uri.lo utf8.lo \
|
||||
xma.lo $(am__objects_1) $(am__objects_2)
|
||||
libqsecmn_la_OBJECTS = $(am_libqsecmn_la_OBJECTS)
|
||||
@ -355,7 +355,7 @@ noinst_HEADERS = \
|
||||
libqsecmn_la_SOURCES = alg-base64.c alg-rand.c alg-search.c alg-sort.c \
|
||||
assert.c chr.c dir.c dll.c env.c gdl.c htb.c fio.c fma.c fmt.c \
|
||||
fs.c fs-err.c fs-move.c glob.c hton.c ipad.c lda.c main.c \
|
||||
mbwc.c mbwc-str.c mem.c mux.c nwad.c nwad-skad.c nwif.c \
|
||||
mb8.c mbwc.c mbwc-str.c mem.c mux.c nwad.c nwad-skad.c nwif.c \
|
||||
nwif-cfg.c nwio.c oht.c opt.c path-basename.c path-canon.c \
|
||||
pio.c pma.c rbt.c rex.c sio.c sll.c slmb.c stdio.c str-beg.c \
|
||||
str-cat.c str-chr.c str-cnv.c str-cmp.c str-cpy.c str-del.c \
|
||||
@ -475,6 +475,7 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ipad.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lda.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mb8.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mbwc-str.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mbwc.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mem.Plo@am__quote@
|
||||
|
38
qse/lib/cmn/mb8.c
Normal file
38
qse/lib/cmn/mb8.c
Normal file
@ -0,0 +1,38 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
Copyright 2006-2012 Chung, Hyung-Hwan.
|
||||
This file is part of QSE.
|
||||
|
||||
QSE is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation, either version 3 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
QSE is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with QSE. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <qse/cmn/mb8.h>
|
||||
|
||||
qse_size_t qse_wctomb8 (qse_wchar_t wc, qse_mchar_t* utf8, qse_size_t size)
|
||||
{
|
||||
if (size <= 0) return size + 1; /* buffer too small */
|
||||
if (wc > QSE_TYPE_MAX(qse_uint8_t)) return 0; /* illegal character */
|
||||
if (utf8) *(qse_uint8_t*)utf8 = wc;
|
||||
return 1;
|
||||
}
|
||||
|
||||
qse_size_t qse_mb8towc (
|
||||
const qse_mchar_t* utf8, qse_size_t size, qse_wchar_t* wc)
|
||||
{
|
||||
QSE_ASSERT (utf8 != QSE_NULL);
|
||||
QSE_ASSERT (size > 0);
|
||||
*wc = *(const qse_uint8_t*)utf8;
|
||||
return 1;
|
||||
}
|
@ -21,6 +21,7 @@
|
||||
#include <qse/cmn/mbwc.h>
|
||||
#include <qse/cmn/slmb.h>
|
||||
#include <qse/cmn/utf8.h>
|
||||
#include <qse/cmn/mb8.h>
|
||||
#include <qse/cmn/cp949.h>
|
||||
#include <qse/cmn/cp950.h>
|
||||
#include <qse/cmn/str.h>
|
||||
@ -30,31 +31,18 @@
|
||||
* dependent.
|
||||
*/
|
||||
|
||||
/* TODO: binary cmgr -> simply expands a byte to wchar and vice versa. */
|
||||
|
||||
static qse_cmgr_t builtin_cmgr[] =
|
||||
{
|
||||
{
|
||||
qse_slmbtoslwc,
|
||||
qse_slwctoslmb
|
||||
},
|
||||
|
||||
/* keep the order aligned with qse_cmgr_id_t values in <qse/cmn/mbwc.h> */
|
||||
{ qse_slmbtoslwc, qse_slwctoslmb },
|
||||
{ qse_utf8touc, qse_uctoutf8 },
|
||||
{ qse_mb8towc, qse_wctomb8 }
|
||||
#if defined(QSE_ENABLE_XCMGRS)
|
||||
{
|
||||
qse_cp949touc,
|
||||
qse_uctocp949
|
||||
},
|
||||
|
||||
{
|
||||
qse_cp950touc,
|
||||
qse_uctocp950
|
||||
},
|
||||
,
|
||||
{ qse_cp949touc, qse_uctocp949 },
|
||||
{ qse_cp950touc, qse_uctocp950 }
|
||||
#endif
|
||||
|
||||
{
|
||||
qse_utf8touc,
|
||||
qse_uctoutf8
|
||||
}
|
||||
};
|
||||
|
||||
static qse_cmgr_t* dfl_cmgr = &builtin_cmgr[QSE_CMGR_SLMB];
|
||||
@ -84,6 +72,8 @@ qse_cmgr_t* qse_findcmgrbyid (qse_cmgr_id_t id)
|
||||
|
||||
qse_cmgr_t* qse_findcmgr (const qse_char_t* name)
|
||||
{
|
||||
/* TODO: binary search or something better for performance improvement
|
||||
* when there are many entries in the table */
|
||||
static struct
|
||||
{
|
||||
const qse_char_t* name;
|
||||
@ -95,7 +85,8 @@ qse_cmgr_t* qse_findcmgr (const qse_char_t* name)
|
||||
{ QSE_T("cp949"), QSE_CMGR_CP949 },
|
||||
{ QSE_T("cp950"), QSE_CMGR_CP950 },
|
||||
#endif
|
||||
{ QSE_T("slmb"), QSE_CMGR_UTF8 }
|
||||
{ QSE_T("slmb"), QSE_CMGR_SLMB },
|
||||
{ QSE_T("mb8"), QSE_CMGR_MB8 }
|
||||
};
|
||||
|
||||
if (name)
|
||||
|
Reference in New Issue
Block a user