This commit is contained in:
hyung-hwan 2008-08-21 04:58:19 +00:00
parent 6dbf01ade0
commit 713586d04a
14 changed files with 192 additions and 264 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: Awk.cpp 312 2008-08-02 13:40:04Z baconevi $
* $Id: Awk.cpp 341 2008-08-20 10:58:19Z baconevi $
*/
#include <ase/awk/StdAwk.hpp>
@ -381,7 +381,7 @@ protected:
if (fp == NULL) return -1;
ConTrack* t = (ConTrack*)
ase_awk_malloc (awk, ASE_SIZEOF(ConTrack));
ase_awk_alloc (awk, ASE_SIZEOF(ConTrack));
if (t == ASE_NULL)
{
if (fp != stdin && fp != stdout) fclose (fp);

View File

@ -1,12 +1,12 @@
/*
* $Id: awk.c 337 2008-08-20 09:17:25Z baconevi $
* $Id: awk.c 341 2008-08-20 10:58:19Z baconevi $
*/
#include <ase/awk/awk.h>
#include <ase/cmn/sll.h>
#include <ase/cmn/mem.h>
#include <ase/cmn/chr.h>
#include <ase/utl/helper.h>
#include <ase/utl/getopt.h>
#include <ase/utl/stdio.h>
#include <ase/utl/main.h>
@ -1099,7 +1099,7 @@ static void init_extension (ase_awk_t* awk)
ext->mmgr = *ase_awk_getmmgr(awk);
ase_awk_setmmgr (awk, &ext->mmgr);
ase_awk_setccls (awk, ASE_GETCCLS());
ase_awk_setccls (awk, ASE_CCLS_GETDFL());
ext->prmfns.pow = custom_awk_pow;
ext->prmfns.sprintf = custom_awk_sprintf;

View File

@ -4,14 +4,13 @@
#include <ase/tgp/tgp.h>
#include <ase/utl/ctype.h>
#include <ase/utl/stdio.h>
#include <ase/utl/main.h>
#include <ase/utl/getopt.h>
#include <ase/cmn/mem.h>
#include <ase/cmn/chr.h>
#include <ase/cmn/str.h>
#include <ase/utl/helper.h>
#include <string.h>
#include <stdlib.h>
@ -153,7 +152,7 @@ static int io_out (int cmd, void* arg, ase_char_t* buf, int len)
return 0;
case ASE_TGP_IO_WRITE:
ase_fprintf (xout->fp, "%.*s", len, buf);
ase_fprintf (xout->fp, ASE_T("%.*s"), len, buf);
return len;
}

View File

@ -1,5 +1,5 @@
/*
* $Id: Awk.hpp 283 2008-07-22 13:12:56Z baconevi $
* $Id: Awk.hpp 341 2008-08-20 10:58:19Z baconevi $
*
* {License}
*/
@ -9,6 +9,7 @@
#include <ase/awk/awk.h>
#include <ase/cmn/map.h>
#include <ase/cmn/chr.h>
#include <stdarg.h>
/////////////////////////////////
@ -49,6 +50,21 @@ public:
/** Represents the underlying interpreter */
typedef ase_awk_t awk_t;
enum ccls_type_t
{
CCLS_UPPER,
CCLS_LOWER,
CCLS_ALPHA,
CCLS_DIGIT,
CCLS_XDIGIT,
CCLS_ALNUM,
CCLS_SPACE,
CCLS_PRINT,
CCLS_GRAPH,
CCLS_CNTRL,
CCLS_PUNCT
};
/**
* Represents the source code I/O context for Awk::parse.
* An instance of Awk::Source is passed to Awk::openSource,
@ -712,12 +728,12 @@ public:
/**
* Sets a value into the custom data area
* Sets a value into the data data area
*/
void setCustom (void* custom);
void setCustom (void* data);
/**
* Gets the value stored in the custom data area
* Gets the value stored in the data data area
*/
void* getCustom () const;
@ -725,7 +741,7 @@ public:
Awk* awk;
run_t* run;
bool callbackFailed;
void* custom;
void* data;
};
/** Constructor */
@ -927,7 +943,7 @@ protected:
* methods. You can determine the context of the method by calling
* Awk::Source::getMode and inspecting its return value. You may use
* Awk::Source::getHandle and Awk::Source::setHandle to store and
* retrieve the custom information needed to complete the operation.
* retrieve the data information needed to complete the operation.
*/
/*@{*/
/**
@ -1022,19 +1038,8 @@ protected:
virtual void* reallocMem (void* ptr, size_t n) = 0;
virtual void freeMem (void* ptr) = 0;
virtual bool_t isUpper (cint_t c) = 0;
virtual bool_t isLower (cint_t c) = 0;
virtual bool_t isAlpha (cint_t c) = 0;
virtual bool_t isDigit (cint_t c) = 0;
virtual bool_t isXdigit (cint_t c) = 0;
virtual bool_t isAlnum (cint_t c) = 0;
virtual bool_t isSpace (cint_t c) = 0;
virtual bool_t isPrint (cint_t c) = 0;
virtual bool_t isGraph (cint_t c) = 0;
virtual bool_t isCntrl (cint_t c) = 0;
virtual bool_t isPunct (cint_t c) = 0;
virtual cint_t toUpper (cint_t c) = 0;
virtual cint_t toLower (cint_t c) = 0;
virtual bool_t isType (cint_t c, ccls_type_t type) = 0;
virtual cint_t transCase (cint_t c, ccls_type_t type) = 0;
virtual real_t pow (real_t x, real_t y) = 0;
virtual int vsprintf (char_t* buf, size_t size,
@ -1058,33 +1063,22 @@ protected:
run_t* run, const char_t* name, size_t len);
static void freeFunctionMapValue (void* owner, void* value);
static void onRunStart (run_t* run, void* custom);
static void onRunEnd (run_t* run, int errnum, void* custom);
static void onRunReturn (run_t* run, val_t* ret, void* custom);
static void onRunStatement (run_t* run, size_t line, void* custom);
static void onRunStart (run_t* run, void* data);
static void onRunEnd (run_t* run, int errnum, void* data);
static void onRunReturn (run_t* run, val_t* ret, void* data);
static void onRunStatement (run_t* run, size_t line, void* data);
static void* allocMem (void* custom, size_t n);
static void* reallocMem (void* custom, void* ptr, size_t n);
static void freeMem (void* custom, void* ptr);
static void* allocMem (void* data, size_t n);
static void* reallocMem (void* data, void* ptr, size_t n);
static void freeMem (void* data, void* ptr);
static bool_t isUpper (void* custom, cint_t c);
static bool_t isLower (void* custom, cint_t c);
static bool_t isAlpha (void* custom, cint_t c);
static bool_t isDigit (void* custom, cint_t c);
static bool_t isXdigit (void* custom, cint_t c);
static bool_t isAlnum (void* custom, cint_t c);
static bool_t isSpace (void* custom, cint_t c);
static bool_t isPrint (void* custom, cint_t c);
static bool_t isGraph (void* custom, cint_t c);
static bool_t isCntrl (void* custom, cint_t c);
static bool_t isPunct (void* custom, cint_t c);
static cint_t toUpper (void* custom, cint_t c);
static cint_t toLower (void* custom, cint_t c);
static bool_t isType (void* data, cint_t c, int type);
static cint_t transCase (void* data, cint_t c, int type);
static real_t pow (void* custom, real_t x, real_t y);
static int sprintf (void* custom, char_t* buf, size_t size,
static real_t pow (void* data, real_t x, real_t y);
static int sprintf (void* data, char_t* buf, size_t size,
const char_t* fmt, ...);
static void dprintf (void* custom, const char_t* fmt, ...);
static void dprintf (void* data, const char_t* fmt, ...);
protected:
awk_t* awk;

View File

@ -1,5 +1,5 @@
/*
* $Id: StdAwk.hpp 195 2008-06-06 13:01:55Z baconevi $
* $Id: StdAwk.hpp 341 2008-08-20 10:58:19Z baconevi $
*
* {License}
*/
@ -77,19 +77,8 @@ protected:
void* reallocMem (void* ptr, size_t n);
void freeMem (void* ptr);
bool_t isUpper (cint_t c);
bool_t isLower (cint_t c);
bool_t isAlpha (cint_t c);
bool_t isDigit (cint_t c);
bool_t isXdigit (cint_t c);
bool_t isAlnum (cint_t c);
bool_t isSpace (cint_t c);
bool_t isPrint (cint_t c);
bool_t isGraph (cint_t c);
bool_t isCntrl (cint_t c);
bool_t isPunct (cint_t c);
cint_t toUpper (cint_t c);
cint_t toLower (cint_t c);
bool_t isType (cint_t c, ccls_type_t type);
cint_t transCase (cint_t c, ccls_type_t type);
real_t pow (real_t x, real_t y);
int vsprintf (char_t* buf, size_t size,

View File

@ -52,6 +52,9 @@ extern "C" {
extern ase_ccls_t* ase_ccls;
ase_bool_t ase_ccls_is (ase_cint_t c, int type);
ase_cint_t ase_ccls_to (ase_cint_t c, int type);
#ifdef __cplusplus
}
#endif

View File

@ -1,5 +1,5 @@
/*
* $Id: Awk.cpp 332 2008-08-18 11:21:48Z baconevi $
* $Id: Awk.cpp 341 2008-08-20 10:58:19Z baconevi $
*
* {License}
*/
@ -231,7 +231,7 @@ void Awk::Argument::clear ()
void* Awk::Argument::operator new (size_t n, awk_t* awk) throw ()
{
void* ptr = ase_awk_malloc (awk, ASE_SIZEOF(awk) + n);
void* ptr = ase_awk_alloc (awk, ASE_SIZEOF(awk) + n);
if (ptr == ASE_NULL) return ASE_NULL;
*(awk_t**)ptr = awk;
@ -240,7 +240,7 @@ void* Awk::Argument::operator new (size_t n, awk_t* awk) throw ()
void* Awk::Argument::operator new[] (size_t n, awk_t* awk) throw ()
{
void* ptr = ase_awk_malloc (awk, ASE_SIZEOF(awk) + n);
void* ptr = ase_awk_alloc (awk, ASE_SIZEOF(awk) + n);
if (ptr == ASE_NULL) return ASE_NULL;
*(awk_t**)ptr = awk;
@ -871,7 +871,7 @@ Awk::Run::Run (Awk* awk):
}
Awk::Run::Run (Awk* awk, run_t* run):
awk (awk), run (run), callbackFailed (false), custom (ASE_NULL)
awk (awk), run (run), callbackFailed (false), data (ASE_NULL)
{
ASE_ASSERT (this->run != ASE_NULL);
}
@ -1008,14 +1008,14 @@ int Awk::Run::getGlobal (int id, Argument& global) const
return global.init (ase_awk_getglobal(this->run,id));
}
void Awk::Run::setCustom (void* custom)
void Awk::Run::setCustom (void* data)
{
this->custom = custom;
this->data = data;
}
void* Awk::Run::getCustom () const
{
return this->custom;
return this->data;
}
//////////////////////////////////////////////////////////////////
@ -1029,24 +1029,13 @@ Awk::Awk (): awk (ASE_NULL), functionMap (ASE_NULL),
{
this->errmsg[0] = ASE_T('\0');
mmgr.malloc = allocMem;
mmgr.realloc = reallocMem;
mmgr.free = freeMem;
mmgr.data = this;
mmgr.alloc = allocMem;
mmgr.realloc = reallocMem;
mmgr.free = freeMem;
mmgr.data = this;
ccls.is_upper = isUpper;
ccls.is_lower = isLower;
ccls.is_alpha = isAlpha;
ccls.is_digit = isDigit;
ccls.is_xdigit = isXdigit;
ccls.is_alnum = isAlnum;
ccls.is_space = isSpace;
ccls.is_print = isPrint;
ccls.is_graph = isGraph;
ccls.is_cntrl = isCntrl;
ccls.is_punct = isPunct;
ccls.to_upper = toUpper;
ccls.to_lower = toLower;
ccls.is = isType;
ccls.to = transCase;
ccls.data = this;
prmfns.pow = pow;
@ -1326,7 +1315,7 @@ int Awk::run (const char_t* main, const char_t** args, size_t nargs)
if (nargs > 0)
{
runarg = (ase_awk_runarg_t*) ase_awk_malloc (
runarg = (ase_awk_runarg_t*) ase_awk_alloc (
awk, ASE_SIZEOF(ase_awk_runarg_t)*(nargs+1));
if (runarg == ASE_NULL)
@ -1453,7 +1442,7 @@ int Awk::addFunction (
ASE_ASSERT (awk != ASE_NULL);
FunctionHandler* tmp = (FunctionHandler*)
ase_awk_malloc (awk, ASE_SIZEOF(handler));
ase_awk_alloc (awk, ASE_SIZEOF(handler));
if (tmp == ASE_NULL)
{
setError (ERR_NOMEM);
@ -1677,9 +1666,9 @@ void Awk::freeFunctionMapValue (void* owner, void* value)
ase_awk_free (awk->awk, value);
}
void Awk::onRunStart (run_t* run, void* custom)
void Awk::onRunStart (run_t* run, void* data)
{
Run* r = (Run*)custom;
Run* r = (Run*)data;
// the actual run_t value for the run-time callback is set here.
// r here refers to runctx declared in Awk::run. As onRunStart
@ -1693,9 +1682,9 @@ void Awk::onRunStart (run_t* run, void* custom)
r->awk->triggerOnRunStart (*r);
}
void Awk::onRunEnd (run_t* run, int errnum, void* custom)
void Awk::onRunEnd (run_t* run, int errnum, void* data)
{
Run* r = (Run*)custom;
Run* r = (Run*)data;
if (errnum == ERR_NOERR && r->callbackFailed)
{
@ -1705,9 +1694,9 @@ void Awk::onRunEnd (run_t* run, int errnum, void* custom)
r->awk->onRunEnd (*r);
}
void Awk::onRunReturn (run_t* run, val_t* ret, void* custom)
void Awk::onRunReturn (run_t* run, val_t* ret, void* data)
{
Run* r = (Run*)custom;
Run* r = (Run*)data;
if (r->callbackFailed) return;
Argument x (r);
@ -1721,113 +1710,58 @@ void Awk::onRunReturn (run_t* run, val_t* ret, void* custom)
}
}
void Awk::onRunStatement (run_t* run, size_t line, void* custom)
void Awk::onRunStatement (run_t* run, size_t line, void* data)
{
Run* r = (Run*)custom;
Run* r = (Run*)data;
if (r->callbackFailed) return;
r->awk->onRunStatement (*r, line);
}
void* Awk::allocMem (void* custom, size_t n)
void* Awk::allocMem (void* data, size_t n)
{
return ((Awk*)custom)->allocMem (n);
return ((Awk*)data)->allocMem (n);
}
void* Awk::reallocMem (void* custom, void* ptr, size_t n)
void* Awk::reallocMem (void* data, void* ptr, size_t n)
{
return ((Awk*)custom)->reallocMem (ptr, n);
return ((Awk*)data)->reallocMem (ptr, n);
}
void Awk::freeMem (void* custom, void* ptr)
void Awk::freeMem (void* data, void* ptr)
{
((Awk*)custom)->freeMem (ptr);
((Awk*)data)->freeMem (ptr);
}
Awk::bool_t Awk::isUpper (void* custom, cint_t c)
{
return ((Awk*)custom)->isUpper (c);
}
Awk::bool_t Awk::isLower (void* custom, cint_t c)
{
return ((Awk*)custom)->isLower (c);
}
Awk::bool_t Awk::isAlpha (void* custom, cint_t c)
{
return ((Awk*)custom)->isAlpha (c);
}
Awk::bool_t Awk::isDigit (void* custom, cint_t c)
{
return ((Awk*)custom)->isDigit (c);
}
Awk::bool_t Awk::isXdigit (void* custom, cint_t c)
{
return ((Awk*)custom)->isXdigit (c);
}
Awk::bool_t Awk::isAlnum (void* custom, cint_t c)
{
return ((Awk*)custom)->isAlnum (c);
}
Awk::bool_t Awk::isSpace (void* custom, cint_t c)
{
return ((Awk*)custom)->isSpace (c);
}
Awk::bool_t Awk::isPrint (void* custom, cint_t c)
{
return ((Awk*)custom)->isPrint (c);
}
Awk::bool_t Awk::isGraph (void* custom, cint_t c)
Awk::bool_t Awk::isType (void* data, cint_t c, int type)
{
return ((Awk*)custom)->isGraph (c);
return ((Awk*)data)->isType (c, (Awk::ccls_type_t)type);
}
Awk::bool_t Awk::isCntrl (void* custom, cint_t c)
Awk::cint_t Awk::transCase (void* data, cint_t c, int type)
{
return ((Awk*)custom)->isCntrl (c);
return ((Awk*)data)->transCase (c, (Awk::ccls_type_t)type);
}
Awk::bool_t Awk::isPunct (void* custom, cint_t c)
Awk::real_t Awk::pow (void* data, real_t x, real_t y)
{
return ((Awk*)custom)->isPunct (c);
}
Awk::cint_t Awk::toUpper (void* custom, cint_t c)
{
return ((Awk*)custom)->toUpper (c);
}
Awk::cint_t Awk::toLower (void* custom, cint_t c)
{
return ((Awk*)custom)->toLower (c);
}
Awk::real_t Awk::pow (void* custom, real_t x, real_t y)
{
return ((Awk*)custom)->pow (x, y);
return ((Awk*)data)->pow (x, y);
}
int Awk::sprintf (void* custom, char_t* buf, size_t size,
int Awk::sprintf (void* data, char_t* buf, size_t size,
const char_t* fmt, ...)
{
va_list ap;
va_start (ap, fmt);
int n = ((Awk*)custom)->vsprintf (buf, size, fmt, ap);
int n = ((Awk*)data)->vsprintf (buf, size, fmt, ap);
va_end (ap);
return n;
}
void Awk::dprintf (void* custom, const char_t* fmt, ...)
void Awk::dprintf (void* data, const char_t* fmt, ...)
{
va_list ap;
va_start (ap, fmt);
((Awk*)custom)->vdprintf (fmt, ap);
((Awk*)data)->vdprintf (fmt, ap);
va_end (ap);
}

View File

@ -1,5 +1,5 @@
/*
* $Id: StdAwk.cpp 152 2008-03-21 11:57:29Z baconevi $
* $Id: StdAwk.cpp 341 2008-08-20 10:58:19Z baconevi $
*
* {License}
*/
@ -11,7 +11,6 @@
#include <ase/awk/StdAwk.hpp>
#include <ase/cmn/str.h>
#include <ase/utl/stdio.h>
#include <ase/utl/ctype.h>
#include <stdlib.h>
#include <math.h>
@ -218,7 +217,7 @@ int StdAwk::system (Run& run, Return& ret, const Argument* args, size_t nargs,
#elif defined(ASE_CHAR_IS_MCHAR)
return ret.set ((long_t)::system(ptr));
#else
char* mbs = (char*)ase_awk_malloc (awk, l*5+1);
char* mbs = (char*) ase_awk_alloc (awk, l*5+1);
if (mbs == ASE_NULL) return -1;
::size_t mbl = ::wcstombs (mbs, ptr, l*5);
@ -435,70 +434,15 @@ void StdAwk::freeMem (void* ptr)
::free (ptr);
}
// character class primitives
StdAwk::bool_t StdAwk::isUpper (cint_t c)
{
return ase_isupper (c);
}
StdAwk::bool_t StdAwk::isLower (cint_t c)
// character handling primitive
Awk::bool_t StdAwk::isType (cint_t c, ccls_type_t type)
{
return ase_islower (c);
return ase_ccls_is (c, type);
}
StdAwk::bool_t StdAwk::isAlpha (cint_t c)
{
return ase_isalpha (c);
}
StdAwk::bool_t StdAwk::isDigit (cint_t c)
Awk::cint_t StdAwk::transCase (cint_t c, ccls_type_t type)
{
return ase_isdigit (c);
}
StdAwk::bool_t StdAwk::isXdigit (cint_t c)
{
return ase_isxdigit (c);
}
StdAwk::bool_t StdAwk::isAlnum (cint_t c)
{
return ase_isalnum (c);
}
StdAwk::bool_t StdAwk::isSpace (cint_t c)
{
return ase_isspace (c);
}
StdAwk::bool_t StdAwk::isPrint (cint_t c)
{
return ase_isprint (c);
}
StdAwk::bool_t StdAwk::isGraph (cint_t c)
{
return ase_isgraph (c);
}
StdAwk::bool_t StdAwk::isCntrl (cint_t c)
{
return ase_iscntrl (c);
}
StdAwk::bool_t StdAwk::isPunct (cint_t c)
{
return ase_ispunct (c);
}
StdAwk::cint_t StdAwk::toUpper (cint_t c)
{
return ase_toupper (c);
}
StdAwk::cint_t StdAwk::toLower (cint_t c)
{
return ase_tolower (c);
return ase_ccls_to (c, type);
}
// miscellaneous primitive

View File

@ -4,7 +4,6 @@
#include "awk.h"
#include <ase/utl/stdio.h>
#include <ase/utl/helper.h>
#include <math.h>
typedef struct ext_t
@ -46,7 +45,7 @@ ase_awk_t* ase_awk_openstd (void)
ext_t* ext;
awk = ase_awk_open (ASE_NULL, ASE_SIZEOF(ext_t), ASE_NULL);
ase_awk_setccls (awk, ASE_GETCCLS());
ase_awk_setccls (awk, ASE_CCLS_GETDFL());
ext = (ext_t*) ase_awk_getextension (awk);
ext->prmfns.pow = custom_awk_pow;

View File

@ -10,13 +10,13 @@
#include <ctype.h>
static ase_bool_t ccls_is (void* data, ase_cint_t c, ase_ccls_type_t type)
ase_bool_t ase_ccls_is (ase_cint_t c, int type)
{
/* TODO: use GetStringTypeW/A for WIN32 to implement these */
#error NOT IMPLEMENTED YET.
}
static ase_cint_t ccls_to (void* data, ase_cint_t c, in type)
ase_cint_t ase_ccls_to (ase_cint_t c, int type)
{
ASE_ASSERTX (type >= ASE_CCLS_UPPER && type <= ASE_CCLS_LOWER,
"The character type should be one of ASE_CCLS_UPPER and ASE_CCLS_LOWER");
@ -30,7 +30,7 @@ static ase_cint_t ccls_to (void* data, ase_cint_t c, in type)
#include <wctype.h>
static ase_bool_t ccls_is (void* data, ase_cint_t c, int type)
ase_bool_t ase_ccls_is (ase_cint_t c, int type)
{
static const char* name[] =
{
@ -69,7 +69,7 @@ static ase_bool_t ccls_is (void* data, ase_cint_t c, int type)
return iswctype (c, desc[type]);
}
static ase_cint_t ccls_to (void* data, ase_cint_t c, int type)
ase_cint_t ase_ccls_to (ase_cint_t c, int type)
{
static const char* name[] =
{
@ -94,6 +94,16 @@ static ase_cint_t ccls_to (void* data, ase_cint_t c, int type)
#error unsupported character type
#endif
static ase_bool_t ccls_is (void* data, ase_cint_t c, int type)
{
return ase_ccls_is (c, type);
}
static ase_cint_t ccls_to (void* data, ase_cint_t c, int type)
{
return ase_ccls_to (c, type);
}
static ase_ccls_t ccls =
{
ccls_is,

View File

@ -9,4 +9,63 @@
#include <ase/cmn/chr.h>
#ifdef USE_STDC
#if defined(ASE_CHAR_IS_MCHAR)
#include <ctype.h>
#define ASE_ISUPPER(c) isupper(c)
#define ASE_ISLOWER(c) islower(c)
#define ASE_ISALPHA(c) isalpha(c)
#define ASE_ISDIGIT(c) isdigit(c)
#define ASE_ISXDIGIT(c) isxdigit(c)
#define ASE_ISALNUM(c) isalnum(c)
#define ASE_ISSPACE(c) isspace(c)
#define ASE_ISPRINT(c) isprint(c)
#define ASE_ISGRAPH(c) isgraph(c)
#define ASE_ISCNTRL(c) iscntrl(c)
#define ASE_ISPUNCT(c) ispunct(c)
#define ASE_TOUPPER(c) toupper(c)
#define ASE_TOLOWER(c) tolower(c)
#elif defined(ASE_CHAR_IS_WCHAR)
#include <ctype.h>
#include <wctype.h>
#define ASE_ISUPPER(c) iswupper(c)
#define ASE_ISLOWER(c) iswlower(c)
#define ASE_ISALPHA(c) iswalpha(c)
#define ASE_ISDIGIT(c) iswdigit(c)
#define ASE_ISXDIGIT(c) iswxdigit(c)
#define ASE_ISALNUM(c) iswalnum(c)
#define ASE_ISSPACE(c) iswspace(c)
#define ASE_ISPRINT(c) iswprint(c)
#define ASE_ISGRAPH(c) iswgraph(c)
#define ASE_ISCNTRL(c) iswcntrl(c)
#define ASE_ISPUNCT(c) iswpunct(c)
#define ASE_TOUPPER(c) towupper(c)
#define ASE_TOLOWER(c) towlower(c)
#else
#error Unsupported character type
#endif
#else
#define ASE_ISUPPER(c) (ase_ccls_is(c,ASE_CCLS_UPPER))
#define ASE_ISLOWER(c) (ase_ccls_is(c,ASE_CCLS_LOWER))
#define ASE_ISALPHA(c) (ase_ccls_is(c,ASE_CCLS_ALPHA))
#define ASE_ISDIGIT(c) (ase_ccls_is(c,ASE_CCLS_DIGIT))
#define ASE_ISXDIGIT(c) (ase_ccls_is(c,ASE_CCLS_XDIGIT))
#define ASE_ISALNUM(c) (ase_ccls_is(c,ASE_CCLS_ALNUM))
#define ASE_ISSPACE(c) (ase_ccls_is(c,ASE_CCLS_SPACE))
#define ASE_ISPRINT(c) (ase_ccls_is(c,ASE_CCLS_PRINT))
#define ASE_ISGRAPH(c) (ase_ccls_is(c,ASE_CCLS_GRAPH))
#define ASE_ISCNTRL(c) (ase_ccls_is(c,ASE_CCLS_CNTRL))
#define ASE_ISPUNCT(c) (ase_ccls_is(c,ASE_CCLS_PUNCT))
#define ASE_TOUPPER(c) (ase_ccls_to(c,ASE_CCLS_UPPER))
#define ASE_TOLOWER(c) (ase_ccls_to(c,ASE_CCLS_LOWER))
#endif
#endif

View File

@ -1,19 +1,19 @@
/*
* $Id: http.c 332 2008-08-18 11:21:48Z baconevi $
* $Id: http.c 341 2008-08-20 10:58:19Z baconevi $
*
* {License}
*/
#include <ase/utl/http.h>
#include <ase/utl/ctype.h>
#include "../cmn/mem.h"
#include "../cmn/chr.h"
static int is_http_space (ase_char_t c)
{
return ase_isspace(c) && c != ASE_T('\r') && c != ASE_T('\n');
return ASE_ISSPACE(c) && c != ASE_T('\r') && c != ASE_T('\n');
}
#define is_http_ctl(c) ase_iscntrl(c)
#define is_http_ctl(c) ASE_ISCNTRL(c)
static int is_http_separator (ase_char_t c)
{
@ -40,7 +40,7 @@ static int is_http_separator (ase_char_t c)
static int is_http_token (ase_char_t c)
{
return ase_isprint(c) && !is_http_ctl(c) && !is_http_separator(c);
return ASE_ISPRINT(c) && !is_http_ctl(c) && !is_http_separator(c);
}
static int digit_to_num (ase_char_t c)
@ -59,10 +59,10 @@ ase_char_t* ase_parsehttpreq (ase_char_t* buf, ase_http_req_t* req)
while (is_http_space(*p)) p++;
/* the method should start with an alphabet */
if (!ase_isalpha(*p)) return ASE_NULL;
if (!ASE_ISALPHA(*p)) return ASE_NULL;
/* scan the method */
req->method = p; while (ase_isalpha(*p)) p++;
req->method = p; while (ASE_ISALPHA(*p)) p++;
/* the method should be followed by a space */
if (!is_http_space(*p)) return ASE_NULL;
@ -78,9 +78,9 @@ ase_char_t* ase_parsehttpreq (ase_char_t* buf, ase_http_req_t* req)
req->args.ptr = ASE_NULL;
x = p;
while (ase_isprint(*p) && !ase_isspace(*p))
while (ASE_ISPRINT(*p) && !ASE_ISSPACE(*p))
{
if (*p == ASE_T('%') && ase_isxdigit(*(p+1)) && ase_isxdigit(*(p+2)))
if (*p == ASE_T('%') && ASE_ISXDIGIT(*(p+1)) && ASE_ISXDIGIT(*(p+2)))
{
*x++ = (digit_to_num(*(p+1)) << 4) + digit_to_num(*(p+2));
p += 3;
@ -120,15 +120,15 @@ ase_char_t* ase_parsehttpreq (ase_char_t* buf, ase_http_req_t* req)
(p[3] == ASE_T('P') || p[3] == ASE_T('p')) &&
p[4] == ASE_T('/') && p[6] == ASE_T('.'))
{
if (!ase_isdigit(p[5])) return ASE_NULL;
if (!ase_isdigit(p[7])) return ASE_NULL;
if (!ASE_ISDIGIT(p[5])) return ASE_NULL;
if (!ASE_ISDIGIT(p[7])) return ASE_NULL;
req->vers.major = p[5] - ASE_T('0');
req->vers.minor = p[7] - ASE_T('0');
p += 8;
}
else return ASE_NULL;
while (ase_isspace(*p))
while (ASE_ISSPACE(*p))
{
if (*p++ == ASE_T('\n')) goto ok;
}
@ -147,7 +147,7 @@ ase_char_t* ase_parsehttphdr (ase_char_t* buf, ase_http_hdr_t* hdr)
ase_char_t* p = buf, * last;
/* ignore leading spaces including CR and NL */
while (ase_isspace(*p)) p++;
while (ASE_ISSPACE(*p)) p++;
if (*p == ASE_T('\0'))
{
@ -172,13 +172,13 @@ ase_char_t* ase_parsehttphdr (ase_char_t* buf, ase_http_hdr_t* hdr)
do { p++; } while (is_http_space(*p));
hdr->value.ptr = last = p;
while (ase_isprint(*p))
while (ASE_ISPRINT(*p))
{
if (!ase_isspace(*p++)) last = p;
if (!ASE_ISSPACE(*p++)) last = p;
}
hdr->value.len = last - hdr->value.ptr;
while (ase_isspace(*p))
while (ASE_ISSPACE(*p))
{
if (*p++ == ASE_T('\n')) goto ok;
}

View File

@ -55,8 +55,7 @@ am__installdirs = "$(DESTDIR)$(libdir)"
libLTLIBRARIES_INSTALL = $(INSTALL)
LTLIBRARIES = $(lib_LTLIBRARIES)
libaseutl_la_LIBADD =
am_libaseutl_la_OBJECTS = helper.lo assert.lo ctype.lo getopt.lo \
http.lo main.lo stdio.lo
am_libaseutl_la_OBJECTS = assert.lo getopt.lo http.lo main.lo stdio.lo
libaseutl_la_OBJECTS = $(am_libaseutl_la_OBJECTS)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)/include/ase
depcomp = $(SHELL) $(top_srcdir)/autoconf/depcomp
@ -194,7 +193,7 @@ sysconfdir = @sysconfdir@
target_alias = @target_alias@
AM_CFLAGS = -I$(top_builddir)/include
lib_LTLIBRARIES = libaseutl.la
libaseutl_la_SOURCES = helper.c assert.c ctype.c getopt.c http.c main.c stdio.c
libaseutl_la_SOURCES = assert.c getopt.c http.c main.c stdio.c
libaseutl_la_LDFLAGS = -version-info 1:0:0
all: all-am
@ -266,9 +265,7 @@ distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/assert.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ctype.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getopt.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/helper.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/http.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stdio.Plo@am__quote@

View File

@ -1,11 +1,11 @@
/*
* $Id: stdio.c 149 2008-03-20 09:49:53Z baconevi $
* $Id: stdio.c 341 2008-08-20 10:58:19Z baconevi $
*
* {License}
*/
#include <ase/utl/stdio.h>
#include <ase/utl/ctype.h>
#include "../cmn/chr.h"
#include <wchar.h>
#include <stdlib.h>
@ -209,7 +209,7 @@ static ase_char_t* __adjust_format (const ase_char_t* format)
}
else
{
while (ase_isdigit(ch))
while (ASE_ISDIGIT(ch))
{
ADDC (buf, ch);
ch = *fp++;
@ -229,7 +229,7 @@ static ase_char_t* __adjust_format (const ase_char_t* format)
}
else
{
while (ase_isdigit(ch))
while (ASE_ISDIGIT(ch))
{
ADDC (buf, ch);
ch = *fp++;
@ -267,7 +267,7 @@ static ase_char_t* __adjust_format (const ase_char_t* format)
#ifdef ASE_CHAR_IS_MCHAR
ADDC (buf, 'l');
#endif
ADDC (buf, ase_tolower(ch));
ADDC (buf, ASE_TOLOWER(ch));
#endif
}
else if (ch == ASE_T('d') || ch == ASE_T('i') ||