*** empty log message ***
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: awk.h,v 1.71 2006-06-22 04:25:44 bacon Exp $
|
||||
* $Id: awk.h,v 1.72 2006-06-25 15:26:57 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _XP_AWK_AWK_H_
|
||||
@ -35,12 +35,15 @@ enum
|
||||
|
||||
enum
|
||||
{
|
||||
XP_AWK_IO_FILE_READ = 0,
|
||||
XP_AWK_IO_FILE_WRITE = 1,
|
||||
XP_AWK_IO_FILE_APPEND = 2,
|
||||
XP_AWK_IO_PIPE_READ = 0,
|
||||
XP_AWK_IO_PIPE_WRITE = 1,
|
||||
|
||||
XP_AWK_IO_PIPE_READ = 0,
|
||||
XP_AWK_IO_PIPE_WRITE = 1
|
||||
XP_AWK_IO_FILE_READ = 0,
|
||||
XP_AWK_IO_FILE_WRITE = 1,
|
||||
XP_AWK_IO_FILE_APPEND = 2,
|
||||
|
||||
XP_AWK_IO_CONSOLE_READ = 0,
|
||||
XP_AWK_IO_CONSOLE_WRITE = 1
|
||||
};
|
||||
|
||||
/* parse options */
|
||||
@ -132,6 +135,7 @@ enum
|
||||
XP_AWK_EXTIO_PIPE,
|
||||
XP_AWK_EXTIO_COPROC,
|
||||
XP_AWK_EXTIO_FILE,
|
||||
XP_AWK_EXTIO_CONSOLE,
|
||||
|
||||
/* reserved for internal use only */
|
||||
XP_AWK_EXTIO_NUM
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: extio.c,v 1.9 2006-06-22 14:15:01 bacon Exp $
|
||||
* $Id: extio.c,v 1.10 2006-06-25 15:26:57 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk_i.h>
|
||||
@ -147,6 +147,8 @@ int xp_awk_writeextio (
|
||||
ioopt = XP_AWK_IO_PIPE_READ;
|
||||
else if (type == XP_AWK_EXTIO_FILE)
|
||||
ioopt = XP_AWK_IO_FILE_READ;
|
||||
else if (type == XP_AWK_EXTIO_CONSOLE)
|
||||
ioopt = XP_AWK_IO_CONSOLE_READ;
|
||||
else ioopt = 0; /* TODO: how to handle this??? */
|
||||
|
||||
if (handler (XP_AWK_IO_OPEN, ioopt, p, XP_NULL, 0) == -1)
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: parse.c,v 1.121 2006-06-22 14:15:01 bacon Exp $
|
||||
* $Id: parse.c,v 1.122 2006-06-25 15:26:57 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk_i.h>
|
||||
@ -2784,7 +2784,7 @@ static xp_awk_nde_t* __parse_print (xp_awk_t* awk)
|
||||
xp_awk_nde_print_t* nde;
|
||||
xp_awk_nde_t* args = XP_NULL;
|
||||
xp_awk_nde_t* out = XP_NULL;
|
||||
int out_type = -1;
|
||||
int out_type;
|
||||
|
||||
/* TODO: handle expression list, not just a single expression */
|
||||
/* TODO: handle ambiguiouty print "1111" > "2222". is > redirection? */
|
||||
@ -2799,24 +2799,13 @@ static xp_awk_nde_t* __parse_print (xp_awk_t* awk)
|
||||
if (args == XP_NULL) return XP_NULL;
|
||||
}
|
||||
|
||||
if (MATCH(awk,TOKEN_GT))
|
||||
{
|
||||
out_type = XP_AWK_PRINT_FILE;
|
||||
}
|
||||
else if (MATCH(awk,TOKEN_RSHIFT))
|
||||
{
|
||||
out_type = XP_AWK_PRINT_FILE_APPEND;
|
||||
}
|
||||
else if (MATCH(awk,TOKEN_BOR))
|
||||
{
|
||||
out_type = XP_AWK_PRINT_PIPE;
|
||||
}
|
||||
else if (MATCH(awk,TOKEN_BORAND))
|
||||
{
|
||||
out_type = XP_AWK_PRINT_COPROC;
|
||||
}
|
||||
out_type = MATCH(awk,TOKEN_GT)? XP_AWK_PRINT_FILE:
|
||||
MATCH(awk,TOKEN_RSHIFT)? XP_AWK_PRINT_FILE_APPEND:
|
||||
MATCH(awk,TOKEN_BOR)? XP_AWK_PRINT_PIPE:
|
||||
MATCH(awk,TOKEN_BORAND)? XP_AWK_PRINT_COPROC:
|
||||
XP_AWK_PRINT_CONSOLE;
|
||||
|
||||
if (out_type != -1)
|
||||
if (out_type != XP_AWK_PRINT_CONSOLE)
|
||||
{
|
||||
if (__get_token(awk) == -1)
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: run.c,v 1.106 2006-06-22 14:15:01 bacon Exp $
|
||||
* $Id: run.c,v 1.107 2006-06-25 15:26:57 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk_i.h>
|
||||
@ -1162,6 +1162,33 @@ static int __run_print_statement (xp_awk_run_t* run, xp_awk_nde_print_t* nde)
|
||||
xp_printf (XP_T("eval_print PRINT_FILE not properly implemented....\n"));
|
||||
return -1;
|
||||
}
|
||||
else if (p->out_type == XP_AWK_PRINT_CONSOLE)
|
||||
{
|
||||
xp_awk_nde_t* np;
|
||||
int n, errnum;
|
||||
|
||||
xp_assert (p->out == XP_NULL);
|
||||
|
||||
for (np = p->args; np != XP_NULL; np = np->next)
|
||||
{
|
||||
v = __eval_expression (run, np);
|
||||
if (v == XP_NULL) return -1;
|
||||
xp_awk_refupval (v);
|
||||
|
||||
/* console has the fixed name */
|
||||
n = xp_awk_writeextio (
|
||||
run, XP_AWK_EXTIO_CONSOLE, XP_T("console"), v, &errnum);
|
||||
if (n < 0 && errnum != XP_AWK_ENOERR)
|
||||
{
|
||||
xp_awk_refdownval (run, v);
|
||||
PANIC_I (run, errnum);
|
||||
}
|
||||
|
||||
xp_awk_refdownval (run, v);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if (p->out_type == XP_AWK_PRINT_FILE_APPEND)
|
||||
{
|
||||
xp_printf (XP_T("eval_print PRINT_FILE_APPEND not properly implemented....\n"));
|
||||
@ -1169,7 +1196,7 @@ static int __run_print_statement (xp_awk_run_t* run, xp_awk_nde_print_t* nde)
|
||||
}
|
||||
else
|
||||
{
|
||||
xp_assert (!"should never happen - wrong out_type for getline");
|
||||
xp_assert (!"should never happen - wrong out_type for print");
|
||||
PANIC_I (run, XP_AWK_EINTERNAL);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: tree.c,v 1.56 2006-06-22 14:15:02 bacon Exp $
|
||||
* $Id: tree.c,v 1.57 2006-06-25 15:26:57 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <xp/awk/awk_i.h>
|
||||
@ -80,7 +80,8 @@ static const xp_char_t* __print_outop_str[] =
|
||||
XP_T("|"),
|
||||
XP_T("|&"),
|
||||
XP_T(">"),
|
||||
XP_T(">>")
|
||||
XP_T(">>"),
|
||||
XP_T("")
|
||||
};
|
||||
|
||||
static void __print_tabs (int depth);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: tree.h,v 1.48 2006-06-22 14:15:02 bacon Exp $
|
||||
* $Id: tree.h,v 1.49 2006-06-25 15:26:57 bacon Exp $
|
||||
*/
|
||||
|
||||
#ifndef _XP_AWK_TREE_H_
|
||||
@ -70,7 +70,8 @@ enum
|
||||
XP_AWK_PRINT_PIPE,
|
||||
XP_AWK_PRINT_COPROC,
|
||||
XP_AWK_PRINT_FILE,
|
||||
XP_AWK_PRINT_FILE_APPEND
|
||||
XP_AWK_PRINT_FILE_APPEND,
|
||||
XP_AWK_PRINT_CONSOLE
|
||||
};
|
||||
|
||||
typedef struct xp_awk_afn_t xp_awk_afn_t;
|
||||
|
Reference in New Issue
Block a user