*** empty log message ***

This commit is contained in:
hyung-hwan 2006-11-18 15:36:57 +00:00
parent 748d7408b1
commit 7111ee2808
9 changed files with 86 additions and 48 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: awk.h,v 1.142 2006-11-18 12:15:20 bacon Exp $
* $Id: awk.h,v 1.143 2006-11-18 15:36:56 bacon Exp $
*/
#ifndef _ASE_AWK_AWK_H_
@ -77,11 +77,10 @@ struct ase_awk_syscas_t
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 (*aprintf) (ase_char_t* fmt, ...); /* assertion */
int (*dprintf) (ase_char_t* fmt, ...); /* debug */
void (*aprintf) (ase_char_t* fmt, ...); /* assertion */
void (*dprintf) (ase_char_t* fmt, ...); /* debug */
void (*abort) (void);
void* custom_data;
};

View File

@ -1,5 +1,5 @@
/*
* $Id: awk_i.h,v 1.81 2006-11-17 07:04:31 bacon Exp $
* $Id: awk_i.h,v 1.82 2006-11-18 15:36:56 bacon Exp $
*/
#ifndef _ASE_AWK_AWKI_H_
@ -273,6 +273,16 @@ struct ase_awk_run_t
ase_awk_str_t fmt;
ase_awk_str_t out;
ase_char_t tmp[4096];
/*
struct
{
ase_char_t* ptr;
ase_size_t len;
} tmp;
*/
ase_bool_t c99; /* syscas.sprintf returns -1 on error */
} sprintf;
int errnum;

View File

@ -1,5 +1,5 @@
/*
* $Id: func.c,v 1.76 2006-11-16 15:16:25 bacon Exp $
* $Id: func.c,v 1.77 2006-11-18 15:36:57 bacon Exp $
*/
#include <ase/awk/awk_i.h>
@ -1283,7 +1283,7 @@ static int __bfn_sprintf (ase_awk_run_t* run)
}
}
ptr = ase_awk_sprintf (run,
ptr = ase_awk_format (run,
&out, &fbu, str0, len0, nargs, ASE_NULL, &len);
if (a0->type != ASE_AWK_VAL_STR) ASE_AWK_FREE (run->awk, str0);
if (ptr == ASE_NULL)

View File

@ -1,5 +1,5 @@
/*
* $Id: run.c,v 1.265 2006-11-18 12:15:20 bacon Exp $
* $Id: run.c,v 1.266 2006-11-18 15:36:57 bacon Exp $
*/
#include <ase/awk/awk_i.h>
@ -2478,7 +2478,7 @@ static int __formatted_output (
ase_size_t len;
int n;
ptr = ase_awk_sprintf (run,
ptr = ase_awk_format (run,
ASE_NULL, ASE_NULL, fmt, fmt_len, 0, args, &len);
if (ptr == ASE_NULL) return -1;
@ -5538,7 +5538,7 @@ static ase_char_t* __idxnde_to_str (
return str;
}
ase_char_t* ase_awk_sprintf (
ase_char_t* ase_awk_format (
ase_awk_run_t* run, ase_awk_str_t* out, ase_awk_str_t* fbu,
const ase_char_t* fmt, ase_size_t fmt_len,
ase_size_t nargs_on_stack, ase_awk_nde_t* args, ase_size_t* len)
@ -5640,8 +5640,9 @@ ase_char_t* ase_awk_sprintf (
if (n == -1) return ASE_NULL;
if (n == 1) l = (ase_long_t)r;
run->awk->syscas.sprintf (
run->sprintf.tmp,
run->sprintf.tmp,
ase_countof(run->sprintf.tmp),
#ifdef _WIN32
ASE_T("%I64d"), (__int64)l);
@ -5656,6 +5657,37 @@ ase_char_t* ase_awk_sprintf (
p++;
}
/*
while (1)
{
n = run->awk->syscas.sprintf (
run->sprintf.tmp.ptr,
run->sprintf.tmp.len,
#ifdef _WIN32
ASE_T("%I64d"), (__int64)l);
#else
ASE_T("%lld"), (long long)l);
#endif
if ((!run->sprintf.tmp.c99 && n == -1) ||
(run->sprintf.tmp.c99 &&
n != ase_awk_strlen(run->sprintf.tmp.ptr))
{
continue;
}
}
p = run->sprintf.tmp.ptr;
while (*p != ASE_T('\0'))
{
FMT_CHAR (*p);
p++;
}
*/
if (args == ASE_NULL || val != ASE_NULL) stack_arg_idx++;
else args = args->next;
i++;
@ -5793,7 +5825,6 @@ ase_char_t* ase_awk_sprintf (
if (n == -1) return ASE_NULL;
if (n == 1) l = (ase_long_t)r;
/* TODO: check the return value of syscas.sprintf and handle an error */
run->awk->syscas.sprintf (
run->sprintf.tmp,
ase_countof(run->sprintf.tmp),
@ -5858,7 +5889,6 @@ ase_char_t* ase_awk_sprintf (
if (n == -1) return ASE_NULL;
if (n == 0) r = (ase_real_t)l;
/* TODO: check the return value of syscas.sprintf and handle an error */
run->awk->syscas.sprintf (
run->sprintf.tmp,
ase_countof(run->sprintf.tmp),
@ -5999,7 +6029,6 @@ ase_char_t* ase_awk_sprintf (
else if (v->type == ASE_AWK_VAL_STR)
{
/* TODO: handle a string contailing null characters */
/* TODO: handle error conditions of sprintf */
run->awk->syscas.sprintf (
run->sprintf.tmp,
ase_countof(run->sprintf.tmp),

View File

@ -1,5 +1,5 @@
/*
* $Id: run.h,v 1.24 2006-11-16 15:16:25 bacon Exp $
* $Id: run.h,v 1.25 2006-11-18 15:36:57 bacon Exp $
*/
#ifndef _ASE_AWK_RUN_H_
@ -104,7 +104,7 @@ enum
extern "C" {
#endif
ase_char_t* ase_awk_sprintf (
ase_char_t* ase_awk_format (
ase_awk_run_t* run, ase_awk_str_t* out, ase_awk_str_t* fbu,
const ase_char_t* fmt, ase_size_t fmt_len,
ase_size_t nargs_on_stack, ase_awk_nde_t* args, ase_size_t* len);

View File

@ -1,5 +1,5 @@
/*
* $Id: tree.c,v 1.87 2006-11-17 07:04:32 bacon Exp $
* $Id: tree.c,v 1.88 2006-11-18 15:36:57 bacon Exp $
*/
#include <ase/awk/awk_i.h>
@ -248,7 +248,7 @@ static int __print_expression (ase_awk_t* awk, ase_awk_nde_t* nde)
{
if (((ase_awk_nde_real_t*)nde)->str == ASE_NULL)
{
ase_char_t tmp[128];
ase_char_t tmp[256];
#if (ASE_SIZEOF_LONG_DOUBLE != 0)
awk->syscas.sprintf (
tmp, ase_countof(tmp), ASE_T("%Lf"),
@ -277,11 +277,6 @@ static int __print_expression (ase_awk_t* awk, ase_awk_nde_t* nde)
ase_size_t len, i;
PUT_SRCSTR (awk, ASE_T("\""));
/*
PUT_SRCSTRX (awk,
((ase_awk_nde_str_t*)nde)->buf,
((ase_awk_nde_str_t*)nde)->len);
*/
ptr = ((ase_awk_nde_str_t*)nde)->buf;
len = ((ase_awk_nde_str_t*)nde)->len;

View File

@ -1,5 +1,5 @@
/*
* $Id: val.c,v 1.89 2006-11-18 12:15:20 bacon Exp $
* $Id: val.c,v 1.90 2006-11-18 15:36:57 bacon Exp $
*/
#include <ase/awk/awk_i.h>
@ -616,7 +616,7 @@ static ase_char_t* __val_real_to_str (
return ASE_NULL;
}
tmp = ase_awk_sprintf (run, &out, &fbu, tmp, tmp_len,
tmp = ase_awk_format (run, &out, &fbu, tmp, tmp_len,
(ase_size_t)-1, (ase_awk_nde_t*)v, &tmp_len);
if (tmp == ASE_NULL)
{

View File

@ -1,5 +1,5 @@
/*
* $Id: awk.c,v 1.115 2006-11-17 07:49:10 bacon Exp $
* $Id: awk.c,v 1.116 2006-11-18 15:36:57 bacon Exp $
*/
#include <ase/awk/awk.h>
@ -26,9 +26,6 @@
#define ASE_PATH_MAX PATH_MAX
#endif
#define xp_vsprintf _vsntprintf
#define xp_sprintf _sntprintf
#define xp_fprintf _ftprintf
#define xp_printf _tprintf
#define xp_assert assert
@ -108,6 +105,11 @@ static int __awk_sprintf (
va_start (ap, fmt);
#if defined(_WIN32)
n = _vsntprintf (buf, len, fmt, ap);
if (n < 0 || (ase_size_t)n >= len)
{
if (len >= 0) buf[len-1] = ASE_T('\0');
n = -1;
}
#elif defined(__MSDOS__)
/* TODO: check buffer overflow */
n = vsprintf (buf, fmt, ap);
@ -118,48 +120,48 @@ static int __awk_sprintf (
return n;
}
static int __awk_aprintf (const ase_char_t* fmt, ...)
static void __awk_aprintf (const ase_char_t* fmt, ...)
{
int n;
va_list ap;
#ifdef _WIN32
int n;
ase_char_t buf[1024];
#endif
va_start (ap, fmt);
#if defined(_WIN32)
n = _vsntprintf (buf, ase_countof(buf), fmt, ap);
if (n < 0) buf[ase_countof(buf)-1] = ASE_T('\0');
#if defined(_MSC_VER) && (_MSC_VER<1400)
MessageBox (NULL, buf, ASE_T("Assertion Failure"), MB_OK | MB_ICONERROR);
MessageBox (NULL, buf,
ASE_T("Assertion Failure"), MB_OK|MB_ICONERROR);
#else
MessageBox (NULL, buf, ASE_T("\uB2DD\uAE30\uB9AC \uC870\uB610"), MB_OK | MB_ICONERROR);
MessageBox (NULL, buf,
ASE_T("\uB2DD\uAE30\uB9AC \uC870\uB610"), MB_OK|MB_ICONERROR);
#endif
#elif defined(__MSDOS__)
n = vprintf (fmt, ap);
vprintf (fmt, ap);
#else
n = xp_vprintf (fmt, ap);
xp_vprintf (fmt, ap);
#endif
va_end (ap);
return n;
}
static int __awk_dprintf (const ase_char_t* fmt, ...)
static void __awk_dprintf (const ase_char_t* fmt, ...)
{
int n;
va_list ap;
va_start (ap, fmt);
#if defined(_WIN32)
n = _vftprintf (stderr, fmt, ap);
_vftprintf (stderr, fmt, ap);
#elif defined(__MSDOS__)
n = vfprintf (stderr, fmt, ap);
vfprintf (stderr, fmt, ap);
#else
n = xp_vfprintf (stderr, fmt, ap);
xp_vfprintf (stderr, fmt, ap);
#endif
va_end (ap);
return n;
}
static ase_real_t __awk_pow (ase_real_t x, ase_real_t y)

View File

@ -1,16 +1,19 @@
SRCS = awk.c
OUTS = $(SRCS:.c=.x)
OBJS = $(SRCS:.c=.o)
CC = @CC@
CFLAGS = @CFLAGS@ -I@abs_top_builddir@/.. -I$(XPKIT)
LDFLAGS = @LDFLAGS@ -L@abs_top_builddir@/awk -L$(XPKIT)/xp/bas
LIBS = @LIBS@ -laseawk -lxpbas -lm
all: $(OUTS)
all: awk
awk: $(OBJS)
$(CC) -o awk awk.o $(LDFLAGS) $(LIBS)
clean:
rm -rf $(OUTS) *.o
rm -rf *.o awk
.SUFFIXES: .c .x
.c.x:
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $< $(LIBS)
.SUFFIXES: .c .o
.c.o:
$(CC) -c $(CFLAGS) $<