*** empty log message ***
This commit is contained in:
parent
5d25996764
commit
1804fd92b0
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: rex.c,v 1.67 2007-02-23 10:33:20 bacon Exp $
|
* $Id: rex.c,v 1.68 2007-02-23 10:57:09 bacon Exp $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -139,13 +139,13 @@ typedef const ase_byte_t* (*atom_matcher_t) (
|
|||||||
#define ADD_CODE(rex,data,len) \
|
#define ADD_CODE(rex,data,len) \
|
||||||
do { if (__add_code(rex,data,len) == -1) return -1; } while (0)
|
do { if (__add_code(rex,data,len) == -1) return -1; } while (0)
|
||||||
|
|
||||||
/* #if defined(__sparc) || defined(__sparc__)
|
#if defined(__sparc) || defined(__sparc__)
|
||||||
#define GET_CODE(rex,pos,type) __get_code(rex,pos)
|
#define GET_CODE(rex,pos,type) __get_code(rex,pos)
|
||||||
#define SET_CODE(rex,pos,type,code) __set_code(rex,pos,code)
|
#define SET_CODE(rex,pos,type,code) __set_code(rex,pos,code)
|
||||||
#else */
|
#else
|
||||||
#define GET_CODE(rex,pos,type) (*((type*)&(rex)->code.buf[pos]))
|
#define GET_CODE(rex,pos,type) (*((type*)&(rex)->code.buf[pos]))
|
||||||
#define SET_CODE(rex,pos,type,code) (GET_CODE(rex,pos,type) = (code))
|
#define SET_CODE(rex,pos,type,code) (GET_CODE(rex,pos,type) = (code))
|
||||||
/* #endif */
|
#endif
|
||||||
|
|
||||||
static int __build_pattern (__builder_t* rex);
|
static int __build_pattern (__builder_t* rex);
|
||||||
static int __build_pattern0 (__builder_t* rex);
|
static int __build_pattern0 (__builder_t* rex);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: err.c,v 1.11 2007-02-11 07:36:54 bacon Exp $
|
* $Id: err.c,v 1.12 2007-02-23 10:53:38 bacon Exp $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -63,14 +63,14 @@ void ase_lsp_seterror (
|
|||||||
switch (argcnt)
|
switch (argcnt)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
lsp->prmfns.sprintf (
|
lsp->prmfns.misc.sprintf (
|
||||||
lsp->errmsg,
|
lsp->errmsg,
|
||||||
ASE_COUNTOF(lsp->errmsg),
|
ASE_COUNTOF(lsp->errmsg),
|
||||||
errfmt);
|
errfmt);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
lsp->prmfns.sprintf (
|
lsp->prmfns.misc.sprintf (
|
||||||
lsp->errmsg,
|
lsp->errmsg,
|
||||||
ASE_COUNTOF(lsp->errmsg),
|
ASE_COUNTOF(lsp->errmsg),
|
||||||
errfmt,
|
errfmt,
|
||||||
@ -78,7 +78,7 @@ void ase_lsp_seterror (
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
lsp->prmfns.sprintf (
|
lsp->prmfns.misc.sprintf (
|
||||||
lsp->errmsg,
|
lsp->errmsg,
|
||||||
ASE_COUNTOF(lsp->errmsg),
|
ASE_COUNTOF(lsp->errmsg),
|
||||||
errfmt,
|
errfmt,
|
||||||
@ -87,7 +87,7 @@ void ase_lsp_seterror (
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
lsp->prmfns.sprintf (
|
lsp->prmfns.misc.sprintf (
|
||||||
lsp->errmsg,
|
lsp->errmsg,
|
||||||
ASE_COUNTOF(lsp->errmsg),
|
ASE_COUNTOF(lsp->errmsg),
|
||||||
errfmt,
|
errfmt,
|
||||||
@ -97,7 +97,7 @@ void ase_lsp_seterror (
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
lsp->prmfns.sprintf (
|
lsp->prmfns.misc.sprintf (
|
||||||
lsp->errmsg,
|
lsp->errmsg,
|
||||||
ASE_COUNTOF(lsp->errmsg),
|
ASE_COUNTOF(lsp->errmsg),
|
||||||
errfmt,
|
errfmt,
|
||||||
@ -108,7 +108,7 @@ void ase_lsp_seterror (
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
case 5:
|
case 5:
|
||||||
lsp->prmfns.sprintf (
|
lsp->prmfns.misc.sprintf (
|
||||||
lsp->errmsg,
|
lsp->errmsg,
|
||||||
ASE_COUNTOF(lsp->errmsg),
|
ASE_COUNTOF(lsp->errmsg),
|
||||||
errfmt,
|
errfmt,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: lsp.c,v 1.24 2007-02-13 06:00:20 bacon Exp $
|
* $Id: lsp.c,v 1.25 2007-02-23 10:53:38 bacon Exp $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -21,48 +21,41 @@ ase_lsp_t* ase_lsp_open (
|
|||||||
|
|
||||||
if (prmfns == ASE_NULL) return ASE_NULL;
|
if (prmfns == ASE_NULL) return ASE_NULL;
|
||||||
|
|
||||||
if (prmfns->malloc == ASE_NULL ||
|
if (prmfns->mmgr.malloc == ASE_NULL ||
|
||||||
prmfns->realloc == ASE_NULL ||
|
prmfns->mmgr.realloc == ASE_NULL ||
|
||||||
prmfns->free == ASE_NULL) return ASE_NULL;
|
prmfns->mmgr.free == ASE_NULL) return ASE_NULL;
|
||||||
|
|
||||||
if (prmfns->is_upper == ASE_NULL ||
|
if (prmfns->ccls.is_upper == ASE_NULL ||
|
||||||
prmfns->is_lower == ASE_NULL ||
|
prmfns->ccls.is_lower == ASE_NULL ||
|
||||||
prmfns->is_alpha == ASE_NULL ||
|
prmfns->ccls.is_alpha == ASE_NULL ||
|
||||||
prmfns->is_digit == ASE_NULL ||
|
prmfns->ccls.is_digit == ASE_NULL ||
|
||||||
prmfns->is_xdigit == ASE_NULL ||
|
prmfns->ccls.is_xdigit == ASE_NULL ||
|
||||||
prmfns->is_alnum == ASE_NULL ||
|
prmfns->ccls.is_alnum == ASE_NULL ||
|
||||||
prmfns->is_space == ASE_NULL ||
|
prmfns->ccls.is_space == ASE_NULL ||
|
||||||
prmfns->is_print == ASE_NULL ||
|
prmfns->ccls.is_print == ASE_NULL ||
|
||||||
prmfns->is_graph == ASE_NULL ||
|
prmfns->ccls.is_graph == ASE_NULL ||
|
||||||
prmfns->is_cntrl == ASE_NULL ||
|
prmfns->ccls.is_cntrl == ASE_NULL ||
|
||||||
prmfns->is_punct == ASE_NULL ||
|
prmfns->ccls.is_punct == ASE_NULL ||
|
||||||
prmfns->to_upper == ASE_NULL ||
|
prmfns->ccls.to_upper == ASE_NULL ||
|
||||||
prmfns->to_lower == ASE_NULL) return ASE_NULL;
|
prmfns->ccls.to_lower == ASE_NULL) return ASE_NULL;
|
||||||
|
|
||||||
if (prmfns->sprintf == ASE_NULL ||
|
if (prmfns->misc.sprintf == ASE_NULL ||
|
||||||
prmfns->aprintf == ASE_NULL ||
|
prmfns->misc.aprintf == ASE_NULL ||
|
||||||
prmfns->dprintf == ASE_NULL ||
|
prmfns->misc.dprintf == ASE_NULL ||
|
||||||
prmfns->abort == ASE_NULL) return ASE_NULL;
|
prmfns->misc.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*) prmfns->malloc (
|
lsp = (ase_lsp_t*) prmfns->mmgr.malloc (
|
||||||
ASE_SIZEOF(ase_lsp_t), prmfns->custom_data);
|
&prmfns->mmgr, ASE_SIZEOF(ase_lsp_t));
|
||||||
#endif
|
#endif
|
||||||
if (lsp == ASE_NULL) return ASE_NULL;
|
if (lsp == ASE_NULL) return ASE_NULL;
|
||||||
|
|
||||||
/* it uses the built-in ase_lsp_memset because lsp is not
|
/* it uses the built-in ase_lsp_memset because lsp is not
|
||||||
* fully initialized yet */
|
* fully initialized yet */
|
||||||
ase_lsp_memset (lsp, 0, ASE_SIZEOF(ase_lsp_t));
|
ase_memset (lsp, 0, ASE_SIZEOF(ase_lsp_t));
|
||||||
|
ase_memcpy (&lsp->prmfns, prmfns, ASE_SIZEOF(lsp->prmfns));
|
||||||
if (prmfns->memcpy == ASE_NULL)
|
|
||||||
{
|
|
||||||
ase_lsp_memcpy (&lsp->prmfns, prmfns, ASE_SIZEOF(lsp->prmfns));
|
|
||||||
lsp->prmfns.memcpy = ase_lsp_memcpy;
|
|
||||||
}
|
|
||||||
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)
|
if (ase_lsp_name_open(&lsp->token.name, 0, lsp) == ASE_NULL)
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: lsp.h,v 1.38 2007-02-11 08:30:18 bacon Exp $
|
* $Id: lsp.h,v 1.39 2007-02-23 10:53:38 bacon Exp $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -17,14 +17,6 @@ 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);
|
||||||
|
|
||||||
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 ase_real_t (*ase_lsp_pow_t) (ase_real_t x, ase_real_t y);
|
||||||
|
|
||||||
typedef int (*ase_lsp_sprintf_t) (
|
typedef int (*ase_lsp_sprintf_t) (
|
||||||
@ -35,36 +27,19 @@ typedef void (*ase_lsp_abort_t) (void* custom_data);
|
|||||||
|
|
||||||
struct ase_lsp_prmfns_t
|
struct ase_lsp_prmfns_t
|
||||||
{
|
{
|
||||||
/* memory */
|
ase_mmgr_t mmgr;
|
||||||
ase_lsp_malloc_t malloc;
|
ase_ccls_t ccls;
|
||||||
ase_lsp_realloc_t realloc;
|
|
||||||
ase_lsp_free_t free;
|
|
||||||
|
|
||||||
ase_lsp_memcpy_t memcpy;
|
|
||||||
ase_lsp_memset_t memset;
|
|
||||||
|
|
||||||
/* character class */
|
|
||||||
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 */
|
/* utilities */
|
||||||
ase_lsp_sprintf_t sprintf;
|
struct
|
||||||
ase_lsp_aprintf_t aprintf;
|
{
|
||||||
ase_lsp_dprintf_t dprintf;
|
ase_lsp_sprintf_t sprintf;
|
||||||
ase_lsp_abort_t abort;
|
ase_lsp_aprintf_t aprintf;
|
||||||
|
ase_lsp_dprintf_t dprintf;
|
||||||
|
ase_lsp_abort_t abort;
|
||||||
|
void* custom_data;
|
||||||
|
} misc;
|
||||||
|
|
||||||
void* custom_data;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* io function commands */
|
/* io function commands */
|
||||||
@ -156,34 +131,6 @@ int ase_lsp_addprim (
|
|||||||
ase_lsp_prim_t prim, ase_size_t min_args, ase_size_t max_args);
|
ase_lsp_prim_t prim, ase_size_t min_args, ase_size_t max_args);
|
||||||
int ase_lsp_removeprim (ase_lsp_t* lsp, const ase_char_t* name);
|
int ase_lsp_removeprim (ase_lsp_t* lsp, const ase_char_t* name);
|
||||||
|
|
||||||
/* string functions exported by lsp.h */
|
|
||||||
ase_char_t* ase_lsp_strdup (ase_lsp_t* lsp, const ase_char_t* str);
|
|
||||||
ase_char_t* ase_lsp_strxdup (
|
|
||||||
ase_lsp_t* lsp, const ase_char_t* str, ase_size_t len);
|
|
||||||
ase_char_t* ase_lsp_strxdup2 (
|
|
||||||
ase_lsp_t* lsp,
|
|
||||||
const ase_char_t* str1, ase_size_t len1,
|
|
||||||
const ase_char_t* str2, ase_size_t len2);
|
|
||||||
|
|
||||||
ase_size_t ase_lsp_strlen (const ase_char_t* str);
|
|
||||||
ase_size_t ase_lsp_strcpy (ase_char_t* buf, const ase_char_t* str);
|
|
||||||
ase_size_t ase_lsp_strncpy (ase_char_t* buf, const ase_char_t* str, ase_size_t len);
|
|
||||||
int ase_lsp_strcmp (const ase_char_t* s1, const ase_char_t* s2);
|
|
||||||
|
|
||||||
int ase_lsp_strxncmp (
|
|
||||||
const ase_char_t* s1, ase_size_t len1,
|
|
||||||
const ase_char_t* s2, ase_size_t len2);
|
|
||||||
|
|
||||||
int ase_lsp_strxncasecmp (
|
|
||||||
ase_lsp_t* lsp,
|
|
||||||
const ase_char_t* s1, ase_size_t len1,
|
|
||||||
const ase_char_t* s2, ase_size_t len2);
|
|
||||||
|
|
||||||
ase_char_t* ase_lsp_strxnstr (
|
|
||||||
const ase_char_t* str, ase_size_t strsz,
|
|
||||||
const ase_char_t* sub, ase_size_t subsz);
|
|
||||||
|
|
||||||
|
|
||||||
/* abort function for assertion. use ASE_LSP_ASSERT instead */
|
/* abort function for assertion. use ASE_LSP_ASSERT instead */
|
||||||
int ase_lsp_assertfail (ase_lsp_t* lsp,
|
int ase_lsp_assertfail (ase_lsp_t* lsp,
|
||||||
const ase_char_t* expr, const ase_char_t* desc,
|
const ase_char_t* expr, const ase_char_t* desc,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: lsp_i.h,v 1.8 2007-02-11 07:36:55 bacon Exp $
|
* $Id: lsp_i.h,v 1.9 2007-02-23 10:53:38 bacon Exp $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -7,6 +7,9 @@
|
|||||||
#ifndef _ASE_LSP_LSPI_H_
|
#ifndef _ASE_LSP_LSPI_H_
|
||||||
#define _ASE_LSP_LSPI_H_
|
#define _ASE_LSP_LSPI_H_
|
||||||
|
|
||||||
|
#include <ase/cmn/mem.h>
|
||||||
|
#include <ase/cmn/str.h>
|
||||||
|
|
||||||
#include <ase/lsp/lsp.h>
|
#include <ase/lsp/lsp.h>
|
||||||
#include <ase/lsp/env.h>
|
#include <ase/lsp/env.h>
|
||||||
#include <ase/lsp/obj.h>
|
#include <ase/lsp/obj.h>
|
||||||
@ -19,38 +22,24 @@
|
|||||||
#pragma warning (disable: 4996)
|
#pragma warning (disable: 4996)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN32) && defined(_MSC_VER) && defined(_DEBUG)
|
|
||||||
#define _CRTDBG_MAP_ALLOC
|
|
||||||
#include <crtdbg.h>
|
|
||||||
|
|
||||||
#define ASE_LSP_MALLOC(lsp,size) malloc (size)
|
#define ASE_LSP_MALLOC(lsp,size) ASE_MALLOC(&(lsp)->prmfns.mmgr,size)
|
||||||
#define ASE_LSP_REALLOC(lsp,ptr,size) realloc (ptr, size)
|
#define ASE_LSP_REALLOC(lsp,ptr,size) ASE_REALLOC(&(lsp)->prmfns.mmgr,ptr,size)
|
||||||
#define ASE_LSP_FREE(lsp,ptr) free (ptr)
|
#define ASE_LSP_FREE(lsp,ptr) ASE_FREE(&(lsp)->prmfns.mmgr,ptr)
|
||||||
#else
|
|
||||||
#define ASE_LSP_MALLOC(lsp,size) \
|
|
||||||
(lsp)->prmfns.malloc (size, (lsp)->prmfns.custom_data)
|
|
||||||
#define ASE_LSP_REALLOC(lsp,ptr,size) \
|
|
||||||
(lsp)->prmfns.realloc (ptr, size, (lsp)->prmfns.custom_data)
|
|
||||||
#define ASE_LSP_FREE(lsp,ptr) \
|
|
||||||
(lsp)->prmfns.free (ptr, (lsp)->prmfns.custom_data)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define ASE_LSP_ISUPPER(lsp,c) (lsp)->prmfns.is_upper(c)
|
#define ASE_LSP_ISUPPER(lsp,c) ASE_ISUPPER(&(lsp)->prmfns.ccls,c)
|
||||||
#define ASE_LSP_ISLOWER(lsp,c) (lsp)->prmfns.is_lower(c)
|
#define ASE_LSP_ISLOWER(lsp,c) ASE_ISLOWER(&(lsp)->prmfns.ccls,c)
|
||||||
#define ASE_LSP_ISALPHA(lsp,c) (lsp)->prmfns.is_alpha(c)
|
#define ASE_LSP_ISALPHA(lsp,c) ASE_ISALPHA(&(lsp)->prmfns.ccls,c)
|
||||||
#define ASE_LSP_ISDIGIT(lsp,c) (lsp)->prmfns.is_digit(c)
|
#define ASE_LSP_ISDIGIT(lsp,c) ASE_ISDIGIT(&(lsp)->prmfns.ccls,c)
|
||||||
#define ASE_LSP_ISXDIGIT(lsp,c) (lsp)->prmfns.is_xdigit(c)
|
#define ASE_LSP_ISXDIGIT(lsp,c) ASE_ISXDIGIT(&(lsp)->prmfns.ccls,c)
|
||||||
#define ASE_LSP_ISALNUM(lsp,c) (lsp)->prmfns.is_alnum(c)
|
#define ASE_LSP_ISALNUM(lsp,c) ASE_ISALNUM(&(lsp)->prmfns.ccls,c)
|
||||||
#define ASE_LSP_ISSPACE(lsp,c) (lsp)->prmfns.is_space(c)
|
#define ASE_LSP_ISSPACE(lsp,c) ASE_ISSPACE(&(lsp)->prmfns.ccls,c)
|
||||||
#define ASE_LSP_ISPRINT(lsp,c) (lsp)->prmfns.is_print(c)
|
#define ASE_LSP_ISPRINT(lsp,c) ASE_ISPRINT(&(lsp)->prmfns.ccls,c)
|
||||||
#define ASE_LSP_ISGRAPH(lsp,c) (lsp)->prmfns.is_graph(c)
|
#define ASE_LSP_ISGRAPH(lsp,c) ASE_ISGRAPH(&(lsp)->prmfns.ccls,c)
|
||||||
#define ASE_LSP_ISCNTRL(lsp,c) (lsp)->prmfns.is_cntrl(c)
|
#define ASE_LSP_ISCNTRL(lsp,c) ASE_ISCNTRL(&(lsp)->prmfns.ccls,c)
|
||||||
#define ASE_LSP_ISPUNCT(lsp,c) (lsp)->prmfns.is_punct(c)
|
#define ASE_LSP_ISPUNCT(lsp,c) ASE_ISPUNCT(&(lsp)->prmfns.ccls,c)
|
||||||
#define ASE_LSP_TOUPPER(lsp,c) (lsp)->prmfns.to_upper(c)
|
#define ASE_LSP_TOUPPER(lsp,c) ASE_TOUPPER(&(lsp)->prmfns.ccls,c)
|
||||||
#define ASE_LSP_TOLOWER(lsp,c) (lsp)->prmfns.to_lower(c)
|
#define ASE_LSP_TOLOWER(lsp,c) ASE_TOLOWER(&(lsp)->prmfns.ccls,c)
|
||||||
|
|
||||||
#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
|
struct ase_lsp_t
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: mem.c,v 1.30 2007-02-13 06:00:20 bacon Exp $
|
* $Id: mem.c,v 1.31 2007-02-23 10:53:38 bacon Exp $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -16,7 +16,7 @@ ase_lsp_mem_t* ase_lsp_openmem (
|
|||||||
mem = (ase_lsp_mem_t*) ASE_LSP_MALLOC (lsp, ASE_SIZEOF(ase_lsp_mem_t));
|
mem = (ase_lsp_mem_t*) ASE_LSP_MALLOC (lsp, ASE_SIZEOF(ase_lsp_mem_t));
|
||||||
if (mem == ASE_NULL) return ASE_NULL;
|
if (mem == ASE_NULL) return ASE_NULL;
|
||||||
|
|
||||||
ASE_LSP_MEMSET (lsp, mem, 0, ASE_SIZEOF(ase_lsp_mem_t));
|
ase_memset (mem, 0, ASE_SIZEOF(ase_lsp_mem_t));
|
||||||
mem->lsp = lsp;
|
mem->lsp = lsp;
|
||||||
|
|
||||||
/* create a new root environment frame */
|
/* create a new root environment frame */
|
||||||
@ -431,9 +431,10 @@ ase_lsp_obj_t* ase_lsp_makesym (
|
|||||||
while (obj != ASE_NULL)
|
while (obj != ASE_NULL)
|
||||||
{
|
{
|
||||||
// if there is a symbol with the same name, it is just used.
|
// if there is a symbol with the same name, it is just used.
|
||||||
if (ase_lsp_strxncmp (
|
if (ase_strxncmp (
|
||||||
ASE_LSP_SYMPTR(obj),
|
ASE_LSP_SYMPTR(obj),
|
||||||
ASE_LSP_SYMLEN(obj), str, len) == 0) return obj;
|
ASE_LSP_SYMLEN(obj),
|
||||||
|
str, len) == 0) return obj;
|
||||||
obj = ASE_LSP_LINK(obj);
|
obj = ASE_LSP_LINK(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -443,7 +444,7 @@ ase_lsp_obj_t* ase_lsp_makesym (
|
|||||||
if (obj == ASE_NULL) return ASE_NULL;
|
if (obj == ASE_NULL) return ASE_NULL;
|
||||||
|
|
||||||
// fill in the symbol buffer
|
// fill in the symbol buffer
|
||||||
ase_lsp_strncpy (ASE_LSP_SYMPTR(obj), str, len);
|
ase_strncpy (ASE_LSP_SYMPTR(obj), str, len);
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
@ -459,7 +460,7 @@ ase_lsp_obj_t* ase_lsp_makestr (
|
|||||||
if (obj == ASE_NULL) return ASE_NULL;
|
if (obj == ASE_NULL) return ASE_NULL;
|
||||||
|
|
||||||
// fill in the string buffer
|
// fill in the string buffer
|
||||||
ase_lsp_strncpy (ASE_LSP_STRPTR(obj), str, len);
|
ase_strncpy (ASE_LSP_STRPTR(obj), str, len);
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
190
ase/lsp/misc.c
190
ase/lsp/misc.c
@ -1,40 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: misc.c,v 1.8 2007-02-03 10:51:52 bacon Exp $
|
* $Id: misc.c,v 1.9 2007-02-23 10:53:39 bacon Exp $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ase/lsp/lsp_i.h>
|
#include <ase/lsp/lsp_i.h>
|
||||||
|
|
||||||
void* ase_lsp_memcpy (void* dst, const void* src, ase_size_t n)
|
|
||||||
{
|
|
||||||
void* p = dst;
|
|
||||||
void* e = (ase_byte_t*)dst + n;
|
|
||||||
|
|
||||||
while (dst < e)
|
|
||||||
{
|
|
||||||
*(ase_byte_t*)dst = *(ase_byte_t*)src;
|
|
||||||
dst = (ase_byte_t*)dst + 1;
|
|
||||||
src = (ase_byte_t*)src + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
void* ase_lsp_memset (void* dst, int val, ase_size_t n)
|
|
||||||
{
|
|
||||||
void* p = dst;
|
|
||||||
void* e = (ase_byte_t*)p + n;
|
|
||||||
|
|
||||||
while (p < e)
|
|
||||||
{
|
|
||||||
*(ase_byte_t*)p = (ase_byte_t)val;
|
|
||||||
p = (ase_byte_t*)p + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return dst;
|
|
||||||
}
|
|
||||||
|
|
||||||
ase_long_t ase_lsp_strxtolong (
|
ase_long_t ase_lsp_strxtolong (
|
||||||
ase_lsp_t* lsp, const ase_char_t* str, ase_size_t len,
|
ase_lsp_t* lsp, const ase_char_t* str, ase_size_t len,
|
||||||
int base, const ase_char_t** endptr)
|
int base, const ase_char_t** endptr)
|
||||||
@ -537,7 +508,7 @@ ase_size_t ase_lsp_longtostr (
|
|||||||
ase_size_t len, ret, i;
|
ase_size_t len, ret, i;
|
||||||
ase_size_t prefix_len;
|
ase_size_t prefix_len;
|
||||||
|
|
||||||
prefix_len = (prefix != ASE_NULL)? ase_lsp_strlen(prefix): 0;
|
prefix_len = (prefix != ASE_NULL)? ase_strlen(prefix): 0;
|
||||||
|
|
||||||
t = value;
|
t = value;
|
||||||
if (t == 0)
|
if (t == 0)
|
||||||
@ -602,172 +573,23 @@ ase_size_t ase_lsp_longtostr (
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ase_char_t* ase_lsp_strdup (ase_lsp_t* lsp, const ase_char_t* str)
|
|
||||||
{
|
|
||||||
ase_char_t* tmp;
|
|
||||||
|
|
||||||
tmp = (ase_char_t*) ASE_LSP_MALLOC (
|
|
||||||
lsp, (ase_lsp_strlen(str) + 1) * ASE_SIZEOF(ase_char_t));
|
|
||||||
if (tmp == ASE_NULL) return ASE_NULL;
|
|
||||||
|
|
||||||
ase_lsp_strcpy (tmp, str);
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
ase_char_t* ase_lsp_strxdup (ase_lsp_t* lsp, const ase_char_t* str, ase_size_t len)
|
|
||||||
{
|
|
||||||
ase_char_t* tmp;
|
|
||||||
|
|
||||||
tmp = (ase_char_t*) ASE_LSP_MALLOC (
|
|
||||||
lsp, (len + 1) * ASE_SIZEOF(ase_char_t));
|
|
||||||
if (tmp == ASE_NULL) return ASE_NULL;
|
|
||||||
|
|
||||||
ase_lsp_strncpy (tmp, str, len);
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
ase_char_t* ase_lsp_strxdup2 (
|
|
||||||
ase_lsp_t* lsp,
|
|
||||||
const ase_char_t* str1, ase_size_t len1,
|
|
||||||
const ase_char_t* str2, ase_size_t len2)
|
|
||||||
{
|
|
||||||
ase_char_t* tmp;
|
|
||||||
|
|
||||||
tmp = (ase_char_t*) ASE_LSP_MALLOC (
|
|
||||||
lsp, (len1 + len2 + 1) * ASE_SIZEOF(ase_char_t));
|
|
||||||
if (tmp == ASE_NULL) return ASE_NULL;
|
|
||||||
|
|
||||||
ase_lsp_strncpy (tmp, str1, len1);
|
|
||||||
ase_lsp_strncpy (tmp + len1, str2, len2);
|
|
||||||
return tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
ase_size_t ase_lsp_strlen (const ase_char_t* str)
|
|
||||||
{
|
|
||||||
const ase_char_t* p = str;
|
|
||||||
while (*p != ASE_T('\0')) p++;
|
|
||||||
return p - str;
|
|
||||||
}
|
|
||||||
|
|
||||||
ase_size_t ase_lsp_strcpy (ase_char_t* buf, const ase_char_t* str)
|
|
||||||
{
|
|
||||||
ase_char_t* org = buf;
|
|
||||||
while ((*buf++ = *str++) != ASE_T('\0'));
|
|
||||||
return buf - org - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
ase_size_t ase_lsp_strncpy (ase_char_t* buf, const ase_char_t* str, ase_size_t len)
|
|
||||||
{
|
|
||||||
const ase_char_t* end = str + len;
|
|
||||||
while (str < end) *buf++ = *str++;
|
|
||||||
*buf = ASE_T('\0');
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ase_lsp_strcmp (const ase_char_t* s1, const ase_char_t* s2)
|
|
||||||
{
|
|
||||||
while (*s1 == *s2)
|
|
||||||
{
|
|
||||||
if (*s1 == ASE_C('\0')) return 0;
|
|
||||||
s1++, s2++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (*s1 > *s2)? 1: -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ase_lsp_strxncmp (
|
|
||||||
const ase_char_t* s1, ase_size_t len1,
|
|
||||||
const ase_char_t* s2, ase_size_t len2)
|
|
||||||
{
|
|
||||||
ase_char_t c1, c2;
|
|
||||||
const ase_char_t* end1 = s1 + len1;
|
|
||||||
const ase_char_t* end2 = s2 + len2;
|
|
||||||
|
|
||||||
while (s1 < end1)
|
|
||||||
{
|
|
||||||
c1 = *s1;
|
|
||||||
if (s2 < end2)
|
|
||||||
{
|
|
||||||
c2 = *s2;
|
|
||||||
if (c1 > c2) return 1;
|
|
||||||
if (c1 < c2) return -1;
|
|
||||||
}
|
|
||||||
else return 1;
|
|
||||||
s1++; s2++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (s2 < end2)? -1: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ase_lsp_strxncasecmp (
|
|
||||||
ase_lsp_t* lsp,
|
|
||||||
const ase_char_t* s1, ase_size_t len1,
|
|
||||||
const ase_char_t* s2, ase_size_t len2)
|
|
||||||
{
|
|
||||||
ase_char_t c1, c2;
|
|
||||||
const ase_char_t* end1 = s1 + len1;
|
|
||||||
const ase_char_t* end2 = s2 + len2;
|
|
||||||
|
|
||||||
while (s1 < end1)
|
|
||||||
{
|
|
||||||
c1 = ASE_LSP_TOUPPER (lsp, *s1);
|
|
||||||
if (s2 < end2)
|
|
||||||
{
|
|
||||||
c2 = ASE_LSP_TOUPPER (lsp, *s2);
|
|
||||||
if (c1 > c2) return 1;
|
|
||||||
if (c1 < c2) return -1;
|
|
||||||
}
|
|
||||||
else return 1;
|
|
||||||
s1++; s2++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (s2 < end2)? -1: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ase_char_t* ase_lsp_strxnstr (
|
|
||||||
const ase_char_t* str, ase_size_t strsz,
|
|
||||||
const ase_char_t* sub, ase_size_t subsz)
|
|
||||||
{
|
|
||||||
const ase_char_t* end, * subp;
|
|
||||||
|
|
||||||
if (subsz == 0) return (ase_char_t*)str;
|
|
||||||
if (strsz < subsz) return ASE_NULL;
|
|
||||||
|
|
||||||
end = str + strsz - subsz;
|
|
||||||
subp = sub + subsz;
|
|
||||||
|
|
||||||
while (str <= end) {
|
|
||||||
const ase_char_t* x = str;
|
|
||||||
const ase_char_t* y = sub;
|
|
||||||
|
|
||||||
while (ase_true) {
|
|
||||||
if (y >= subp) return (ase_char_t*)str;
|
|
||||||
if (*x != *y) break;
|
|
||||||
x++; y++;
|
|
||||||
}
|
|
||||||
|
|
||||||
str++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ASE_NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ase_lsp_assertfail (ase_lsp_t* lsp,
|
int ase_lsp_assertfail (ase_lsp_t* lsp,
|
||||||
const ase_char_t* expr, const ase_char_t* desc,
|
const ase_char_t* expr, const ase_char_t* desc,
|
||||||
const ase_char_t* file, int line)
|
const ase_char_t* file, int line)
|
||||||
{
|
{
|
||||||
if (desc == ASE_NULL)
|
if (desc == ASE_NULL)
|
||||||
{
|
{
|
||||||
lsp->prmfns.aprintf (
|
lsp->prmfns.misc.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->prmfns.aprintf (
|
lsp->prmfns.misc.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->prmfns.abort (lsp);
|
|
||||||
|
lsp->prmfns.misc.abort (lsp->prmfns.misc.custom_data);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: name.c,v 1.14 2007-02-03 10:51:52 bacon Exp $
|
* $Id: name.c,v 1.15 2007-02-23 10:53:39 bacon Exp $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -71,8 +71,7 @@ int ase_lsp_name_addc (ase_lsp_name_t* name, ase_cint_t c)
|
|||||||
if (space == ASE_NULL) return -1;
|
if (space == ASE_NULL) return -1;
|
||||||
|
|
||||||
/* don't need to copy up to the terminating null */
|
/* don't need to copy up to the terminating null */
|
||||||
ASE_LSP_MEMCPY (name->lsp, space, name->buf,
|
ase_memcpy (space, name->buf, name->capa*ASE_SIZEOF(ase_char_t));
|
||||||
name->capa*ASE_SIZEOF(ase_char_t));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: prim_compar.c,v 1.13 2007-02-11 07:36:55 bacon Exp $
|
* $Id: prim_compar.c,v 1.14 2007-02-23 10:53:39 bacon Exp $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -69,7 +69,7 @@
|
|||||||
{ \
|
{ \
|
||||||
if (ASE_LSP_TYPE(p2) == ASE_LSP_OBJ_SYM) \
|
if (ASE_LSP_TYPE(p2) == ASE_LSP_OBJ_SYM) \
|
||||||
{ \
|
{ \
|
||||||
res = ase_lsp_strxncmp ( \
|
res = ase_strxncmp ( \
|
||||||
ASE_LSP_SYMPTR(p1), ASE_LSP_SYMLEN(p1), \
|
ASE_LSP_SYMPTR(p1), ASE_LSP_SYMLEN(p1), \
|
||||||
ASE_LSP_SYMPTR(p2), ASE_LSP_SYMLEN(p2)) op 0; \
|
ASE_LSP_SYMPTR(p2), ASE_LSP_SYMLEN(p2)) op 0; \
|
||||||
} \
|
} \
|
||||||
@ -85,7 +85,7 @@
|
|||||||
{ \
|
{ \
|
||||||
if (ASE_LSP_TYPE(p2) == ASE_LSP_OBJ_STR) \
|
if (ASE_LSP_TYPE(p2) == ASE_LSP_OBJ_STR) \
|
||||||
{ \
|
{ \
|
||||||
res = ase_lsp_strxncmp ( \
|
res = ase_strxncmp ( \
|
||||||
ASE_LSP_STRPTR(p1), ASE_LSP_STRLEN(p1), \
|
ASE_LSP_STRPTR(p1), ASE_LSP_STRLEN(p1), \
|
||||||
ASE_LSP_STRPTR(p2), ASE_LSP_STRLEN(p2)) op 0; \
|
ASE_LSP_STRPTR(p2), ASE_LSP_STRLEN(p2)) op 0; \
|
||||||
} \
|
} \
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: print.c,v 1.24 2007-02-17 15:27:19 bacon Exp $
|
* $Id: print.c,v 1.25 2007-02-23 10:53:39 bacon Exp $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
#define OUTPUT_STR(lsp,str) \
|
#define OUTPUT_STR(lsp,str) \
|
||||||
do { \
|
do { \
|
||||||
if (lsp->output_func(ASE_LSP_IO_WRITE, lsp->output_arg, (ase_char_t*)str, ase_lsp_strlen(str)) == -1) { \
|
if (lsp->output_func(ASE_LSP_IO_WRITE, lsp->output_arg, (ase_char_t*)str, ase_strlen(str)) == -1) { \
|
||||||
ase_lsp_seterror (lsp, ASE_LSP_EOUTPUT, ASE_NULL, 0); \
|
ase_lsp_seterror (lsp, ASE_LSP_EOUTPUT, ASE_NULL, 0); \
|
||||||
return -1; \
|
return -1; \
|
||||||
} \
|
} \
|
||||||
@ -44,19 +44,19 @@ 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 ASE_SIZEOF_LONG_LONG > 0
|
#if ASE_SIZEOF_LONG_LONG > 0
|
||||||
lsp->prmfns.sprintf (
|
lsp->prmfns.misc.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));
|
||||||
#elif ASE_SIZEOF___INT64 > 0
|
#elif ASE_SIZEOF___INT64 > 0
|
||||||
lsp->prmfns.sprintf (
|
lsp->prmfns.misc.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 ASE_SIZEOF_LONG > 0
|
#elif ASE_SIZEOF_LONG > 0
|
||||||
lsp->prmfns.sprintf (
|
lsp->prmfns.misc.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));
|
||||||
#elif ASE_SIZEOF_INT > 0
|
#elif ASE_SIZEOF_INT > 0
|
||||||
lsp->prmfns.sprintf (
|
lsp->prmfns.misc.sprintf (
|
||||||
buf, ASE_COUNTOF(buf),
|
buf, ASE_COUNTOF(buf),
|
||||||
ASE_T("%d"), (int)ASE_LSP_IVAL(obj));
|
ASE_T("%d"), (int)ASE_LSP_IVAL(obj));
|
||||||
#else
|
#else
|
||||||
@ -66,7 +66,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->prmfns.sprintf (buf, ASE_COUNTOF(buf),
|
lsp->prmfns.misc.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);
|
||||||
@ -128,7 +128,7 @@ static int __print (ase_lsp_t* lsp, const ase_lsp_obj_t* obj, ase_bool_t prt_con
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
lsp->prmfns.sprintf (buf, ASE_COUNTOF(buf),
|
lsp->prmfns.misc.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);
|
||||||
}
|
}
|
||||||
|
@ -97,47 +97,37 @@ struct prmfns_data_t
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void* lsp_malloc (ase_size_t n, void* custom_data)
|
static void* lsp_malloc (ase_mmgr_t* mmgr, ase_size_t n)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
return HeapAlloc (((prmfns_data_t*)custom_data)->heap, 0, n);
|
return HeapAlloc (((prmfns_data_t*)mmgr->custom_data)->heap, 0, n);
|
||||||
#else
|
#else
|
||||||
return malloc (n);
|
return malloc (n);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void* lsp_realloc (void* ptr, ase_size_t n, void* custom_data)
|
static void* lsp_realloc (ase_mmgr_t* mmgr, void* ptr, ase_size_t n)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
/* HeapReAlloc behaves differently from realloc */
|
/* HeapReAlloc behaves differently from realloc */
|
||||||
if (ptr == NULL)
|
if (ptr == NULL)
|
||||||
return HeapAlloc (((prmfns_data_t*)custom_data)->heap, 0, n);
|
return HeapAlloc (((prmfns_data_t*)mmgr->custom_data)->heap, 0, n);
|
||||||
else
|
else
|
||||||
return HeapReAlloc (((prmfns_data_t*)custom_data)->heap, 0, ptr, n);
|
return HeapReAlloc (((prmfns_data_t*)mmgr->custom_data)->heap, 0, ptr, n);
|
||||||
#else
|
#else
|
||||||
return realloc (ptr, n);
|
return realloc (ptr, n);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lsp_free (void* ptr, void* custom_data)
|
static void lsp_free (ase_mmgr_t* mmgr, void* ptr)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
HeapFree (((prmfns_data_t*)custom_data)->heap, 0, ptr);
|
HeapFree (((prmfns_data_t*)mmgr->custom_data)->heap, 0, ptr);
|
||||||
#else
|
#else
|
||||||
free (ptr);
|
free (ptr);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void* lsp_memcpy (void* dst, const void* src, ase_size_t n)
|
|
||||||
{
|
|
||||||
return memcpy (dst, src, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void* lsp_memset (void* dst, int val, ase_size_t n)
|
|
||||||
{
|
|
||||||
return memset (dst, val, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void lsp_abort (void* custom_data)
|
static void lsp_abort (void* custom_data)
|
||||||
{
|
{
|
||||||
abort ();
|
abort ();
|
||||||
@ -197,31 +187,10 @@ int lsp_main (int argc, ase_char_t* argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
memset (&prmfns, 0, sizeof(prmfns));
|
memset (&prmfns, 0, sizeof(prmfns));
|
||||||
prmfns.malloc = lsp_malloc;
|
|
||||||
prmfns.realloc = lsp_realloc;
|
|
||||||
prmfns.free = lsp_free;
|
|
||||||
prmfns.memcpy = lsp_memcpy;
|
|
||||||
prmfns.memset = lsp_memset;
|
|
||||||
|
|
||||||
prmfns.is_upper = (ase_lsp_isctype_t)ase_isupper;
|
|
||||||
prmfns.is_lower = (ase_lsp_isctype_t)ase_islower;
|
|
||||||
prmfns.is_alpha = (ase_lsp_isctype_t)ase_isalpha;
|
|
||||||
prmfns.is_digit = (ase_lsp_isctype_t)ase_isdigit;
|
|
||||||
prmfns.is_xdigit = (ase_lsp_isctype_t)ase_isxdigit;
|
|
||||||
prmfns.is_alnum = (ase_lsp_isctype_t)ase_isalnum;
|
|
||||||
prmfns.is_space = (ase_lsp_isctype_t)ase_isspace;
|
|
||||||
prmfns.is_print = (ase_lsp_isctype_t)ase_isprint;
|
|
||||||
prmfns.is_graph = (ase_lsp_isctype_t)ase_isgraph;
|
|
||||||
prmfns.is_cntrl = (ase_lsp_isctype_t)ase_iscntrl;
|
|
||||||
prmfns.is_punct = (ase_lsp_isctype_t)ase_ispunct;
|
|
||||||
prmfns.to_upper = (ase_lsp_toctype_t)ase_toupper;
|
|
||||||
prmfns.to_lower = (ase_lsp_toctype_t)ase_tolower;
|
|
||||||
|
|
||||||
prmfns.sprintf = ase_sprintf;
|
|
||||||
prmfns.aprintf = lsp_aprintf;
|
|
||||||
prmfns.dprintf = lsp_dprintf;
|
|
||||||
prmfns.abort = lsp_abort;
|
|
||||||
|
|
||||||
|
prmfns.mmgr.malloc = lsp_malloc;
|
||||||
|
prmfns.mmgr.realloc = lsp_realloc;
|
||||||
|
prmfns.mmgr.free = lsp_free;
|
||||||
#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)
|
||||||
@ -230,9 +199,31 @@ int lsp_main (int argc, ase_char_t* argv[])
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
prmfns.custom_data = &prmfns_data;
|
prmfns.mmgr.custom_data = &prmfns_data;
|
||||||
|
#else
|
||||||
|
prmfns.mmgr.custom_data = ASE_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 = ASE_NULL;
|
||||||
|
|
||||||
|
prmfns.misc.sprintf = ase_sprintf;
|
||||||
|
prmfns.misc.aprintf = lsp_aprintf;
|
||||||
|
prmfns.misc.dprintf = lsp_dprintf;
|
||||||
|
prmfns.misc.abort = lsp_abort;
|
||||||
|
|
||||||
lsp = ase_lsp_open (&prmfns, mem, inc);
|
lsp = ase_lsp_open (&prmfns, mem, inc);
|
||||||
if (lsp == ASE_NULL)
|
if (lsp == ASE_NULL)
|
||||||
{
|
{
|
||||||
|
@ -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@/lsp -L@abs_top_builddir@/utl
|
LDFLAGS = @LDFLAGS@ -L@abs_top_builddir@/cmn -L@abs_top_builddir@/lsp -L@abs_top_builddir@/utl
|
||||||
LIBS = @LIBS@ -laselsp -laseutl -lm
|
LIBS = @LIBS@ -laseutl -laselsp -lasecmn -lm
|
||||||
|
|
||||||
all: aselsp
|
all: aselsp
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: stdio.h,v 1.3 2007-02-22 14:32:08 bacon Exp $
|
* $Id: stdio.h,v 1.4 2007-02-23 10:53:39 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _ASE_UTL_STDIO_H_
|
#ifndef _ASE_UTL_STDIO_H_
|
||||||
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <wchar.h>
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user