Recovered from cvs revision 2007-05-25 03:08:00

This commit is contained in:
2007-05-26 01:30:00 +00:00
parent d58553120e
commit 5c480566dc
6 changed files with 258 additions and 11 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: Awk.cpp,v 1.18 2007/05/23 14:15:16 bacon Exp $
* $Id: Awk.cpp,v 1.20 2007/05/24 04:17:42 bacon Exp $
*/
#include <ase/awk/StdAwk.hpp>
@ -73,10 +73,10 @@ public:
{
#ifdef _WIN32
::Sleep (args[0].toInt() * 1000);
return ret->set (0);
#else
::sleep (args[0].toInt());
return ret->set ((long_t)::sleep (args[0].toInt()));
#endif
return 0;
}
int addConsoleInput (const char_t* file)
@ -464,7 +464,22 @@ static void print_error (const ase_char_t* msg)
static void print_usage (const ase_char_t* argv0)
{
ase_printf (ASE_T("Usage: %s [-m main-function] [-si source-in-file] [-so source-out-file] [-ci console-in-file]* [-co console-out-file]* [-a argument]*\n"), argv0);
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;
ase_printf (ASE_T("Usage: %s [-m main] [-si file]? [-so file]? [-ci file]* [-co file]* [-a arg]*\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"));
}
int awk_main (int argc, ase_char_t* argv[])

View File

@ -1,5 +1,5 @@
/*
* $Id: awk.c,v 1.8 2007/05/16 09:15:14 bacon Exp $
* $Id: awk.c,v 1.9 2007/05/24 04:04:44 bacon Exp $
*/
#include <ase/awk/awk.h>
@ -846,6 +846,43 @@ static unsigned int __stdcall run_awk_thr (void* arg)
}
#endif
static int bfn_sleep (
ase_awk_run_t* run, const ase_char_t* fnm, ase_size_t fnl)
{
ase_size_t nargs;
ase_awk_val_t* a0;
ase_long_t lv;
ase_real_t rv;
ase_awk_val_t* r;
int n;
nargs = ase_awk_getnargs (run);
ASE_ASSERT (nargs == 1);
a0 = ase_awk_getarg (run, 0);
n = ase_awk_valtonum (run, a0, &lv, &rv);
if (n == -1) return -1;
if (n == 1) lv = (ase_long_t)rv;
#ifdef _WIN32
Sleep (lv * 1000);
n = 0;
#else
n = sleep (lv);
#endif
r = ase_awk_makeintval (run, n);
if (r == ASE_NULL)
{
ase_awk_setrunerrnum (run, ASE_AWK_ENOMEM);
return -1;
}
ase_awk_setretval (run, r);
return 0;
}
static int awk_main (int argc, ase_char_t* argv[])
{
ase_awk_t* awk;
@ -1016,6 +1053,17 @@ static int awk_main (int argc, ase_char_t* argv[])
app_awk = awk;
if (ase_awk_addbfn (awk,
ASE_T("sleep"), 5, 0,
1, 1, ASE_NULL, bfn_sleep) == ASE_NULL)
{
ase_awk_close (awk);
#ifdef _WIN32
HeapDestroy (mmgr_data.heap);
#endif
return -1;
}
ase_awk_setoption (awk, opt);
/*
@ -1040,6 +1088,9 @@ static int awk_main (int argc, ase_char_t* argv[])
(unsigned int)ase_awk_geterrlin(awk),
ase_awk_geterrmsg(awk));
ase_awk_close (awk);
#ifdef _WIN32
HeapDestroy (mmgr_data.heap);
#endif
return -1;
}
@ -1078,6 +1129,9 @@ static int awk_main (int argc, ase_char_t* argv[])
if (run_awk (awk, mfn, runarg) == -1)
{
ase_awk_close (awk);
#ifdef _WIN32
HeapDestroy (mmgr_data.heap);
#endif
return -1;
}
#endif

View File

@ -9,6 +9,8 @@ BEGIN {
END {
for (c in pop)
printf ("%15s %6d\n",c,pop[c]) | "sort -t' ' +1rn";
close ("sort -t' ' +1rn");
sleep (1);
}
Asia 2173
North America 340