This commit is contained in:
hyung-hwan 2008-06-29 02:37:09 +00:00
parent 092eeacafd
commit cbc48145c4
7 changed files with 157 additions and 45 deletions

View File

@ -5,7 +5,7 @@
#include <ase/awk/awk.h> #include <ase/awk/awk.h>
#include <ase/awk/val.h> #include <ase/awk/val.h>
#include <ase/utl/ctype.h> #include <ase/utl/helper.h>
#include <ase/utl/stdio.h> #include <ase/utl/stdio.h>
#include <ase/utl/main.h> #include <ase/utl/main.h>
@ -1145,27 +1145,16 @@ static int awk_main (int argc, ase_char_t* argv[])
prmfns.mmgr.custom_data = NULL; prmfns.mmgr.custom_data = NULL;
#endif #endif
prmfns.ccls.is_upper = custom_awk_isupper; /*prmfns.mmgr = *ASE_GETMMGR();*/
prmfns.ccls.is_lower = custom_awk_islower; prmfns.ccls = *ASE_GETCCLS();
prmfns.ccls.is_alpha = custom_awk_isalpha;
prmfns.ccls.is_digit = custom_awk_isdigit;
prmfns.ccls.is_xdigit = custom_awk_isxdigit;
prmfns.ccls.is_alnum = custom_awk_isalnum;
prmfns.ccls.is_space = custom_awk_isspace;
prmfns.ccls.is_print = custom_awk_isprint;
prmfns.ccls.is_graph = custom_awk_isgraph;
prmfns.ccls.is_cntrl = custom_awk_iscntrl;
prmfns.ccls.is_punct = custom_awk_ispunct;
prmfns.ccls.to_upper = custom_awk_toupper;
prmfns.ccls.to_lower = custom_awk_tolower;
prmfns.ccls.custom_data = NULL;
prmfns.misc.pow = custom_awk_pow; prmfns.misc.pow = custom_awk_pow;
prmfns.misc.sprintf = custom_awk_sprintf; prmfns.misc.sprintf = custom_awk_sprintf;
prmfns.misc.dprintf = custom_awk_dprintf; prmfns.misc.dprintf = custom_awk_dprintf;
prmfns.misc.custom_data = NULL; prmfns.misc.custom_data = NULL;
if ((awk = ase_awk_open(&prmfns, ASE_NULL)) == ASE_NULL) awk = ase_awk_open(&prmfns, ASE_NULL);
if (awk == ASE_NULL)
{ {
#ifdef _WIN32 #ifdef _WIN32
HeapDestroy (mmgr_data.heap); HeapDestroy (mmgr_data.heap);

View File

@ -10,16 +10,8 @@
#include <ase/utl/getopt.h> #include <ase/utl/getopt.h>
#include <ase/cmn/mem.h> #include <ase/cmn/mem.h>
#include <ase/cmn/str.h> #include <ase/cmn/str.h>
//#include <ase/utl/helper.h>
/*
#include <ase/std/io.h>
#include <ase/std/lib.h>
#include <ase/std/mem.h>
#include <ase/std/opt.h>
*/
#include <ase/utl/helper.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
@ -99,21 +91,6 @@ static ase_ssize_t put_output (
return -1; return -1;
} }
static void* custom_tgp_malloc (void* custom, ase_size_t n)
{
return malloc (n);
}
static void* custom_tgp_realloc (void* custom, void* ptr, ase_size_t n)
{
return realloc (ptr, n);
}
static void custom_tgp_free (void* custom, void* ptr)
{
free (ptr);
}
#endif #endif
static void print_usage (const ase_char_t* argv0) static void print_usage (const ase_char_t* argv0)

View File

@ -0,0 +1,28 @@
/*
* $Id: helper.h 231 2008-06-28 08:37:09Z baconevi $
*/
#ifndef _ASE_UTL_HELPER_H_
#define _ASE_UTL_HELPER_H_
#include <ase/types.h>
#include <ase/macros.h>
#define ASE_GETMMGR() (ase_mmgr)
#define ASE_SETMMGR(m) ((ase_mmgr) = (m))
#define ASE_GETCCLS() (ase_ccls)
#define ASE_SETCCLS(c) ((ase_ccls) = (c))
#ifdef __cplusplus
extern "C" {
#endif
extern ase_mmgr_t* ase_mmgr;
extern ase_ccls_t* ase_ccls;
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,5 +1,5 @@
pkginclude_HEADERS = ctype.h getopt.h http.h main.h stdio.h pkginclude_HEADERS = helper.h ctype.h getopt.h http.h main.h stdio.h
pkgincludedir= $(includedir)/ase/utl pkgincludedir= $(includedir)/ase/utl

117
ase/lib/utl/helper.c Normal file
View File

@ -0,0 +1,117 @@
/*
* $Id: helper.c 231 2008-06-28 08:37:09Z baconevi $
*/
#include <ase/utl/helper.h>
#include <ase/utl/ctype.h>
#include <stdlib.h>
static void* mmgr_malloc (void* custom, ase_size_t n)
{
return malloc (n);
}
static void* mmgr_realloc (void* custom, void* ptr, ase_size_t n)
{
return realloc (ptr, n);
}
static void mmgr_free (void* custom, void* ptr)
{
free (ptr);
}
static ase_bool_t ccls_isupper (void* custom, ase_cint_t c)
{
return ase_isupper (c);
}
static ase_bool_t ccls_islower (void* custom, ase_cint_t c)
{
return ase_islower (c);
}
static ase_bool_t ccls_isalpha (void* custom, ase_cint_t c)
{
return ase_isalpha (c);
}
static ase_bool_t ccls_isdigit (void* custom, ase_cint_t c)
{
return ase_isdigit (c);
}
static ase_bool_t ccls_isxdigit (void* custom, ase_cint_t c)
{
return ase_isxdigit (c);
}
static ase_bool_t ccls_isalnum (void* custom, ase_cint_t c)
{
return ase_isalnum (c);
}
static ase_bool_t ccls_isspace (void* custom, ase_cint_t c)
{
return ase_isspace (c);
}
static ase_bool_t ccls_isprint (void* custom, ase_cint_t c)
{
return ase_isprint (c);
}
static ase_bool_t ccls_isgraph (void* custom, ase_cint_t c)
{
return ase_isgraph (c);
}
static ase_bool_t ccls_iscntrl (void* custom, ase_cint_t c)
{
return ase_iscntrl (c);
}
static ase_bool_t ccls_ispunct (void* custom, ase_cint_t c)
{
return ase_ispunct (c);
}
static ase_cint_t ccls_toupper (void* custom, ase_cint_t c)
{
return ase_toupper (c);
}
static ase_cint_t ccls_tolower (void* custom, ase_cint_t c)
{
return ase_tolower (c);
}
static ase_mmgr_t mmgr =
{
mmgr_malloc,
mmgr_realloc,
mmgr_free,
ASE_NULL
};
static ase_ccls_t ccls =
{
ccls_isupper,
ccls_islower,
ccls_isalpha,
ccls_isdigit,
ccls_isxdigit,
ccls_isalnum,
ccls_isspace,
ccls_isprint,
ccls_isgraph,
ccls_iscntrl,
ccls_ispunct,
ccls_toupper,
ccls_tolower,
ASE_NULL
};
ase_mmgr_t* ase_mmgr = &mmgr;
ase_ccls_t* ase_ccls = &ccls;

View File

@ -2,5 +2,5 @@
AM_CFLAGS = -I$(top_builddir)/include AM_CFLAGS = -I$(top_builddir)/include
lib_LTLIBRARIES = libaseutl.la lib_LTLIBRARIES = libaseutl.la
libaseutl_la_SOURCES = assert.c ctype.c getopt.c http.c main.c stdio.c libaseutl_la_SOURCES = helper.c assert.c ctype.c getopt.c http.c main.c stdio.c
libaseutl_la_LDFLAGS = -release $(VERSION) libaseutl_la_LDFLAGS = -release $(VERSION)

View File

@ -55,8 +55,8 @@ am__installdirs = "$(DESTDIR)$(libdir)"
libLTLIBRARIES_INSTALL = $(INSTALL) libLTLIBRARIES_INSTALL = $(INSTALL)
LTLIBRARIES = $(lib_LTLIBRARIES) LTLIBRARIES = $(lib_LTLIBRARIES)
libaseutl_la_LIBADD = libaseutl_la_LIBADD =
am_libaseutl_la_OBJECTS = assert.lo ctype.lo getopt.lo http.lo main.lo \ am_libaseutl_la_OBJECTS = helper.lo assert.lo ctype.lo getopt.lo \
stdio.lo http.lo main.lo stdio.lo
libaseutl_la_OBJECTS = $(am_libaseutl_la_OBJECTS) libaseutl_la_OBJECTS = $(am_libaseutl_la_OBJECTS)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include/ase DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include/ase
depcomp = $(SHELL) $(top_srcdir)/autoconf/depcomp depcomp = $(SHELL) $(top_srcdir)/autoconf/depcomp
@ -191,7 +191,7 @@ sysconfdir = @sysconfdir@
target_alias = @target_alias@ target_alias = @target_alias@
AM_CFLAGS = -I$(top_builddir)/include AM_CFLAGS = -I$(top_builddir)/include
lib_LTLIBRARIES = libaseutl.la lib_LTLIBRARIES = libaseutl.la
libaseutl_la_SOURCES = assert.c ctype.c getopt.c http.c main.c stdio.c libaseutl_la_SOURCES = helper.c assert.c ctype.c getopt.c http.c main.c stdio.c
libaseutl_la_LDFLAGS = -release $(VERSION) libaseutl_la_LDFLAGS = -release $(VERSION)
all: all-am all: all-am
@ -265,6 +265,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/assert.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/assert.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ctype.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ctype.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/helper.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/http.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@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stdio.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stdio.Plo@am__quote@