*** empty log message ***

This commit is contained in:
hyung-hwan 2007-02-23 08:28:39 +00:00
parent 8c4383a64f
commit 89e66ed7aa
7 changed files with 217 additions and 165 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Id: jni.c,v 1.67 2007-02-23 08:17:49 bacon Exp $ * $Id: jni.c,v 1.68 2007-02-23 08:28:39 bacon Exp $
* *
* {License} * {License}
*/ */
@ -16,17 +16,14 @@
#include <ase/awk/awk.h> #include <ase/awk/awk.h>
#include <ase/awk/val.h> #include <ase/awk/val.h>
#include "../etc/printf.c" #include <ase/utl/stdio.h>
#include <ase/utl/ctype.h>
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>
#include <tchar.h> #include <tchar.h>
#endif #endif
#ifdef _MSC_VER
#define snprintf _snprintf
#endif
#ifndef ASE_CHAR_IS_WCHAR #ifndef ASE_CHAR_IS_WCHAR
#error this module supports ASE_CHAR_IS_WCHAR only #error this module supports ASE_CHAR_IS_WCHAR only
#endif #endif
@ -99,17 +96,17 @@ struct run_data_t
jmethodID double_value; jmethodID double_value;
}; };
static void* awk_malloc (ase_size_t n, void* custom_data) static void* awk_malloc (ase_mmgr_t* mmgr, ase_size_t n)
{ {
return malloc (n); return malloc (n);
} }
static void* awk_realloc (void* ptr, ase_size_t n, void* custom_data) static void* awk_realloc (ase_mmgr_t* mmgr, void* ptr, ase_size_t n)
{ {
return realloc (ptr, n); return realloc (ptr, n);
} }
static void awk_free (void* ptr, void* custom_data) static void awk_free (ase_mmgr_t* mmgr, void* ptr)
{ {
free (ptr); free (ptr);
} }
@ -124,26 +121,6 @@ static void awk_abort (void* custom_data)
abort (); abort ();
} }
static int awk_sprintf (
ase_char_t* buf, ase_size_t len, const ase_char_t* fmt, ...)
{
int n;
va_list ap;
va_start (ap, fmt);
n = ase_vsprintf (buf, len, fmt, ap);
va_end (ap);
return n;
}
static void awk_aprintf (const ase_char_t* fmt, ...)
{
va_list ap;
va_start (ap, fmt);
ase_vprintf (fmt, ap);
va_end (ap);
}
static void awk_dprintf (const ase_char_t* fmt, ...) static void awk_dprintf (const ase_char_t* fmt, ...)
{ {
va_list ap; va_list ap;
@ -246,31 +223,33 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_open (JNIEnv* env, jobject obj)
int opt, errnum; int opt, errnum;
memset (&prmfns, 0, sizeof(prmfns)); memset (&prmfns, 0, sizeof(prmfns));
prmfns.malloc = awk_malloc;
prmfns.realloc = awk_realloc;
prmfns.free = awk_free;
prmfns.is_upper = iswupper; prmfns.mmgr.malloc = awk_malloc;
prmfns.is_lower = iswlower; prmfns.mmgr.realloc = awk_realloc;
prmfns.is_alpha = iswalpha; prmfns.mmgr.free = awk_free;
prmfns.is_digit = iswdigit; prmfns.mmgr.custom_data = NULL;
prmfns.is_xdigit = iswxdigit;
prmfns.is_alnum = iswalnum;
prmfns.is_space = iswspace;
prmfns.is_print = iswprint;
prmfns.is_graph = iswgraph;
prmfns.is_cntrl = iswcntrl;
prmfns.is_punct = iswpunct;
prmfns.to_upper = towupper;
prmfns.to_lower = towlower;
prmfns.memcpy = memcpy; prmfns.ccls.is_upper = ase_isupper;
prmfns.memset = memset; prmfns.ccls.is_lower = ase_islower;
prmfns.pow = awk_pow; prmfns.ccls.is_alpha = ase_isalpha;
prmfns.sprintf = awk_sprintf; prmfns.ccls.is_digit = ase_isdigit;
prmfns.aprintf = awk_aprintf; prmfns.ccls.is_xdigit = ase_isxdigit;
prmfns.dprintf = awk_dprintf; prmfns.ccls.is_alnum = ase_isalnum;
prmfns.abort = awk_abort; prmfns.ccls.is_space = ase_isspace;
prmfns.ccls.is_print = ase_isprint;
prmfns.ccls.is_graph = ase_isgraph;
prmfns.ccls.is_cntrl = ase_iscntrl;
prmfns.ccls.is_punct = ase_ispunct;
prmfns.ccls.to_upper = ase_toupper;
prmfns.ccls.to_lower = ase_tolower;
prmfns.ccls.custom_data = NULL;
prmfns.misc.pow = awk_pow;
prmfns.misc.sprintf = ase_sprintf;
prmfns.misc.aprintf = ase_printf;
prmfns.misc.dprintf = awk_dprintf;
prmfns.misc.abort = awk_abort;
prmfns.misc.custom_data = NULL;
awk_data = (awk_data_t*) malloc (sizeof(awk_data_t)); awk_data = (awk_data_t*) malloc (sizeof(awk_data_t));
if (awk_data == NULL) if (awk_data == NULL)
@ -1365,7 +1344,7 @@ static int __handle_bfn (
env = run_data->env; env = run_data->env;
obj = run_data->obj; obj = run_data->obj;
awk_sprintf ( ase_sprintf (
msg_nomem, ASE_COUNTOF(msg_nomem), msg_nomem, ASE_COUNTOF(msg_nomem),
ASE_T("out of memory in handling %.*s"), ASE_T("out of memory in handling %.*s"),
fnl, fnm); fnl, fnm);

View File

@ -1,4 +1,4 @@
SUBDIRS=cmn awk lsp utl SUBDIRS=cmn utl awk lsp
all: all:
@for i in $(SUBDIRS); \ @for i in $(SUBDIRS); \

View File

@ -1,5 +1,5 @@
/* /*
* $Id: awk.c,v 1.175 2007-02-23 08:17:51 bacon Exp $ * $Id: awk.c,v 1.176 2007-02-23 08:21:35 bacon Exp $
*/ */
#include <ase/awk/awk.h> #include <ase/awk/awk.h>
@ -755,29 +755,6 @@ static int awk_main (int argc, ase_char_t* argv[])
prmfns.mmgr.malloc = awk_malloc; prmfns.mmgr.malloc = awk_malloc;
prmfns.mmgr.realloc = awk_realloc; prmfns.mmgr.realloc = awk_realloc;
prmfns.mmgr.free = awk_free; prmfns.mmgr.free = awk_free;
prmfns.ccls.is_upper = ase_isupper;
prmfns.ccls.is_lower = ase_islower;
prmfns.ccls.is_alpha = ase_isalpha;
prmfns.ccls.is_digit = ase_isdigit;
prmfns.ccls.is_xdigit = ase_isxdigit;
prmfns.ccls.is_alnum = ase_isalnum;
prmfns.ccls.is_space = ase_isspace;
prmfns.ccls.is_print = ase_isprint;
prmfns.ccls.is_graph = ase_isgraph;
prmfns.ccls.is_cntrl = ase_iscntrl;
prmfns.ccls.is_punct = ase_ispunct;
prmfns.ccls.to_upper = ase_toupper;
prmfns.ccls.to_lower = ase_tolower;
prmfns.misc.pow = awk_pow;
prmfns.misc.sprintf = ase_sprintf;
prmfns.misc.aprintf = awk_aprintf;
prmfns.misc.dprintf = awk_dprintf;
prmfns.misc.abort = awk_abort;
prmfns.misc.lock = NULL;
prmfns.misc.unlock = NULL;
#ifdef _WIN32 #ifdef _WIN32
prmfns_data.heap = HeapCreate (0, 1000000, 1000000); prmfns_data.heap = HeapCreate (0, 1000000, 1000000);
if (prmfns_data.heap == NULL) if (prmfns_data.heap == NULL)
@ -787,8 +764,34 @@ static int awk_main (int argc, ase_char_t* argv[])
} }
prmfns.mmgr.custom_data = &prmfns_data; prmfns.mmgr.custom_data = &prmfns_data;
#else
prmfns.mmgr.custom_data = NULL;
#endif #endif
prmfns.ccls.is_upper = ase_isupper;
prmfns.ccls.is_lower = ase_islower;
prmfns.ccls.is_alpha = ase_isalpha;
prmfns.ccls.is_digit = ase_isdigit;
prmfns.ccls.is_xdigit = ase_isxdigit;
prmfns.ccls.is_alnum = ase_isalnum;
prmfns.ccls.is_space = ase_isspace;
prmfns.ccls.is_print = ase_isprint;
prmfns.ccls.is_graph = ase_isgraph;
prmfns.ccls.is_cntrl = ase_iscntrl;
prmfns.ccls.is_punct = ase_ispunct;
prmfns.ccls.to_upper = ase_toupper;
prmfns.ccls.to_lower = ase_tolower;
prmfns.ccls.custom_data = NULL;
prmfns.misc.pow = awk_pow;
prmfns.misc.sprintf = ase_sprintf;
prmfns.misc.aprintf = awk_aprintf;
prmfns.misc.dprintf = awk_dprintf;
prmfns.misc.abort = awk_abort;
prmfns.misc.lock = NULL;
prmfns.misc.unlock = NULL;
prmfns.misc.custom_data = NULL;
if ((awk = ase_awk_open(&prmfns, ASE_NULL, &errnum)) == ASE_NULL) if ((awk = ase_awk_open(&prmfns, ASE_NULL, &errnum)) == ASE_NULL)
{ {
#ifdef _WIN32 #ifdef _WIN32

View File

@ -3,8 +3,8 @@ OBJS = $(SRCS:.c=.o)
CC = @CC@ CC = @CC@
CFLAGS = @CFLAGS@ -I@abs_top_builddir@/.. CFLAGS = @CFLAGS@ -I@abs_top_builddir@/..
LDFLAGS = @LDFLAGS@ -L@abs_top_builddir@/awk -L@abs_top_builddir@/utl LDFLAGS = @LDFLAGS@ -L@abs_top_builddir@/cmn -L@abs_top_builddir@/awk -L@abs_top_builddir@/utl
LIBS = @LIBS@ -laseawk -laseutl -lm LIBS = @LIBS@ -lasecmn -laseawk -laseutl -lm
all: aseawk all: aseawk

View File

@ -1,5 +1,5 @@
/* /*
* $Id: types.h,v 1.72 2007-02-23 08:17:48 bacon Exp $ * $Id: types.h,v 1.73 2007-02-23 08:22:35 bacon Exp $
* *
* {License} * {License}
*/ */
@ -230,7 +230,6 @@ typedef int ase_mcint_t;
#endif #endif
#endif #endif
typedef struct ase_cstr_t ase_cstr_t;
typedef struct ase_mmgr_t ase_mmgr_t; typedef struct ase_mmgr_t ase_mmgr_t;
typedef struct ase_ccls_t ase_ccls_t; typedef struct ase_ccls_t ase_ccls_t;
@ -241,12 +240,6 @@ typedef void (*ase_free_t) (ase_mmgr_t* mmgr, void* ptr);
typedef ase_bool_t (*ase_isccls_t) (ase_ccls_t* ccls, ase_cint_t c); typedef ase_bool_t (*ase_isccls_t) (ase_ccls_t* ccls, ase_cint_t c);
typedef ase_cint_t (*ase_toccls_t) (ase_ccls_t* ccls, ase_cint_t c); typedef ase_cint_t (*ase_toccls_t) (ase_ccls_t* ccls, ase_cint_t c);
struct ase_cstr_t
{
ase_char_t* ptr;
ase_size_t len;
};
struct ase_mmgr_t struct ase_mmgr_t
{ {
ase_malloc_t malloc; ase_malloc_t malloc;

View File

@ -1,27 +1,149 @@
/* /*
* $Id: ctype.c,v 1.1 2007-02-20 14:47:33 bacon Exp $ * $Id: ctype.c,v 1.2 2007-02-23 08:17:51 bacon Exp $
*/ */
#include <ase/utl/ctype.h> #include <ase/utl/ctype.h>
#if defined(ASE_CHAR_IS_MCHAR) && defined(isupper) #if defined(ASE_CHAR_IS_MCHAR)
int ase_isupper (int c) { return isupper (c); } #include <ctype.h>
int ase_islower (int c) { return islower (c); }
int ase_isalpha (int c) { return isalpha (c); } ase_bool_t ase_isupper (ase_ccls_t* ccls, ase_cint_t c)
int ase_isdigit (int c) { return isdigit (c); } {
int ase_isxdigit (int c) { return isxdigit (c); } return isupper (c);
int ase_isalnum (int c) { return isalnum (c); } }
int ase_isspace (int c) { return isspace (c); }
int ase_isprint (int c) { return isprint (c); } ase_bool_t ase_islower (ase_ccls_t* ccls, ase_cint_t c)
int ase_isgraph (int c) { return isgraph (c); } {
int ase_iscntrl (int c) { return iscntrl (c); } return islower (c);
int ase_ispunct (int c) { return ispunct (c); } }
ase_bool_t ase_isalpha (ase_ccls_t* ccls, ase_cint_t c)
{
return isalpha (c);
}
ase_bool_t ase_isdigit (ase_ccls_t* ccls, ase_cint_t c)
{
return isdigit (c);
}
ase_bool_t ase_isxdigit (ase_ccls_t* ccls, ase_cint_t c)
{
return isxdigit (c);
}
ase_bool_t ase_isalnum (ase_ccls_t* ccls, ase_cint_t c)
{
return isalnum (c);
}
ase_bool_t ase_isspace (ase_ccls_t* ccls, ase_cint_t c)
{
return isspace (c);
}
ase_bool_t ase_isprint (ase_ccls_t* ccls, ase_cint_t c)
{
return isprint (c);
}
ase_bool_t ase_isgraph (ase_ccls_t* ccls, ase_cint_t c)
{
return isgraph (c);
}
ase_bool_t ase_iscntrl (ase_ccls_t* ccls, ase_cint_t c)
{
return iscntrl (c);
}
ase_bool_t ase_ispunct (ase_ccls_t* ccls, ase_cint_t c)
{
return ispunct (c);
}
ase_cint_t ase_toupper (ase_ccls_t* ccls, ase_cint_t c)
{
return toupper (c);
}
ase_cint_t ase_tolower (ase_ccls_t* ccls, ase_cint_t c)
{
return tolower (c);
}
#elif defined(ASE_CHAR_IS_WCHAR)
#include <wctype.h>
ase_bool_t ase_isupper (ase_ccls_t* ccls, ase_cint_t c)
{
return iswupper (c);
}
ase_bool_t ase_islower (ase_ccls_t* ccls, ase_cint_t c)
{
return iswlower (c);
}
ase_bool_t ase_isalpha (ase_ccls_t* ccls, ase_cint_t c)
{
return iswalpha (c);
}
ase_bool_t ase_isdigit (ase_ccls_t* ccls, ase_cint_t c)
{
return iswdigit (c);
}
ase_bool_t ase_isxdigit (ase_ccls_t* ccls, ase_cint_t c)
{
return iswxdigit (c);
}
ase_bool_t ase_isalnum (ase_ccls_t* ccls, ase_cint_t c)
{
return iswalnum (c);
}
ase_bool_t ase_isspace (ase_ccls_t* ccls, ase_cint_t c)
{
return iswspace (c);
}
ase_bool_t ase_isprint (ase_ccls_t* ccls, ase_cint_t c)
{
return iswprint (c);
}
ase_bool_t ase_isgraph (ase_ccls_t* ccls, ase_cint_t c)
{
return iswgraph (c);
}
ase_bool_t ase_iscntrl (ase_ccls_t* ccls, ase_cint_t c)
{
return iswcntrl (c);
}
ase_bool_t ase_ispunct (ase_ccls_t* ccls, ase_cint_t c)
{
return iswpunct (c);
}
ase_cint_t ase_toupper (ase_ccls_t* ccls, ase_cint_t c)
{
return towupper (c);
}
ase_cint_t ase_tolower (ase_ccls_t* ccls, ase_cint_t c)
{
return towlower (c);
}
#else
#error unsupported character type
#endif #endif
#if defined(ASE_CHAR_IS_MCHAR) && defined(toupper)
int ase_toupper (int c) { return toupper (c); }
int ase_tolower (int c) { return tolower (c); }
#endif

View File

@ -8,69 +8,24 @@
#include <ase/types.h> #include <ase/types.h>
#include <ase/macros.h> #include <ase/macros.h>
#if defined(ASE_CHAR_IS_MCHAR)
#include <ctype.h>
#if !defined(isupper)
#define ase_isupper isupper
#define ase_islower islower
#define ase_isalpha isalpha
#define ase_isdigit isdigit
#define ase_isxdigit isxdigit
#define ase_isalnum isalnum
#define ase_isspace isspace
#define ase_isprint isprint
#define ase_isgraph isgraph
#define ase_iscntrl iscntrl
#define ase_ispunct ispunct
#endif
#if !defined(toupper)
#define ase_toupper toupper
#define ase_tolower tolower
#endif
#else
#include <wctype.h>
#define ase_isupper iswupper
#define ase_islower iswlower
#define ase_isalpha iswalpha
#define ase_isdigit iswdigit
#define ase_isxdigit iswxdigit
#define ase_isalnum iswalnum
#define ase_isspace iswspace
#define ase_isprint iswprint
#define ase_isgraph iswgraph
#define ase_iscntrl iswcntrl
#define ase_ispunct iswpunct
#define ase_toupper towupper
#define ase_tolower towlower
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#if defined(ASE_CHAR_IS_MCHAR) && defined(isupper) ase_bool_t ase_isupper (ase_ccls_t* ccls, ase_cint_t c);
int ase_isupper (int c); ase_bool_t ase_islower (ase_ccls_t* ccls, ase_cint_t c);
int ase_islower (int c); ase_bool_t ase_isalpha (ase_ccls_t* ccls, ase_cint_t c);
int ase_isalpha (int c); ase_bool_t ase_isdigit (ase_ccls_t* ccls, ase_cint_t c);
int ase_isdigit (int c); ase_bool_t ase_isxdigit (ase_ccls_t* ccls, ase_cint_t c);
int ase_isxdigit (int c); ase_bool_t ase_isalnum (ase_ccls_t* ccls, ase_cint_t c);
int ase_isalnum (int c); ase_bool_t ase_isspace (ase_ccls_t* ccls, ase_cint_t c);
int ase_isspace (int c); ase_bool_t ase_isprint (ase_ccls_t* ccls, ase_cint_t c);
int ase_isprint (int c); ase_bool_t ase_isgraph (ase_ccls_t* ccls, ase_cint_t c);
int ase_isgraph (int c); ase_bool_t ase_iscntrl (ase_ccls_t* ccls, ase_cint_t c);
int ase_iscntrl (int c); ase_bool_t ase_ispunct (ase_ccls_t* ccls, ase_cint_t c);
int ase_ispunct (int c);
#endif
#if defined(ASE_CHAR_IS_MCHAR) && defined(toupper) ase_cint_t ase_toupper (ase_ccls_t* ccls, ase_cint_t c);
int ase_toupper (int c); ase_cint_t ase_tolower (ase_ccls_t* ccls, ase_cint_t c);
int ase_tolower (int c);
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }