deprecated QSE_AWK_BASEONE

This commit is contained in:
hyung-hwan 2009-02-18 07:55:48 +00:00
parent c3b04c6fc1
commit 70b517578e
8 changed files with 30 additions and 55 deletions

View File

@ -232,7 +232,6 @@ static struct
{ QSE_T("rio"), QSE_AWK_RIO },
{ QSE_T("rwpipe"), QSE_AWK_RWPIPE },
{ QSE_T("newline"), QSE_AWK_NEWLINE },
{ QSE_T("baseone"), QSE_AWK_BASEONE },
{ QSE_T("stripspaces"), QSE_AWK_STRIPSPACES },
{ QSE_T("nextofile"), QSE_AWK_NEXTOFILE },
{ QSE_T("crfl"), QSE_AWK_CRLF },

View File

@ -574,7 +574,6 @@ public:
/** Can terminate a statement with a new line */
OPT_NEWLINE = QSE_AWK_NEWLINE,
OPT_BASEONE = QSE_AWK_BASEONE,
OPT_STRIPSPACES = QSE_AWK_STRIPSPACES,
/** Support the nextofile statement */

View File

@ -261,9 +261,6 @@ enum qse_awk_option_t
/* can terminate a statement with a new line */
QSE_AWK_NEWLINE = (1 << 9),
/* use 1 as the start index for string operations and ARGV */
QSE_AWK_BASEONE = (1 << 10),
/* strip off leading and trailing spaces when splitting a record
* into fields with a regular expression.
*
@ -292,7 +289,11 @@ enum qse_awk_option_t
QSE_AWK_MAPTOVAR = (1 << 15),
/* allows BEGIN, END, pattern-action blocks */
QSE_AWK_PABLOCK = (1 << 16)
QSE_AWK_PABLOCK = (1 << 16),
/* option aggregtes */
QSE_AWK_CLASSIC = QSE_AWK_IMPLICIT | QSE_AWK_RIO |
QSE_AWK_NEWLINE | QSE_AWK_PABLOCK
};
/* error code */

View File

@ -1225,14 +1225,6 @@ int Awk::open ()
qse_map_setfreeer (functionMap, QSE_MAP_VAL, freeFunctionMapValue);
qse_map_setscale (functionMap, QSE_MAP_KEY, QSE_SIZEOF(qse_char_t));
int opt =
OPT_IMPLICIT |
OPT_RIO |
OPT_NEWLINE |
OPT_BASEONE |
OPT_PABLOCK;
qse_awk_setoption (awk, opt);
runCallback = false;
return 0;
}

View File

@ -150,7 +150,7 @@ qse_awk_t* qse_awk_open (qse_mmgr_t* mmgr, qse_size_t xtn, qse_awk_prm_t* prm)
qse_lda_setcopier (awk->parse.params, QSE_LDA_COPIER_INLINE);
qse_lda_setscale (awk->parse.params, QSE_SIZEOF(qse_char_t));
awk->option = 0;
awk->option = QSE_AWK_CLASSIC;
awk->errnum = QSE_AWK_ENOERR;
awk->errlin = 0;
awk->stopall = QSE_FALSE;
@ -364,7 +364,6 @@ void qse_awk_setoption (qse_awk_t* awk, int opt)
awk->option = opt;
}
void qse_awk_stopall (qse_awk_t* awk)
{
awk->stopall = QSE_TRUE;

View File

@ -459,9 +459,7 @@ static int fnc_index (
}
ptr = qse_strxnstr (str0, len0, str1, len1);
idx = (ptr == QSE_NULL)? -1: (qse_long_t)(ptr - str0);
if (qse_awk_getoption(run->awk) & QSE_AWK_BASEONE) idx = idx + 1;
idx = (ptr == QSE_NULL)? 0: ((qse_long_t)(ptr-str0) + 1);
if (a0->type != QSE_AWK_VAL_STR) QSE_AWK_FREE (run->awk, str0);
if (a1->type != QSE_AWK_VAL_STR) QSE_AWK_FREE (run->awk, str1);
@ -563,7 +561,7 @@ static int fnc_substr (
if (n == 1) lcount = (qse_long_t)rcount;
}
if (qse_awk_getoption(run->awk) & QSE_AWK_BASEONE) lindex = lindex - 1;
lindex = lindex - 1;
if (lindex >= (qse_long_t)len) lindex = (qse_long_t)len;
else if (lindex < 0) lindex = 0;
@ -593,7 +591,7 @@ static int fnc_split (
qse_awk_val_t* a0, * a1, * a2, * t1, * t2, ** a1_ref;
qse_char_t* str, * str_free, * p, * tok;
qse_size_t str_len, str_left, tok_len;
qse_long_t sta, num;
qse_long_t num;
qse_char_t key[QSE_SIZEOF(qse_long_t)*8+2];
qse_size_t key_len;
qse_char_t* fs_ptr, * fs_free;
@ -740,8 +738,7 @@ static int fnc_split (
qse_awk_rtx_refupval (run, *a1_ref);
p = str; str_left = str_len;
sta = (qse_awk_getoption(run->awk) & QSE_AWK_BASEONE)? 1: 0;
num = sta;
num = 1;
while (p != QSE_NULL)
{
@ -830,7 +827,7 @@ static int fnc_split (
if (fs_free != QSE_NULL) QSE_AWK_FREE (run->awk, fs_free);
if (fs_rex_free != QSE_NULL) QSE_AWK_FREEREX (run->awk, fs_rex_free);
if (sta == 1) num--;
num--;
t1 = qse_awk_rtx_makeintval (run, num);
if (t1 == QSE_NULL)
@ -1301,8 +1298,7 @@ static int fnc_match (
if (n == -1) return -1;
idx = (n == 0)? -1: (qse_long_t)(mat_ptr - str0);
if (qse_awk_getoption(run->awk) & QSE_AWK_BASEONE) idx = idx + 1;
idx = (n == 0)? 0: ((qse_long_t)(mat_ptr-str0) + 1);
a0 = qse_awk_rtx_makeintval (run, idx);
if (a0 == QSE_NULL)

View File

@ -1005,16 +1005,8 @@ static int build_runarg (
return -1;
}
if (qse_awk_getoption(run->awk) & QSE_AWK_BASEONE)
{
key_len = qse_awk_longtostr (argc+1,
10, QSE_NULL, key, QSE_COUNTOF(key));
}
else
{
key_len = qse_awk_longtostr (argc,
10, QSE_NULL, key, QSE_COUNTOF(key));
}
QSE_ASSERT (key_len != (qse_size_t)-1);
/* increment reference count of v_tmp in advance as if

View File

@ -38,7 +38,7 @@ typedef struct xtn_t
{
const qse_char_t*const* files;
const qse_char_t* str;
} p;
} u;
qse_size_t index; /* current file index */
qse_sio_t* handle; /* the handle to an open file */
} in;
@ -60,13 +60,13 @@ typedef struct rxtn_t
struct
{
struct {
const qse_char_t** files;
const qse_char_t*const* files;
qse_size_t index;
} in;
struct
{
const qse_char_t** files;
const qse_char_t*const* files;
qse_size_t index;
} out;
} c; /* console */
@ -142,9 +142,7 @@ qse_awk_t* qse_awk_opensimple (void)
QSE_MEMSET (xtn, 0, QSE_SIZEOF(xtn_t));
/* set default options */
qse_awk_setoption (awk,
QSE_AWK_IMPLICIT | QSE_AWK_RIO | QSE_AWK_NEWLINE |
QSE_AWK_BASEONE | QSE_AWK_PABLOCK);
qse_awk_setoption (awk, QSE_AWK_CLASSIC);
/* add intrinsic functions */
if (add_functions (awk) == -1)
@ -168,9 +166,10 @@ static qse_ssize_t sf_in (
{
if (xtn->s.in.type == QSE_AWK_SOURCE_FILES)
{
if (xtn->s.in.p.files[xtn->s.in.index] == QSE_NULL) return 0;
if (xtn->s.in.u.files == QSE_NULL) return -1;
if (xtn->s.in.u.files[xtn->s.in.index] == QSE_NULL) return 0;
if (xtn->s.in.p.files[xtn->s.in.index][0] == QSE_T('\0'))
if (xtn->s.in.u.files[xtn->s.in.index][0] == QSE_T('\0'))
{
xtn->s.in.handle = qse_sio_in;
}
@ -179,15 +178,13 @@ static qse_ssize_t sf_in (
xtn->s.in.handle = qse_sio_open (
awk->mmgr,
0,
xtn->s.in.p.files[xtn->s.in.index],
xtn->s.in.u.files[xtn->s.in.index],
QSE_SIO_READ
);
if (xtn->s.in.handle == QSE_NULL) return -1;
}
/*
qse_awk_setsinname ();
*/
//qse_awk_setsource (awk, xtn->s.in.u.files[xtn->s.in.index]);
}
return 1;
@ -216,10 +213,10 @@ static qse_ssize_t sf_in (
sio = xtn->s.in.handle;
n = qse_sio_getsn (sio, data, size);
if (n == 0 && xtn->s.in.p.files[++xtn->s.in.index] != QSE_NULL)
if (n == 0 && xtn->s.in.u.files[++xtn->s.in.index] != QSE_NULL)
{
if (sio != qse_sio_in) qse_sio_close (sio);
if (xtn->s.in.p.files[xtn->s.in.index][0] == QSE_T('\0'))
if (xtn->s.in.u.files[xtn->s.in.index][0] == QSE_T('\0'))
{
xtn->s.in.handle = qse_sio_in;
}
@ -228,7 +225,7 @@ static qse_ssize_t sf_in (
xtn->s.in.handle = qse_sio_open (
awk->mmgr,
0,
xtn->s.in.p.files[xtn->s.in.index],
xtn->s.in.u.files[xtn->s.in.index],
QSE_SIO_READ
);
if (xtn->s.in.handle == QSE_NULL) return -1;
@ -244,9 +241,9 @@ static qse_ssize_t sf_in (
}
else
{
while (n < size && xtn->s.in.p.str[xtn->s.in.index] != QSE_T('\0'))
while (n < size && xtn->s.in.u.str[xtn->s.in.index] != QSE_T('\0'))
{
data[n++] = xtn->s.in.p.str[xtn->s.in.index++];
data[n++] = xtn->s.in.u.str[xtn->s.in.index++];
}
}
@ -318,11 +315,11 @@ int qse_awk_parsesimple (
if (ist == QSE_AWK_SOURCE_FILES)
{
xtn->s.in.p.files = (const qse_char_t* const*)isp;
xtn->s.in.u.files = (const qse_char_t*const*)isp;
}
else if (ist == QSE_AWK_SOURCE_STRING)
{
xtn->s.in.p.str = (const qse_char_t*)isp;
xtn->s.in.u.str = (const qse_char_t*)isp;
}
else
{