added qse_sio_putmbsf(), qse_sio_putwcsf(), qse_sio_putstrf()
This commit is contained in:
parent
35e9b1777f
commit
bd3502f7e9
@ -302,6 +302,24 @@ QSE_EXPORT qse_ssize_t qse_sio_putwcsn (
|
||||
qse_size_t size
|
||||
);
|
||||
|
||||
QSE_EXPORT qse_ssize_t qse_sio_putmbsf (
|
||||
qse_sio_t* sio,
|
||||
const qse_mchar_t* fmt,
|
||||
...
|
||||
);
|
||||
|
||||
QSE_EXPORT qse_ssize_t qse_sio_putwcsf (
|
||||
qse_sio_t* sio,
|
||||
const qse_wchar_t* fmt,
|
||||
...
|
||||
);
|
||||
|
||||
QSE_EXPORT qse_ssize_t qse_sio_putstrf (
|
||||
qse_sio_t* sio,
|
||||
const qse_char_t* fmt,
|
||||
...
|
||||
);
|
||||
|
||||
#if defined(QSE_CHAR_IS_MCHAR)
|
||||
# define qse_sio_putc(sio,c) qse_sio_putmb(sio,c)
|
||||
# define qse_sio_putstr(sio,str) qse_sio_putmbs(sio,str)
|
||||
|
@ -9,9 +9,11 @@ lib_LTLIBRARIES = libqsecmn.la
|
||||
noinst_HEADERS = \
|
||||
cp949.h \
|
||||
cp950.h \
|
||||
fmt.h \
|
||||
fmt-intmax.h \
|
||||
fmt-print.h \
|
||||
fs.h \
|
||||
mem.h \
|
||||
printf.h \
|
||||
str-join.h \
|
||||
str-subst.h \
|
||||
syscall.h \
|
||||
@ -37,7 +39,8 @@ libqsecmn_la_SOURCES = \
|
||||
htb.c \
|
||||
fio.c \
|
||||
fma.c \
|
||||
fmt.c \
|
||||
fmt-intmax.c \
|
||||
fmt-print.c \
|
||||
fs.c \
|
||||
fs-err.c \
|
||||
fs-move.c \
|
||||
@ -64,7 +67,6 @@ libqsecmn_la_SOURCES = \
|
||||
pma.c \
|
||||
rbt.c \
|
||||
rex.c \
|
||||
printf.c \
|
||||
sio.c \
|
||||
sll.c \
|
||||
slmb.c \
|
||||
|
@ -87,11 +87,11 @@ am__DEPENDENCIES_1 =
|
||||
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 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 printf.c sio.c sll.c \
|
||||
slmb.c stdio.c str-beg.c str-cat.c str-chr.c str-cnv.c \
|
||||
fma.c fmt-intmax.c fmt-print.c fs.c fs-err.c fs-move.c glob.c \
|
||||
hton.c ipad.c lda.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-join.c str-len.c str-pac.c str-pbrk.c str-put.c str-rev.c \
|
||||
@ -104,21 +104,21 @@ am__libqsecmn_la_SOURCES_DIST = alg-base64.c alg-rand.c alg-search.c \
|
||||
@ENABLE_XCMGRS_TRUE@am__objects_2 = cp949.lo cp950.lo
|
||||
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 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 printf.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-join.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)
|
||||
htb.lo fio.lo fma.lo fmt-intmax.lo fmt-print.lo fs.lo \
|
||||
fs-err.lo fs-move.lo glob.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-join.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)
|
||||
AM_V_lt = $(am__v_lt_@AM_V@)
|
||||
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
|
||||
@ -367,9 +367,11 @@ lib_LTLIBRARIES = libqsecmn.la $(am__append_3)
|
||||
noinst_HEADERS = \
|
||||
cp949.h \
|
||||
cp950.h \
|
||||
fmt.h \
|
||||
fmt-intmax.h \
|
||||
fmt-print.h \
|
||||
fs.h \
|
||||
mem.h \
|
||||
printf.h \
|
||||
str-join.h \
|
||||
str-subst.h \
|
||||
syscall.h \
|
||||
@ -382,19 +384,20 @@ noinst_HEADERS = \
|
||||
tre-stack.h
|
||||
|
||||
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 \
|
||||
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 printf.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-join.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 $(am__append_1) $(am__append_2)
|
||||
assert.c chr.c dir.c dll.c env.c gdl.c htb.c fio.c fma.c \
|
||||
fmt-intmax.c fmt-print.c fs.c fs-err.c fs-move.c glob.c hton.c \
|
||||
ipad.c lda.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-join.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 $(am__append_1) $(am__append_2)
|
||||
libqsecmn_la_LDFLAGS = -version-info 1:0:0 -no-undefined
|
||||
libqsecmn_la_LIBADD = $(SOCKET_LIBS)
|
||||
@ENABLE_CXX_TRUE@libqsecmnxx_la_SOURCES = \
|
||||
@ -493,7 +496,8 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/env.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fio.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fma.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fmt.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fmt-intmax.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fmt-print.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fs-err.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fs-move.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fs.Plo@am__quote@
|
||||
@ -520,7 +524,6 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/path-canon.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pio.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pma.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/printf.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rbt.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rex.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sio.Plo@am__quote@
|
||||
|
@ -30,7 +30,7 @@
|
||||
#define char_t qse_mchar_t
|
||||
#define fmt_uintmax fmt_unsigned_to_mbs
|
||||
#define strlen(x) qse_mbslen(x)
|
||||
#include "fmt.h"
|
||||
#include "fmt-intmax.h"
|
||||
|
||||
#undef T
|
||||
#undef char_t
|
||||
@ -41,7 +41,7 @@
|
||||
#define char_t qse_wchar_t
|
||||
#define fmt_uintmax fmt_unsigned_to_wcs
|
||||
#define strlen(x) qse_wcslen(x)
|
||||
#include "fmt.h"
|
||||
#include "fmt-intmax.h"
|
||||
|
||||
/* ==================== multibyte ===================================== */
|
||||
|
@ -153,19 +153,19 @@ static int put_mchar (qse_mchar_t c, void *arg)
|
||||
static const qse_mchar_t m_hex2ascii[] = QSE_MT("0123456789abcdefghijklmnopqrstuvwxyz");
|
||||
#define hex2ascii(hex) (m_hex2ascii[hex])
|
||||
|
||||
#include "printf.h"
|
||||
#include "fmt-print.h"
|
||||
|
||||
int qse_mprintf (const char_t *fmt, ...)
|
||||
qse_ssize_t qse_mprintf (const char_t *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int n;
|
||||
qse_ssize_t n;
|
||||
va_start (ap, fmt);
|
||||
n = qse_mxprintf (fmt, put_mchar, put_wchar, QSE_NULL, ap);
|
||||
va_end (ap);
|
||||
return n;
|
||||
}
|
||||
|
||||
int qse_mvprintf (const char_t* fmt, va_list ap)
|
||||
qse_ssize_t qse_mvprintf (const char_t* fmt, va_list ap)
|
||||
{
|
||||
return qse_mxprintf (fmt, put_mchar, put_wchar, QSE_NULL, ap);
|
||||
}
|
||||
@ -194,19 +194,19 @@ int qse_mvprintf (const char_t* fmt, va_list ap)
|
||||
static const qse_wchar_t w_hex2ascii[] = QSE_WT("0123456789abcdefghijklmnopqrstuvwxyz");
|
||||
#define hex2ascii(hex) (w_hex2ascii[hex])
|
||||
|
||||
#include "printf.h"
|
||||
#include "fmt-print.h"
|
||||
|
||||
int qse_wprintf (const char_t *fmt, ...)
|
||||
qse_ssize_t qse_wprintf (const char_t *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int n;
|
||||
qse_ssize_t n;
|
||||
va_start (ap, fmt);
|
||||
n = qse_wxprintf (fmt, put_wchar, put_mchar, QSE_NULL, ap);
|
||||
va_end (ap);
|
||||
return n;
|
||||
}
|
||||
|
||||
int qse_wvprintf (const char_t* fmt, va_list ap)
|
||||
qse_ssize_t qse_wvprintf (const char_t* fmt, va_list ap)
|
||||
{
|
||||
return qse_wxprintf (fmt, put_wchar, put_mchar, QSE_NULL, ap);
|
||||
}
|
@ -95,7 +95,7 @@ static char_t* sprintn (char_t* nbuf, qse_uintmax_t num, int base, int *lenp, in
|
||||
outcnt++; \
|
||||
} while (0)
|
||||
|
||||
int xprintf (const char_t* fmt, int (*put_char)(char_t, void*), int (*put_ochar) (ochar_t, void*), void *arg, va_list ap)
|
||||
qse_ssize_t xprintf (const char_t* fmt, int (*put_char)(char_t, void*), int (*put_ochar) (ochar_t, void*), void *arg, va_list ap)
|
||||
{
|
||||
char_t nbuf[MAXNBUF];
|
||||
const char_t* p, * percent;
|
||||
@ -106,7 +106,7 @@ int xprintf (const char_t* fmt, int (*put_char)(char_t, void*), int (*put_ochar)
|
||||
int lm_flag, lm_dflag, flagc, numlen;
|
||||
qse_uintmax_t num = 0;
|
||||
int stop = 0;
|
||||
int outcnt = 0;
|
||||
qse_ssize_t outcnt = 0;
|
||||
|
||||
struct
|
||||
{
|
||||
@ -740,7 +740,7 @@ oops:
|
||||
QSE_MMGR_FREE (QSE_MMGR_GETDFL(), fltfmt.ptr);
|
||||
if (fltout.ptr != fltout.sbuf)
|
||||
QSE_MMGR_FREE (QSE_MMGR_GETDFL(), fltout.ptr);
|
||||
return -1;
|
||||
return (qse_ssize_t)-1;
|
||||
}
|
||||
#undef PUT_CHAR
|
||||
#undef PUT_OCHAR
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include <qse/cmn/sio.h>
|
||||
#include "mem.h"
|
||||
#include "fmt.h"
|
||||
|
||||
#if defined(_WIN32)
|
||||
# include <windows.h> /* for the UGLY hack */
|
||||
@ -580,6 +581,56 @@ qse_ssize_t qse_sio_putwcsn (
|
||||
return n;
|
||||
}
|
||||
|
||||
static int put_wchar (qse_wchar_t c, void *arg)
|
||||
{
|
||||
return qse_sio_putwc (arg, c);
|
||||
}
|
||||
|
||||
static int put_mchar (qse_mchar_t c, void *arg)
|
||||
{
|
||||
return qse_sio_putmb (arg, c);
|
||||
}
|
||||
|
||||
qse_ssize_t qse_sio_putmbsf (qse_sio_t* sio, const qse_mchar_t* fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
qse_ssize_t x;
|
||||
|
||||
va_start (ap, fmt);
|
||||
x = qse_mxprintf (fmt, put_mchar, put_wchar, sio, ap);
|
||||
va_end (ap);
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
qse_ssize_t qse_sio_putwcsf (qse_sio_t* sio, const qse_wchar_t* fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
qse_ssize_t x;
|
||||
|
||||
va_start (ap, fmt);
|
||||
x = qse_wxprintf (fmt, put_wchar, put_mchar, sio, ap);
|
||||
va_end (ap);
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
qse_ssize_t qse_sio_putstrf (qse_sio_t* sio, const qse_char_t* fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
qse_ssize_t x;
|
||||
|
||||
va_start (ap, fmt);
|
||||
#if defined(QSE_CHAR_IS_MCHAR)
|
||||
x = qse_mxprintf (fmt, put_mchar, put_wchar, sio, ap);
|
||||
#else
|
||||
x = qse_wxprintf (fmt, put_wchar, put_mchar, sio, ap);
|
||||
#endif
|
||||
va_end (ap);
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
int qse_sio_getpos (qse_sio_t* sio, qse_sio_pos_t* pos)
|
||||
{
|
||||
qse_fio_off_t off;
|
||||
@ -667,4 +718,3 @@ static qse_ssize_t file_output (
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -49,6 +49,7 @@ static int test1 (void)
|
||||
QSE_MMGR_GETDFL(), 0, QSE_SIO_STDOUT,
|
||||
QSE_SIO_WRITE | QSE_SIO_IGNOREMBWCERR);
|
||||
qse_sio_putwcs (out, unistr);
|
||||
qse_sio_putwcsf (out, QSE_WT ("[%.*s] [%.*s]\n"), (int)qse_wcslen(unistr) - 1, unistr, (int)qse_wcslen(unistr) - 1, unistr);
|
||||
qse_sio_close (out);
|
||||
return 0;
|
||||
}
|
||||
@ -86,6 +87,8 @@ static int test2 (void)
|
||||
qse_wcstombs (unistr, &wlen, mbsbuf, &mlen);
|
||||
|
||||
qse_sio_putmbs (out, mbsbuf);
|
||||
|
||||
qse_sio_putmbsf (out, QSE_MT ("[%.*s] [%.*s]\n"), (int)qse_mbslen(mbsbuf) - 1, mbsbuf, (int)qse_mbslen(mbsbuf) - 1, mbsbuf);
|
||||
qse_sio_close (out);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user