From 18da765a29ecc5ec3ee5057b1240dae905720ebd Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Wed, 30 Aug 2006 14:25:33 +0000 Subject: [PATCH] *** empty log message *** --- ase/awk/run.c | 2 +- ase/awk/sa.c | 82 ++++++++------------------------------------ ase/awk/sa.h | 8 ++++- ase/test/awk/t14.awk | 13 ++++--- 4 files changed, 30 insertions(+), 75 deletions(-) diff --git a/ase/awk/run.c b/ase/awk/run.c index 651f12f2..fc555cd8 100644 --- a/ase/awk/run.c +++ b/ase/awk/run.c @@ -1,5 +1,5 @@ /* - * $Id: run.c,v 1.184 2006-08-30 14:23:19 bacon Exp $ + * $Id: run.c,v 1.185 2006-08-30 14:25:33 bacon Exp $ */ #include diff --git a/ase/awk/sa.c b/ase/awk/sa.c index e936a946..3e8ee858 100644 --- a/ase/awk/sa.c +++ b/ase/awk/sa.c @@ -1,5 +1,5 @@ /* - * $Id: sa.c,v 1.30 2006-08-16 11:35:53 bacon Exp $ + * $Id: sa.c,v 1.31 2006-08-30 14:23:19 bacon Exp $ */ #include @@ -123,79 +123,25 @@ xp_char_t* xp_strxnstr ( xp_char_t* xp_strtok (const xp_char_t* s, const xp_char_t* delim, xp_char_t** tok, xp_size_t* tok_len) { - const xp_char_t* p = s, *d; - const xp_char_t* sp = XP_NULL, * ep = XP_NULL; - xp_char_t c; - int delim_mode; - - /* skip preceding space xp_char_tacters */ - while (/* *p != XP_T('\0') && */ xp_isspace(*p)) p++; - - if (delim == XP_NULL) delim_mode = 0; - else { - delim_mode = 1; - for (d = delim; *d != XP_T('\0'); d++) - if (!xp_isspace(*d)) delim_mode = 2; - } - - if (delim_mode == 0) { - /* when XP_NULL is given as "delim", it has an effect of cutting - preceding and trailing space characters off "s". */ - while ((c = *p) != XP_T('\0')) - { - if (!xp_isspace(c)) - { - if (sp == XP_NULL) sp = p; - ep = p; - } - p++; - } - } - else if (delim_mode == 1) - { - while ((c = *p) != XP_T('\0')) - { - if (xp_isspace(c)) break; - - if (sp == XP_NULL) sp = p; - ep = p++; - } - } - else /* if (delim_mode == 2) */ - { - while ((c = *p) != XP_T('\0')) { - if (xp_isspace(c)) { - p++; - continue; - } - for (d = delim; *d; d++) { - if (c == *d) { - goto exit_loop; - } - } - if (sp == XP_NULL) sp = p; - ep = p++; - } - } - -exit_loop: - if (sp == XP_NULL) { - *tok = XP_NULL; - *tok_len = (xp_size_t)0; - } - else { - *tok = (xp_char_t*)sp; - *tok_len = ep - sp + 1; - } - return (c == XP_T('\0'))? XP_NULL: ((xp_char_t*)++p); + return xp_strxntok ( + s, xp_strlen(s), delim, xp_strlen(delim), tok, tok_len); } xp_char_t* xp_strxtok (const xp_char_t* s, xp_size_t len, const xp_char_t* delim, xp_char_t** tok, xp_size_t* tok_len) +{ + return xp_strxntok (s, len, delim, xp_strlen(delim), tok, tok_len); +} + +xp_char_t* xp_strxntok ( + const xp_char_t* s, xp_size_t len, + const xp_char_t* delim, xp_size_t delim_len, + xp_char_t** tok, xp_size_t* tok_len) { const xp_char_t* p = s, *d; const xp_char_t* end = s + len; const xp_char_t* sp = XP_NULL, * ep = XP_NULL; + const xp_char_t* delim_end = delim + delim_len; xp_char_t c; int delim_mode; @@ -206,7 +152,7 @@ xp_char_t* xp_strxtok (const xp_char_t* s, xp_size_t len, else { delim_mode = 1; - for (d = delim; *d != XP_T('\0'); d++) + for (d = delim; d < delim_end; d++) if (!xp_isspace(*d)) delim_mode = 2; } @@ -246,7 +192,7 @@ xp_char_t* xp_strxtok (const xp_char_t* s, xp_size_t len, p++; continue; } - for (d = delim; *d != XP_T('\0'); d++) + for (d = delim; d < delim_end; d++) { if (c == *d) goto exit_loop; } diff --git a/ase/awk/sa.h b/ase/awk/sa.h index 0730bcba..4f9fe69d 100644 --- a/ase/awk/sa.h +++ b/ase/awk/sa.h @@ -1,5 +1,5 @@ /* - * $Id: sa.h,v 1.32 2006-08-30 07:15:14 bacon Exp $ + * $Id: sa.h,v 1.33 2006-08-30 14:23:19 bacon Exp $ */ #ifndef _XP_AWK_SA_H_ @@ -153,6 +153,12 @@ xp_char_t* xp_strtok (const xp_char_t* s, xp_char_t* xp_strxtok (const xp_char_t* s, xp_size_t len, const xp_char_t* delim, xp_char_t** tok, xp_size_t* tok_len); +#define xp_strxntok xp_awk_strxntok +xp_char_t* xp_strxntok ( + const xp_char_t* s, xp_size_t len, + const xp_char_t* delim, xp_size_t delim_len, + xp_char_t** tok, xp_size_t* tok_len); + #define xp_printf xp_awk_printf int xp_printf (const xp_char_t* fmt, ...); diff --git a/ase/test/awk/t14.awk b/ase/test/awk/t14.awk index 5bb69639..b0f3aad9 100644 --- a/ase/test/awk/t14.awk +++ b/ase/test/awk/t14.awk @@ -1,5 +1,7 @@ global x, y; +BEGIN { FS="A"; } + { print "NF = " NF; for (i = 0; i < 10; i++) @@ -10,11 +12,12 @@ global x, y; $1 = 100; - //$1 = $2; - //$3 = $2; - //$2 = $2; + /*$1 = $2; + $3 = $2; + $2 = $2;*/ + + /*OFS["1234"]=":";*/ - OFS["1234"]=":"; $20 = 10; print $0; print "--------------------"; @@ -22,4 +25,4 @@ global x, y; print "===================="; } -END { system ("dir /w/p"); print sin(270); } +END { fflush (); system ("dir /w/p"); print sin(270); }