*** empty log message ***
This commit is contained in:
parent
0f31bffe69
commit
f6488f6eba
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: awk.c,v 1.101 2006-12-16 16:12:07 bacon Exp $
|
* $Id: awk.c,v 1.102 2006-12-19 14:20:29 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if defined(__BORLANDC__)
|
#if defined(__BORLANDC__)
|
||||||
@ -114,6 +114,7 @@ ase_awk_t* ase_awk_open (const ase_awk_sysfns_t* sysfns, int* errnum)
|
|||||||
|
|
||||||
awk->option = 0;
|
awk->option = 0;
|
||||||
awk->errnum = ASE_AWK_ENOERR;
|
awk->errnum = ASE_AWK_ENOERR;
|
||||||
|
awk->errlin = 0;
|
||||||
|
|
||||||
awk->parse.nlocals_max = 0;
|
awk->parse.nlocals_max = 0;
|
||||||
|
|
||||||
@ -260,11 +261,6 @@ void ase_awk_setopt (ase_awk_t* awk, int opt)
|
|||||||
awk->option = opt;
|
awk->option = opt;
|
||||||
}
|
}
|
||||||
|
|
||||||
ase_size_t ase_awk_getsrcline (ase_awk_t* awk)
|
|
||||||
{
|
|
||||||
return awk->token.line;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ase_awk_setmaxrundepth (ase_awk_t* awk, int types, ase_size_t depth)
|
void ase_awk_setmaxrundepth (ase_awk_t* awk, int types, ase_size_t depth)
|
||||||
{
|
{
|
||||||
if (types & ASE_AWK_DEPTH_BLOCK)
|
if (types & ASE_AWK_DEPTH_BLOCK)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: awk.h,v 1.169 2006-12-17 14:56:05 bacon Exp $
|
* $Id: awk.h,v 1.170 2006-12-19 14:20:30 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _ASE_AWK_AWK_H_
|
#ifndef _ASE_AWK_AWK_H_
|
||||||
@ -309,9 +309,9 @@ enum
|
|||||||
ASE_AWK_EOPERAND, /* invalid operand */
|
ASE_AWK_EOPERAND, /* invalid operand */
|
||||||
ASE_AWK_EPOSIDX, /* wrong position index */
|
ASE_AWK_EPOSIDX, /* wrong position index */
|
||||||
ASE_AWK_ENOSUCHFN, /* no such function */
|
ASE_AWK_ENOSUCHFN, /* no such function */
|
||||||
ASE_AWK_ENOTASSIGNABLE, /* value not assignable */
|
ASE_AWK_ENOASS, /* value not assignable */
|
||||||
ASE_AWK_ENOTINDEXABLE, /* not indexable variable */
|
ASE_AWK_ENOIDX, /* variable not indexable */
|
||||||
ASE_AWK_ENOTDELETABLE, /* not deletable variable */
|
ASE_AWK_ENODEL, /* variable not deletable */
|
||||||
ASE_AWK_ENOTREFERENCEABLE, /* not referenceable value */
|
ASE_AWK_ENOTREFERENCEABLE, /* not referenceable value */
|
||||||
ASE_AWK_EIDXVALASSMAP, /* indexed value cannot be assigned a map */
|
ASE_AWK_EIDXVALASSMAP, /* indexed value cannot be assigned a map */
|
||||||
ASE_AWK_EPOSVALASSMAP, /* a positional cannot be assigned a map */
|
ASE_AWK_EPOSVALASSMAP, /* a positional cannot be assigned a map */
|
||||||
@ -402,7 +402,11 @@ int ase_awk_close (ase_awk_t* awk);
|
|||||||
int ase_awk_clear (ase_awk_t* awk);
|
int ase_awk_clear (ase_awk_t* awk);
|
||||||
|
|
||||||
int ase_awk_geterrnum (ase_awk_t* awk);
|
int ase_awk_geterrnum (ase_awk_t* awk);
|
||||||
ase_size_t ase_awk_getsrcline (ase_awk_t* awk);
|
ase_size_t ase_awk_geterrlin (ase_awk_t* awk);
|
||||||
|
const ase_char_t* ase_awk_geterrmsg (ase_awk_t* awk);
|
||||||
|
void ase_awk_seterror (
|
||||||
|
ase_awk_t* run, int errnum,
|
||||||
|
ase_size_t errlin, const ase_char_t* msg);
|
||||||
|
|
||||||
int ase_awk_getopt (ase_awk_t* awk);
|
int ase_awk_getopt (ase_awk_t* awk);
|
||||||
void ase_awk_setopt (ase_awk_t* awk, int opt);
|
void ase_awk_setopt (ase_awk_t* awk, int opt);
|
||||||
@ -451,7 +455,7 @@ void* ase_awk_getruncustomdata (ase_awk_run_t* awk);
|
|||||||
|
|
||||||
/* functions to manipulate the run-time error */
|
/* functions to manipulate the run-time error */
|
||||||
int ase_awk_getrunerrnum (ase_awk_run_t* run);
|
int ase_awk_getrunerrnum (ase_awk_run_t* run);
|
||||||
int ase_awk_getrunerrlin (ase_awk_run_t* run);
|
ase_size_t ase_awk_getrunerrlin (ase_awk_run_t* run);
|
||||||
const ase_char_t* ase_awk_getrunerrmsg (ase_awk_run_t* run);
|
const ase_char_t* ase_awk_getrunerrmsg (ase_awk_run_t* run);
|
||||||
void ase_awk_setrunerrnum (ase_awk_run_t* run, int errnum);
|
void ase_awk_setrunerrnum (ase_awk_run_t* run, int errnum);
|
||||||
void ase_awk_setrunerror (
|
void ase_awk_setrunerror (
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: awk_i.h,v 1.93 2006-12-17 14:56:06 bacon Exp $
|
* $Id: awk_i.h,v 1.94 2006-12-19 14:20:30 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _ASE_AWK_AWKI_H_
|
#ifndef _ASE_AWK_AWKI_H_
|
||||||
@ -135,7 +135,8 @@ struct ase_awk_t
|
|||||||
ase_awk_tab_t params;
|
ase_awk_tab_t params;
|
||||||
ase_size_t nlocals_max;
|
ase_size_t nlocals_max;
|
||||||
|
|
||||||
ase_awk_nde_t* (*parse_block) (ase_awk_t*,ase_bool_t);
|
ase_awk_nde_t* (*parse_block) (
|
||||||
|
ase_awk_t*,ase_size_t,ase_bool_t);
|
||||||
} parse;
|
} parse;
|
||||||
|
|
||||||
/* source code management */
|
/* source code management */
|
||||||
@ -207,6 +208,8 @@ struct ase_awk_t
|
|||||||
|
|
||||||
/* housekeeping */
|
/* housekeeping */
|
||||||
int errnum;
|
int errnum;
|
||||||
|
ase_size_t errlin;
|
||||||
|
ase_char_t errmsg[256];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ase_awk_chain_t
|
struct ase_awk_chain_t
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: err.c,v 1.61 2006-12-17 14:56:06 bacon Exp $
|
* $Id: err.c,v 1.62 2006-12-19 14:20:30 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ase/awk/awk_i.h>
|
#include <ase/awk/awk_i.h>
|
||||||
@ -9,6 +9,28 @@ int ase_awk_geterrnum (ase_awk_t* awk)
|
|||||||
return awk->errnum;
|
return awk->errnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ase_size_t ase_awk_geterrlin (ase_awk_t* awk)
|
||||||
|
{
|
||||||
|
return awk->errlin;
|
||||||
|
}
|
||||||
|
|
||||||
|
const ase_char_t* ase_awk_geterrmsg (ase_awk_t* awk)
|
||||||
|
{
|
||||||
|
if (awk->errmsg[0] == ASE_T('\0'))
|
||||||
|
return ase_awk_geterrstr (awk->errnum);
|
||||||
|
return awk->errmsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ase_awk_seterror (
|
||||||
|
ase_awk_t* awk, int errnum,
|
||||||
|
ase_size_t errlin, const ase_char_t* msg)
|
||||||
|
{
|
||||||
|
awk->errnum = errnum;
|
||||||
|
awk->errlin = errlin;
|
||||||
|
if (msg == ASE_NULL) awk->errmsg[0] = ASE_T('\0');
|
||||||
|
else ase_awk_strxcpy (awk->errmsg, ASE_COUNTOF(awk->errmsg), msg);
|
||||||
|
}
|
||||||
|
|
||||||
const ase_char_t* ase_awk_geterrstr (int errnum)
|
const ase_char_t* ase_awk_geterrstr (int errnum)
|
||||||
{
|
{
|
||||||
static const ase_char_t* __errstr[] =
|
static const ase_char_t* __errstr[] =
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: jni.c,v 1.42 2006-12-16 14:43:50 bacon Exp $
|
* $Id: jni.c,v 1.43 2006-12-19 14:20:30 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -331,8 +331,8 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_parse (JNIEnv* env, jobject obj)
|
|||||||
|
|
||||||
n = snprintf (msg, sizeof(msg),
|
n = snprintf (msg, sizeof(msg),
|
||||||
"parse error at line %d: %S",
|
"parse error at line %d: %S",
|
||||||
ase_awk_getsrcline(awk),
|
ase_awk_geterrlin(awk),
|
||||||
ase_awk_geterrstr(ase_awk_geterrnum(awk)));
|
ase_awk_geterrmsg(awk));
|
||||||
if (n < 0 || n >= sizeof(msg)) msg[sizeof(msg)-1] = '\0';
|
if (n < 0 || n >= sizeof(msg)) msg[sizeof(msg)-1] = '\0';
|
||||||
|
|
||||||
(*env)->ThrowNew (env, except, msg);
|
(*env)->ThrowNew (env, except, msg);
|
||||||
|
535
ase/awk/parse.c
535
ase/awk/parse.c
File diff suppressed because it is too large
Load Diff
147
ase/awk/run.c
147
ase/awk/run.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: run.c,v 1.304 2006-12-17 14:56:06 bacon Exp $
|
* $Id: run.c,v 1.305 2006-12-19 14:20:30 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ase/awk/awk_i.h>
|
#include <ase/awk/awk_i.h>
|
||||||
@ -547,7 +547,7 @@ int ase_awk_getrunerrnum (ase_awk_run_t* run)
|
|||||||
return run->errnum;
|
return run->errnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ase_awk_getrunerrlin (ase_awk_run_t* run)
|
ase_size_t ase_awk_getrunerrlin (ase_awk_run_t* run)
|
||||||
{
|
{
|
||||||
return run->errlin;
|
return run->errlin;
|
||||||
}
|
}
|
||||||
@ -588,7 +588,7 @@ int ase_awk_run (ase_awk_t* awk,
|
|||||||
int n, errnum;
|
int n, errnum;
|
||||||
|
|
||||||
/* clear the awk error code */
|
/* clear the awk error code */
|
||||||
awk->errnum = ASE_AWK_ENOERR;
|
ase_awk_seterror (awk, ASE_AWK_ENOERR, 0, ASE_NULL);
|
||||||
|
|
||||||
/* check if the code has ever been parsed */
|
/* check if the code has ever been parsed */
|
||||||
if (awk->tree.nglobals == 0 &&
|
if (awk->tree.nglobals == 0 &&
|
||||||
@ -598,7 +598,7 @@ int ase_awk_run (ase_awk_t* awk,
|
|||||||
ase_awk_map_getsize(&awk->tree.afns) == 0)
|
ase_awk_map_getsize(&awk->tree.afns) == 0)
|
||||||
{
|
{
|
||||||
/* if not, deny the run */
|
/* if not, deny the run */
|
||||||
awk->errnum = ASE_AWK_ENOPER;
|
ase_awk_seterror (awk, ASE_AWK_ENOPER, 0, ASE_NULL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -608,7 +608,7 @@ int ase_awk_run (ase_awk_t* awk,
|
|||||||
{
|
{
|
||||||
/* if it fails, the failure is reported thru
|
/* if it fails, the failure is reported thru
|
||||||
* the awk object */
|
* the awk object */
|
||||||
awk->errnum = ASE_AWK_ENOMEM;
|
ase_awk_seterror (awk, ASE_AWK_ENOMEM, 0, ASE_NULL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -623,9 +623,9 @@ int ase_awk_run (ase_awk_t* awk,
|
|||||||
{
|
{
|
||||||
/* if it fails, the failure is still reported thru
|
/* if it fails, the failure is still reported thru
|
||||||
* the awk object */
|
* the awk object */
|
||||||
awk->errnum = errnum;
|
ase_awk_seterror (awk, errnum, 0, ASE_NULL);
|
||||||
__del_run (awk, run);
|
|
||||||
|
|
||||||
|
__del_run (awk, run);
|
||||||
ASE_AWK_FREE (awk, run);
|
ASE_AWK_FREE (awk, run);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -645,8 +645,16 @@ int ase_awk_run (ase_awk_t* awk,
|
|||||||
{
|
{
|
||||||
/* if no callback is specified, awk's error number
|
/* if no callback is specified, awk's error number
|
||||||
* is updated with the run's error number */
|
* is updated with the run's error number */
|
||||||
awk->errnum = (runcbs == ASE_NULL)?
|
if (runcbs == ASE_NULL)
|
||||||
run->errnum: ASE_AWK_ERUNTIME;
|
{
|
||||||
|
ase_awk_seterror (
|
||||||
|
awk, run->errnum, run->errlin, ASE_NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ase_awk_seterror (
|
||||||
|
awk, ASE_AWK_ERUNTIME, 0, ASE_NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* the run loop ended. execute the end callback if it exists */
|
/* the run loop ended. execute the end callback if it exists */
|
||||||
@ -2122,7 +2130,7 @@ static int __run_foreach (ase_awk_run_t* run, ase_awk_nde_foreach_t* nde)
|
|||||||
if (rv->type != ASE_AWK_VAL_MAP)
|
if (rv->type != ASE_AWK_VAL_MAP)
|
||||||
{
|
{
|
||||||
ase_awk_refdownval (run, rv);
|
ase_awk_refdownval (run, rv);
|
||||||
PANIC_I (run, ASE_AWK_ENOTINDEXABLE);
|
PANIC_I (run, ASE_AWK_ENOIDX);
|
||||||
}
|
}
|
||||||
map = ((ase_awk_val_map_t*)rv)->map;
|
map = ((ase_awk_val_map_t*)rv)->map;
|
||||||
|
|
||||||
@ -2199,26 +2207,42 @@ static int __run_next (ase_awk_run_t* run, ase_awk_nde_next_t* nde)
|
|||||||
/* the parser checks if next has been called in the begin/end
|
/* the parser checks if next has been called in the begin/end
|
||||||
* block or whereever inappropriate. so the runtime doesn't
|
* block or whereever inappropriate. so the runtime doesn't
|
||||||
* check that explicitly */
|
* check that explicitly */
|
||||||
|
if (run->active_block == (ase_awk_nde_blk_t*)run->awk->tree.begin)
|
||||||
if (run->active_block == (ase_awk_nde_blk_t*)run->awk->tree.begin ||
|
|
||||||
run->active_block == (ase_awk_nde_blk_t*)run->awk->tree.end)
|
|
||||||
{
|
{
|
||||||
PANIC_I (run, ASE_AWK_ENEXTCALL);
|
ase_awk_setrunerror (
|
||||||
|
run, ASE_AWK_ENEXTCALL, nde->line,
|
||||||
|
ASE_T("next called from the BEGIN block"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else if (run->active_block == (ase_awk_nde_blk_t*)run->awk->tree.end)
|
||||||
|
{
|
||||||
|
ase_awk_setrunerror (
|
||||||
|
run, ASE_AWK_ENEXTCALL, nde->line,
|
||||||
|
ASE_T("next called from the END block"));
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
run->exit_level = EXIT_NEXT;
|
run->exit_level = EXIT_NEXT;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __run_nextinfile (ase_awk_run_t* run)
|
static int __run_nextinfile (ase_awk_run_t* run, ase_awk_nde_nextfile_t* nde)
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
/* normal nextfile statement */
|
/* normal nextfile statement */
|
||||||
if (run->active_block == (ase_awk_nde_blk_t*)run->awk->tree.begin ||
|
if (run->active_block == (ase_awk_nde_blk_t*)run->awk->tree.begin)
|
||||||
run->active_block == (ase_awk_nde_blk_t*)run->awk->tree.end)
|
|
||||||
{
|
{
|
||||||
run->errnum = ASE_AWK_ENEXTFILECALL;
|
ase_awk_setrunerror (
|
||||||
|
run, ASE_AWK_ENEXTCALL, nde->line,
|
||||||
|
ASE_T("nextfile called from the BEGIN block"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
else if (run->active_block == (ase_awk_nde_blk_t*)run->awk->tree.end)
|
||||||
|
{
|
||||||
|
ase_awk_setrunerror (
|
||||||
|
run, ASE_AWK_ENEXTCALL, nde->line,
|
||||||
|
ASE_T("nextfile called from the END block"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2227,6 +2251,8 @@ static int __run_nextinfile (ase_awk_run_t* run)
|
|||||||
{
|
{
|
||||||
if (run->errnum == ASE_AWK_EIOHANDLER)
|
if (run->errnum == ASE_AWK_EIOHANDLER)
|
||||||
run->errnum = ASE_AWK_ECONINNEXT;
|
run->errnum = ASE_AWK_ECONINNEXT;
|
||||||
|
ase_awk_setrunerror (
|
||||||
|
run, run->errnum, nde->line, ASE_NULL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2237,14 +2263,19 @@ static int __run_nextinfile (ase_awk_run_t* run)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (__update_fnr (run, 0) == -1) return -1;
|
if (__update_fnr (run, 0) == -1)
|
||||||
|
{
|
||||||
|
ase_awk_setrunerror (
|
||||||
|
run, run->errnum, nde->line, ASE_NULL);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
run->exit_level = EXIT_NEXT;
|
run->exit_level = EXIT_NEXT;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __run_nextoutfile (ase_awk_run_t* run)
|
static int __run_nextoutfile (ase_awk_run_t* run, ase_awk_nde_nextfile_t* nde)
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
@ -2253,6 +2284,8 @@ static int __run_nextoutfile (ase_awk_run_t* run)
|
|||||||
{
|
{
|
||||||
if (run->errnum == ASE_AWK_EIOHANDLER)
|
if (run->errnum == ASE_AWK_EIOHANDLER)
|
||||||
run->errnum = ASE_AWK_ECONOUTNEXT;
|
run->errnum = ASE_AWK_ECONOUTNEXT;
|
||||||
|
ase_awk_setrunerror (
|
||||||
|
run, run->errnum, nde->line, ASE_NULL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2269,7 +2302,9 @@ static int __run_nextoutfile (ase_awk_run_t* run)
|
|||||||
|
|
||||||
static int __run_nextfile (ase_awk_run_t* run, ase_awk_nde_nextfile_t* nde)
|
static int __run_nextfile (ase_awk_run_t* run, ase_awk_nde_nextfile_t* nde)
|
||||||
{
|
{
|
||||||
return (nde->out)? __run_nextoutfile (run): __run_nextinfile (run);
|
return (nde->out)?
|
||||||
|
__run_nextoutfile (run, nde):
|
||||||
|
__run_nextinfile (run, nde);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int __run_delete (ase_awk_run_t* run, ase_awk_nde_delete_t* nde)
|
static int __run_delete (ase_awk_run_t* run, ase_awk_nde_delete_t* nde)
|
||||||
@ -2300,7 +2335,8 @@ static int __run_delete (ase_awk_run_t* run, ase_awk_nde_delete_t* nde)
|
|||||||
tmp = ase_awk_makemapval (run);
|
tmp = ase_awk_makemapval (run);
|
||||||
if (tmp == ASE_NULL)
|
if (tmp == ASE_NULL)
|
||||||
{
|
{
|
||||||
run->errnum = ASE_AWK_ENOMEM;
|
ase_awk_setrunerror (run,
|
||||||
|
ASE_AWK_ENOMEM, nde->line, ASE_NULL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2309,7 +2345,9 @@ static int __run_delete (ase_awk_run_t* run, ase_awk_nde_delete_t* nde)
|
|||||||
{
|
{
|
||||||
ase_awk_refupval (run, tmp);
|
ase_awk_refupval (run, tmp);
|
||||||
ase_awk_refdownval (run, tmp);
|
ase_awk_refdownval (run, tmp);
|
||||||
run->errnum = ASE_AWK_ENOMEM;
|
|
||||||
|
ase_awk_setrunerror (run,
|
||||||
|
ASE_AWK_ENOMEM, var->line, ASE_NULL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2327,7 +2365,14 @@ static int __run_delete (ase_awk_run_t* run, ase_awk_nde_delete_t* nde)
|
|||||||
|
|
||||||
if (val->type != ASE_AWK_VAL_MAP)
|
if (val->type != ASE_AWK_VAL_MAP)
|
||||||
{
|
{
|
||||||
run->errnum = ASE_AWK_ENOTDELETABLE;
|
ase_char_t msg[ASE_COUNTOF(run->errmsg)];
|
||||||
|
run->awk->sysfns.sprintf (
|
||||||
|
msg, ASE_COUNTOF(msg),
|
||||||
|
ASE_T("%.*s not deletable"),
|
||||||
|
var->id.name_len, var->id.name);
|
||||||
|
ase_awk_setrunerror (run,
|
||||||
|
ASE_AWK_ENODEL,
|
||||||
|
var->line, msg);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2341,7 +2386,12 @@ static int __run_delete (ase_awk_run_t* run, ase_awk_nde_delete_t* nde)
|
|||||||
ASE_AWK_ASSERT (run->awk, var->idx != ASE_NULL);
|
ASE_AWK_ASSERT (run->awk, var->idx != ASE_NULL);
|
||||||
|
|
||||||
idx = __eval_expression (run, var->idx);
|
idx = __eval_expression (run, var->idx);
|
||||||
if (idx == ASE_NULL) return -1;
|
if (idx == ASE_NULL)
|
||||||
|
{
|
||||||
|
ase_awk_setrunerror (run,
|
||||||
|
run->errnum, var->line, ASE_NULL);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
ase_awk_refupval (run, idx);
|
ase_awk_refupval (run, idx);
|
||||||
key = ase_awk_valtostr (
|
key = ase_awk_valtostr (
|
||||||
@ -2349,7 +2399,12 @@ static int __run_delete (ase_awk_run_t* run, ase_awk_nde_delete_t* nde)
|
|||||||
ASE_NULL, &key_len);
|
ASE_NULL, &key_len);
|
||||||
ase_awk_refdownval (run, idx);
|
ase_awk_refdownval (run, idx);
|
||||||
|
|
||||||
if (key == ASE_NULL) return -1;
|
if (key == ASE_NULL)
|
||||||
|
{
|
||||||
|
ase_awk_setrunerror (run,
|
||||||
|
run->errnum, var->line, ASE_NULL);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
ase_awk_map_remove (map, key, key_len);
|
ase_awk_map_remove (map, key, key_len);
|
||||||
ASE_AWK_FREE (run->awk, key);
|
ASE_AWK_FREE (run->awk, key);
|
||||||
@ -2389,7 +2444,8 @@ static int __run_delete (ase_awk_run_t* run, ase_awk_nde_delete_t* nde)
|
|||||||
tmp = ase_awk_makemapval (run);
|
tmp = ase_awk_makemapval (run);
|
||||||
if (tmp == ASE_NULL)
|
if (tmp == ASE_NULL)
|
||||||
{
|
{
|
||||||
run->errnum = ASE_AWK_ENOMEM;
|
ase_awk_setrunerror (run,
|
||||||
|
ASE_AWK_ENOMEM, nde->line, ASE_NULL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2403,6 +2459,8 @@ static int __run_delete (ase_awk_run_t* run, ase_awk_nde_delete_t* nde)
|
|||||||
{
|
{
|
||||||
ase_awk_refupval (run, tmp);
|
ase_awk_refupval (run, tmp);
|
||||||
ase_awk_refdownval (run, tmp);
|
ase_awk_refdownval (run, tmp);
|
||||||
|
ase_awk_setrunerror (run,
|
||||||
|
run->errnum, var->line, ASE_NULL);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2424,7 +2482,14 @@ static int __run_delete (ase_awk_run_t* run, ase_awk_nde_delete_t* nde)
|
|||||||
|
|
||||||
if (val->type != ASE_AWK_VAL_MAP)
|
if (val->type != ASE_AWK_VAL_MAP)
|
||||||
{
|
{
|
||||||
run->errnum = ASE_AWK_ENOTDELETABLE;
|
ase_char_t msg[ASE_COUNTOF(run->errmsg)];
|
||||||
|
run->awk->sysfns.sprintf (
|
||||||
|
msg, ASE_COUNTOF(msg),
|
||||||
|
ASE_T("%.*s not deletable"),
|
||||||
|
var->id.name_len, var->id.name);
|
||||||
|
ase_awk_setrunerror (run,
|
||||||
|
ASE_AWK_ENODEL,
|
||||||
|
var->line, msg);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2440,7 +2505,12 @@ static int __run_delete (ase_awk_run_t* run, ase_awk_nde_delete_t* nde)
|
|||||||
ASE_AWK_ASSERT (run->awk, var->idx != ASE_NULL);
|
ASE_AWK_ASSERT (run->awk, var->idx != ASE_NULL);
|
||||||
|
|
||||||
idx = __eval_expression (run, var->idx);
|
idx = __eval_expression (run, var->idx);
|
||||||
if (idx == ASE_NULL) return -1;
|
if (idx == ASE_NULL)
|
||||||
|
{
|
||||||
|
ase_awk_setrunerror (run,
|
||||||
|
run->errnum, var->line, ASE_NULL);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
ase_awk_refupval (run, idx);
|
ase_awk_refupval (run, idx);
|
||||||
key = ase_awk_valtostr (
|
key = ase_awk_valtostr (
|
||||||
@ -2448,7 +2518,12 @@ static int __run_delete (ase_awk_run_t* run, ase_awk_nde_delete_t* nde)
|
|||||||
ASE_NULL, &key_len);
|
ASE_NULL, &key_len);
|
||||||
ase_awk_refdownval (run, idx);
|
ase_awk_refdownval (run, idx);
|
||||||
|
|
||||||
if (key == ASE_NULL) return -1;
|
if (key == ASE_NULL)
|
||||||
|
{
|
||||||
|
ase_awk_setrunerror (run,
|
||||||
|
run->errnum, var->line, ASE_NULL);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
ase_awk_map_remove (map, key, key_len);
|
ase_awk_map_remove (map, key, key_len);
|
||||||
ASE_AWK_FREE (run->awk, key);
|
ASE_AWK_FREE (run->awk, key);
|
||||||
@ -2462,9 +2537,9 @@ static int __run_delete (ase_awk_run_t* run, ase_awk_nde_delete_t* nde)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
ASE_AWK_ASSERTX (run->awk,
|
ASE_AWK_ASSERTX (run->awk,
|
||||||
!"should never happen - wrong variable type for delete",
|
!"should never happen - wrong target for delete",
|
||||||
"the delete statement cannot be called with other nodes than the variables such as a named variable, a named indexed variable, etc");
|
"the delete statement cannot be called with other nodes than the variables such as a named variable, a named indexed variable, etc");
|
||||||
run->errnum = ASE_AWK_EINTERNAL;
|
ase_awk_setrunerror (run, ASE_AWK_EINTERNAL, var->line, "delete statement called with a wrong target");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2941,7 +3016,7 @@ static ase_awk_val_t* __do_assignment (
|
|||||||
if (val->type == ASE_AWK_VAL_MAP)
|
if (val->type == ASE_AWK_VAL_MAP)
|
||||||
{
|
{
|
||||||
/* a map cannot be assigned to a variable */
|
/* a map cannot be assigned to a variable */
|
||||||
PANIC (run, ASE_AWK_ENOTASSIGNABLE);
|
PANIC (run, ASE_AWK_ENOASS);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (var->type == ASE_AWK_NDE_NAMED ||
|
if (var->type == ASE_AWK_NDE_NAMED ||
|
||||||
@ -3123,7 +3198,7 @@ static ase_awk_val_t* __do_assignment_map (
|
|||||||
}
|
}
|
||||||
else if (map->type != ASE_AWK_VAL_MAP)
|
else if (map->type != ASE_AWK_VAL_MAP)
|
||||||
{
|
{
|
||||||
PANIC (run, ASE_AWK_ENOTINDEXABLE);
|
PANIC (run, ASE_AWK_ENOIDX);
|
||||||
}
|
}
|
||||||
|
|
||||||
str = __idxnde_to_str (run, var->idx, &len);
|
str = __idxnde_to_str (run, var->idx, &len);
|
||||||
@ -5265,7 +5340,7 @@ static ase_awk_val_t** __get_reference_indexed (
|
|||||||
}
|
}
|
||||||
else if ((*val)->type != ASE_AWK_VAL_MAP)
|
else if ((*val)->type != ASE_AWK_VAL_MAP)
|
||||||
{
|
{
|
||||||
PANIC (run, ASE_AWK_ENOTINDEXABLE);
|
PANIC (run, ASE_AWK_ENOIDX);
|
||||||
}
|
}
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk, nde->idx != ASE_NULL);
|
ASE_AWK_ASSERT (run->awk, nde->idx != ASE_NULL);
|
||||||
@ -5387,7 +5462,7 @@ static ase_awk_val_t* __eval_indexed (
|
|||||||
}
|
}
|
||||||
else if ((*val)->type != ASE_AWK_VAL_MAP)
|
else if ((*val)->type != ASE_AWK_VAL_MAP)
|
||||||
{
|
{
|
||||||
PANIC (run, ASE_AWK_ENOTINDEXABLE);
|
PANIC (run, ASE_AWK_ENOIDX);
|
||||||
}
|
}
|
||||||
|
|
||||||
ASE_AWK_ASSERT (run->awk, nde->idx != ASE_NULL);
|
ASE_AWK_ASSERT (run->awk, nde->idx != ASE_NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user