diff --git a/ase/awk/awk.c b/ase/awk/awk.c index 5ca8f0b6..32eff25b 100644 --- a/ase/awk/awk.c +++ b/ase/awk/awk.c @@ -1,5 +1,5 @@ /* - * $Id: awk.c,v 1.47 2006-04-24 15:34:52 bacon Exp $ + * $Id: awk.c,v 1.48 2006-05-10 16:02:38 bacon Exp $ */ #include @@ -75,6 +75,8 @@ xp_awk_t* xp_awk_open (void) awk->lex.curc = XP_CHAR_EOF; awk->lex.ungotc_count = 0; + awk->lex.buf_pos = 0; + awk->lex.buf_len = 0; return awk; } @@ -165,6 +167,8 @@ int xp_awk_attsrc (xp_awk_t* awk, xp_awk_io_t src, void* arg) awk->srcio_arg = arg; awk->lex.curc = XP_CHAR_EOF; awk->lex.ungotc_count = 0; + awk->lex.buf_pos = 0; + awk->lex.buf_len = 0; return 0; } @@ -185,6 +189,8 @@ int xp_awk_detsrc (xp_awk_t* awk) awk->srcio_arg = XP_NULL; awk->lex.curc = XP_CHAR_EOF; awk->lex.ungotc_count = 0; + awk->lex.buf_pos = 0; + awk->lex.buf_len = 0; } return 0; diff --git a/ase/awk/awk_i.h b/ase/awk/awk_i.h index 3c935aea..323ee024 100644 --- a/ase/awk/awk_i.h +++ b/ase/awk/awk_i.h @@ -1,5 +1,5 @@ /* - * $Id: awk_i.h,v 1.8 2006-04-22 13:54:52 bacon Exp $ + * $Id: awk_i.h,v 1.9 2006-05-10 16:02:39 bacon Exp $ */ #ifndef _XP_AWK_AWKI_H_ @@ -96,6 +96,10 @@ struct xp_awk_t xp_cint_t curc; xp_cint_t ungotc[5]; xp_size_t ungotc_count; + + xp_char_t buf[512]; + xp_size_t buf_pos; + xp_size_t buf_len; } lex; /* token */ diff --git a/ase/awk/parse.c b/ase/awk/parse.c index 6e5567f5..e31ee6d6 100644 --- a/ase/awk/parse.c +++ b/ase/awk/parse.c @@ -1,5 +1,5 @@ /* - * $Id: parse.c,v 1.102 2006-05-07 17:45:08 bacon Exp $ + * $Id: parse.c,v 1.103 2006-05-10 16:02:39 bacon Exp $ */ #include @@ -3131,6 +3131,7 @@ static int __get_char (xp_awk_t* awk) return 0; } + /* n = awk->srcio (XP_AWK_INPUT_DATA, awk->srcio_arg, &c, 1); if (n == -1) { @@ -3138,7 +3139,28 @@ static int __get_char (xp_awk_t* awk) return -1; } awk->lex.curc = (n == 0)? XP_CHAR_EOF: c; - + */ + if (awk->lex.buf_pos >= awk->lex.buf_len) + { + n = awk->srcio (XP_AWK_INPUT_DATA, + awk->srcio_arg, awk->lex.buf, xp_countof(awk->lex.buf)); + if (n == -1) + { + awk->errnum = XP_AWK_ESRCINDATA; + return -1; + } + + if (n == 0) + { + awk->lex.curc = XP_CHAR_EOF; + return 0; + } + + awk->lex.buf_pos = 0; + awk->lex.buf_len = n; + } + + awk->lex.curc = awk->lex.buf[awk->lex.buf_pos++]; return 0; } diff --git a/ase/test/awk/t1.awk b/ase/test/awk/t1.awk index 85907b6c..1ca5faee 100644 --- a/ase/test/awk/t1.awk +++ b/ase/test/awk/t1.awk @@ -17,3 +17,4 @@ BEGIN { s = sum (100); } +