Recovered from cvs revision 2007-05-24 03:37:00
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: Awk.cpp,v 1.17 2007/05/19 16:45:27 bacon Exp $
|
||||
* $Id: Awk.cpp,v 1.18 2007/05/23 14:15:16 bacon Exp $
|
||||
*/
|
||||
|
||||
#include <ase/awk/StdAwk.hpp>
|
||||
@ -12,6 +12,8 @@
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
class TestAwk: public ASE::StdAwk
|
||||
@ -34,11 +36,24 @@ public:
|
||||
{
|
||||
#ifdef _WIN32
|
||||
ASE_ASSERT (heap == ASE_NULL);
|
||||
heap = HeapCreate (0, 1000000, 1000000);
|
||||
heap = ::HeapCreate (0, 1000000, 1000000);
|
||||
if (heap == ASE_NULL) return -1;
|
||||
#endif
|
||||
|
||||
return StdAwk::open ();
|
||||
int n = StdAwk::open ();
|
||||
|
||||
if (addFunction (ASE_T("sleep"), 1, 1,
|
||||
(FunctionHandler)&TestAwk::sleep) == -1)
|
||||
{
|
||||
StdAwk::close ();
|
||||
#ifdef _WIN32
|
||||
HeapDestroy (heap);
|
||||
heap = ASE_NULL;
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
void close ()
|
||||
@ -54,6 +69,16 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
int sleep (Return* ret, const Argument* args, size_t nargs)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
::Sleep (args[0].toInt() * 1000);
|
||||
#else
|
||||
::sleep (args[0].toInt());
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int addConsoleInput (const char_t* file)
|
||||
{
|
||||
if (numConInFiles < ASE_COUNTOF(conInFile))
|
||||
|
@ -1,5 +1,13 @@
|
||||
BEGIN { FS = "\t"; }
|
||||
{ pop[$4] += $3; }
|
||||
END { for (c in pop)
|
||||
END {
|
||||
for (c in pop)
|
||||
printf ("%15s\t%6d\n", c, pop[c]) | "sort -t'\t' +1rn";
|
||||
}
|
||||
|
||||
# the following two statements make the program behave
|
||||
# consistently across different platforms.
|
||||
# on some platforms, the sort command output has
|
||||
# been delayed until the program exits.
|
||||
close ("sort -t'\t' +1rn");
|
||||
sleep (1);
|
||||
}
|
||||
|
Reference in New Issue
Block a user