From 6ee7a71b8d3da1c2f37a0d4ff1bcdae899fdbef7 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Thu, 3 Nov 2011 14:56:26 +0000 Subject: [PATCH] added qse_fmtulongtombs()/qse_fmtulongtowcs() --- qse/cmd/Makefile.am | 2 +- qse/cmd/Makefile.in | 2 +- qse/doc/Makefile.am | 2 +- qse/doc/Makefile.in | 2 +- qse/include/qse/Makefile.am | 2 +- qse/include/qse/Makefile.in | 2 +- qse/include/qse/cmn/Makefile.am | 1 + qse/include/qse/cmn/Makefile.in | 12 +-- qse/include/qse/cmn/chr.h | 15 +++ qse/include/qse/cmn/fmt.h | 85 +++++++++++++++++ qse/include/qse/cmn/str.h | 12 +++ qse/include/qse/fs/dir.h | 14 +-- qse/lib/Makefile.am | 2 +- qse/lib/Makefile.in | 2 +- qse/lib/cmn/Makefile.am | 20 ++-- qse/lib/cmn/Makefile.in | 46 +++++---- qse/lib/cmn/chr.c | 1 + qse/lib/cmn/fmt.c | 161 ++++++++++++++++++++++++++++++++ qse/lib/cmn/tre-parse.c | 4 +- qse/lib/fs/dir.c | 2 +- qse/lib/net/httpd.c | 6 ++ qse/lib/net/httpd_task.c | 6 ++ qse/samples/Makefile.am | 2 +- qse/samples/Makefile.in | 2 +- qse/samples/cmn/Makefile.am | 3 +- qse/samples/cmn/Makefile.in | 25 +++-- qse/samples/cmn/fmt01.c | 34 +++++++ 27 files changed, 402 insertions(+), 65 deletions(-) create mode 100644 qse/include/qse/cmn/fmt.h create mode 100644 qse/lib/cmn/fmt.c create mode 100644 qse/samples/cmn/fmt01.c diff --git a/qse/cmd/Makefile.am b/qse/cmd/Makefile.am index d27e5bf5..1eecc07a 100644 --- a/qse/cmd/Makefile.am +++ b/qse/cmd/Makefile.am @@ -1,2 +1,2 @@ -SUBDIRS = awk cut sed +SUBDIRS = awk cut sed stx DIST_SUBDIRS = $(SUBDIRS) diff --git a/qse/cmd/Makefile.in b/qse/cmd/Makefile.in index 05d7c04c..c614c690 100644 --- a/qse/cmd/Makefile.in +++ b/qse/cmd/Makefile.in @@ -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 diff --git a/qse/doc/Makefile.am b/qse/doc/Makefile.am index d75dd0a2..2b2a0e2c 100644 --- a/qse/doc/Makefile.am +++ b/qse/doc/Makefile.am @@ -3,4 +3,4 @@ AUTOMAKE_OPTIONS = no-dependencies EXTRA_DIST = Doxyfile.in gendoc.sh -SUBDIRS = page +SUBDIRS = page image diff --git a/qse/doc/Makefile.in b/qse/doc/Makefile.in index ee5ea922..4ee3f810 100644 --- a/qse/doc/Makefile.in +++ b/qse/doc/Makefile.in @@ -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: diff --git a/qse/include/qse/Makefile.am b/qse/include/qse/Makefile.am index 9fed40ba..ff86e12b 100644 --- a/qse/include/qse/Makefile.am +++ b/qse/include/qse/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = cmn awk cut sed stx fs +SUBDIRS = cmn awk cut sed fs net stx pkgincludedir = $(includedir)/qse diff --git a/qse/include/qse/Makefile.in b/qse/include/qse/Makefile.in index 2732814c..086dc4d7 100644 --- a/qse/include/qse/Makefile.in +++ b/qse/include/qse/Makefile.in @@ -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 diff --git a/qse/include/qse/cmn/Makefile.am b/qse/include/qse/cmn/Makefile.am index c009886e..416b4fcd 100644 --- a/qse/include/qse/cmn/Makefile.am +++ b/qse/include/qse/cmn/Makefile.am @@ -7,6 +7,7 @@ pkginclude_HEADERS = \ env.h \ fio.h \ fma.h \ + fmt.h \ gdl.h \ htb.h \ lda.h \ diff --git a/qse/include/qse/cmn/Makefile.in b/qse/include/qse/cmn/Makefile.in index a3fdc055..f652f09a 100644 --- a/qse/include/qse/cmn/Makefile.in +++ b/qse/include/qse/cmn/Makefile.in @@ -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 diff --git a/qse/include/qse/cmn/chr.h b/qse/include/qse/cmn/chr.h index 72259b04..5c9131dc 100644 --- a/qse/include/qse/cmn/chr.h +++ b/qse/include/qse/cmn/chr.h @@ -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. diff --git a/qse/include/qse/cmn/fmt.h b/qse/include/qse/cmn/fmt.h new file mode 100644 index 00000000..a43d0a06 --- /dev/null +++ b/qse/include/qse/cmn/fmt.h @@ -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 . + */ + +#ifndef _QSE_CMN_FMT_H_ +#define _QSE_CMN_FMT_H_ + +#include +#include + +/** @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 diff --git a/qse/include/qse/cmn/str.h b/qse/include/qse/cmn/str.h index c5f06fcd..0c040839 100644 --- a/qse/include/qse/cmn/str.h +++ b/qse/include/qse/cmn/str.h @@ -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 diff --git a/qse/include/qse/fs/dir.h b/qse/include/qse/fs/dir.h index 1b95d53b..a036c40a 100644 --- a/qse/include/qse/fs/dir.h +++ b/qse/include/qse/fs/dir.h @@ -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; diff --git a/qse/lib/Makefile.am b/qse/lib/Makefile.am index 81964eea..5681c3eb 100644 --- a/qse/lib/Makefile.am +++ b/qse/lib/Makefile.am @@ -1,2 +1,2 @@ -SUBDIRS = cmn awk cut sed fs +SUBDIRS = cmn awk cut sed fs net stx DIST_SUBDIRS = $(SUBDIRS) diff --git a/qse/lib/Makefile.in b/qse/lib/Makefile.in index d48f4141..d2e29bad 100644 --- a/qse/lib/Makefile.in +++ b/qse/lib/Makefile.in @@ -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 diff --git a/qse/lib/cmn/Makefile.am b/qse/lib/cmn/Makefile.am index ed7cb58c..9fe69bab 100644 --- a/qse/lib/cmn/Makefile.am +++ b/qse/lib/cmn/Makefile.am @@ -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 diff --git a/qse/lib/cmn/Makefile.in b/qse/lib/cmn/Makefile.in index 6c33992d..157fecac 100644 --- a/qse/lib/cmn/Makefile.in +++ b/qse/lib/cmn/Makefile.in @@ -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"; \ diff --git a/qse/lib/cmn/chr.c b/qse/lib/cmn/chr.c index 9ee74564..8cfe232c 100644 --- a/qse/lib/cmn/chr.c +++ b/qse/lib/cmn/chr.c @@ -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; } + diff --git a/qse/lib/cmn/fmt.c b/qse/lib/cmn/fmt.c new file mode 100644 index 00000000..9f6be3b4 --- /dev/null +++ b/qse/lib/cmn/fmt.c @@ -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 . + */ + +#include + +/* ==================== 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; +} + + diff --git a/qse/lib/cmn/tre-parse.c b/qse/lib/cmn/tre-parse.c index a571ddf7..da97e45e 100644 --- a/qse/lib/cmn/tre-parse.c +++ b/qse/lib/cmn/tre-parse.c @@ -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 diff --git a/qse/lib/fs/dir.c b/qse/lib/fs/dir.c index faf44b08..257df5fb 100644 --- a/qse/lib/fs/dir.c +++ b/qse/lib/fs/dir.c @@ -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; diff --git a/qse/lib/net/httpd.c b/qse/lib/net/httpd.c index ace83686..ae2879b5 100644 --- a/qse/lib/net/httpd.c +++ b/qse/lib/net/httpd.c @@ -18,6 +18,11 @@ License along with QSE. If not, see . */ +#if defined(_WIN32) || defined(__DOS__) || defined(__OS2__) +/* UNSUPPORTED YET.. */ +/* TODO: IMPLEMENT THIS */ +#else + #include "httpd.h" #include "../cmn/mem.h" #include @@ -1196,3 +1201,4 @@ void qse_httpd_markclientbad (qse_httpd_t* httpd, qse_httpd_client_t* client) client->bad = 1; } +#endif diff --git a/qse/lib/net/httpd_task.c b/qse/lib/net/httpd_task.c index 37d38b97..a58328ee 100644 --- a/qse/lib/net/httpd_task.c +++ b/qse/lib/net/httpd_task.c @@ -18,6 +18,11 @@ License along with QSE. If not, see . */ +#if defined(_WIN32) || defined(__DOS__) || defined(__OS2__) +/* UNSUPPORTED YET.. */ +/* TODO: IMPLEMENT THIS */ +#else + #include "httpd.h" #include "../cmn/mem.h" #include @@ -1221,3 +1226,4 @@ qse_httpd_task_t* qse_httpd_entaskproxy (...) /*------------------------------------------------------------------------*/ +#endif diff --git a/qse/samples/Makefile.am b/qse/samples/Makefile.am index 5a74f472..eb4f7ebe 100644 --- a/qse/samples/Makefile.am +++ b/qse/samples/Makefile.am @@ -1 +1 @@ -SUBDIRS = cmn awk cut sed fs +SUBDIRS = cmn awk cut sed fs net diff --git a/qse/samples/Makefile.in b/qse/samples/Makefile.in index 9e109e4b..b9164aa3 100644 --- a/qse/samples/Makefile.in +++ b/qse/samples/Makefile.in @@ -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: diff --git a/qse/samples/cmn/Makefile.am b/qse/samples/cmn/Makefile.am index 1f33d170..29b514af 100644 --- a/qse/samples/cmn/Makefile.am +++ b/qse/samples/cmn/Makefile.am @@ -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 diff --git a/qse/samples/cmn/Makefile.in b/qse/samples/cmn/Makefile.in index 92fdf77a..a2ac12d0 100644 --- a/qse/samples/cmn/Makefile.in +++ b/qse/samples/cmn/Makefile.in @@ -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@ diff --git a/qse/samples/cmn/fmt01.c b/qse/samples/cmn/fmt01.c new file mode 100644 index 00000000..056308c2 --- /dev/null +++ b/qse/samples/cmn/fmt01.c @@ -0,0 +1,34 @@ +#include +#include + +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); +} +