This commit is contained in:
parent
c412bf24af
commit
0187587607
@ -11,7 +11,7 @@
|
|||||||
#include <ase/cmn/conf_msw.h>
|
#include <ase/cmn/conf_msw.h>
|
||||||
#elif defined(vms) || defined(__vms)
|
#elif defined(vms) || defined(__vms)
|
||||||
#include <ase/cmn/conf_vms.h>
|
#include <ase/cmn/conf_vms.h>
|
||||||
#elif defined(__unix__) || defined(__unix) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || (defined(__APPLE__) && defined(__MACH__))
|
#elif defined(__unix__) || defined(__unix) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || (defined(__APPLE__) && defined(__MACH__)) || defined(__SPU__)
|
||||||
#if !defined(__unix__)
|
#if !defined(__unix__)
|
||||||
#define __unix__
|
#define __unix__
|
||||||
#endif
|
#endif
|
||||||
|
@ -78,7 +78,7 @@ void ase_assert_printf (const ase_char_t* fmt, ...)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void dprintf (const ase_char_t* fmt, ...)
|
static void local_dprintf (const ase_char_t* fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start (ap, fmt);
|
va_start (ap, fmt);
|
||||||
@ -310,7 +310,7 @@ static ase_ssize_t awk_extio_pipe (
|
|||||||
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? */
|
||||||
|
|
||||||
dprintf (ASE_T("opening %s of type %d (pipe)\n"), epa->name, epa->type);
|
local_dprintf (ASE_T("opening %s of type %d (pipe)\n"), epa->name, epa->type);
|
||||||
handle = ase_popen (epa->name, mode);
|
handle = ase_popen (epa->name, mode);
|
||||||
if (handle == NULL) return -1;
|
if (handle == NULL) return -1;
|
||||||
epa->handle = (void*)handle;
|
epa->handle = (void*)handle;
|
||||||
@ -319,7 +319,7 @@ static ase_ssize_t awk_extio_pipe (
|
|||||||
|
|
||||||
case ASE_AWK_IO_CLOSE:
|
case ASE_AWK_IO_CLOSE:
|
||||||
{
|
{
|
||||||
dprintf (ASE_T("closing %s of type (pipe) %d\n"), epa->name, epa->type);
|
local_dprintf (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;
|
||||||
@ -436,7 +436,7 @@ static ase_ssize_t awk_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? */
|
||||||
|
|
||||||
dprintf (ASE_T("opening %s of type %d (file)\n"), epa->name, epa->type);
|
local_dprintf (ASE_T("opening %s of type %d (file)\n"), epa->name, epa->type);
|
||||||
handle = ase_fopen (epa->name, mode);
|
handle = ase_fopen (epa->name, mode);
|
||||||
if (handle == NULL)
|
if (handle == NULL)
|
||||||
{
|
{
|
||||||
@ -456,7 +456,7 @@ static ase_ssize_t awk_extio_file (
|
|||||||
|
|
||||||
case ASE_AWK_IO_CLOSE:
|
case ASE_AWK_IO_CLOSE:
|
||||||
{
|
{
|
||||||
dprintf (ASE_T("closing %s of type %d (file)\n"), epa->name, epa->type);
|
local_dprintf (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;
|
||||||
@ -660,7 +660,7 @@ static ase_ssize_t awk_extio_console (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dprintf (ASE_T("open the next console [%s]\n"), infiles[infile_no]);
|
local_dprintf (ASE_T("open the next console [%s]\n"), infiles[infile_no]);
|
||||||
epa->handle = fp;
|
epa->handle = fp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -710,20 +710,20 @@ static int open_extio_console (ase_awk_extio_t* epa)
|
|||||||
{
|
{
|
||||||
/* TODO: OpenConsole in GUI APPLICATION */
|
/* TODO: OpenConsole in GUI APPLICATION */
|
||||||
|
|
||||||
dprintf (ASE_T("opening console[%s] of type %x\n"), epa->name, epa->type);
|
local_dprintf (ASE_T("opening console[%s] of type %x\n"), epa->name, epa->type);
|
||||||
|
|
||||||
if (epa->mode == ASE_AWK_EXTIO_CONSOLE_READ)
|
if (epa->mode == ASE_AWK_EXTIO_CONSOLE_READ)
|
||||||
{
|
{
|
||||||
if (infiles[infile_no] == ASE_NULL)
|
if (infiles[infile_no] == ASE_NULL)
|
||||||
{
|
{
|
||||||
/* no more input file */
|
/* no more input file */
|
||||||
dprintf (ASE_T("console - no more file\n"));;
|
local_dprintf (ASE_T("console - no more file\n"));;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (infiles[infile_no][0] == ASE_T('\0'))
|
if (infiles[infile_no][0] == ASE_T('\0'))
|
||||||
{
|
{
|
||||||
dprintf (ASE_T(" console(r) - <standard input>\n"));
|
local_dprintf (ASE_T(" console(r) - <standard input>\n"));
|
||||||
epa->handle = stdin;
|
epa->handle = stdin;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -742,7 +742,7 @@ static int open_extio_console (ase_awk_extio_t* epa)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
dprintf (ASE_T(" console(r) - %s\n"), infiles[infile_no]);
|
local_dprintf (ASE_T(" console(r) - %s\n"), infiles[infile_no]);
|
||||||
if (ase_awk_setfilename (
|
if (ase_awk_setfilename (
|
||||||
epa->run, infiles[infile_no],
|
epa->run, infiles[infile_no],
|
||||||
ase_strlen(infiles[infile_no])) == -1)
|
ase_strlen(infiles[infile_no])) == -1)
|
||||||
@ -759,7 +759,7 @@ 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"));
|
local_dprintf (ASE_T(" console(w) - <standard output>\n"));
|
||||||
|
|
||||||
if (ase_awk_setofilename (epa->run, ASE_T(""), 0) == -1)
|
if (ase_awk_setofilename (epa->run, ASE_T(""), 0) == -1)
|
||||||
{
|
{
|
||||||
@ -775,7 +775,7 @@ static int open_extio_console (ase_awk_extio_t* epa)
|
|||||||
|
|
||||||
static int close_extio_console (ase_awk_extio_t* epa)
|
static int close_extio_console (ase_awk_extio_t* epa)
|
||||||
{
|
{
|
||||||
dprintf (ASE_T("closing console of type %x\n"), epa->type);
|
local_dprintf (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 &&
|
||||||
@ -802,7 +802,7 @@ static int next_extio_console (ase_awk_extio_t* epa)
|
|||||||
int n;
|
int n;
|
||||||
FILE* fp = (FILE*)epa->handle;
|
FILE* fp = (FILE*)epa->handle;
|
||||||
|
|
||||||
dprintf (ASE_T("switching console[%s] of type %x\n"), epa->name, epa->type);
|
local_dprintf (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;
|
||||||
@ -846,47 +846,47 @@ static void stop_run (int sig)
|
|||||||
static void on_run_start (ase_awk_run_t* run, void* custom)
|
static void on_run_start (ase_awk_run_t* run, void* custom)
|
||||||
{
|
{
|
||||||
app_run = run;
|
app_run = run;
|
||||||
dprintf (ASE_T("[AWK ABOUT TO START]\n"));
|
local_dprintf (ASE_T("[AWK ABOUT TO START]\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int print_awk_value (ase_pair_t* pair, void* arg)
|
static int print_awk_value (ase_pair_t* pair, void* arg)
|
||||||
{
|
{
|
||||||
ase_awk_run_t* run = (ase_awk_run_t*)arg;
|
ase_awk_run_t* run = (ase_awk_run_t*)arg;
|
||||||
dprintf (ASE_T("%.*s = "), pair->key.len, pair->key.ptr);
|
local_dprintf (ASE_T("%.*s = "), pair->key.len, pair->key.ptr);
|
||||||
ase_awk_dprintval (run, (ase_awk_val_t*)pair->val);
|
ase_awk_dprintval (run, (ase_awk_val_t*)pair->val);
|
||||||
dprintf (ASE_T("\n"));
|
local_dprintf (ASE_T("\n"));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_run_statement (
|
static void on_run_statement (
|
||||||
ase_awk_run_t* run, ase_size_t line, void* custom)
|
ase_awk_run_t* run, ase_size_t line, void* custom)
|
||||||
{
|
{
|
||||||
/*dprintf (L"running %d\n", (int)line);*/
|
/*local_dprintf (L"running %d\n", (int)line);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_run_return (
|
static void on_run_return (
|
||||||
ase_awk_run_t* run, ase_awk_val_t* ret, void* custom)
|
ase_awk_run_t* run, ase_awk_val_t* ret, void* custom)
|
||||||
{
|
{
|
||||||
dprintf (ASE_T("[RETURN] - "));
|
local_dprintf (ASE_T("[RETURN] - "));
|
||||||
ase_awk_dprintval (run, ret);
|
ase_awk_dprintval (run, ret);
|
||||||
dprintf (ASE_T("\n"));
|
local_dprintf (ASE_T("\n"));
|
||||||
|
|
||||||
dprintf (ASE_T("[NAMED VARIABLES]\n"));
|
local_dprintf (ASE_T("[NAMED VARIABLES]\n"));
|
||||||
ase_map_walk (ase_awk_getrunnamedvarmap(run), print_awk_value, run);
|
ase_map_walk (ase_awk_getrunnamedvarmap(run), print_awk_value, run);
|
||||||
dprintf (ASE_T("[END NAMED VARIABLES]\n"));
|
local_dprintf (ASE_T("[END NAMED VARIABLES]\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_run_end (ase_awk_run_t* run, int errnum, void* custom_data)
|
static void on_run_end (ase_awk_run_t* run, int errnum, void* custom_data)
|
||||||
{
|
{
|
||||||
if (errnum != ASE_AWK_ENOERR)
|
if (errnum != ASE_AWK_ENOERR)
|
||||||
{
|
{
|
||||||
dprintf (ASE_T("[AWK ENDED WITH AN ERROR]\n"));
|
local_dprintf (ASE_T("[AWK ENDED WITH AN ERROR]\n"));
|
||||||
ase_printf (ASE_T("RUN ERROR: CODE [%d] LINE [%u] %s\n"),
|
ase_printf (ASE_T("RUN ERROR: CODE [%d] LINE [%u] %s\n"),
|
||||||
errnum,
|
errnum,
|
||||||
(unsigned int)ase_awk_getrunerrlin(run),
|
(unsigned int)ase_awk_getrunerrlin(run),
|
||||||
ase_awk_getrunerrmsg(run));
|
ase_awk_getrunerrmsg(run));
|
||||||
}
|
}
|
||||||
else dprintf (ASE_T("[AWK ENDED SUCCESSFULLY]\n"));
|
else local_dprintf (ASE_T("[AWK ENDED SUCCESSFULLY]\n"));
|
||||||
|
|
||||||
app_run = NULL;
|
app_run = NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user