added qse_fmtulongtombs()/qse_fmtulongtowcs()

This commit is contained in:
hyung-hwan 2011-11-03 14:56:26 +00:00
parent e5a9693411
commit 6ee7a71b8d
27 changed files with 402 additions and 65 deletions

View File

@ -1,2 +1,2 @@
SUBDIRS = awk cut sed
SUBDIRS = awk cut sed stx
DIST_SUBDIRS = $(SUBDIRS)

View File

@ -230,7 +230,7 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
SUBDIRS = awk cut sed
SUBDIRS = awk cut sed stx
DIST_SUBDIRS = $(SUBDIRS)
all: all-recursive

View File

@ -3,4 +3,4 @@ AUTOMAKE_OPTIONS = no-dependencies
EXTRA_DIST = Doxyfile.in gendoc.sh
SUBDIRS = page
SUBDIRS = page image

View File

@ -236,7 +236,7 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AUTOMAKE_OPTIONS = no-dependencies
EXTRA_DIST = Doxyfile.in gendoc.sh
SUBDIRS = page
SUBDIRS = page image
all: all-recursive
.SUFFIXES:

View File

@ -1,4 +1,4 @@
SUBDIRS = cmn awk cut sed stx fs
SUBDIRS = cmn awk cut sed fs net stx
pkgincludedir = $(includedir)/qse

View File

@ -259,7 +259,7 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
SUBDIRS = cmn awk cut sed stx fs
SUBDIRS = cmn awk cut sed fs net stx
pkginclude_HEADERS = conf_msw.h conf_os2.h conf_dos.h conf_vms.h \
types.h macros.h pack1.h unpack.h $(am__append_1)
all: config.h

View File

@ -7,6 +7,7 @@ pkginclude_HEADERS = \
env.h \
fio.h \
fma.h \
fmt.h \
gdl.h \
htb.h \
lda.h \

View File

@ -52,9 +52,9 @@ CONFIG_CLEAN_VPATH_FILES =
SOURCES =
DIST_SOURCES =
am__pkginclude_HEADERS_DIST = alg.h chr.h dll.h env.h fio.h fma.h \
gdl.h htb.h lda.h main.h map.h mem.h oht.h opt.h path.h pio.h \
pma.h rbt.h rex.h sio.h sll.h stdio.h str.h time.h tio.h tre.h \
xma.h Mmgr.hpp StdMmgr.hpp Mmged.hpp
fmt.h gdl.h htb.h lda.h main.h map.h mem.h oht.h opt.h path.h \
pio.h pma.h rbt.h rex.h sio.h sll.h stdio.h str.h time.h tio.h \
tre.h xma.h Mmgr.hpp StdMmgr.hpp Mmged.hpp
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
@ -223,9 +223,9 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
pkginclude_HEADERS = alg.h chr.h dll.h env.h fio.h fma.h gdl.h htb.h \
lda.h main.h map.h mem.h oht.h opt.h path.h pio.h pma.h rbt.h \
rex.h sio.h sll.h stdio.h str.h time.h tio.h tre.h xma.h \
pkginclude_HEADERS = alg.h chr.h dll.h env.h fio.h fma.h fmt.h gdl.h \
htb.h lda.h main.h map.h mem.h oht.h opt.h path.h pio.h pma.h \
rbt.h rex.h sio.h sll.h stdio.h str.h time.h tio.h tre.h xma.h \
$(am__append_1)
all: all-am

View File

@ -147,6 +147,21 @@ typedef qse_ctype_t qse_wctype_t;
# define QSE_TOLOWER(c) QSE_TOWLOWER(c)
#endif
#define QSE_XDIGITTONUM(c) \
(((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)
#define QSE_MXDIGITTONUM(c) \
(((c) >= QSE_MT('0') && (c) <= QSE_MT('9'))? ((c) - QSE_MT('0')): \
((c) >= QSE_MT('A') && (c) <= QSE_MT('F'))? ((c) - QSE_MT('A') + 10): \
((c) >= QSE_MT('a') && (c) <= QSE_MT('f'))? ((c) - QSE_MT('a') + 10): -1)
#define QSE_WXDIGITTONUM(c) \
(((c) >= QSE_WT('0') && (c) <= QSE_WT('9'))? ((c) - QSE_WT('0')): \
((c) >= QSE_WT('A') && (c) <= QSE_WT('F'))? ((c) - QSE_WT('A') + 10): \
((c) >= QSE_WT('a') && (c) <= QSE_WT('f'))? ((c) - QSE_WT('a') + 10): -1)
/**
* The qse_mbstate_t type defines a structure large enough to hold
* the standard mbstate_t.

85
qse/include/qse/cmn/fmt.h Normal file
View File

@ -0,0 +1,85 @@
/*
* $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/>.
*/
#ifndef _QSE_CMN_FMT_H_
#define _QSE_CMN_FMT_H_
#include <qse/types.h>
#include <qse/macros.h>
/** @file
* This file defines various formatting functions.
*/
enum qse_fmtulongtowcs_flag_t
{
QSE_FMTULONGTOWCS_UPPERCASE = (0x100 << 0),
#define QSE_FMTULONGTOWCS_UPPERCASE QSE_FMTULONGTOWCS_UPPERCASE
QSE_FMTULONGTOWCS_FILLRIGHT = (0x100 << 1)
#define QSE_FMTULONGTOWCS_FILLRIGHT QSE_FMTULONGTOWCS_FILLRIGHT
};
enum qse_fmtulongtombs_flag_t
{
QSE_FMTULONGTOMBS_UPPERCASE = (0x100 << 0),
#define QSE_FMTULONGTOMBS_UPPERCASE QSE_FMTULONGTOMBS_UPPERCASE
QSE_FMTULONGTOMBS_FILLRIGHT = (0x100 << 1)
#define QSE_FMTULONGTOMBS_FILLRIGHT QSE_FMTULONGTOMBS_FILLRIGHT
};
#ifdef QSE_CHAR_IS_MCHAR
# define QSE_FMTULONG_UPPERCASE QSE_FMTULONGTOMBS_UPPERCASE
# define QSE_FMTULONG_FILLRIGHT QSE_FMTULONGTOMBS_FILLRIGHT
#else
# define QSE_FMTULONG_UPPERCASE QSE_FMTULONGTOWCS_UPPERCASE
# define QSE_FMTULONG_FILLRIGHT QSE_FMTULONGTOWCS_FILLRIGHT
#endif
#ifdef __cplusplus
extern "C" {
#endif
qse_size_t qse_fmtulongtombs (
qse_mchar_t* buf,
qse_size_t size,
qse_long_t value,
int base_and_flags,
qse_mchar_t fill_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 fill_char
);
#ifdef QSE_CHAR_IS_MCHAR
# define qse_fmtulong(b,sz,v,bf,fc) qse_fmtulongtombs(b,sz,v,bf,fc)
#else
# define qse_fmtulong(b,sz,v,bf,fc) qse_fmtulongtowcs(b,sz,v,bf,fc)
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@ -297,7 +297,9 @@ typedef qse_wchar_t* (*qse_wcsxsubst_subst_t) (
enum qse_mbstrmx_op_t
{
QSE_MBSTRMX_LEFT = (1 << 0), /**< trim leading spaces */
#define QSE_MBSTRMX_LEFT QSE_MBSTRMX_LEFT
QSE_MBSTRMX_RIGHT = (1 << 1) /**< trim trailing spaces */
#define QSE_MBSTRMX_RIGHT QSE_MBSTRMX_RIGHT
};
/**
@ -306,7 +308,9 @@ enum qse_mbstrmx_op_t
enum qse_wcstrmx_op_t
{
QSE_WCSTRMX_LEFT = (1 << 0), /**< trim leading spaces */
#define QSE_WCSTRMX_LEFT QSE_WCSTRMX_LEFT
QSE_WCSTRMX_RIGHT = (1 << 1) /**< trim trailing spaces */
#define QSE_WCSTRMX_RIGHT QSE_WCSTRMX_RIGHT
};
#ifdef QSE_CHAR_IS_MCHAR
@ -320,17 +324,25 @@ enum qse_wcstrmx_op_t
enum qse_mbsfnmat_flag_t
{
QSE_MBSFNMAT_PATHNAME = (1 << 0),
#define QSE_MBSFNMAT_PATHNAME QSE_MBSFNMAT_PATHNAME
QSE_MBSFNMAT_NOESCAPE = (1 << 1),
#define QSE_MBSFNMAT_NOESCAPE QSE_MBSFNMAT_NOESCAPE
QSE_MBSFNMAT_PERIOD = (1 << 2),
#define QSE_MBSFNMAT_PERIOD QSE_MBSFNMAT_PERIOD
QSE_MBSFNMAT_IGNORECASE = (1 << 3)
#define QSE_MBSFNMAT_IGNORECASE QSE_MBSFNMAT_IGNORECASE
};
enum qse_wcsfnmat_flag_t
{
QSE_WCSFNMAT_PATHNAME = (1 << 0),
#define QSE_WCSFNMAT_PATHNAME QSE_WCSFNMAT_PATHNAME
QSE_WCSFNMAT_NOESCAPE = (1 << 1),
#define QSE_WCSFNMAT_NOESCAPE QSE_WCSFNMAT_NOESCAPE
QSE_WCSFNMAT_PERIOD = (1 << 2),
#define QSE_WCSFNMAT_PERIOD QSE_WCSFNMAT_PERIOD
QSE_WCSFNMAT_IGNORECASE = (1 << 3)
#define QSE_WCSFNMAT_IGNORECASE QSE_WCSFNMAT_IGNORECASE
};
#ifdef QSE_CHAR_IS_MCHAR

View File

@ -49,13 +49,13 @@ enum qse_dir_ent_flag_t
enum qse_dir_ent_type_t
{
QSE_DIR_ENT_UNKNOWN,
QSE_DIR_ENT_SUBDIR,
QSE_DIR_ENT_REGULAR,
QSE_DIR_ENT_CHRDEV,
QSE_DIR_ENT_BLKDEV,
QSE_DIR_ENT_SYMLINK,
QSE_DIR_ENT_PIPE
QSE_DIR_ENT_UNKNOWN,
QSE_DIR_ENT_SUBDIR,
QSE_DIR_ENT_REGULAR,
QSE_DIR_ENT_CHRDEV,
QSE_DIR_ENT_BLKDEV,
QSE_DIR_ENT_SYMLINK,
QSE_DIR_ENT_PIPE
};
typedef enum qse_dir_ent_type_t qse_dir_ent_type_t;

View File

@ -1,2 +1,2 @@
SUBDIRS = cmn awk cut sed fs
SUBDIRS = cmn awk cut sed fs net stx
DIST_SUBDIRS = $(SUBDIRS)

View File

@ -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

View File

@ -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

View File

@ -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"; \

View File

@ -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
View 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;
}

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -1 +1 @@
SUBDIRS = cmn awk cut sed fs
SUBDIRS = cmn awk cut sed fs net

View File

@ -231,7 +231,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
all: all-recursive
.SUFFIXES:

View File

@ -6,7 +6,7 @@ AM_CPPFLAGS = \
-I$(includedir)
bin_PROGRAMS = xma fma pma chr str sll dll lda oht htb rbt fio pio sio time main main2 rex01 env path01 tre01
bin_PROGRAMS = xma fma pma chr str sll dll lda oht htb rbt fio pio sio time main main2 rex01 env path01 tre01 fmt01
LDFLAGS = -L../../lib/cmn
LDADD = -lqsecmn
@ -32,6 +32,7 @@ rex01_SOURCES = rex01.c
env_SOURCES = env.c
path01_SOURCES = path01.c
tre01_SOURCES = tre01.c
fmt01_SOURCES = fmt01.c
if ENABLE_CXX

View File

@ -39,7 +39,7 @@ bin_PROGRAMS = xma$(EXEEXT) fma$(EXEEXT) pma$(EXEEXT) chr$(EXEEXT) \
oht$(EXEEXT) htb$(EXEEXT) rbt$(EXEEXT) fio$(EXEEXT) \
pio$(EXEEXT) sio$(EXEEXT) time$(EXEEXT) main$(EXEEXT) \
main2$(EXEEXT) rex01$(EXEEXT) env$(EXEEXT) path01$(EXEEXT) \
tre01$(EXEEXT)
tre01$(EXEEXT) fmt01$(EXEEXT)
subdir = samples/cmn
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@ -76,6 +76,10 @@ am_fma_OBJECTS = fma.$(OBJEXT)
fma_OBJECTS = $(am_fma_OBJECTS)
fma_LDADD = $(LDADD)
fma_DEPENDENCIES =
am_fmt01_OBJECTS = fmt01.$(OBJEXT)
fmt01_OBJECTS = $(am_fmt01_OBJECTS)
fmt01_LDADD = $(LDADD)
fmt01_DEPENDENCIES =
am_htb_OBJECTS = htb.$(OBJEXT)
htb_OBJECTS = $(am_htb_OBJECTS)
htb_LDADD = $(LDADD)
@ -154,17 +158,17 @@ LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
$(LDFLAGS) -o $@
SOURCES = $(chr_SOURCES) $(dll_SOURCES) $(env_SOURCES) $(fio_SOURCES) \
$(fma_SOURCES) $(htb_SOURCES) $(lda_SOURCES) $(main_SOURCES) \
$(main2_SOURCES) $(oht_SOURCES) $(path01_SOURCES) \
$(pio_SOURCES) $(pma_SOURCES) $(rbt_SOURCES) $(rex01_SOURCES) \
$(sio_SOURCES) $(sll_SOURCES) $(str_SOURCES) $(time_SOURCES) \
$(tre01_SOURCES) $(xma_SOURCES)
DIST_SOURCES = $(chr_SOURCES) $(dll_SOURCES) $(env_SOURCES) \
$(fio_SOURCES) $(fma_SOURCES) $(htb_SOURCES) $(lda_SOURCES) \
$(fma_SOURCES) $(fmt01_SOURCES) $(htb_SOURCES) $(lda_SOURCES) \
$(main_SOURCES) $(main2_SOURCES) $(oht_SOURCES) \
$(path01_SOURCES) $(pio_SOURCES) $(pma_SOURCES) $(rbt_SOURCES) \
$(rex01_SOURCES) $(sio_SOURCES) $(sll_SOURCES) $(str_SOURCES) \
$(time_SOURCES) $(tre01_SOURCES) $(xma_SOURCES)
DIST_SOURCES = $(chr_SOURCES) $(dll_SOURCES) $(env_SOURCES) \
$(fio_SOURCES) $(fma_SOURCES) $(fmt01_SOURCES) $(htb_SOURCES) \
$(lda_SOURCES) $(main_SOURCES) $(main2_SOURCES) $(oht_SOURCES) \
$(path01_SOURCES) $(pio_SOURCES) $(pma_SOURCES) $(rbt_SOURCES) \
$(rex01_SOURCES) $(sio_SOURCES) $(sll_SOURCES) $(str_SOURCES) \
$(time_SOURCES) $(tre01_SOURCES) $(xma_SOURCES)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@ -337,6 +341,7 @@ rex01_SOURCES = rex01.c
env_SOURCES = env.c
path01_SOURCES = path01.c
tre01_SOURCES = tre01.c
fmt01_SOURCES = fmt01.c
all: all-am
.SUFFIXES:
@ -429,6 +434,9 @@ fio$(EXEEXT): $(fio_OBJECTS) $(fio_DEPENDENCIES)
fma$(EXEEXT): $(fma_OBJECTS) $(fma_DEPENDENCIES)
@rm -f fma$(EXEEXT)
$(LINK) $(fma_OBJECTS) $(fma_LDADD) $(LIBS)
fmt01$(EXEEXT): $(fmt01_OBJECTS) $(fmt01_DEPENDENCIES)
@rm -f fmt01$(EXEEXT)
$(LINK) $(fmt01_OBJECTS) $(fmt01_LDADD) $(LIBS)
htb$(EXEEXT): $(htb_OBJECTS) $(htb_DEPENDENCIES)
@rm -f htb$(EXEEXT)
$(LINK) $(htb_OBJECTS) $(htb_LDADD) $(LIBS)
@ -489,6 +497,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/env.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fio.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fma.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fmt01.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/htb.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lda.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@

34
qse/samples/cmn/fmt01.c Normal file
View File

@ -0,0 +1,34 @@
#include <qse/cmn/fmt.h>
#include <qse/cmn/main.h>
static int test_main (int argc, qse_char_t* argv[], qse_char_t* envp[])
{
qse_char_t buf[50];
int bases[] = { 2, 8, 10, 16 };
int flags[] =
{
0,
QSE_FMTULONG_UPPERCASE,
QSE_FMTULONG_FILLRIGHT,
QSE_FMTULONG_UPPERCASE | QSE_FMTULONG_FILLRIGHT
};
int i, j;
int num = 0xF0F3;
for (i = 0; i < QSE_COUNTOF(bases); i++)
{
for (j = 0; j < QSE_COUNTOF(flags); j++)
{
qse_fmtulong (buf, QSE_COUNTOF(buf), num, bases[i] | flags[j], QSE_T('.'));
qse_printf (QSE_T("%8X => [%4d:%04X] [%s]\n"), num, bases[i], flags[j], buf);
}
}
return 0;
}
int qse_main (int argc, qse_achar_t* argv[], qse_achar_t* envp[])
{
return qse_runmainwithenv (argc, argv, envp, test_main);
}