added -v var=val to cmd/awk/awk.c

This commit is contained in:
2009-06-21 06:47:34 +00:00
parent cf606b6819
commit e66a372119
10 changed files with 348 additions and 346 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: val.c 200 2009-06-14 13:22:00Z hyunghwan.chung $
* $Id: val.c 205 2009-06-20 12:47:34Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -348,6 +348,30 @@ init:
return (qse_awk_val_t*)val;
}
qse_awk_val_t* qse_awk_rtx_makenstrval (
qse_awk_rtx_t* run, const qse_char_t* str, qse_size_t len)
{
int x;
qse_awk_val_t* v;
qse_long_t l;
qse_real_t r;
x = qse_awk_rtx_strtonum (run, 1, str, len, &l, &r);
v = qse_awk_rtx_makestrval (run, str, len);
if (v == QSE_NULL) return QSE_NULL;
if (x >= 0)
{
/* set the numeric string flag if a string
* can be converted to a number */
QSE_ASSERT (x == 0 || x == 1);
v->nstr = x + 1; /* long -> 1, real -> 2 */
}
return v;
}
qse_awk_val_t* qse_awk_rtx_makerexval (
qse_awk_rtx_t* run, const qse_char_t* buf, qse_size_t len, void* code)
{