diff --git a/ase/awk/makefile.bcc b/ase/awk/makefile.bcc index de87b8f3..a6246598 100644 --- a/ase/awk/makefile.bcc +++ b/ase/awk/makefile.bcc @@ -13,7 +13,7 @@ all: $(OBJS) ! clean: - del $(OBJS) $(OUT) *.obj + -del $(OBJS) $(OUT) *.obj .SUFFIXES: .c .obj .c.obj: diff --git a/ase/awk/makefile.tcc b/ase/awk/makefile.tcc index 0f8efa6c..8cd32673 100644 --- a/ase/awk/makefile.tcc +++ b/ase/awk/makefile.tcc @@ -1,21 +1,37 @@ +# +# makefile for turbo c 2.0 +# + SRCS = awk.c err.c tree.c str.c tab.c map.c parse.c \ run.c rec.c val.c misc.c extio.c rex.c -OBJS = $(SRCS:.c=.obj) +OBJS = awk.obj err.obj tree.obj str.obj tab.obj map.obj parse.obj \ + run.obj rec.obj val.obj misc.obj extio.obj rex.obj OUT = xpawk.lib CC = tcc +AR = tlib CFLAGS = -1 -O -mh -w -f87 -G -I..\.. -Ddos -DXP_AWK_STAND_ALONE all: $(OBJS) - tlib $(OUT) @&&! -+-$(**: = &^ -+-) -! + -del $(OUT) + $(AR) $(OUT) +awk.obj + $(AR) $(OUT) +err.obj + $(AR) $(OUT) +tree.obj + $(AR) $(OUT) +str.obj + $(AR) $(OUT) +tab.obj + $(AR) $(OUT) +map.obj + $(AR) $(OUT) +parse.obj + $(AR) $(OUT) +run.obj + $(AR) $(OUT) +rec.obj + $(AR) $(OUT) +val.obj + $(AR) $(OUT) +misc.obj + $(AR) $(OUT) +extio.obj + $(AR) $(OUT) +rex.obj clean: - del $(OBJS) $(OUT) *.obj + -del *.obj + -del $(OUT) -.SUFFIXES: .c .obj .c.obj: $(CC) $(CFLAGS) -c $< diff --git a/ase/awk/rex.c b/ase/awk/rex.c index 79545cbd..920bae97 100644 --- a/ase/awk/rex.c +++ b/ase/awk/rex.c @@ -1,5 +1,5 @@ /* - * $Id: rex.c,v 1.33 2006-10-04 10:11:04 bacon Exp $ + * $Id: rex.c,v 1.34 2006-10-08 05:46:41 bacon Exp $ */ #include @@ -57,7 +57,7 @@ typedef struct __match_t __match_t; struct __code_t { - //xp_byte_t cmd; + /*xp_byte_t cmd;*/ short cmd; short negate; /* only for CMD_CHARSET */ xp_size_t lbound; @@ -334,7 +334,6 @@ int xp_awk_matchrex ( matcher.depth.max = awk->max_depth; */ matcher.depth.max = 0; matcher.depth.cur = 0; -// TODO: set it to a good value matcher.ignorecase = (option & XP_AWK_REX_IGNORECASE)? 1: 0; mat.matched = xp_false; @@ -720,7 +719,9 @@ static int __build_charset (__builder_t* builder, struct __code_t* cmd) else { /* invalid range */ -//xp_printf (XP_T("invalid character set range\n")); +#ifdef DEBUG_REX +xp_printf (XP_T("__build_charset: invalid character set range\n")); +#endif builder->errnum = XP_AWK_EREXCRANGE; return -1; } @@ -750,7 +751,9 @@ static int __build_cclass (__builder_t* builder, xp_char_t* cc) if (ccp->name == XP_NULL) { /* wrong class name */ -//xp_printf (XP_T("wrong class name\n")); +#ifdef DEBUG_REX +xp_printf (XP_T("__build_cclass: wrong class name\n"));*/ +#endif builder->errnum = XP_AWK_EREXCCLASS; return -1; } @@ -761,7 +764,9 @@ static int __build_cclass (__builder_t* builder, xp_char_t* cc) if (builder->ptn.curc.type != CT_NORMAL || builder->ptn.curc.value != XP_T(':')) { -//xp_printf (XP_T(": expected\n")); +#ifdef BUILD_REX +xp_printf (XP_T("__build_cclass: a colon(:) expected\n")); +#endif builder->errnum = XP_AWK_EREXCOLON; return -1; } @@ -772,7 +777,9 @@ static int __build_cclass (__builder_t* builder, xp_char_t* cc) if (builder->ptn.curc.type != CT_SPECIAL || builder->ptn.curc.value != XP_T(']')) { -//xp_printf (XP_T("] expected\n")); +#ifdef DEBUG_REX +xp_printf (XP_T("__build_cclass: ] expected\n")); +#endif builder->errnum = XP_AWK_EREXRBRACKET; return -1; } @@ -838,8 +845,8 @@ static int __build_range (__builder_t* builder, struct __code_t* cmd) { xp_size_t bound; -// TODO: should allow white spaces in the range??? -// what if it is not in the raight format? convert it to ordinary characters?? +/* TODO: should allow white spaces in the range??? +what if it is not in the raight format? convert it to ordinary characters?? */ bound = 0; while (builder->ptn.curc.type == CT_NORMAL && (builder->ptn.curc.value >= XP_T('0') && @@ -1017,7 +1024,9 @@ static const xp_byte_t* __match_pattern ( nb = *(xp_size_t*)p; p += xp_sizeof(nb); el = *(xp_size_t*)p; p += xp_sizeof(el); -//xp_printf (XP_T("NB = %u, EL = %u\n"), (unsigned)nb, (unsigned)el); +#ifdef BUILD_REX +xp_printf (XP_T("__match_pattern: NB = %u, EL = %u\n"), (unsigned)nb, (unsigned)el); +#endif mat->matched = xp_false; mat->match_len = 0; @@ -1078,7 +1087,7 @@ static const xp_byte_t* __match_branch_body0 ( __matcher_t* matcher, const xp_byte_t* base, __match_t* mat) { const xp_byte_t* p; -// __match_t mat2; +/* __match_t mat2;*/ xp_size_t match_len = 0; mat->matched = xp_false; @@ -1200,8 +1209,11 @@ static const xp_byte_t* __match_any_char ( p += xp_sizeof(*cp); } -//xp_printf (XP_T("lbound = %u, ubound = %u\n"), -//(unsigned int)lbound, (unsigned int)ubound); +#ifdef BUILD_REX +xp_printf (XP_T("__match_any_char: lbound = %u, ubound = %u\n"), + (unsigned int)lbound, (unsigned int)ubound); +#endif + /* find the longest match */ while (si < ubound) { @@ -1209,7 +1221,9 @@ static const xp_byte_t* __match_any_char ( si++; } -//xp_printf (XP_T("max si = %d\n"), si); +#ifdef BUILD_REX +xp_printf (XP_T("__match_any_char: max si = %d\n"), si); +#endif if (si >= lbound && si <= ubound) { p = __match_occurrences (matcher, si, p, lbound, ubound, mat); @@ -1265,8 +1279,10 @@ static const xp_byte_t* __match_ord_char ( } } -//xp_printf (XP_T("lbound = %u, ubound = %u\n"), -//(unsigned int)lbound, (unsigned int)ubound); +#ifdef BUILD_REX +xp_printf (XP_T("__match_ord_char: lbound = %u, ubound = %u\n"), + (unsigned int)lbound, (unsigned int)ubound);*/ +#endif mat->matched = xp_false; mat->match_len = 0; @@ -1291,7 +1307,10 @@ static const xp_byte_t* __match_ord_char ( } } -//xp_printf (XP_T("max si = %d, lbound = %u, ubound = %u\n"), si, lbound, ubound); +#ifdef DEBUG_REX +xp_printf (XP_T("__match_ord_char: max si = %d, lbound = %u, ubound = %u\n"), si, lbound, ubound); +#endif + if (si >= lbound && si <= ubound) { p = __match_occurrences (matcher, si, p, lbound, ubound, mat); @@ -1445,7 +1464,9 @@ static const xp_byte_t* __match_group ( mat2.branch = mat->branch; mat2.branch_end = mat->branch_end; -//xp_printf (XP_T("GROUP si = %d [%s]\n"), si, mat->match_ptr); +#ifdef DEBUG_REX +xp_printf (XP_T("__match_group: GROUP si = %d [%s]\n"), si, mat->match_ptr); +#endif tmp = __match_branch_body (matcher, p, &mat2); if (tmp == XP_NULL) { @@ -1542,7 +1563,9 @@ static const xp_byte_t* __match_occurrences ( mat2.branch = mat->branch; mat2.branch_end = mat->branch_end; -//xp_printf (XP_T("si = %d [%s]\n"), si, mat->match_ptr); +#ifdef DEBUG_REX +xp_printf (XP_T("__match occurrences: si = %d [%s]\n"), si, mat->match_ptr); +#endif tmp = __match_branch_body (matcher, p, &mat2); if (mat2.matched) @@ -1683,7 +1706,9 @@ static const xp_byte_t* __print_pattern (const xp_byte_t* p) nb = *(xp_size_t*)p; p += xp_sizeof(nb); el = *(xp_size_t*)p; p += xp_sizeof(el); -//xp_printf (XP_T("NB = %u, EL = %u\n"), (unsigned int)nb, (unsigned int)el); +#ifdef DEBUG_REX +xp_printf (XP_T("__print_pattern: NB = %u, EL = %u\n"), (unsigned int)nb, (unsigned int)el); +#endif for (i = 0; i < nb; i++) { @@ -1700,7 +1725,9 @@ static const xp_byte_t* __print_branch (const xp_byte_t* p) na = *(xp_size_t*)p; p += xp_sizeof(na); bl = *(xp_size_t*)p; p += xp_sizeof(bl); -//xp_printf (XP_T("NA = %u, BL = %u\n"), (unsigned int) na, (unsigned int)bl); +#ifdef DEBUG_REX +xp_printf (XP_T("__print_branch: NA = %u, BL = %u\n"), (unsigned int) na, (unsigned int)bl); +#endif for (i = 0; i < na; i++) { diff --git a/ase/awk/run.c b/ase/awk/run.c index 17832244..c9304903 100644 --- a/ase/awk/run.c +++ b/ase/awk/run.c @@ -1,5 +1,5 @@ /* - * $Id: run.c,v 1.226 2006-10-06 14:34:37 bacon Exp $ + * $Id: run.c,v 1.227 2006-10-08 05:46:41 bacon Exp $ */ #include @@ -2974,13 +2974,13 @@ static int __cmp_str_nil ( static int __cmp_str_int ( xp_awk_run_t* run, xp_awk_val_t* left, xp_awk_val_t* right) { - return __cmp_int_str (run, right, left); + return -__cmp_int_str (run, right, left); } static int __cmp_str_real ( xp_awk_run_t* run, xp_awk_val_t* left, xp_awk_val_t* right) { - return __cmp_real_str (run, right, left); + return -__cmp_real_str (run, right, left); } static int __cmp_str_str ( diff --git a/ase/awk/val.c b/ase/awk/val.c index 3756ed01..fd089998 100644 --- a/ase/awk/val.c +++ b/ase/awk/val.c @@ -1,5 +1,5 @@ /* - * $Id: val.c,v 1.69 2006-10-06 03:33:43 bacon Exp $ + * $Id: val.c,v 1.70 2006-10-08 05:46:41 bacon Exp $ */ #include @@ -649,7 +649,7 @@ int xp_awk_valtonum ( /* TODO: need to check if it is a valid number using endptr for strxtoreal? */ return 1; /* real */ } - +/* TODO: do should i handle strings ending with invalid number characters like "123xx" or "dkdkdkd"? */ return 0; /* long */ }