*** 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
CFLAGS = /pointer_size=long /include="../.." /define=XP_AWK_STAND_ALONE
CFLAGS = /pointer_size=long /include="../.."
LIBRFLAGS =
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__)
@ -12,41 +12,41 @@
static int __add_builtin_prims (ase_lsp_t* lsp);
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_lsp_t* lsp;
if (syscas == ASE_NULL) return ASE_NULL;
if (prmfns == ASE_NULL) return ASE_NULL;
if (syscas->malloc == ASE_NULL ||
syscas->realloc == ASE_NULL ||
syscas->free == ASE_NULL) return ASE_NULL;
if (prmfns->malloc == ASE_NULL ||
prmfns->realloc == ASE_NULL ||
prmfns->free == ASE_NULL) return ASE_NULL;
if (syscas->is_upper == ASE_NULL ||
syscas->is_lower == ASE_NULL ||
syscas->is_alpha == ASE_NULL ||
syscas->is_digit == ASE_NULL ||
syscas->is_xdigit == ASE_NULL ||
syscas->is_alnum == ASE_NULL ||
syscas->is_space == ASE_NULL ||
syscas->is_print == ASE_NULL ||
syscas->is_graph == ASE_NULL ||
syscas->is_cntrl == ASE_NULL ||
syscas->is_punct == ASE_NULL ||
syscas->to_upper == ASE_NULL ||
syscas->to_lower == ASE_NULL) return ASE_NULL;
if (prmfns->is_upper == ASE_NULL ||
prmfns->is_lower == ASE_NULL ||
prmfns->is_alpha == ASE_NULL ||
prmfns->is_digit == ASE_NULL ||
prmfns->is_xdigit == ASE_NULL ||
prmfns->is_alnum == ASE_NULL ||
prmfns->is_space == ASE_NULL ||
prmfns->is_print == ASE_NULL ||
prmfns->is_graph == ASE_NULL ||
prmfns->is_cntrl == ASE_NULL ||
prmfns->is_punct == ASE_NULL ||
prmfns->to_upper == ASE_NULL ||
prmfns->to_lower == ASE_NULL) return ASE_NULL;
if (syscas->sprintf == ASE_NULL ||
syscas->aprintf == ASE_NULL ||
syscas->dprintf == ASE_NULL ||
syscas->abort == ASE_NULL) return ASE_NULL;
if (prmfns->sprintf == ASE_NULL ||
prmfns->aprintf == ASE_NULL ||
prmfns->dprintf == ASE_NULL ||
prmfns->abort == ASE_NULL) return ASE_NULL;
#if defined(_WIN32) && defined(_MSC_VER) && defined(_DEBUG)
lsp = (ase_lsp_t*) malloc (ASE_SIZEOF(ase_lsp_t));
#else
lsp = (ase_lsp_t*) syscas->malloc (
ASE_SIZEOF(ase_lsp_t), syscas->custom_data);
lsp = (ase_lsp_t*) prmfns->malloc (
ASE_SIZEOF(ase_lsp_t), prmfns->custom_data);
#endif
if (lsp == ASE_NULL) return ASE_NULL;
@ -54,13 +54,13 @@ ase_lsp_t* ase_lsp_open (
* fully initialized yet */
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));
lsp->syscas.memcpy = ase_lsp_memcpy;
ase_lsp_memcpy (&lsp->prmfns, prmfns, ASE_SIZEOF(lsp->prmfns));
lsp->prmfns.memcpy = ase_lsp_memcpy;
}
else syscas->memcpy (&lsp->syscas, syscas, ASE_SIZEOF(lsp->syscas));
if (syscas->memset == ASE_NULL) lsp->syscas.memset = ase_lsp_memset;
else prmfns->memcpy (&lsp->prmfns, prmfns, ASE_SIZEOF(lsp->prmfns));
if (prmfns->memset == ASE_NULL) lsp->prmfns.memset = ase_lsp_memset;
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_
@ -10,41 +10,57 @@
typedef struct ase_lsp_t ase_lsp_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) (
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 */
void* (*malloc) (ase_size_t n, void* custom_data);
void* (*realloc) (void* ptr, ase_size_t n, void* custom_data);
void (*free) (void* ptr, void* custom_data);
ase_lsp_malloc_t malloc;
ase_lsp_realloc_t realloc;
ase_lsp_free_t free;
ase_lsp_memcpy_t memcpy;
ase_lsp_memset_t memset;
/* character class */
ase_bool_t (*is_upper) (ase_cint_t c);
ase_bool_t (*is_lower) (ase_cint_t c);
ase_bool_t (*is_alpha) (ase_cint_t c);
ase_bool_t (*is_digit) (ase_cint_t c);
ase_bool_t (*is_xdigit) (ase_cint_t c);
ase_bool_t (*is_alnum) (ase_cint_t c);
ase_bool_t (*is_space) (ase_cint_t c);
ase_bool_t (*is_print) (ase_cint_t c);
ase_bool_t (*is_graph) (ase_cint_t c);
ase_bool_t (*is_cntrl) (ase_cint_t c);
ase_bool_t (*is_punct) (ase_cint_t c);
ase_cint_t (*to_upper) (ase_cint_t c);
ase_cint_t (*to_lower) (ase_cint_t c);
ase_lsp_isctype_t is_upper;
ase_lsp_isctype_t is_lower;
ase_lsp_isctype_t is_alpha;
ase_lsp_isctype_t is_digit;
ase_lsp_isctype_t is_xdigit;
ase_lsp_isctype_t is_alnum;
ase_lsp_isctype_t is_space;
ase_lsp_isctype_t is_print;
ase_lsp_isctype_t is_graph;
ase_lsp_isctype_t is_cntrl;
ase_lsp_isctype_t is_punct;
ase_lsp_toctype_t to_upper;
ase_lsp_toctype_t to_lower;
/* utilities */
void* (*memcpy) (void* dst, const void* src, ase_size_t n);
void* (*memset) (void* dst, int val, ase_size_t n);
int (*sprintf) (ase_char_t* buf, ase_size_t size, ase_char_t* fmt, ...);
int (*aprintf) (ase_char_t* fmt, ...);
int (*dprintf) (ase_char_t* fmt, ...);
void (*abort) (void);
ase_lsp_sprintf_t sprintf;
ase_lsp_aprintf_t aprintf;
ase_lsp_dprintf_t dprintf;
ase_lsp_abort_t abort;
void* custom_data;
};
@ -109,7 +125,7 @@ extern "C" {
#endif
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);
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_
@ -26,33 +26,33 @@
#define ASE_LSP_FREE(lsp,ptr) free (ptr)
#else
#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) \
(lsp)->syscas.realloc (ptr, size, (lsp)->syscas.custom_data)
(lsp)->prmfns.realloc (ptr, size, (lsp)->prmfns.custom_data)
#define ASE_LSP_FREE(lsp,ptr) \
(lsp)->syscas.free (ptr, (lsp)->syscas.custom_data)
(lsp)->prmfns.free (ptr, (lsp)->prmfns.custom_data)
#endif
#define ASE_LSP_ISUPPER(lsp,c) (lsp)->syscas.is_upper(c)
#define ASE_LSP_ISLOWER(lsp,c) (lsp)->syscas.is_lower(c)
#define ASE_LSP_ISALPHA(lsp,c) (lsp)->syscas.is_alpha(c)
#define ASE_LSP_ISDIGIT(lsp,c) (lsp)->syscas.is_digit(c)
#define ASE_LSP_ISXDIGIT(lsp,c) (lsp)->syscas.is_xdigit(c)
#define ASE_LSP_ISALNUM(lsp,c) (lsp)->syscas.is_alnum(c)
#define ASE_LSP_ISSPACE(lsp,c) (lsp)->syscas.is_space(c)
#define ASE_LSP_ISPRINT(lsp,c) (lsp)->syscas.is_print(c)
#define ASE_LSP_ISGRAPH(lsp,c) (lsp)->syscas.is_graph(c)
#define ASE_LSP_ISCNTRL(lsp,c) (lsp)->syscas.is_cntrl(c)
#define ASE_LSP_ISPUNCT(lsp,c) (lsp)->syscas.is_punct(c)
#define ASE_LSP_TOUPPER(lsp,c) (lsp)->syscas.to_upper(c)
#define ASE_LSP_TOLOWER(lsp,c) (lsp)->syscas.to_lower(c)
#define ASE_LSP_ISUPPER(lsp,c) (lsp)->prmfns.is_upper(c)
#define ASE_LSP_ISLOWER(lsp,c) (lsp)->prmfns.is_lower(c)
#define ASE_LSP_ISALPHA(lsp,c) (lsp)->prmfns.is_alpha(c)
#define ASE_LSP_ISDIGIT(lsp,c) (lsp)->prmfns.is_digit(c)
#define ASE_LSP_ISXDIGIT(lsp,c) (lsp)->prmfns.is_xdigit(c)
#define ASE_LSP_ISALNUM(lsp,c) (lsp)->prmfns.is_alnum(c)
#define ASE_LSP_ISSPACE(lsp,c) (lsp)->prmfns.is_space(c)
#define ASE_LSP_ISPRINT(lsp,c) (lsp)->prmfns.is_print(c)
#define ASE_LSP_ISGRAPH(lsp,c) (lsp)->prmfns.is_graph(c)
#define ASE_LSP_ISCNTRL(lsp,c) (lsp)->prmfns.is_cntrl(c)
#define ASE_LSP_ISPUNCT(lsp,c) (lsp)->prmfns.is_punct(c)
#define ASE_LSP_TOUPPER(lsp,c) (lsp)->prmfns.to_upper(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_MEMSET(lsp,dst,val,len) (lsp)->syscas.memset (dst, val, len)
#define ASE_LSP_MEMCPY(lsp,dst,src,len) (lsp)->prmfns.memcpy (dst, src, len)
#define ASE_LSP_MEMSET(lsp,dst,val,len) (lsp)->prmfns.memset (dst, val, len)
struct ase_lsp_t
{
ase_lsp_syscas_t syscas;
ase_lsp_prmfns_t prmfns;
/* error number */
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>
@ -756,16 +756,16 @@ int ase_lsp_assertfail (ase_lsp_t* lsp,
{
if (desc == ASE_NULL)
{
lsp->syscas.aprintf (
lsp->prmfns.aprintf (
ASE_T("ASSERTION FAILURE AT FILE %s LINE %d\n%s\n"),
file, line, expr);
}
else
{
lsp->syscas.aprintf (
lsp->prmfns.aprintf (
ASE_T("ASSERTION FAILURE AT FILE %s LINE %d\n%s\n\nDESCRIPTION:\n%s\n"),
file, line, expr, desc);
}
lsp->syscas.abort ();
lsp->prmfns.abort (lsp);
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>
@ -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:
#if defined(__BORLANDC__) || defined(_MSC_VER)
lsp->syscas.sprintf (
lsp->prmfns.sprintf (
buf, ASE_COUNTOF(buf),
ASE_T("%I64d"), (__int64)ASE_LSP_IVAL(obj));
#elif defined(vax) || defined(__vax) || defined(_SCO_DS)
lsp->syscas.sprintf (
lsp->prmfns.sprintf (
buf, ASE_COUNTOF(buf),
ASE_T("%ld"), (long)ASE_LSP_IVAL(obj));
#else
lsp->syscas.sprintf (
lsp->prmfns.sprintf (
buf, ASE_COUNTOF(buf),
ASE_T("%lld"), (long long)ASE_LSP_IVAL(obj));
#endif
@ -58,7 +58,7 @@ static int __print (ase_lsp_t* lsp, const ase_lsp_obj_t* obj, ase_bool_t prt_con
break;
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));
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;
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));
OUTPUT_STR (lsp, buf);
}

View File

@ -1,9 +1,6 @@
#include <ase/lsp/lsp.h>
#include <xp/bas/stdio.h>
#include <xp/bas/ctype.h>
#include <xp/bas/stdcli.h>
#include <xp/bas/locale.h>
#include <xp/bas/sio.h>
#include "../etc/printf.h"
#include "../etc/main.h"
#ifdef _WIN32
#include <tchar.h>
@ -170,44 +167,63 @@ static void __lsp_free (void* ptr, void* custom_data)
#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;
va_list ap;
#ifdef _WIN32
xp_char_t buf[1024];
#endif
va_start (ap, fmt);
#ifdef _WIN32
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
n = ase_vsprintf (buf, len, fmt, ap);
va_end (ap);
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_start (ap, fmt);
#ifdef _WIN32
n = _vftprintf (stderr, fmt, ap);
#else
n = xp_vfprintf (stderr, fmt, ap);
int n;
ase_char_t buf[1024];
#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);
return n;
}
int __main (int argc, xp_char_t* argv[])
@ -280,15 +296,15 @@ int __main (int argc, xp_char_t* argv[])
syscas.memcpy = memcpy;
syscas.memset = memset;
syscas.sprintf = xp_sprintf;
syscas.aprintf = __aprintf;
syscas.dprintf = __dprintf;
syscas.abort = abort;
syscas.aprintf = lsp_aprintf;
syscas.dprintf = lsp_dprintf;
syscas.abort = lsp_abort;
#ifdef _WIN32
syscas_data.heap = HeapCreate (0, 1000000, 1000000);
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;
}