Recovered from cvs revision 2007-10-28 06:12:00
This commit is contained in:
parent
d60e97954b
commit
1fb4e03c11
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: extio.c,v 1.6 2007/10/25 14:43:17 bacon Exp $
|
* $Id: extio.c,v 1.7 2007/10/26 12:49:24 bacon Exp $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -74,8 +74,6 @@ static int out_mask_map[] =
|
|||||||
MASK_WRITE
|
MASK_WRITE
|
||||||
};
|
};
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
#include <tchar.h>
|
|
||||||
int ase_awk_readextio (
|
int ase_awk_readextio (
|
||||||
ase_awk_run_t* run, int in_type,
|
ase_awk_run_t* run, int in_type,
|
||||||
const ase_char_t* name, ase_str_t* buf)
|
const ase_char_t* name, ase_str_t* buf)
|
||||||
@ -394,8 +392,8 @@ int ase_awk_readextio (
|
|||||||
rs->type != ASE_AWK_VAL_STR) ASE_AWK_FREE (run->awk, rs_ptr);
|
rs->type != ASE_AWK_VAL_STR) ASE_AWK_FREE (run->awk, rs_ptr);
|
||||||
ase_awk_refdownval (run, rs);
|
ase_awk_refdownval (run, rs);
|
||||||
|
|
||||||
/* increment NR */
|
/* increment NR for console input */
|
||||||
if (ret != -1 && ret != 0)
|
if (extio_type == ASE_AWK_EXTIO_CONSOLE && ret != -1 && ret != 0)
|
||||||
{
|
{
|
||||||
ase_awk_val_t* nr;
|
ase_awk_val_t* nr;
|
||||||
ase_long_t lv;
|
ase_long_t lv;
|
||||||
@ -411,14 +409,6 @@ int ase_awk_readextio (
|
|||||||
{
|
{
|
||||||
if (n == 1) lv = (ase_long_t)rv;
|
if (n == 1) lv = (ase_long_t)rv;
|
||||||
|
|
||||||
|
|
||||||
// TODO---> WRONG: NR SHOULD BE UPDATED FOR CONSOLE INPUT...
|
|
||||||
// { print "NR=" NR; a=getline<"awk.c"; print a; }
|
|
||||||
{
|
|
||||||
wchar_t x[100];
|
|
||||||
_sntprintf (x, 100, _T("ddd %d\n"), (int)lv);
|
|
||||||
OutputDebugStringW (x);
|
|
||||||
}
|
|
||||||
nr = ase_awk_makeintval (run, lv + 1);
|
nr = ase_awk_makeintval (run, lv + 1);
|
||||||
if (nr == ASE_NULL) ret = -1;
|
if (nr == ASE_NULL) ret = -1;
|
||||||
else
|
else
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: parse.c,v 1.23 2007/10/25 14:43:17 bacon Exp $
|
* $Id: parse.c,v 1.24 2007/10/26 12:49:24 bacon Exp $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -298,11 +298,13 @@ static global_t gtab[] =
|
|||||||
/* ignore case in string comparison */
|
/* ignore case in string comparison */
|
||||||
{ ASE_T("IGNORECASE"), 10, 0 },
|
{ ASE_T("IGNORECASE"), 10, 0 },
|
||||||
|
|
||||||
/* number of fields in current input record */
|
/* number of fields in current input record
|
||||||
|
* NF is also updated if you assign a value to $0. so it is not
|
||||||
|
* associated with ASE_AWK_PABLOCK */
|
||||||
{ ASE_T("NF"), 2, 0 },
|
{ ASE_T("NF"), 2, 0 },
|
||||||
|
|
||||||
/* input record number */
|
/* input record number */
|
||||||
{ ASE_T("NR"), 2, 0 },
|
{ ASE_T("NR"), 2, ASE_AWK_PABLOCK },
|
||||||
|
|
||||||
/* current output file name */
|
/* current output file name */
|
||||||
{ ASE_T("OFILENAME"), 9, ASE_AWK_PABLOCK | ASE_AWK_NEXTOFILE },
|
{ ASE_T("OFILENAME"), 9, ASE_AWK_PABLOCK | ASE_AWK_NEXTOFILE },
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: Awk.hpp,v 1.40 2007/10/21 07:59:35 bacon Exp $
|
* $Id: Awk.hpp,v 1.41 2007/10/26 12:49:24 bacon Exp $
|
||||||
*
|
*
|
||||||
* {License}
|
* {License}
|
||||||
*/
|
*/
|
||||||
@ -442,6 +442,27 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
enum class GLOBAL: int
|
||||||
|
{
|
||||||
|
ARGC = ASE::Awk::GBL_ARGC,
|
||||||
|
ARGV = ASE::Awk::GBL_ARGV,
|
||||||
|
CONVFMT = ASE::Awk::GBL_CONVFMT,
|
||||||
|
FILENAME = ASE::Awk::GBL_FILENAME,
|
||||||
|
FNR = ASE::Awk::GBL_FNR,
|
||||||
|
FS = ASE::Awk::GBL_FS,
|
||||||
|
IGNORECASE = ASE::Awk::GBL_IGNORECASE,
|
||||||
|
NF = ASE::Awk::GBL_NF,
|
||||||
|
NR = ASE::Awk::GBL_NR,
|
||||||
|
OFILENAME = ASE::Awk::GBL_OFILENAME,
|
||||||
|
OFMT = ASE::Awk::GBL_OFMT,
|
||||||
|
OFS = ASE::Awk::GBL_OFS,
|
||||||
|
ORS = ASE::Awk::GBL_ORS,
|
||||||
|
RLENGTH = ASE::Awk::GBL_RLENGTH,
|
||||||
|
RS = ASE::Awk::GBL_RS,
|
||||||
|
RSTART = ASE::Awk::GBL_RSTART,
|
||||||
|
SUBSEP = ASE::Awk::GBL_SUBSEP
|
||||||
|
};
|
||||||
|
|
||||||
property Awk^ Owner
|
property Awk^ Owner
|
||||||
{
|
{
|
||||||
Awk^ get () { return this->owner; }
|
Awk^ get () { return this->owner; }
|
||||||
@ -482,70 +503,70 @@ public:
|
|||||||
(ASE::Awk::ErrorCode)num, line, p);
|
(ASE::Awk::ErrorCode)num, line, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SetGlobal (int id, System::String^ v)
|
bool SetGlobal (GLOBAL id, System::String^ v)
|
||||||
{
|
{
|
||||||
cli::pin_ptr<const char_t> nptr = PtrToStringChars(v);
|
cli::pin_ptr<const char_t> nptr = PtrToStringChars(v);
|
||||||
return run.setGlobal (id, nptr, v->Length) == 0;
|
return run.setGlobal ((ASE::Awk::Global)id, nptr, v->Length) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SetGlobal (int id, long_t v)
|
bool SetGlobal (GLOBAL id, long_t v)
|
||||||
{
|
{
|
||||||
return run.setGlobal (id, v) == 0;
|
return run.setGlobal ((ASE::Awk::Global)id, v) == 0;
|
||||||
}
|
}
|
||||||
bool SetGlobal (int id, System::SByte^ v)
|
bool SetGlobal (GLOBAL id, System::SByte^ v)
|
||||||
{
|
{
|
||||||
return run.setGlobal (id, (long_t)(__int8)v) == 0;
|
return run.setGlobal ((ASE::Awk::Global)id, (long_t)(__int8)v) == 0;
|
||||||
}
|
}
|
||||||
bool SetGlobal (int id, System::Int16^ v)
|
bool SetGlobal (GLOBAL id, System::Int16^ v)
|
||||||
{
|
{
|
||||||
return run.setGlobal (id, (long_t)(__int16)v) == 0;
|
return run.setGlobal ((ASE::Awk::Global)id, (long_t)(__int16)v) == 0;
|
||||||
}
|
}
|
||||||
bool SetGlobal (int id, System::Int32^ v)
|
bool SetGlobal (GLOBAL id, System::Int32^ v)
|
||||||
{
|
{
|
||||||
return run.setGlobal (id, (long_t)(__int32)v) == 0;
|
return run.setGlobal ((ASE::Awk::Global)id, (long_t)(__int32)v) == 0;
|
||||||
}
|
}
|
||||||
bool SetGlobal (int id, System::Int64^ v)
|
bool SetGlobal (GLOBAL id, System::Int64^ v)
|
||||||
{
|
{
|
||||||
return run.setGlobal (id, (long_t)(__int64)v) == 0;
|
return run.setGlobal ((ASE::Awk::Global)id, (long_t)(__int64)v) == 0;
|
||||||
}
|
}
|
||||||
bool SetGlobal (int id, System::Byte^ v)
|
bool SetGlobal (GLOBAL id, System::Byte^ v)
|
||||||
{
|
{
|
||||||
return run.setGlobal (id, (long_t)(unsigned __int8)v) == 0;
|
return run.setGlobal ((ASE::Awk::Global)id, (long_t)(unsigned __int8)v) == 0;
|
||||||
}
|
}
|
||||||
bool SetGlobal (int id, System::UInt16^ v)
|
bool SetGlobal (GLOBAL id, System::UInt16^ v)
|
||||||
{
|
{
|
||||||
return run.setGlobal (id, (long_t)(unsigned __int16)v) == 0;
|
return run.setGlobal ((ASE::Awk::Global)id, (long_t)(unsigned __int16)v) == 0;
|
||||||
}
|
}
|
||||||
bool SetGlobal (int id, System::UInt32^ v)
|
bool SetGlobal (GLOBAL id, System::UInt32^ v)
|
||||||
{
|
{
|
||||||
return run.setGlobal (id, (long_t)(unsigned __int32)v) == 0;
|
return run.setGlobal ((ASE::Awk::Global)id, (long_t)(unsigned __int32)v) == 0;
|
||||||
}
|
}
|
||||||
bool SetGlobal (int id, System::UInt64^ v)
|
bool SetGlobal (GLOBAL id, System::UInt64^ v)
|
||||||
{
|
{
|
||||||
return run.setGlobal (id, (long_t)(unsigned __int64)v) == 0;
|
return run.setGlobal ((ASE::Awk::Global)id, (long_t)(unsigned __int64)v) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SetGlobal (int id, real_t v)
|
bool SetGlobal (GLOBAL id, real_t v)
|
||||||
{
|
{
|
||||||
return run.setGlobal (id, v) == 0;
|
return run.setGlobal ((ASE::Awk::Global)id, v) == 0;
|
||||||
}
|
}
|
||||||
bool SetGlobal (int id, System::Single^ v)
|
bool SetGlobal (GLOBAL id, System::Single^ v)
|
||||||
{
|
{
|
||||||
return run.setGlobal (id, (real_t)(float)v) == 0;
|
return run.setGlobal ((ASE::Awk::Global)id, (real_t)(float)v) == 0;
|
||||||
}
|
}
|
||||||
bool SetGlobal (int id, System::Double^ v)
|
bool SetGlobal (GLOBAL id, System::Double^ v)
|
||||||
{
|
{
|
||||||
return run.setGlobal (id, (real_t)(double)v) == 0;
|
return run.setGlobal ((ASE::Awk::Global)id, (real_t)(double)v) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SetGlobal (int id, Return^ v)
|
bool SetGlobal (GLOBAL id, Return^ v)
|
||||||
{
|
{
|
||||||
return run.setGlobal (id, v->ret) == 0;
|
return run.setGlobal ((ASE::Awk::Global)id, v->ret) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetGlobal (int id, [System::Runtime::InteropServices::Out] Argument^% v)
|
bool GetGlobal (GLOBAL id, [System::Runtime::InteropServices::Out] Argument^% v)
|
||||||
{
|
{
|
||||||
return run.getGlobal (id, *v->arg) == 0;
|
return run.getGlobal ((ASE::Awk::Global)id, *v->arg) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public protected:
|
public protected:
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: awk.c,v 1.19 2007/10/11 14:39:46 bacon Exp $
|
* $Id: awk.c,v 1.20 2007/10/26 12:49:24 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ase/awk/awk.h>
|
#include <ase/awk/awk.h>
|
||||||
@ -554,6 +554,14 @@ static ase_ssize_t awk_extio_console (
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ase_awk_setglobal (
|
||||||
|
epa->run, ASE_AWK_GLOBAL_NR, ase_awk_val_zero) == -1)
|
||||||
|
{
|
||||||
|
/* need to reset NR */
|
||||||
|
fclose (fp);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (epa->handle != ASE_NULL &&
|
if (epa->handle != ASE_NULL &&
|
||||||
epa->handle != stdin &&
|
epa->handle != stdin &&
|
||||||
epa->handle != stdout &&
|
epa->handle != stdout &&
|
||||||
|
Loading…
Reference in New Issue
Block a user