diff --git a/ase/awk/awk.c b/ase/awk/awk.c index a4bb7fe7..d7c22d71 100644 --- a/ase/awk/awk.c +++ b/ase/awk/awk.c @@ -1,5 +1,5 @@ /* - * $Id: awk.c,v 1.105 2007-01-25 14:10:03 bacon Exp $ + * $Id: awk.c,v 1.106 2007-02-01 08:38:22 bacon Exp $ */ #if defined(__BORLANDC__) @@ -12,31 +12,31 @@ static void __free_afn (void* awk, void* afn); ase_awk_t* ase_awk_open ( - const ase_awk_sysfns_t* sysfns, void* custom_data, int* errnum) + const ase_awk_prmfns_t* prmfns, void* custom_data, int* errnum) { ase_awk_t* awk; - if (sysfns == ASE_NULL || - sysfns->malloc == ASE_NULL || - sysfns->free == ASE_NULL || - sysfns->is_upper == ASE_NULL || - sysfns->is_lower == ASE_NULL || - sysfns->is_alpha == ASE_NULL || - sysfns->is_digit == ASE_NULL || - sysfns->is_xdigit == ASE_NULL || - sysfns->is_alnum == ASE_NULL || - sysfns->is_space == ASE_NULL || - sysfns->is_print == ASE_NULL || - sysfns->is_graph == ASE_NULL || - sysfns->is_cntrl == ASE_NULL || - sysfns->is_punct == ASE_NULL || - sysfns->to_upper == ASE_NULL || - sysfns->to_lower == ASE_NULL || - sysfns->pow == ASE_NULL || - sysfns->sprintf == ASE_NULL || - sysfns->aprintf == ASE_NULL || - sysfns->dprintf == ASE_NULL || - sysfns->abort == ASE_NULL) + if (prmfns == ASE_NULL || + prmfns->malloc == ASE_NULL || + prmfns->free == ASE_NULL || + 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 || + prmfns->pow == ASE_NULL || + prmfns->sprintf == ASE_NULL || + prmfns->aprintf == ASE_NULL || + prmfns->dprintf == ASE_NULL || + prmfns->abort == ASE_NULL) { *errnum = ASE_AWK_ESYSFNS; return ASE_NULL; @@ -45,8 +45,8 @@ ase_awk_t* ase_awk_open ( #if defined(_WIN32) && defined(_MSC_VER) && defined(_DEBUG) awk = (ase_awk_t*) malloc (ASE_SIZEOF(ase_awk_t)); #else - awk = (ase_awk_t*) sysfns->malloc ( - ASE_SIZEOF(ase_awk_t), sysfns->custom_data); + awk = (ase_awk_t*) prmfns->malloc ( + ASE_SIZEOF(ase_awk_t), prmfns->custom_data); #endif if (awk == ASE_NULL) { @@ -58,13 +58,13 @@ ase_awk_t* ase_awk_open ( * fully initialized yet */ ase_awk_memset (awk, 0, ASE_SIZEOF(ase_awk_t)); - if (sysfns->memcpy == ASE_NULL) + if (prmfns->memcpy == ASE_NULL) { - ase_awk_memcpy (&awk->sysfns, sysfns, ASE_SIZEOF(awk->sysfns)); - awk->sysfns.memcpy = ase_awk_memcpy; + ase_awk_memcpy (&awk->prmfns, prmfns, ASE_SIZEOF(awk->prmfns)); + awk->prmfns.memcpy = ase_awk_memcpy; } - else sysfns->memcpy (&awk->sysfns, sysfns, ASE_SIZEOF(awk->sysfns)); - if (sysfns->memset == ASE_NULL) awk->sysfns.memset = ase_awk_memset; + else prmfns->memcpy (&awk->prmfns, prmfns, ASE_SIZEOF(awk->prmfns)); + if (prmfns->memset == ASE_NULL) awk->prmfns.memset = ase_awk_memset; if (ase_awk_str_open (&awk->token.name, 128, awk) == ASE_NULL) { diff --git a/ase/awk/awk.h b/ase/awk/awk.h index d5f6fdee..eb687320 100644 --- a/ase/awk/awk.h +++ b/ase/awk/awk.h @@ -1,5 +1,5 @@ /* - * $Id: awk.h,v 1.185 2007-01-25 14:10:03 bacon Exp $ + * $Id: awk.h,v 1.186 2007-02-01 08:38:22 bacon Exp $ */ #ifndef _ASE_AWK_AWK_H_ @@ -13,7 +13,7 @@ typedef struct ase_awk_run_t ase_awk_run_t; typedef struct ase_awk_val_t ase_awk_val_t; typedef struct ase_awk_extio_t ase_awk_extio_t; -typedef struct ase_awk_sysfns_t ase_awk_sysfns_t; +typedef struct ase_awk_prmfns_t ase_awk_prmfns_t; typedef struct ase_awk_srcios_t ase_awk_srcios_t; typedef struct ase_awk_runios_t ase_awk_runios_t; typedef struct ase_awk_runcbs_t ase_awk_runcbs_t; @@ -68,7 +68,7 @@ struct ase_awk_extio_t ase_awk_extio_t* next; }; -struct ase_awk_sysfns_t +struct ase_awk_prmfns_t { /* memory allocation/deallocation */ ase_awk_malloc_t malloc; /* required */ @@ -402,7 +402,7 @@ extern "C" { #endif ase_awk_t* ase_awk_open ( - const ase_awk_sysfns_t* sysfns, void* custom_data, int* errnum); + const ase_awk_prmfns_t* prmfns, void* custom_data, int* errnum); int ase_awk_close (ase_awk_t* awk); int ase_awk_clear (ase_awk_t* awk); diff --git a/ase/awk/awk_i.h b/ase/awk/awk_i.h index c0d29066..459ffa2a 100644 --- a/ase/awk/awk_i.h +++ b/ase/awk/awk_i.h @@ -1,5 +1,5 @@ /* - * $Id: awk_i.h,v 1.98 2007-01-25 14:10:03 bacon Exp $ + * $Id: awk_i.h,v 1.99 2007-02-01 08:38:22 bacon Exp $ */ #ifndef _ASE_AWK_AWKI_H_ @@ -45,41 +45,41 @@ typedef struct ase_awk_tree_t ase_awk_tree_t; #define ASE_AWK_FREE(awk,ptr) free (ptr) #else #define ASE_AWK_MALLOC(awk,size) \ - (awk)->sysfns.malloc (size, (awk)->sysfns.custom_data) + (awk)->prmfns.malloc (size, (awk)->prmfns.custom_data) #define ASE_AWK_REALLOC(awk,ptr,size) \ - (awk)->sysfns.realloc (ptr, size, (awk)->sysfns.custom_data) + (awk)->prmfns.realloc (ptr, size, (awk)->prmfns.custom_data) #define ASE_AWK_FREE(awk,ptr) \ - (awk)->sysfns.free (ptr, (awk)->sysfns.custom_data) + (awk)->prmfns.free (ptr, (awk)->prmfns.custom_data) #endif #define ASE_AWK_LOCK(awk) \ do { \ - if ((awk)->sysfns.lock != ASE_NULL) \ - (awk)->sysfns.lock ((awk)->sysfns.custom_data); \ + if ((awk)->prmfns.lock != ASE_NULL) \ + (awk)->prmfns.lock ((awk)->prmfns.custom_data); \ } while (0) #define ASE_AWK_UNLOCK(awk) \ do { \ - if ((awk)->sysfns.unlock != ASE_NULL) \ - (awk)->sysfns.unlock ((awk)->sysfns.custom_data); \ + if ((awk)->prmfns.unlock != ASE_NULL) \ + (awk)->prmfns.unlock ((awk)->prmfns.custom_data); \ } while (0) -#define ASE_AWK_ISUPPER(awk,c) (awk)->sysfns.is_upper(c) -#define ASE_AWK_ISLOWER(awk,c) (awk)->sysfns.is_lower(c) -#define ASE_AWK_ISALPHA(awk,c) (awk)->sysfns.is_alpha(c) -#define ASE_AWK_ISDIGIT(awk,c) (awk)->sysfns.is_digit(c) -#define ASE_AWK_ISXDIGIT(awk,c) (awk)->sysfns.is_xdigit(c) -#define ASE_AWK_ISALNUM(awk,c) (awk)->sysfns.is_alnum(c) -#define ASE_AWK_ISSPACE(awk,c) (awk)->sysfns.is_space(c) -#define ASE_AWK_ISPRINT(awk,c) (awk)->sysfns.is_print(c) -#define ASE_AWK_ISGRAPH(awk,c) (awk)->sysfns.is_graph(c) -#define ASE_AWK_ISCNTRL(awk,c) (awk)->sysfns.is_cntrl(c) -#define ASE_AWK_ISPUNCT(awk,c) (awk)->sysfns.is_punct(c) -#define ASE_AWK_TOUPPER(awk,c) (awk)->sysfns.to_upper(c) -#define ASE_AWK_TOLOWER(awk,c) (awk)->sysfns.to_lower(c) +#define ASE_AWK_ISUPPER(awk,c) (awk)->prmfns.is_upper(c) +#define ASE_AWK_ISLOWER(awk,c) (awk)->prmfns.is_lower(c) +#define ASE_AWK_ISALPHA(awk,c) (awk)->prmfns.is_alpha(c) +#define ASE_AWK_ISDIGIT(awk,c) (awk)->prmfns.is_digit(c) +#define ASE_AWK_ISXDIGIT(awk,c) (awk)->prmfns.is_xdigit(c) +#define ASE_AWK_ISALNUM(awk,c) (awk)->prmfns.is_alnum(c) +#define ASE_AWK_ISSPACE(awk,c) (awk)->prmfns.is_space(c) +#define ASE_AWK_ISPRINT(awk,c) (awk)->prmfns.is_print(c) +#define ASE_AWK_ISGRAPH(awk,c) (awk)->prmfns.is_graph(c) +#define ASE_AWK_ISCNTRL(awk,c) (awk)->prmfns.is_cntrl(c) +#define ASE_AWK_ISPUNCT(awk,c) (awk)->prmfns.is_punct(c) +#define ASE_AWK_TOUPPER(awk,c) (awk)->prmfns.to_upper(c) +#define ASE_AWK_TOLOWER(awk,c) (awk)->prmfns.to_lower(c) -#define ASE_AWK_MEMCPY(awk,dst,src,len) (awk)->sysfns.memcpy (dst, src, len) -#define ASE_AWK_MEMSET(awk,dst,val,len) (awk)->sysfns.memset (dst, val, len) +#define ASE_AWK_MEMCPY(awk,dst,src,len) (awk)->prmfns.memcpy (dst, src, len) +#define ASE_AWK_MEMSET(awk,dst,val,len) (awk)->prmfns.memset (dst, val, len) struct ase_awk_tree_t { @@ -96,7 +96,7 @@ struct ase_awk_tree_t struct ase_awk_t { - ase_awk_sysfns_t sysfns; + ase_awk_prmfns_t prmfns; void* custom_data; /* options */ diff --git a/ase/awk/func.c b/ase/awk/func.c index df12334c..f33dee7d 100644 --- a/ase/awk/func.c +++ b/ase/awk/func.c @@ -1,5 +1,5 @@ /* - * $Id: func.c,v 1.91 2007-01-25 14:10:03 bacon Exp $ + * $Id: func.c,v 1.92 2007-02-01 08:38:22 bacon Exp $ */ #include @@ -51,7 +51,7 @@ void* ase_awk_addbfn ( if (ase_awk_getbfn (awk, name, name_len) != ASE_NULL) { - awk->sysfns.sprintf ( + awk->prmfns.sprintf ( awk->errmsg, ASE_COUNTOF(awk->errmsg), ASE_T("'%.*s' added already"), name_len, name); ase_awk_seterror (awk, ASE_AWK_EEXIST, 0, awk->errmsg); diff --git a/ase/awk/jni.c b/ase/awk/jni.c index d9fccce3..ba15f46a 100644 --- a/ase/awk/jni.c +++ b/ase/awk/jni.c @@ -1,5 +1,5 @@ /* - * $Id: jni.c,v 1.64 2007-02-01 07:23:59 bacon Exp $ + * $Id: jni.c,v 1.65 2007-02-01 08:38:22 bacon Exp $ */ #include @@ -239,36 +239,36 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_open (JNIEnv* env, jobject obj) jclass class; jfieldID handle; ase_awk_t* awk; - ase_awk_sysfns_t sysfns; + ase_awk_prmfns_t prmfns; awk_data_t* awk_data; int opt, errnum; - memset (&sysfns, 0, sizeof(sysfns)); - sysfns.malloc = awk_malloc; - sysfns.realloc = awk_realloc; - sysfns.free = awk_free; + memset (&prmfns, 0, sizeof(prmfns)); + prmfns.malloc = awk_malloc; + prmfns.realloc = awk_realloc; + prmfns.free = awk_free; - sysfns.is_upper = iswupper; - sysfns.is_lower = iswlower; - sysfns.is_alpha = iswalpha; - sysfns.is_digit = iswdigit; - sysfns.is_xdigit = iswxdigit; - sysfns.is_alnum = iswalnum; - sysfns.is_space = iswspace; - sysfns.is_print = iswprint; - sysfns.is_graph = iswgraph; - sysfns.is_cntrl = iswcntrl; - sysfns.is_punct = iswpunct; - sysfns.to_upper = towupper; - sysfns.to_lower = towlower; + prmfns.is_upper = iswupper; + prmfns.is_lower = iswlower; + prmfns.is_alpha = iswalpha; + prmfns.is_digit = iswdigit; + 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; - sysfns.memcpy = memcpy; - sysfns.memset = memset; - sysfns.pow = awk_pow; - sysfns.sprintf = awk_sprintf; - sysfns.aprintf = awk_aprintf; - sysfns.dprintf = awk_dprintf; - sysfns.abort = awk_abort; + prmfns.memcpy = memcpy; + prmfns.memset = memset; + prmfns.pow = awk_pow; + prmfns.sprintf = awk_sprintf; + prmfns.aprintf = awk_aprintf; + prmfns.dprintf = awk_dprintf; + prmfns.abort = awk_abort; awk_data = (awk_data_t*) malloc (sizeof(awk_data_t)); if (awk_data == NULL) @@ -283,10 +283,10 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_open (JNIEnv* env, jobject obj) memset (awk_data, 0, sizeof(awk_data_t)); - awk = ase_awk_open (&sysfns, awk_data, &errnum); + awk = ase_awk_open (&prmfns, awk_data, &errnum); if (awk == NULL) { - free (sysfns.custom_data); + free (prmfns.custom_data); throw_exception ( env, ase_awk_geterrstr(errnum), diff --git a/ase/awk/misc.c b/ase/awk/misc.c index 12639afa..e41d80f5 100644 --- a/ase/awk/misc.c +++ b/ase/awk/misc.c @@ -1,5 +1,5 @@ /* - * $Id: misc.c,v 1.48 2006-12-16 16:12:07 bacon Exp $ + * $Id: misc.c,v 1.49 2007-02-01 08:38:23 bacon Exp $ */ #include @@ -1105,18 +1105,18 @@ int ase_awk_assertfail (ase_awk_t* awk, { if (desc == ASE_NULL) { - awk->sysfns.aprintf ( + awk->prmfns.aprintf ( ASE_T("ASSERTION FAILURE AT FILE %s LINE %d\n%s\n"), file, line, expr); } else { - awk->sysfns.aprintf ( + awk->prmfns.aprintf ( ASE_T("ASSERTION FAILURE AT FILE %s LINE %d\n%s\n\nDESCRIPTION:\n%s\n"), file, line, expr, desc); } - awk->sysfns.abort (awk->sysfns.custom_data); + awk->prmfns.abort (awk->prmfns.custom_data); return 0; } diff --git a/ase/awk/parse.c b/ase/awk/parse.c index 51af26d6..53b46645 100644 --- a/ase/awk/parse.c +++ b/ase/awk/parse.c @@ -1,5 +1,5 @@ /* - * $Id: parse.c,v 1.239 2007-01-07 07:26:16 bacon Exp $ + * $Id: parse.c,v 1.240 2007-02-01 08:38:23 bacon Exp $ */ #include @@ -331,7 +331,7 @@ static struct __bvent __bvtab[] = } \ else \ { \ - awk->sysfns.sprintf ( \ + awk->prmfns.sprintf ( \ (awk)->errmsg, ASE_COUNTOF((awk)->errmsg), \ msg, \ ASE_AWK_STR_LEN(&(awk)->token.name), \ @@ -703,7 +703,7 @@ static ase_awk_nde_t* __parse_function (ase_awk_t* awk) } else { - awk->sysfns.sprintf ( + awk->prmfns.sprintf ( awk->errmsg, ASE_COUNTOF(awk->errmsg), ASE_T("'%.*s' not a valid function name"), ASE_AWK_STR_LEN(&awk->token.name), @@ -722,7 +722,7 @@ static ase_awk_nde_t* __parse_function (ase_awk_t* awk) /* check if it is a builtin function */ if (ase_awk_getbfn (awk, name, name_len) != ASE_NULL) { - awk->sysfns.sprintf ( + awk->prmfns.sprintf ( awk->errmsg, ASE_COUNTOF(awk->errmsg), ASE_T("built-in function '%.*s' redefined"), name_len, name); @@ -737,7 +737,7 @@ static ase_awk_nde_t* __parse_function (ase_awk_t* awk) if (ase_awk_map_get(&awk->tree.afns, name, name_len) != ASE_NULL) { /* the function is defined previously */ - awk->sysfns.sprintf ( + awk->prmfns.sprintf ( awk->errmsg, ASE_COUNTOF(awk->errmsg), ASE_T("function '%.*s' redefined"), name_len, name); @@ -757,7 +757,7 @@ static ase_awk_nde_t* __parse_function (ase_awk_t* awk) g = ase_awk_tab_find (&awk->parse.globals, 0, name, name_len); if (g != (ase_size_t)-1) { - awk->sysfns.sprintf ( + awk->prmfns.sprintf ( awk->errmsg, ASE_COUNTOF(awk->errmsg), ASE_T("global variable '%.*s' redefined"), name_len, name); @@ -844,7 +844,7 @@ static ase_awk_nde_t* __parse_function (ase_awk_t* awk) } else { - awk->sysfns.sprintf ( + awk->prmfns.sprintf ( awk->errmsg, ASE_COUNTOF(awk->errmsg), ASE_T("'%.*s' not a valid parameter name"), ASE_AWK_STR_LEN(&awk->token.name), @@ -870,7 +870,7 @@ static ase_awk_nde_t* __parse_function (ase_awk_t* awk) ASE_AWK_FREE (awk, name_dup); ase_awk_tab_clear (&awk->parse.params); - awk->sysfns.sprintf ( + awk->prmfns.sprintf ( awk->errmsg, ASE_COUNTOF(awk->errmsg), ASE_T("conflicting parameter '%.*s' with the function"), param_len, param); @@ -897,7 +897,7 @@ static ase_awk_nde_t* __parse_function (ase_awk_t* awk) ASE_AWK_FREE (awk, name_dup); ase_awk_tab_clear (&awk->parse.params); - awk->sysfns.sprintf ( + awk->prmfns.sprintf ( awk->errmsg, ASE_COUNTOF(awk->errmsg), ASE_T("duplicate parameter '%.*s'"), param_len, param); @@ -985,7 +985,7 @@ static ase_awk_nde_t* __parse_function (ase_awk_t* awk) } else { - awk->sysfns.sprintf ( + awk->prmfns.sprintf ( awk->errmsg, ASE_COUNTOF(awk->errmsg), ASE_T("'%.*s' not a valid start of the function body"), ASE_AWK_STR_LEN(&awk->token.name), @@ -1328,7 +1328,7 @@ static ase_awk_t* __add_global ( /* check if it conflict with a builtin function name */ if (ase_awk_getbfn (awk, name, len) != ASE_NULL) { - awk->sysfns.sprintf ( + awk->prmfns.sprintf ( awk->errmsg, ASE_COUNTOF(awk->errmsg), ASE_T("built-in function '%.*s' redefined"), len, name); @@ -1341,7 +1341,7 @@ static ase_awk_t* __add_global ( if (ase_awk_map_get ( &awk->tree.afns, name, len) != ASE_NULL) { - awk->sysfns.sprintf ( + awk->prmfns.sprintf ( awk->errmsg, ASE_COUNTOF(awk->errmsg), ASE_T("function '%.*s' redefined"), len, name); @@ -1355,7 +1355,7 @@ static ase_awk_t* __add_global ( if (ase_awk_tab_find ( &awk->parse.globals, 0, name, len) != (ase_size_t)-1) { - awk->sysfns.sprintf ( + awk->prmfns.sprintf ( awk->errmsg, ASE_COUNTOF(awk->errmsg), ASE_T("duplicate global variable '%.*s'"), len, name); @@ -1395,7 +1395,7 @@ static ase_awk_t* __collect_globals (ase_awk_t* awk) } else { - awk->sysfns.sprintf ( + awk->prmfns.sprintf ( awk->errmsg, ASE_COUNTOF(awk->errmsg), ASE_T("'%.*s' not a valid variable name"), ASE_AWK_STR_LEN(&awk->token.name), @@ -1453,7 +1453,7 @@ static ase_awk_t* __collect_locals (ase_awk_t* awk, ase_size_t nlocals) } else { - awk->sysfns.sprintf ( + awk->prmfns.sprintf ( awk->errmsg, ASE_COUNTOF(awk->errmsg), ASE_T("'%.*s' not a valid variable name"), ASE_AWK_STR_LEN(&awk->token.name), @@ -1476,7 +1476,7 @@ static ase_awk_t* __collect_locals (ase_awk_t* awk, ase_size_t nlocals) /* check if it conflict with a builtin function name */ if (ase_awk_getbfn (awk, local, local_len) != ASE_NULL) { - awk->sysfns.sprintf ( + awk->prmfns.sprintf ( awk->errmsg, ASE_COUNTOF(awk->errmsg), ASE_T("built-in function '%.*s' redefined"), local_len, local); @@ -1491,7 +1491,7 @@ static ase_awk_t* __collect_locals (ase_awk_t* awk, ase_size_t nlocals) if (ase_awk_map_get ( &awk->tree.afns, local, local_len) != ASE_NULL) { - awk->sysfns.sprintf ( + awk->prmfns.sprintf ( awk->errmsg, ASE_COUNTOF(awk->errmsg), ASE_T("function '%.*s' redefined"), local_len, local); @@ -1507,7 +1507,7 @@ static ase_awk_t* __collect_locals (ase_awk_t* awk, ase_size_t nlocals) if (ase_awk_tab_find (&awk->parse.params, 0, local, local_len) != (ase_size_t)-1) { - awk->sysfns.sprintf ( + awk->prmfns.sprintf ( awk->errmsg, ASE_COUNTOF(awk->errmsg), ASE_T("parameter '%.*s' redefined"), local_len, local); @@ -1523,7 +1523,7 @@ static ase_awk_t* __collect_locals (ase_awk_t* awk, ase_size_t nlocals) ((awk->option & ASE_AWK_SHADING)? nlocals: 0), local, local_len) != (ase_size_t)-1) { - awk->sysfns.sprintf ( + awk->prmfns.sprintf ( awk->errmsg, ASE_COUNTOF(awk->errmsg), ASE_T("duplicate local variable '%.*s'"), local_len, local); @@ -2948,7 +2948,7 @@ static ase_awk_nde_t* __parse_primary_ident (ase_awk_t* awk, ase_size_t line) /* built-in function should be in the form * of the function call */ - awk->sysfns.sprintf ( + awk->prmfns.sprintf ( awk->errmsg, ASE_COUNTOF(awk->errmsg), ASE_T("function name '%.*s' without a left parenthesis"), name_len, name_dup); @@ -3059,7 +3059,7 @@ static ase_awk_nde_t* __parse_primary_ident (ase_awk_t* awk, ase_size_t line) return (ase_awk_nde_t*)nde; } - awk->sysfns.sprintf ( + awk->prmfns.sprintf ( awk->errmsg, ASE_COUNTOF(awk->errmsg), ASE_T("undefined identifier '%.*s'"), name_len, name_dup); @@ -3202,7 +3202,7 @@ static ase_awk_nde_t* __parse_hashidx ( ase_awk_clrpt (awk, idx); ASE_AWK_FREE (awk, nde); - awk->sysfns.sprintf ( + awk->prmfns.sprintf ( awk->errmsg, ASE_COUNTOF(awk->errmsg), ASE_T("undefined identifier '%.*s'"), name_len, name); ase_awk_seterror (awk, ASE_AWK_EUNDEF, line, awk->errmsg); @@ -4585,7 +4585,7 @@ static int __get_token (ase_awk_t* awk) } else { - awk->sysfns.sprintf ( + awk->prmfns.sprintf ( awk->errmsg, ASE_COUNTOF(awk->errmsg), ASE_T("invalid character '%c'"), c); ase_awk_seterror ( diff --git a/ase/awk/rec.c b/ase/awk/rec.c index f7aa01d3..725e59d3 100644 --- a/ase/awk/rec.c +++ b/ase/awk/rec.c @@ -1,5 +1,5 @@ /* - * $Id: rec.c,v 1.12 2007-01-02 12:25:18 bacon Exp $ + * $Id: rec.c,v 1.13 2007-02-01 08:38:23 bacon Exp $ */ #include @@ -303,7 +303,7 @@ static int __recomp_record_fields ( * number of fields that the current record can hold, * the field spaces are resized */ - if (run->awk->sysfns.realloc != ASE_NULL) + if (run->awk->prmfns.realloc != ASE_NULL) { tmp = ASE_AWK_REALLOC ( run->awk, run->inrec.flds, diff --git a/ase/awk/rex.c b/ase/awk/rex.c index f4d56f7d..6554ee85 100644 --- a/ase/awk/rex.c +++ b/ase/awk/rex.c @@ -1,5 +1,5 @@ /* - * $Id: rex.c,v 1.54 2007-01-06 15:45:50 bacon Exp $ + * $Id: rex.c,v 1.55 2007-02-01 08:38:23 bacon Exp $ */ #include @@ -714,7 +714,7 @@ static int __build_charset (__builder_t* builder, struct __code_t* cmd) { /* invalid range */ #ifdef DEBUG_REX - builder->awk->sysfns.dprintf ( + builder->awk->prmfns.dprintf ( ASE_T("__build_charset: invalid character set range\n")); #endif builder->errnum = ASE_AWK_EREXCRANGE; @@ -747,7 +747,7 @@ static int __build_cclass (__builder_t* builder, ase_char_t* cc) { /* wrong class name */ #ifdef DEBUG_REX - builder->awk->sysfns.dprintf ( + builder->awk->prmfns.dprintf ( ASE_T("__build_cclass: wrong class name\n")); #endif builder->errnum = ASE_AWK_EREXCCLASS; @@ -761,7 +761,7 @@ static int __build_cclass (__builder_t* builder, ase_char_t* cc) builder->ptn.curc.value != ASE_T(':')) { #ifdef BUILD_REX - builder->awk->sysfns.dprintf ( + builder->awk->prmfns.dprintf ( ASE_T("__build_cclass: a colon(:) expected\n")); #endif builder->errnum = ASE_AWK_EREXCOLON; @@ -775,7 +775,7 @@ static int __build_cclass (__builder_t* builder, ase_char_t* cc) builder->ptn.curc.value != ASE_T(']')) { #ifdef DEBUG_REX - builder->awk->sysfns.dprintf ( + builder->awk->prmfns.dprintf ( ASE_T("__build_cclass: ] expected\n")); #endif builder->errnum = ASE_AWK_EREXRBRACKET; @@ -956,7 +956,7 @@ static int __add_code (__builder_t* builder, void* data, ase_size_t len) if (capa == 0) capa = DEF_CODE_CAPA; while (len > capa - builder->code.size) { capa = capa * 2; } - if (builder->awk->sysfns.realloc != ASE_NULL) + if (builder->awk->prmfns.realloc != ASE_NULL) { tmp = (ase_byte_t*) ASE_AWK_REALLOC ( builder->awk, builder->code.buf, capa); @@ -1023,7 +1023,7 @@ static const ase_byte_t* __match_pattern ( el = *(ase_size_t*)p; p += ASE_SIZEOF(el); #ifdef BUILD_REX - matcher->awk->sysfns.dprintf ( + matcher->awk->prmfns.dprintf ( ASE_T("__match_pattern: NB = %u, EL = %u\n"), (unsigned)nb, (unsigned)el); #endif @@ -1211,7 +1211,7 @@ static const ase_byte_t* __match_any_char ( } #ifdef BUILD_REX - matcher->awk->sysfns.dprintf ( + matcher->awk->prmfns.dprintf ( ASE_T("__match_any_char: lbound = %u, ubound = %u\n"), (unsigned int)lbound, (unsigned int)ubound); #endif @@ -1224,7 +1224,7 @@ static const ase_byte_t* __match_any_char ( } #ifdef BUILD_REX - matcher->awk->sysfns.dprintf ( + matcher->awk->prmfns.dprintf ( ASE_T("__match_any_char: max si = %u\n"), (unsigned)si); #endif @@ -1284,7 +1284,7 @@ static const ase_byte_t* __match_ord_char ( } #ifdef BUILD_REX - matcher->awk->sysfns.dprintf ( + matcher->awk->prmfns.dprintf ( ASE_T("__match_ord_char: cc = %c, lbound = %u, ubound = %u\n"), cc, (unsigned int)lbound, (unsigned int)ubound); #endif @@ -1299,7 +1299,7 @@ static const ase_byte_t* __match_ord_char ( { if (&mat->match_ptr[si] >= matcher->match.str.end) break; #ifdef DEBUG_REX - matcher->awk->sysfns.dprintf ( + matcher->awk->prmfns.dprintf ( ASE_T("__match_ord_char: %c %c\n"), cc, mat->match_ptr[si]); #endif @@ -1313,7 +1313,7 @@ static const ase_byte_t* __match_ord_char ( { if (&mat->match_ptr[si] >= matcher->match.str.end) break; #ifdef DEBUG_REX - matcher->awk->sysfns.dprintf ( + matcher->awk->prmfns.dprintf ( ASE_T("__match_ord_char: %c %c\n"), cc, mat->match_ptr[si]); #endif @@ -1323,7 +1323,7 @@ static const ase_byte_t* __match_ord_char ( } #ifdef DEBUG_REX - matcher->awk->sysfns.dprintf ( + matcher->awk->prmfns.dprintf ( ASE_T("__match_ord_char: max occurrences=%u, lbound=%u, ubound=%u\n"), (unsigned)si, (unsigned)lbound, (unsigned)ubound); #endif @@ -1355,7 +1355,7 @@ static const ase_byte_t* __match_charset ( csl = *(ase_size_t*)p; p += ASE_SIZEOF(csl); #ifdef BUILD_REX - matcher->awk->sysfns.dprintf ( + matcher->awk->prmfns.dprintf ( ASE_T("__match_charset: lbound = %u, ubound = %u\n"), (unsigned int)lbound, (unsigned int)ubound); #endif @@ -1380,7 +1380,7 @@ static const ase_byte_t* __match_charset ( p = p + csl - (ASE_SIZEOF(csc) + ASE_SIZEOF(csl)); #ifdef DEBUG_REX - matcher->awk->sysfns.dprintf ( + matcher->awk->prmfns.dprintf ( ASE_T("__match_charset: max occurrences=%u, lbound=%u, ubound=%u\n"), (unsigned)si, (unsigned)lbound, (unsigned)ubound); #endif @@ -1493,7 +1493,7 @@ static const ase_byte_t* __match_group ( mat2.branch_end = mat->branch_end; #ifdef DEBUG_REX - matcher->awk->sysfns.dprintf ( + matcher->awk->prmfns.dprintf ( ASE_T("__match_group: GROUP si=%d [%s]\n"), (unsigned)si, mat->match_ptr); #endif @@ -1594,7 +1594,7 @@ static const ase_byte_t* __match_occurrences ( mat2.branch_end = mat->branch_end; #ifdef DEBUG_REX - matcher->awk->sysfns.dprintf ( + matcher->awk->prmfns.dprintf ( ASE_T("__match occurrences: si=%u [%s]\n"), (unsigned)si, mat->match_ptr); #endif @@ -1634,7 +1634,7 @@ static ase_bool_t __test_charset ( if (matcher->ignorecase) c1 = ASE_AWK_TOUPPER(matcher->awk, c1); #ifdef DEBUG_REX - matcher->awk->sysfns.dprintf ( + matcher->awk->prmfns.dprintf ( ASE_T("__match_charset: %c %c\n"), c, c1); #endif if (c == c1) return ase_true; @@ -1651,7 +1651,7 @@ static ase_bool_t __test_charset ( c2 = ASE_AWK_TOUPPER(matcher->awk, c2); } #ifdef DEBUG_REX - matcher->awk->sysfns.dprintf ( + matcher->awk->prmfns.dprintf ( ASE_T("__match_charset: %c %c-%c\n"), c, c1, c2); #endif if (c >= c1 && c <= c2) return ase_true; @@ -1660,7 +1660,7 @@ static ase_bool_t __test_charset ( { c1 = *(const ase_char_t*)p; #ifdef DEBUG_REX - matcher->awk->sysfns.dprintf ( + matcher->awk->prmfns.dprintf ( ASE_T("__match_charset: %c %s\n"), c, __char_class[c1].name); #endif @@ -1745,7 +1745,7 @@ static ase_bool_t __cc_isxdigit (ase_awk_t* awk, ase_char_t c) void ase_awk_printrex (ase_awk_t* awk, void* rex) { __print_pattern (rex); - awk->sysfns.dprintf (ASE_T("\n")); + awk->prmfns.dprintf (ASE_T("\n")); } static const ase_byte_t* __print_pattern (const ase_byte_t* p) diff --git a/ase/awk/run.c b/ase/awk/run.c index 809033f6..1287a191 100644 --- a/ase/awk/run.c +++ b/ase/awk/run.c @@ -1,5 +1,5 @@ /* - * $Id: run.c,v 1.322 2007-01-30 10:55:27 bacon Exp $ + * $Id: run.c,v 1.323 2007-02-01 08:38:23 bacon Exp $ */ #include @@ -212,9 +212,9 @@ typedef ase_awk_val_t* (*eval_expr_t) (ase_awk_run_t* run, ase_awk_nde_t* nde); static int __printval (ase_awk_pair_t* pair, void* arg) { ase_awk_run_t* run = (ase_awk_run_t*)arg; - run->awk->sysfns.dprintf (ASE_T("%s = "), (const ase_char_t*)pair->key); + run->awk->prmfns.dprintf (ASE_T("%s = "), (const ase_char_t*)pair->key); ase_awk_dprintval (run, (ase_awk_val_t*)pair->val); - run->awk->sysfns.dprintf (ASE_T("\n")); + run->awk->prmfns.dprintf (ASE_T("\n")); return 0; } #endif @@ -253,7 +253,7 @@ static int __set_global ( if (var != ASE_NULL) { - run->awk->sysfns.sprintf ( + run->awk->prmfns.sprintf ( run->errmsg, ASE_COUNTOF(run->errmsg), ASE_T("map '%.*s' not assignable with a scalar"), var->id.name_len, var->id.name); @@ -1382,9 +1382,9 @@ static int __run_main ( else { #ifdef _DEBUG - run->awk->sysfns.dprintf (ASE_T("[RETURN] - ")); + run->awk->prmfns.dprintf (ASE_T("[RETURN] - ")); ase_awk_dprintval (run, v); - run->awk->sysfns.dprintf (ASE_T("\n")); + run->awk->prmfns.dprintf (ASE_T("\n")); #endif /* destroy the return value if necessary */ ase_awk_refupval (run, v); @@ -1501,9 +1501,9 @@ static int __run_main ( v = STACK_RETVAL(run); #ifdef _DEBUG - run->awk->sysfns.dprintf (ASE_T("[RETURN] - ")); + run->awk->prmfns.dprintf (ASE_T("[RETURN] - ")); ase_awk_dprintval (run, v); - run->awk->sysfns.dprintf (ASE_T("\n")); + run->awk->prmfns.dprintf (ASE_T("\n")); #endif /* the life of the global return value is over here @@ -1530,9 +1530,9 @@ static int __run_main ( run->exit_level = EXIT_NONE; #ifdef _DEBUG - run->awk->sysfns.dprintf (ASE_T("[VARIABLES]\n")); + run->awk->prmfns.dprintf (ASE_T("[VARIABLES]\n")); ase_awk_map_walk (&run->named, __printval, run); - run->awk->sysfns.dprintf (ASE_T("[END VARIABLES]\n")); + run->awk->prmfns.dprintf (ASE_T("[END VARIABLES]\n")); #endif return n; @@ -1753,7 +1753,7 @@ static int __run_block0 (ase_awk_run_t* run, ase_awk_nde_blk_t* nde) p = nde->body; nlocals = nde->nlocals; -/*run->awk->sysfns.dprintf (ASE_T("securing space for local variables nlocals = %d\n"), (int)nlocals);*/ +/*run->awk->prmfns.dprintf (ASE_T("securing space for local variables nlocals = %d\n"), (int)nlocals);*/ saved_stack_top = run->stack_top; /* secure space for local variables */ @@ -1770,10 +1770,10 @@ static int __run_block0 (ase_awk_run_t* run, ase_awk_nde_blk_t* nde) /* refupval is not required for ase_awk_val_nil */ } -/*run->awk->sysfns.dprintf (ASE_T("executing block statements\n"));*/ +/*run->awk->prmfns.dprintf (ASE_T("executing block statements\n"));*/ while (p != ASE_NULL && run->exit_level == EXIT_NONE) { -/*run->awk->sysfns.dprintf (ASE_T("running a statement\n"));*/ +/*run->awk->prmfns.dprintf (ASE_T("running a statement\n"));*/ if (__run_statement(run,p) == -1) { n = -1; @@ -1782,7 +1782,7 @@ static int __run_block0 (ase_awk_run_t* run, ase_awk_nde_blk_t* nde) p = p->next; } -/*run->awk->sysfns.dprintf (ASE_T("popping off local variables\n"));*/ +/*run->awk->prmfns.dprintf (ASE_T("popping off local variables\n"));*/ /* pop off local variables */ nlocals = nde->nlocals; while (nlocals > 0) @@ -2207,14 +2207,14 @@ static int __run_return (ase_awk_run_t* run, ase_awk_nde_return_t* nde) * by the parser first of all */ ASE_AWK_ASSERT (run->awk, nde->val->next == ASE_NULL); -/*run->awk->sysfns.dprintf (ASE_T("returning....\n"));*/ +/*run->awk->prmfns.dprintf (ASE_T("returning....\n"));*/ val = __eval_expression (run, nde->val); if (val == ASE_NULL) return -1; ase_awk_refdownval (run, STACK_RETVAL(run)); STACK_RETVAL(run) = val; ase_awk_refupval (run, val); /* see __eval_call for the trick */ -/*run->awk->sysfns.dprintf (ASE_T("set return value....\n"));*/ +/*run->awk->prmfns.dprintf (ASE_T("set return value....\n"));*/ } run->exit_level = EXIT_FUNCTION; @@ -2409,7 +2409,7 @@ static int __run_delete (ase_awk_run_t* run, ase_awk_nde_delete_t* nde) if (val->type != ASE_AWK_VAL_MAP) { - run->awk->sysfns.sprintf ( + run->awk->prmfns.sprintf ( run->errmsg, ASE_COUNTOF(run->errmsg), ASE_T("'%.*s' not deletable"), var->id.name_len, var->id.name); @@ -2520,7 +2520,7 @@ static int __run_delete (ase_awk_run_t* run, ase_awk_nde_delete_t* nde) if (val->type != ASE_AWK_VAL_MAP) { - run->awk->sysfns.sprintf ( + run->awk->prmfns.sprintf ( run->errmsg, ASE_COUNTOF(run->errmsg), ASE_T("'%.*s' not deletable"), var->id.name_len, var->id.name); @@ -3101,7 +3101,7 @@ static ase_awk_val_t* __do_assignment_scalar ( { /* once a variable becomes a map, * it cannot be changed to a scalar variable */ - run->awk->sysfns.sprintf ( + run->awk->prmfns.sprintf ( run->errmsg, ASE_COUNTOF(run->errmsg), ASE_T("map '%.*s' not assignable with a scalar"), var->id.name_len, var->id.name); @@ -3135,7 +3135,7 @@ static ase_awk_val_t* __do_assignment_scalar ( { /* once the variable becomes a map, * it cannot be changed to a scalar variable */ - run->awk->sysfns.sprintf ( + run->awk->prmfns.sprintf ( run->errmsg, ASE_COUNTOF(run->errmsg), ASE_T("map '%.*s' not assignable with a scalar"), var->id.name_len, var->id.name); @@ -3155,7 +3155,7 @@ static ase_awk_val_t* __do_assignment_scalar ( { /* once the variable becomes a map, * it cannot be changed to a scalar variable */ - run->awk->sysfns.sprintf ( + run->awk->prmfns.sprintf ( run->errmsg, ASE_COUNTOF(run->errmsg), ASE_T("map '%.*s' not assignable with a scalar"), var->id.name_len, var->id.name); @@ -3273,7 +3273,7 @@ static ase_awk_val_t* __do_assignment_map ( str = __idxnde_to_str (run, var->idx, &len); if (str == ASE_NULL) return ASE_NULL; -/*run->awk->sysfns.dprintf (ASE_T("**** index str=>%s, map->ref=%d, map->type=%d\n"), str, (int)map->ref, (int)map->type);*/ +/*run->awk->prmfns.dprintf (ASE_T("**** index str=>%s, map->ref=%d, map->type=%d\n"), str, (int)map->ref, (int)map->type);*/ n = ase_awk_map_putx (map->map, str, len, val, ASE_NULL); if (n < 0) { @@ -4361,7 +4361,7 @@ static ase_awk_val_t* __eval_binop_exp ( ase_real_t r1, r2; ase_awk_val_t* res; - ASE_AWK_ASSERTX (run->awk, run->awk->sysfns.pow != ASE_NULL, + ASE_AWK_ASSERTX (run->awk, run->awk->prmfns.pow != ASE_NULL, "the pow function should be provided when the awk object is created to make the exponentiation work properly."); n1 = ase_awk_valtonum (run, left, &l1, &r1); @@ -4422,14 +4422,14 @@ static ase_awk_val_t* __eval_binop_exp ( { /* left - int, right - real */ res = ase_awk_makerealval (run, - run->awk->sysfns.pow((ase_real_t)l1,(ase_real_t)r2)); + run->awk->prmfns.pow((ase_real_t)l1,(ase_real_t)r2)); } else { /* left - real, right - real */ ASE_AWK_ASSERT (run->awk, n3 == 3); res = ase_awk_makerealval (run, - run->awk->sysfns.pow((ase_real_t)r1,(ase_real_t)r2)); + run->awk->prmfns.pow((ase_real_t)r1,(ase_real_t)r2)); } if (res == ASE_NULL) @@ -5244,7 +5244,7 @@ static ase_awk_val_t* __eval_afn (ase_awk_run_t* run, ase_awk_nde_t* nde) if (len2 < ASE_COUNTOF(run->errmsg) && call->what.afn.name.len > ASE_COUNTOF(run->errmsg)-len2) { - run->awk->sysfns.sprintf ( + run->awk->prmfns.sprintf ( run->errmsg, ASE_COUNTOF(run->errmsg), fmt2, @@ -5253,7 +5253,7 @@ static ase_awk_val_t* __eval_afn (ase_awk_run_t* run, ase_awk_nde_t* nde) } else { - run->awk->sysfns.sprintf ( + run->awk->prmfns.sprintf ( run->errmsg, ASE_COUNTOF(run->errmsg), fmt, @@ -5358,7 +5358,7 @@ static ase_awk_val_t* __eval_call ( saved_stack_top = run->stack_top; -/*run->awk->sysfns.dprintf (ASE_T("setting up function stack frame stack_top = %ld stack_base = %ld\n"), run->stack_top, run->stack_base); */ +/*run->awk->prmfns.dprintf (ASE_T("setting up function stack frame stack_top = %ld stack_base = %ld\n"), run->stack_top, run->stack_base); */ if (__raw_push(run,(void*)run->stack_base) == -1) { ase_awk_setrunerror ( @@ -5483,7 +5483,7 @@ static ase_awk_val_t* __eval_call ( run->stack_base = saved_stack_top; STACK_NARGS(run) = (void*)nargs; -/*run->awk->sysfns.dprintf (ASE_T("running function body\n")); */ +/*run->awk->prmfns.dprintf (ASE_T("running function body\n")); */ if (afn != ASE_NULL) { @@ -5509,16 +5509,16 @@ static ase_awk_val_t* __eval_call ( } } -/*run->awk->sysfns.dprintf (ASE_T("block run complete\n")); */ +/*run->awk->prmfns.dprintf (ASE_T("block run complete\n")); */ /* refdown args in the run.stack */ nargs = (ase_size_t)STACK_NARGS(run); -/*run->awk->sysfns.dprintf (ASE_T("block run complete nargs = %d\n"), (int)nargs); */ +/*run->awk->prmfns.dprintf (ASE_T("block run complete nargs = %d\n"), (int)nargs); */ for (i = 0; i < nargs; i++) { ase_awk_refdownval (run, STACK_ARG(run,i)); } -/*run->awk->sysfns.dprintf (ASE_T("got return value\n")); */ +/*run->awk->prmfns.dprintf (ASE_T("got return value\n")); */ /* this trick has been mentioned in __run_return. * adjust the reference count of the return value. @@ -5533,7 +5533,7 @@ static ase_awk_val_t* __eval_call ( if (run->exit_level == EXIT_FUNCTION) run->exit_level = EXIT_NONE; -/*run->awk->sysfns.dprintf (ASE_T("returning from function stack_top=%ld, stack_base=%ld\n"), run->stack_top, run->stack_base); */ +/*run->awk->prmfns.dprintf (ASE_T("returning from function stack_top=%ld, stack_base=%ld\n"), run->stack_top, run->stack_base); */ return (n == -1)? ASE_NULL: v; } @@ -6102,7 +6102,7 @@ static int __raw_push (ase_awk_run_t* run, void* val) n = run->stack_limit + STACK_INCREMENT; - if (run->awk->sysfns.realloc != ASE_NULL) + if (run->awk->prmfns.realloc != ASE_NULL) { tmp = (void**) ASE_AWK_REALLOC ( run->awk, run->stack, n * ASE_SIZEOF(void*)); @@ -6154,7 +6154,7 @@ static int __read_record (ase_awk_run_t* run) return -1; } /* -run->awk->sysfns.dprintf (ASE_T("len = %d str=[%s]\n"), +run->awk->prmfns.dprintf (ASE_T("len = %d str=[%s]\n"), (int)ASE_AWK_STR_LEN(&run->inrec.line), ASE_AWK_STR_BUF(&run->inrec.line)); */ @@ -6472,7 +6472,7 @@ ase_char_t* ase_awk_format ( do { - n = run->awk->sysfns.sprintf ( + n = run->awk->prmfns.sprintf ( run->format.tmp.ptr, run->format.tmp.len, #if ASE_SIZEOF_LONG_LONG > 0 @@ -6575,7 +6575,7 @@ ase_char_t* ase_awk_format ( do { - n = run->awk->sysfns.sprintf ( + n = run->awk->prmfns.sprintf ( run->format.tmp.ptr, run->format.tmp.len, #if ASE_SIZEOF_LONG_LONG > 0 @@ -6695,7 +6695,7 @@ ase_char_t* ase_awk_format ( do { - n = run->awk->sysfns.sprintf ( + n = run->awk->prmfns.sprintf ( run->format.tmp.ptr, run->format.tmp.len, ASE_AWK_STR_BUF(fbu), @@ -6782,7 +6782,7 @@ ase_char_t* ase_awk_format ( do { - n = run->awk->sysfns.sprintf ( + n = run->awk->prmfns.sprintf ( run->format.tmp.ptr, run->format.tmp.len, ASE_AWK_STR_BUF(fbu), diff --git a/ase/awk/str.c b/ase/awk/str.c index 3ad3d031..1ff785fe 100644 --- a/ase/awk/str.c +++ b/ase/awk/str.c @@ -1,5 +1,5 @@ /* - * $Id: str.c,v 1.14 2006-12-13 14:16:12 bacon Exp $ + * $Id: str.c,v 1.15 2007-02-01 08:38:24 bacon Exp $ */ #include @@ -109,7 +109,7 @@ ase_size_t ase_awk_str_ncat ( /* double the capa if necessary for concatenation */ if (capa < str->capa * 2) capa = str->capa * 2; - if (str->awk->sysfns.realloc != ASE_NULL) + if (str->awk->prmfns.realloc != ASE_NULL) { tmp = (ase_char_t*) ASE_AWK_REALLOC ( str->awk, str->buf, diff --git a/ase/awk/tab.c b/ase/awk/tab.c index 0a68f1aa..594eac90 100644 --- a/ase/awk/tab.c +++ b/ase/awk/tab.c @@ -1,5 +1,5 @@ /* - * $Id: tab.c,v 1.27 2006-12-13 14:16:12 bacon Exp $ + * $Id: tab.c,v 1.28 2007-02-01 08:38:24 bacon Exp $ */ #include @@ -58,7 +58,7 @@ ase_awk_tab_t* ase_awk_tab_setcapa (ase_awk_tab_t* tab, ase_size_t capa) if (capa > 0) { - if (tab->awk->sysfns.realloc != ASE_NULL) + if (tab->awk->prmfns.realloc != ASE_NULL) { tmp = ASE_AWK_REALLOC (tab->awk, tab->buf, ASE_SIZEOF(*tab->buf) * capa); diff --git a/ase/awk/tree.c b/ase/awk/tree.c index bdff8a68..a00112bb 100644 --- a/ase/awk/tree.c +++ b/ase/awk/tree.c @@ -1,5 +1,5 @@ /* - * $Id: tree.c,v 1.99 2007-01-03 04:16:15 bacon Exp $ + * $Id: tree.c,v 1.100 2007-02-01 08:38:24 bacon Exp $ */ #include @@ -258,11 +258,11 @@ static int __print_expression (ase_awk_t* awk, ase_awk_nde_t* nde) { ase_char_t tmp[256]; #if (ASE_SIZEOF_LONG_DOUBLE != 0) - awk->sysfns.sprintf ( + awk->prmfns.sprintf ( tmp, ASE_COUNTOF(tmp), ASE_T("%Lf"), (long double)((ase_awk_nde_real_t*)nde)->val); #elif (ASE_SIZEOF_DOUBLE != 0) - awk->sysfns.sprintf ( + awk->prmfns.sprintf ( tmp, ASE_COUNTOF(tmp), ASE_T("%f"), (double)((ase_awk_nde_real_t*)nde)->val); #else diff --git a/ase/awk/val.c b/ase/awk/val.c index 395dbe3e..3ae32e86 100644 --- a/ase/awk/val.c +++ b/ase/awk/val.c @@ -1,5 +1,5 @@ /* - * $Id: val.c,v 1.104 2007-01-28 11:12:30 bacon Exp $ + * $Id: val.c,v 1.105 2007-02-01 08:38:24 bacon Exp $ */ #include @@ -339,9 +339,9 @@ void ase_awk_refupval (ase_awk_run_t* run, ase_awk_val_t* val) if (ase_awk_isbuiltinval(val)) return; /* -run->awk->sysfns.dprintf (ASE_T("ref up [ptr=%p] [count=%d] "), val, (int)val->ref); +run->awk->prmfns.dprintf (ASE_T("ref up [ptr=%p] [count=%d] "), val, (int)val->ref); ase_awk_dprintval (run, val); -run->awk->sysfns.dprintf (ASE_T("\n")); +run->awk->prmfns.dprintf (ASE_T("\n")); */ val->ref++; @@ -352,9 +352,9 @@ void ase_awk_refdownval (ase_awk_run_t* run, ase_awk_val_t* val) if (ase_awk_isbuiltinval(val)) return; /* -run->awk->sysfns.dprintf (ASE_T("ref down [ptr=%p] [count=%d]\n"), val, (int)val->ref); +run->awk->prmfns.dprintf (ASE_T("ref down [ptr=%p] [count=%d]\n"), val, (int)val->ref); ase_awk_dprintval (run, val); -run->awk->sysfns.dprintf (ASE_T("\n")); +run->awk->prmfns.dprintf (ASE_T("\n")); */ ASE_AWK_ASSERTX (run->awk, val->ref > 0, @@ -462,7 +462,7 @@ ase_char_t* ase_awk_valtostr ( } #ifdef _DEBUG - run->awk->sysfns.dprintf ( + run->awk->prmfns.dprintf ( ASE_T("ERROR: WRONG VALUE TYPE [%d] in ase_awk_valtostr\n"), v->type); #endif @@ -719,7 +719,7 @@ int ase_awk_valtonum ( } #ifdef _DEBUG - run->awk->sysfns.dprintf ( + run->awk->prmfns.dprintf ( ASE_T("ERROR: WRONG VALUE TYPE [%d] in ase_awk_valtonum\n"), v->type); #endif @@ -748,7 +748,7 @@ int ase_awk_strtonum ( } -#define __DPRINTF run->awk->sysfns.dprintf +#define __DPRINTF run->awk->prmfns.dprintf static int __print_pair (ase_awk_pair_t* pair, void* arg) { diff --git a/ase/com/Awk.cpp b/ase/com/Awk.cpp index a15b662e..c8fe3138 100644 --- a/ase/com/Awk.cpp +++ b/ase/com/Awk.cpp @@ -1,5 +1,5 @@ /* - * $Id: Awk.cpp,v 1.22 2007-01-25 14:14:55 bacon Exp $ + * $Id: Awk.cpp,v 1.23 2007-02-01 08:38:24 bacon Exp $ */ #include "stdafx.h" @@ -413,36 +413,36 @@ HRESULT CAwk::Parse (int* ret) { if (handle == NULL) { - ase_awk_sysfns_t sysfns; + ase_awk_prmfns_t prmfns; - memset (&sysfns, 0, sizeof(sysfns)); - sysfns.malloc = awk_malloc; - sysfns.realloc = awk_realloc; - sysfns.free = awk_free; + memset (&prmfns, 0, sizeof(prmfns)); + prmfns.malloc = awk_malloc; + prmfns.realloc = awk_realloc; + prmfns.free = awk_free; - sysfns.is_upper = iswupper; - sysfns.is_lower = iswlower; - sysfns.is_alpha = iswalpha; - sysfns.is_digit = iswdigit; - sysfns.is_xdigit = iswxdigit; - sysfns.is_alnum = iswalnum; - sysfns.is_space = iswspace; - sysfns.is_print = iswprint; - sysfns.is_graph = iswgraph; - sysfns.is_cntrl = iswcntrl; - sysfns.is_punct = iswpunct; - sysfns.to_upper = towupper; - sysfns.to_lower = towlower; + prmfns.is_upper = iswupper; + prmfns.is_lower = iswlower; + prmfns.is_alpha = iswalpha; + prmfns.is_digit = iswdigit; + 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; - sysfns.memcpy = memcpy; - sysfns.memset = memset; - sysfns.pow = awk_pow; - sysfns.sprintf = awk_sprintf; - sysfns.aprintf = awk_aprintf; - sysfns.dprintf = awk_dprintf; - sysfns.abort = awk_abort; + prmfns.memcpy = memcpy; + prmfns.memset = memset; + prmfns.pow = awk_pow; + prmfns.sprintf = awk_sprintf; + prmfns.aprintf = awk_aprintf; + prmfns.dprintf = awk_dprintf; + prmfns.abort = awk_abort; - handle = ase_awk_open (&sysfns, NULL, &errnum); + handle = ase_awk_open (&prmfns, NULL, &errnum); if (handle == NULL) { errlin = 0; diff --git a/ase/doc/ase.man b/ase/doc/ase.man index 15ed5a60..c37aba2b 100644 --- a/ase/doc/ase.man +++ b/ase/doc/ase.man @@ -2,9 +2,21 @@ ASE is a collection of scriping engines for various programming languages. It has been written in the hopt that it will be useful for programmers. + +== Source == + +ase - the root directory of the ase project +ase/awk - AWK module +ase/lsp - lisp module +ase/com - COM interface source code for ASE modules +ase/test/awk - +ase/test/lsp - +ase/test/com - +ase/etc - +ase/doc - + == License == The toolkit is distributed under the ASE general license. == Author == Chung, Hyung-Hwan, the sole author of ASE, is ... - diff --git a/ase/doc/ase.xdg b/ase/doc/ase.xdg new file mode 100644 index 00000000..f2c13995 --- /dev/null +++ b/ase/doc/ase.xdg @@ -0,0 +1,9 @@ +# +# XPKIT Document Generator Project File +# + +IndexFile: index.html +SourceExtension: .man +InputDir: +OutputDir: docs +Copyright: Copyright(c) 2005-2006 Chung, Hyung-Hwan. All rights reserved diff --git a/ase/doc/awk.man b/ase/doc/awk.man new file mode 100644 index 00000000..f192fdfc --- /dev/null +++ b/ase/doc/awk.man @@ -0,0 +1,93 @@ +.title Introduction To ASE AWK + +== OVERVIEW == + +=== What is it? === +'''''ASE AWK''''' is an embeddable implementation of the AWK programming language. It is composed of a set of C functions to help programmers embed the AWK interpreter to their own applications easily. + +=== What does it do? === +'''''ASE AWK''''' can do most of the things that other existing AWK interpreters can do. + +=== Differences with other implementations === +There exist a number of AWK interpreters available. Most of Unix/Linux operating systems come with an AWK interpreter. + +== DESCRIPTION == + +=== Interpreter === +Multiple instances of interpreters can be created in a single application and each instance of the interpreter created maintains its own state in the data structure pointed at by its handle of the type ''ase_awk_t''. + + * ase_awk_t - an abstract type to an interpreter object. + * ase_awk_open - creates an interpreter object. + * ase_awk_close - destroys the interprer object created by ase_awk_open. + +{{{ +ase_awk_t* ase_awk_open (void); +void ase_awk_close (ase_awk_t* awk); +}}} + +The interpreter provides two distinct functionalites in large; the parser and the executor. The parser transforms the source code into the internal parse tree and the executor evaluates the parse tree and runs the code. + +{{{ +int ase_awk_parse (ase_awk_t* awk); +int ase_awk_run (ase_awk_t* awk, ase_awk_io_t txtio, void* txtio_arg); +}}} + +=== IO Handlers === +'''''ASE AWK''''' does not provide any built-in IO handling routines. Instead, it requires users to provide them. 4 different IO streams should be provided to take full advantage of the interpreter. + + * Source code input + * Source code output + * Data input + * Data output + +{{{ +enum +{ + XP_AWK_INPUT_OPEN = 0, + XP_AWK_INPUT_CLOSE = 1, + XP_AWK_INPUT_NEXT = 2, + XP_AWK_INPUT_DATA = 3, + + XP_AWK_OUTPUT_OPEN = 4, + XP_AWK_OUTPUT_CLOSE = 5, + XP_AWK_OUTPUT_NEXT = 6, + XP_AWK_OUTPUT_DATA = 7 +}; + +typedef ase_ssize_t (*ase_awk_io_t) (int cmd, void* arg, ase_char_t* data, ase_size_t count); +}}} + +=== Miscellaneous Functions === +'''''ASE AWK''''' provides extra utility routines as well as the interpreter. These routines used by the interpreter can be accessed from the interested applications directly without regard to the interpreter. + +==== String ==== + +==== Conversion ==== + * ase_awk_strtolong - convert a numeric string to an integer of the ase_long_t type. + * ase_awk_strtoreal - convert a numeric string to a decimal number of the ase_real_t type. + +{{{ +ase_long_t ase_awk_strtolong (const ase_char_t* str, int base, const ase_char_t** endptr); +ase_real_t ase_awk_strtoreal (const ase_char_t* str); +}}} + +==== Regular Expression ==== +The regular expression routines built into the interpreter can replace other regular expression libraries available. By utilizing this, the application can have the identical regular expression functionalities as the embedded AWK interpreter. + +{{{ +ase_awk_rex_t* ase_awk_rex_open (ase_awk_rex_t* rex); +void ase_awk_rex_close (ase_awk_rex_t* rex); +}}} + +=== User-defined Built-in Functions === +Custom built-in functions can be added to the interpreter. This requires the deeper look into the internals of the interpreter. + +== EXAMPLE == +{{{ +#include + +int ase_main () +{ + return 0; +} +}}} diff --git a/ase/test/awk/awk.c b/ase/test/awk/awk.c index 57faccfa..02e62cc4 100644 --- a/ase/test/awk/awk.c +++ b/ase/test/awk/awk.c @@ -1,5 +1,5 @@ /* - * $Id: awk.c,v 1.159 2007-01-29 02:56:15 bacon Exp $ + * $Id: awk.c,v 1.160 2007-02-01 08:38:24 bacon Exp $ */ #include @@ -650,8 +650,8 @@ static void on_run_end ( } #ifdef _WIN32 -typedef struct sysfns_data_t sysfns_data_t; -struct sysfns_data_t +typedef struct prmfns_data_t prmfns_data_t; +struct prmfns_data_t { HANDLE heap; }; @@ -660,7 +660,7 @@ struct sysfns_data_t static void* awk_malloc (ase_size_t n, void* custom_data) { #ifdef _WIN32 - return HeapAlloc (((sysfns_data_t*)custom_data)->heap, 0, n); + return HeapAlloc (((prmfns_data_t*)custom_data)->heap, 0, n); #else return malloc (n); #endif @@ -671,9 +671,9 @@ static void* awk_realloc (void* ptr, ase_size_t n, void* custom_data) #ifdef _WIN32 /* HeapReAlloc behaves differently from realloc */ if (ptr == NULL) - return HeapAlloc (((sysfns_data_t*)custom_data)->heap, 0, n); + return HeapAlloc (((prmfns_data_t*)custom_data)->heap, 0, n); else - return HeapReAlloc (((sysfns_data_t*)custom_data)->heap, 0, ptr, n); + return HeapReAlloc (((prmfns_data_t*)custom_data)->heap, 0, ptr, n); #else return realloc (ptr, n); #endif @@ -682,7 +682,7 @@ static void* awk_realloc (void* ptr, ase_size_t n, void* custom_data) static void awk_free (void* ptr, void* custom_data) { #ifdef _WIN32 - HeapFree (((sysfns_data_t*)custom_data)->heap, 0, ptr); + HeapFree (((prmfns_data_t*)custom_data)->heap, 0, ptr); #else free (ptr); #endif @@ -742,11 +742,11 @@ static int __main (int argc, ase_char_t* argv[]) ase_awk_runcbs_t runcbs; ase_awk_runios_t runios; ase_awk_runarg_t runarg[10]; - ase_awk_sysfns_t sysfns; + ase_awk_prmfns_t prmfns; struct src_io src_io = { NULL, NULL }; int opt, i, file_count = 0, errnum; #ifdef _WIN32 - sysfns_data_t sysfns_data; + prmfns_data_t prmfns_data; #endif const ase_char_t* mfn = ASE_NULL; @@ -793,51 +793,51 @@ static int __main (int argc, ase_char_t* argv[]) } } - memset (&sysfns, 0, ASE_SIZEOF(sysfns)); + memset (&prmfns, 0, ASE_SIZEOF(prmfns)); - sysfns.malloc = awk_malloc; - sysfns.realloc = awk_realloc; - sysfns.free = awk_free; - sysfns.memcpy = memcpy; - sysfns.memset = memset; + prmfns.malloc = awk_malloc; + prmfns.realloc = awk_realloc; + prmfns.free = awk_free; + prmfns.memcpy = memcpy; + prmfns.memset = memset; - sysfns.is_upper = (ase_awk_isctype_t)awk_isupper; - sysfns.is_lower = (ase_awk_isctype_t)awk_islower; - sysfns.is_alpha = (ase_awk_isctype_t)awk_isalpha; - sysfns.is_digit = (ase_awk_isctype_t)awk_isdigit; - sysfns.is_xdigit = (ase_awk_isctype_t)awk_isxdigit; - sysfns.is_alnum = (ase_awk_isctype_t)awk_isalnum; - sysfns.is_space = (ase_awk_isctype_t)awk_isspace; - sysfns.is_print = (ase_awk_isctype_t)awk_isprint; - sysfns.is_graph = (ase_awk_isctype_t)awk_isgraph; - sysfns.is_cntrl = (ase_awk_isctype_t)awk_iscntrl; - sysfns.is_punct = (ase_awk_isctype_t)awk_ispunct; - sysfns.to_upper = (ase_awk_toctype_t)awk_toupper; - sysfns.to_lower = (ase_awk_toctype_t)awk_tolower; + prmfns.is_upper = (ase_awk_isctype_t)awk_isupper; + prmfns.is_lower = (ase_awk_isctype_t)awk_islower; + prmfns.is_alpha = (ase_awk_isctype_t)awk_isalpha; + prmfns.is_digit = (ase_awk_isctype_t)awk_isdigit; + prmfns.is_xdigit = (ase_awk_isctype_t)awk_isxdigit; + prmfns.is_alnum = (ase_awk_isctype_t)awk_isalnum; + prmfns.is_space = (ase_awk_isctype_t)awk_isspace; + prmfns.is_print = (ase_awk_isctype_t)awk_isprint; + prmfns.is_graph = (ase_awk_isctype_t)awk_isgraph; + prmfns.is_cntrl = (ase_awk_isctype_t)awk_iscntrl; + prmfns.is_punct = (ase_awk_isctype_t)awk_ispunct; + prmfns.to_upper = (ase_awk_toctype_t)awk_toupper; + prmfns.to_lower = (ase_awk_toctype_t)awk_tolower; - sysfns.pow = awk_pow; - sysfns.sprintf = awk_sprintf; - sysfns.aprintf = awk_aprintf; - sysfns.dprintf = awk_dprintf; - sysfns.abort = awk_abort; - sysfns.lock = NULL; - sysfns.unlock = NULL; + prmfns.pow = awk_pow; + prmfns.sprintf = awk_sprintf; + prmfns.aprintf = awk_aprintf; + prmfns.dprintf = awk_dprintf; + prmfns.abort = awk_abort; + prmfns.lock = NULL; + prmfns.unlock = NULL; #ifdef _WIN32 - sysfns_data.heap = HeapCreate (0, 1000000, 1000000); - if (sysfns_data.heap == NULL) + prmfns_data.heap = HeapCreate (0, 1000000, 1000000); + if (prmfns_data.heap == NULL) { awk_printf (ASE_T("Error: cannot create an awk heap\n")); return -1; } - sysfns.custom_data = &sysfns_data; + prmfns.custom_data = &prmfns_data; #endif - if ((awk = ase_awk_open(&sysfns, ASE_NULL, &errnum)) == ASE_NULL) + if ((awk = ase_awk_open(&prmfns, ASE_NULL, &errnum)) == ASE_NULL) { #ifdef _WIN32 - HeapDestroy (sysfns_data.heap); + HeapDestroy (prmfns_data.heap); #endif awk_printf ( ASE_T("ERROR: cannot open awk [%d] %s\n"), @@ -904,7 +904,7 @@ static int __main (int argc, ase_char_t* argv[]) ase_awk_close (awk); #ifdef _WIN32 - HeapDestroy (sysfns_data.heap); + HeapDestroy (prmfns_data.heap); #endif return 0; }