Recovered from cvs revision 2007-10-10 13:22:00

This commit is contained in:
hyung-hwan 2007-10-10 22:33:00 +00:00
parent c79702df8e
commit 3cfcc8b0c9
13 changed files with 2261 additions and 2114 deletions

View File

@ -19,15 +19,15 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aseawk_jni", "awk\aseawk_jn
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "asecom", "com\asecom.vcproj", "{963AF7B5-12E6-42B6-8CBE-89136C1A109B}"
ProjectSection(ProjectDependencies) = postProject
{5F2E77D5-1485-48D1-9371-987BC55FEE83} = {5F2E77D5-1485-48D1-9371-987BC55FEE83}
{C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD} = {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}
{17621C83-40C9-4305-BAF9-132E250B5FE3} = {17621C83-40C9-4305-BAF9-132E250B5FE3}
{C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD} = {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}
{5F2E77D5-1485-48D1-9371-987BC55FEE83} = {5F2E77D5-1485-48D1-9371-987BC55FEE83}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aseawk", "test\awk\aseawk.vcproj", "{57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F}"
ProjectSection(ProjectDependencies) = postProject
{5F2E77D5-1485-48D1-9371-987BC55FEE83} = {5F2E77D5-1485-48D1-9371-987BC55FEE83}
{C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD} = {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}
{5F2E77D5-1485-48D1-9371-987BC55FEE83} = {5F2E77D5-1485-48D1-9371-987BC55FEE83}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aselsp", "lsp\aselsp.vcproj", "{42FE7CED-34B7-45C8-92C9-8856E16640D2}"
@ -37,8 +37,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aselsp", "lsp\aselsp.vcproj
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aselsp", "test\lsp\aselsp.vcproj", "{868702B0-CB6B-4F1D-B98A-32193347EFAF}"
ProjectSection(ProjectDependencies) = postProject
{42FE7CED-34B7-45C8-92C9-8856E16640D2} = {42FE7CED-34B7-45C8-92C9-8856E16640D2}
{C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD} = {C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}
{42FE7CED-34B7-45C8-92C9-8856E16640D2} = {42FE7CED-34B7-45C8-92C9-8856E16640D2}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aseawk++", "awk\aseawk++.vcproj", "{E7A8B741-4E9D-4ED4-9F77-E7F637A678A5}"
@ -48,8 +48,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aseawk++", "awk\aseawk++.vc
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "aseawk++", "test\awk\aseawk++.vcproj", "{3BEA6CFE-C158-4BFB-B5FB-ED85251E3F98}"
ProjectSection(ProjectDependencies) = postProject
{57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F} = {57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F}
{E7A8B741-4E9D-4ED4-9F77-E7F637A678A5} = {E7A8B741-4E9D-4ED4-9F77-E7F637A678A5}
{57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F} = {57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "asenet", "net\asenet.vcproj", "{A63E9DF9-1D47-4D81-834C-1D40406C18C4}"
@ -85,6 +85,7 @@ Global
{17621C83-40C9-4305-BAF9-132E250B5FE3}.Debug MD|Win32.ActiveCfg = Debug MD|Win32
{17621C83-40C9-4305-BAF9-132E250B5FE3}.Debug MD|Win32.Build.0 = Debug MD|Win32
{17621C83-40C9-4305-BAF9-132E250B5FE3}.Debug|Any CPU.ActiveCfg = Debug|Win32
{17621C83-40C9-4305-BAF9-132E250B5FE3}.Debug|Any CPU.Build.0 = Debug|Win32
{17621C83-40C9-4305-BAF9-132E250B5FE3}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{17621C83-40C9-4305-BAF9-132E250B5FE3}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{17621C83-40C9-4305-BAF9-132E250B5FE3}.Debug|Win32.ActiveCfg = Debug|Win32
@ -100,6 +101,7 @@ Global
{C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}.Debug MD|Win32.ActiveCfg = Debug MD|Win32
{C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}.Debug MD|Win32.Build.0 = Debug MD|Win32
{C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}.Debug|Any CPU.ActiveCfg = Debug|Win32
{C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}.Debug|Any CPU.Build.0 = Debug|Win32
{C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{C3EBBFAE-9D08-4FA2-8B0E-D09BEBF84EDD}.Debug|Win32.ActiveCfg = Debug|Win32
@ -115,6 +117,7 @@ Global
{5F2E77D5-1485-48D1-9371-987BC55FEE83}.Debug MD|Win32.ActiveCfg = Debug MD|Win32
{5F2E77D5-1485-48D1-9371-987BC55FEE83}.Debug MD|Win32.Build.0 = Debug MD|Win32
{5F2E77D5-1485-48D1-9371-987BC55FEE83}.Debug|Any CPU.ActiveCfg = Debug|Win32
{5F2E77D5-1485-48D1-9371-987BC55FEE83}.Debug|Any CPU.Build.0 = Debug|Win32
{5F2E77D5-1485-48D1-9371-987BC55FEE83}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{5F2E77D5-1485-48D1-9371-987BC55FEE83}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{5F2E77D5-1485-48D1-9371-987BC55FEE83}.Debug|Win32.ActiveCfg = Debug|Win32
@ -130,6 +133,7 @@ Global
{23B58791-FD44-4F95-9F77-34E4AF45A296}.Debug MD|Win32.ActiveCfg = Debug MD|Win32
{23B58791-FD44-4F95-9F77-34E4AF45A296}.Debug MD|Win32.Build.0 = Debug MD|Win32
{23B58791-FD44-4F95-9F77-34E4AF45A296}.Debug|Any CPU.ActiveCfg = Debug|Win32
{23B58791-FD44-4F95-9F77-34E4AF45A296}.Debug|Any CPU.Build.0 = Debug|Win32
{23B58791-FD44-4F95-9F77-34E4AF45A296}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{23B58791-FD44-4F95-9F77-34E4AF45A296}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{23B58791-FD44-4F95-9F77-34E4AF45A296}.Debug|Win32.ActiveCfg = Debug|Win32
@ -145,6 +149,7 @@ Global
{963AF7B5-12E6-42B6-8CBE-89136C1A109B}.Debug MD|Win32.ActiveCfg = Debug MD|Win32
{963AF7B5-12E6-42B6-8CBE-89136C1A109B}.Debug MD|Win32.Build.0 = Debug MD|Win32
{963AF7B5-12E6-42B6-8CBE-89136C1A109B}.Debug|Any CPU.ActiveCfg = Debug|Win32
{963AF7B5-12E6-42B6-8CBE-89136C1A109B}.Debug|Any CPU.Build.0 = Debug|Win32
{963AF7B5-12E6-42B6-8CBE-89136C1A109B}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{963AF7B5-12E6-42B6-8CBE-89136C1A109B}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{963AF7B5-12E6-42B6-8CBE-89136C1A109B}.Debug|Win32.ActiveCfg = Debug|Win32
@ -160,6 +165,7 @@ Global
{57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F}.Debug MD|Win32.ActiveCfg = Debug MD|Win32
{57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F}.Debug MD|Win32.Build.0 = Debug MD|Win32
{57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F}.Debug|Any CPU.ActiveCfg = Debug|Win32
{57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F}.Debug|Any CPU.Build.0 = Debug|Win32
{57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{57F1E1D0-28B6-42BF-BAFB-045AEE2DCF4F}.Debug|Win32.ActiveCfg = Debug|Win32
@ -175,6 +181,7 @@ Global
{42FE7CED-34B7-45C8-92C9-8856E16640D2}.Debug MD|Win32.ActiveCfg = Debug MD|Win32
{42FE7CED-34B7-45C8-92C9-8856E16640D2}.Debug MD|Win32.Build.0 = Debug MD|Win32
{42FE7CED-34B7-45C8-92C9-8856E16640D2}.Debug|Any CPU.ActiveCfg = Debug|Win32
{42FE7CED-34B7-45C8-92C9-8856E16640D2}.Debug|Any CPU.Build.0 = Debug|Win32
{42FE7CED-34B7-45C8-92C9-8856E16640D2}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{42FE7CED-34B7-45C8-92C9-8856E16640D2}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{42FE7CED-34B7-45C8-92C9-8856E16640D2}.Debug|Win32.ActiveCfg = Debug|Win32
@ -190,6 +197,7 @@ Global
{868702B0-CB6B-4F1D-B98A-32193347EFAF}.Debug MD|Win32.ActiveCfg = Debug MD|Win32
{868702B0-CB6B-4F1D-B98A-32193347EFAF}.Debug MD|Win32.Build.0 = Debug MD|Win32
{868702B0-CB6B-4F1D-B98A-32193347EFAF}.Debug|Any CPU.ActiveCfg = Debug|Win32
{868702B0-CB6B-4F1D-B98A-32193347EFAF}.Debug|Any CPU.Build.0 = Debug|Win32
{868702B0-CB6B-4F1D-B98A-32193347EFAF}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{868702B0-CB6B-4F1D-B98A-32193347EFAF}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{868702B0-CB6B-4F1D-B98A-32193347EFAF}.Debug|Win32.ActiveCfg = Debug|Win32
@ -205,6 +213,7 @@ Global
{E7A8B741-4E9D-4ED4-9F77-E7F637A678A5}.Debug MD|Win32.ActiveCfg = Debug MD|Win32
{E7A8B741-4E9D-4ED4-9F77-E7F637A678A5}.Debug MD|Win32.Build.0 = Debug MD|Win32
{E7A8B741-4E9D-4ED4-9F77-E7F637A678A5}.Debug|Any CPU.ActiveCfg = Debug|Win32
{E7A8B741-4E9D-4ED4-9F77-E7F637A678A5}.Debug|Any CPU.Build.0 = Debug|Win32
{E7A8B741-4E9D-4ED4-9F77-E7F637A678A5}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{E7A8B741-4E9D-4ED4-9F77-E7F637A678A5}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{E7A8B741-4E9D-4ED4-9F77-E7F637A678A5}.Debug|Win32.ActiveCfg = Debug|Win32
@ -220,6 +229,7 @@ Global
{3BEA6CFE-C158-4BFB-B5FB-ED85251E3F98}.Debug MD|Win32.ActiveCfg = Debug MD|Win32
{3BEA6CFE-C158-4BFB-B5FB-ED85251E3F98}.Debug MD|Win32.Build.0 = Debug MD|Win32
{3BEA6CFE-C158-4BFB-B5FB-ED85251E3F98}.Debug|Any CPU.ActiveCfg = Debug|Win32
{3BEA6CFE-C158-4BFB-B5FB-ED85251E3F98}.Debug|Any CPU.Build.0 = Debug|Win32
{3BEA6CFE-C158-4BFB-B5FB-ED85251E3F98}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{3BEA6CFE-C158-4BFB-B5FB-ED85251E3F98}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{3BEA6CFE-C158-4BFB-B5FB-ED85251E3F98}.Debug|Win32.ActiveCfg = Debug|Win32
@ -235,6 +245,7 @@ Global
{A63E9DF9-1D47-4D81-834C-1D40406C18C4}.Debug MD|Win32.ActiveCfg = Debug MD|Win32
{A63E9DF9-1D47-4D81-834C-1D40406C18C4}.Debug MD|Win32.Build.0 = Debug MD|Win32
{A63E9DF9-1D47-4D81-834C-1D40406C18C4}.Debug|Any CPU.ActiveCfg = Debug|Win32
{A63E9DF9-1D47-4D81-834C-1D40406C18C4}.Debug|Any CPU.Build.0 = Debug|Win32
{A63E9DF9-1D47-4D81-834C-1D40406C18C4}.Debug|Mixed Platforms.ActiveCfg = Debug|Win32
{A63E9DF9-1D47-4D81-834C-1D40406C18C4}.Debug|Mixed Platforms.Build.0 = Debug|Win32
{A63E9DF9-1D47-4D81-834C-1D40406C18C4}.Debug|Win32.ActiveCfg = Debug|Win32

View File

@ -1,5 +1,5 @@
/*
* $Id: Awk.cpp,v 1.69 2007/10/08 09:43:15 bacon Exp $
* $Id: Awk.cpp,v 1.70 2007/10/10 03:37:49 bacon Exp $
*
* {License}
*/
@ -935,16 +935,34 @@ const Awk::char_t* Awk::Run::getErrorMessage () const
return ase_awk_getrunerrmsg (this->run);
}
void Awk::Run::setError (
ErrorCode code, size_t line, const char_t* arg, size_t len)
void Awk::Run::setError (ErrorCode code)
{
ASE_ASSERT (this->run != ASE_NULL);
ase_awk_setrunerror (this->run, code, 0, ASE_NULL, 0);
}
ase_cstr_t x = { arg, len };
void Awk::Run::setError (ErrorCode code, size_t line)
{
ASE_ASSERT (this->run != ASE_NULL);
ase_awk_setrunerror (this->run, code, line, ASE_NULL, 0);
}
void Awk::Run::setError (ErrorCode code, size_t line, const char_t* arg)
{
ASE_ASSERT (this->run != ASE_NULL);
ase_cstr_t x = { arg, ase_strlen(arg) };
ase_awk_setrunerror (this->run, code, line, &x, 1);
}
void Awk::Run::setError (
ErrorCode code, size_t line, const char_t* arg, size_t len)
{
ASE_ASSERT (this->run != ASE_NULL);
ase_cstr_t x = { arg, len };
ase_awk_setrunerror (this->run, code, line, &x, 1);
}
void Awk::Run::setErrorWithMessage (
ErrorCode code, size_t line, const char_t* msg)
{
ASE_ASSERT (this->run != ASE_NULL);
@ -1063,8 +1081,22 @@ const Awk::char_t* Awk::getErrorMessage () const
return this->errmsg;
}
void Awk::setError (
ErrorCode code, size_t line, const char_t* arg, size_t len)
void Awk::setError (ErrorCode code)
{
setError (code, 0, ASE_NULL, 0);
}
void Awk::setError (ErrorCode code, size_t line)
{
setError (code, line, ASE_NULL, 0);
}
void Awk::setError (ErrorCode code, size_t line, const char_t* arg)
{
setError (code, line, arg, ase_strlen(arg));
}
void Awk::setError (ErrorCode code, size_t line, const char_t* arg, size_t len)
{
if (awk != ASE_NULL)
{
@ -1082,8 +1114,7 @@ void Awk::setError (
}
}
void Awk::setError (
ErrorCode code, size_t line, const char_t* msg)
void Awk::setErrorWithMessage (ErrorCode code, size_t line, const char_t* msg)
{
if (awk != ASE_NULL)
{

View File

@ -1,5 +1,5 @@
/*
* $Id: Awk.hpp,v 1.70 2007/10/08 09:43:15 bacon Exp $
* $Id: Awk.hpp,v 1.71 2007/10/10 03:37:49 bacon Exp $
*
* {License}
*/
@ -578,9 +578,13 @@ public:
size_t getErrorLine () const;
const char_t* getErrorMessage () const;
void setError (ErrorCode code, size_t line = 0,
const char_t* arg = ASE_NULL, size_t len = 0);
void setError (ErrorCode code, size_t line, const char_t* msg);
void setError (ErrorCode code);
void setError (ErrorCode code, size_t line);
void setError (ErrorCode code, size_t line, const char_t* arg);
void setError (ErrorCode code, size_t line, const char_t* arg, size_t len);
void setErrorWithMessage (
ErrorCode code, size_t line, const char_t* msg);
/**
* Sets the value of a global variable. The global variable
@ -705,9 +709,13 @@ public:
const char_t* getErrorMessage () const;
protected:
void setError (ErrorCode code, size_t line = 0,
const char_t* arg = ASE_NULL, size_t len = 0);
void setError (ErrorCode code, size_t line, const char_t* msg);
void setError (ErrorCode code);
void setError (ErrorCode code, size_t line);
void setError (ErrorCode code, size_t line, const char_t* arg);
void setError (ErrorCode code, size_t line, const char_t* arg, size_t len);
void setErrorWithMessage (
ErrorCode code, size_t line, const char_t* msg);
void clearError ();
void retrieveError ();

View File

@ -17,7 +17,7 @@
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)\lib"
IntermediateDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\jni"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
@ -54,10 +54,6 @@
StringPooling="true"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
PrecompiledHeaderFile=".\release/aseawk_jni.pch"
AssemblerListingLocation=".\release/"
ObjectFile=".\release/"
ProgramDataBaseFileName=".\release/"
WarningLevel="3"
SuppressStartupBanner="true"
/>
@ -79,9 +75,6 @@
LinkIncremental="1"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="$(OutDir)"
ProgramDatabaseFile=".\../release/lib/aseawk_jni.pdb"
ImportLibrary="release/aseawk_jni.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
@ -112,7 +105,7 @@
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)\lib"
IntermediateDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\jni"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
@ -148,10 +141,6 @@
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
PrecompiledHeaderFile=".\debug/aseawk_jni.pch"
AssemblerListingLocation=".\debug/"
ObjectFile=".\debug/"
ProgramDataBaseFileName=".\debug/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
@ -175,9 +164,6 @@
SuppressStartupBanner="true"
AdditionalLibraryDirectories="$(OutDir)"
GenerateDebugInformation="true"
ProgramDatabaseFile=".\../debug/lib/aseawk_jni.pdb"
ImportLibrary="debug/aseawk_jni.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
@ -208,7 +194,7 @@
<Configuration
Name="Debug MD|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)\jni"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
@ -244,10 +230,6 @@
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
PrecompiledHeaderFile=".\debug/aseawk_jni.pch"
AssemblerListingLocation=".\debug/"
ObjectFile=".\debug/"
ProgramDataBaseFileName=".\debug/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
@ -271,9 +253,6 @@
SuppressStartupBanner="true"
AdditionalLibraryDirectories="$(OutDir)"
GenerateDebugInformation="true"
ProgramDatabaseFile=".\../debug/lib/aseawk_jni.pdb"
ImportLibrary="debug/aseawk_jni.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"

View File

@ -1,5 +1,5 @@
/*
* $Id: awk.h,v 1.16 2007/09/27 11:30:54 bacon Exp $
* $Id: awk.h,v 1.17 2007/10/10 03:37:49 bacon Exp $
*
* {License}
*/
@ -199,7 +199,10 @@ enum ase_awk_option_t
ASE_AWK_RESET = (1 << 15),
/* allows the assignment of a map value to a variable */
ASE_AWK_MAPTOVAR = (1 << 16)
ASE_AWK_MAPTOVAR = (1 << 16),
/* allows BEGIN, END, pattern-action blocks */
ASE_AWK_PABLOCK = (1 << 17)
};
/* error code */

View File

@ -1,5 +1,5 @@
/*
* $Id: jni.c,v 1.15 2007/09/24 11:15:58 bacon Exp $
* $Id: jni.c,v 1.16 2007/10/10 03:37:49 bacon Exp $
*
* {License}
*/
@ -34,7 +34,14 @@
#define CLASS_EXTIO "ase/awk/Extio"
#define FIELD_HANDLE "handle"
#define MSG_SIZE 256
#if defined(_WIN32) && defined(_MSC_VER) && (_MSC_VER>=1400)
#pragma warning(disable:4996)
#define time_t __time64_t
#define time _time64
#define localtime _localtime64
#define gmtime _gmtime64
#endif
enum
{
@ -1450,10 +1457,10 @@ static int __handle_bfn (
return -1;
}
tmp[0] = (jchar*)'b';
tmp[1] = (jchar*)'f';
tmp[2] = (jchar*)'n';
tmp[3] = (jchar*)'_';
tmp[0] = (jchar)'b';
tmp[1] = (jchar)'f';
tmp[2] = (jchar)'n';
tmp[3] = (jchar)'_';
for (i = 0; i < fnl; i++) tmp[i+4] = (jchar)fnm[i];
name = (*env)->NewString (env, tmp, fnl+4);
free (tmp);
@ -1689,7 +1696,7 @@ static int __handle_bfn (
if (len > 0 && ASE_SIZEOF(jchar) != ASE_SIZEOF(ase_char_t))
{
ase_size_t i;
jsize x;
ase_char_t* tmp = (ase_char_t*)
malloc (ASE_SIZEOF(ase_char_t)*len);
if (tmp == ASE_NULL)
@ -1700,7 +1707,7 @@ static int __handle_bfn (
return -1;
}
for (i = 0; i < len; i++) tmp[i] = (ase_char_t)ptr[i];
for (x = 0; x < len; x++) tmp[x] = (ase_char_t)ptr[x];
v = ase_awk_makestrval (run, tmp, len);
free (tmp);
}
@ -1771,7 +1778,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_addfunc (
if (len > 0 && ASE_SIZEOF(jchar) != ASE_SIZEOF(ase_char_t))
{
ase_size_t i;
jsize x;
ase_char_t* tmp = (ase_char_t*)
malloc (ASE_SIZEOF(ase_char_t)*len);
if (tmp == ASE_NULL)
@ -1785,7 +1792,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_addfunc (
return;
}
for (i = 0; i < len; i++) tmp[i] = (ase_char_t)ptr[i];
for (x = 0; x < len; x++) tmp[x] = (ase_char_t)ptr[x];
n = (ase_awk_addfunc (awk, tmp, len, 0,
min_args, max_args, ASE_NULL, __handle_bfn) == NULL)? -1: 0;
free (tmp);
@ -1848,7 +1855,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_delfunc (
if (len > 0 && ASE_SIZEOF(jchar) != ASE_SIZEOF(ase_char_t))
{
ase_size_t i;
jsize x;
ase_char_t* tmp = (ase_char_t*)
malloc (ASE_SIZEOF(ase_char_t)*len);
if (tmp == ASE_NULL)
@ -1862,7 +1869,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_delfunc (
return;
}
for (i = 0; i < len; i++) tmp[i] = (ase_char_t)ptr[i];
for (x = 0; x < len; x++) tmp[x] = (ase_char_t)ptr[x];
n = ase_awk_delfunc (awk, tmp, len);
free (tmp);
}
@ -2069,7 +2076,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_setword (
if (ol > 0 && ASE_SIZEOF(jchar) != ASE_SIZEOF(ase_char_t))
{
ase_size_t i;
jsize x;
ox = (ase_char_t*)malloc (ASE_SIZEOF(ase_char_t)*ol);
if (ox == ASE_NULL)
{
@ -2084,13 +2091,13 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_setword (
return;
}
for (i = 0; i < ol; i++) ox[i] = (ase_char_t)op[i];
for (x = 0; x < ol; x++) ox[x] = (ase_char_t)op[x];
}
else ox = (ase_char_t*)op;
if (nl > 0 && ASE_SIZEOF(jchar) != ASE_SIZEOF(ase_char_t))
{
ase_size_t i;
jsize x;
nx = (ase_char_t*) malloc (ASE_SIZEOF(ase_char_t)*nl);
if (nx == ASE_NULL)
{
@ -2107,7 +2114,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_setword (
return;
}
for (i = 0; i < nl; i++) nx[i] = (ase_char_t)np[i];
for (x = 0; x < nl; x++) nx[x] = (ase_char_t)np[x];
}
else nx = (ase_char_t*)np;
@ -2152,7 +2159,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_setfilename (
if (len > 0 && ASE_SIZEOF(jchar) != ASE_SIZEOF(ase_char_t))
{
ase_size_t i;
jsize x;
ase_char_t* tmp = (ase_char_t*)
malloc (ASE_SIZEOF(ase_char_t)*len);
if (tmp == ASE_NULL)
@ -2167,7 +2174,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_setfilename (
return;
}
for (i = 0; i < len; i++) tmp[i] = (ase_char_t)ptr[i];
for (x = 0; x < len; x++) tmp[x] = (ase_char_t)ptr[x];
n = ase_awk_setfilename (run, tmp, len);
free (tmp);
}
@ -2211,7 +2218,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_setofilename (
if (len > 0 && ASE_SIZEOF(jchar) != ASE_SIZEOF(ase_char_t))
{
ase_size_t i;
jsize x;
ase_char_t* tmp = (ase_char_t*)
malloc (ASE_SIZEOF(ase_char_t)*len);
if (tmp == ASE_NULL)
@ -2226,7 +2233,7 @@ JNIEXPORT void JNICALL Java_ase_awk_Awk_setofilename (
return;
}
for (i = 0; i < len; i++) tmp[i] = (ase_char_t)ptr[i];
for (x = 0; x < len; x++) tmp[x] = (ase_char_t)ptr[x];
n = ase_awk_setofilename (run, tmp, len);
free (tmp);
}
@ -2273,7 +2280,7 @@ JNIEXPORT jobject JNICALL Java_ase_awk_Awk_strtonum (
if (len > 0 && ASE_SIZEOF(jchar) != ASE_SIZEOF(ase_char_t))
{
ase_size_t i;
jsize x;
ase_char_t* tmp = (ase_char_t*)
malloc (ASE_SIZEOF(ase_char_t)*len);
if (tmp == ASE_NULL)
@ -2287,7 +2294,7 @@ JNIEXPORT jobject JNICALL Java_ase_awk_Awk_strtonum (
return NULL;
}
for (i = 0; i < len; i++) tmp[i] = (ase_char_t)ptr[i];
for (x = 0; x < len; x++) tmp[x] = (ase_char_t)ptr[x];
n = ase_awk_strtonum (
(ase_awk_run_t*)runid, tmp, len, &lv, &rv);
free (tmp);

View File

@ -1,5 +1,5 @@
/*
* $Id: parse.c,v 1.18 2007/09/25 15:27:54 bacon Exp $
* $Id: parse.c,v 1.19 2007/10/10 03:37:49 bacon Exp $
*
* {License}
*/
@ -237,8 +237,8 @@ static kwent_t kwtab[] =
{ ASE_T("in"), 2, TOKEN_IN, 0 },
/* top-level block starters */
{ ASE_T("BEGIN"), 5, TOKEN_BEGIN, 0 },
{ ASE_T("END"), 3, TOKEN_END, 0 },
{ ASE_T("BEGIN"), 5, TOKEN_BEGIN, ASE_AWK_PABLOCK },
{ ASE_T("END"), 3, TOKEN_END, ASE_AWK_PABLOCK },
{ ASE_T("function"), 8, TOKEN_FUNCTION, 0 },
{ ASE_T("func"), 4, TOKEN_FUNCTION, 0 },
@ -649,6 +649,13 @@ static ase_awk_t* parse_progunit (ase_awk_t* awk)
else if (MATCH(awk,TOKEN_LBRACE))
{
/* patternless block */
if ((awk->option & ASE_AWK_PABLOCK) == 0)
{
/* TODO: SET ERROR */
SETERRTOK (awk, ASE_AWK_EFUNC);
return ASE_NULL;
}
awk->parse.id.block = PARSE_ACTION_BLOCK;
if (parse_pattern_block (
awk, ASE_NULL, ase_false) == ASE_NULL) return ASE_NULL;
@ -666,6 +673,13 @@ static ase_awk_t* parse_progunit (ase_awk_t* awk)
*/
ase_awk_nde_t* ptn;
if ((awk->option & ASE_AWK_PABLOCK) == 0)
{
/* TODO: SET ERROR */
SETERRTOK (awk, ASE_AWK_EFUNC);
return ASE_NULL;
}
awk->parse.id.block = PARSE_PATTERN;
ptn = parse_expression (awk, awk->token.line);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/*
* $Id: StdAwk.cpp,v 1.16 2007/10/08 09:43:15 bacon Exp $
* $Id: StdAwk.cpp,v 1.17 2007/10/10 03:37:49 bacon Exp $
*
* {License}
*/
@ -16,98 +16,95 @@
#pragma warning(disable:4996)
namespace ASE
ASE_BEGIN_NAMESPACE2(ASE,Net)
StdAwk::StdAwk ()
{
namespace Net
{
random_seed = (gcnew System::Random)->Next (System::Int32::MinValue, System::Int32::MaxValue);
random = gcnew System::Random (random_seed);
StdAwk::StdAwk ()
{
random_seed = (gcnew System::Random)->Next (System::Int32::MinValue, System::Int32::MaxValue);
random = gcnew System::Random (random_seed);
// TODO: exception/error handling....
AddFunction ("sin", 1, 1, gcnew FunctionHandler (this, &StdAwk::Sin));
AddFunction ("cos", 1, 1, gcnew FunctionHandler (this, &StdAwk::Cos));
AddFunction ("tan", 1, 1, gcnew FunctionHandler (this, &StdAwk::Tan));
AddFunction ("atan", 1, 1, gcnew FunctionHandler (this, &StdAwk::Atan));
AddFunction ("atan2", 2, 2, gcnew FunctionHandler (this, &StdAwk::Atan2));
AddFunction ("log", 1, 1, gcnew FunctionHandler (this, &StdAwk::Log));
AddFunction ("exp", 1, 1, gcnew FunctionHandler (this, &StdAwk::Exp));
AddFunction ("sqrt", 1, 1, gcnew FunctionHandler (this, &StdAwk::Sqrt));
AddFunction ("int", 1, 1, gcnew FunctionHandler (this, &StdAwk::Int));
AddFunction ("rand", 0, 0, gcnew FunctionHandler (this, &StdAwk::Rand));
AddFunction ("srand", 1, 1, gcnew FunctionHandler (this, &StdAwk::Srand));
AddFunction ("systime", 0, 0, gcnew FunctionHandler (this, &StdAwk::Systime));
AddFunction ("strftime", 0, 2, gcnew FunctionHandler (this, &StdAwk::Strftime));
AddFunction ("strfgmtime", 0, 2, gcnew FunctionHandler (this, &StdAwk::Strfgmtime));
}
// TODO: exception/error handling....
AddFunction ("sin", 1, 1, gcnew FunctionHandler (this, &StdAwk::Sin));
AddFunction ("cos", 1, 1, gcnew FunctionHandler (this, &StdAwk::Cos));
AddFunction ("tan", 1, 1, gcnew FunctionHandler (this, &StdAwk::Tan));
AddFunction ("atan", 1, 1, gcnew FunctionHandler (this, &StdAwk::Atan));
AddFunction ("atan2", 2, 2, gcnew FunctionHandler (this, &StdAwk::Atan2));
AddFunction ("log", 1, 1, gcnew FunctionHandler (this, &StdAwk::Log));
AddFunction ("exp", 1, 1, gcnew FunctionHandler (this, &StdAwk::Exp));
AddFunction ("sqrt", 1, 1, gcnew FunctionHandler (this, &StdAwk::Sqrt));
AddFunction ("int", 1, 1, gcnew FunctionHandler (this, &StdAwk::Int));
AddFunction ("rand", 0, 0, gcnew FunctionHandler (this, &StdAwk::Rand));
AddFunction ("srand", 1, 1, gcnew FunctionHandler (this, &StdAwk::Srand));
AddFunction ("systime", 0, 0, gcnew FunctionHandler (this, &StdAwk::Systime));
AddFunction ("strftime", 0, 2, gcnew FunctionHandler (this, &StdAwk::Strftime));
AddFunction ("strfgmtime", 0, 2, gcnew FunctionHandler (this, &StdAwk::Strfgmtime));
}
StdAwk::~StdAwk ()
{
}
StdAwk::~StdAwk ()
{
}
bool StdAwk::Sin (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret)
{
return ret->Set ((real_t)System::Math::Sin (args[0]->RealValue));
}
bool StdAwk::Sin (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret)
{
return ret->Set ((real_t)System::Math::Sin (args[0]->RealValue));
}
bool StdAwk::Cos (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret)
{
return ret->Set ((real_t)System::Math::Cos (args[0]->RealValue));
}
bool StdAwk::Cos (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret)
{
return ret->Set ((real_t)System::Math::Cos (args[0]->RealValue));
}
bool StdAwk::Tan (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret)
{
return ret->Set ((real_t)System::Math::Tan (args[0]->RealValue));
}
bool StdAwk::Tan (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret)
{
return ret->Set ((real_t)System::Math::Tan (args[0]->RealValue));
}
bool StdAwk::Atan (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret)
{
return ret->Set ((real_t)System::Math::Atan (args[0]->RealValue));
}
bool StdAwk::Atan (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret)
{
return ret->Set ((real_t)System::Math::Atan (args[0]->RealValue));
}
bool StdAwk::Atan2 (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret)
{
return ret->Set ((real_t)System::Math::Atan2 (args[0]->RealValue, args[1]->RealValue));
}
bool StdAwk::Atan2 (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret)
{
return ret->Set ((real_t)System::Math::Atan2 (args[0]->RealValue, args[1]->RealValue));
}
bool StdAwk::Log (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret)
{
return ret->Set ((real_t)System::Math::Log (args[0]->RealValue));
}
bool StdAwk::Log (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret)
{
return ret->Set ((real_t)System::Math::Log (args[0]->RealValue));
}
bool StdAwk::Exp (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret)
{
return ret->Set ((real_t)System::Math::Exp (args[0]->RealValue));
}
bool StdAwk::Exp (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret)
{
return ret->Set ((real_t)System::Math::Exp (args[0]->RealValue));
}
bool StdAwk::Sqrt (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret)
{
return ret->Set ((real_t)System::Math::Sqrt (args[0]->RealValue));
}
bool StdAwk::Sqrt (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret)
{
return ret->Set ((real_t)System::Math::Sqrt (args[0]->RealValue));
}
bool StdAwk::Int (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret)
{
return ret->Set (args[0]->LongValue);
}
bool StdAwk::Int (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret)
{
return ret->Set (args[0]->LongValue);
}
bool StdAwk::Rand (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret)
{
return ret->Set ((long_t)random->Next ());
}
bool StdAwk::Rand (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret)
{
return ret->Set ((long_t)random->Next ());
}
bool StdAwk::Srand (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret)
{
int seed = (int)args[0]->LongValue;
System::Random^ tmp = gcnew System::Random (seed);
bool StdAwk::Srand (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret)
{
int seed = (int)args[0]->LongValue;
System::Random^ tmp = gcnew System::Random (seed);
if (!ret->Set((long_t)tmp->Next())) return false;
if (!ret->Set((long_t)tmp->Next())) return false;
this->random_seed = seed;
this->random = tmp;
return true;
}
this->random_seed = seed;
this->random = tmp;
return true;
}
#if defined(_WIN32) && defined(_MSC_VER) && (_MSC_VER>=1400)
#define time_t __time64_t
@ -116,251 +113,251 @@ namespace ASE
#define gmtime _gmtime64
#endif
bool StdAwk::Systime (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret)
{
return ret->Set ((long_t)::time(NULL));
}
bool StdAwk::Systime (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret)
{
return ret->Set ((long_t)::time(NULL));
}
bool StdAwk::Strftime (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret)
{
wchar_t buf[128];
struct tm* tm;
size_t len;
bool StdAwk::Strftime (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret)
{
wchar_t buf[128];
struct tm* tm;
size_t len;
if (args->Length < 1)
{
const wchar_t* fmt = L"%c";
time_t t = (args->Length < 2)? ::time(NULL): (time_t)args[1]->LongValue;
if (args->Length < 1)
{
const wchar_t* fmt = L"%c";
time_t t = (args->Length < 2)? ::time(NULL): (time_t)args[1]->LongValue;
tm = ::localtime (&t);
len = ::wcsftime (buf, ASE_COUNTOF(buf), fmt, tm);
}
else
{
cli::pin_ptr<const ASE::Awk::char_t> fmt = PtrToStringChars(args[0]->StringValue);
tm = ::localtime (&t);
len = ::wcsftime (buf, ASE_COUNTOF(buf), fmt, tm);
}
else
{
cli::pin_ptr<const ASE::Awk::char_t> fmt = PtrToStringChars(args[0]->StringValue);
time_t t = (args->Length < 2)? ::time(NULL): (time_t)args[1]->LongValue;
time_t t = (args->Length < 2)? ::time(NULL): (time_t)args[1]->LongValue;
tm = ::localtime (&t);
len = ::wcsftime (buf, ASE_COUNTOF(buf), fmt, tm);
}
tm = ::localtime (&t);
len = ::wcsftime (buf, ASE_COUNTOF(buf), fmt, tm);
}
return ret->Set (gcnew System::String (buf, 0, len));
}
return ret->Set (gcnew System::String (buf, 0, len));
}
bool StdAwk::Strfgmtime (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret)
{
wchar_t buf[128];
struct tm* tm;
size_t len;
bool StdAwk::Strfgmtime (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret)
{
wchar_t buf[128];
struct tm* tm;
size_t len;
if (args->Length < 1)
{
const wchar_t* fmt = L"%c";
time_t t = (args->Length < 2)? ::time(NULL): (time_t)args[1]->LongValue;
if (args->Length < 1)
{
const wchar_t* fmt = L"%c";
time_t t = (args->Length < 2)? ::time(NULL): (time_t)args[1]->LongValue;
tm = ::gmtime (&t);
len = ::wcsftime (buf, ASE_COUNTOF(buf), fmt, tm);
}
else
{
cli::pin_ptr<const ASE::Awk::char_t> fmt = PtrToStringChars(args[0]->StringValue);
tm = ::gmtime (&t);
len = ::wcsftime (buf, ASE_COUNTOF(buf), fmt, tm);
}
else
{
cli::pin_ptr<const ASE::Awk::char_t> fmt = PtrToStringChars(args[0]->StringValue);
time_t t = (args->Length < 2)? ::time(NULL): (time_t)args[1]->LongValue;
time_t t = (args->Length < 2)? ::time(NULL): (time_t)args[1]->LongValue;
tm = ::gmtime (&t);
len = ::wcsftime (buf, ASE_COUNTOF(buf), fmt, tm);
}
tm = ::gmtime (&t);
len = ::wcsftime (buf, ASE_COUNTOF(buf), fmt, tm);
}
return ret->Set (gcnew System::String (buf, 0, len));
}
return ret->Set (gcnew System::String (buf, 0, len));
}
int StdAwk::OpenFile (File^ file)
int StdAwk::OpenFile (File^ file)
{
System::IO::FileMode mode;
System::IO::FileAccess access;
System::IO::FileStream^ fs;
if (file->Mode->Equals(File::MODE::READ))
{
mode = System::IO::FileMode::Open;
access = System::IO::FileAccess::Read;
fs = gcnew System::IO::FileStream (file->Name, mode, access);
System::IO::StreamReader^ rd = gcnew System::IO::StreamReader (fs);
file->Handle = rd;
}
else if (file->Mode->Equals(File::MODE::WRITE))
{
mode = System::IO::FileMode::Create;
access = System::IO::FileAccess::Write;
fs = gcnew System::IO::FileStream (file->Name, mode, access);
System::IO::StreamWriter^ wr = gcnew System::IO::StreamWriter (fs);
file->Handle = wr;
}
else /* File::MODE::APPEND */
{
mode = System::IO::FileMode::Append;
access = System::IO::FileAccess::Write;
fs = gcnew System::IO::FileStream (file->Name, mode, access);
System::IO::StreamWriter^ wr = gcnew System::IO::StreamWriter (fs);
file->Handle = wr;
}
return 1;
}
int StdAwk::CloseFile (File^ file)
{
if (file->Mode->Equals(File::MODE::READ))
{
System::IO::StreamReader^ sr = (System::IO::StreamReader^)file->Handle;
sr->Close ();
}
else
{
System::IO::StreamWriter^ sw = (System::IO::StreamWriter^)file->Handle;
sw->Close ();
}
return 0;
}
int StdAwk::ReadFile (File^ file, cli::array<char_t>^ buf, int len)
{
System::IO::StreamReader^ sr = (System::IO::StreamReader^)file->Handle;
return sr->Read (buf, 0, len);
}
int StdAwk::WriteFile (File^ file, cli::array<char_t>^ buf, int len)
{
System::IO::StreamWriter^ sw = (System::IO::StreamWriter^)file->Handle;
sw->Write (buf, 0, len);
return len;
}
int StdAwk::FlushFile (File^ file)
{
System::IO::StreamWriter^ sw = (System::IO::StreamWriter^)file->Handle;
sw->Flush ();
return 0;
}
int StdAwk::OpenPipe (Pipe^ pipe)
{
FILE* fp = NULL;
cli::pin_ptr<const wchar_t> name =
PtrToStringChars(pipe->Name);
if (pipe->Mode->Equals(Pipe::MODE::READ))
{
fp = _wpopen (name, L"r");
}
else // Pipe::MODE::WRITE
{
fp = _wpopen (name, L"w");
}
if (fp == NULL) return -1;
pipe->Handle = System::IntPtr ((void*)fp);
return 1;
}
int StdAwk::ClosePipe (Pipe^ pipe)
{
System::IntPtr ip = (System::IntPtr)pipe->Handle;
FILE* fp = (FILE*)ip.ToPointer();
return (::_pclose (fp) == EOF)? -1: 0;
}
int StdAwk::ReadPipe (Pipe^ pipe, cli::array<char_t>^ buf, int len)
{
System::IntPtr ip = (System::IntPtr)pipe->Handle;
FILE* fp = (FILE*)ip.ToPointer();
int n = 0;
while (n < len)
{
wint_t c = fgetwc (fp);
if (c == WEOF) break;
buf[n++] = c;
if (c == L'\n') break;
}
return n;
}
int StdAwk::WritePipe (Pipe^ pipe, cli::array<char_t>^ buf, int len)
{
System::IntPtr ip = (System::IntPtr)pipe->Handle;
FILE* fp = (FILE*)ip.ToPointer();
int left;
cli::pin_ptr<char_t> bp = &buf[0];
/* somehow, fwprintf returns 0 when non-ascii
* characters are included in the buffer.
while (left > 0)
{
if (*bp == ASE_T('\0'))
{
System::IO::FileMode mode;
System::IO::FileAccess access;
System::IO::FileStream^ fs;
if (file->Mode->Equals(File::MODE::READ))
if (fputwc (*ptr, fp) == WEOF)
{
mode = System::IO::FileMode::Open;
access = System::IO::FileAccess::Read;
fs = gcnew System::IO::FileStream (file->Name, mode, access);
System::IO::StreamReader^ rd = gcnew System::IO::StreamReader (fs);
file->Handle = rd;
return -1;
}
else if (file->Mode->Equals(File::MODE::WRITE))
{
mode = System::IO::FileMode::Create;
access = System::IO::FileAccess::Write;
left -= 1; bp += 1;
}
else
{
int n = fwprintf (fp, L"%.*s", left, bp);
if (n < 0 || n > left) return -1;
left -= n; bp += n;
}
}*/
fs = gcnew System::IO::FileStream (file->Name, mode, access);
System::IO::StreamWriter^ wr = gcnew System::IO::StreamWriter (fs);
file->Handle = wr;
/* so the scheme has been changed to the following */
char* mbp = unicode_to_multibyte (bp, len, &left);
if (mbp == NULL) return -1;
char* ptr = mbp;
while (left > 0)
{
if (*ptr == '\0')
{
if (fputwc (*ptr, fp) == WEOF)
{
::free (mbp);
return -1;
}
else /* File::MODE::APPEND */
left -= 1; ptr += 1;
}
else
{
int n = fprintf (fp, "%.*s", left, ptr);
if (n < 0 || n > left)
{
mode = System::IO::FileMode::Append;
access = System::IO::FileAccess::Write;
fs = gcnew System::IO::FileStream (file->Name, mode, access);
System::IO::StreamWriter^ wr = gcnew System::IO::StreamWriter (fs);
file->Handle = wr;
::free (mbp);
return -1;
}
return 1;
}
int StdAwk::CloseFile (File^ file)
{
if (file->Mode->Equals(File::MODE::READ))
{
System::IO::StreamReader^ sr = (System::IO::StreamReader^)file->Handle;
sr->Close ();
}
else
{
System::IO::StreamWriter^ sw = (System::IO::StreamWriter^)file->Handle;
sw->Close ();
}
return 0;
}
int StdAwk::ReadFile (File^ file, cli::array<char_t>^ buf, int len)
{
System::IO::StreamReader^ sr = (System::IO::StreamReader^)file->Handle;
return sr->Read (buf, 0, len);
}
int StdAwk::WriteFile (File^ file, cli::array<char_t>^ buf, int len)
{
System::IO::StreamWriter^ sw = (System::IO::StreamWriter^)file->Handle;
sw->Write (buf, 0, len);
return len;
}
int StdAwk::FlushFile (File^ file)
{
System::IO::StreamWriter^ sw = (System::IO::StreamWriter^)file->Handle;
sw->Flush ();
return 0;
}
int StdAwk::OpenPipe (Pipe^ pipe)
{
FILE* fp = NULL;
cli::pin_ptr<const wchar_t> name =
PtrToStringChars(pipe->Name);
if (pipe->Mode->Equals(Pipe::MODE::READ))
{
fp = _wpopen (name, L"r");
}
else // Pipe::MODE::WRITE
{
fp = _wpopen (name, L"w");
}
if (fp == NULL) return -1;
pipe->Handle = System::IntPtr ((void*)fp);
return 1;
}
int StdAwk::ClosePipe (Pipe^ pipe)
{
System::IntPtr ip = (System::IntPtr)pipe->Handle;
FILE* fp = (FILE*)ip.ToPointer();
return (::_pclose (fp) == EOF)? -1: 0;
}
int StdAwk::ReadPipe (Pipe^ pipe, cli::array<char_t>^ buf, int len)
{
System::IntPtr ip = (System::IntPtr)pipe->Handle;
FILE* fp = (FILE*)ip.ToPointer();
int n = 0;
while (n < len)
{
wint_t c = fgetwc (fp);
if (c == WEOF) break;
buf[n++] = c;
if (c == L'\n') break;
}
return n;
}
int StdAwk::WritePipe (Pipe^ pipe, cli::array<char_t>^ buf, int len)
{
System::IntPtr ip = (System::IntPtr)pipe->Handle;
FILE* fp = (FILE*)ip.ToPointer();
int left;
cli::pin_ptr<char_t> bp = &buf[0];
/* somehow, fwprintf returns 0 when non-ascii
* characters are included in the buffer.
while (left > 0)
{
if (*bp == ASE_T('\0'))
{
if (fputwc (*ptr, fp) == WEOF)
{
return -1;
}
left -= 1; bp += 1;
}
else
{
int n = fwprintf (fp, L"%.*s", left, bp);
if (n < 0 || n > left) return -1;
left -= n; bp += n;
}
}*/
/* so the scheme has been changed to the following */
char* mbp = unicode_to_multibyte (bp, len, &left);
if (mbp == NULL) return -1;
char* ptr = mbp;
while (left > 0)
{
if (*ptr == '\0')
{
if (fputwc (*ptr, fp) == WEOF)
{
::free (mbp);
return -1;
}
left -= 1; ptr += 1;
}
else
{
int n = fprintf (fp, "%.*s", left, ptr);
if (n < 0 || n > left)
{
::free (mbp);
return -1;
}
left -= n; ptr += n;
}
}
::free (mbp);
return len;
}
int StdAwk::FlushPipe (Pipe^ pipe)
{
System::IntPtr ip = (System::IntPtr)pipe->Handle;
FILE* fp = (FILE*)ip.ToPointer();
return (::fflush (fp) == EOF)? -1: 0;
left -= n; ptr += n;
}
}
::free (mbp);
return len;
}
int StdAwk::FlushPipe (Pipe^ pipe)
{
System::IntPtr ip = (System::IntPtr)pipe->Handle;
FILE* fp = (FILE*)ip.ToPointer();
return (::fflush (fp) == EOF)? -1: 0;
}
ASE_END_NAMESPACE2(Net,ASE)

View File

@ -1,57 +1,54 @@
/*
* $Id: StdAwk.hpp,v 1.8 2007/10/08 09:43:15 bacon Exp $
* $Id: StdAwk.hpp,v 1.9 2007/10/10 03:37:49 bacon Exp $
*/
#include <ase/net/Awk.hpp>
namespace ASE
ASE_BEGIN_NAMESPACE2(ASE,Net)
public ref class StdAwk abstract: public Awk
{
namespace Net
{
public ref class StdAwk abstract: public Awk
{
public:
StdAwk ();
~StdAwk ();
public:
StdAwk ();
~StdAwk ();
protected:
int random_seed;
System::Random^ random;
protected:
int random_seed;
System::Random^ random;
bool Sin (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret);
bool Cos (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret);
bool Tan (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret);
bool Atan (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret);
bool Atan2 (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret);
bool Log (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret);
bool Exp (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret);
bool Sqrt (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret);
bool Int (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret);
bool Rand (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret);
bool Srand (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret);
bool Systime (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret);
bool Strftime (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret);
bool Strfgmtime (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret);
bool Sin (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret);
bool Cos (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret);
bool Tan (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret);
bool Atan (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret);
bool Atan2 (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret);
bool Log (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret);
bool Exp (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret);
bool Sqrt (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret);
bool Int (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret);
bool Rand (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret);
bool Srand (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret);
bool Systime (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret);
bool Strftime (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret);
bool Strfgmtime (Context^ ctx, System::String^ name, array<Argument^>^ args, Return^ ret);
public protected:
// File
virtual int OpenFile (File^ file) override;
virtual int CloseFile (File^ file) override;
virtual int ReadFile (
File^ file, cli::array<char_t>^ buf, int len) override;
virtual int WriteFile (
File^ file, cli::array<char_t>^ buf, int len) override;
virtual int FlushFile (File^ file) override;
public protected:
// File
virtual int OpenFile (File^ file) override;
virtual int CloseFile (File^ file) override;
virtual int ReadFile (
File^ file, cli::array<char_t>^ buf, int len) override;
virtual int WriteFile (
File^ file, cli::array<char_t>^ buf, int len) override;
virtual int FlushFile (File^ file) override;
// Pipe
virtual int OpenPipe (Pipe^ pipe) override;
virtual int ClosePipe (Pipe^ pipe) override;
virtual int ReadPipe (
Pipe^ pipe, cli::array<char_t>^ buf, int len) override;
virtual int WritePipe (
Pipe^ pipe, cli::array<char_t>^ buf, int len) override;
virtual int FlushPipe (Pipe^ pipe) override;
};
}
}
// Pipe
virtual int OpenPipe (Pipe^ pipe) override;
virtual int ClosePipe (Pipe^ pipe) override;
virtual int ReadPipe (
Pipe^ pipe, cli::array<char_t>^ buf, int len) override;
virtual int WritePipe (
Pipe^ pipe, cli::array<char_t>^ buf, int len) override;
virtual int FlushPipe (Pipe^ pipe) override;
};
ASE_END_NAMESPACE2(Net,ASE)

View File

@ -1,5 +1,5 @@
/*
* $Id: Awk.cpp,v 1.41 2007/10/07 15:27:39 bacon Exp $
* $Id: Awk.cpp,v 1.42 2007/10/10 03:37:49 bacon Exp $
*/
#include <ase/awk/StdAwk.hpp>
@ -16,6 +16,11 @@
#include <unistd.h>
#endif
#if defined(_WIN32) && defined(_MSC_VER) && defined(_DEBUG)
#define _CRTDBG_MAP_ALLOC
#include <crtdbg.h>
#endif
class TestAwk: public ASE::StdAwk
{
public:

Binary file not shown.