Recovered from cvs revision 2007-10-12 14:20:00

This commit is contained in:
hyung-hwan 2007-10-13 01:13:00 +00:00
parent 917d2fe1ff
commit 8c505c6d5d
23 changed files with 126 additions and 67 deletions

View File

@ -7,6 +7,7 @@
- added Awk::AddGlobal, Awk::DeleteGlobal (net/Awk.hpp, net/Awk.cpp) - added Awk::AddGlobal, Awk::DeleteGlobal (net/Awk.hpp, net/Awk.cpp)
- added Awk::Run::SetGlobal, Awk::Run::GetGlobal (net/Awk.hpp, net/Awk.cpp) - added Awk::Run::SetGlobal, Awk::Run::GetGlobal (net/Awk.hpp, net/Awk.cpp)
- enhanced ase_awk_getglobalname - enhanced ase_awk_getglobalname
- yet to be added to the COM and JNI bindings.
* added three new options - ASE_AWK_RESET, ASE_AWK_MAPTOVAR, ASE_AWK_PABLOCK * added three new options - ASE_AWK_RESET, ASE_AWK_MAPTOVAR, ASE_AWK_PABLOCK
* enhanced Awk::dispatchFunction to set a more accurate error code (awk/Awk.cpp) * enhanced Awk::dispatchFunction to set a more accurate error code (awk/Awk.cpp)

View File

@ -129,7 +129,7 @@ if [ "$ASEARC" = "gzip" ]
then then
tar -cvf "ase-$ASEVER.tar" "ase-$ASEVER" tar -cvf "ase-$ASEVER.tar" "ase-$ASEVER"
gzip "ase-$ASEVER.tar" gzip "ase-$ASEVER.tar"
mv "ase-$ASEVER.tar.gz" "ase-$ASEVER.tgz" #mv "ase-$ASEVER.tar.gz" "ase-$ASEVER.tgz"
elif [ "$ASEARC" = "zip" ] elif [ "$ASEARC" = "zip" ]
then then
ls -l ls -l

View File

@ -1,5 +1,5 @@
/* /*
* $Id: Awk.cpp,v 1.43 2007/10/10 07:03:56 bacon Exp $ * $Id: Awk.cpp,v 1.45 2007/10/11 14:39:46 bacon Exp $
*/ */
#include <ase/awk/StdAwk.hpp> #include <ase/awk/StdAwk.hpp>
@ -52,8 +52,10 @@ public:
#endif #endif
if (n == -1) if (n == -1)
{ {
#ifdef _WIN32
HeapDestroy (heap); HeapDestroy (heap);
heap = ASE_NULL; heap = ASE_NULL;
#endif
return -1; return -1;
} }
@ -595,41 +597,7 @@ static void print_error (const ase_char_t* msg)
ase_printf (ASE_T("Error: %s\n"), msg); ase_printf (ASE_T("Error: %s\n"), msg);
} }
static void print_usage (const ase_char_t* argv0) static struct
{
const ase_char_t* base;
base = ase_strrchr(argv0, ASE_T('/'));
if (base == ASE_NULL) base = ase_strrchr(argv0, ASE_T('\\'));
if (base == ASE_NULL) base = argv0; else base++;
ase_printf (ASE_T("Usage: %s [-m main] [-si file]? [-so file]? [-ci file]* [-co file]* [-a arg]* [-w o:n]* \n"), base);
ase_printf (ASE_T(" -m main Specify the main function name\n"));
ase_printf (ASE_T(" -si file Specify the input source file\n"));
ase_printf (ASE_T(" The source code is read from stdin when it is not specified\n"));
ase_printf (ASE_T(" -so file Specify the output source file\n"));
ase_printf (ASE_T(" The deparsed code is not output when is it not specified\n"));
ase_printf (ASE_T(" -ci file Specify the input console file\n"));
ase_printf (ASE_T(" -co file Specify the output console file\n"));
ase_printf (ASE_T(" -a str Specify an argument\n"));
ase_printf (ASE_T(" -w o:n Specify an old and new word pair\n"));
ase_printf (ASE_T(" o - an original word\n"));
ase_printf (ASE_T(" n - the new word to replace the original\n"));
}
int awk_main (int argc, ase_char_t* argv[])
{
TestAwk awk;
int mode = 0;
const ase_char_t* mainfn = NULL;
const ase_char_t* srcin = ASE_T("");
const ase_char_t* srcout = NULL;
const ase_char_t* args[256];
ase_size_t nargs = 0;
ase_size_t nsrcins = 0;
ase_size_t nsrcouts = 0;
struct
{ {
const ase_char_t* name; const ase_char_t* name;
TestAwk::Option opt; TestAwk::Option opt;
@ -654,6 +622,48 @@ int awk_main (int argc, ase_char_t* argv[])
{ ASE_T("pablock"), TestAwk::OPT_PABLOCK } { ASE_T("pablock"), TestAwk::OPT_PABLOCK }
}; };
static void print_usage (const ase_char_t* argv0)
{
const ase_char_t* base;
int j;
base = ase_strrchr(argv0, ASE_T('/'));
if (base == ASE_NULL) base = ase_strrchr(argv0, ASE_T('\\'));
if (base == ASE_NULL) base = argv0; else base++;
ase_printf (ASE_T("Usage: %s [-m main] [-si file]? [-so file]? [-ci file]* [-co file]* [-a arg]* [-w o:n]* \n"), base);
ase_printf (ASE_T(" -m main Specify the main function name\n"));
ase_printf (ASE_T(" -si file Specify the input source file\n"));
ase_printf (ASE_T(" The source code is read from stdin when it is not specified\n"));
ase_printf (ASE_T(" -so file Specify the output source file\n"));
ase_printf (ASE_T(" The deparsed code is not output when is it not specified\n"));
ase_printf (ASE_T(" -ci file Specify the input console file\n"));
ase_printf (ASE_T(" -co file Specify the output console file\n"));
ase_printf (ASE_T(" -a str Specify an argument\n"));
ase_printf (ASE_T(" -w o:n Specify an old and new word pair\n"));
ase_printf (ASE_T(" o - an original word\n"));
ase_printf (ASE_T(" n - the new word to replace the original\n"));
ase_printf (ASE_T("\nYou may specify the following options to change the behavior of the interpreter.\n"));
for (j = 0; j < ASE_COUNTOF(otab); j++)
{
ase_printf (ASE_T(" -%-20s -no%-20s\n"), otab[j].name, otab[j].name);
}
}
int awk_main (int argc, ase_char_t* argv[])
{
TestAwk awk;
int mode = 0;
const ase_char_t* mainfn = NULL;
const ase_char_t* srcin = ASE_T("");
const ase_char_t* srcout = NULL;
const ase_char_t* args[256];
ase_size_t nargs = 0;
ase_size_t nsrcins = 0;
ase_size_t nsrcouts = 0;
if (awk.open() == -1) if (awk.open() == -1)
{ {
ase_fprintf (stderr, ASE_T("cannot open awk\n")); ase_fprintf (stderr, ASE_T("cannot open awk\n"));

View File

@ -1,5 +1,5 @@
/* /*
* $Id: awk.c,v 1.17 2007/09/30 15:12:20 bacon Exp $ * $Id: awk.c,v 1.19 2007/10/11 14:39:46 bacon Exp $
*/ */
#include <ase/awk/awk.h> #include <ase/awk/awk.h>
@ -789,9 +789,42 @@ static void on_run_end (ase_awk_run_t* run, int errnum, void* custom_data)
app_run = NULL; app_run = NULL;
} }
static struct
{
const ase_char_t* name;
int opt;
} otab[] =
{
{ ASE_T("implicit"), ASE_AWK_IMPLICIT },
{ ASE_T("explicit"), ASE_AWK_EXPLICIT },
{ ASE_T("uniquefn"), ASE_AWK_UNIQUEFN },
{ ASE_T("shading"), ASE_AWK_SHADING },
{ ASE_T("shift"), ASE_AWK_SHIFT },
{ ASE_T("idiv"), ASE_AWK_IDIV },
{ ASE_T("strconcat"), ASE_AWK_STRCONCAT },
{ ASE_T("extio"), ASE_AWK_EXTIO },
{ ASE_T("blockless"), ASE_AWK_BLOCKLESS },
{ ASE_T("baseone"), ASE_AWK_BASEONE },
{ ASE_T("stripspaces"), ASE_AWK_STRIPSPACES },
{ ASE_T("nextofile"), ASE_AWK_NEXTOFILE },
{ ASE_T("crfl"), ASE_AWK_CRLF },
{ ASE_T("argstomain"), ASE_AWK_ARGSTOMAIN },
{ ASE_T("reset"), ASE_AWK_RESET },
{ ASE_T("maptovar"), ASE_AWK_MAPTOVAR },
{ ASE_T("pablock"), ASE_AWK_PABLOCK }
};
static void print_usage (const ase_char_t* argv0) static void print_usage (const ase_char_t* argv0)
{ {
ase_printf (ASE_T("Usage: %s [-m] [-d] [-ns] [-a argument]* -f source-file [data-file]*\n"), argv0); int j;
ase_printf (ASE_T("Usage: %s [-m] [-d] [-a argument]* -f source-file [data-file]*\n"), argv0);
ase_printf (ASE_T("\nYou may specify the following options to change the behavior of the interpreter.\n"));
for (j = 0; j < ASE_COUNTOF(otab); j++)
{
ase_printf (ASE_T(" -%-20s -no%-20s\n"), otab[j].name, otab[j].name);
}
} }
static int run_awk (ase_awk_t* awk, static int run_awk (ase_awk_t* awk,
@ -900,21 +933,12 @@ static int awk_main (int argc, ase_char_t* argv[])
int deparse = 0; int deparse = 0;
opt = ASE_AWK_IMPLICIT | opt = ASE_AWK_IMPLICIT |
/*ASE_AWK_EXPLICIT |*/
ASE_AWK_UNIQUEFN | ASE_AWK_UNIQUEFN |
ASE_AWK_SHADING | ASE_AWK_SHADING |
/*ASE_AWK_SHIFT |*/
/*ASE_AWK_IDIV |*/
/*ASE_AWK_STRCONCAT |*/
ASE_AWK_EXTIO | ASE_AWK_EXTIO |
ASE_AWK_BLOCKLESS | ASE_AWK_BLOCKLESS |
ASE_AWK_BASEONE /*|*/ ASE_AWK_BASEONE |
/*ASE_AWK_STRIPSPACES |*/ ASE_AWK_PABLOCK;
/*ASE_AWK_NEXTOFILE |*/
/*ASE_AWK_CRLF |*/
/*ASE_AWK_ARGSTOMAIN |*/
/*ASE_AWK_RESET*/
/*ASE_AWK_MAPTOVAR*/;
if (argc <= 1) if (argc <= 1)
{ {
@ -944,15 +968,39 @@ static int awk_main (int argc, ase_char_t* argv[])
/* specify arguments */ /* specify arguments */
mode = 2; mode = 2;
} }
else if (ase_strcmp(argv[i], ASE_T("-ns")) == 0)
{
/* no space stripping */
opt &= ~ASE_AWK_STRIPSPACES;
}
else if (argv[i][0] == ASE_T('-')) else if (argv[i][0] == ASE_T('-'))
{ {
int j;
if (argv[i][1] == ASE_T('n') && argv[i][2] == ASE_T('o'))
{
for (j = 0; j < ASE_COUNTOF(otab); j++)
{
if (ase_strcmp(&argv[i][3], otab[j].name) == 0)
{
opt &= ~otab[j].opt;
goto ok_valid;
}
}
}
else
{
for (j = 0; j < ASE_COUNTOF(otab); j++)
{
if (ase_strcmp(&argv[i][1], otab[j].name) == 0)
{
opt |= otab[j].opt;
goto ok_valid;
}
}
}
print_usage (argv[0]); print_usage (argv[0]);
return -1; return -1;
ok_valid:
;
} }
else if (file_count < ASE_COUNTOF(infiles)-1) else if (file_count < ASE_COUNTOF(infiles)-1)
{ {

View File

@ -1,8 +1,6 @@
global abc;
BEGIN { BEGIN {
abc[20] = "abc"; abc[20] = "abc";
abc = 10; abc = 10;
} }
RUN ERROR: CODE [96] LINE [5] map 'abc' not assignable with a scalar RUN ERROR: CODE [97] LINE [3] map 'abc' not assignable with a scalar

View File

@ -2,4 +2,4 @@ BEGIN {
delete ARGC; delete ARGC;
} }
RUN ERROR: CODE [88] LINE [2] variable 'ARGC' not deletable RUN ERROR: CODE [89]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xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxhel...' not found

View File

@ -1 +1 @@
PARSE ERROR: CODE [56] LINE [2] intrinsic function 'substr' redefined PARSE ERROR: CODE [57] LINE [2] intrinsic function 'substr' redefined

View File

@ -1 +1 @@
PARSE ERROR: CODE [56] LINE [3] intrinsic function 'substr' redefined PARSE ERROR: CODE [57] LINE [3] intrinsic function 'substr' redefined

View File

@ -1 +1 @@
PARSE ERROR: CODE [57] LINE [9] function 'abc' redefined PARSE ERROR: CODE [58] LINE [9] function 'abc' redefined

View File

@ -1 +1 @@
PARSE ERROR: CODE [58] LINE [4] global variable 'abc' redefined PARSE ERROR: CODE [59] LINE [4] global variable 'abc' redefined

View File

@ -1 +1 @@
PARSE ERROR: CODE [59] LINE [4] parameter 'x' redefined PARSE ERROR: CODE [60] LINE [4] parameter 'x' redefined

View File

@ -1 +1 @@
PARSE ERROR: CODE [57] LINE [11] function 'abc' redefined PARSE ERROR: CODE [58] LINE [11] function 'abc' redefined

View File

@ -1 +1 @@
PARSE ERROR: CODE [57] LINE [1] function 'abc' redefined PARSE ERROR: CODE [58] LINE [1] function 'abc' redefined

View File

@ -1 +1 @@
PARSE ERROR: CODE [52] LINE [2] BEGIN not followed by a left bracket on the same line PARSE ERROR: CODE [53] LINE [2] BEGIN not followed by a left bracket on the same line

View File

@ -1 +1 @@
PARSE ERROR: CODE [63] LINE [1] '+' not a valid parameter name PARSE ERROR: CODE [64] LINE [1] '+' not a valid parameter name

View File

@ -1 +1 @@
PARSE ERROR: CODE [64] LINE [1] '+' not a valid variable name PARSE ERROR: CODE [65] LINE [1] '+' not a valid variable name

View File

@ -1 +1 @@
PARSE ERROR: CODE [64] LINE [3] '+' not a valid variable name PARSE ERROR: CODE [65] LINE [3] '+' not a valid variable name

View File

@ -2,4 +2,4 @@ BEGIN {
print abc > "123\0abc"; print abc > "123\0abc";
} }
RUN ERROR: CODE [112] LINE [2] i/o name containing a null character RUN ERROR: CODE [113] LINE [2] i/o name containing a null character

View File

@ -3,4 +3,4 @@ BEGIN {
split ("a b c",xx); split ("a b c",xx);
} }
RUN ERROR: CODE [97] LINE [3] cannot change a scalar value to a map RUN ERROR: CODE [98] LINE [3] cannot change a scalar value to a map

View File

@ -1 +1 @@
PARSE ERROR: CODE [61] LINE [1] duplicate global variable 'ARGV' PARSE ERROR: CODE [62] LINE [1] duplicate global variable 'ARGV'

View File

@ -1,12 +1,14 @@
#!/bin/sh #!/bin/sh
OPTION=-explicit
run_script_for_init() run_script_for_init()
{ {
script="$1" script="$1"
data="$2" data="$2"
output=`echo $script | sed 's/\.awk$/.out/g'` output=`echo $script | sed 's/\.awk$/.out/g'`
"$ASEAWK" -d -f "$script" "$data" > "$output" "$ASEAWK" $OPTION -d -f "$script" "$data" > "$output"
} }
run_init() run_init()
@ -39,7 +41,7 @@ run_script_for_test()
output=`echo $script | sed 's/\.awk$/.out/g'` output=`echo $script | sed 's/\.awk$/.out/g'`
echo ">> RUNNING $script" echo ">> RUNNING $script"
"$ASEAWK" -d -f "$script" "$data" > "$output.$pid" "$ASEAWK" $OPTION -d -f "$script" "$data" > "$output.$pid"
#diff -y "$output" "$output.$pid" #diff -y "$output" "$output.$pid"
diff "$output" "$output.$pid" diff "$output" "$output.$pid"