*** empty log message ***

This commit is contained in:
hyung-hwan 2006-09-30 17:03:11 +00:00
parent 95b904c8e9
commit ec0067a430
7 changed files with 124 additions and 54 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: err.c,v 1.40 2006-09-14 06:40:06 bacon Exp $
* $Id: err.c,v 1.41 2006-09-30 17:02:35 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -16,7 +16,7 @@ const xp_char_t* xp_awk_geterrstr (int errnum)
XP_T("no error"),
XP_T("out of memory"),
XP_T("invalid parameter"),
XP_T("run-time error"),
XP_T("general run-time error"),
XP_T("one or more running instances"),
XP_T("too many running instances"),
XP_T("recursion too deep"),

View File

@ -1,5 +1,5 @@
/*
* $Id: func.c,v 1.53 2006-09-22 14:04:25 bacon Exp $
* $Id: func.c,v 1.54 2006-09-30 17:02:35 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -888,6 +888,14 @@ static int __substitute (xp_awk_t* awk, void* run, xp_long_t max_count)
else
{
/* operation is on a2 */
if (((xp_awk_val_ref_t*)a2)->id == XP_AWK_VAL_REF_POS)
{
FREE_A_PTRS (awk);
/* a map is not allowed as the third parameter */
xp_awk_seterrnum (run, XP_AWK_EMAPNOTALLOWED);
return -1;
}
a2_ref = (xp_awk_val_t**)((xp_awk_val_ref_t*)a2)->adr;
if ((*a2_ref)->type == XP_AWK_VAL_MAP)
{
@ -1009,8 +1017,8 @@ static int __substitute (xp_awk_t* awk, void* run, xp_long_t max_count)
}
sub_count++;
cur_ptr = mat_ptr + mat_len;
cur_len = cur_len - ((mat_ptr - cur_ptr) + mat_len);
cur_ptr = mat_ptr + mat_len;
}
FREE_A0_REX (awk, rex);

View File

@ -1,5 +1,5 @@
/*
* $Id: run.c,v 1.212 2006-09-29 11:18:13 bacon Exp $
* $Id: run.c,v 1.213 2006-09-30 17:02:36 bacon Exp $
*/
#include <xp/awk/awk_i.h>
@ -1956,8 +1956,8 @@ static int __run_print (xp_awk_run_t* run, xp_awk_nde_print_t* nde)
if (p->args == XP_NULL)
{
/*
v = run->inrec.d0;
xp_awk_refupval (v);
n = xp_awk_writeextio_val (run, p->out_type, dst, v);
if (n < 0 && run->errnum != XP_AWK_EIOHANDLER)
@ -1967,6 +1967,16 @@ static int __run_print (xp_awk_run_t* run, xp_awk_nde_print_t* nde)
return -1;
}
xp_awk_refdownval (run, v);
*/
n = xp_awk_writeextio_str (
run, p->out_type, dst,
XP_AWK_STR_BUF(&run->inrec.line),
XP_AWK_STR_LEN(&run->inrec.line));
if (n < 0 && run->errnum != XP_AWK_EIOHANDLER)
{
if (out != XP_NULL) XP_AWK_FREE (run->awk, out);
return -1;
}
/* TODO: how to handle n == -1 && errnum == XP_AWK_EIOHANDLER.
* that is the user handler returned an error... */
}
@ -1974,6 +1984,18 @@ static int __run_print (xp_awk_run_t* run, xp_awk_nde_print_t* nde)
{
for (np = p->args; np != XP_NULL; np = np->next)
{
if (np != p->args)
{
n = xp_awk_writeextio_str (
run, p->out_type, dst,
run->global.ofs.ptr, run->global.ofs.len);
if (n < 0 && run->errnum != XP_AWK_EIOHANDLER)
{
if (out != XP_NULL) XP_AWK_FREE (run->awk, out);
return -1;
}
}
v = __eval_expression (run, np);
if (v == XP_NULL)
{
@ -1991,19 +2013,9 @@ static int __run_print (xp_awk_run_t* run, xp_awk_nde_print_t* nde)
}
xp_awk_refdownval (run, v);
n = xp_awk_writeextio_str (
run, p->out_type, dst,
run->global.ofs.ptr, run->global.ofs.len);
if (n < 0 && run->errnum != XP_AWK_EIOHANDLER)
{
if (out != XP_NULL) XP_AWK_FREE (run->awk, out);
return -1;
}
/* TODO: how to handle n == -1 && run->errnum == XP_AWK_EIOHANDLER.
* that is the user handler returned an error... */
/* TODO: print proper field separator */
}
}
@ -4113,6 +4125,24 @@ static xp_awk_val_t* __eval_call (
xp_awk_strlen(bfn_arg_spec) > nargs));
if (bfn_arg_spec != XP_NULL &&
bfn_arg_spec[nargs] == XP_T('r'))
{
xp_awk_val_t** ref;
xp_awk_val_t* tmp;
ref = __get_reference (run, p);
if (ref == XP_NULL)
{
UNWIND_RUN_STACK (run, nargs);
return XP_NULL;
}
/* p->type-XP_AWK_NDE_NAMED assumes that the
* derived value matches XP_AWK_VAL_REF_XXX */
v = xp_awk_makerefval (
run, p->type-XP_AWK_NDE_NAMED, ref);
}
else if (bfn_arg_spec != XP_NULL &&
bfn_arg_spec[nargs] == XP_T('x'))
{
/* a regular expression is passed to
@ -4129,6 +4159,7 @@ static xp_awk_val_t* __eval_call (
return XP_NULL;
}
#if 0
if (bfn_arg_spec != XP_NULL &&
bfn_arg_spec[nargs] == XP_T('r'))
{
@ -4163,6 +4194,7 @@ static xp_awk_val_t* __eval_call (
v = tmp;
}
#endif
if (__raw_push(run,v) == -1)
{
@ -4312,7 +4344,6 @@ static xp_awk_val_t** __get_reference (xp_awk_run_t* run, xp_awk_nde_t* nde)
run, tgt, (xp_awk_val_t**)&pair->val);
}
if (nde->type == XP_AWK_NDE_GLOBALIDX)
{
return __get_reference_indexed (run, tgt,
@ -4331,6 +4362,31 @@ static xp_awk_val_t** __get_reference (xp_awk_run_t* run, xp_awk_nde_t* nde)
(xp_awk_val_t**)&STACK_ARG(run,tgt->id.idxa));
}
if (nde->type == XP_AWK_NDE_POS)
{
int n;
xp_long_t lv;
xp_real_t rv;
xp_awk_val_t* v;
/* the position number is returned for the positional
* variable unlike other reference types. */
v = __eval_expression (run, ((xp_awk_nde_pos_t*)nde)->val);
if (v == XP_NULL) return XP_NULL;
xp_awk_refupval (v);
n = xp_awk_valtonum (run, v, &lv, &rv);
xp_awk_refdownval (run, v);
if (n == -1) PANIC (run, XP_AWK_EPOSIDX);
if (n == 1) lv = (xp_long_t)rv;
if (lv < 0) PANIC (run, XP_AWK_EPOSIDX);
/* TODO: ............................................. */
return (xp_awk_val_t**)(lv+1);
}
PANIC (run, XP_AWK_ENOTREFERENCEABLE);
}

View File

@ -1,5 +1,5 @@
/*
* $Id: tree.h,v 1.72 2006-09-11 14:29:23 bacon Exp $
* $Id: tree.h,v 1.73 2006-09-30 17:02:36 bacon Exp $
*/
#ifndef _XP_AWK_TREE_H_
@ -58,9 +58,9 @@ enum
XP_AWK_NDE_GLOBALIDX,
XP_AWK_NDE_LOCALIDX,
XP_AWK_NDE_ARGIDX,
XP_AWK_NDE_POS,
/* ---------------------------------- */
XP_AWK_NDE_POS,
XP_AWK_NDE_GETLINE,
};

View File

@ -1,5 +1,5 @@
/*
* $Id: val.h,v 1.42 2006-09-28 06:56:30 bacon Exp $
* $Id: val.h,v 1.43 2006-09-30 17:02:36 bacon Exp $
*/
#ifndef _XP_AWK_VAL_H_
@ -35,7 +35,8 @@ enum
XP_AWK_VAL_REF_NAMEDIDX,
XP_AWK_VAL_REF_GLOBALIDX,
XP_AWK_VAL_REF_LOCALIDX,
XP_AWK_VAL_REF_ARGIDX
XP_AWK_VAL_REF_ARGIDX,
XP_AWK_VAL_REF_POS
};
typedef struct xp_awk_val_nil_t xp_awk_val_nil_t;

View File

@ -1,43 +1,45 @@
BEGIN {
print "1==1 : ", (1 == 1);
print "1==0 : ", (1 == 0);
OFS="\t\t";
print "1.0==1 : " (1.0 == 1);
print "1.1==1 : " (1.1 == 1);
print "1==1 :", (1 == 1);
print "1==0 :", (1 == 0);
print "1.0!=1 : " (1.0 != 1);
print "1.1!=1 : " (1.1 != 1);
print "1.0==1 :", (1.0 == 1);
print "1.1==1 :", (1.1 == 1);
print "1.0!=1 :", (1.0 != 1);
print "1.1!=1 :", (1.1 != 1);
print "abc" == "abc";
print "abc" != "abc";
print "------------------------";
print "a == \"\" : " (a == "");
print "a >= \"\" : " (a >= "");
print "a <= \"\" : " (a <= "");
print "a > \"\" : " (a > "");
print "a < \"\" : " (a < "");
print "--------------------------";
print "a == \"\" :", (a == "");
print "a >= \"\" :", (a >= "");
print "a <= \"\" :", (a <= "");
print "a > \"\" :", (a > "");
print "a < \"\" :", (a < "");
print "------------------------";
print "a == \" \" : " (a == " ");
print "a >= \" \" : " (a >= " ");
print "a <= \" \" : " (a <= " ");
print "a > \" \" : " (a > " ");
print "a < \" \" : " (a < " ");
print "--------------------------";
print "a == \" \" :", (a == " ");
print "a >= \" \" :", (a >= " ");
print "a <= \" \" :", (a <= " ");
print "a > \" \" :", (a > " ");
print "a < \" \" :", (a < " ");
print "------------------------";
print "\"\" == a : " ("" == a);
print "\"\" >= a: " ("" >= a);
print "\"\" <= a: " ("" <= a);
print "\"\" > a: " ("" > a);
print "\"\" < a: " ("" < a);
print "--------------------------";
print "\"\" == a :", ("" == a);
print "\"\" >= a:", ("" >= a);
print "\"\" <= a:", ("" <= a);
print "\"\" > a:", ("" > a);
print "\"\" < a:", ("" < a);
print "------------------------";
print "\" \" == a : " (" " == a);
print "\" \" >= a: " (" " >= a);
print "\" \" <= a: " (" " <= a);
print "\" \" > a: " (" " > a);
print "\" \" < a: " (" " < a);
print "--------------------------";
print "\" \" == a :", (" " == a);
print "\" \" >= a:", (" " >= a);
print "\" \" <= a:", (" " <= a);
print "\" \" > a:", (" " > a);
print "\" \" < a:", (" " < a);
#a[10] = 2;
#print a == 1;

View File

@ -2,15 +2,18 @@
{
$0 = tolower($0); # remove case distinctions
# remove punctuation
#gsub(/[^[:alnum:]_[:blank:]]/, "", $0);
a=0;
gsub(/[^[:alnum:]_[:blank:]]/, " ", $a);
#gsub(/[^[:alnum:]_[:blank:]]/, " ");
for (i = 1; i <= NF; i++) freq[$i]++;
}
END {
for (word in freq)
print word, "\t", freq[word];
print word, freq[word];
}