Recovered from cvs revision 2007-10-26 12:49:00

This commit is contained in:
hyung-hwan 2007-10-26 21:49:00 +00:00
parent 01c0434577
commit d60e97954b
7 changed files with 65 additions and 29 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Id: Awk.hpp,v 1.78 2007/10/21 07:59:35 bacon Exp $ * $Id: Awk.hpp,v 1.79 2007/10/25 14:43:17 bacon Exp $
* *
* {License} * {License}
*/ */
@ -571,7 +571,6 @@ public:
GBL_ARGC = ASE_AWK_GLOBAL_ARGC, GBL_ARGC = ASE_AWK_GLOBAL_ARGC,
GBL_ARGV = ASE_AWK_GLOBAL_ARGV, GBL_ARGV = ASE_AWK_GLOBAL_ARGV,
GBL_CONVFMT = ASE_AWK_GLOBAL_CONVFMT, GBL_CONVFMT = ASE_AWK_GLOBAL_CONVFMT,
GBL_ENVIRON = ASE_AWK_GLOBAL_ENVIRON,
GBL_FILENAME = ASE_AWK_GLOBAL_FILENAME, GBL_FILENAME = ASE_AWK_GLOBAL_FILENAME,
GBL_FNR = ASE_AWK_GLOBAL_FNR, GBL_FNR = ASE_AWK_GLOBAL_FNR,
GBL_FS = ASE_AWK_GLOBAL_FS, GBL_FS = ASE_AWK_GLOBAL_FS,

View File

@ -1,5 +1,5 @@
/* /*
* $Id: awk.h,v 1.22 2007/10/24 09:57:45 bacon Exp $ * $Id: awk.h,v 1.23 2007/10/25 14:43:17 bacon Exp $
* *
* {License} * {License}
*/ */
@ -408,7 +408,6 @@ enum ase_awk_global_id_t
ASE_AWK_GLOBAL_ARGC, ASE_AWK_GLOBAL_ARGC,
ASE_AWK_GLOBAL_ARGV, ASE_AWK_GLOBAL_ARGV,
ASE_AWK_GLOBAL_CONVFMT, ASE_AWK_GLOBAL_CONVFMT,
ASE_AWK_GLOBAL_ENVIRON,
ASE_AWK_GLOBAL_FILENAME, ASE_AWK_GLOBAL_FILENAME,
ASE_AWK_GLOBAL_FNR, ASE_AWK_GLOBAL_FNR,
ASE_AWK_GLOBAL_FS, ASE_AWK_GLOBAL_FS,

View File

@ -1,5 +1,5 @@
/* /*
* $Id: extio.c,v 1.5 2007/10/21 13:58:47 bacon Exp $ * $Id: extio.c,v 1.6 2007/10/25 14:43:17 bacon Exp $
* *
* {License} * {License}
*/ */
@ -74,6 +74,8 @@ static int out_mask_map[] =
MASK_WRITE MASK_WRITE
}; };
#include <windows.h>
#include <tchar.h>
int ase_awk_readextio ( int ase_awk_readextio (
ase_awk_run_t* run, int in_type, ase_awk_run_t* run, int in_type,
const ase_char_t* name, ase_str_t* buf) const ase_char_t* name, ase_str_t* buf)
@ -409,12 +411,16 @@ int ase_awk_readextio (
{ {
if (n == 1) lv = (ase_long_t)rv; if (n == 1) lv = (ase_long_t)rv;
// TODO---> WRONG: NR SHOULD BE UPDATED FOR CONSOLE INPUT...
// { print "NR=" NR; a=getline<"awk.c"; print a; }
{
wchar_t x[100];
_sntprintf (x, 100, _T("ddd %d\n"), (int)lv);
OutputDebugStringW (x);
}
nr = ase_awk_makeintval (run, lv + 1); nr = ase_awk_makeintval (run, lv + 1);
if (nr == ASE_NULL) if (nr == ASE_NULL) ret = -1;
{
/*ase_awk_setrunerrnum (run, ASE_AWK_ENOMEM);*/
ret = -1;
}
else else
{ {
if (ase_awk_setglobal ( if (ase_awk_setglobal (

View File

@ -1,5 +1,5 @@
/* /*
* $Id: func.c,v 1.12 2007/10/24 09:57:45 bacon Exp $ * $Id: func.c,v 1.13 2007/10/25 14:43:17 bacon Exp $
* *
* {License} * {License}
*/ */
@ -142,7 +142,7 @@ ase_awk_bfn_t* ase_awk_getbfn (
for (bfn = sys_bfn; bfn->name.ptr != ASE_NULL; bfn++) for (bfn = sys_bfn; bfn->name.ptr != ASE_NULL; bfn++)
{ {
if (bfn->valid != 0 && if (bfn->valid != 0 &&
(awk->option & bfn->valid) == 0) continue; (awk->option & bfn->valid) != bfn->valid) continue;
pair = ase_awk_map_get ( pair = ase_awk_map_get (
awk->kwtab, bfn->name.ptr, bfn->name.len); awk->kwtab, bfn->name.ptr, bfn->name.len);

View File

@ -1,5 +1,5 @@
/* /*
* $Id: parse.c,v 1.22 2007/10/24 14:17:32 bacon Exp $ * $Id: parse.c,v 1.23 2007/10/25 14:43:17 bacon Exp $
* *
* {License} * {License}
*/ */
@ -82,7 +82,6 @@ enum
TOKEN_EXIT, TOKEN_EXIT,
TOKEN_NEXT, TOKEN_NEXT,
TOKEN_NEXTFILE, TOKEN_NEXTFILE,
TOKEN_NEXTINFILE,
TOKEN_NEXTOFILE, TOKEN_NEXTOFILE,
TOKEN_DELETE, TOKEN_DELETE,
TOKEN_RESET, TOKEN_RESET,
@ -256,9 +255,9 @@ static kwent_t kwtab[] =
{ ASE_T("continue"), 8, TOKEN_CONTINUE, 0 }, { ASE_T("continue"), 8, TOKEN_CONTINUE, 0 },
{ ASE_T("return"), 6, TOKEN_RETURN, 0 }, { ASE_T("return"), 6, TOKEN_RETURN, 0 },
{ ASE_T("exit"), 4, TOKEN_EXIT, 0 }, { ASE_T("exit"), 4, TOKEN_EXIT, 0 },
{ ASE_T("next"), 4, TOKEN_NEXT, 0 }, { ASE_T("next"), 4, TOKEN_NEXT, ASE_AWK_PABLOCK },
{ ASE_T("nextfile"), 8, TOKEN_NEXTFILE, 0 }, { ASE_T("nextfile"), 8, TOKEN_NEXTFILE, ASE_AWK_PABLOCK },
{ ASE_T("nextofile"), 9, TOKEN_NEXTOFILE, ASE_AWK_NEXTOFILE }, { ASE_T("nextofile"), 9, TOKEN_NEXTOFILE, ASE_AWK_PABLOCK | ASE_AWK_NEXTOFILE },
{ ASE_T("delete"), 6, TOKEN_DELETE, 0 }, { ASE_T("delete"), 6, TOKEN_DELETE, 0 },
{ ASE_T("reset"), 5, TOKEN_RESET, ASE_AWK_RESET }, { ASE_T("reset"), 5, TOKEN_RESET, ASE_AWK_RESET },
{ ASE_T("print"), 5, TOKEN_PRINT, ASE_AWK_EXTIO }, { ASE_T("print"), 5, TOKEN_PRINT, ASE_AWK_EXTIO },
@ -283,18 +282,42 @@ static global_t gtab[] =
{ {
{ ASE_T("ARGC"), 4, 0 }, { ASE_T("ARGC"), 4, 0 },
{ ASE_T("ARGV"), 4, 0 }, { ASE_T("ARGV"), 4, 0 },
/* output real-to-str conversion format for other cases than 'print' */
{ ASE_T("CONVFMT"), 7, 0 }, { ASE_T("CONVFMT"), 7, 0 },
{ ASE_T("ENVIRON"), 7, 0 },
{ ASE_T("FILENAME"), 8, 0 }, /* current input file name */
{ ASE_T("FNR"), 3, 0 }, { ASE_T("FILENAME"), 8, ASE_AWK_PABLOCK },
/* input record number in current file */
{ ASE_T("FNR"), 3, ASE_AWK_PABLOCK },
/* input field separator */
{ ASE_T("FS"), 2, 0 }, { ASE_T("FS"), 2, 0 },
/* ignore case in string comparison */
{ ASE_T("IGNORECASE"), 10, 0 }, { ASE_T("IGNORECASE"), 10, 0 },
/* number of fields in current input record */
{ ASE_T("NF"), 2, 0 }, { ASE_T("NF"), 2, 0 },
/* input record number */
{ ASE_T("NR"), 2, 0 }, { ASE_T("NR"), 2, 0 },
{ ASE_T("OFILENAME"), 9, ASE_AWK_NEXTOFILE },
{ ASE_T("OFMT"), 4, 0 }, /* current output file name */
{ ASE_T("OFS"), 3, 0 }, { ASE_T("OFILENAME"), 9, ASE_AWK_PABLOCK | ASE_AWK_NEXTOFILE },
{ ASE_T("ORS"), 3, 0 },
/* output real-to-str conversion format for 'print' */
{ ASE_T("OFMT"), 4, ASE_AWK_EXTIO},
/* output field separator for 'print' */
{ ASE_T("OFS"), 3, ASE_AWK_EXTIO },
/* output record separator. used for 'print' and blockless output
* ASE_AWK_BLOCKLESS desn't have to be specified becuase
* it requires ASE_AWK_EXTIO to be ON. */
{ ASE_T("ORS"), 3, ASE_AWK_EXTIO },
{ ASE_T("RLENGTH"), 7, 0 }, { ASE_T("RLENGTH"), 7, 0 },
{ ASE_T("RS"), 2, 0 }, { ASE_T("RS"), 2, 0 },
{ ASE_T("RSTART"), 6, 0 }, { ASE_T("RSTART"), 6, 0 },
@ -718,6 +741,7 @@ static ase_awk_t* parse_progunit (ase_awk_t* awk)
{ {
/* blockless pattern */ /* blockless pattern */
ase_bool_t newline = MATCH(awk,TOKEN_NEWLINE); ase_bool_t newline = MATCH(awk,TOKEN_NEWLINE);
ase_size_t tline = awk->token.prev.line;
awk->parse.id.block = PARSE_ACTION_BLOCK; awk->parse.id.block = PARSE_ACTION_BLOCK;
if (parse_pattern_block ( if (parse_pattern_block (
@ -738,6 +762,15 @@ static ase_awk_t* parse_progunit (ase_awk_t* awk)
return ASE_NULL; return ASE_NULL;
} }
} }
if ((awk->option & ASE_AWK_EXTIO) != ASE_AWK_EXTIO)
{
/* blockless pattern requires ASE_AWK_EXTIO
* to be ON because the implicit block is
* "print $0" */
SETERRLIN (awk, ASE_AWK_ENOSUP, tline);
return ASE_NULL;
}
} }
else else
{ {
@ -5029,7 +5062,7 @@ static int classify_ident (
ase_size_t l; ase_size_t l;
if (kwp->valid != 0 && if (kwp->valid != 0 &&
(awk->option & kwp->valid) == 0) continue; (awk->option & kwp->valid) != kwp->valid) continue;
pair = ase_awk_map_get (awk->kwtab, kwp->name, kwp->name_len); pair = ase_awk_map_get (awk->kwtab, kwp->name, kwp->name_len);
if (pair != ASE_NULL) if (pair != ASE_NULL)

View File

@ -1,5 +1,5 @@
/* /*
* $Id: run.c,v 1.18 2007/10/21 13:58:47 bacon Exp $ * $Id: run.c,v 1.19 2007/10/25 14:43:17 bacon Exp $
* *
* {License} * {License}
*/ */
@ -1624,7 +1624,6 @@ static int run_block0 (ase_awk_run_t* run, ase_awk_nde_blk_t* nde)
/* adjust the error line */ /* adjust the error line */
run->errlin = nde->line; run->errlin = nde->line;
return -1; return -1;
} }
@ -1637,7 +1636,6 @@ static int run_block0 (ase_awk_run_t* run, ase_awk_nde_blk_t* nde)
/* adjust the error line */ /* adjust the error line */
run->errlin = nde->line; run->errlin = nde->line;
return -1; return -1;
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: AseAwkPanel.java,v 1.10 2007/10/24 14:17:32 bacon Exp $ * $Id: AseAwkPanel.java,v 1.11 2007/10/25 14:43:17 bacon Exp $
*/ */
import java.awt.*; import java.awt.*;
@ -97,6 +97,7 @@ public class AseAwkPanel extends Panel
setWord ("OFMT", "ofmt"); setWord ("OFMT", "ofmt");
setOption (getOption() | StdAwk.OPTION_MAPTOVAR); setOption (getOption() | StdAwk.OPTION_MAPTOVAR);
//setOption (getOption() & ~StdAwk.OPTION_EXTIO);
} }
public void sleep (Context ctx, String name, Return ret, Argument[] args) public void sleep (Context ctx, String name, Return ret, Argument[] args)