*** empty log message ***

This commit is contained in:
hyung-hwan 2006-10-31 14:32:50 +00:00
parent 66cc0f0cb2
commit 2fce0a2637
4 changed files with 24 additions and 13 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Id: awk.c,v 1.89 2006-10-28 12:17:24 bacon Exp $ * $Id: awk.c,v 1.90 2006-10-31 14:31:46 bacon Exp $
*/ */
#if defined(__BORLANDC__) #if defined(__BORLANDC__)
@ -39,6 +39,8 @@ ase_awk_t* ase_awk_open (const ase_awk_syscas_t* syscas)
syscas->dprintf == ASE_NULL || syscas->dprintf == ASE_NULL ||
syscas->abort == ASE_NULL) return ASE_NULL; syscas->abort == ASE_NULL) return ASE_NULL;
if (syscas->pow == ASE_NULL) return ASE_NULL;
#if defined(_WIN32) && defined(_DEBUG) #if defined(_WIN32) && defined(_DEBUG)
awk = (ase_awk_t*) malloc (ase_sizeof(ase_awk_t)); awk = (ase_awk_t*) malloc (ase_sizeof(ase_awk_t));
#else #else

View File

@ -1,5 +1,5 @@
/* /*
* $Id: awk.h,v 1.138 2006-10-31 10:13:14 bacon Exp $ * $Id: awk.h,v 1.139 2006-10-31 14:31:46 bacon Exp $
*/ */
#ifndef _ASE_AWK_AWK_H_ #ifndef _ASE_AWK_AWK_H_
@ -72,14 +72,16 @@ struct ase_awk_syscas_t
ase_cint_t (*to_lower) (ase_cint_t c); ase_cint_t (*to_lower) (ase_cint_t c);
/* utilities */ /* utilities */
void* (*memcpy) (void* dst, const void* src, ase_size_t n); void* (*memcpy) (void* dst, const void* src, ase_size_t n);
void* (*memset) (void* dst, int val, ase_size_t n); void* (*memset) (void* dst, int val, ase_size_t n);
ase_real_t (*pow) (ase_real_t x, ase_real_t y);
int (*sprintf) (ase_char_t* buf, ase_size_t size, ase_char_t* fmt, ...); int (*sprintf) (ase_char_t* buf, ase_size_t size, ase_char_t* fmt, ...);
int (*aprintf) (ase_char_t* fmt, ...); /* assertion */ int (*aprintf) (ase_char_t* fmt, ...); /* assertion */
int (*dprintf) (ase_char_t* fmt, ...); /* debug */ int (*dprintf) (ase_char_t* fmt, ...); /* debug */
void (*abort) (void); void (*abort) (void);
void* custom_data; void* custom_data;
}; };

View File

@ -1,12 +1,9 @@
/* /*
* $Id: run.c,v 1.250 2006-10-31 10:13:15 bacon Exp $ * $Id: run.c,v 1.251 2006-10-31 14:31:46 bacon Exp $
*/ */
#include <ase/awk/awk_i.h> #include <ase/awk/awk_i.h>
/* TODO: remove this dependency...*/
#include <math.h>
#define CMP_ERROR -99 #define CMP_ERROR -99
#define DEF_BUF_CAPA 256 #define DEF_BUF_CAPA 256
#define STACK_INCREMENT 512 #define STACK_INCREMENT 512
@ -3704,6 +3701,10 @@ static ase_awk_val_t* __eval_binop_exp (
ase_real_t r1, r2; ase_real_t r1, r2;
ase_awk_val_t* res; ase_awk_val_t* res;
ASE_AWK_ASSERTX (run->awk, run->awk->syscas.pow != ASE_NULL,
"the pow function should be provided when the awk object "
"is created to make the exponentiation work properly.");
n1 = ase_awk_valtonum (run, left, &l1, &r1); n1 = ase_awk_valtonum (run, left, &l1, &r1);
n2 = ase_awk_valtonum (run, right, &l2, &r2); n2 = ase_awk_valtonum (run, right, &l2, &r2);
@ -3726,14 +3727,14 @@ static ase_awk_val_t* __eval_binop_exp (
} }
else if (n3 == 2) else if (n3 == 2)
{ {
res = ase_awk_makerealval ( res = ase_awk_makerealval (run,
run, pow((ase_real_t)l1,(ase_real_t)r2)); run->awk->syscas.pow((ase_real_t)l1,(ase_real_t)r2));
} }
else else
{ {
ASE_AWK_ASSERT (run->awk, n3 == 3); ASE_AWK_ASSERT (run->awk, n3 == 3);
res = ase_awk_makerealval ( res = ase_awk_makerealval (run,
run, pow((ase_real_t)r1,(ase_real_t)r2)); run->awk->syscas.pow((ase_real_t)r1,(ase_real_t)r2));
} }
if (res == ASE_NULL) PANIC (run, ASE_AWK_ENOMEM); if (res == ASE_NULL) PANIC (run, ASE_AWK_ENOMEM);

View File

@ -1,5 +1,5 @@
/* /*
* $Id: awk.c,v 1.108 2006-10-31 10:12:44 bacon Exp $ * $Id: awk.c,v 1.109 2006-10-31 14:32:50 bacon Exp $
*/ */
#include <ase/awk/awk.h> #include <ase/awk/awk.h>
@ -7,6 +7,7 @@
#include <string.h> #include <string.h>
#include <signal.h> #include <signal.h>
#include <stdarg.h> #include <stdarg.h>
#include <math.h>
#ifdef ASE_CHAR_IS_WCHAR #ifdef ASE_CHAR_IS_WCHAR
#include <wchar.h> #include <wchar.h>
@ -125,6 +126,10 @@ static int __dprintf (const ase_char_t* fmt, ...)
return n; return n;
} }
static ase_real_t __pow (ase_real_t x, ase_real_t y)
{
return pow (x, y);
}
static FILE* popen_t (const ase_char_t* cmd, const ase_char_t* mode) static FILE* popen_t (const ase_char_t* cmd, const ase_char_t* mode)
{ {
@ -723,6 +728,7 @@ static int __main (int argc, ase_char_t* argv[])
#endif #endif
syscas.memcpy = memcpy; syscas.memcpy = memcpy;
syscas.memset = memset; syscas.memset = memset;
syscas.pow = __pow;
syscas.sprintf = xp_sprintf; syscas.sprintf = xp_sprintf;
syscas.aprintf = __aprintf; syscas.aprintf = __aprintf;
syscas.dprintf = __dprintf; syscas.dprintf = __dprintf;