*** empty log message ***

This commit is contained in:
hyung-hwan 2007-03-02 11:41:56 +00:00
parent cbc0fffeb2
commit 866ff735fc
7 changed files with 116 additions and 10 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: err.c,v 1.75 2007-03-02 11:14:33 bacon Exp $
* $Id: err.c,v 1.76 2007-03-02 11:41:55 bacon Exp $
*
* {License}
*/
@ -196,6 +196,7 @@ void ase_awk_seterror (
const ase_cstr_t* errarg, ase_size_t argcnt)
{
const ase_char_t* errfmt;
ase_size_t fmtlen;
ASE_AWK_ASSERT (awk, argcnt <= 5);
@ -203,6 +204,7 @@ void ase_awk_seterror (
awk->errlin = errlin;
errfmt = __geterrstr (errnum);
fmtlen = ase_strlen(errfmt);
switch (argcnt)
{
@ -215,13 +217,33 @@ void ase_awk_seterror (
return;
case 1:
{
ase_char_t tmp[ASE_COUNTOF(awk->errmsg)];
ase_size_t len, tl;
if (fmtlen < ASE_COUNTOF(awk->errmsg) &&
errarg[0].len + fmtlen >= ASE_COUNTOF(awk->errmsg))
{
len = ASE_COUNTOF(awk->errmsg) - fmtlen - 3 - 1;
tl = ase_strxncpy (tmp, ASE_COUNTOF(tmp), errarg[0].ptr, len);
tmp[tl] = ASE_T('.');
tmp[tl+1] = ASE_T('.');
tmp[tl+2] = ASE_T('.');
len += 3;
}
else
{
len = errarg[0].len;
ase_strxncpy (tmp, ASE_COUNTOF(tmp), errarg[0].ptr, len);
}
awk->prmfns.misc.sprintf (
awk->prmfns.misc.custom_data,
awk->errmsg,
ASE_COUNTOF(awk->errmsg),
errfmt,
errarg[0].len, errarg[0].ptr);
errfmt, len, tmp);
return;
}
case 2:
awk->prmfns.misc.sprintf (
@ -331,6 +353,7 @@ void ase_awk_setrunerror (
const ase_cstr_t* errarg, ase_size_t argcnt)
{
const ase_char_t* errfmt;
ase_size_t fmtlen;
ASE_AWK_ASSERT (run->awk, argcnt <= 5);
@ -338,6 +361,7 @@ void ase_awk_setrunerror (
run->errlin = errlin;
errfmt = __geterrstr (errnum);
fmtlen = ase_strlen (errfmt);
switch (argcnt)
{
@ -350,13 +374,33 @@ void ase_awk_setrunerror (
return;
case 1:
{
ase_char_t tmp[ASE_COUNTOF(run->errmsg)];
ase_size_t len, tl;
if (fmtlen < ASE_COUNTOF(run->errmsg) &&
errarg[0].len + fmtlen >= ASE_COUNTOF(run->errmsg))
{
len = ASE_COUNTOF(run->errmsg) - fmtlen - 3 - 1;
tl = ase_strxncpy (tmp, ASE_COUNTOF(tmp), errarg[0].ptr, len);
tmp[tl] = ASE_T('.');
tmp[tl+1] = ASE_T('.');
tmp[tl+2] = ASE_T('.');
len += 3;
}
else
{
len = errarg[0].len;
ase_strxncpy (tmp, ASE_COUNTOF(tmp), errarg[0].ptr, len);
}
run->awk->prmfns.misc.sprintf (
run->awk->prmfns.misc.custom_data,
run->errmsg,
ASE_COUNTOF(run->errmsg),
errfmt,
errarg[0].len, errarg[0].ptr);
errfmt, len, tmp);
return;
}
case 2:
run->awk->prmfns.misc.sprintf (

View File

@ -1,5 +1,5 @@
/*
* $Id: str.c,v 1.5 2007-02-23 08:17:51 bacon Exp $
* $Id: str.c,v 1.6 2007-03-02 11:41:55 bacon Exp $
*
* {License}
*/
@ -47,6 +47,44 @@ ase_size_t ase_strncpy (
return len;
}
ase_size_t ase_strxncpy (
ase_char_t* buf, ase_size_t bsz, const ase_char_t* str, ase_size_t len)
{
ase_size_t n;
if (bsz <= 0) return 0;
if ((n = bsz - 1) > len) n = len;
ase_memcpy (buf, str, n * ASE_SIZEOF(ase_char_t));
buf[n] = ASE_T('\0');
return n;
}
ase_size_t ase_strxncat (
ase_char_t* buf, ase_size_t bsz, const ase_char_t* str, ase_size_t len)
{
ase_char_t* p, * p2;
const ase_char_t* end;
ase_size_t blen;
blen = ase_strlen(buf);
if (blen >= bsz) return blen; /* something wrong */
p = buf + blen;
p2 = buf + bsz - 1;
end = str + len;
while (p < p2)
{
if (str >= end) break;
*p++ = *str++;
}
if (bsz > 0) *p = ASE_T('\0');
return p - buf;
}
int ase_strcmp (const ase_char_t* s1, const ase_char_t* s2)
{
while (*s1 == *s2)

View File

@ -1,5 +1,5 @@
/*
* $Id: str.h,v 1.3 2007-02-23 06:43:30 bacon Exp $
* $Id: str.h,v 1.4 2007-03-02 11:41:55 bacon Exp $
*
* {License}
*/
@ -33,9 +33,17 @@ extern "C" {
ase_size_t ase_strlen (const ase_char_t* str);
ase_size_t ase_strcpy (ase_char_t* buf, const ase_char_t* str);
ase_size_t ase_strxcpy (ase_char_t* buf, ase_size_t bsz, const ase_char_t* str);
ase_size_t ase_strncpy (ase_char_t* buf, const ase_char_t* str, ase_size_t len);
ase_size_t ase_strcpy (
ase_char_t* buf, const ase_char_t* str);
ase_size_t ase_strxcpy (
ase_char_t* buf, ase_size_t bsz, const ase_char_t* str);
ase_size_t ase_strncpy (
ase_char_t* buf, const ase_char_t* str, ase_size_t len);
ase_size_t ase_strxncpy (
ase_char_t* buf, ase_size_t bsz, const ase_char_t* str, ase_size_t len);
ase_size_t ase_strxncat (
ase_char_t* buf, ase_size_t bsz, const ase_char_t* str, ase_size_t len);
int ase_strcmp (const ase_char_t* s1, const ase_char_t* s2);
int ase_strxncmp (

3
ase/test/awk/err-002.awk Normal file
View File

@ -0,0 +1,3 @@
BEGIN {
ARGC = 39;
}

6
ase/test/awk/err-003.awk Normal file
View File

@ -0,0 +1,6 @@
global abc;
BEGIN {
abc[20] = "abc";
abc = 10;
}

3
ase/test/awk/err-004.awk Normal file
View File

@ -0,0 +1,3 @@
BEGIN {
delete ARGC;
}

4
ase/test/awk/err-005.awk Normal file
View File

@ -0,0 +1,4 @@
BEGIN {
iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiix = 20;
delete iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiix ;
}