*** empty log message ***

This commit is contained in:
hyung-hwan 2006-07-17 06:21:39 +00:00
parent 3ffaab0599
commit 10f51cc517
5 changed files with 124 additions and 7 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Id: func.c,v 1.11 2006-07-17 04:17:40 bacon Exp $ * $Id: func.c,v 1.12 2006-07-17 06:19:35 bacon Exp $
*/ */
#include <xp/awk/awk_i.h> #include <xp/awk/awk_i.h>
@ -226,7 +226,7 @@ static int __bfn_sin (void* run)
if (n == 0) rv = (xp_real_t)lv; if (n == 0) rv = (xp_real_t)lv;
v = xp_awk_makerealval (run, sin(rv)); v = xp_awk_makerealval (run, (xp_real_t)sin(rv));
if (v == XP_NULL) if (v == XP_NULL)
{ {
xp_awk_seterrnum (run, XP_AWK_ENOMEM); xp_awk_seterrnum (run, XP_AWK_ENOMEM);

46
ase/awk/rex.c Normal file
View File

@ -0,0 +1,46 @@
/*
* $Id: rex.c,v 1.1 2006-07-17 06:21:39 bacon Exp $
*/
#include <xp/awk/awk_i.h>
#ifndef XP_AWK_STAND_ALONE
#include <xp/bas/memory.h>
#include <xp/bas/assert.h>
#endif
xp_awk_rex_t* xp_awk_rex_open (xp_awk_rex_t* rex)
{
if (rex == XP_NULL)
{
rex = (xp_awk_rex_t*) xp_malloc (xp_sizeof(xp_awk_rex_t));
if (rex == XP_NULL) return XP_NULL;
rex->__dynamic = xp_true;
}
else rex->__dynamic = xp_false;
return rex;
}
void xp_awk_rex_close (xp_awk_rex_t* rex)
{
if (rex->__dynamic) xp_free (rex);
}
int xp_awk_rex_compile (const xp_awk_rex_t* rex, const xp_char_t* ptn)
{
const xp_char_t* p = ptn;
xp_char_t c;
while (*p != XP_T('\0'))
{
c = *p++; // TODO: backspace escaping...
if (c == XP_T('|'))
{
}
}
return -1;
}

31
ase/awk/rex.h Normal file
View File

@ -0,0 +1,31 @@
/*
* $Id: rex.h,v 1.1 2006-07-17 06:21:39 bacon Exp $
**/
#ifndef _XP_AWK_REX_H_
#define _XP_AWK_REX_H_
#ifndef _XP_AWK_AWK_H_
#error Never include this file directly. Include <xp/awk/awk.h> instead
#endif
typedef struct xp_awk_rex_t xp_awk_rex_t;
struct xp_awk_rex_t
{
xp_bool_t __dynamic;
};
#ifdef __cplusplus
extern "C" {
#endif
xp_awk_rex_t* xp_awk_rex_open (xp_awk_rex_t* rex);
void xp_awk_rex_close (xp_awk_rex_t* rex);
int xp_awk_rex_compile (const xp_awk_rex_t* rex, const xp_char_t* ptn);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,5 +1,5 @@
/* /*
* $Id: val.c,v 1.42 2006-07-17 04:17:40 bacon Exp $ * $Id: val.c,v 1.43 2006-07-17 06:19:35 bacon Exp $
*/ */
#include <xp/awk/awk_i.h> #include <xp/awk/awk_i.h>
@ -425,10 +425,50 @@ xp_char_t* xp_awk_valtostr (
return tmp; return tmp;
} }
/* TODO:
if (v->type == XP_AWK_VAL_REAL) if (v->type == XP_AWK_VAL_REAL)
{ {
}*/ /* TODO: change the code */
xp_char_t tbuf[256], * tmp;
#if (XP_SIZEOF_LONG_DOUBLE != 0)
xp_sprintf (
tbuf, xp_countof(tbuf), XP_T("%Lf"),
(long double)((xp_awk_val_real_t*)v)->val);
#elif (XP_SIZEOF_DOUBLE != 0)
xp_sprintf (
tbuf, xp_countof(tbuf), XP_T("%f"),
(double)((xp_awk_val_real_t*)v)->val);
#else
#error Unsupported floating-point data type
#endif
if (buf == XP_NULL)
{
tmp = xp_strdup (tbuf);
if (tmp == XP_NULL)
{
*errnum = XP_AWK_ENOMEM;
return XP_NULL;
}
if (len != XP_NULL) *len = xp_strlen(tmp);
}
else
{
xp_str_clear (buf);
if (xp_str_cat (buf, tbuf) == (xp_size_t)-1)
{
*errnum = XP_AWK_ENOMEM;
return XP_NULL;
}
tmp = XP_STR_BUF(buf);
if (len != XP_NULL) *len = XP_STR_LEN(buf);
}
return tmp;
}
if (v->type == XP_AWK_VAL_STR) if (v->type == XP_AWK_VAL_STR)
{ {
@ -505,7 +545,7 @@ int xp_awk_valtonum (xp_awk_val_t* v, xp_long_t* l, xp_real_t* r)
return 0; /* long */ return 0; /* long */
} }
xp_printf (XP_T("*** ERROR: WRONG VALUE TYPE [%d] in xp_awk_valtostr v=> %p***\n"), v->type, v); xp_printf (XP_T("*** ERROR: WRONG VALUE TYPE [%d] in xp_awk_valtonum v=> %p***\n"), v->type, v);
return -1; /* error */ return -1; /* error */
} }

View File

@ -22,4 +22,4 @@ global x, y;
print "===================="; print "====================";
} }
END { system ("dir /w/p"); print sin(10); } END { system ("dir /w/p"); print sin(90.0); }