*** empty log message ***

This commit is contained in:
hyung-hwan 2007-03-04 14:55:55 +00:00
parent f764b53571
commit c71d350312
4 changed files with 50 additions and 29 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: awk.c,v 1.113 2007-03-04 06:26:45 bacon Exp $
* $Id: awk.c,v 1.114 2007-03-04 14:55:55 bacon Exp $
*
* {License}
*/
@ -168,6 +168,8 @@ static void __free_afn (void* owner, void* afn)
int ase_awk_close (ase_awk_t* awk)
{
ase_size_t i;
if (ase_awk_clear (awk) == -1) return -1;
ase_awk_clrbfn (awk);
@ -177,6 +179,15 @@ int ase_awk_close (ase_awk_t* awk)
ase_awk_tab_close (&awk->parse.params);
ase_str_close (&awk->token.name);
for (i = 0; i < ASE_COUNTOF(awk->errstr); i++)
{
if (awk->errstr[i] != ASE_NULL)
{
ASE_AWK_FREE (awk, awk->errstr[i]);
awk->errstr[i] = ASE_NULL;
}
}
/* ASE_AWK_ALLOC, ASE_AWK_FREE, etc can not be used
* from the next line onwards */
ASE_AWK_FREE (awk, awk);
@ -185,15 +196,6 @@ int ase_awk_close (ase_awk_t* awk)
int ase_awk_clear (ase_awk_t* awk)
{
/* you should stop all running instances beforehand */
/*
if (awk->run.ptr != ASE_NULL)
{
awk->errnum = ASE_AWK_ERUNNING;
return -1;
}
*/
ase_memset (&awk->src.ios, 0, ASE_SIZEOF(awk->src.ios));
awk->src.lex.curc = ASE_CHAR_EOF;
awk->src.lex.ungotc_count = 0;

View File

@ -1,5 +1,5 @@
/*
* $Id: awk.h,v 1.199 2007-03-04 06:26:45 bacon Exp $
* $Id: awk.h,v 1.200 2007-03-04 14:55:55 bacon Exp $
*
* {License}
*/
@ -327,7 +327,10 @@ enum
ASE_AWK_EREXCCLASS, /* invalid character class */
ASE_AWK_EREXBRANGE, /* invalid boundary range */
ASE_AWK_EREXEND, /* unexpected end of the pattern */
ASE_AWK_EREXGARBAGE /* garbage after the pattern */
ASE_AWK_EREXGARBAGE, /* garbage after the pattern */
/* the number of error numbers, internal use only */
ASE_AWK_NUMERRNUM
};
/* depth types */
@ -394,6 +397,10 @@ int ase_awk_close (ase_awk_t* awk);
int ase_awk_clear (ase_awk_t* awk);
void* ase_awk_getcustomdata (ase_awk_t* awk);
const ase_char_t* ase_awk_geterrstr (ase_awk_t* awk, int num);
int ase_awk_seterrstr (ase_awk_t* awk, int num, const ase_char_t* str);
int ase_awk_geterrnum (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);
@ -509,8 +516,6 @@ int ase_awk_assertfail (ase_awk_t* awk,
const ase_char_t* expr, const ase_char_t* desc,
const ase_char_t* file, int line);
/* utility functions to convert an error number ot a string */
const ase_char_t* ase_awk_geterrstr (int errnum);
#ifdef __cplusplus
}

View File

@ -1,5 +1,5 @@
/*
* $Id: awk_i.h,v 1.109 2007-03-04 06:26:45 bacon Exp $
* $Id: awk_i.h,v 1.110 2007-03-04 14:55:55 bacon Exp $
*
* {License}
*/
@ -202,6 +202,8 @@ struct ase_awk_t
int errnum;
ase_size_t errlin;
ase_char_t errmsg[256];
ase_char_t* errstr[ASE_AWK_NUMERRNUM];
};
struct ase_awk_chain_t

View File

@ -1,5 +1,5 @@
/*
* $Id: err.c,v 1.82 2007-03-04 06:56:16 bacon Exp $
* $Id: err.c,v 1.83 2007-03-04 14:55:55 bacon Exp $
*
* {License}
*/
@ -149,17 +149,29 @@ static const ase_char_t* __geterrstr (int errnum)
return ASE_T("unknown error");
}
const ase_char_t* ase_awk_geterrstr (int errnum)
const ase_char_t* ase_awk_geterrstr (ase_awk_t* awk, int num)
{
return __geterrstr (errnum);
if (awk != ASE_NULL &&
awk->errstr[num] != ASE_NULL) return awk->errstr[num];
return __geterrstr (num);
}
ase_char_t* ase_awk_seterrstr (
ase_awk_t* awk, int errnum, const ase_char_t* errstr)
int ase_awk_seterrstr (ase_awk_t* awk, int num, const ase_char_t* str)
{
ase_char_t* dup = ase_strdup (errstr, awk);
if (dup == ASE_NULL) return ASE_NULL;
awk->errstr[errnum] = dup;
ase_char_t* dup;
if (str == ASE_NULL) dup = ASE_NULL;
else
{
dup = ase_strdup (str, &awk->prmfns.mmgr);
if (dup == ASE_NULL) return -1;
}
if (awk->errstr[num] != ASE_NULL)
ASE_AWK_FREE (awk, awk->errstr[num]);
else awk->errstr[num] = dup;
return 0;
}
int ase_awk_geterrnum (ase_awk_t* awk)
@ -175,7 +187,7 @@ ase_size_t ase_awk_geterrlin (ase_awk_t* awk)
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 ase_awk_geterrstr (awk, awk->errnum);
return awk->errmsg;
}
@ -188,7 +200,7 @@ void ase_awk_geterror (
if (errmsg != ASE_NULL)
{
if (awk->errmsg[0] == ASE_T('\0'))
*errmsg = ase_awk_geterrstr (awk->errnum);
*errmsg = ase_awk_geterrstr (awk, awk->errnum);
else
*errmsg = awk->errmsg;
}
@ -206,7 +218,7 @@ void ase_awk_seterror (
awk->errnum = errnum;
awk->errlin = errlin;
errfmt = __geterrstr (errnum);
errfmt = ase_awk_geterrstr (awk, errnum);
fmtlen = ase_strlen(errfmt);
switch (argcnt)
@ -324,7 +336,7 @@ ase_size_t ase_awk_getrunerrlin (ase_awk_run_t* run)
const ase_char_t* ase_awk_getrunerrmsg (ase_awk_run_t* run)
{
if (run->errmsg[0] == ASE_T('\0'))
return ase_awk_geterrstr (run->errnum);
return ase_awk_geterrstr (run->awk, run->errnum);
return run->errmsg;
}
@ -345,7 +357,7 @@ void ase_awk_getrunerror (
if (errmsg != ASE_NULL)
{
if (run->errmsg[0] == ASE_T('\0'))
*errmsg = ase_awk_geterrstr (run->errnum);
*errmsg = ase_awk_geterrstr (run->awk, run->errnum);
else
*errmsg = run->errmsg;
}
@ -363,7 +375,7 @@ void ase_awk_setrunerror (
run->errnum = errnum;
run->errlin = errlin;
errfmt = __geterrstr (errnum);
errfmt = ase_awk_geterrstr (run->awk, errnum);
fmtlen = ase_strlen (errfmt);
switch (argcnt)