*** empty log message ***

This commit is contained in:
hyung-hwan 2007-03-19 15:25:51 +00:00
parent 1abc5fdb67
commit f25d2f88d5
5 changed files with 117 additions and 34 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Id: awk.h,v 1.210 2007-03-10 15:32:54 bacon Exp $ * $Id: awk.h,v 1.211 2007-03-19 15:25:50 bacon Exp $
* *
* {License} * {License}
*/ */
@ -211,6 +211,11 @@ enum
ASE_AWK_EISDIR, /* is a directory */ ASE_AWK_EISDIR, /* is a directory */
ASE_AWK_EIOERR, /* i/o error */ ASE_AWK_EIOERR, /* i/o error */
ASE_AWK_EOPEN, /* cannot open */
ASE_AWK_EREAD, /* cannot read */
ASE_AWK_EWRITE, /* cannot write */
ASE_AWK_ECLOSE, /* cannot close */
ASE_AWK_EINTERN, /* internal error */ ASE_AWK_EINTERN, /* internal error */
ASE_AWK_ERUNTIME, /* run-time error */ ASE_AWK_ERUNTIME, /* run-time error */
ASE_AWK_EBLKNST, /* blocke nested too deeply */ ASE_AWK_EBLKNST, /* blocke nested too deeply */

View File

@ -1,5 +1,5 @@
/* /*
* $Id: err.c,v 1.94 2007-03-10 15:32:54 bacon Exp $ * $Id: err.c,v 1.95 2007-03-19 15:25:50 bacon Exp $
* *
* {License} * {License}
*/ */
@ -27,6 +27,11 @@ static const ase_char_t* __geterrstr (int errnum)
ASE_T("system too busy"), ASE_T("system too busy"),
ASE_T("is a directory"), ASE_T("is a directory"),
ASE_T("i/o error"), ASE_T("i/o error"),
ASE_T("cannot open '%.*s'"),
ASE_T("cannot read '%.*s'"),
ASE_T("cannot write '%.*s'"),
ASE_T("cannot close '%.*s'"),
ASE_T("internal error that should never have happened"), ASE_T("internal error that should never have happened"),
ASE_T("general run-time error"), ASE_T("general run-time error"),

View File

@ -1,5 +1,5 @@
/* /*
* $Id: extio.c,v 1.76 2007-03-10 15:02:30 bacon Exp $ * $Id: extio.c,v 1.77 2007-03-19 15:25:50 bacon Exp $
* *
* {License} * {License}
*/ */
@ -144,13 +144,21 @@ int ase_awk_readextio (
p->in.eof = ase_false; p->in.eof = ase_false;
p->in.eos = ase_false; p->in.eos = ase_false;
run->errnum = ASE_AWK_ENOERR;
n = handler (ASE_AWK_IO_OPEN, p, ASE_NULL, 0); n = handler (ASE_AWK_IO_OPEN, p, ASE_NULL, 0);
if (n <= -1) if (n <= -1)
{ {
ASE_AWK_FREE (run->awk, p->name); ASE_AWK_FREE (run->awk, p->name);
ASE_AWK_FREE (run->awk, p); ASE_AWK_FREE (run->awk, p);
if (run->errnum == ASE_AWK_ENOERR)
{
/* if the error number has not been set by the user */
ase_awk_setrunerror ( ase_awk_setrunerror (
run, ASE_AWK_EIOIMPL, 0, ASE_NULL, 0); run, ASE_AWK_EIOIMPL, 0, ASE_NULL, 0);
}
return -1; return -1;
} }
@ -219,12 +227,16 @@ int ase_awk_readextio (
break; break;
} }
run->errnum = ASE_AWK_ENOERR;
n = handler (ASE_AWK_IO_READ, p, p->in.buf, ASE_COUNTOF(p->in.buf)); n = handler (ASE_AWK_IO_READ, p, p->in.buf, ASE_COUNTOF(p->in.buf));
if (n <= -1) if (n <= -1)
{ {
/* handler error. getline should return -1 */ /* handler error. getline should return -1 */
if (run->errnum == ASE_AWK_ENOERR)
{
ase_awk_setrunerror ( ase_awk_setrunerror (
run, ASE_AWK_EIOIMPL, 0, ASE_NULL, 0); run, ASE_AWK_EIOIMPL, 0, ASE_NULL, 0);
}
ret = -1; ret = -1;
break; break;
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: run.c,v 1.345 2007-03-19 03:33:53 bacon Exp $ * $Id: run.c,v 1.346 2007-03-19 15:25:51 bacon Exp $
* *
* {License} * {License}
*/ */
@ -1648,6 +1648,12 @@ static int __run_block0 (ase_awk_run_t* run, ase_awk_nde_blk_t* nde)
run, ASE_AWK_ECOUTWR, nde->line, run, ASE_AWK_ECOUTWR, nde->line,
ASE_NULL, 0); ASE_NULL, 0);
} }
else
{
/* adjust the error line */
run->errlin = nde->line;
}
return -1; return -1;
} }
@ -2253,6 +2259,7 @@ static int __run_nextoutfile (ase_awk_run_t* run, ase_awk_nde_nextfile_t* nde)
} }
else else
{ {
/* adjust the error line */
run->errlin = nde->line; run->errlin = nde->line;
} }
@ -2585,8 +2592,10 @@ static int __run_print (ase_awk_run_t* run, ase_awk_nde_print_t* nde)
ASE_STR_LEN(&run->inrec.line)); ASE_STR_LEN(&run->inrec.line));
if (n <= -1 /*&& run->errnum != ASE_AWK_EIOIMPL*/) if (n <= -1 /*&& run->errnum != ASE_AWK_EIOIMPL*/)
{ {
if (out != ASE_NULL) ASE_AWK_FREE (run->awk, out); if (out != ASE_NULL)
/* change the error line */ ASE_AWK_FREE (run->awk, out);
/* adjust the error line */
run->errlin = nde->line; run->errlin = nde->line;
return -1; return -1;
} }
@ -2615,8 +2624,10 @@ static int __run_print (ase_awk_run_t* run, ase_awk_nde_print_t* nde)
run->global.ofs.len); run->global.ofs.len);
if (n <= -1 /*&& run->errnum != ASE_AWK_EIOIMPL*/) if (n <= -1 /*&& run->errnum != ASE_AWK_EIOIMPL*/)
{ {
if (out != ASE_NULL) ASE_AWK_FREE (run->awk, out); if (out != ASE_NULL)
/* change the error line */ ASE_AWK_FREE (run->awk, out);
/* adjust the error line */
run->errlin = nde->line; run->errlin = nde->line;
return -1; return -1;
} }
@ -2625,7 +2636,8 @@ static int __run_print (ase_awk_run_t* run, ase_awk_nde_print_t* nde)
v = __eval_expression (run, np); v = __eval_expression (run, np);
if (v == ASE_NULL) if (v == ASE_NULL)
{ {
if (out != ASE_NULL) ASE_AWK_FREE (run->awk, out); if (out != ASE_NULL)
ASE_AWK_FREE (run->awk, out);
return -1; return -1;
} }
ase_awk_refupval (run, v); ase_awk_refupval (run, v);
@ -2633,9 +2645,11 @@ static int __run_print (ase_awk_run_t* run, ase_awk_nde_print_t* nde)
n = ase_awk_writeextio_val (run, nde->out_type, dst, v); n = ase_awk_writeextio_val (run, nde->out_type, dst, v);
if (n <= -1 /*&& run->errnum != ASE_AWK_EIOIMPL*/) if (n <= -1 /*&& run->errnum != ASE_AWK_EIOIMPL*/)
{ {
if (out != ASE_NULL) ASE_AWK_FREE (run->awk, out); if (out != ASE_NULL)
ASE_AWK_FREE (run->awk, out);
ase_awk_refdownval (run, v); ase_awk_refdownval (run, v);
/* change the error line */ /* adjust the error line */
run->errlin = nde->line; run->errlin = nde->line;
return -1; return -1;
} }
@ -6136,15 +6150,23 @@ static int __read_record (ase_awk_run_t* run)
run, ASE_AWK_IN_CONSOLE, ASE_T(""), &run->inrec.line); run, ASE_AWK_IN_CONSOLE, ASE_T(""), &run->inrec.line);
if (n <= -1) if (n <= -1)
{ {
/* save the error number first as the error number can
* be changed by ase_awk_clrrec if it fails */
/*
int saved = run->errnum; int saved = run->errnum;
*/
ase_awk_clrrec (run, ase_false); ase_awk_clrrec (run, ase_false);
/*
if (saved == ASE_AWK_EIOIMPL) if (saved == ASE_AWK_EIOIMPL)
{ {
ase_awk_setrunerror ( ase_awk_setrunerror (
run, ASE_AWK_ECINRD, 0, ASE_NULL, 0); run, ASE_AWK_ECINRD, 0, ASE_NULL, 0);
} }
*/
return -1; return -1;
} }
#ifdef DEBUG_RUN #ifdef DEBUG_RUN
ase_dprintf (ASE_T("record len = %d str=[%.*s]\n"), ase_dprintf (ASE_T("record len = %d str=[%.*s]\n"),
(int)ASE_STR_LEN(&run->inrec.line), (int)ASE_STR_LEN(&run->inrec.line),

View File

@ -1,5 +1,5 @@
/* /*
* $Id: awk.c,v 1.190 2007-03-15 14:19:23 bacon Exp $ * $Id: awk.c,v 1.191 2007-03-19 15:25:51 bacon Exp $
*/ */
#include <ase/awk/awk.h> #include <ase/awk/awk.h>
@ -460,20 +460,6 @@ static ase_ssize_t awk_extio_console (
if (infiles[infile_no] == ASE_NULL) if (infiles[infile_no] == ASE_NULL)
{ {
/* no more input console */ /* no more input console */
/* is this correct??? */
/*
if (epa->handle != ASE_NULL &&
epa->handle != stdin &&
epa->handle != stdout &&
epa->handle != stderr)
{
fclose ((FILE*)epa->handle);
}
epa->handle = ASE_NULL;
*/
return 0; return 0;
} }
@ -484,8 +470,19 @@ static ase_ssize_t awk_extio_console (
epa->handle != stdout && epa->handle != stdout &&
epa->handle != stderr) epa->handle != stderr)
{ {
fclose ((FILE*)epa->handle); /* TODO: ................................ */
if (fclose ((FILE*)epa->handle) == EOF)
{
ase_cstr_t errarg;
errarg.ptr = ASE_T("consolXXXe");
errarg.len = 7;
ase_awk_setrunerror (epa->run, ASE_AWK_ECLOSE, 0, &errarg, 1);
return -1;
}
} }
epa->handle = stdin; epa->handle = stdin;
} }
else else
@ -493,7 +490,20 @@ static ase_ssize_t awk_extio_console (
FILE* fp = ase_fopen (infiles[infile_no], ASE_T("r")); FILE* fp = ase_fopen (infiles[infile_no], ASE_T("r"));
if (fp == ASE_NULL) if (fp == ASE_NULL)
{ {
dprintf (ASE_T("failed to open the next console of type %x - fopen failure\n"), epa->type); ase_cstr_t errarg;
errarg.ptr = infiles[infile_no];
errarg.len = ase_strlen(infiles[infile_no]);
ase_awk_setrunerror (epa->run, ASE_AWK_EOPEN, 0, &errarg, 1);
return -1;
}
if (ase_awk_setfilename (
epa->run, infiles[infile_no],
ase_strlen(infiles[infile_no])) == -1)
{
fclose (fp);
return -1; return -1;
} }
@ -502,7 +512,19 @@ static ase_ssize_t awk_extio_console (
epa->handle != stdout && epa->handle != stdout &&
epa->handle != stderr) epa->handle != stderr)
{ {
fclose ((FILE*)epa->handle); /* TODO: ................................ */
if (fclose ((FILE*)epa->handle) == EOF)
{
ase_cstr_t errarg;
errarg.ptr = ASE_T("console");
errarg.len = 7;
ase_awk_setrunerror (epa->run, ASE_AWK_ECLOSE, 0, &errarg, 1);
fclose (fp);
return -1;
}
} }
dprintf (ASE_T("open the next console [%s]\n"), infiles[infile_no]); dprintf (ASE_T("open the next console [%s]\n"), infiles[infile_no]);
@ -562,7 +584,12 @@ static int open_extio_console (ase_awk_extio_t* epa)
FILE* fp = ase_fopen (infiles[infile_no], ASE_T("r")); FILE* fp = ase_fopen (infiles[infile_no], ASE_T("r"));
if (fp == ASE_NULL) if (fp == ASE_NULL)
{ {
dprintf (ASE_T("cannot open console of type %x - fopen failure\n"), epa->type); ase_cstr_t errarg;
errarg.ptr = infiles[infile_no];
errarg.len = ase_strlen(infiles[infile_no]);
ase_awk_setrunerror (epa->run, ASE_AWK_EOPEN, 0, &errarg, 1);
return -1; return -1;
} }
@ -584,8 +611,12 @@ static int open_extio_console (ase_awk_extio_t* epa)
else if (epa->mode == ASE_AWK_EXTIO_CONSOLE_WRITE) else if (epa->mode == ASE_AWK_EXTIO_CONSOLE_WRITE)
{ {
dprintf (ASE_T(" console(w) - <standard output>\n")); dprintf (ASE_T(" console(w) - <standard output>\n"));
/* TODO: does output console has a name??? */
/*ase_awk_setconsolename (ASE_T(""));*/ if (ase_awk_setofilename (epa->run, ASE_T(""), 0) == -1)
{
return -1;
}
epa->handle = stdout; epa->handle = stdout;
return 1; return 1;
} }
@ -602,10 +633,18 @@ static int close_extio_console (ase_awk_extio_t* epa)
epa->handle != stdout && epa->handle != stdout &&
epa->handle != stderr) epa->handle != stderr)
{ {
fclose ((FILE*)epa->handle); if (fclose ((FILE*)epa->handle) == EOF)
{
ase_cstr_t errarg;
errarg.ptr = epa->name;
errarg.len = ase_strlen(epa->name);
ase_awk_setrunerror (epa->run, ASE_AWK_ECLOSE, 0, &errarg, 1);
return -1;
}
} }
/* TODO: CloseConsole in GUI APPLICATION */
return 0; return 0;
} }