added qse_fmtulongtombs()/qse_fmtulongtowcs()
This commit is contained in:
@ -1,2 +1,2 @@
|
||||
SUBDIRS = cmn awk cut sed fs
|
||||
SUBDIRS = cmn awk cut sed fs net stx
|
||||
DIST_SUBDIRS = $(SUBDIRS)
|
||||
|
@ -230,7 +230,7 @@ target_alias = @target_alias@
|
||||
top_build_prefix = @top_build_prefix@
|
||||
top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
SUBDIRS = cmn awk cut sed fs
|
||||
SUBDIRS = cmn awk cut sed fs net stx
|
||||
DIST_SUBDIRS = $(SUBDIRS)
|
||||
all: all-recursive
|
||||
|
||||
|
@ -8,8 +8,17 @@ AM_CPPFLAGS = \
|
||||
|
||||
lib_LTLIBRARIES = libqsecmn.la
|
||||
|
||||
libqsecmn_la_SOURCES = \
|
||||
noinst_HEADERS = \
|
||||
mem.h \
|
||||
syscall.h \
|
||||
tre.h \
|
||||
tre-ast.h \
|
||||
tre-compile.h \
|
||||
tre-match-utils.h \
|
||||
tre-parse.h \
|
||||
tre-stack.h
|
||||
|
||||
libqsecmn_la_SOURCES = \
|
||||
alg-search.c \
|
||||
alg-sort.c \
|
||||
assert.c \
|
||||
@ -22,9 +31,9 @@ libqsecmn_la_SOURCES = \
|
||||
lda.c \
|
||||
fio.c \
|
||||
fma.c \
|
||||
fmt.c \
|
||||
main.c \
|
||||
mem.c \
|
||||
mem.h \
|
||||
oht.c \
|
||||
opt.c \
|
||||
path-basename.c \
|
||||
@ -64,24 +73,17 @@ libqsecmn_la_SOURCES = \
|
||||
str-tok.c \
|
||||
str-trm.c \
|
||||
str-word.c \
|
||||
syscall.h \
|
||||
time.c \
|
||||
tio.c \
|
||||
tio-get.c \
|
||||
tio-put.c \
|
||||
tre.c \
|
||||
tre.h \
|
||||
tre-ast.c \
|
||||
tre-ast.h \
|
||||
tre-compile.c \
|
||||
tre-compile.h \
|
||||
tre-match-backtrack.c \
|
||||
tre-match-parallel.c \
|
||||
tre-match-utils.h \
|
||||
tre-parse.c \
|
||||
tre-parse.h \
|
||||
tre-stack.c \
|
||||
tre-stack.h \
|
||||
stdio.c \
|
||||
xma.c
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
|
||||
@SET_MAKE@
|
||||
|
||||
|
||||
VPATH = @srcdir@
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
@ -36,7 +37,8 @@ build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
@ENABLE_CXX_TRUE@am__append_1 = libqsecmnxx.la
|
||||
subdir = lib/cmn
|
||||
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
|
||||
DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
|
||||
$(srcdir)/Makefile.in
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_numval.m4 \
|
||||
$(top_srcdir)/m4/ax_pthread.m4 $(top_srcdir)/m4/libtool.m4 \
|
||||
@ -75,15 +77,15 @@ LTLIBRARIES = $(lib_LTLIBRARIES)
|
||||
libqsecmn_la_DEPENDENCIES =
|
||||
am_libqsecmn_la_OBJECTS = alg-search.lo alg-sort.lo assert.lo chr.lo \
|
||||
chr-cnv.lo dll.lo env.lo gdl.lo htb.lo lda.lo fio.lo fma.lo \
|
||||
main.lo mem.lo oht.lo opt.lo path-basename.lo path-canon.lo \
|
||||
pio.lo pma.lo rbt.lo rex.lo sio.lo sll.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 time.lo tio.lo tio-get.lo \
|
||||
tio-put.lo tre.lo tre-ast.lo tre-compile.lo \
|
||||
fmt.lo main.lo mem.lo oht.lo opt.lo path-basename.lo \
|
||||
path-canon.lo pio.lo pma.lo rbt.lo rex.lo sio.lo sll.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 time.lo tio.lo \
|
||||
tio-get.lo tio-put.lo tre.lo tre-ast.lo tre-compile.lo \
|
||||
tre-match-backtrack.lo tre-match-parallel.lo tre-parse.lo \
|
||||
tre-stack.lo stdio.lo xma.lo
|
||||
libqsecmn_la_OBJECTS = $(am_libqsecmn_la_OBJECTS)
|
||||
@ -123,6 +125,7 @@ CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
|
||||
SOURCES = $(libqsecmn_la_SOURCES) $(libqsecmnxx_la_SOURCES)
|
||||
DIST_SOURCES = $(libqsecmn_la_SOURCES) \
|
||||
$(am__libqsecmnxx_la_SOURCES_DIST)
|
||||
HEADERS = $(noinst_HEADERS)
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
@ -274,8 +277,17 @@ AM_CPPFLAGS = \
|
||||
-I$(includedir)
|
||||
|
||||
lib_LTLIBRARIES = libqsecmn.la $(am__append_1)
|
||||
libqsecmn_la_SOURCES = \
|
||||
noinst_HEADERS = \
|
||||
mem.h \
|
||||
syscall.h \
|
||||
tre.h \
|
||||
tre-ast.h \
|
||||
tre-compile.h \
|
||||
tre-match-utils.h \
|
||||
tre-parse.h \
|
||||
tre-stack.h
|
||||
|
||||
libqsecmn_la_SOURCES = \
|
||||
alg-search.c \
|
||||
alg-sort.c \
|
||||
assert.c \
|
||||
@ -288,9 +300,9 @@ libqsecmn_la_SOURCES = \
|
||||
lda.c \
|
||||
fio.c \
|
||||
fma.c \
|
||||
fmt.c \
|
||||
main.c \
|
||||
mem.c \
|
||||
mem.h \
|
||||
oht.c \
|
||||
opt.c \
|
||||
path-basename.c \
|
||||
@ -330,24 +342,17 @@ libqsecmn_la_SOURCES = \
|
||||
str-tok.c \
|
||||
str-trm.c \
|
||||
str-word.c \
|
||||
syscall.h \
|
||||
time.c \
|
||||
tio.c \
|
||||
tio-get.c \
|
||||
tio-put.c \
|
||||
tre.c \
|
||||
tre.h \
|
||||
tre-ast.c \
|
||||
tre-ast.h \
|
||||
tre-compile.c \
|
||||
tre-compile.h \
|
||||
tre-match-backtrack.c \
|
||||
tre-match-parallel.c \
|
||||
tre-match-utils.h \
|
||||
tre-parse.c \
|
||||
tre-parse.h \
|
||||
tre-stack.c \
|
||||
tre-stack.h \
|
||||
stdio.c \
|
||||
xma.c
|
||||
|
||||
@ -444,6 +449,7 @@ 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)/gdl.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htb.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lda.Plo@am__quote@
|
||||
@ -634,7 +640,7 @@ distdir: $(DISTFILES)
|
||||
done
|
||||
check-am: all-am
|
||||
check: check-am
|
||||
all-am: Makefile $(LTLIBRARIES)
|
||||
all-am: Makefile $(LTLIBRARIES) $(HEADERS)
|
||||
installdirs:
|
||||
for dir in "$(DESTDIR)$(libdir)"; do \
|
||||
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
|
||||
|
@ -402,3 +402,4 @@ qse_mctype_t qse_getmctype (const qse_mchar_t* name)
|
||||
qse_mctype_t id;
|
||||
return (qse_getmctypebyname(name,&id) <= -1)? ((qse_mctype_t)0): id;
|
||||
}
|
||||
|
||||
|
161
qse/lib/cmn/fmt.c
Normal file
161
qse/lib/cmn/fmt.c
Normal file
@ -0,0 +1,161 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
Copyright 2006-2011 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/fmt.h>
|
||||
|
||||
/* ==================== multibyte ===================================== */
|
||||
qse_size_t qse_fmtulongtombs (
|
||||
qse_mchar_t* buf, qse_size_t size,
|
||||
qse_long_t value, int base_and_flags, qse_mchar_t fillchar)
|
||||
{
|
||||
qse_mchar_t tmp[(QSE_SIZEOF(qse_ulong_t) * 8)];
|
||||
qse_mchar_t* p, * bp, * be;
|
||||
int base;
|
||||
qse_mchar_t xbasechar;
|
||||
|
||||
base = base_and_flags & 0xFF;
|
||||
if (base < 2 || base > 36 || size <= 0) return 0;
|
||||
|
||||
p = tmp;
|
||||
bp = buf;
|
||||
be = buf + size - 1;
|
||||
|
||||
xbasechar = (base_and_flags & QSE_FMTULONGTOMBS_UPPERCASE)? QSE_MT('A'): QSE_MT('a');
|
||||
|
||||
/* store the resulting numeric string into 'tmp' first */
|
||||
do
|
||||
{
|
||||
int digit = value % base;
|
||||
if (digit < 10) *p++ = digit + QSE_MT('0');
|
||||
else *p++ = digit + xbasechar - 10;
|
||||
value /= base;
|
||||
}
|
||||
while (value > 0);
|
||||
|
||||
/* fill space */
|
||||
if (fillchar != QSE_MT('\0'))
|
||||
{
|
||||
qse_size_t tmplen = p - tmp;
|
||||
|
||||
if (base_and_flags & QSE_FMTULONGTOMBS_FILLRIGHT)
|
||||
{
|
||||
/* copy the numeric string to the destination buffer */
|
||||
while (p > tmp && bp < be) *bp++ = *--p;
|
||||
|
||||
/* fill the right side */
|
||||
while (size - 1 > tmplen)
|
||||
{
|
||||
*bp++ = fillchar;
|
||||
size--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* fill the left side */
|
||||
while (size - 1 > tmplen)
|
||||
{
|
||||
*bp++ = fillchar;
|
||||
size--;
|
||||
}
|
||||
|
||||
/* copy the numeric string to the destination buffer */
|
||||
while (p > tmp && bp < be) *bp++ = *--p;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* copy the numeric string to the destination buffer */
|
||||
while (p > tmp && bp < be) *bp++ = *--p;
|
||||
}
|
||||
|
||||
*bp = QSE_MT('\0');
|
||||
return bp - buf;
|
||||
}
|
||||
|
||||
/* ==================== wide-char ===================================== */
|
||||
qse_size_t qse_fmtulongtowcs (
|
||||
qse_wchar_t* buf, qse_size_t size,
|
||||
qse_long_t value, int base_and_flags, qse_wchar_t fillchar)
|
||||
{
|
||||
qse_wchar_t tmp[(QSE_SIZEOF(qse_ulong_t) * 8)];
|
||||
qse_wchar_t* p, * bp, * be;
|
||||
int base;
|
||||
qse_wchar_t xbasechar;
|
||||
|
||||
base = base_and_flags & 0xFF;
|
||||
if (base < 2 || base > 36 || size <= 0) return 0;
|
||||
|
||||
p = tmp;
|
||||
bp = buf;
|
||||
be = buf + size - 1;
|
||||
|
||||
xbasechar = (base_and_flags & QSE_FMTULONGTOWCS_UPPERCASE)? QSE_WT('A'): QSE_WT('a');
|
||||
|
||||
/* store the resulting numeric string into 'tmp' first */
|
||||
do
|
||||
{
|
||||
int digit = value % base;
|
||||
if (digit < 10) *p++ = digit + QSE_WT('0');
|
||||
else *p++ = digit + xbasechar - 10;
|
||||
value /= base;
|
||||
}
|
||||
while (value > 0);
|
||||
|
||||
/* fill space */
|
||||
if (fillchar != QSE_WT('\0'))
|
||||
{
|
||||
qse_size_t tmplen = p - tmp;
|
||||
|
||||
if (base_and_flags & QSE_FMTULONGTOWCS_FILLRIGHT)
|
||||
{
|
||||
/* copy the numeric string to the destination buffer */
|
||||
while (p > tmp && bp < be) *bp++ = *--p;
|
||||
|
||||
/* fill the right side */
|
||||
while (size - 1 > tmplen)
|
||||
{
|
||||
*bp++ = fillchar;
|
||||
size--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* fill the left side */
|
||||
while (size - 1 > tmplen)
|
||||
{
|
||||
*bp++ = fillchar;
|
||||
size--;
|
||||
}
|
||||
|
||||
/* copy the numeric string to the destination buffer */
|
||||
while (p > tmp && bp < be) *bp++ = *--p;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* copy the numeric string to the destination buffer */
|
||||
while (p > tmp && bp < be) *bp++ = *--p;
|
||||
}
|
||||
|
||||
*bp = QSE_WT('\0');
|
||||
return bp - buf;
|
||||
}
|
||||
|
||||
|
@ -106,9 +106,7 @@ static const struct tre_macro_struct
|
||||
|
||||
static QSE_INLINE int xdigit_to_num (qse_char_t c)
|
||||
{
|
||||
return (c >= QSE_T('0') && c <= QSE_T('9'))? (c - QSE_T('0')):
|
||||
(c >= QSE_T('A') && c <= QSE_T('F'))? (c - QSE_T('A') + 10):
|
||||
(c >= QSE_T('a') && c <= QSE_T('f'))? (c - QSE_T('a') + 10): -1;
|
||||
return QSE_XDIGITTONUM (c);
|
||||
}
|
||||
|
||||
/* Expands a macro delimited by `regex' and `regex_end' to `buf', which
|
||||
|
@ -553,7 +553,7 @@ qse_dir_ent_t* qse_dir_read (qse_dir_t* dir, int flags)
|
||||
|
||||
if (flags & QSE_DIR_ENT_SIZE)
|
||||
{
|
||||
ULARGE_INTEGER li;
|
||||
LARGE_INTEGER li;
|
||||
li.LowPart = info->wfd.nFileSizeLow;
|
||||
li.HighPart = info->wfd.nFileSizeHigh;
|
||||
dir->ent.size = li.QuadPart;
|
||||
|
@ -18,6 +18,11 @@
|
||||
License along with QSE. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if defined(_WIN32) || defined(__DOS__) || defined(__OS2__)
|
||||
/* UNSUPPORTED YET.. */
|
||||
/* TODO: IMPLEMENT THIS */
|
||||
#else
|
||||
|
||||
#include "httpd.h"
|
||||
#include "../cmn/mem.h"
|
||||
#include <qse/cmn/chr.h>
|
||||
@ -1196,3 +1201,4 @@ void qse_httpd_markclientbad (qse_httpd_t* httpd, qse_httpd_client_t* client)
|
||||
client->bad = 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -18,6 +18,11 @@
|
||||
License along with QSE. If not, see <htrd://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if defined(_WIN32) || defined(__DOS__) || defined(__OS2__)
|
||||
/* UNSUPPORTED YET.. */
|
||||
/* TODO: IMPLEMENT THIS */
|
||||
#else
|
||||
|
||||
#include "httpd.h"
|
||||
#include "../cmn/mem.h"
|
||||
#include <qse/cmn/str.h>
|
||||
@ -1221,3 +1226,4 @@ qse_httpd_task_t* qse_httpd_entaskproxy (...)
|
||||
|
||||
/*------------------------------------------------------------------------*/
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user