*** empty log message ***

This commit is contained in:
hyung-hwan 2006-06-28 03:44:40 +00:00
parent 9bd13da27c
commit 69b807966c
5 changed files with 76 additions and 56 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Id: extio.c,v 1.11 2006-06-26 15:09:28 bacon Exp $ * $Id: extio.c,v 1.12 2006-06-28 03:44:39 bacon Exp $
*/ */
#include <xp/awk/awk_i.h> #include <xp/awk/awk_i.h>
@ -100,14 +100,43 @@ xp_printf(XP_TEXT("%s"), buf);
} }
int xp_awk_writeextio ( int xp_awk_writeextio (
xp_awk_run_t* run, int type, xp_awk_run_t* run, int out_type,
const xp_char_t* name, xp_awk_val_t* v, int* errnum) const xp_char_t* name, xp_awk_val_t* v, int* errnum)
{ {
xp_awk_extio_t* p = run->extio; xp_awk_extio_t* p = run->extio;
xp_awk_io_t handler = run->awk->extio[type]; xp_awk_io_t handler;
xp_str_t buf; xp_str_t buf;
int ioopt; int extio_type, extio_opt;
static int __out_type_map[] =
{
/* the order should match the order of the
* XP_AWK_OUT_XXX values in tree.h */
XP_AWK_EXTIO_PIPE,
XP_AWK_EXTIO_COPROC,
XP_AWK_EXTIO_FILE,
XP_AWK_EXTIO_FILE,
XP_AWK_EXTIO_CONSOLE
};
static int __out_opt_map[] =
{
/* the order should match the order of the
* XP_AWK_OUT_XXX values in tree.h */
XP_AWK_IO_PIPE_WRITE,
0,
XP_AWK_IO_FILE_WRITE,
XP_AWK_IO_FILE_APPEND,
XP_AWK_IO_CONSOLE_WRITE
};
xp_assert (out_type >= 0 && out_type <= xp_countof(__out_type_map));
xp_assert (out_type >= 0 && out_type <= xp_countof(__out_opt_map));
extio_type = __out_type_map[out_type];
extio_opt = __out_opt_map[out_type];
handler = run->awk->extio[extio_type];
if (handler == XP_NULL) if (handler == XP_NULL)
{ {
/* no io handler provided */ /* no io handler provided */
@ -132,7 +161,9 @@ int xp_awk_writeextio (
/* look for the corresponding extio for name */ /* look for the corresponding extio for name */
while (p != XP_NULL) while (p != XP_NULL)
{ {
if (p->type == type && xp_strcmp(p->name,name) == 0) break; /* TODO: should it be extio_type or out_type???? */
if (p->type == extio_type &&
xp_strcmp(p->name,name) == 0) break;
p = p->next; p = p->next;
} }
@ -156,19 +187,16 @@ int xp_awk_writeextio (
return -1; return -1;
} }
p->type = type; /* TODO: should it be extio_type or out_type???? */
/* TODO: should it be extio_type or out_type???? */
/* TODO: should it be extio_type or out_type???? */
/* TODO: should it be extio_type or out_type???? */
/* TODO: should it be extio_type or out_type???? */
p->type = extio_type;
p->handle = XP_NULL; p->handle = XP_NULL;
p->next = XP_NULL; p->next = XP_NULL;
if (type == XP_AWK_EXTIO_PIPE) if (handler (XP_AWK_IO_OPEN, extio_opt, p, XP_NULL, 0) == -1)
ioopt = XP_AWK_IO_PIPE_WRITE;
else if (type == XP_AWK_EXTIO_FILE)
ioopt = XP_AWK_IO_FILE_WRITE;
else if (type == XP_AWK_EXTIO_CONSOLE)
ioopt = XP_AWK_IO_CONSOLE_WRITE;
else ioopt = 0; /* TODO: how to handle this??? */
if (handler (XP_AWK_IO_OPEN, ioopt, p, XP_NULL, 0) == -1)
{ {
xp_free (p->name); xp_free (p->name);
xp_free (p); xp_free (p);

View File

@ -1,5 +1,5 @@
/* /*
* $Id: parse.c,v 1.125 2006-06-27 14:32:03 bacon Exp $ * $Id: parse.c,v 1.126 2006-06-28 03:44:39 bacon Exp $
*/ */
#include <xp/awk/awk_i.h> #include <xp/awk/awk_i.h>
@ -2852,7 +2852,7 @@ static xp_awk_nde_t* __parse_print (xp_awk_t* awk)
else args = ep->left; else args = ep->left;
out = ep->right; out = ep->right;
out_type = XP_AWK_PRINT_FILE; out_type = XP_AWK_OUT_FILE;
xp_free (tmp); xp_free (tmp);
} }
@ -2865,7 +2865,7 @@ static xp_awk_nde_t* __parse_print (xp_awk_t* awk)
else args = ep->left; else args = ep->left;
out = ep->right; out = ep->right;
out_type = XP_AWK_PRINT_FILE_APPEND; out_type = XP_AWK_OUT_FILE_APPEND;
xp_free (tmp); xp_free (tmp);
} }
@ -2874,13 +2874,13 @@ static xp_awk_nde_t* __parse_print (xp_awk_t* awk)
if (out == XP_NULL) if (out == XP_NULL)
{ {
out_type = MATCH(awk,TOKEN_GT)? XP_AWK_PRINT_FILE: out_type = MATCH(awk,TOKEN_GT)? XP_AWK_OUT_FILE:
MATCH(awk,TOKEN_RSHIFT)? XP_AWK_PRINT_FILE_APPEND: MATCH(awk,TOKEN_RSHIFT)? XP_AWK_OUT_FILE_APPEND:
MATCH(awk,TOKEN_BOR)? XP_AWK_PRINT_PIPE: MATCH(awk,TOKEN_BOR)? XP_AWK_OUT_PIPE:
MATCH(awk,TOKEN_BORAND)? XP_AWK_PRINT_COPROC: MATCH(awk,TOKEN_BORAND)? XP_AWK_OUT_COPROC:
XP_AWK_PRINT_CONSOLE; XP_AWK_OUT_CONSOLE;
if (out_type != XP_AWK_PRINT_CONSOLE) if (out_type != XP_AWK_OUT_CONSOLE)
{ {
if (__get_token(awk) == -1) if (__get_token(awk) == -1)
{ {

View File

@ -1,5 +1,5 @@
/* /*
* $Id: run.c,v 1.110 2006-06-27 14:18:19 bacon Exp $ * $Id: run.c,v 1.111 2006-06-28 03:44:39 bacon Exp $
*/ */
#include <xp/awk/awk_i.h> #include <xp/awk/awk_i.h>
@ -1099,28 +1099,14 @@ static int __run_print (xp_awk_run_t* run, xp_awk_nde_print_t* nde)
const xp_char_t* dst; const xp_char_t* dst;
xp_awk_val_t* v; xp_awk_val_t* v;
xp_awk_nde_t* np; xp_awk_nde_t* np;
int extio_type, errnum, n; int errnum, n;
static int __print_extio_map[] =
{
/* the order should match the order of the
* XP_AWK_PRINT_XXX values in tree.h */
XP_AWK_EXTIO_PIPE,
XP_AWK_EXTIO_COPROC,
XP_AWK_EXTIO_FILE,
XP_AWK_EXTIO_FILE,
XP_AWK_EXTIO_CONSOLE
};
xp_assert ( xp_assert (
(p->out_type == XP_AWK_PRINT_PIPE && p->out != XP_NULL) || (p->out_type == XP_AWK_OUT_PIPE && p->out != XP_NULL) ||
(p->out_type == XP_AWK_PRINT_COPROC && p->out != XP_NULL) || (p->out_type == XP_AWK_OUT_COPROC && p->out != XP_NULL) ||
(p->out_type == XP_AWK_PRINT_FILE && p->out != XP_NULL) || (p->out_type == XP_AWK_OUT_FILE && p->out != XP_NULL) ||
(p->out_type == XP_AWK_PRINT_FILE_APPEND && p->out != XP_NULL) || (p->out_type == XP_AWK_OUT_FILE_APPEND && p->out != XP_NULL) ||
(p->out_type == XP_AWK_PRINT_CONSOLE && p->out == XP_NULL)); (p->out_type == XP_AWK_OUT_CONSOLE && p->out == XP_NULL));
xp_assert (p->out_type >= 0 && p->out_type < xp_countof(__print_extio_map));
extio_type = __print_extio_map[p->out_type];
if (p->out != XP_NULL) if (p->out != XP_NULL)
{ {
@ -1151,7 +1137,7 @@ static int __run_print (xp_awk_run_t* run, xp_awk_nde_print_t* nde)
} }
xp_awk_refupval (v); xp_awk_refupval (v);
n = xp_awk_writeextio (run, extio_type, dst, v, &errnum); n = xp_awk_writeextio (run, p->out_type, dst, v, &errnum);
if (n < 0 && errnum != XP_AWK_ENOERR) if (n < 0 && errnum != XP_AWK_ENOERR)
{ {
if (out != XP_NULL) xp_free (out); if (out != XP_NULL) xp_free (out);
@ -1174,7 +1160,7 @@ static int __run_print (xp_awk_run_t* run, xp_awk_nde_print_t* nde)
xp_awk_refupval (v); xp_awk_refupval (v);
n = xp_awk_writeextio ( n = xp_awk_writeextio (
run, extio_type, dst, v, &errnum); run, p->out_type, dst, v, &errnum);
if (n < 0 && errnum != XP_AWK_ENOERR) if (n < 0 && errnum != XP_AWK_ENOERR)
{ {
if (out != XP_NULL) xp_free (out); if (out != XP_NULL) xp_free (out);
@ -1199,7 +1185,7 @@ static int __run_print (xp_awk_run_t* run, xp_awk_nde_print_t* nde)
xp_awk_refupval (v); xp_awk_refupval (v);
n = xp_awk_writeextio ( n = xp_awk_writeextio (
run, extio_type, dst, v, &errnum); run, p->out_type, dst, v, &errnum);
if (n < 0 && errnum != XP_AWK_ENOERR) if (n < 0 && errnum != XP_AWK_ENOERR)
{ {
if (out != XP_NULL) xp_free (out); if (out != XP_NULL) xp_free (out);

View File

@ -1,5 +1,5 @@
/* /*
* $Id: tree.h,v 1.51 2006-06-27 14:18:19 bacon Exp $ * $Id: tree.h,v 1.52 2006-06-28 03:44:40 bacon Exp $
*/ */
#ifndef _XP_AWK_TREE_H_ #ifndef _XP_AWK_TREE_H_
@ -67,13 +67,14 @@ enum
enum enum
{ {
/* the order of these values match __print_extio_map in run.c */ /* the order of these values match
* __out_type_map and __out_opt_map in extio.c */
XP_AWK_PRINT_PIPE, XP_AWK_OUT_PIPE,
XP_AWK_PRINT_COPROC, XP_AWK_OUT_COPROC,
XP_AWK_PRINT_FILE, XP_AWK_OUT_FILE,
XP_AWK_PRINT_FILE_APPEND, XP_AWK_OUT_FILE_APPEND,
XP_AWK_PRINT_CONSOLE XP_AWK_OUT_CONSOLE
}; };
typedef struct xp_awk_afn_t xp_awk_afn_t; typedef struct xp_awk_afn_t xp_awk_afn_t;
@ -322,7 +323,7 @@ struct xp_awk_nde_print_t
{ {
XP_AWK_NDE_HDR; XP_AWK_NDE_HDR;
xp_awk_nde_t* args; xp_awk_nde_t* args;
int out_type; /* XP_AWK_PRINT_XXX */ int out_type; /* XP_AWK_OUT_XXX */
xp_awk_nde_t* out; xp_awk_nde_t* out;
}; };

View File

@ -10,4 +10,9 @@ BEGIN
delete abc; delete abc;
delete abc["aaaa"] ; delete abc["aaaa"] ;
/*
print 1 > 2 + 3;
print 1 < 2 + 3;
*/
} }