*** empty log message ***

This commit is contained in:
hyung-hwan 2007-02-01 08:52:10 +00:00
parent abbef2a1f5
commit 758a2f71fd
7 changed files with 152 additions and 120 deletions

View File

@ -4,7 +4,7 @@
objects = awk.obj,err.obj,tree.obj,str.obj,tab.obj,map.obj,parse.obj,run.obj,rec.obj,val.obj,func.obj,misc.obj,extio.obj,rex.obj objects = awk.obj,err.obj,tree.obj,str.obj,tab.obj,map.obj,parse.obj,run.obj,rec.obj,val.obj,func.obj,misc.obj,extio.obj,rex.obj
CFLAGS = /pointer_size=long /include="../.." /define=XP_AWK_STAND_ALONE CFLAGS = /pointer_size=long /include="../.."
LIBRFLAGS = LIBRFLAGS =
aseawk.olb : $(objects) aseawk.olb : $(objects)

View File

@ -1,5 +1,5 @@
/* /*
* $Id: lsp.c,v 1.19 2006-11-29 03:19:48 bacon Exp $ * $Id: lsp.c,v 1.20 2007-02-01 08:49:51 bacon Exp $
*/ */
#if defined(__BORLANDC__) #if defined(__BORLANDC__)
@ -12,41 +12,41 @@
static int __add_builtin_prims (ase_lsp_t* lsp); static int __add_builtin_prims (ase_lsp_t* lsp);
ase_lsp_t* ase_lsp_open ( ase_lsp_t* ase_lsp_open (
const ase_lsp_syscas_t* syscas, const ase_lsp_prmfns_t* prmfns,
ase_size_t mem_ubound, ase_size_t mem_ubound_inc) ase_size_t mem_ubound, ase_size_t mem_ubound_inc)
{ {
ase_lsp_t* lsp; ase_lsp_t* lsp;
if (syscas == ASE_NULL) return ASE_NULL; if (prmfns == ASE_NULL) return ASE_NULL;
if (syscas->malloc == ASE_NULL || if (prmfns->malloc == ASE_NULL ||
syscas->realloc == ASE_NULL || prmfns->realloc == ASE_NULL ||
syscas->free == ASE_NULL) return ASE_NULL; prmfns->free == ASE_NULL) return ASE_NULL;
if (syscas->is_upper == ASE_NULL || if (prmfns->is_upper == ASE_NULL ||
syscas->is_lower == ASE_NULL || prmfns->is_lower == ASE_NULL ||
syscas->is_alpha == ASE_NULL || prmfns->is_alpha == ASE_NULL ||
syscas->is_digit == ASE_NULL || prmfns->is_digit == ASE_NULL ||
syscas->is_xdigit == ASE_NULL || prmfns->is_xdigit == ASE_NULL ||
syscas->is_alnum == ASE_NULL || prmfns->is_alnum == ASE_NULL ||
syscas->is_space == ASE_NULL || prmfns->is_space == ASE_NULL ||
syscas->is_print == ASE_NULL || prmfns->is_print == ASE_NULL ||
syscas->is_graph == ASE_NULL || prmfns->is_graph == ASE_NULL ||
syscas->is_cntrl == ASE_NULL || prmfns->is_cntrl == ASE_NULL ||
syscas->is_punct == ASE_NULL || prmfns->is_punct == ASE_NULL ||
syscas->to_upper == ASE_NULL || prmfns->to_upper == ASE_NULL ||
syscas->to_lower == ASE_NULL) return ASE_NULL; prmfns->to_lower == ASE_NULL) return ASE_NULL;
if (syscas->sprintf == ASE_NULL || if (prmfns->sprintf == ASE_NULL ||
syscas->aprintf == ASE_NULL || prmfns->aprintf == ASE_NULL ||
syscas->dprintf == ASE_NULL || prmfns->dprintf == ASE_NULL ||
syscas->abort == ASE_NULL) return ASE_NULL; prmfns->abort == ASE_NULL) return ASE_NULL;
#if defined(_WIN32) && defined(_MSC_VER) && defined(_DEBUG) #if defined(_WIN32) && defined(_MSC_VER) && defined(_DEBUG)
lsp = (ase_lsp_t*) malloc (ASE_SIZEOF(ase_lsp_t)); lsp = (ase_lsp_t*) malloc (ASE_SIZEOF(ase_lsp_t));
#else #else
lsp = (ase_lsp_t*) syscas->malloc ( lsp = (ase_lsp_t*) prmfns->malloc (
ASE_SIZEOF(ase_lsp_t), syscas->custom_data); ASE_SIZEOF(ase_lsp_t), prmfns->custom_data);
#endif #endif
if (lsp == ASE_NULL) return ASE_NULL; if (lsp == ASE_NULL) return ASE_NULL;
@ -54,13 +54,13 @@ ase_lsp_t* ase_lsp_open (
* fully initialized yet */ * fully initialized yet */
ase_lsp_memset (lsp, 0, ASE_SIZEOF(ase_lsp_t)); ase_lsp_memset (lsp, 0, ASE_SIZEOF(ase_lsp_t));
if (syscas->memcpy == ASE_NULL) if (prmfns->memcpy == ASE_NULL)
{ {
ase_lsp_memcpy (&lsp->syscas, syscas, ASE_SIZEOF(lsp->syscas)); ase_lsp_memcpy (&lsp->prmfns, prmfns, ASE_SIZEOF(lsp->prmfns));
lsp->syscas.memcpy = ase_lsp_memcpy; lsp->prmfns.memcpy = ase_lsp_memcpy;
} }
else syscas->memcpy (&lsp->syscas, syscas, ASE_SIZEOF(lsp->syscas)); else prmfns->memcpy (&lsp->prmfns, prmfns, ASE_SIZEOF(lsp->prmfns));
if (syscas->memset == ASE_NULL) lsp->syscas.memset = ase_lsp_memset; if (prmfns->memset == ASE_NULL) lsp->prmfns.memset = ase_lsp_memset;
if (ase_lsp_name_open(&lsp->token.name, 0, lsp) == ASE_NULL) if (ase_lsp_name_open(&lsp->token.name, 0, lsp) == ASE_NULL)
{ {

View File

@ -1,5 +1,5 @@
/* /*
* $Id: lsp.h,v 1.33 2006-10-30 14:31:37 bacon Exp $ * $Id: lsp.h,v 1.34 2007-02-01 08:49:51 bacon Exp $
*/ */
#ifndef _ASE_LSP_LSP_H_ #ifndef _ASE_LSP_LSP_H_
@ -10,41 +10,57 @@
typedef struct ase_lsp_t ase_lsp_t; typedef struct ase_lsp_t ase_lsp_t;
typedef struct ase_lsp_obj_t ase_lsp_obj_t; typedef struct ase_lsp_obj_t ase_lsp_obj_t;
typedef struct ase_lsp_syscas_t ase_lsp_syscas_t; typedef struct ase_lsp_prmfns_t ase_lsp_prmfns_t;
typedef ase_ssize_t (*ase_lsp_io_t) ( typedef ase_ssize_t (*ase_lsp_io_t) (
int cmd, void* arg, ase_char_t* data, ase_size_t count); int cmd, void* arg, ase_char_t* data, ase_size_t count);
struct ase_lsp_syscas_t typedef void* (*ase_lsp_malloc_t) (ase_size_t n, void* custom_data);
typedef void* (*ase_lsp_realloc_t) (void* ptr, ase_size_t n, void* custom_data);
typedef void (*ase_lsp_free_t) (void* ptr, void* custom_data);
typedef void* (*ase_lsp_memcpy_t) (void* dst, const void* src, ase_size_t n);
typedef void* (*ase_lsp_memset_t) (void* dst, int val, ase_size_t n);
typedef ase_bool_t (*ase_lsp_isctype_t) (ase_cint_t c);
typedef ase_cint_t (*ase_lsp_toctype_t) (ase_cint_t c);
typedef ase_real_t (*ase_lsp_pow_t) (ase_real_t x, ase_real_t y);
typedef int (*ase_lsp_sprintf_t) (
ase_char_t* buf, ase_size_t size, const ase_char_t* fmt, ...);
typedef void (*ase_lsp_aprintf_t) (const ase_char_t* fmt, ...);
typedef void (*ase_lsp_dprintf_t) (const ase_char_t* fmt, ...);
typedef void (*ase_lsp_abort_t) (void* custom_data);
struct ase_lsp_prmfns_t
{ {
/* memory */ /* memory */
void* (*malloc) (ase_size_t n, void* custom_data); ase_lsp_malloc_t malloc;
void* (*realloc) (void* ptr, ase_size_t n, void* custom_data); ase_lsp_realloc_t realloc;
void (*free) (void* ptr, void* custom_data); ase_lsp_free_t free;
ase_lsp_memcpy_t memcpy;
ase_lsp_memset_t memset;
/* character class */ /* character class */
ase_bool_t (*is_upper) (ase_cint_t c); ase_lsp_isctype_t is_upper;
ase_bool_t (*is_lower) (ase_cint_t c); ase_lsp_isctype_t is_lower;
ase_bool_t (*is_alpha) (ase_cint_t c); ase_lsp_isctype_t is_alpha;
ase_bool_t (*is_digit) (ase_cint_t c); ase_lsp_isctype_t is_digit;
ase_bool_t (*is_xdigit) (ase_cint_t c); ase_lsp_isctype_t is_xdigit;
ase_bool_t (*is_alnum) (ase_cint_t c); ase_lsp_isctype_t is_alnum;
ase_bool_t (*is_space) (ase_cint_t c); ase_lsp_isctype_t is_space;
ase_bool_t (*is_print) (ase_cint_t c); ase_lsp_isctype_t is_print;
ase_bool_t (*is_graph) (ase_cint_t c); ase_lsp_isctype_t is_graph;
ase_bool_t (*is_cntrl) (ase_cint_t c); ase_lsp_isctype_t is_cntrl;
ase_bool_t (*is_punct) (ase_cint_t c); ase_lsp_isctype_t is_punct;
ase_cint_t (*to_upper) (ase_cint_t c); ase_lsp_toctype_t to_upper;
ase_cint_t (*to_lower) (ase_cint_t c); ase_lsp_toctype_t to_lower;
/* utilities */ /* utilities */
void* (*memcpy) (void* dst, const void* src, ase_size_t n); ase_lsp_sprintf_t sprintf;
void* (*memset) (void* dst, int val, ase_size_t n); ase_lsp_aprintf_t aprintf;
ase_lsp_dprintf_t dprintf;
int (*sprintf) (ase_char_t* buf, ase_size_t size, ase_char_t* fmt, ...); ase_lsp_abort_t abort;
int (*aprintf) (ase_char_t* fmt, ...);
int (*dprintf) (ase_char_t* fmt, ...);
void (*abort) (void);
void* custom_data; void* custom_data;
}; };
@ -109,7 +125,7 @@ extern "C" {
#endif #endif
ase_lsp_t* ase_lsp_open ( ase_lsp_t* ase_lsp_open (
const ase_lsp_syscas_t* syscas, const ase_lsp_prmfns_t* prmfns,
ase_size_t mem_ubound, ase_size_t mem_ubound_inc); ase_size_t mem_ubound, ase_size_t mem_ubound_inc);
void ase_lsp_close (ase_lsp_t* lsp); void ase_lsp_close (ase_lsp_t* lsp);

View File

@ -1,5 +1,5 @@
/* /*
* $Id: lsp_i.h,v 1.5 2006-11-29 03:19:49 bacon Exp $ * $Id: lsp_i.h,v 1.6 2007-02-01 08:49:52 bacon Exp $
*/ */
#ifndef _ASE_LSP_LSPI_H_ #ifndef _ASE_LSP_LSPI_H_
@ -26,33 +26,33 @@
#define ASE_LSP_FREE(lsp,ptr) free (ptr) #define ASE_LSP_FREE(lsp,ptr) free (ptr)
#else #else
#define ASE_LSP_MALLOC(lsp,size) \ #define ASE_LSP_MALLOC(lsp,size) \
(lsp)->syscas.malloc (size, (lsp)->syscas.custom_data) (lsp)->prmfns.malloc (size, (lsp)->prmfns.custom_data)
#define ASE_LSP_REALLOC(lsp,ptr,size) \ #define ASE_LSP_REALLOC(lsp,ptr,size) \
(lsp)->syscas.realloc (ptr, size, (lsp)->syscas.custom_data) (lsp)->prmfns.realloc (ptr, size, (lsp)->prmfns.custom_data)
#define ASE_LSP_FREE(lsp,ptr) \ #define ASE_LSP_FREE(lsp,ptr) \
(lsp)->syscas.free (ptr, (lsp)->syscas.custom_data) (lsp)->prmfns.free (ptr, (lsp)->prmfns.custom_data)
#endif #endif
#define ASE_LSP_ISUPPER(lsp,c) (lsp)->syscas.is_upper(c) #define ASE_LSP_ISUPPER(lsp,c) (lsp)->prmfns.is_upper(c)
#define ASE_LSP_ISLOWER(lsp,c) (lsp)->syscas.is_lower(c) #define ASE_LSP_ISLOWER(lsp,c) (lsp)->prmfns.is_lower(c)
#define ASE_LSP_ISALPHA(lsp,c) (lsp)->syscas.is_alpha(c) #define ASE_LSP_ISALPHA(lsp,c) (lsp)->prmfns.is_alpha(c)
#define ASE_LSP_ISDIGIT(lsp,c) (lsp)->syscas.is_digit(c) #define ASE_LSP_ISDIGIT(lsp,c) (lsp)->prmfns.is_digit(c)
#define ASE_LSP_ISXDIGIT(lsp,c) (lsp)->syscas.is_xdigit(c) #define ASE_LSP_ISXDIGIT(lsp,c) (lsp)->prmfns.is_xdigit(c)
#define ASE_LSP_ISALNUM(lsp,c) (lsp)->syscas.is_alnum(c) #define ASE_LSP_ISALNUM(lsp,c) (lsp)->prmfns.is_alnum(c)
#define ASE_LSP_ISSPACE(lsp,c) (lsp)->syscas.is_space(c) #define ASE_LSP_ISSPACE(lsp,c) (lsp)->prmfns.is_space(c)
#define ASE_LSP_ISPRINT(lsp,c) (lsp)->syscas.is_print(c) #define ASE_LSP_ISPRINT(lsp,c) (lsp)->prmfns.is_print(c)
#define ASE_LSP_ISGRAPH(lsp,c) (lsp)->syscas.is_graph(c) #define ASE_LSP_ISGRAPH(lsp,c) (lsp)->prmfns.is_graph(c)
#define ASE_LSP_ISCNTRL(lsp,c) (lsp)->syscas.is_cntrl(c) #define ASE_LSP_ISCNTRL(lsp,c) (lsp)->prmfns.is_cntrl(c)
#define ASE_LSP_ISPUNCT(lsp,c) (lsp)->syscas.is_punct(c) #define ASE_LSP_ISPUNCT(lsp,c) (lsp)->prmfns.is_punct(c)
#define ASE_LSP_TOUPPER(lsp,c) (lsp)->syscas.to_upper(c) #define ASE_LSP_TOUPPER(lsp,c) (lsp)->prmfns.to_upper(c)
#define ASE_LSP_TOLOWER(lsp,c) (lsp)->syscas.to_lower(c) #define ASE_LSP_TOLOWER(lsp,c) (lsp)->prmfns.to_lower(c)
#define ASE_LSP_MEMCPY(lsp,dst,src,len) (lsp)->syscas.memcpy (dst, src, len) #define ASE_LSP_MEMCPY(lsp,dst,src,len) (lsp)->prmfns.memcpy (dst, src, len)
#define ASE_LSP_MEMSET(lsp,dst,val,len) (lsp)->syscas.memset (dst, val, len) #define ASE_LSP_MEMSET(lsp,dst,val,len) (lsp)->prmfns.memset (dst, val, len)
struct ase_lsp_t struct ase_lsp_t
{ {
ase_lsp_syscas_t syscas; ase_lsp_prmfns_t prmfns;
/* error number */ /* error number */
int errnum; int errnum;

View File

@ -1,5 +1,5 @@
/* /*
* $Id: misc.c,v 1.6 2006-11-29 02:54:17 bacon Exp $ * $Id: misc.c,v 1.7 2007-02-01 08:49:52 bacon Exp $
*/ */
#include <ase/lsp/lsp_i.h> #include <ase/lsp/lsp_i.h>
@ -756,16 +756,16 @@ int ase_lsp_assertfail (ase_lsp_t* lsp,
{ {
if (desc == ASE_NULL) if (desc == ASE_NULL)
{ {
lsp->syscas.aprintf ( lsp->prmfns.aprintf (
ASE_T("ASSERTION FAILURE AT FILE %s LINE %d\n%s\n"), ASE_T("ASSERTION FAILURE AT FILE %s LINE %d\n%s\n"),
file, line, expr); file, line, expr);
} }
else else
{ {
lsp->syscas.aprintf ( lsp->prmfns.aprintf (
ASE_T("ASSERTION FAILURE AT FILE %s LINE %d\n%s\n\nDESCRIPTION:\n%s\n"), ASE_T("ASSERTION FAILURE AT FILE %s LINE %d\n%s\n\nDESCRIPTION:\n%s\n"),
file, line, expr, desc); file, line, expr, desc);
} }
lsp->syscas.abort (); lsp->prmfns.abort (lsp);
return 0; return 0;
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: print.c,v 1.19 2006-11-29 02:54:17 bacon Exp $ * $Id: print.c,v 1.20 2007-02-01 08:49:52 bacon Exp $
*/ */
#include <ase/lsp/lsp_i.h> #include <ase/lsp/lsp_i.h>
@ -42,15 +42,15 @@ static int __print (ase_lsp_t* lsp, const ase_lsp_obj_t* obj, ase_bool_t prt_con
case ASE_LSP_OBJ_INT: case ASE_LSP_OBJ_INT:
#if defined(__BORLANDC__) || defined(_MSC_VER) #if defined(__BORLANDC__) || defined(_MSC_VER)
lsp->syscas.sprintf ( lsp->prmfns.sprintf (
buf, ASE_COUNTOF(buf), buf, ASE_COUNTOF(buf),
ASE_T("%I64d"), (__int64)ASE_LSP_IVAL(obj)); ASE_T("%I64d"), (__int64)ASE_LSP_IVAL(obj));
#elif defined(vax) || defined(__vax) || defined(_SCO_DS) #elif defined(vax) || defined(__vax) || defined(_SCO_DS)
lsp->syscas.sprintf ( lsp->prmfns.sprintf (
buf, ASE_COUNTOF(buf), buf, ASE_COUNTOF(buf),
ASE_T("%ld"), (long)ASE_LSP_IVAL(obj)); ASE_T("%ld"), (long)ASE_LSP_IVAL(obj));
#else #else
lsp->syscas.sprintf ( lsp->prmfns.sprintf (
buf, ASE_COUNTOF(buf), buf, ASE_COUNTOF(buf),
ASE_T("%lld"), (long long)ASE_LSP_IVAL(obj)); ASE_T("%lld"), (long long)ASE_LSP_IVAL(obj));
#endif #endif
@ -58,7 +58,7 @@ static int __print (ase_lsp_t* lsp, const ase_lsp_obj_t* obj, ase_bool_t prt_con
break; break;
case ASE_LSP_OBJ_REAL: case ASE_LSP_OBJ_REAL:
lsp->syscas.sprintf (buf, ASE_COUNTOF(buf), lsp->prmfns.sprintf (buf, ASE_COUNTOF(buf),
ASE_T("%Lf"), (long double)ASE_LSP_RVAL(obj)); ASE_T("%Lf"), (long double)ASE_LSP_RVAL(obj));
OUTPUT_STR (lsp, buf); OUTPUT_STR (lsp, buf);
@ -117,7 +117,7 @@ static int __print (ase_lsp_t* lsp, const ase_lsp_obj_t* obj, ase_bool_t prt_con
break; break;
default: default:
lsp->syscas.sprintf (buf, ASE_COUNTOF(buf), lsp->prmfns.sprintf (buf, ASE_COUNTOF(buf),
ASE_T("unknown object type: %d"), ASE_LSP_TYPE(obj)); ASE_T("unknown object type: %d"), ASE_LSP_TYPE(obj));
OUTPUT_STR (lsp, buf); OUTPUT_STR (lsp, buf);
} }

View File

@ -1,9 +1,6 @@
#include <ase/lsp/lsp.h> #include <ase/lsp/lsp.h>
#include <xp/bas/stdio.h> #include "../etc/printf.h"
#include <xp/bas/ctype.h> #include "../etc/main.h"
#include <xp/bas/stdcli.h>
#include <xp/bas/locale.h>
#include <xp/bas/sio.h>
#ifdef _WIN32 #ifdef _WIN32
#include <tchar.h> #include <tchar.h>
@ -170,44 +167,63 @@ static void __lsp_free (void* ptr, void* custom_data)
#endif #endif
} }
static int __aprintf (const xp_char_t* fmt, ...) static void lsp_abort (void* custom_data)
{
abort ();
}
static int lsp_sprintf (
ase_char_t* buf, ase_size_t len, const ase_char_t* fmt, ...)
{ {
int n; int n;
va_list ap; va_list ap;
#ifdef _WIN32
xp_char_t buf[1024];
#endif
va_start (ap, fmt); va_start (ap, fmt);
#ifdef _WIN32 n = ase_vsprintf (buf, len, fmt, ap);
n = xp_vsprintf (buf, xp_countof(buf), fmt, ap);
#if defined(_MSC_VER) && (_MSC_VER>=1400)
MessageBox (NULL, buf, ASE_T("\uD655\uC778\uC2E4\uD328 Assertion Failure"), MB_OK | MB_ICONERROR);
#else
MessageBox (NULL, buf, ASE_T("Assertion Failure"), MB_OK | MB_ICONERROR);
#endif
#else
n = xp_vprintf (fmt, ap);
#endif
va_end (ap); va_end (ap);
return n; return n;
} }
static int __dprintf (const ase_char_t* fmt, ...) static void lsp_aprintf (const ase_char_t* fmt, ...)
{ {
int n;
va_list ap; va_list ap;
va_start (ap, fmt);
#ifdef _WIN32 #ifdef _WIN32
n = _vftprintf (stderr, fmt, ap); int n;
#else ase_char_t buf[1024];
n = xp_vfprintf (stderr, fmt, ap);
#endif #endif
va_start (ap, fmt);
#if defined(_WIN32)
n = _vsntprintf (buf, ASE_COUNTOF(buf), fmt, ap);
if (n < 0) buf[ASE_COUNTOF(buf)-1] = ASE_T('\0');
#if defined(_MSC_VER) && (_MSC_VER<1400)
MessageBox (NULL, buf,
ASE_T("Assertion Failure"), MB_OK|MB_ICONERROR);
#else
MessageBox (NULL, buf,
ASE_T("\uB2DD\uAE30\uB9AC \uC870\uB610"), MB_OK|MB_ICONERROR);
#endif
#else
ase_vprintf (fmt, ap);
#endif
va_end (ap);
}
static void lsp_dprintf (const ase_char_t* fmt, ...)
{
va_list ap;
va_start (ap, fmt);
ase_vfprintf (stderr, fmt, ap);
va_end (ap);
}
static void lsp_printf (const ase_char_t* fmt, ...)
{
va_list ap;
va_start (ap, fmt);
ase_vprintf (fmt, ap);
va_end (ap); va_end (ap);
return n;
} }
int __main (int argc, xp_char_t* argv[]) int __main (int argc, xp_char_t* argv[])
@ -280,15 +296,15 @@ int __main (int argc, xp_char_t* argv[])
syscas.memcpy = memcpy; syscas.memcpy = memcpy;
syscas.memset = memset; syscas.memset = memset;
syscas.sprintf = xp_sprintf; syscas.sprintf = xp_sprintf;
syscas.aprintf = __aprintf; syscas.aprintf = lsp_aprintf;
syscas.dprintf = __dprintf; syscas.dprintf = lsp_dprintf;
syscas.abort = abort; syscas.abort = lsp_abort;
#ifdef _WIN32 #ifdef _WIN32
syscas_data.heap = HeapCreate (0, 1000000, 1000000); syscas_data.heap = HeapCreate (0, 1000000, 1000000);
if (syscas_data.heap == NULL) if (syscas_data.heap == NULL)
{ {
xp_printf (ASE_T("Error: cannot create an awk heap\n")); xp_printf (ASE_T("Error: cannot create an lsp heap\n"));
return -1; return -1;
} }