*** empty log message ***

This commit is contained in:
hyung-hwan 2006-09-02 14:59:15 +00:00
parent cb27721259
commit 9386a9a7ac
8 changed files with 93 additions and 80 deletions

View File

@ -231,10 +231,6 @@ SOURCE=.\run.c
# End Source File
# Begin Source File
SOURCE=.\sa.c
# End Source File
# Begin Source File
SOURCE=.\str.c
# End Source File
# Begin Source File
@ -283,10 +279,6 @@ SOURCE=.\run.h
# End Source File
# Begin Source File
SOURCE=.\sa.h
# End Source File
# Begin Source File
SOURCE=.\str.h
# End Source File
# Begin Source File

View File

@ -1,5 +1,5 @@
/*
* $Id: func.c,v 1.43 2006-09-01 16:30:50 bacon Exp $
* $Id: func.c,v 1.44 2006-09-02 14:58:27 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -504,6 +504,7 @@ static int __bfn_split (xp_awk_t* awk, void* run)
xp_size_t len, left, tok_len;
xp_long_t num;
xp_char_t key[xp_sizeof(xp_long_t)*8+2];
xp_size_t key_len;
nargs = xp_awk_getnargs (run);
xp_assert (nargs >= 2 && nargs <= 3);
@ -579,11 +580,13 @@ static int __bfn_split (xp_awk_t* awk, void* run)
}
/* put it into the map */
xp_awk_longtostr (num, 10, XP_NULL, key, xp_countof(key));
key_len = xp_awk_longtostr (
num, 10, XP_NULL, key, xp_countof(key));
xp_assert (key_len != (xp_size_t)-1);
if (xp_awk_map_putx (
((xp_awk_val_map_t*)t1)->map,
key, xp_awk_strlen(key), t2, XP_NULL) == -1)
key, key_len, t2, XP_NULL) == -1)
{
if (a0->type != XP_AWK_VAL_STR) XP_AWK_FREE (awk, str);
xp_awk_seterrnum (run, XP_AWK_ENOMEM);

View File

@ -1,5 +1,5 @@
/*
* $Id: parse.c,v 1.178 2006-09-01 16:30:50 bacon Exp $
* $Id: parse.c,v 1.179 2006-09-02 14:58:28 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -4106,7 +4106,7 @@ static int __deparse (xp_awk_t* awk)
if (awk->tree.nglobals > awk->tree.nbglobals)
{
xp_size_t i;
xp_size_t i, n;
xp_assert (awk->tree.nglobals > 0);
if (xp_awk_putsrcstr (awk, XP_T("global ")) == -1)
@ -4114,17 +4114,19 @@ static int __deparse (xp_awk_t* awk)
for (i = awk->tree.nbglobals; i < awk->tree.nglobals - 1; i++)
{
xp_awk_longtostr ((xp_long_t)i,
n = xp_awk_longtostr ((xp_long_t)i,
10, XP_T("__global"), tmp, xp_countof(tmp));
if (xp_awk_putsrcstr (awk, tmp) == -1)
xp_assert (n != (xp_size_t)-1);
if (xp_awk_putsrcstrx (awk, tmp, n) == -1)
EXIT_DEPARSE (XP_AWK_ESRCOUTWRITE);
if (xp_awk_putsrcstr (awk, XP_T(", ")) == -1)
EXIT_DEPARSE (XP_AWK_ESRCOUTWRITE);
}
xp_awk_longtostr ((xp_long_t)i,
n = xp_awk_longtostr ((xp_long_t)i,
10, XP_T("__global"), tmp, xp_countof(tmp));
if (xp_awk_putsrcstr (awk, tmp) == -1)
xp_assert (n != (xp_size_t)-1);
if (xp_awk_putsrcstrx (awk, tmp, n) == -1)
EXIT_DEPARSE (XP_AWK_ESRCOUTWRITE);
if (xp_awk_putsrcstr (awk, XP_T(";\n\n")) == -1)
EXIT_DEPARSE (XP_AWK_ESRCOUTWRITE);
@ -4206,7 +4208,7 @@ static int __deparse_func (xp_awk_pair_t* pair, void* arg)
{
struct __deparse_func_t* df = (struct __deparse_func_t*)arg;
xp_awk_afn_t* afn = (xp_awk_afn_t*)pair->val;
xp_size_t i;
xp_size_t i, n;
xp_assert (xp_awk_strxncmp (
pair->key, pair->key_len, afn->name, afn->name_len) == 0);
@ -4217,9 +4219,10 @@ static int __deparse_func (xp_awk_pair_t* pair, void* arg)
for (i = 0; i < afn->nargs; )
{
xp_awk_longtostr (i++, 10,
n = xp_awk_longtostr (i++, 10,
XP_T("__param"), df->tmp, df->tmp_len);
if (xp_awk_putsrcstr (df->awk, df->tmp) == -1) return -1;
xp_assert (n != (xp_size_t)-1);
if (xp_awk_putsrcstrx (df->awk, df->tmp, n) == -1) return -1;
if (i >= afn->nargs) break;
if (xp_awk_putsrcstr (df->awk, XP_T(", ")) == -1) return -1;
}

View File

@ -1,5 +1,5 @@
/*
* $Id: run.c,v 1.194 2006-09-01 07:18:40 bacon Exp $
* $Id: run.c,v 1.195 2006-09-02 14:58:28 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -636,6 +636,14 @@ static int __run_main (xp_awk_run_t* run)
run->stack_top = saved_stack_top;
return -1;
}
if (xp_awk_setglobal (run, XP_AWK_GLOBAL_NF, xp_awk_val_zero) == -1)
{
/* it can simply restore the top of the stack this way
* because the values pused onto the stack so far are
* all xp_awk_val_nils and xp_awk_val_zeros */
run->stack_top = saved_stack_top;
return -1;
}
run->exit_level = EXIT_NONE;
@ -1833,19 +1841,20 @@ static xp_awk_val_t* __eval_expression (xp_awk_run_t* run, xp_awk_nde_t* nde)
if (v->type == XP_AWK_VAL_REX)
{
xp_awk_refupval (v);
if (run->inrec.d0->type == XP_AWK_VAL_NIL)
{
/* the record has never been read.
* probably, this functions has been triggered
* by the statements in the BEGIN block */
n = xp_awk_isemptyrex(
n = xp_awk_isemptyrex (
((xp_awk_val_rex_t*)v)->code)? 1: 0;
}
else
{
xp_assert (run->inrec.d0->type == XP_AWK_VAL_STR);
xp_awk_refupval (v);
n = xp_awk_matchrex (
((xp_awk_run_t*)run)->awk,
((xp_awk_val_rex_t*)v)->code,
@ -1858,11 +1867,10 @@ static xp_awk_val_t* __eval_expression (xp_awk_run_t* run, xp_awk_nde_t* nde)
xp_awk_refdownval (run, v);
PANIC (run, errnum);
}
}
xp_awk_refdownval (run, v);
}
v = xp_awk_makeintval (run, (n != 0));
if (v == XP_NULL) PANIC (run, XP_AWK_ENOMEM);
}

View File

@ -1,5 +1,5 @@
/*
* $Id: tree.c,v 1.72 2006-09-01 03:44:17 bacon Exp $
* $Id: tree.c,v 1.73 2006-09-02 14:58:28 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -122,8 +122,6 @@ static int __print_tabs (xp_awk_t* awk, int depth)
static int __print_expression (xp_awk_t* awk, xp_awk_nde_t* nde)
{
xp_char_t tmp[128];
switch (nde->type)
{
case XP_AWK_NDE_GRP:
@ -230,30 +228,20 @@ static int __print_expression (xp_awk_t* awk, xp_awk_nde_t* nde)
case XP_AWK_NDE_INT:
{
#if defined(__LCC__)
xp_awk_sprintf (
awk, tmp, xp_countof(tmp), XP_T("%lld"),
(long long)((xp_awk_nde_int_t*)nde)->val);
#elif defined(__BORLANDC__) || defined(_MSC_VER)
xp_awk_sprintf (
awk, tmp, xp_countof(tmp), XP_T("%I64d"),
(__int64)((xp_awk_nde_int_t*)nde)->val);
#elif defined(vax) || defined(__vax) || defined(_SCO_DS)
xp_awk_sprintf (
awk, tmp, xp_countof(tmp), XP_T("%ld"),
(long)((xp_awk_nde_int_t*)nde)->val);
#else
xp_awk_sprintf (
awk, tmp, xp_countof(tmp), XP_T("%lld"),
(long long)((xp_awk_nde_int_t*)nde)->val);
#endif
xp_char_t tmp[xp_sizeof(xp_long_t)*8+2];
xp_size_t n;
PUT_SRCSTR (awk, tmp);
n = xp_awk_longtostr (
((xp_awk_nde_int_t*)nde)->val,
10, XP_NULL, tmp, xp_countof(tmp));
PUT_SRCSTRX (awk, tmp, n);
break;
}
case XP_AWK_NDE_REAL:
{
xp_char_t tmp[128];
xp_awk_sprintf (
awk, tmp, xp_countof(tmp), XP_T("%Lf"),
(long double)((xp_awk_nde_real_t*)nde)->val);
@ -285,14 +273,16 @@ static int __print_expression (xp_awk_t* awk, xp_awk_nde_t* nde)
case XP_AWK_NDE_ARG:
{
xp_char_t tmp[xp_sizeof(xp_long_t)*8+2];
xp_size_t n;
xp_awk_nde_var_t* px = (xp_awk_nde_var_t*)nde;
xp_assert (px->id.idxa != (xp_size_t)-1);
n = xp_awk_longtostr (
px->id.idxa, 10, XP_NULL, tmp, xp_countof(tmp));
PUT_SRCSTR (awk, XP_T("__param"));
xp_awk_sprintf (
awk, tmp, xp_countof(tmp),
XP_T("%lu"), (unsigned long)px->id.idxa);
PUT_SRCSTR (awk, tmp);
PUT_SRCSTRX (awk, tmp, n);
xp_assert (px->idx == XP_NULL);
break;
@ -300,15 +290,16 @@ static int __print_expression (xp_awk_t* awk, xp_awk_nde_t* nde)
case XP_AWK_NDE_ARGIDX:
{
xp_char_t tmp[xp_sizeof(xp_long_t)*8+2];
xp_size_t n;
xp_awk_nde_var_t* px = (xp_awk_nde_var_t*)nde;
xp_assert (px->id.idxa != (xp_size_t)-1);
xp_assert (px->idx != XP_NULL);
PUT_SRCSTR (awk, XP_T("__param"));
xp_awk_sprintf (
awk, tmp, xp_countof(tmp),
XP_T("%lu"), (unsigned long)px->id.idxa);
PUT_SRCSTR (awk, tmp);
n = xp_awk_longtostr (
px->id.idxa, 10, XP_NULL, tmp, xp_countof(tmp));
PUT_SRCSTRX (awk, tmp, n);
PUT_SRCSTR (awk, XP_T("["));
PRINT_EXPRESSION_LIST (awk, px->idx);
PUT_SRCSTR (awk, XP_T("]"));
@ -340,14 +331,17 @@ static int __print_expression (xp_awk_t* awk, xp_awk_nde_t* nde)
case XP_AWK_NDE_GLOBAL:
{
xp_char_t tmp[xp_sizeof(xp_long_t)*8+2];
xp_size_t n;
xp_awk_nde_var_t* px = (xp_awk_nde_var_t*)nde;
if (px->id.idxa != (xp_size_t)-1)
{
PUT_SRCSTR (awk, XP_T("__global"));
xp_awk_sprintf (
awk, tmp, xp_countof(tmp),
XP_T("%lu"), (unsigned long)px->id.idxa);
PUT_SRCSTR (awk, tmp);
n = xp_awk_longtostr (
px->id.idxa, 10,
XP_NULL, tmp, xp_countof(tmp));
PUT_SRCSTRX (awk, tmp, n);
}
else
{
@ -359,14 +353,17 @@ static int __print_expression (xp_awk_t* awk, xp_awk_nde_t* nde)
case XP_AWK_NDE_GLOBALIDX:
{
xp_char_t tmp[xp_sizeof(xp_long_t)*8+2];
xp_size_t n;
xp_awk_nde_var_t* px = (xp_awk_nde_var_t*)nde;
if (px->id.idxa != (xp_size_t)-1)
{
PUT_SRCSTR (awk, XP_T("__global"));
xp_awk_sprintf (
awk, tmp, xp_countof(tmp),
XP_T("%lu"), (unsigned long)px->id.idxa);
PUT_SRCSTR (awk, tmp);
n = xp_awk_longtostr (
px->id.idxa, 10,
XP_NULL, tmp, xp_countof(tmp));
PUT_SRCSTRX (awk, tmp, n);
PUT_SRCSTR (awk, XP_T("["));
}
else
@ -382,14 +379,17 @@ static int __print_expression (xp_awk_t* awk, xp_awk_nde_t* nde)
case XP_AWK_NDE_LOCAL:
{
xp_char_t tmp[xp_sizeof(xp_long_t)*8+2];
xp_size_t n;
xp_awk_nde_var_t* px = (xp_awk_nde_var_t*)nde;
if (px->id.idxa != (xp_size_t)-1)
{
PUT_SRCSTR (awk, XP_T("__local"));
xp_awk_sprintf (
awk, tmp, xp_countof(tmp),
XP_T("%lu"), (unsigned long)px->id.idxa);
PUT_SRCSTR (awk, tmp);
n = xp_awk_longtostr (
px->id.idxa, 10,
XP_NULL, tmp, xp_countof(tmp));
PUT_SRCSTRX (awk, tmp, n);
}
else
{
@ -401,14 +401,17 @@ static int __print_expression (xp_awk_t* awk, xp_awk_nde_t* nde)
case XP_AWK_NDE_LOCALIDX:
{
xp_char_t tmp[xp_sizeof(xp_long_t)*8+2];
xp_size_t n;
xp_awk_nde_var_t* px = (xp_awk_nde_var_t*)nde;
if (px->id.idxa != (xp_size_t)-1)
{
PUT_SRCSTR (awk, XP_T("__local"));
xp_awk_sprintf (
awk, tmp, xp_countof(tmp),
XP_T("%lu"), (unsigned long)px->id.idxa);
PUT_SRCSTR (awk, tmp);
n = xp_awk_longtostr (
px->id.idxa, 10,
XP_NULL, tmp, xp_countof(tmp));
PUT_SRCSTRX (awk, tmp, n);
PUT_SRCSTR (awk, XP_T("["));
}
else
@ -509,7 +512,6 @@ static int __print_expression_list (xp_awk_t* awk, xp_awk_nde_t* tree)
static int __print_statements (xp_awk_t* awk, xp_awk_nde_t* tree, int depth)
{
xp_awk_nde_t* p = tree;
xp_char_t tmp[128];
xp_size_t i;
while (p != XP_NULL)
@ -526,6 +528,8 @@ static int __print_statements (xp_awk_t* awk, xp_awk_nde_t* tree, int depth)
case XP_AWK_NDE_BLK:
{
xp_char_t tmp[xp_sizeof(xp_long_t)*8+2];
xp_size_t n;
xp_awk_nde_blk_t* px = (xp_awk_nde_blk_t*)p;
PRINT_TABS (awk, depth);
@ -539,14 +543,16 @@ static int __print_statements (xp_awk_t* awk, xp_awk_nde_t* tree, int depth)
for (i = 0; i < px->nlocals - 1; i++)
{
PUT_SRCSTR (awk, XP_T("__local"));
xp_awk_sprintf (awk, tmp, xp_countof(tmp), XP_T("%lu"), (unsigned long)i);
PUT_SRCSTR (awk, tmp);
n = xp_awk_longtostr (
i, 10, XP_NULL, tmp, xp_countof(tmp));
PUT_SRCSTRX (awk, tmp, n);
PUT_SRCSTR (awk, XP_T(", "));
}
PUT_SRCSTR (awk, XP_T("__local"));
xp_awk_sprintf (awk, tmp, xp_countof(tmp), XP_T("%lu"), (unsigned long)i);
PUT_SRCSTR (awk, tmp);
n = xp_awk_longtostr (
i, 10, XP_NULL, tmp, xp_countof(tmp));
PUT_SRCSTRX (awk, tmp, n);
PUT_SRCSTR (awk, XP_T(";\n"));
}

View File

@ -1,5 +1,5 @@
/*
* $Id: awk.c,v 1.86 2006-09-01 16:31:13 bacon Exp $
* $Id: awk.c,v 1.87 2006-09-02 14:59:15 bacon Exp $
*/
#include <xp/awk/awk.h>
@ -627,7 +627,6 @@ static int __main (int argc, xp_char_t* argv[])
}
else
{
xp_awk_close (awk);
xp_printf (XP_T("Usage: %s [-m] source_file [data_file]\n"), argv[0]);
return -1;
}

View File

@ -1,12 +1,14 @@
function main ()
{
local i;
local i, k, c;
for (i = 0; i < 10; i++)
{
abc[i*2] = i;
}
k = 20;
for (i = 0; i < 100; i++)
{
if (i in abc) j[i] = i;

View File

@ -74,7 +74,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
# ADD LINK32 xpawk.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"..\..\..\debug\awk.exe" /pdbtype:sept /libpath:"..\..\..\debug"
# ADD LINK32 xpawk.lib xpbas.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"..\..\..\debug\awk.exe" /pdbtype:sept /libpath:"..\..\..\debug"
!ENDIF