interim commit
This commit is contained in:
parent
1e7f2551e5
commit
90955d1b0a
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: Awk.hpp 240 2009-07-19 13:02:33Z hyunghwan.chung $
|
* $Id: Awk.hpp 245 2009-07-25 05:18:42Z hyunghwan.chung $
|
||||||
*
|
*
|
||||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||||
|
|
||||||
@ -86,12 +86,6 @@ public:
|
|||||||
ERR_RUNTIME = QSE_AWK_ERUNTIME,
|
ERR_RUNTIME = QSE_AWK_ERUNTIME,
|
||||||
ERR_BLKNST = QSE_AWK_EBLKNST,
|
ERR_BLKNST = QSE_AWK_EBLKNST,
|
||||||
ERR_EXPRNST = QSE_AWK_EEXPRNST,
|
ERR_EXPRNST = QSE_AWK_EEXPRNST,
|
||||||
ERR_SINOP = QSE_AWK_ESINOP,
|
|
||||||
ERR_SINCL = QSE_AWK_ESINCL,
|
|
||||||
ERR_SINRD = QSE_AWK_ESINRD,
|
|
||||||
ERR_SOUTOP = QSE_AWK_ESOUTOP,
|
|
||||||
ERR_SOUTCL = QSE_AWK_ESOUTCL,
|
|
||||||
ERR_SOUTWR = QSE_AWK_ESOUTWR,
|
|
||||||
ERR_LXCHR = QSE_AWK_ELXCHR,
|
ERR_LXCHR = QSE_AWK_ELXCHR,
|
||||||
ERR_LXDIG = QSE_AWK_ELXDIG,
|
ERR_LXDIG = QSE_AWK_ELXDIG,
|
||||||
ERR_LXUNG = QSE_AWK_ELXUNG,
|
ERR_LXUNG = QSE_AWK_ELXUNG,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: awk.h 240 2009-07-19 13:02:33Z hyunghwan.chung $
|
* $Id: awk.h 245 2009-07-25 05:18:42Z hyunghwan.chung $
|
||||||
*
|
*
|
||||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||||
|
|
||||||
@ -271,14 +271,24 @@ enum qse_awk_sio_cmd_t
|
|||||||
};
|
};
|
||||||
typedef enum qse_awk_sio_cmd_t qse_awk_sio_cmd_t;
|
typedef enum qse_awk_sio_cmd_t qse_awk_sio_cmd_t;
|
||||||
|
|
||||||
|
struct qse_awk_sio_arg_t
|
||||||
|
{
|
||||||
|
qse_char_t* name; /**< [IN] name of I/O object */
|
||||||
|
void* handle; /**< [OUT] I/O handle set by a handler */
|
||||||
|
|
||||||
|
struct qse_awk_sio_arg_t* next;
|
||||||
|
};
|
||||||
|
typedef struct qse_awk_sio_arg_t qse_awk_sio_arg_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The qse_awk_sio_fun_t type defines a source IO function
|
* The qse_awk_sio_fun_t type defines a source IO function
|
||||||
*/
|
*/
|
||||||
typedef qse_ssize_t (*qse_awk_sio_fun_t) (
|
typedef qse_ssize_t (*qse_awk_sio_fun_t) (
|
||||||
qse_awk_t* awk,
|
qse_awk_t* awk,
|
||||||
qse_awk_sio_cmd_t cmd,
|
qse_awk_sio_cmd_t cmd,
|
||||||
qse_char_t* data,
|
qse_awk_sio_arg_t* arg,
|
||||||
qse_size_t count
|
qse_char_t* data,
|
||||||
|
qse_size_t count
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -616,14 +626,6 @@ enum qse_awk_errnum_t
|
|||||||
QSE_AWK_EBLKNST, /**< block nested too deeply */
|
QSE_AWK_EBLKNST, /**< block nested too deeply */
|
||||||
QSE_AWK_EEXPRNST,/**< expression nested too deeply */
|
QSE_AWK_EEXPRNST,/**< expression nested too deeply */
|
||||||
|
|
||||||
QSE_AWK_ESINOP, /**< failed to open source input */
|
|
||||||
QSE_AWK_ESINCL, /**< failed to close source output */
|
|
||||||
QSE_AWK_ESINRD, /**< failed to read source input */
|
|
||||||
|
|
||||||
QSE_AWK_ESOUTOP, /**< failed to open source output */
|
|
||||||
QSE_AWK_ESOUTCL, /**< failed to close source output */
|
|
||||||
QSE_AWK_ESOUTWR, /**< failed to write source output */
|
|
||||||
|
|
||||||
QSE_AWK_ELXCHR, /**< invalid character '${0}' */
|
QSE_AWK_ELXCHR, /**< invalid character '${0}' */
|
||||||
QSE_AWK_ELXDIG, /**< invalid digit '${0}' */
|
QSE_AWK_ELXDIG, /**< invalid digit '${0}' */
|
||||||
QSE_AWK_ELXUNG, /**< failed to unget character */
|
QSE_AWK_ELXUNG, /**< failed to unget character */
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: err.c 240 2009-07-19 13:02:33Z hyunghwan.chung $
|
* $Id: err.c 245 2009-07-25 05:18:42Z hyunghwan.chung $
|
||||||
*
|
*
|
||||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||||
|
|
||||||
@ -43,14 +43,6 @@ const qse_char_t* qse_awk_dflerrstr (qse_awk_t* awk, qse_awk_errnum_t errnum)
|
|||||||
QSE_T("block nested too deeply"),
|
QSE_T("block nested too deeply"),
|
||||||
QSE_T("expression nested too deeply"),
|
QSE_T("expression nested too deeply"),
|
||||||
|
|
||||||
QSE_T("failed to open source input"),
|
|
||||||
QSE_T("failed to close source input"),
|
|
||||||
QSE_T("failed to read source input"),
|
|
||||||
|
|
||||||
QSE_T("failed to open source output"),
|
|
||||||
QSE_T("failed to close source output"),
|
|
||||||
QSE_T("failed to write source output"),
|
|
||||||
|
|
||||||
QSE_T("invalid character '${0}'"),
|
QSE_T("invalid character '${0}'"),
|
||||||
QSE_T("invalid digit '${0}'"),
|
QSE_T("invalid digit '${0}'"),
|
||||||
QSE_T("failed to unget character"),
|
QSE_T("failed to unget character"),
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: parse.c 241 2009-07-22 12:47:13Z hyunghwan.chung $
|
* $Id: parse.c 245 2009-07-25 05:18:42Z hyunghwan.chung $
|
||||||
*
|
*
|
||||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||||
|
|
||||||
@ -509,7 +509,8 @@ static int parse (qse_awk_t* awk)
|
|||||||
{
|
{
|
||||||
/* cannot open the source file.
|
/* cannot open the source file.
|
||||||
* it doesn't even have to call CLOSE */
|
* it doesn't even have to call CLOSE */
|
||||||
if (ISNOERR(awk)) SETERR (awk, QSE_AWK_ESINOP);
|
if (ISNOERR(awk))
|
||||||
|
SETERRARG (awk, QSE_AWK_EOPEN, 0, QSE_T("<SIN>"), 5);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -581,7 +582,8 @@ exit_parse:
|
|||||||
{
|
{
|
||||||
/* this is to keep the earlier error above
|
/* this is to keep the earlier error above
|
||||||
* that might be more critical than this */
|
* that might be more critical than this */
|
||||||
if (ISNOERR(awk)) SETERR (awk, QSE_AWK_ESINCL);
|
if (ISNOERR(awk))
|
||||||
|
SETERRARG (awk, QSE_AWK_ECLOSE, 0, QSE_T("<SIN>"), 5);
|
||||||
n = -1;
|
n = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -606,6 +608,14 @@ static int begin_include (qse_awk_t* awk)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CLRERR (awk);
|
||||||
|
op = awk->src.ios.in (awk, QSE_AWK_SIO_OPEN, QSE_NULL, 0);
|
||||||
|
if (op <= -1)
|
||||||
|
{
|
||||||
|
if (ISNOERR(awk)) SETERRTOK (awk, QSE_AWK_EOPEN);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
/* TODO: implement this */
|
/* TODO: implement this */
|
||||||
SETERRLIN (awk, QSE_AWK_ENOSUP, awk->ptoken.line);
|
SETERRLIN (awk, QSE_AWK_ENOSUP, awk->ptoken.line);
|
||||||
return -1;
|
return -1;
|
||||||
@ -4977,7 +4987,8 @@ static int get_char (qse_awk_t* awk)
|
|||||||
);
|
);
|
||||||
if (n <= -1)
|
if (n <= -1)
|
||||||
{
|
{
|
||||||
if (ISNOERR(awk)) SETERR (awk, QSE_AWK_ESINRD);
|
if (ISNOERR(awk))
|
||||||
|
SETERRARG (awk, QSE_AWK_EREAD, 0, QSE_T("<SIN>"), 5);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5482,7 +5493,8 @@ static int deparse (qse_awk_t* awk)
|
|||||||
op = awk->src.ios.out (awk, QSE_AWK_SIO_OPEN, QSE_NULL, 0);
|
op = awk->src.ios.out (awk, QSE_AWK_SIO_OPEN, QSE_NULL, 0);
|
||||||
if (op <= -1)
|
if (op <= -1)
|
||||||
{
|
{
|
||||||
if (ISNOERR(awk)) SETERR (awk, QSE_AWK_ESOUTOP);
|
if (ISNOERR(awk))
|
||||||
|
SETERRARG (awk, QSE_AWK_EOPEN, 0, QSE_T("<SOUT>"), 6);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5690,7 +5702,8 @@ exit_deparse:
|
|||||||
{
|
{
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
{
|
{
|
||||||
if (ISNOERR(awk)) SETERR (awk, QSE_AWK_ESOUTCL);
|
if (ISNOERR(awk))
|
||||||
|
SETERRARG (awk, QSE_AWK_ECLOSE, 0, QSE_T("<SOUT>"), 6);
|
||||||
n = -1;
|
n = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5781,7 +5794,6 @@ static int flush_out (qse_awk_t* awk)
|
|||||||
while (awk->src.shared.buf_pos < awk->src.shared.buf_len)
|
while (awk->src.shared.buf_pos < awk->src.shared.buf_len)
|
||||||
{
|
{
|
||||||
CLRERR (awk);
|
CLRERR (awk);
|
||||||
|
|
||||||
n = awk->src.ios.out (
|
n = awk->src.ios.out (
|
||||||
awk, QSE_AWK_SIO_WRITE,
|
awk, QSE_AWK_SIO_WRITE,
|
||||||
&awk->src.shared.buf[awk->src.shared.buf_pos],
|
&awk->src.shared.buf[awk->src.shared.buf_pos],
|
||||||
@ -5789,7 +5801,8 @@ static int flush_out (qse_awk_t* awk)
|
|||||||
);
|
);
|
||||||
if (n <= 0)
|
if (n <= 0)
|
||||||
{
|
{
|
||||||
if (ISNOERR(awk)) SETERR (awk, QSE_AWK_ESOUTWR);
|
if (ISNOERR(awk))
|
||||||
|
SETERRARG (awk, QSE_AWK_EWRITE, 0, QSE_T("<SOUT>"), 6);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: std.c 237 2009-07-16 12:43:47Z hyunghwan.chung $
|
* $Id: std.c 245 2009-07-25 05:18:42Z hyunghwan.chung $
|
||||||
*
|
*
|
||||||
Copyright 2006-2009 Chung, Hyung-Hwan.
|
Copyright 2006-2009 Chung, Hyung-Hwan.
|
||||||
|
|
||||||
@ -157,7 +157,7 @@ void* qse_awk_getxtnstd (qse_awk_t* awk)
|
|||||||
|
|
||||||
static qse_ssize_t sf_in (
|
static qse_ssize_t sf_in (
|
||||||
qse_awk_t* awk, qse_awk_sio_cmd_t cmd,
|
qse_awk_t* awk, qse_awk_sio_cmd_t cmd,
|
||||||
qse_char_t* data, qse_size_t size)
|
qse_awk_sio_arg_t* arg, qse_char_t* data, qse_size_t size)
|
||||||
{
|
{
|
||||||
xtn_t* xtn = QSE_XTN (awk);
|
xtn_t* xtn = QSE_XTN (awk);
|
||||||
|
|
||||||
@ -182,7 +182,17 @@ static qse_ssize_t sf_in (
|
|||||||
xtn->s.in.u.file,
|
xtn->s.in.u.file,
|
||||||
QSE_SIO_READ
|
QSE_SIO_READ
|
||||||
);
|
);
|
||||||
if (xtn->s.in.handle == QSE_NULL) return -1;
|
if (xtn->s.in.handle == QSE_NULL)
|
||||||
|
{
|
||||||
|
qse_cstr_t arg;
|
||||||
|
arg.ptr = xtn->s.in.u.file;
|
||||||
|
arg.len = qse_strlen(arg.ptr);
|
||||||
|
qse_awk_seterror (
|
||||||
|
awk, QSE_AWK_EOPEN,
|
||||||
|
0, &arg
|
||||||
|
);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
@ -214,8 +224,21 @@ static qse_ssize_t sf_in (
|
|||||||
{
|
{
|
||||||
case QSE_AWK_PARSESTD_FILE:
|
case QSE_AWK_PARSESTD_FILE:
|
||||||
case QSE_AWK_PARSESTD_STDIO:
|
case QSE_AWK_PARSESTD_STDIO:
|
||||||
|
{
|
||||||
|
qse_ssize_t n;
|
||||||
|
|
||||||
QSE_ASSERT (xtn->s.in.handle != QSE_NULL);
|
QSE_ASSERT (xtn->s.in.handle != QSE_NULL);
|
||||||
return qse_sio_getsn (xtn->s.in.handle, data, size);
|
n = qse_sio_getsn (xtn->s.in.handle, data, size);
|
||||||
|
if (n == -1)
|
||||||
|
{
|
||||||
|
qse_cstr_t arg;
|
||||||
|
arg.ptr = xtn->s.in.u.file;
|
||||||
|
arg.len = qse_strlen(arg.ptr);
|
||||||
|
qse_awk_seterror (
|
||||||
|
awk, QSE_AWK_EREAD, 0, &arg);
|
||||||
|
}
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
case QSE_AWK_PARSESTD_CP:
|
case QSE_AWK_PARSESTD_CP:
|
||||||
{
|
{
|
||||||
@ -245,7 +268,7 @@ static qse_ssize_t sf_in (
|
|||||||
|
|
||||||
static qse_ssize_t sf_out (
|
static qse_ssize_t sf_out (
|
||||||
qse_awk_t* awk, qse_awk_sio_cmd_t cmd,
|
qse_awk_t* awk, qse_awk_sio_cmd_t cmd,
|
||||||
qse_char_t* data, qse_size_t size)
|
qse_awk_sio_arg_t* arg, qse_char_t* data, qse_size_t size)
|
||||||
{
|
{
|
||||||
xtn_t* xtn = QSE_XTN (awk);
|
xtn_t* xtn = QSE_XTN (awk);
|
||||||
|
|
||||||
@ -272,7 +295,17 @@ static qse_ssize_t sf_out (
|
|||||||
QSE_SIO_CREATE |
|
QSE_SIO_CREATE |
|
||||||
QSE_SIO_TRUNCATE
|
QSE_SIO_TRUNCATE
|
||||||
);
|
);
|
||||||
if (xtn->s.out.handle == QSE_NULL) return -1;
|
if (xtn->s.out.handle == QSE_NULL)
|
||||||
|
{
|
||||||
|
qse_cstr_t arg;
|
||||||
|
arg.ptr = xtn->s.out.u.file;
|
||||||
|
arg.len = qse_strlen(arg.ptr);
|
||||||
|
qse_awk_seterror (
|
||||||
|
awk, QSE_AWK_EOPEN,
|
||||||
|
0, &arg
|
||||||
|
);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
@ -319,8 +352,21 @@ static qse_ssize_t sf_out (
|
|||||||
{
|
{
|
||||||
case QSE_AWK_PARSESTD_FILE:
|
case QSE_AWK_PARSESTD_FILE:
|
||||||
case QSE_AWK_PARSESTD_STDIO:
|
case QSE_AWK_PARSESTD_STDIO:
|
||||||
|
{
|
||||||
|
qse_ssize_t n;
|
||||||
QSE_ASSERT (xtn->s.out.handle != QSE_NULL);
|
QSE_ASSERT (xtn->s.out.handle != QSE_NULL);
|
||||||
return qse_sio_putsn (xtn->s.out.handle, data, size);
|
n = qse_sio_putsn (xtn->s.out.handle, data, size);
|
||||||
|
if (n == -1)
|
||||||
|
{
|
||||||
|
qse_cstr_t arg;
|
||||||
|
arg.ptr = xtn->s.in.u.file;
|
||||||
|
arg.len = qse_strlen(arg.ptr);
|
||||||
|
qse_awk_seterror (
|
||||||
|
awk, QSE_AWK_EWRITE, 0, &arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
case QSE_AWK_PARSESTD_CP:
|
case QSE_AWK_PARSESTD_CP:
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user