*** empty log message ***

This commit is contained in:
hyung-hwan 2006-11-17 07:06:53 +00:00
parent a926eb0ae7
commit 4b33fba56f
10 changed files with 80 additions and 17 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Id: awk_i.h,v 1.80 2006-11-16 15:16:24 bacon Exp $ * $Id: awk_i.h,v 1.81 2006-11-17 07:04:31 bacon Exp $
*/ */
#ifndef _ASE_AWK_AWKI_H_ #ifndef _ASE_AWK_AWKI_H_
@ -195,9 +195,9 @@ struct ase_awk_run_t
ase_size_t stack_limit; ase_size_t stack_limit;
int exit_level; int exit_level;
ase_awk_val_int_t* icache[100]; /* TODO: choose the optimal size */ ase_awk_val_int_t* icache[200]; /* TODO: choose the optimal size */
ase_awk_val_real_t* rcache[100]; /* TODO: choose the optimal size */ ase_awk_val_real_t* rcache[200]; /* TODO: choose the optimal size */
ase_awk_val_ref_t* fcache[100]; /* TODO: choose the optimal size */ ase_awk_val_ref_t* fcache[200]; /* TODO: choose the optimal size */
ase_size_t icache_count; ase_size_t icache_count;
ase_size_t rcache_count; ase_size_t rcache_count;
ase_size_t fcache_count; ase_size_t fcache_count;

View File

@ -1,5 +1,5 @@
/* /*
* $Id: parse.c,v 1.202 2006-11-13 15:08:17 bacon Exp $ * $Id: parse.c,v 1.203 2006-11-17 07:04:31 bacon Exp $
*/ */
#include <ase/awk/awk_i.h> #include <ase/awk/awk_i.h>
@ -4376,6 +4376,11 @@ static int __deparse (ase_awk_t* awk)
} }
else else
{ {
if (chain->pattern != ASE_NULL)
{
if (__put_char (awk, ASE_T(' ')) == -1)
EXIT_DEPARSE (ASE_AWK_ESRCOUTWRITE);
}
if (ase_awk_prnpt (awk, chain->action) == -1) if (ase_awk_prnpt (awk, chain->action) == -1)
EXIT_DEPARSE (ASE_AWK_ESRCOUTWRITE); EXIT_DEPARSE (ASE_AWK_ESRCOUTWRITE);
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: run.c,v 1.263 2006-11-16 15:16:25 bacon Exp $ * $Id: run.c,v 1.264 2006-11-17 07:04:31 bacon Exp $
*/ */
#include <ase/awk/awk_i.h> #include <ase/awk/awk_i.h>
@ -1149,7 +1149,8 @@ static int __run_main (ase_awk_run_t* run, ase_awk_runarg_t* runarg)
} }
if (n == 0 && if (n == 0 &&
run->awk->tree.chain != ASE_NULL && (run->awk->tree.chain != ASE_NULL ||
run->awk->tree.end != ASE_NULL) &&
run->exit_level != EXIT_ABORT) run->exit_level != EXIT_ABORT)
{ {
if (__run_pattern_blocks (run) == -1) n = -1; if (__run_pattern_blocks (run) == -1) n = -1;
@ -1197,7 +1198,7 @@ static int __run_main (ase_awk_run_t* run, ase_awk_runarg_t* runarg)
} }
/* pops off the global variables */ /* pops off the global variables */
nglobals = run->awk->tree.nglobals; /*run->nglobals */ nglobals = run->awk->tree.nglobals;
while (nglobals > 0) while (nglobals > 0)
{ {
--nglobals; --nglobals;
@ -1252,7 +1253,10 @@ static int __run_pattern_blocks (ase_awk_run_t* run)
__update_fnr (run, run->global.fnr + 1); __update_fnr (run, run->global.fnr + 1);
if (__run_pattern_block_chain (run, run->awk->tree.chain) == -1) if (run->awk->tree.chain != ASE_NULL)
{
if (__run_pattern_block_chain (
run, run->awk->tree.chain) == -1)
{ {
int saved = run->errnum; int saved = run->errnum;
@ -1263,6 +1267,7 @@ static int __run_pattern_blocks (ase_awk_run_t* run)
return -1; return -1;
} }
} }
}
/* In case of getline, the code would make getline return -1, /* In case of getline, the code would make getline return -1,
* set ERRNO, make this function return 0 after having checked * set ERRNO, make this function return 0 after having checked
@ -1428,6 +1433,18 @@ static int __run_block (ase_awk_run_t* run, ase_awk_nde_blk_t* nde)
else return -1; else return -1;
} }
n = ase_awk_writeextio_str (
run, ASE_AWK_OUT_CONSOLE, ASE_T(""),
run->global.ors.ptr, run->global.ors.len);
if (n == -1)
{
ase_awk_refdownval (run, run->inrec.d0);
if (run->errnum == ASE_AWK_EIOHANDLER)
PANIC_I (run, ASE_AWK_ECONOUTDATA);
else return -1;
}
ase_awk_refdownval (run, run->inrec.d0); ase_awk_refdownval (run, run->inrec.d0);
return 0; return 0;
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: tree.c,v 1.86 2006-11-01 04:41:01 bacon Exp $ * $Id: tree.c,v 1.87 2006-11-17 07:04:32 bacon Exp $
*/ */
#include <ase/awk/awk_i.h> #include <ase/awk/awk_i.h>
@ -273,11 +273,36 @@ static int __print_expression (ase_awk_t* awk, ase_awk_nde_t* nde)
case ASE_AWK_NDE_STR: case ASE_AWK_NDE_STR:
{ {
/* TODO: ESCAPING */ ase_char_t* ptr;
ase_size_t len, i;
PUT_SRCSTR (awk, ASE_T("\"")); PUT_SRCSTR (awk, ASE_T("\""));
/*
PUT_SRCSTRX (awk, PUT_SRCSTRX (awk,
((ase_awk_nde_str_t*)nde)->buf, ((ase_awk_nde_str_t*)nde)->buf,
((ase_awk_nde_str_t*)nde)->len); ((ase_awk_nde_str_t*)nde)->len);
*/
ptr = ((ase_awk_nde_str_t*)nde)->buf;
len = ((ase_awk_nde_str_t*)nde)->len;
for (i = 0; i < len; i++)
{
/* TODO: more deescaping */
if (ptr[i] == ASE_T('\n'))
PUT_SRCSTR (awk, ASE_T("\\n"));
else if (ptr[i] == ASE_T('\r'))
PUT_SRCSTR (awk, ASE_T("\\r"));
else if (ptr[i] == ASE_T('\f'))
PUT_SRCSTR (awk, ASE_T("\\f"));
else if (ptr[i] == ASE_T('\b'))
PUT_SRCSTR (awk, ASE_T("\\b"));
else if (ptr[i] == ASE_T('\v'))
PUT_SRCSTR (awk, ASE_T("\\v"));
else if (ptr[i] == ASE_T('\a'))
PUT_SRCSTR (awk, ASE_T("\\a"));
else
PUT_SRCSTRX (awk, &ptr[i], 1);
}
PUT_SRCSTR (awk, ASE_T("\"")); PUT_SRCSTR (awk, ASE_T("\""));
break; break;
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: val.c,v 1.87 2006-11-16 15:16:25 bacon Exp $ * $Id: val.c,v 1.88 2006-11-17 07:04:32 bacon Exp $
*/ */
#include <ase/awk/awk_i.h> #include <ase/awk/awk_i.h>
@ -631,6 +631,7 @@ static ase_char_t* __val_real_to_str (
{ {
ase_awk_str_close (&fbu); ase_awk_str_close (&fbu);
ase_awk_str_forfeit (&out); ase_awk_str_forfeit (&out);
if (len != ASE_NULL) *len = tmp_len;
} }
else else
{ {

2
ase/test/awk/emp-021.awk Normal file
View File

@ -0,0 +1,2 @@
{ names = names $1 " "; }
END { print names; }

2
ase/test/awk/emp-022.awk Normal file
View File

@ -0,0 +1,2 @@
{ last = $0; }
END { print last; }

1
ase/test/awk/emp-023.awk Normal file
View File

@ -0,0 +1 @@
{ print $1, length($1); }

4
ase/test/awk/emp-024.awk Normal file
View File

@ -0,0 +1,4 @@
{ nc = nc + length($0) + 1;
nw = nw + NF;
}
END { print NR, "lines,", nw, "words,", nc, "characters"; }

6
ase/test/awk/emp.data Normal file
View File

@ -0,0 +1,6 @@
Beth 4.00 0
Dan 3.74 0
Kathy 4.00 10
Mark 5.00 20
Mary 5.50 22
Susie 4.25 18