From b7f8bba219b84a1022b5a81ae333bfd0cac61300 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Thu, 21 May 2009 04:44:47 +0000 Subject: [PATCH] added the Mmgr class and modifiled related classes --- qse/cmd/awk/Awk.cpp | 6 +-- qse/include/qse/Makefile.am | 4 ++ qse/include/qse/Mmgr.hpp | 67 +++++++++++++++++++++++++++++++++ qse/include/qse/awk/Awk.hpp | 19 ++-------- qse/include/qse/awk/StdAwk.hpp | 9 ++--- qse/include/qse/cmn/Makefile.am | 6 ++- qse/include/qse/sed/Makefile.am | 2 +- qse/include/qse/sed/Sed.hpp | 6 +-- qse/include/qse/sed/StdSed.hpp | 42 +++++++++++++++++++++ qse/lib/awk/Awk.cpp | 30 ++------------- qse/lib/awk/Makefile.am | 4 +- qse/lib/awk/StdAwk.cpp | 12 ++---- qse/lib/cmn/Makefile.am | 4 +- qse/lib/cmn/Makefile.in | 4 +- qse/lib/sed/Makefile.am | 4 +- qse/lib/sed/Makefile.in | 9 +++-- qse/lib/sed/Sed.cpp | 33 +++++++++++----- qse/lib/sed/StdSed.cpp | 44 ++++++++++++++++++++++ qse/lib/utl/Makefile.am | 2 +- qse/lib/utl/Makefile.in | 56 ++++++++++++++++++++++++--- qse/test/sed/Makefile.am | 5 ++- qse/test/sed/Makefile.in | 48 +++++++++++++++++++++-- qse/test/sed/sed02.cpp | 40 ++++++++++++++++++++ 23 files changed, 360 insertions(+), 96 deletions(-) create mode 100644 qse/include/qse/Mmgr.hpp create mode 100644 qse/include/qse/sed/StdSed.hpp create mode 100644 qse/lib/sed/StdSed.cpp create mode 100644 qse/test/sed/sed02.cpp diff --git a/qse/cmd/awk/Awk.cpp b/qse/cmd/awk/Awk.cpp index 9bfac6d5..9b6d390d 100644 --- a/qse/cmd/awk/Awk.cpp +++ b/qse/cmd/awk/Awk.cpp @@ -561,7 +561,7 @@ protected: return 1; } - void* allocMem (size_t n) + void* allocMem (size_t n) throw () { #ifdef _WIN32 return ::HeapAlloc (heap, 0, n); @@ -570,7 +570,7 @@ protected: #endif } - void* reallocMem (void* ptr, size_t n) + void* reallocMem (void* ptr, size_t n) throw () { #ifdef _WIN32 if (ptr == NULL) @@ -582,7 +582,7 @@ protected: #endif } - void freeMem (void* ptr) + void freeMem (void* ptr) throw () { #ifdef _WIN32 ::HeapFree (heap, 0, ptr); diff --git a/qse/include/qse/Makefile.am b/qse/include/qse/Makefile.am index fb5f0d97..f97612a7 100644 --- a/qse/include/qse/Makefile.am +++ b/qse/include/qse/Makefile.am @@ -4,6 +4,10 @@ SUBDIRS = cmn utl awk lsp pkginclude_HEADERS = config.h.in conf_msw.h conf_vms.h types.h macros.h pack1.h unpack.h +if ENABLE_CXX +pkginclude_HEADERS += Mmgr.hpp +endif + pkgincludedir= $(includedir)/qse CLEANFILES = *dist diff --git a/qse/include/qse/Mmgr.hpp b/qse/include/qse/Mmgr.hpp new file mode 100644 index 00000000..21b5504c --- /dev/null +++ b/qse/include/qse/Mmgr.hpp @@ -0,0 +1,67 @@ +/* + * $Id: Sed.hpp 127 2009-05-07 13:15:04Z baconevi $ + * + Copyright 2006-2009 Chung, Hyung-Hwan. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +#ifndef _QSE_MMGR_HPP_ +#define _QSE_MMGR_HPP_ + +#include +#include + +///////////////////////////////// +QSE_BEGIN_NAMESPACE(QSE) +///////////////////////////////// + +class Mmgr: public qse_mmgr_t +{ +public: + Mmgr () throw () + { + this->alloc = alloc_mem; + this->realloc = realloc_mem; + this->free = free_mem; + this->data = this; + } + + virtual ~Mmgr () {} + +protected: + virtual void* allocMem (qse_size_t n) throw () = 0; + virtual void* reallocMem (void* ptr, qse_size_t n) throw () = 0; + virtual void freeMem (void* ptr) throw () = 0; + + static void* alloc_mem (void* data, qse_size_t n) throw () + { + return ((Mmgr*)data)->allocMem (n); + } + + static void* realloc_mem (void* data, void* ptr, qse_size_t n) throw () + { + return ((Mmgr*)data)->reallocMem (ptr, n); + } + + static void free_mem (void* data, void* ptr) throw () + { + return ((Mmgr*)data)->freeMem (ptr); + } +}; + +///////////////////////////////// +QSE_END_NAMESPACE(QSE) +///////////////////////////////// + +#endif diff --git a/qse/include/qse/awk/Awk.hpp b/qse/include/qse/awk/Awk.hpp index 20b7f8d4..e3427e88 100644 --- a/qse/include/qse/awk/Awk.hpp +++ b/qse/include/qse/awk/Awk.hpp @@ -1,5 +1,5 @@ /* - * $Id: Awk.hpp 127 2009-05-07 13:15:04Z hyunghwan.chung $ + * $Id: Awk.hpp 148 2009-05-20 10:44:47Z hyunghwan.chung $ * Copyright 2006-2009 Chung, Hyung-Hwan. @@ -22,6 +22,7 @@ #include #include #include +#include #include ///////////////////////////////// @@ -31,7 +32,7 @@ QSE_BEGIN_NAMESPACE(QSE) /** * Represents the AWK interpreter engine */ -class Awk +class Awk: public Mmgr { public: /** Boolean data type */ @@ -732,9 +733,7 @@ public: }; /** Constructor */ - Awk (); - /** Destructor */ - virtual ~Awk (); + Awk () throw (); /** Returns the underlying handle */ operator awk_t* () const; @@ -1022,10 +1021,6 @@ protected: virtual void onRunStatement (Run& run, size_t line); // primitive handlers - virtual void* allocMem (size_t n) = 0; - virtual void* reallocMem (void* ptr, size_t n) = 0; - virtual void freeMem (void* ptr) = 0; - virtual real_t pow (real_t x, real_t y) = 0; virtual int vsprintf (char_t* buf, size_t size, const char_t* fmt, va_list arg) = 0; @@ -1054,10 +1049,6 @@ protected: static void onRunExit (rtx_t* run, val_t* ret, void* data); static void onRunStatement (rtx_t* run, size_t line, void* data); - static void* allocMem (void* data, size_t n); - static void* reallocMem (void* data, void* ptr, size_t n); - static void freeMem (void* data, void* ptr); - static real_t pow (awk_t* data, real_t x, real_t y); static int sprintf (awk_t* data, char_t* buf, size_t size, const char_t* fmt, ...); @@ -1078,8 +1069,6 @@ protected: private: Awk (const Awk&); Awk& operator= (const Awk&); - - mmgr_t mmgr; }; ///////////////////////////////// diff --git a/qse/include/qse/awk/StdAwk.hpp b/qse/include/qse/awk/StdAwk.hpp index b2c180ee..042f0cb1 100644 --- a/qse/include/qse/awk/StdAwk.hpp +++ b/qse/include/qse/awk/StdAwk.hpp @@ -1,5 +1,5 @@ /* - * $Id: StdAwk.hpp 127 2009-05-07 13:15:04Z hyunghwan.chung $ + * $Id: StdAwk.hpp 148 2009-05-20 10:44:47Z hyunghwan.chung $ * Copyright 2006-2009 Chung, Hyung-Hwan. @@ -33,7 +33,6 @@ QSE_BEGIN_NAMESPACE(QSE) class StdAwk: public Awk { public: - StdAwk (); int open (); int run (const char_t** args, size_t nargs); @@ -80,9 +79,9 @@ protected: int flushFile (File& io); // primitive handlers - void* allocMem (size_t n); - void* reallocMem (void* ptr, size_t n); - void freeMem (void* ptr); + void* allocMem (size_t n) throw (); + void* reallocMem (void* ptr, size_t n) throw (); + void freeMem (void* ptr) throw (); real_t pow (real_t x, real_t y); int vsprintf (char_t* buf, size_t size, diff --git a/qse/include/qse/cmn/Makefile.am b/qse/include/qse/cmn/Makefile.am index c39b3b3f..8dc2f48b 100644 --- a/qse/include/qse/cmn/Makefile.am +++ b/qse/include/qse/cmn/Makefile.am @@ -1,5 +1,9 @@ -pkginclude_HEADERS = mem.h chr.h str.h lda.h map.h rex.h sll.h dll.h opt.h tio.h fio.h pio.h sio.h time.h +pkginclude_HEADERS = mem.h chr.h str.h lda.h map.h rex.h sll.h dll.h opt.h tio.h fio.h pio.h sio.h time.h + +#if ENABLE_CXX +#pkginclude_HEADERS += +#endif pkgincludedir = $(includedir)/qse/cmn diff --git a/qse/include/qse/sed/Makefile.am b/qse/include/qse/sed/Makefile.am index d6675105..a515274a 100644 --- a/qse/include/qse/sed/Makefile.am +++ b/qse/include/qse/sed/Makefile.am @@ -1,5 +1,5 @@ -pkginclude_HEADERS = sed.h +pkginclude_HEADERS = sed.h Sed.hpp StdSed.hpp pkgincludedir= $(includedir)/qse/sed diff --git a/qse/include/qse/sed/Sed.hpp b/qse/include/qse/sed/Sed.hpp index 8a74e84f..58bc6bbb 100644 --- a/qse/include/qse/sed/Sed.hpp +++ b/qse/include/qse/sed/Sed.hpp @@ -19,6 +19,7 @@ #ifndef _QSE_SED_SED_HPP_ #define _QSE_SED_SED_HPP_ +#include #include ///////////////////////////////// @@ -28,11 +29,10 @@ QSE_BEGIN_NAMESPACE(QSE) /** * The Sed class implements a stream editor. */ -class Sed: +class Sed: public Mmgr { public: - Sed () throw (); - ~Sed () throw (); + Sed () throw (): sed (QSE_NULL) {} int open () throw (); void close () throw (); diff --git a/qse/include/qse/sed/StdSed.hpp b/qse/include/qse/sed/StdSed.hpp new file mode 100644 index 00000000..4abdc77a --- /dev/null +++ b/qse/include/qse/sed/StdSed.hpp @@ -0,0 +1,42 @@ +/* + * $Id: Sed.hpp 127 2009-05-07 13:15:04Z baconevi $ + * + Copyright 2006-2009 Chung, Hyung-Hwan. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +#ifndef _QSE_SED_STDSED_HPP_ +#define _QSE_SED_STDSED_HPP_ + +#include + +///////////////////////////////// +QSE_BEGIN_NAMESPACE(QSE) +///////////////////////////////// + +class StdSed: public Sed +{ +public: + +protected: + void* allocMem (qse_size_t n) throw (); + void* reallocMem (void* ptr, qse_size_t n) throw (); + void freeMem (void* ptr) throw (); +}; + +///////////////////////////////// +QSE_END_NAMESPACE(QSE) +///////////////////////////////// + +#endif diff --git a/qse/lib/awk/Awk.cpp b/qse/lib/awk/Awk.cpp index ed09bd3c..5f0d4959 100644 --- a/qse/lib/awk/Awk.cpp +++ b/qse/lib/awk/Awk.cpp @@ -1,5 +1,5 @@ /* - * $Id: Awk.cpp 127 2009-05-07 13:15:04Z hyunghwan.chung $ + * $Id: Awk.cpp 148 2009-05-20 10:44:47Z hyunghwan.chung $ * Copyright 2006-2009 Chung, Hyung-Hwan. @@ -1065,21 +1065,12 @@ void* Awk::Run::getData () const // Awk ////////////////////////////////////////////////////////////////// -Awk::Awk (): awk (QSE_NULL), functionMap (QSE_NULL), +Awk::Awk () throw (): awk (QSE_NULL), functionMap (QSE_NULL), sourceIn (Source::READ), sourceOut (Source::WRITE), errnum (ERR_NOERR), errlin (0), runCallback (false) { this->errmsg[0] = QSE_T('\0'); - - mmgr.alloc = allocMem; - mmgr.realloc = reallocMem; - mmgr.free = freeMem; - mmgr.data = this; -} - -Awk::~Awk () -{ } Awk::operator Awk::awk_t* () const @@ -1193,7 +1184,7 @@ int Awk::open () prm.pow = pow; prm.sprintf = sprintf; - awk = qse_awk_open (&mmgr, QSE_SIZEOF(xtn_t), &prm); + awk = qse_awk_open (this, QSE_SIZEOF(xtn_t), &prm); if (awk == QSE_NULL) { setError (ERR_NOMEM); @@ -1754,21 +1745,6 @@ void Awk::onRunStatement (rtx_t* run, size_t line, void* data) r->awk->onRunStatement (*r, line); } -void* Awk::allocMem (void* data, size_t n) -{ - return ((Awk*)data)->allocMem (n); -} - -void* Awk::reallocMem (void* data, void* ptr, size_t n) -{ - return ((Awk*)data)->reallocMem (ptr, n); -} - -void Awk::freeMem (void* data, void* ptr) -{ - ((Awk*)data)->freeMem (ptr); -} - Awk::real_t Awk::pow (awk_t* awk, real_t x, real_t y) { xtn_t* xtn = (xtn_t*) QSE_XTN (awk); diff --git a/qse/lib/awk/Makefile.am b/qse/lib/awk/Makefile.am index 8eca6762..e8b0b3c1 100644 --- a/qse/lib/awk/Makefile.am +++ b/qse/lib/awk/Makefile.am @@ -5,8 +5,8 @@ AM_CPPFLAGS = -I$(top_srcdir)/include lib_LTLIBRARIES = libqseawk.la libqseawk_la_SOURCES = awk.c err.c tree.c parse.c run.c rec.c val.c fnc.c misc.c rio.c std.c awk.h rio.h val.h fnc.h misc.h parse.h run.h tree.h -libqseawk_la_LDFLAGS= -L../cmn -L../utl -version-info 1:0:0 -no-undefined -libqseawk_la_LIBADD= -lqsecmn -lqseutl +libqseawk_la_LDFLAGS = -L../cmn -L../utl -version-info 1:0:0 -no-undefined +libqseawk_la_LIBADD = -lqsecmn -lqseutl if ENABLE_CXX lib_LTLIBRARIES += libqseawk++.la diff --git a/qse/lib/awk/StdAwk.cpp b/qse/lib/awk/StdAwk.cpp index cbf455e1..9c4b504c 100644 --- a/qse/lib/awk/StdAwk.cpp +++ b/qse/lib/awk/StdAwk.cpp @@ -1,5 +1,5 @@ /* - * $Id: StdAwk.cpp 127 2009-05-07 13:15:04Z hyunghwan.chung $ + * $Id: StdAwk.cpp 148 2009-05-20 10:44:47Z hyunghwan.chung $ * Copyright 2006-2009 Chung, Hyung-Hwan. @@ -37,10 +37,6 @@ QSE_BEGIN_NAMESPACE(QSE) ///////////////////////////////// -StdAwk::StdAwk () -{ -} - #define ADDFNC(name,min,max,impl) \ do { \ if (addFunction (name, min, max, \ @@ -396,17 +392,17 @@ int StdAwk::flushFile (File& io) } // memory allocation primitives -void* StdAwk::allocMem (size_t n) +void* StdAwk::allocMem (size_t n) throw () { return ::malloc (n); } -void* StdAwk::reallocMem (void* ptr, size_t n) +void* StdAwk::reallocMem (void* ptr, size_t n) throw () { return ::realloc (ptr, n); } -void StdAwk::freeMem (void* ptr) +void StdAwk::freeMem (void* ptr) throw () { ::free (ptr); } diff --git a/qse/lib/cmn/Makefile.am b/qse/lib/cmn/Makefile.am index 4eee794a..cdfaf330 100644 --- a/qse/lib/cmn/Makefile.am +++ b/qse/lib/cmn/Makefile.am @@ -1,6 +1,6 @@ AUTOMAKE_OPTIONS = nostdinc -AM_CFLAGS = -I$(top_builddir)/include +AM_CPPFLAGS = -I$(top_builddir)/include lib_LTLIBRARIES = libqsecmn.la libqsecmn_la_SOURCES = \ @@ -11,7 +11,7 @@ libqsecmn_la_SOURCES = \ tio.c tio_get.c tio_put.c \ fio.c pio.c sio.c \ time.c \ - misc.c + misc.c libqsecmn_la_LDFLAGS = -version-info 1:0:0 -no-undefined if WIN32 diff --git a/qse/lib/cmn/Makefile.in b/qse/lib/cmn/Makefile.in index c15173c8..d3cf22b8 100644 --- a/qse/lib/cmn/Makefile.in +++ b/qse/lib/cmn/Makefile.in @@ -202,7 +202,7 @@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = nostdinc -AM_CFLAGS = -I$(top_builddir)/include +AM_CPPFLAGS = -I$(top_builddir)/include lib_LTLIBRARIES = libqsecmn.la libqsecmn_la_SOURCES = \ syscall.h mem.h chr.h \ @@ -212,7 +212,7 @@ libqsecmn_la_SOURCES = \ tio.c tio_get.c tio_put.c \ fio.c pio.c sio.c \ time.c \ - misc.c + misc.c libqsecmn_la_LDFLAGS = -version-info 1:0:0 -no-undefined @WIN32_TRUE@libqsecmn_la_LIBADD = -lpsapi diff --git a/qse/lib/sed/Makefile.am b/qse/lib/sed/Makefile.am index 15b31622..65767728 100644 --- a/qse/lib/sed/Makefile.am +++ b/qse/lib/sed/Makefile.am @@ -1,5 +1,5 @@ -AM_CFLAGS = -I$(top_builddir)/include +AM_CPPFLAGS = -I$(top_builddir)/include lib_LTLIBRARIES = libqsesed.la libqsesed_la_SOURCES = sed.c sed.h @@ -8,7 +8,7 @@ libqsesed_la_LIBADD = -lqsecmn -lqseutl if ENABLE_CXX lib_LTLIBRARIES += libqsesed++.la -libqsesed___la_SOURCES = Sed.cpp +libqsesed___la_SOURCES = Sed.cpp StdSed.cpp libqsesed___la_LDFLAGS = -L. -L../cmn -L../utl -version-info 1:0:0 -no-undefined libqsesed___la_LIBADD = -lqsesed -lqsecmn -lqseutl endif diff --git a/qse/lib/sed/Makefile.in b/qse/lib/sed/Makefile.in index 198a2c1f..695ef353 100644 --- a/qse/lib/sed/Makefile.in +++ b/qse/lib/sed/Makefile.in @@ -52,8 +52,8 @@ am__installdirs = "$(DESTDIR)$(libdir)" libLTLIBRARIES_INSTALL = $(INSTALL) LTLIBRARIES = $(lib_LTLIBRARIES) libqsesed___la_DEPENDENCIES = -am__libqsesed___la_SOURCES_DIST = Sed.cpp -@ENABLE_CXX_TRUE@am_libqsesed___la_OBJECTS = Sed.lo +am__libqsesed___la_SOURCES_DIST = Sed.cpp StdSed.cpp +@ENABLE_CXX_TRUE@am_libqsesed___la_OBJECTS = Sed.lo StdSed.lo libqsesed___la_OBJECTS = $(am_libqsesed___la_OBJECTS) libqsesed___la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ @@ -217,12 +217,12 @@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -AM_CFLAGS = -I$(top_builddir)/include +AM_CPPFLAGS = -I$(top_builddir)/include lib_LTLIBRARIES = libqsesed.la $(am__append_1) libqsesed_la_SOURCES = sed.c sed.h libqsesed_la_LDFLAGS = -version-info 1:0:0 -no-undefined -L../cmn -L../utl libqsesed_la_LIBADD = -lqsecmn -lqseutl -@ENABLE_CXX_TRUE@libqsesed___la_SOURCES = Sed.cpp +@ENABLE_CXX_TRUE@libqsesed___la_SOURCES = Sed.cpp StdSed.cpp @ENABLE_CXX_TRUE@libqsesed___la_LDFLAGS = -L. -L../cmn -L../utl -version-info 1:0:0 -no-undefined @ENABLE_CXX_TRUE@libqsesed___la_LIBADD = -lqsesed -lqsecmn -lqseutl all: all-am @@ -297,6 +297,7 @@ distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Sed.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/StdSed.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sed.Plo@am__quote@ .c.o: diff --git a/qse/lib/sed/Sed.cpp b/qse/lib/sed/Sed.cpp index 3fb878fd..d1dc58d8 100644 --- a/qse/lib/sed/Sed.cpp +++ b/qse/lib/sed/Sed.cpp @@ -17,22 +17,26 @@ */ #include +#include "sed.h" + +#include +#include ///////////////////////////////// QSE_BEGIN_NAMESPACE(QSE) ///////////////////////////////// -Sed::Sed () throw () : sed (QSE_NULL) +int Sed::open () throw () { -} + sed = qse_sed_open (this, QSE_SIZEOF(Sed*)); + if (sed == QSE_NULL) + { + // TODO: set error... + return -1; + } -Sed::~Sed () throw () -{ - close (); -} - -int Sed::open () throw() -{ + *(Sed**)QSE_XTN(sed) = this; + return 0; } void Sed::close () throw() @@ -44,8 +48,17 @@ void Sed::close () throw() } } +int Sed::compile () throw () +{ + return 0; +} + +int Sed::execute () throw () +{ + return 0; +} ///////////////////////////////// -QSE_BEGIN_NAMESPACE(QSE) +QSE_END_NAMESPACE(QSE) ///////////////////////////////// diff --git a/qse/lib/sed/StdSed.cpp b/qse/lib/sed/StdSed.cpp new file mode 100644 index 00000000..cfe7161b --- /dev/null +++ b/qse/lib/sed/StdSed.cpp @@ -0,0 +1,44 @@ +/* + * $Id: Sed.hpp 127 2009-05-07 13:15:04Z baconevi $ + * + Copyright 2006-2009 Chung, Hyung-Hwan. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +#include +#include + +///////////////////////////////// +QSE_BEGIN_NAMESPACE(QSE) +///////////////////////////////// + +void* StdSed::allocMem (qse_size_t n) throw () +{ + return ::malloc (n); +} + +void* StdSed::reallocMem (void* ptr, qse_size_t n) throw () +{ + return ::realloc (ptr, n); +} + +void StdSed::freeMem (void* ptr) throw () +{ + ::free (ptr); +} + +///////////////////////////////// +QSE_END_NAMESPACE(QSE) +///////////////////////////////// + diff --git a/qse/lib/utl/Makefile.am b/qse/lib/utl/Makefile.am index 1f9e36d8..b24dc726 100644 --- a/qse/lib/utl/Makefile.am +++ b/qse/lib/utl/Makefile.am @@ -1,5 +1,5 @@ -AM_CFLAGS = -I$(top_builddir)/include +AM_CPPFLAGS = -I$(top_builddir)/include lib_LTLIBRARIES = libqseutl.la libqseutl_la_SOURCES = \ diff --git a/qse/lib/utl/Makefile.in b/qse/lib/utl/Makefile.in index 79c19a6e..1bf20116 100644 --- a/qse/lib/utl/Makefile.in +++ b/qse/lib/utl/Makefile.in @@ -32,6 +32,7 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ +@ENABLE_CXX_TRUE@am__append_1 = libqsesed++.la subdir = lib/utl DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -50,6 +51,14 @@ am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; am__installdirs = "$(DESTDIR)$(libdir)" libLTLIBRARIES_INSTALL = $(INSTALL) LTLIBRARIES = $(lib_LTLIBRARIES) +libqsesed___la_DEPENDENCIES = +am__libqsesed___la_SOURCES_DIST = Sed.cpp +@ENABLE_CXX_TRUE@am_libqsesed___la_OBJECTS = Sed.lo +libqsesed___la_OBJECTS = $(am_libqsesed___la_OBJECTS) +libqsesed___la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ + $(CXXFLAGS) $(libqsesed___la_LDFLAGS) $(LDFLAGS) -o $@ +@ENABLE_CXX_TRUE@am_libqsesed___la_rpath = -rpath $(libdir) libqseutl_la_DEPENDENCIES = am_libqseutl_la_OBJECTS = assert.lo http.lo main.lo stdio.lo tgp.lo libqseutl_la_OBJECTS = $(am_libqseutl_la_OBJECTS) @@ -68,8 +77,18 @@ CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ -SOURCES = $(libqseutl_la_SOURCES) -DIST_SOURCES = $(libqseutl_la_SOURCES) +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libqsesed___la_SOURCES) $(libqseutl_la_SOURCES) +DIST_SOURCES = $(am__libqsesed___la_SOURCES_DIST) \ + $(libqseutl_la_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) @@ -198,8 +217,8 @@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -AM_CFLAGS = -I$(top_builddir)/include -lib_LTLIBRARIES = libqseutl.la +AM_CPPFLAGS = -I$(top_builddir)/include +lib_LTLIBRARIES = libqseutl.la $(am__append_1) libqseutl_la_SOURCES = \ assert.c http.c main.c stdio.c \ tgp.c \ @@ -207,10 +226,13 @@ libqseutl_la_SOURCES = \ libqseutl_la_LDFLAGS = -version-info 1:0:0 -no-undefined -L../cmn libqseutl_la_LIBADD = -lqsecmn +@ENABLE_CXX_TRUE@libqsesed___la_SOURCES = Sed.cpp +@ENABLE_CXX_TRUE@libqsesed___la_LDFLAGS = -L. -L../cmn -L../utl -version-info 1:0:0 -no-undefined +@ENABLE_CXX_TRUE@libqsesed___la_LIBADD = -lqsesed -lqsecmn -lqseutl all: all-am .SUFFIXES: -.SUFFIXES: .c .lo .o .obj +.SUFFIXES: .c .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ @@ -267,6 +289,8 @@ clean-libLTLIBRARIES: echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done +libqsesed++.la: $(libqsesed___la_OBJECTS) $(libqsesed___la_DEPENDENCIES) + $(libqsesed___la_LINK) $(am_libqsesed___la_rpath) $(libqsesed___la_OBJECTS) $(libqsesed___la_LIBADD) $(LIBS) libqseutl.la: $(libqseutl_la_OBJECTS) $(libqseutl_la_DEPENDENCIES) $(libqseutl_la_LINK) -rpath $(libdir) $(libqseutl_la_OBJECTS) $(libqseutl_la_LIBADD) $(LIBS) @@ -276,6 +300,7 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Sed.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/assert.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/http.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Plo@am__quote@ @@ -303,6 +328,27 @@ distclean-compile: @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< +.cpp.o: +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.cpp.lo: +@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< + mostlyclean-libtool: -rm -f *.lo diff --git a/qse/test/sed/Makefile.am b/qse/test/sed/Makefile.am index b0425552..9dec592a 100644 --- a/qse/test/sed/Makefile.am +++ b/qse/test/sed/Makefile.am @@ -1,8 +1,11 @@ AM_CPPFLAGS = -I$(top_srcdir)/include -bin_PROGRAMS = sed01 +bin_PROGRAMS = sed01 sed02 LDFLAGS = -L../../lib/cmn -L../../lib/utl -L../../lib/sed LDADD = -lqsesed -lqseutl -lqsecmn $(LIBM) sed01_SOURCES = sed01.c + +sed02_SOURCES = sed02.cpp +sed02_LDADD = -lqsesed++ $(LDADD) diff --git a/qse/test/sed/Makefile.in b/qse/test/sed/Makefile.in index a1600b66..8214100d 100644 --- a/qse/test/sed/Makefile.in +++ b/qse/test/sed/Makefile.in @@ -32,7 +32,7 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ -bin_PROGRAMS = sed01$(EXEEXT) +bin_PROGRAMS = sed01$(EXEEXT) sed02$(EXEEXT) subdir = test/sed DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -50,6 +50,10 @@ sed01_OBJECTS = $(am_sed01_OBJECTS) sed01_LDADD = $(LDADD) am__DEPENDENCIES_1 = sed01_DEPENDENCIES = $(am__DEPENDENCIES_1) +am_sed02_OBJECTS = sed02.$(OBJEXT) +sed02_OBJECTS = $(am_sed02_OBJECTS) +am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1) +sed02_DEPENDENCIES = $(am__DEPENDENCIES_2) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include/qse depcomp = $(SHELL) $(top_srcdir)/autoconf/depcomp am__depfiles_maybe = depfiles @@ -62,8 +66,17 @@ CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ -SOURCES = $(sed01_SOURCES) -DIST_SOURCES = $(sed01_SOURCES) +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +LTCXXCOMPILE = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(sed01_SOURCES) $(sed02_SOURCES) +DIST_SOURCES = $(sed01_SOURCES) $(sed02_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) @@ -195,10 +208,12 @@ top_srcdir = @top_srcdir@ AM_CPPFLAGS = -I$(top_srcdir)/include LDADD = -lqsesed -lqseutl -lqsecmn $(LIBM) sed01_SOURCES = sed01.c +sed02_SOURCES = sed02.cpp +sed02_LDADD = -lqsesed++ $(LDADD) all: all-am .SUFFIXES: -.SUFFIXES: .c .lo .o .obj +.SUFFIXES: .c .cpp .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ @@ -259,6 +274,9 @@ clean-binPROGRAMS: sed01$(EXEEXT): $(sed01_OBJECTS) $(sed01_DEPENDENCIES) @rm -f sed01$(EXEEXT) $(LINK) $(sed01_OBJECTS) $(sed01_LDADD) $(LIBS) +sed02$(EXEEXT): $(sed02_OBJECTS) $(sed02_DEPENDENCIES) + @rm -f sed02$(EXEEXT) + $(CXXLINK) $(sed02_OBJECTS) $(sed02_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) @@ -267,6 +285,7 @@ distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sed01.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sed02.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @@ -289,6 +308,27 @@ distclean-compile: @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< +.cpp.o: +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.cpp.lo: +@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $< + mostlyclean-libtool: -rm -f *.lo diff --git a/qse/test/sed/sed02.cpp b/qse/test/sed/sed02.cpp new file mode 100644 index 00000000..0dd81d7b --- /dev/null +++ b/qse/test/sed/sed02.cpp @@ -0,0 +1,40 @@ +/* + * $Id$ + * + Copyright 2006-2009 Chung, Hyung-Hwan. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +#include +#include +#include + +int sed_main (int argc, qse_char_t* argv[]) +{ + QSE::StdSed sed; + + if (sed.open () == -1) + { + qse_printf (QSE_T("cannot open a stream editor\n")); + return -1; + } + + sed.close (); + return 0; +} + +int qse_main (int argc, char* argv[]) +{ + return qse_runmain (argc, argv, sed_main); +}