*** empty log message ***
This commit is contained in:
parent
38ff71c2f2
commit
fa80f5dade
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: run.c,v 1.60 2006-04-19 03:42:08 bacon Exp $
|
* $Id: run.c,v 1.61 2006-04-19 04:18:43 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/awk/awk_i.h>
|
#include <xp/awk/awk_i.h>
|
||||||
@ -763,6 +763,7 @@ static xp_awk_val_t* __do_assignment (
|
|||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
|
/* TODO: need to check if the old value is a map?? prevent the assignment? */
|
||||||
n = xp_awk_map_putx (
|
n = xp_awk_map_putx (
|
||||||
&awk->run.named, var->id.name, val, XP_NULL);
|
&awk->run.named, var->id.name, val, XP_NULL);
|
||||||
if (n < 0) PANIC (awk, XP_AWK_ENOMEM);
|
if (n < 0) PANIC (awk, XP_AWK_ENOMEM);
|
||||||
@ -771,18 +772,21 @@ static xp_awk_val_t* __do_assignment (
|
|||||||
}
|
}
|
||||||
else if (var->type == XP_AWK_NDE_GLOBAL)
|
else if (var->type == XP_AWK_NDE_GLOBAL)
|
||||||
{
|
{
|
||||||
|
/* TODO: need to check if the old value is a map?? prevent the assignment? */
|
||||||
xp_awk_refdownval (awk, STACK_GLOBAL(awk,var->id.idxa));
|
xp_awk_refdownval (awk, STACK_GLOBAL(awk,var->id.idxa));
|
||||||
STACK_GLOBAL(awk,var->id.idxa) = val;
|
STACK_GLOBAL(awk,var->id.idxa) = val;
|
||||||
xp_awk_refupval (val);
|
xp_awk_refupval (val);
|
||||||
}
|
}
|
||||||
else if (var->type == XP_AWK_NDE_LOCAL)
|
else if (var->type == XP_AWK_NDE_LOCAL)
|
||||||
{
|
{
|
||||||
|
/* TODO: need to check if the old value is a map?? prevent the assignment? */
|
||||||
xp_awk_refdownval (awk, STACK_LOCAL(awk,var->id.idxa));
|
xp_awk_refdownval (awk, STACK_LOCAL(awk,var->id.idxa));
|
||||||
STACK_LOCAL(awk,var->id.idxa) = val;
|
STACK_LOCAL(awk,var->id.idxa) = val;
|
||||||
xp_awk_refupval (val);
|
xp_awk_refupval (val);
|
||||||
}
|
}
|
||||||
else if (var->type == XP_AWK_NDE_ARG)
|
else if (var->type == XP_AWK_NDE_ARG)
|
||||||
{
|
{
|
||||||
|
/* TODO: need to check if the old value is a map?? prevent the assignment? */
|
||||||
xp_awk_refdownval (awk, STACK_ARG(awk,var->id.idxa));
|
xp_awk_refdownval (awk, STACK_ARG(awk,var->id.idxa));
|
||||||
STACK_ARG(awk,var->id.idxa) = val;
|
STACK_ARG(awk,var->id.idxa) = val;
|
||||||
xp_awk_refupval (val);
|
xp_awk_refupval (val);
|
||||||
@ -843,7 +847,8 @@ static xp_awk_val_t* __do_assignment_map (
|
|||||||
if (tmp == XP_NULL) PANIC (awk, XP_AWK_ENOMEM);
|
if (tmp == XP_NULL) PANIC (awk, XP_AWK_ENOMEM);
|
||||||
|
|
||||||
/* decrease the reference count of the previous value -
|
/* decrease the reference count of the previous value -
|
||||||
* in fact, this is not necessary as map is always xp_awk_val_nil here. */
|
* in fact, this is not necessary as map is always
|
||||||
|
* xp_awk_val_nil here. */
|
||||||
xp_awk_refdownval (awk, (xp_awk_val_t*)map);
|
xp_awk_refdownval (awk, (xp_awk_val_t*)map);
|
||||||
|
|
||||||
if (var->type == XP_AWK_NDE_GLOBALIDX)
|
if (var->type == XP_AWK_NDE_GLOBALIDX)
|
||||||
|
58
ase/awk/sa.c
58
ase/awk/sa.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: sa.c,v 1.16 2006-04-16 04:31:38 bacon Exp $
|
* $Id: sa.c,v 1.17 2006-04-19 04:18:43 bacon Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <xp/awk/awk_i.h>
|
#include <xp/awk/awk_i.h>
|
||||||
@ -162,7 +162,7 @@ xp_str_t* xp_str_open (xp_str_t* str, xp_size_t capa)
|
|||||||
return XP_NULL;
|
return XP_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
str->size = 0;
|
str->size = 0;
|
||||||
str->capa = capa;
|
str->capa = capa;
|
||||||
str->buf[0] = XP_CHAR('\0');
|
str->buf[0] = XP_CHAR('\0');
|
||||||
|
|
||||||
@ -252,8 +252,10 @@ static xp_char_t* __adjust_format (const xp_char_t* format)
|
|||||||
|
|
||||||
if (xp_str_open (&str, 256) == XP_NULL) return XP_NULL;
|
if (xp_str_open (&str, 256) == XP_NULL) return XP_NULL;
|
||||||
|
|
||||||
while (*fp != XP_CHAR('\0')) {
|
while (*fp != XP_CHAR('\0'))
|
||||||
while (*fp != XP_CHAR('\0') && *fp != XP_CHAR('%')) {
|
{
|
||||||
|
while (*fp != XP_CHAR('\0') && *fp != XP_CHAR('%'))
|
||||||
|
{
|
||||||
ADDC (str, *fp++);
|
ADDC (str, *fp++);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,12 +268,15 @@ static xp_char_t* __adjust_format (const xp_char_t* format)
|
|||||||
ch = *fp++;
|
ch = *fp++;
|
||||||
|
|
||||||
/* flags */
|
/* flags */
|
||||||
for (;;) {
|
for (;;)
|
||||||
|
{
|
||||||
if (ch == XP_CHAR(' ') || ch == XP_CHAR('+') ||
|
if (ch == XP_CHAR(' ') || ch == XP_CHAR('+') ||
|
||||||
ch == XP_CHAR('-') || ch == XP_CHAR('#')) {
|
ch == XP_CHAR('-') || ch == XP_CHAR('#'))
|
||||||
|
{
|
||||||
ADDC (str, ch);
|
ADDC (str, ch);
|
||||||
}
|
}
|
||||||
else if (ch == XP_CHAR('0')) {
|
else if (ch == XP_CHAR('0'))
|
||||||
|
{
|
||||||
ADDC (str, ch);
|
ADDC (str, ch);
|
||||||
ch = *fp++;
|
ch = *fp++;
|
||||||
break;
|
break;
|
||||||
@ -283,21 +288,26 @@ static xp_char_t* __adjust_format (const xp_char_t* format)
|
|||||||
|
|
||||||
/* check the width */
|
/* check the width */
|
||||||
if (ch == XP_CHAR('*')) ADDC (str, ch);
|
if (ch == XP_CHAR('*')) ADDC (str, ch);
|
||||||
else {
|
else
|
||||||
while (xp_isdigit(ch)) {
|
{
|
||||||
|
while (xp_isdigit(ch))
|
||||||
|
{
|
||||||
ADDC (str, ch);
|
ADDC (str, ch);
|
||||||
ch = *fp++;
|
ch = *fp++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* precision */
|
/* precision */
|
||||||
if (ch == XP_CHAR('.')) {
|
if (ch == XP_CHAR('.'))
|
||||||
|
{
|
||||||
ADDC (str, ch);
|
ADDC (str, ch);
|
||||||
ch = *fp++;
|
ch = *fp++;
|
||||||
|
|
||||||
if (ch == XP_CHAR('*')) ADDC (str, ch);
|
if (ch == XP_CHAR('*')) ADDC (str, ch);
|
||||||
else {
|
else
|
||||||
while (xp_isdigit(ch)) {
|
{
|
||||||
|
while (xp_isdigit(ch))
|
||||||
|
{
|
||||||
ADDC (str, ch);
|
ADDC (str, ch);
|
||||||
ch = *fp++;
|
ch = *fp++;
|
||||||
}
|
}
|
||||||
@ -305,9 +315,11 @@ static xp_char_t* __adjust_format (const xp_char_t* format)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* modifier */
|
/* modifier */
|
||||||
for (modifier = 0;;) {
|
for (modifier = 0;;)
|
||||||
|
{
|
||||||
if (ch == XP_CHAR('h')) modifier = MOD_SHORT;
|
if (ch == XP_CHAR('h')) modifier = MOD_SHORT;
|
||||||
else if (ch == XP_CHAR('l')) {
|
else if (ch == XP_CHAR('l'))
|
||||||
|
{
|
||||||
modifier = (modifier == MOD_LONG)? MOD_LONGLONG: MOD_LONG;
|
modifier = (modifier == MOD_LONG)? MOD_LONGLONG: MOD_LONG;
|
||||||
}
|
}
|
||||||
else break;
|
else break;
|
||||||
@ -317,13 +329,15 @@ static xp_char_t* __adjust_format (const xp_char_t* format)
|
|||||||
|
|
||||||
/* type */
|
/* type */
|
||||||
if (ch == XP_CHAR('%')) ADDC (str, ch);
|
if (ch == XP_CHAR('%')) ADDC (str, ch);
|
||||||
else if (ch == XP_CHAR('c') || ch == XP_CHAR('s')) {
|
else if (ch == XP_CHAR('c') || ch == XP_CHAR('s'))
|
||||||
|
{
|
||||||
#if !defined(XP_CHAR_IS_MCHAR) && !defined(_WIN32)
|
#if !defined(XP_CHAR_IS_MCHAR) && !defined(_WIN32)
|
||||||
ADDC (str, 'l');
|
ADDC (str, 'l');
|
||||||
#endif
|
#endif
|
||||||
ADDC (str, ch);
|
ADDC (str, ch);
|
||||||
}
|
}
|
||||||
else if (ch == XP_CHAR('C') || ch == XP_CHAR('S')) {
|
else if (ch == XP_CHAR('C') || ch == XP_CHAR('S'))
|
||||||
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
ADDC (str, ch);
|
ADDC (str, ch);
|
||||||
#else
|
#else
|
||||||
@ -335,14 +349,18 @@ static xp_char_t* __adjust_format (const xp_char_t* format)
|
|||||||
}
|
}
|
||||||
else if (ch == XP_CHAR('d') || ch == XP_CHAR('i') ||
|
else if (ch == XP_CHAR('d') || ch == XP_CHAR('i') ||
|
||||||
ch == XP_CHAR('o') || ch == XP_CHAR('u') ||
|
ch == XP_CHAR('o') || ch == XP_CHAR('u') ||
|
||||||
ch == XP_CHAR('x') || ch == XP_CHAR('X')) {
|
ch == XP_CHAR('x') || ch == XP_CHAR('X'))
|
||||||
if (modifier == MOD_SHORT) {
|
{
|
||||||
|
if (modifier == MOD_SHORT)
|
||||||
|
{
|
||||||
ADDC (str, 'h');
|
ADDC (str, 'h');
|
||||||
}
|
}
|
||||||
else if (modifier == MOD_LONG) {
|
else if (modifier == MOD_LONG)
|
||||||
|
{
|
||||||
ADDC (str, 'l');
|
ADDC (str, 'l');
|
||||||
}
|
}
|
||||||
else if (modifier == MOD_LONGLONG) {
|
else if (modifier == MOD_LONGLONG)
|
||||||
|
{
|
||||||
#if defined(_WIN32) && !defined(__LCC__)
|
#if defined(_WIN32) && !defined(__LCC__)
|
||||||
ADDC (str, 'I');
|
ADDC (str, 'I');
|
||||||
ADDC (str, '6');
|
ADDC (str, '6');
|
||||||
|
19
ase/test/awk/t1.awk
Normal file
19
ase/test/awk/t1.awk
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
function sum(i, k, y)
|
||||||
|
{
|
||||||
|
|
||||||
|
y = 0;
|
||||||
|
for (k = i; k; k = k - 1)
|
||||||
|
{
|
||||||
|
y = y + k;
|
||||||
|
}
|
||||||
|
|
||||||
|
return y;
|
||||||
|
y = 10;
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
|
BEGIN {
|
||||||
|
//s = sum(10000000);
|
||||||
|
s = sum (100);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user