*** empty log message ***
This commit is contained in:
parent
d139e60f30
commit
9ca2c470d7
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: run.c,v 1.244 2006-10-26 09:27:15 bacon Exp $
|
* $Id: run.c,v 1.245 2006-10-27 11:04:16 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ase/awk/awk_i.h>
|
#include <ase/awk/awk_i.h>
|
||||||
@ -666,18 +666,22 @@ static int __init_run (ase_awk_run_t* run, ase_awk_runios_t* runios, int* errnum
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
run->pattern_range_state = (ase_byte_t*) ASE_AWK_MALLOC (
|
if (run->awk->tree.chain_size > 0)
|
||||||
run->awk, run->awk->tree.chain_size * ase_sizeof(ase_byte_t));
|
|
||||||
if (run->pattern_range_state == ASE_NULL)
|
|
||||||
{
|
{
|
||||||
ase_awk_map_close (&run->named);
|
run->pattern_range_state = (ase_byte_t*) ASE_AWK_MALLOC (
|
||||||
ase_awk_str_close (&run->inrec.line);
|
run->awk, run->awk->tree.chain_size*ase_sizeof(ase_byte_t));
|
||||||
*errnum = ASE_AWK_ENOMEM;
|
if (run->pattern_range_state == ASE_NULL)
|
||||||
return -1;
|
{
|
||||||
}
|
ase_awk_map_close (&run->named);
|
||||||
|
ase_awk_str_close (&run->inrec.line);
|
||||||
|
*errnum = ASE_AWK_ENOMEM;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
ASE_AWK_MEMSET (run->awk, run->pattern_range_state, 0,
|
ASE_AWK_MEMSET (run->awk, run->pattern_range_state, 0,
|
||||||
run->awk->tree.chain_size * ase_sizeof(ase_byte_t));
|
run->awk->tree.chain_size * ase_sizeof(ase_byte_t));
|
||||||
|
}
|
||||||
|
else run->pattern_range_state = ASE_NULL;
|
||||||
|
|
||||||
run->extio.handler[ASE_AWK_EXTIO_PIPE] = runios->pipe;
|
run->extio.handler[ASE_AWK_EXTIO_PIPE] = runios->pipe;
|
||||||
run->extio.handler[ASE_AWK_EXTIO_COPROC] = runios->coproc;
|
run->extio.handler[ASE_AWK_EXTIO_COPROC] = runios->coproc;
|
||||||
@ -695,7 +699,8 @@ static int __init_run (ase_awk_run_t* run, ase_awk_runios_t* runios, int* errnum
|
|||||||
|
|
||||||
static void __deinit_run (ase_awk_run_t* run)
|
static void __deinit_run (ase_awk_run_t* run)
|
||||||
{
|
{
|
||||||
ASE_AWK_FREE (run->awk, run->pattern_range_state);
|
if (run->pattern_range_state != ASE_NULL)
|
||||||
|
ASE_AWK_FREE (run->awk, run->pattern_range_state);
|
||||||
|
|
||||||
/* close all pending eio's */
|
/* close all pending eio's */
|
||||||
/* TODO: what if this operation fails? */
|
/* TODO: what if this operation fails? */
|
||||||
@ -1314,6 +1319,7 @@ static int __run_pattern_block (
|
|||||||
{
|
{
|
||||||
/* pattern, pattern { ... } */
|
/* pattern, pattern { ... } */
|
||||||
ASE_AWK_ASSERT (run->awk, ptn->next->next == ASE_NULL);
|
ASE_AWK_ASSERT (run->awk, ptn->next->next == ASE_NULL);
|
||||||
|
ASE_AWK_ASSERT (run->awk, run->pattern_range_state != ASE_NULL);
|
||||||
|
|
||||||
if (run->pattern_range_state[block_no] == 0)
|
if (run->pattern_range_state[block_no] == 0)
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: awk.c,v 1.105 2006-10-27 10:28:53 bacon Exp $
|
* $Id: awk.c,v 1.106 2006-10-27 11:06:09 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ase/awk/awk.h>
|
#include <ase/awk/awk.h>
|
||||||
@ -224,7 +224,7 @@ static ase_ssize_t process_extio_pipe (
|
|||||||
else if (epa->mode == ASE_AWK_IO_PIPE_WRITE)
|
else if (epa->mode == ASE_AWK_IO_PIPE_WRITE)
|
||||||
mode = ASE_T("w");
|
mode = ASE_T("w");
|
||||||
else return -1; /* TODO: any way to set the error number? */
|
else return -1; /* TODO: any way to set the error number? */
|
||||||
xp_printf (ASE_TEXT("opending %s of type %d (pipe)\n"), epa->name, epa->type);
|
xp_printf (ASE_T("opending %s of type %d (pipe)\n"), epa->name, epa->type);
|
||||||
handle = popen_t (epa->name, mode);
|
handle = popen_t (epa->name, mode);
|
||||||
if (handle == NULL) return -1;
|
if (handle == NULL) return -1;
|
||||||
epa->handle = (void*)handle;
|
epa->handle = (void*)handle;
|
||||||
@ -233,7 +233,7 @@ xp_printf (ASE_TEXT("opending %s of type %d (pipe)\n"), epa->name, epa->type);
|
|||||||
|
|
||||||
case ASE_AWK_IO_CLOSE:
|
case ASE_AWK_IO_CLOSE:
|
||||||
{
|
{
|
||||||
xp_printf (ASE_TEXT("closing %s of type (pipe) %d\n"), epa->name, epa->type);
|
xp_printf (ASE_T("closing %s of type (pipe) %d\n"), epa->name, epa->type);
|
||||||
fclose ((FILE*)epa->handle);
|
fclose ((FILE*)epa->handle);
|
||||||
epa->handle = NULL;
|
epa->handle = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
@ -288,7 +288,7 @@ static ase_ssize_t process_extio_file (
|
|||||||
mode = ASE_T("a");
|
mode = ASE_T("a");
|
||||||
else return -1; /* TODO: any way to set the error number? */
|
else return -1; /* TODO: any way to set the error number? */
|
||||||
|
|
||||||
xp_printf (ASE_TEXT("opending %s of type %d (file)\n"), epa->name, epa->type);
|
xp_printf (ASE_T("opending %s of type %d (file)\n"), epa->name, epa->type);
|
||||||
handle = fopen_t (epa->name, mode);
|
handle = fopen_t (epa->name, mode);
|
||||||
if (handle == NULL) return -1;
|
if (handle == NULL) return -1;
|
||||||
|
|
||||||
@ -298,7 +298,7 @@ xp_printf (ASE_TEXT("opending %s of type %d (file)\n"), epa->name, epa->type);
|
|||||||
|
|
||||||
case ASE_AWK_IO_CLOSE:
|
case ASE_AWK_IO_CLOSE:
|
||||||
{
|
{
|
||||||
xp_printf (ASE_TEXT("closing %s of type %d (file)\n"), epa->name, epa->type);
|
xp_printf (ASE_T("closing %s of type %d (file)\n"), epa->name, epa->type);
|
||||||
fclose ((FILE*)epa->handle);
|
fclose ((FILE*)epa->handle);
|
||||||
epa->handle = NULL;
|
epa->handle = NULL;
|
||||||
return 0;
|
return 0;
|
||||||
@ -394,7 +394,7 @@ static ase_ssize_t process_extio_console (
|
|||||||
FILE* fp = fopen_t (infiles[infile_no], ASE_T("r"));
|
FILE* fp = fopen_t (infiles[infile_no], ASE_T("r"));
|
||||||
if (fp == ASE_NULL)
|
if (fp == ASE_NULL)
|
||||||
{
|
{
|
||||||
xp_printf (ASE_TEXT("failed to open the next console of type %x - fopen failure\n"), epa->type);
|
xp_printf (ASE_T("failed to open the next console of type %x - fopen failure\n"), epa->type);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -403,7 +403,7 @@ xp_printf (ASE_TEXT("failed to open the next console of type %x - fopen failure\
|
|||||||
epa->handle != stdout &&
|
epa->handle != stdout &&
|
||||||
epa->handle != stderr) fclose (epa->handle);
|
epa->handle != stderr) fclose (epa->handle);
|
||||||
|
|
||||||
xp_printf (ASE_TEXT("open the next console [%s]\n"), infiles[infile_no]);
|
xp_printf (ASE_T("open the next console [%s]\n"), infiles[infile_no]);
|
||||||
epa->handle = fp;
|
epa->handle = fp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -439,14 +439,14 @@ static int open_extio_console (ase_awk_extio_t* epa)
|
|||||||
/* epa->name is always empty for console */
|
/* epa->name is always empty for console */
|
||||||
xp_assert (epa->name[0] == ASE_T('\0'));
|
xp_assert (epa->name[0] == ASE_T('\0'));
|
||||||
|
|
||||||
xp_printf (ASE_TEXT("opening console[%s] of type %x\n"), epa->name, epa->type);
|
xp_printf (ASE_T("opening console[%s] of type %x\n"), epa->name, epa->type);
|
||||||
|
|
||||||
if (epa->mode == ASE_AWK_IO_CONSOLE_READ)
|
if (epa->mode == ASE_AWK_IO_CONSOLE_READ)
|
||||||
{
|
{
|
||||||
if (infiles[infile_no] == ASE_NULL)
|
if (infiles[infile_no] == ASE_NULL)
|
||||||
{
|
{
|
||||||
/* no more input file */
|
/* no more input file */
|
||||||
xp_printf (ASE_TEXT("console - no more file\n"));;
|
xp_printf (ASE_T("console - no more file\n"));;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -462,7 +462,7 @@ xp_printf (ASE_T(" console(r) - <standard input>\n"));
|
|||||||
FILE* fp = fopen_t (infiles[infile_no], ASE_T("r"));
|
FILE* fp = fopen_t (infiles[infile_no], ASE_T("r"));
|
||||||
if (fp == ASE_NULL)
|
if (fp == ASE_NULL)
|
||||||
{
|
{
|
||||||
xp_printf (ASE_TEXT("failed to open console of type %x - fopen failure\n"), epa->type);
|
xp_printf (ASE_T("failed to open console of type %x - fopen failure\n"), epa->type);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -495,7 +495,7 @@ xp_printf (ASE_T(" console(w) - <standard output>\n"));
|
|||||||
|
|
||||||
static int close_extio_console (ase_awk_extio_t* epa)
|
static int close_extio_console (ase_awk_extio_t* epa)
|
||||||
{
|
{
|
||||||
xp_printf (ASE_TEXT("closing console of type %x\n"), epa->type);
|
xp_printf (ASE_T("closing console of type %x\n"), epa->type);
|
||||||
|
|
||||||
if (epa->handle != ASE_NULL &&
|
if (epa->handle != ASE_NULL &&
|
||||||
epa->handle != stdin &&
|
epa->handle != stdin &&
|
||||||
@ -513,7 +513,7 @@ static int next_extio_console (ase_awk_extio_t* epa)
|
|||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
FILE* fp = epa->handle;
|
FILE* fp = epa->handle;
|
||||||
xp_printf (ASE_TEXT("switching console[%s] of type %x\n"), epa->name, epa->type);
|
xp_printf (ASE_T("switching console[%s] of type %x\n"), epa->name, epa->type);
|
||||||
|
|
||||||
n = open_extio_console(epa);
|
n = open_extio_console(epa);
|
||||||
if (n == -1) return -1;
|
if (n == -1) return -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user