From dee681b9398603b6a36e9c1f65a785ae92d6d258 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Sat, 6 May 2006 12:52:36 +0000 Subject: [PATCH] *** empty log message *** --- ase/awk/err.c | 94 +++++++-------- ase/awk/map.c | 4 +- ase/awk/misc.c | 60 +++++----- ase/awk/parse.c | 298 ++++++++++++++++++++++++------------------------ ase/awk/run.c | 88 +++++++------- ase/awk/sa.c | 56 ++++----- ase/awk/tree.c | 236 +++++++++++++++++++------------------- ase/awk/val.c | 50 ++++---- ase/macros.h | 32 +++++- ase/types.h | 10 +- 10 files changed, 482 insertions(+), 446 deletions(-) diff --git a/ase/awk/err.c b/ase/awk/err.c index 13863664..be7bd748 100644 --- a/ase/awk/err.c +++ b/ase/awk/err.c @@ -1,5 +1,5 @@ /* - * $Id: err.c,v 1.17 2006-04-30 15:50:38 bacon Exp $ + * $Id: err.c,v 1.18 2006-05-06 12:52:36 bacon Exp $ */ #include @@ -13,63 +13,63 @@ const xp_char_t* xp_awk_geterrstr (xp_awk_t* awk) { static const xp_char_t* __errstr[] = { - XP_TEXT("no error"), - XP_TEXT("out of memory"), + XP_T("no error"), + XP_T("out of memory"), - XP_TEXT("no source io handler set"), - XP_TEXT("cannot open source input"), - XP_TEXT("cannot close source input"), - XP_TEXT("cannot switch to next source input"), - XP_TEXT("cannot read source input"), + XP_T("no source io handler set"), + XP_T("cannot open source input"), + XP_T("cannot close source input"), + XP_T("cannot switch to next source input"), + XP_T("cannot read source input"), - XP_TEXT("cannot open text input"), - XP_TEXT("cannot close text input"), - XP_TEXT("cannot switch to next text input"), - XP_TEXT("cannot read text input"), + XP_T("cannot open text input"), + XP_T("cannot close text input"), + XP_T("cannot switch to next text input"), + XP_T("cannot read text input"), - XP_TEXT("invalid character"), - XP_TEXT("cannot unget character"), + XP_T("invalid character"), + XP_T("cannot unget character"), - XP_TEXT("unexpected end of source"), - XP_TEXT("unexpected end of a string"), - XP_TEXT("unexpected end of a regular expression"), - XP_TEXT("left brace expected"), - XP_TEXT("left parenthesis expected"), - XP_TEXT("right parenthesis expected"), - XP_TEXT("right bracket expected"), - XP_TEXT("comma expected"), - XP_TEXT("semicolon expected"), - XP_TEXT("colon expected"), - XP_TEXT("keyword 'in' expected"), - XP_TEXT("not a variable after 'in'"), - XP_TEXT("expression expected"), + XP_T("unexpected end of source"), + XP_T("unexpected end of a string"), + XP_T("unexpected end of a regular expression"), + XP_T("left brace expected"), + XP_T("left parenthesis expected"), + XP_T("right parenthesis expected"), + XP_T("right bracket expected"), + XP_T("comma expected"), + XP_T("semicolon expected"), + XP_T("colon expected"), + XP_T("keyword 'in' expected"), + XP_T("not a variable after 'in'"), + XP_T("expression expected"), - XP_TEXT("keyword 'while' expected"), - XP_TEXT("assignment statement expected"), - XP_TEXT("identifier expected"), - XP_TEXT("duplicate BEGIN"), - XP_TEXT("duplicate END"), - XP_TEXT("duplicate function name"), - XP_TEXT("duplicate parameter name"), - XP_TEXT("duplicate variable name"), - XP_TEXT("duplicate name"), - XP_TEXT("undefined identifier"), - XP_TEXT("l-value required"), - XP_TEXT("too many arguments"), + XP_T("keyword 'while' expected"), + XP_T("assignment statement expected"), + XP_T("identifier expected"), + XP_T("duplicate BEGIN"), + XP_T("duplicate END"), + XP_T("duplicate function name"), + XP_T("duplicate parameter name"), + XP_T("duplicate variable name"), + XP_T("duplicate name"), + XP_T("undefined identifier"), + XP_T("l-value required"), + XP_T("too many arguments"), - XP_TEXT("divide by zero"), - XP_TEXT("invalid operand"), - XP_TEXT("no such function"), - XP_TEXT("value not assignable"), - XP_TEXT("value not indexable"), - XP_TEXT("wrong index value"), + XP_T("divide by zero"), + XP_T("invalid operand"), + XP_T("no such function"), + XP_T("value not assignable"), + XP_T("value not indexable"), + XP_T("wrong index value"), - XP_TEXT("internal error that should never have happened") + XP_T("internal error that should never have happened") }; if (awk->errnum >= 0 && awk->errnum < xp_countof(__errstr)) { return __errstr[awk->errnum]; } - return XP_TEXT("unknown error"); + return XP_T("unknown error"); } diff --git a/ase/awk/map.c b/ase/awk/map.c index 36f04096..1eac3183 100644 --- a/ase/awk/map.c +++ b/ase/awk/map.c @@ -1,5 +1,5 @@ /* - * $Id: map.c,v 1.18 2006-05-03 16:07:24 bacon Exp $ + * $Id: map.c,v 1.19 2006-05-06 12:52:36 bacon Exp $ */ #include @@ -252,7 +252,7 @@ static xp_size_t __hash (const xp_char_t* key) { xp_size_t n = 0, i; - while (*key != XP_CHAR('\0')) + while (*key != XP_T('\0')) { xp_byte_t* bp = (xp_byte_t*)key; for (i = 0; i < xp_sizeof(*key); i++) n = n * 31 + *bp++; diff --git a/ase/awk/misc.c b/ase/awk/misc.c index 0e9ff0b8..a8159fb5 100644 --- a/ase/awk/misc.c +++ b/ase/awk/misc.c @@ -1,5 +1,5 @@ /* - * $Id: misc.c,v 1.6 2006-04-26 15:49:33 bacon Exp $ + * $Id: misc.c,v 1.7 2006-05-06 12:52:36 bacon Exp $ */ #include @@ -20,27 +20,27 @@ xp_long_t xp_awk_strtolong ( p = str; while (xp_isspace(*p)) p++; - while (*p != XP_CHAR('\0')) + while (*p != XP_T('\0')) { - if (*p == XP_CHAR('-')) + if (*p == XP_T('-')) { negative = ~negative; p++; } - else if (*p == XP_CHAR('+')) p++; + else if (*p == XP_T('+')) p++; else break; } if (base == 0) { - if (*p == XP_CHAR('0')) + if (*p == XP_T('0')) { p++; - if (*p == XP_CHAR('x') || *p == XP_CHAR('X')) + if (*p == XP_T('x') || *p == XP_T('X')) { p++; base = 16; } - else if (*p == XP_CHAR('b') || *p == XP_CHAR('B')) + else if (*p == XP_T('b') || *p == XP_T('B')) { p++; base = 2; } @@ -50,23 +50,23 @@ xp_long_t xp_awk_strtolong ( } else if (base == 16) { - if (*p == XP_CHAR('0') && - (*(p+1) == XP_CHAR('x') || *(p+1) == XP_CHAR('X'))) p += 2; + if (*p == XP_T('0') && + (*(p+1) == XP_T('x') || *(p+1) == XP_T('X'))) p += 2; } else if (base == 2) { - if (*p == XP_CHAR('0') && - (*(p+1) == XP_CHAR('b') || *(p+1) == XP_CHAR('B'))) p += 2; + if (*p == XP_T('0') && + (*(p+1) == XP_T('b') || *(p+1) == XP_T('B'))) p += 2; } - while (*p != XP_CHAR('\0')) + while (*p != XP_T('\0')) { - if (*p >= XP_CHAR('0') && *p <= XP_CHAR('9')) - digit = *p - XP_CHAR('0'); - else if (*p >= XP_CHAR('A') && *p <= XP_CHAR('Z')) - digit = *p - XP_CHAR('A') + 10; - else if (*p >= XP_CHAR('a') && *p <= XP_CHAR('z')) - digit = *p - XP_CHAR('a') + 10; + if (*p >= XP_T('0') && *p <= XP_T('9')) + digit = *p - XP_T('0'); + else if (*p >= XP_T('A') && *p <= XP_T('Z')) + digit = *p - XP_T('A') + 10; + else if (*p >= XP_T('a') && *p <= XP_T('z')) + digit = *p - XP_T('a') + 10; else break; if (digit >= base) break; @@ -137,14 +137,14 @@ xp_real_t xp_awk_strtoreal (const xp_char_t* str) /* Strip off leading blanks and check for a sign */ while (xp_isspace(*p)) p++; - while (*p != XP_CHAR('\0')) + while (*p != XP_T('\0')) { - if (*p == XP_CHAR('-')) + if (*p == XP_T('-')) { sign = ~sign; p++; } - else if (*p == XP_CHAR('+')) p++; + else if (*p == XP_T('+')) p++; else break; } @@ -154,7 +154,7 @@ xp_real_t xp_awk_strtoreal (const xp_char_t* str) for (mantSize = 0; ; mantSize++) { c = *p; if (!xp_isdigit(c)) { - if ((c != XP_CHAR('.')) || (decPt >= 0)) break; + if ((c != XP_T('.')) || (decPt >= 0)) break; decPt = mantSize; } p++; @@ -201,40 +201,40 @@ xp_real_t xp_awk_strtoreal (const xp_char_t* str) { c = *p; p++; - if (c == XP_CHAR('.')) + if (c == XP_T('.')) { c = *p; p++; } - frac1 = 10 * frac1 + (c - XP_CHAR('0')); + frac1 = 10 * frac1 + (c - XP_T('0')); } frac2 = 0; for (; mantSize > 0; mantSize -= 1) { c = *p; p++; - if (c == XP_CHAR('.')) + if (c == XP_T('.')) { c = *p; p++; } - frac2 = 10*frac2 + (c - XP_CHAR('0')); + frac2 = 10*frac2 + (c - XP_T('0')); } fraction = (1.0e9 * frac1) + frac2; } /* Skim off the exponent */ p = pExp; - if ((*p == XP_CHAR('E')) || (*p == XP_CHAR('e'))) + if ((*p == XP_T('E')) || (*p == XP_T('e'))) { p++; - if (*p == XP_CHAR('-')) + if (*p == XP_T('-')) { expSign = 1; p++; } else { - if (*p == XP_CHAR('+')) p++; + if (*p == XP_T('+')) p++; expSign = 0; } if (!xp_isdigit(*p)) @@ -244,7 +244,7 @@ xp_real_t xp_awk_strtoreal (const xp_char_t* str) } while (xp_isdigit(*p)) { - exp = exp * 10 + (*p - XP_CHAR('0')); + exp = exp * 10 + (*p - XP_T('0')); p++; } } diff --git a/ase/awk/parse.c b/ase/awk/parse.c index 51f3e4a9..550d9887 100644 --- a/ase/awk/parse.c +++ b/ase/awk/parse.c @@ -1,5 +1,5 @@ /* - * $Id: parse.c,v 1.100 2006-05-02 15:43:10 bacon Exp $ + * $Id: parse.c,v 1.101 2006-05-06 12:52:36 bacon Exp $ */ #include @@ -173,28 +173,28 @@ struct __kwent static struct __kwent __kwtab[] = { - { XP_TEXT("BEGIN"), TOKEN_BEGIN, 0 }, - { XP_TEXT("END"), TOKEN_END, 0 }, + { XP_T("BEGIN"), TOKEN_BEGIN, 0 }, + { XP_T("END"), TOKEN_END, 0 }, - { XP_TEXT("function"), TOKEN_FUNCTION, 0 }, - { XP_TEXT("func"), TOKEN_FUNCTION, 0 }, - { XP_TEXT("if"), TOKEN_IF, 0 }, - { XP_TEXT("else"), TOKEN_ELSE, 0 }, - { XP_TEXT("while"), TOKEN_WHILE, 0 }, - { XP_TEXT("for"), TOKEN_FOR, 0 }, - { XP_TEXT("do"), TOKEN_DO, 0 }, - { XP_TEXT("break"), TOKEN_BREAK, 0 }, - { XP_TEXT("continue"), TOKEN_CONTINUE, 0 }, - { XP_TEXT("return"), TOKEN_RETURN, 0 }, - { XP_TEXT("exit"), TOKEN_EXIT, 0 }, - { XP_TEXT("delete"), TOKEN_DELETE, 0 }, - { XP_TEXT("next"), TOKEN_NEXT, 0 }, - { XP_TEXT("nextfile"), TOKEN_NEXTFILE, 0 }, + { XP_T("function"), TOKEN_FUNCTION, 0 }, + { XP_T("func"), TOKEN_FUNCTION, 0 }, + { XP_T("if"), TOKEN_IF, 0 }, + { XP_T("else"), TOKEN_ELSE, 0 }, + { XP_T("while"), TOKEN_WHILE, 0 }, + { XP_T("for"), TOKEN_FOR, 0 }, + { XP_T("do"), TOKEN_DO, 0 }, + { XP_T("break"), TOKEN_BREAK, 0 }, + { XP_T("continue"), TOKEN_CONTINUE, 0 }, + { XP_T("return"), TOKEN_RETURN, 0 }, + { XP_T("exit"), TOKEN_EXIT, 0 }, + { XP_T("delete"), TOKEN_DELETE, 0 }, + { XP_T("next"), TOKEN_NEXT, 0 }, + { XP_T("nextfile"), TOKEN_NEXTFILE, 0 }, - { XP_TEXT("local"), TOKEN_LOCAL, XP_AWK_EXPLICIT }, - { XP_TEXT("global"), TOKEN_GLOBAL, XP_AWK_EXPLICIT }, + { XP_T("local"), TOKEN_LOCAL, XP_AWK_EXPLICIT }, + { XP_T("global"), TOKEN_GLOBAL, XP_AWK_EXPLICIT }, - { XP_TEXT("in"), TOKEN_IN, 0 }, + { XP_T("in"), TOKEN_IN, 0 }, { XP_NULL, 0, 0 } }; @@ -202,27 +202,27 @@ static struct __kwent __kwtab[] = /* TODO: static struct __kwent __bvtab[] = { - { XP_TEXT("ARGC"), TOKEN_ARGC, 0 }, - { XP_TEXT("ARGIND"), TOKEN_ARGIND, 0 }, - { XP_TEXT("ARGV"), TOKEN_ARGV, 0 }, - { XP_TEXT("CONVFMT"), TOKEN_CONVFMT, 0 }, - { XP_TEXT("FIELDWIDTHS"), TOKEN_FIELDWIDTHS, 0 }, - { XP_TEXT("ENVIRON"), TOKEN_ENVIRON, 0 }, - { XP_TEXT("ERRNO"), TOKEN_ERRNO, 0 }, - { XP_TEXT("FILENAME"), TOKEN_FILENAME, 0 }, - { XP_TEXT("FNR"), TOKEN_FNR, 0 }, - { XP_TEXT("FS"), TOKEN_FS, 0 }, - { XP_TEXT("IGNORECASE"), TOKEN_IGNORECASE, 0 }, - { XP_TEXT("NF"), TOKEN_NF, 0 }, - { XP_TEXT("NR"), TOKEN_NR, 0 }, - { XP_TEXT("OFMT"), TOKEN_OFMT, 0 }, - { XP_TEXT("OFS"), TOKEN_OFS, 0 }, - { XP_TEXT("ORS"), TOKEN_ORS, 0 }, - { XP_TEXT("RS"), TOKEN_RS, 0 }, - { XP_TEXT("RT"), TOKEN_RT, 0 }, - { XP_TEXT("RSTART"), TOKEN_RSTART, 0 }, - { XP_TEXT("RLENGTH"), TOKEN_RLENGTH, 0 }, - { XP_TEXT("SUBSEP"), TOKEN_SUBSEP, 0 }, + { XP_T("ARGC"), TOKEN_ARGC, 0 }, + { XP_T("ARGIND"), TOKEN_ARGIND, 0 }, + { XP_T("ARGV"), TOKEN_ARGV, 0 }, + { XP_T("CONVFMT"), TOKEN_CONVFMT, 0 }, + { XP_T("FIELDWIDTHS"), TOKEN_FIELDWIDTHS, 0 }, + { XP_T("ENVIRON"), TOKEN_ENVIRON, 0 }, + { XP_T("ERRNO"), TOKEN_ERRNO, 0 }, + { XP_T("FILENAME"), TOKEN_FILENAME, 0 }, + { XP_T("FNR"), TOKEN_FNR, 0 }, + { XP_T("FS"), TOKEN_FS, 0 }, + { XP_T("IGNORECASE"), TOKEN_IGNORECASE, 0 }, + { XP_T("NF"), TOKEN_NF, 0 }, + { XP_T("NR"), TOKEN_NR, 0 }, + { XP_T("OFMT"), TOKEN_OFMT, 0 }, + { XP_T("OFS"), TOKEN_OFS, 0 }, + { XP_T("ORS"), TOKEN_ORS, 0 }, + { XP_T("RS"), TOKEN_RS, 0 }, + { XP_T("RT"), TOKEN_RT, 0 }, + { XP_T("RSTART"), TOKEN_RSTART, 0 }, + { XP_T("RLENGTH"), TOKEN_RLENGTH, 0 }, + { XP_T("SUBSEP"), TOKEN_SUBSEP, 0 }, { XP_NULL, 0, 0 } }; */ @@ -273,16 +273,16 @@ static int __dump_func (xp_awk_pair_t* pair, void* arg) xp_size_t i; xp_assert (xp_strcmp(pair->key, func->name) == 0); - xp_printf (XP_TEXT("function %s ("), func->name); + xp_printf (XP_T("function %s ("), func->name); for (i = 0; i < func->nargs; ) { - xp_printf (XP_TEXT("__arg%lu"), (unsigned long)i++); + xp_printf (XP_T("__arg%lu"), (unsigned long)i++); if (i >= func->nargs) break; - xp_printf (XP_TEXT(", ")); + xp_printf (XP_T(", ")); } - xp_printf (XP_TEXT(")\n")); + xp_printf (XP_T(")\n")); xp_awk_prnpt (func->body); - xp_printf (XP_TEXT("\n")); + xp_printf (XP_T("\n")); return 0; } @@ -295,21 +295,21 @@ static void __dump (xp_awk_t* awk) { xp_size_t i; - xp_printf (XP_TEXT("global ")); + xp_printf (XP_T("global ")); for (i = 0; i < awk->tree.nglobals - 1; i++) { - xp_printf (XP_TEXT("__global%lu, "), (unsigned long)i); + xp_printf (XP_T("__global%lu, "), (unsigned long)i); } - xp_printf (XP_TEXT("__global%lu;\n\n"), (unsigned long)i); + xp_printf (XP_T("__global%lu;\n\n"), (unsigned long)i); } xp_awk_map_walk (&awk->tree.funcs, __dump_func, XP_NULL); if (awk->tree.begin != XP_NULL) { - xp_printf (XP_TEXT("BEGIN ")); + xp_printf (XP_T("BEGIN ")); xp_awk_prnpt (awk->tree.begin); - xp_printf (XP_TEXT("\n")); + xp_printf (XP_T("\n")); } chain = awk->tree.chain; @@ -317,13 +317,13 @@ static void __dump (xp_awk_t* awk) { if (chain->pattern != XP_NULL) xp_awk_prnpt (chain->pattern); if (chain->action != XP_NULL) xp_awk_prnpt (chain->action); - xp_printf (XP_TEXT("\n")); + xp_printf (XP_T("\n")); chain = chain->next; } if (awk->tree.end != XP_NULL) { - xp_printf (XP_TEXT("END ")); + xp_printf (XP_T("END ")); xp_awk_prnpt (awk->tree.end); } } @@ -356,7 +356,7 @@ int xp_awk_parse (xp_awk_t* awk) } awk->tree.nglobals = xp_awk_tab_getsize(&awk->parse.globals); -xp_printf (XP_TEXT("-----------------------------\n")); +xp_printf (XP_T("-----------------------------\n")); __dump (awk); return 0; @@ -422,7 +422,7 @@ static xp_awk_t* __parse_progunit (xp_awk_t* awk) { /* { print $0; } */ /* TODO: XXXX */ - xp_printf (XP_TEXT("BLOCKLESS NOT IMPLEMENTED....\n")); + xp_printf (XP_T("BLOCKLESS NOT IMPLEMENTED....\n")); PANIC (awk, XP_AWK_EINTERNAL); } } @@ -2562,7 +2562,7 @@ static int __get_token (xp_awk_t* awk) { if (__get_number(awk) == -1) return -1; } - else if (xp_isalpha(c) || c == XP_CHAR('_')) + else if (xp_isalpha(c) || c == XP_T('_')) { /* identifier */ do @@ -2570,11 +2570,11 @@ static int __get_token (xp_awk_t* awk) ADD_TOKEN_CHAR (awk, c); GET_CHAR_TO (awk, c); } - while (xp_isalpha(c) || c == XP_CHAR('_') || xp_isdigit(c)); + while (xp_isalpha(c) || c == XP_T('_') || xp_isdigit(c)); SET_TOKEN_TYPE (awk, __classify_ident(awk,XP_STR_BUF(&awk->token.name))); } - else if (c == XP_CHAR('\"')) + else if (c == XP_T('\"')) { SET_TOKEN_TYPE (awk, TOKEN_STR); @@ -2589,187 +2589,187 @@ static int __get_token (xp_awk_t* awk) while (n == 1); c = awk->lex.curc; - if (c != XP_CHAR('\"')) break; + if (c != XP_T('\"')) break; if (__get_string(awk) == -1) return -1; } } - else if (c == XP_CHAR('=')) + else if (c == XP_T('=')) { GET_CHAR_TO (awk, c); - if (c == XP_CHAR('=')) + if (c == XP_T('=')) { SET_TOKEN_TYPE (awk, TOKEN_EQ); - ADD_TOKEN_STR (awk, XP_TEXT("==")); + ADD_TOKEN_STR (awk, XP_T("==")); GET_CHAR_TO (awk, c); } else { SET_TOKEN_TYPE (awk, TOKEN_ASSIGN); - ADD_TOKEN_STR (awk, XP_TEXT("=")); + ADD_TOKEN_STR (awk, XP_T("=")); } } - else if (c == XP_CHAR('!')) + else if (c == XP_T('!')) { GET_CHAR_TO (awk, c); - if (c == XP_CHAR('=')) + if (c == XP_T('=')) { SET_TOKEN_TYPE (awk, TOKEN_NE); - ADD_TOKEN_STR (awk, XP_TEXT("!=")); + ADD_TOKEN_STR (awk, XP_T("!=")); GET_CHAR_TO (awk, c); } - else if (c == XP_CHAR('~')) + else if (c == XP_T('~')) { SET_TOKEN_TYPE (awk, TOKEN_NM); - ADD_TOKEN_STR (awk, XP_TEXT("!~")); + ADD_TOKEN_STR (awk, XP_T("!~")); GET_CHAR_TO (awk, c); } else { SET_TOKEN_TYPE (awk, TOKEN_NOT); - ADD_TOKEN_STR (awk, XP_TEXT("!")); + ADD_TOKEN_STR (awk, XP_T("!")); } } - else if (c == XP_CHAR('>')) + else if (c == XP_T('>')) { GET_CHAR_TO (awk, c); - if ((awk->opt.parse & XP_AWK_SHIFT) && c == XP_CHAR('>')) + if ((awk->opt.parse & XP_AWK_SHIFT) && c == XP_T('>')) { SET_TOKEN_TYPE (awk, TOKEN_RSHIFT); - ADD_TOKEN_STR (awk, XP_TEXT(">>")); + ADD_TOKEN_STR (awk, XP_T(">>")); GET_CHAR_TO (awk, c); } - else if (c == XP_CHAR('=')) + else if (c == XP_T('=')) { SET_TOKEN_TYPE (awk, TOKEN_GE); - ADD_TOKEN_STR (awk, XP_TEXT(">=")); + ADD_TOKEN_STR (awk, XP_T(">=")); GET_CHAR_TO (awk, c); } else { SET_TOKEN_TYPE (awk, TOKEN_GT); - ADD_TOKEN_STR (awk, XP_TEXT(">")); + ADD_TOKEN_STR (awk, XP_T(">")); } } - else if (c == XP_CHAR('<')) + else if (c == XP_T('<')) { GET_CHAR_TO (awk, c); - if ((awk->opt.parse & XP_AWK_SHIFT) && c == XP_CHAR('<')) + if ((awk->opt.parse & XP_AWK_SHIFT) && c == XP_T('<')) { SET_TOKEN_TYPE (awk, TOKEN_LSHIFT); - ADD_TOKEN_STR (awk, XP_TEXT("<<")); + ADD_TOKEN_STR (awk, XP_T("<<")); GET_CHAR_TO (awk, c); } - else if (c == XP_CHAR('=')) + else if (c == XP_T('=')) { SET_TOKEN_TYPE (awk, TOKEN_LE); - ADD_TOKEN_STR (awk, XP_TEXT("<=")); + ADD_TOKEN_STR (awk, XP_T("<=")); GET_CHAR_TO (awk, c); } else { SET_TOKEN_TYPE (awk, TOKEN_LT); - ADD_TOKEN_STR (awk, XP_TEXT("<")); + ADD_TOKEN_STR (awk, XP_T("<")); } } - else if (c == XP_CHAR('|')) + else if (c == XP_T('|')) { GET_CHAR_TO (awk, c); - if (c == XP_CHAR('|')) + if (c == XP_T('|')) { SET_TOKEN_TYPE (awk, TOKEN_LOR); - ADD_TOKEN_STR (awk, XP_TEXT("||")); + ADD_TOKEN_STR (awk, XP_T("||")); GET_CHAR_TO (awk, c); } else { SET_TOKEN_TYPE (awk, TOKEN_BOR); - ADD_TOKEN_STR (awk, XP_TEXT("|")); + ADD_TOKEN_STR (awk, XP_T("|")); } } - else if (c == XP_CHAR('&')) + else if (c == XP_T('&')) { GET_CHAR_TO (awk, c); - if (c == XP_CHAR('&')) + if (c == XP_T('&')) { SET_TOKEN_TYPE (awk, TOKEN_LAND); - ADD_TOKEN_STR (awk, XP_TEXT("&&")); + ADD_TOKEN_STR (awk, XP_T("&&")); GET_CHAR_TO (awk, c); } else { SET_TOKEN_TYPE (awk, TOKEN_BAND); - ADD_TOKEN_STR (awk, XP_TEXT("&")); + ADD_TOKEN_STR (awk, XP_T("&")); } } - else if (c == XP_CHAR('~')) + else if (c == XP_T('~')) { SET_TOKEN_TYPE (awk, TOKEN_TILDE); ADD_TOKEN_CHAR (awk, c); GET_CHAR_TO (awk, c); } - else if (c == XP_CHAR('^')) + else if (c == XP_T('^')) { SET_TOKEN_TYPE (awk, TOKEN_BXOR); ADD_TOKEN_CHAR (awk, c); GET_CHAR_TO (awk, c); } - else if (c == XP_CHAR('+')) + else if (c == XP_T('+')) { GET_CHAR_TO (awk, c); - if (c == XP_CHAR('+')) + if (c == XP_T('+')) { SET_TOKEN_TYPE (awk, TOKEN_PLUSPLUS); - ADD_TOKEN_STR (awk, XP_TEXT("++")); + ADD_TOKEN_STR (awk, XP_T("++")); GET_CHAR_TO (awk, c); } - else if (c == XP_CHAR('=')) + else if (c == XP_T('=')) { SET_TOKEN_TYPE (awk, TOKEN_PLUS_ASSIGN); - ADD_TOKEN_STR (awk, XP_TEXT("+=")); + ADD_TOKEN_STR (awk, XP_T("+=")); GET_CHAR_TO (awk, c); } else { SET_TOKEN_TYPE (awk, TOKEN_PLUS); - ADD_TOKEN_STR (awk, XP_TEXT("+")); + ADD_TOKEN_STR (awk, XP_T("+")); } } - else if (c == XP_CHAR('-')) + else if (c == XP_T('-')) { GET_CHAR_TO (awk, c); - if (c == XP_CHAR('-')) + if (c == XP_T('-')) { SET_TOKEN_TYPE (awk, TOKEN_MINUSMINUS); - ADD_TOKEN_STR (awk, XP_TEXT("--")); + ADD_TOKEN_STR (awk, XP_T("--")); GET_CHAR_TO (awk, c); } - else if (c == XP_CHAR('=')) + else if (c == XP_T('=')) { SET_TOKEN_TYPE (awk, TOKEN_MINUS_ASSIGN); - ADD_TOKEN_STR (awk, XP_TEXT("-=")); + ADD_TOKEN_STR (awk, XP_T("-=")); GET_CHAR_TO (awk, c); } else { SET_TOKEN_TYPE (awk, TOKEN_MINUS); - ADD_TOKEN_STR (awk, XP_TEXT("-")); + ADD_TOKEN_STR (awk, XP_T("-")); } } - else if (c == XP_CHAR('*')) + else if (c == XP_T('*')) { GET_CHAR_TO (awk, c); - if (c == XP_CHAR('=')) + if (c == XP_T('=')) { SET_TOKEN_TYPE (awk, TOKEN_MUL_ASSIGN); ADD_TOKEN_CHAR (awk, c); GET_CHAR_TO (awk, c); } - else if (c == XP_CHAR('*')) + else if (c == XP_T('*')) { GET_CHAR_TO (awk, c); - if (c == XP_CHAR('=')) + if (c == XP_T('=')) { SET_TOKEN_TYPE (awk, TOKEN_EXP_ASSIGN); ADD_TOKEN_CHAR (awk, c); @@ -2787,11 +2787,11 @@ static int __get_token (xp_awk_t* awk) ADD_TOKEN_CHAR (awk, c); } } - else if (c == XP_CHAR('/')) + else if (c == XP_T('/')) { GET_CHAR_TO (awk, c); - if (c == XP_CHAR('=')) + if (c == XP_T('=')) { SET_TOKEN_TYPE (awk, TOKEN_DIV_ASSIGN); ADD_TOKEN_CHAR (awk, c); @@ -2803,11 +2803,11 @@ static int __get_token (xp_awk_t* awk) ADD_TOKEN_CHAR (awk, c); } } - else if (c == XP_CHAR('%')) + else if (c == XP_T('%')) { GET_CHAR_TO (awk, c); - if (c == XP_CHAR('=')) + if (c == XP_T('=')) { SET_TOKEN_TYPE (awk, TOKEN_MOD_ASSIGN); ADD_TOKEN_CHAR (awk, c); @@ -2819,73 +2819,73 @@ static int __get_token (xp_awk_t* awk) ADD_TOKEN_CHAR (awk, c); } } - else if (c == XP_CHAR('(')) + else if (c == XP_T('(')) { SET_TOKEN_TYPE (awk, TOKEN_LPAREN); ADD_TOKEN_CHAR (awk, c); GET_CHAR_TO (awk, c); } - else if (c == XP_CHAR(')')) + else if (c == XP_T(')')) { SET_TOKEN_TYPE (awk, TOKEN_RPAREN); ADD_TOKEN_CHAR (awk, c); GET_CHAR_TO (awk, c); } - else if (c == XP_CHAR('{')) + else if (c == XP_T('{')) { SET_TOKEN_TYPE (awk, TOKEN_LBRACE); ADD_TOKEN_CHAR (awk, c); GET_CHAR_TO (awk, c); } - else if (c == XP_CHAR('}')) + else if (c == XP_T('}')) { SET_TOKEN_TYPE (awk, TOKEN_RBRACE); ADD_TOKEN_CHAR (awk, c); GET_CHAR_TO (awk, c); } - else if (c == XP_CHAR('[')) + else if (c == XP_T('[')) { SET_TOKEN_TYPE (awk, TOKEN_LBRACK); ADD_TOKEN_CHAR (awk, c); GET_CHAR_TO (awk, c); } - else if (c == XP_CHAR(']')) + else if (c == XP_T(']')) { SET_TOKEN_TYPE (awk, TOKEN_RBRACK); ADD_TOKEN_CHAR (awk, c); GET_CHAR_TO (awk, c); } - else if (c == XP_CHAR('$')) + else if (c == XP_T('$')) { SET_TOKEN_TYPE (awk, TOKEN_DOLLAR); ADD_TOKEN_CHAR (awk, c); GET_CHAR_TO (awk, c); } - else if (c == XP_CHAR(',')) + else if (c == XP_T(',')) { SET_TOKEN_TYPE (awk, TOKEN_COMMA); ADD_TOKEN_CHAR (awk, c); GET_CHAR_TO (awk, c); } - else if (c == XP_CHAR('.')) + else if (c == XP_T('.')) { SET_TOKEN_TYPE (awk, TOKEN_PERIOD); ADD_TOKEN_CHAR (awk, c); GET_CHAR_TO (awk, c); } - else if (c == XP_CHAR(';')) + else if (c == XP_T(';')) { SET_TOKEN_TYPE (awk, TOKEN_SEMICOLON); ADD_TOKEN_CHAR (awk, c); GET_CHAR_TO (awk, c); } - else if (c == XP_CHAR(':')) + else if (c == XP_T(':')) { SET_TOKEN_TYPE (awk, TOKEN_COLON); ADD_TOKEN_CHAR (awk, c); GET_CHAR_TO (awk, c); } - else if (c == XP_CHAR('?')) + else if (c == XP_T('?')) { SET_TOKEN_TYPE (awk, TOKEN_QUEST); ADD_TOKEN_CHAR (awk, c); @@ -2897,7 +2897,7 @@ static int __get_token (xp_awk_t* awk) return -1; } -xp_printf (XP_TEXT("token -> [%s]\n"), XP_STR_BUF(&awk->token.name)); +xp_printf (XP_T("token -> [%s]\n"), XP_STR_BUF(&awk->token.name)); return 0; } @@ -2910,12 +2910,12 @@ static int __get_number (xp_awk_t* awk) c = awk->lex.curc; - if (c == XP_CHAR('0')) + if (c == XP_T('0')) { ADD_TOKEN_CHAR (awk, c); GET_CHAR_TO (awk, c); - if (c == XP_CHAR('x') || c == XP_CHAR('X')) + if (c == XP_T('x') || c == XP_T('X')) { /* hexadecimal number */ do @@ -2927,7 +2927,7 @@ static int __get_number (xp_awk_t* awk) return 0; } - else if (c == XP_CHAR('b') || c == XP_CHAR('B')) + else if (c == XP_T('b') || c == XP_T('B')) { /* binary number */ do @@ -2935,14 +2935,14 @@ static int __get_number (xp_awk_t* awk) ADD_TOKEN_CHAR (awk, c); GET_CHAR_TO (awk, c); } - while (c == XP_CHAR('0') || c == XP_CHAR('1')); + while (c == XP_T('0') || c == XP_T('1')); return 0; } else if (c != '.') { /* octal number */ - while (c >= XP_CHAR('0') && c <= XP_CHAR('7')) + while (c >= XP_T('0') && c <= XP_T('7')) { ADD_TOKEN_CHAR (awk, c); GET_CHAR_TO (awk, c); @@ -2958,7 +2958,7 @@ static int __get_number (xp_awk_t* awk) GET_CHAR_TO (awk, c); } - if (c == XP_CHAR('.')) + if (c == XP_T('.')) { /* floating-point number */ SET_TOKEN_TYPE (awk, TOKEN_REAL); @@ -2973,14 +2973,14 @@ static int __get_number (xp_awk_t* awk) } } - if (c == XP_CHAR('E') || c == XP_CHAR('e')) + if (c == XP_T('E') || c == XP_T('e')) { SET_TOKEN_TYPE (awk, TOKEN_REAL); ADD_TOKEN_CHAR (awk, c); GET_CHAR_TO (awk, c); - if (c == XP_CHAR('+') || c == XP_CHAR('-')) + if (c == XP_T('+') || c == XP_T('-')) { ADD_TOKEN_CHAR (awk, c); GET_CHAR_TO (awk, c); @@ -3010,13 +3010,13 @@ static int __get_string (xp_awk_t* awk) return -1; } - if (escaped == xp_false && c == XP_CHAR('\"')) + if (escaped == xp_false && c == XP_T('\"')) { GET_CHAR_TO (awk, c); break; } - if (escaped == xp_false && c == XP_CHAR('\\')) + if (escaped == xp_false && c == XP_T('\\')) { GET_CHAR_TO (awk, c); escaped = xp_true; @@ -3025,9 +3025,9 @@ static int __get_string (xp_awk_t* awk) if (escaped == xp_true) { - if (c == XP_CHAR('n')) c = XP_CHAR('\n'); - else if (c == XP_CHAR('r')) c = XP_CHAR('\r'); - else if (c == XP_CHAR('t')) c = XP_CHAR('\t'); + if (c == XP_T('n')) c = XP_T('\n'); + else if (c == XP_T('r')) c = XP_T('\r'); + else if (c == XP_T('t')) c = XP_T('\t'); /* TODO: more escape characters */ escaped = xp_false; } @@ -3056,13 +3056,13 @@ static int __get_regex (xp_awk_t* awk) return -1; } - if (escaped == xp_false && c == XP_CHAR('/')) + if (escaped == xp_false && c == XP_T('/')) { GET_CHAR_TO (awk, c); break; } - if (escaped == xp_false && c == XP_CHAR('\\')) + if (escaped == xp_false && c == XP_T('\\')) { GET_CHAR_TO (awk, c); escaped = xp_true; @@ -3071,9 +3071,9 @@ static int __get_regex (xp_awk_t* awk) if (escaped == xp_true) { - if (c == XP_CHAR('n')) c = XP_CHAR('\n'); - else if (c == XP_CHAR('r')) c = XP_CHAR('\r'); - else if (c == XP_CHAR('t')) c = XP_CHAR('\t'); + if (c == XP_T('n')) c = XP_T('\n'); + else if (c == XP_T('r')) c = XP_T('\r'); + else if (c == XP_T('t')) c = XP_T('\t'); /* TODO: more escape characters */ escaped = xp_false; } @@ -3130,7 +3130,7 @@ static int __skip_comment (xp_awk_t* awk) { xp_cint_t c = awk->lex.curc; - if ((awk->opt.parse & XP_AWK_HASHSIGN) && c == XP_CHAR('#')) + if ((awk->opt.parse & XP_AWK_HASHSIGN) && c == XP_T('#')) { do { @@ -3142,10 +3142,10 @@ static int __skip_comment (xp_awk_t* awk) return 1; /* comment by # */ } - if (c != XP_CHAR('/')) return 0; /* not a comment */ + if (c != XP_T('/')) return 0; /* not a comment */ GET_CHAR_TO (awk, c); - if ((awk->opt.parse & XP_AWK_DBLSLASHES) && c == XP_CHAR('/')) + if ((awk->opt.parse & XP_AWK_DBLSLASHES) && c == XP_T('/')) { do { @@ -3156,15 +3156,15 @@ static int __skip_comment (xp_awk_t* awk) GET_CHAR (awk); return 1; /* comment by // */ } - else if (c == XP_CHAR('*')) + else if (c == XP_T('*')) { do { GET_CHAR_TO (awk, c); - if (c == XP_CHAR('*')) + if (c == XP_T('*')) { GET_CHAR_TO (awk, c); - if (c == XP_CHAR('/')) + if (c == XP_T('/')) { GET_CHAR_TO (awk, c); break; @@ -3177,7 +3177,7 @@ static int __skip_comment (xp_awk_t* awk) } if (__unget_char(awk,c) == -1) return -1; /* error */ - awk->lex.curc = XP_CHAR('/'); + awk->lex.curc = XP_T('/'); return 0; } diff --git a/ase/awk/run.c b/ase/awk/run.c index 4996f260..cbe54298 100644 --- a/ase/awk/run.c +++ b/ase/awk/run.c @@ -1,5 +1,5 @@ /* - * $Id: run.c,v 1.85 2006-05-04 15:59:43 bacon Exp $ + * $Id: run.c,v 1.86 2006-05-06 12:52:36 bacon Exp $ */ #include @@ -148,9 +148,9 @@ typedef xp_awk_val_t* (*eval_expr_t) (xp_awk_run_t* run, xp_awk_nde_t* nde); /* TODO: remove this function */ static int __printval (xp_awk_pair_t* pair, void* arg) { - xp_printf (XP_TEXT("%s = "), (const xp_char_t*)pair->key); + xp_printf (XP_T("%s = "), (const xp_char_t*)pair->key); xp_awk_printval ((xp_awk_val_t*)pair->val); - xp_printf (XP_TEXT("\n")); + xp_printf (XP_T("\n")); return 0; } @@ -294,11 +294,11 @@ static int __run_main (xp_awk_run_t* run) /* TODO: should the main function be user-specifiable? */ static xp_char_t m_a_i_n[] = { - XP_CHAR('m'), - XP_CHAR('a'), - XP_CHAR('i'), - XP_CHAR('n'), - XP_CHAR('\0') + XP_T('m'), + XP_T('a'), + XP_T('i'), + XP_T('n'), + XP_T('\0') }; static xp_awk_nde_call_t nde = { @@ -395,9 +395,9 @@ static int __run_main (xp_awk_run_t* run) } v = STACK_RETVAL(run); -xp_printf (XP_TEXT("Return Value - ")); +xp_printf (XP_T("Return Value - ")); xp_awk_printval (v); -xp_printf (XP_TEXT("\n")); +xp_printf (XP_T("\n")); /* the life of the global return value is over here * unlike the return value of each function */ /*xp_awk_refdownval_nofree (awk, v);*/ @@ -421,9 +421,9 @@ xp_printf (XP_TEXT("\n")); /* just reset the exit level */ run->exit_level = EXIT_NONE; -xp_printf (XP_TEXT("-[VARIABLES]------------------------\n")); +xp_printf (XP_T("-[VARIABLES]------------------------\n")); xp_awk_map_walk (&run->named, __printval, XP_NULL); -xp_printf (XP_TEXT("-[END VARIABLES]--------------------------\n")); +xp_printf (XP_T("-[END VARIABLES]--------------------------\n")); return n; } @@ -464,7 +464,7 @@ static int __run_pattern_blocks (xp_awk_run_t* run) /* for each block { run it } * handle according if next and nextfile has been called */ - xp_printf (XP_TEXT("**** line [%s]\n"), XP_STR_BUF(&run->input.line)); + xp_printf (XP_T("**** line [%s]\n"), XP_STR_BUF(&run->input.line)); } n = run->txtio (XP_AWK_INPUT_CLOSE, run->txtio_arg, XP_NULL, 0); @@ -485,7 +485,7 @@ static int __run_block (xp_awk_run_t* run, xp_awk_nde_blk_t* nde) p = nde->body; nlocals = nde->nlocals; -/*xp_printf (XP_TEXT("securing space for local variables nlocals = %d\n"), nlocals);*/ +/*xp_printf (XP_T("securing space for local variables nlocals = %d\n"), nlocals);*/ saved_stack_top = run->stack_top; /* secure space for local variables */ @@ -502,10 +502,10 @@ static int __run_block (xp_awk_run_t* run, xp_awk_nde_blk_t* nde) /* refupval is not required for xp_awk_val_nil */ } -/*xp_printf (XP_TEXT("executing block statements\n"));*/ +/*xp_printf (XP_T("executing block statements\n"));*/ while (p != XP_NULL && run->exit_level == EXIT_NONE) { -/*xp_printf (XP_TEXT("running a statement\n"));*/ +/*xp_printf (XP_T("running a statement\n"));*/ if (__run_statement(run,p) == -1) { n = -1; @@ -514,7 +514,7 @@ static int __run_block (xp_awk_run_t* run, xp_awk_nde_blk_t* nde) p = p->next; } -/*xp_printf (XP_TEXT("popping off local variables\n"));*/ +/*xp_printf (XP_T("popping off local variables\n"));*/ /* pop off local variables */ nlocals = nde->nlocals; while (nlocals > 0) @@ -852,7 +852,7 @@ static int __run_return_statement (xp_awk_run_t* run, xp_awk_nde_return_t* nde) if (nde->val != XP_NULL) { xp_awk_val_t* val; -/*xp_printf (XP_TEXT("returning....\n"));*/ +/*xp_printf (XP_T("returning....\n"));*/ val = __eval_expression(run, nde->val); if (val == XP_NULL) return -1; @@ -860,7 +860,7 @@ static int __run_return_statement (xp_awk_run_t* run, xp_awk_nde_return_t* nde) STACK_RETVAL(run) = val; xp_awk_refupval (val); /* see __eval_call for the trick */ -/*xp_printf (XP_TEXT("set return value....\n"));*/ +/*xp_printf (XP_T("set return value....\n"));*/ } run->exit_level = EXIT_FUNCTION; @@ -889,7 +889,7 @@ static int __run_exit_statement (xp_awk_run_t* run, xp_awk_nde_exit_t* nde) static int __run_next_statement (xp_awk_run_t* run, xp_awk_nde_next_t* nde) { /* TODO */ -xp_printf (XP_TEXT("**** next NOT IMPLEMENTED...\n")); +xp_printf (XP_T("**** next NOT IMPLEMENTED...\n")); return -1; } @@ -1070,7 +1070,7 @@ static xp_awk_val_t* __do_assignment ( else if (var->type == XP_AWK_NDE_POS) { /* TODO: */ - xp_printf (XP_TEXT("XP_AWK_NDE_POS not implemented\n")); + xp_printf (XP_T("XP_AWK_NDE_POS not implemented\n")); PANIC (run, XP_AWK_EINTERNAL); } else @@ -1164,7 +1164,7 @@ static xp_awk_val_t* __do_assignment_map ( if (str == XP_NULL) return XP_NULL; /* -xp_printf (XP_TEXT("**** index str=>%s, map->ref=%d, map->type=%d\n"), str, map->ref, map->type); +xp_printf (XP_T("**** index str=>%s, map->ref=%d, map->type=%d\n"), str, map->ref, map->type); */ n = xp_awk_map_putx (map->map, str, val, XP_NULL); if (n < 0) @@ -2023,7 +2023,7 @@ static xp_awk_val_t* __eval_binop_ma ( xp_awk_run_t* run, xp_awk_val_t* left, xp_awk_val_t* right) { /* TODO: ... */ -xp_printf (XP_TEXT("eval_binop_ma not implemented yet...\n")); +xp_printf (XP_T("eval_binop_ma not implemented yet...\n")); PANIC (run, XP_AWK_EINTERNAL); return XP_NULL; } @@ -2371,7 +2371,7 @@ static xp_awk_val_t* __eval_call (xp_awk_run_t* run, xp_awk_nde_t* nde) xp_awk_nde_call_t* call = (xp_awk_nde_call_t*)nde; int n; -/*xp_printf (XP_TEXT(".....__eval_call\n"));*/ +/*xp_printf (XP_T(".....__eval_call\n"));*/ pair = xp_awk_map_get (&run->tree->funcs, call->name); if (pair == XP_NULL) PANIC (run, XP_AWK_ENOSUCHFUNC); @@ -2429,7 +2429,7 @@ static xp_awk_val_t* __eval_call (xp_awk_run_t* run, xp_awk_nde_t* nde) saved_stack_top = run->stack_top; -/*xp_printf (XP_TEXT("setting up function stack frame stack_top = %ld stack_base = %ld\n"), run->stack_top, run->stack_base); */ +/*xp_printf (XP_T("setting up function stack frame stack_top = %ld stack_base = %ld\n"), run->stack_top, run->stack_base); */ if (__raw_push(run,(void*)run->stack_base) == -1) { PANIC (run, XP_AWK_ENOMEM); @@ -2533,21 +2533,21 @@ static xp_awk_val_t* __eval_call (xp_awk_run_t* run, xp_awk_nde_t* nde) run->stack_base = saved_stack_top; STACK_NARGS(run) = (void*)nargs; -/*xp_printf (XP_TEXT("running function body\n")); */ +/*xp_printf (XP_T("running function body\n")); */ xp_assert (func->body->type == XP_AWK_NDE_BLK); n = __run_block(run,(xp_awk_nde_blk_t*)func->body); -/*xp_printf (XP_TEXT("block run complete\n")); */ +/*xp_printf (XP_T("block run complete\n")); */ /* refdown args in the run.stack */ nargs = (xp_size_t)STACK_NARGS(run); -/*xp_printf (XP_TEXT("block run complete nargs = %d\n"), nargs); */ +/*xp_printf (XP_T("block run complete nargs = %d\n"), nargs); */ for (i = 0; i < nargs; i++) { xp_awk_refdownval (run, STACK_ARG(run,i)); } -/*xp_printf (XP_TEXT("got return value\n")); */ +/*xp_printf (XP_T("got return value\n")); */ /* this is the trick mentioned in __run_return_statement. * adjust the reference count of the return value. @@ -2565,7 +2565,7 @@ static xp_awk_val_t* __eval_call (xp_awk_run_t* run, xp_awk_nde_t* nde) run->exit_level = EXIT_NONE; } -/*xp_printf (XP_TEXT("returning from function stack_top=%ld, stack_base=%ld\n"), run->stack_top, run->stack_base); */ +/*xp_printf (XP_T("returning from function stack_top=%ld, stack_base=%ld\n"), run->stack_top, run->stack_base); */ return (n == -1)? XP_NULL: v; } @@ -2600,7 +2600,7 @@ static xp_awk_val_t* __eval_str (xp_awk_run_t* run, xp_awk_nde_t* nde) static xp_awk_val_t* __eval_rex (xp_awk_run_t* run, xp_awk_nde_t* nde) { /* TODO */ -xp_printf (XP_TEXT("eval_rex not implemented yet...\n")); +xp_printf (XP_T("eval_rex not implemented yet...\n")); PANIC (run, XP_AWK_EINTERNAL); return XP_NULL; } @@ -2689,7 +2689,7 @@ static xp_awk_val_t* __eval_argidx (xp_awk_run_t* run, xp_awk_nde_t* nde) static xp_awk_val_t* __eval_pos (xp_awk_run_t* run, xp_awk_nde_t* nde) { /* TODO: */ - xp_printf (XP_TEXT("eval_pos not competed....\n")); + xp_printf (XP_T("eval_pos not competed....\n")); return XP_NULL; } @@ -2763,7 +2763,7 @@ static int __read_text_input (xp_awk_run_t* run) /* TODO: use LF instead of this hard coded value */ /* any better way to tell line terminating with newlines? * line with new line characters removed or retained? */ - if (c == XP_CHAR('\n')) break; + if (c == XP_T('\n')) break; } return 1; @@ -2796,9 +2796,9 @@ static int __val_to_num (xp_awk_val_t* v, xp_long_t* l, xp_real_t* r) /* don't care about val->len */ *l = xp_awk_strtolong (((xp_awk_val_str_t*)v)->buf, 0, &endptr); - if (*endptr == XP_CHAR('.') || - *endptr == XP_CHAR('E') || - *endptr == XP_CHAR('e')) + if (*endptr == XP_T('.') || + *endptr == XP_T('E') || + *endptr == XP_T('e')) { *r = xp_awk_strtoreal (((xp_awk_val_str_t*)v)->buf); return 1; /* real */ @@ -2831,13 +2831,13 @@ static xp_char_t* __val_to_str (xp_awk_val_t* v, int* errnum, xp_str_t* buf) return XP_NULL; } - tmp[0] = XP_CHAR('0'); - tmp[1] = XP_CHAR('\0'); + tmp[0] = XP_T('0'); + tmp[1] = XP_T('\0'); return tmp; } else { - if (xp_str_cat (buf, XP_TEXT("0")) == (xp_size_t)-1) + if (xp_str_cat (buf, XP_T("0")) == (xp_size_t)-1) { *errnum = XP_AWK_ENOMEM; return XP_NULL; @@ -2860,7 +2860,7 @@ static xp_char_t* __val_to_str (xp_awk_val_t* v, int* errnum, xp_str_t* buf) return XP_NULL; } - tmp[len] = XP_CHAR('\0'); + tmp[len] = XP_T('\0'); } else { @@ -2869,7 +2869,7 @@ static xp_char_t* __val_to_str (xp_awk_val_t* v, int* errnum, xp_str_t* buf) /* extend the buffer */ if (xp_str_nccat ( - buf, XP_CHAR(' '), len) == (xp_size_t)-1) + buf, XP_T(' '), len) == (xp_size_t)-1) { *errnum = XP_AWK_ENOMEM; return XP_NULL; @@ -2881,11 +2881,11 @@ static xp_char_t* __val_to_str (xp_awk_val_t* v, int* errnum, xp_str_t* buf) while (t > 0) { - tmp[--len] = (xp_char_t)(t % 10) + XP_CHAR('0'); + tmp[--len] = (xp_char_t)(t % 10) + XP_T('0'); t /= 10; } - if (((xp_awk_val_int_t*)v)->val < 0) tmp[--len] = XP_CHAR('-'); + if (((xp_awk_val_int_t*)v)->val < 0) tmp[--len] = XP_T('-'); /*return (buf == XP_NULL) tmp: XP_STR_BUF(buf);*/ return tmp; @@ -2974,7 +2974,7 @@ static xp_char_t* __idxnde_to_str (xp_awk_run_t* run, xp_awk_nde_t* nde) /* TODO: configurable index seperator */ if (XP_STR_LEN(&idxstr) > 0 && - xp_str_cat (&idxstr, XP_TEXT(",")) == (xp_size_t)-1) + xp_str_cat (&idxstr, XP_T(",")) == (xp_size_t)-1) { xp_awk_refdownval (run, idx); xp_str_close (&idxstr); diff --git a/ase/awk/sa.c b/ase/awk/sa.c index 327edfec..c8b08dc1 100644 --- a/ase/awk/sa.c +++ b/ase/awk/sa.c @@ -1,5 +1,5 @@ /* - * $Id: sa.c,v 1.20 2006-05-04 15:59:43 bacon Exp $ + * $Id: sa.c,v 1.21 2006-05-06 12:52:36 bacon Exp $ */ #include @@ -11,7 +11,7 @@ static xp_char_t* __adjust_format (const xp_char_t* format); xp_size_t xp_strlen (const xp_char_t* str) { const xp_char_t* p = str; - while (*p != XP_CHAR('\0')) p++; + while (*p != XP_T('\0')) p++; return p - str; } @@ -56,7 +56,7 @@ xp_char_t* xp_strxdup2 ( xp_size_t xp_strcpy (xp_char_t* buf, const xp_char_t* str) { xp_char_t* org = buf; - while ((*buf++ = *str++) != XP_CHAR('\0')); + while ((*buf++ = *str++) != XP_T('\0')); return buf - org - 1; } @@ -64,13 +64,13 @@ xp_size_t xp_strncpy (xp_char_t* buf, const xp_char_t* str, xp_size_t len) { const xp_char_t* end = str + len; while (str < end) *buf++ = *str++; - *buf = XP_CHAR('\0'); + *buf = XP_T('\0'); return len; } int xp_strcmp (const xp_char_t* s1, const xp_char_t* s2) { - while (*s1 == *s2 && *s2 != XP_CHAR('\0')) s1++, s2++; + while (*s1 == *s2 && *s2 != XP_T('\0')) s1++, s2++; if (*s1 > *s2) return 1; else if (*s1 < *s2) return -1; return 0; @@ -165,7 +165,7 @@ xp_str_t* xp_str_open (xp_str_t* str, xp_size_t capa) str->size = 0; str->capa = capa; - str->buf[0] = XP_CHAR('\0'); + str->buf[0] = XP_T('\0'); return str; } @@ -191,7 +191,7 @@ static xp_size_t __strncpy (xp_char_t* buf, const xp_char_t* str, xp_size_t len) { const xp_char_t* end = str + len; while (str < end) *buf++ = *str++; - *buf = XP_CHAR('\0'); + *buf = XP_T('\0'); return len; } @@ -216,7 +216,7 @@ xp_size_t xp_str_ncat (xp_str_t* str, const xp_char_t* s, xp_size_t len) } str->size += __strncpy (&str->buf[str->size], s, len); - str->buf[str->size] = XP_CHAR('\0'); + str->buf[str->size] = XP_T('\0'); return str->size; } @@ -242,7 +242,7 @@ xp_size_t xp_str_nccat (xp_str_t* str, xp_char_t c, xp_size_t len) void xp_str_clear (xp_str_t* str) { str->size = 0; - str->buf[0] = XP_CHAR('\0'); + str->buf[0] = XP_T('\0'); } @@ -268,15 +268,15 @@ static xp_char_t* __adjust_format (const xp_char_t* format) if (xp_str_open (&str, 256) == XP_NULL) return XP_NULL; - while (*fp != XP_CHAR('\0')) + while (*fp != XP_T('\0')) { - while (*fp != XP_CHAR('\0') && *fp != XP_CHAR('%')) + while (*fp != XP_T('\0') && *fp != XP_T('%')) { ADDC (str, *fp++); } - if (*fp == XP_CHAR('\0')) break; - xp_assert (*fp == XP_CHAR('%')); + if (*fp == XP_T('\0')) break; + xp_assert (*fp == XP_T('%')); ch = *fp++; ADDC (str, ch); /* add % */ @@ -286,12 +286,12 @@ static xp_char_t* __adjust_format (const xp_char_t* format) /* flags */ for (;;) { - if (ch == XP_CHAR(' ') || ch == XP_CHAR('+') || - ch == XP_CHAR('-') || ch == XP_CHAR('#')) + if (ch == XP_T(' ') || ch == XP_T('+') || + ch == XP_T('-') || ch == XP_T('#')) { ADDC (str, ch); } - else if (ch == XP_CHAR('0')) + else if (ch == XP_T('0')) { ADDC (str, ch); ch = *fp++; @@ -303,7 +303,7 @@ static xp_char_t* __adjust_format (const xp_char_t* format) } /* check the width */ - if (ch == XP_CHAR('*')) ADDC (str, ch); + if (ch == XP_T('*')) ADDC (str, ch); else { while (xp_isdigit(ch)) @@ -314,12 +314,12 @@ static xp_char_t* __adjust_format (const xp_char_t* format) } /* precision */ - if (ch == XP_CHAR('.')) + if (ch == XP_T('.')) { ADDC (str, ch); ch = *fp++; - if (ch == XP_CHAR('*')) ADDC (str, ch); + if (ch == XP_T('*')) ADDC (str, ch); else { while (xp_isdigit(ch)) @@ -333,8 +333,8 @@ static xp_char_t* __adjust_format (const xp_char_t* format) /* modifier */ for (modifier = 0;;) { - if (ch == XP_CHAR('h')) modifier = MOD_SHORT; - else if (ch == XP_CHAR('l')) + if (ch == XP_T('h')) modifier = MOD_SHORT; + else if (ch == XP_T('l')) { modifier = (modifier == MOD_LONG)? MOD_LONGLONG: MOD_LONG; } @@ -344,15 +344,15 @@ static xp_char_t* __adjust_format (const xp_char_t* format) /* type */ - if (ch == XP_CHAR('%')) ADDC (str, ch); - else if (ch == XP_CHAR('c') || ch == XP_CHAR('s')) + if (ch == XP_T('%')) ADDC (str, ch); + else if (ch == XP_T('c') || ch == XP_T('s')) { #if !defined(XP_CHAR_IS_MCHAR) && !defined(_WIN32) ADDC (str, 'l'); #endif ADDC (str, ch); } - else if (ch == XP_CHAR('C') || ch == XP_CHAR('S')) + else if (ch == XP_T('C') || ch == XP_T('S')) { #ifdef _WIN32 ADDC (str, ch); @@ -363,9 +363,9 @@ static xp_char_t* __adjust_format (const xp_char_t* format) ADDC (str, xp_tolower(ch)); #endif } - else if (ch == XP_CHAR('d') || ch == XP_CHAR('i') || - ch == XP_CHAR('o') || ch == XP_CHAR('u') || - ch == XP_CHAR('x') || ch == XP_CHAR('X')) + else if (ch == XP_T('d') || ch == XP_T('i') || + ch == XP_T('o') || ch == XP_T('u') || + ch == XP_T('x') || ch == XP_T('X')) { if (modifier == MOD_SHORT) { @@ -388,7 +388,7 @@ static xp_char_t* __adjust_format (const xp_char_t* format) } ADDC (str, ch); } - else if (ch == XP_CHAR('\0')) break; + else if (ch == XP_T('\0')) break; else ADDC (str, ch); } diff --git a/ase/awk/tree.c b/ase/awk/tree.c index c9f3fa2b..2fe93d80 100644 --- a/ase/awk/tree.c +++ b/ase/awk/tree.c @@ -1,5 +1,5 @@ /* - * $Id: tree.c,v 1.46 2006-05-02 15:43:11 bacon Exp $ + * $Id: tree.c,v 1.47 2006-05-06 12:52:36 bacon Exp $ */ #include @@ -12,60 +12,60 @@ static const xp_char_t* __assop_str[] = { - XP_TEXT("="), - XP_TEXT("+="), - XP_TEXT("-="), - XP_TEXT("*="), - XP_TEXT("/="), - XP_TEXT("%="), - XP_TEXT("**=") + XP_T("="), + XP_T("+="), + XP_T("-="), + XP_T("*="), + XP_T("/="), + XP_T("%="), + XP_T("**=") }; static const xp_char_t* __binop_str[] = { - XP_TEXT("||"), - XP_TEXT("&&"), - XP_TEXT("in"), + XP_T("||"), + XP_T("&&"), + XP_T("in"), - XP_TEXT("|"), - XP_TEXT("^"), - XP_TEXT("&"), + XP_T("|"), + XP_T("^"), + XP_T("&"), - XP_TEXT("=="), - XP_TEXT("!="), - XP_TEXT(">"), - XP_TEXT(">="), - XP_TEXT("<"), - XP_TEXT("<="), + XP_T("=="), + XP_T("!="), + XP_T(">"), + XP_T(">="), + XP_T("<"), + XP_T("<="), - XP_TEXT("<<"), - XP_TEXT(">>"), + XP_T("<<"), + XP_T(">>"), - XP_TEXT("+"), - XP_TEXT("-"), - XP_TEXT("*"), - XP_TEXT("/"), - XP_TEXT("%"), - XP_TEXT("**"), + XP_T("+"), + XP_T("-"), + XP_T("*"), + XP_T("/"), + XP_T("%"), + XP_T("**"), - XP_TEXT("~"), - XP_TEXT("!~") + XP_T("~"), + XP_T("!~") }; static const xp_char_t* __unrop_str[] = { - XP_TEXT("+"), - XP_TEXT("-"), - XP_TEXT("!"), - XP_TEXT("~") + XP_T("+"), + XP_T("-"), + XP_T("!"), + XP_T("~") }; static const xp_char_t* __incop_str[] = { - XP_TEXT("++"), - XP_TEXT("--"), - XP_TEXT("++"), - XP_TEXT("--") + XP_T("++"), + XP_T("--"), + XP_T("++"), + XP_T("--") }; static void __print_tabs (int depth); @@ -76,7 +76,7 @@ static void __print_statements (xp_awk_nde_t* tree, int depth); static void __print_tabs (int depth) { int i; - for (i = 0; i < depth; i++) xp_printf (XP_TEXT("\t")); + for (i = 0; i < depth; i++) xp_printf (XP_T("\t")); } static int __print_expression (xp_awk_nde_t* nde) @@ -87,149 +87,149 @@ static int __print_expression (xp_awk_nde_t* nde) { xp_awk_nde_t* p = ((xp_awk_nde_grp_t*)nde)->body; - xp_printf (XP_TEXT("(")); + xp_printf (XP_T("(")); while (p != XP_NULL) { __print_expression (p); - if (p->next != XP_NULL) xp_printf (XP_TEXT(",")); + if (p->next != XP_NULL) xp_printf (XP_T(",")); p = p->next; } - xp_printf (XP_TEXT(")")); + xp_printf (XP_T(")")); } break; case XP_AWK_NDE_ASS: if (__print_expression (((xp_awk_nde_ass_t*)nde)->left) == -1) return -1; - xp_printf (XP_TEXT(" %s "), + xp_printf (XP_T(" %s "), __assop_str[((xp_awk_nde_exp_t*)nde)->opcode]); if (__print_expression (((xp_awk_nde_ass_t*)nde)->right) == -1) return -1; xp_assert ((((xp_awk_nde_ass_t*)nde)->right)->next == XP_NULL); break; case XP_AWK_NDE_EXP_BIN: - xp_printf (XP_TEXT("(")); + xp_printf (XP_T("(")); if (__print_expression(((xp_awk_nde_exp_t*)nde)->left) == -1) return -1; xp_assert ((((xp_awk_nde_exp_t*)nde)->left)->next == XP_NULL); - xp_printf (XP_TEXT(" %s "), + xp_printf (XP_T(" %s "), __binop_str[((xp_awk_nde_exp_t*)nde)->opcode]); if (((xp_awk_nde_exp_t*)nde)->right->type == XP_AWK_NDE_ASS) - xp_printf (XP_TEXT("(")); + xp_printf (XP_T("(")); if (__print_expression (((xp_awk_nde_exp_t*)nde)->right) == -1) return -1; if (((xp_awk_nde_exp_t*)nde)->right->type == XP_AWK_NDE_ASS) - xp_printf (XP_TEXT(")")); + xp_printf (XP_T(")")); xp_assert ((((xp_awk_nde_exp_t*)nde)->right)->next == XP_NULL); - xp_printf (XP_TEXT(")")); + xp_printf (XP_T(")")); break; case XP_AWK_NDE_EXP_UNR: xp_assert (((xp_awk_nde_exp_t*)nde)->right == XP_NULL); - xp_printf (XP_TEXT("%s("), + xp_printf (XP_T("%s("), __unrop_str[((xp_awk_nde_exp_t*)nde)->opcode]); if (__print_expression (((xp_awk_nde_exp_t*)nde)->left) == -1) return -1; - xp_printf (XP_TEXT(")")); + xp_printf (XP_T(")")); break; case XP_AWK_NDE_EXP_INCPRE: xp_assert (((xp_awk_nde_exp_t*)nde)->right == XP_NULL); - xp_printf (XP_TEXT("%s("), + xp_printf (XP_T("%s("), __incop_str[((xp_awk_nde_exp_t*)nde)->opcode]); if (__print_expression (((xp_awk_nde_exp_t*)nde)->left) == -1) return -1; - xp_printf (XP_TEXT(")")); + xp_printf (XP_T(")")); break; case XP_AWK_NDE_EXP_INCPST: xp_assert (((xp_awk_nde_exp_t*)nde)->right == XP_NULL); - xp_printf (XP_TEXT("(")); + xp_printf (XP_T("(")); if (__print_expression (((xp_awk_nde_exp_t*)nde)->left) == -1) return -1; - xp_printf (XP_TEXT(")%s"), + xp_printf (XP_T(")%s"), __incop_str[((xp_awk_nde_exp_t*)nde)->opcode]); break; case XP_AWK_NDE_CND: - xp_printf (XP_TEXT("(")); + xp_printf (XP_T("(")); if (__print_expression(((xp_awk_nde_cnd_t*)nde)->test) == -1) return -1; - xp_printf (XP_TEXT(")?")); + xp_printf (XP_T(")?")); if (__print_expression(((xp_awk_nde_cnd_t*)nde)->left) == -1) return -1; - xp_printf (XP_TEXT(":")); + xp_printf (XP_T(":")); if (__print_expression(((xp_awk_nde_cnd_t*)nde)->right) == -1) return -1; break; case XP_AWK_NDE_INT: #if defined(__LCC__) - xp_printf (XP_TEXT("%lld"), (long long)((xp_awk_nde_int_t*)nde)->val); + xp_printf (XP_T("%lld"), (long long)((xp_awk_nde_int_t*)nde)->val); #elif defined(__BORLANDC__) || defined(_MSC_VER) - xp_printf (XP_TEXT("%I64d"), (__int64)((xp_awk_nde_int_t*)nde)->val); + xp_printf (XP_T("%I64d"), (__int64)((xp_awk_nde_int_t*)nde)->val); #elif defined(vax) || defined(__vax) || defined(_SCO_DS) - xp_printf (XP_TEXT("%ld"), (long)((xp_awk_nde_int_t*)nde)->val); + xp_printf (XP_T("%ld"), (long)((xp_awk_nde_int_t*)nde)->val); #else - xp_printf (XP_TEXT("%lld"), (long long)((xp_awk_nde_int_t*)nde)->val); + xp_printf (XP_T("%lld"), (long long)((xp_awk_nde_int_t*)nde)->val); #endif break; case XP_AWK_NDE_REAL: - xp_printf (XP_TEXT("%Lf"), (long double)((xp_awk_nde_real_t*)nde)->val); + xp_printf (XP_T("%Lf"), (long double)((xp_awk_nde_real_t*)nde)->val); break; case XP_AWK_NDE_STR: /* TODO: buf, len */ - xp_printf (XP_TEXT("\"%s\""), ((xp_awk_nde_str_t*)nde)->buf); + xp_printf (XP_T("\"%s\""), ((xp_awk_nde_str_t*)nde)->buf); break; case XP_AWK_NDE_REX: /* TODO: buf, len */ - xp_printf (XP_TEXT("/%s/"), ((xp_awk_nde_rex_t*)nde)->buf); + xp_printf (XP_T("/%s/"), ((xp_awk_nde_rex_t*)nde)->buf); break; case XP_AWK_NDE_ARG: xp_assert (((xp_awk_nde_var_t*)nde)->id.idxa != (xp_size_t)-1); - xp_printf (XP_TEXT("__arg%lu"), + xp_printf (XP_T("__arg%lu"), (unsigned long)((xp_awk_nde_var_t*)nde)->id.idxa); xp_assert (((xp_awk_nde_var_t*)nde)->idx == XP_NULL); break; case XP_AWK_NDE_ARGIDX: xp_assert (((xp_awk_nde_var_t*)nde)->id.idxa != (xp_size_t)-1); - xp_printf (XP_TEXT("__arg%lu["), + xp_printf (XP_T("__arg%lu["), (unsigned long)((xp_awk_nde_var_t*)nde)->id.idxa); xp_assert (((xp_awk_nde_var_t*)nde)->idx != XP_NULL); __print_expression_list (((xp_awk_nde_var_t*)nde)->idx); - xp_printf (XP_TEXT("]")); + xp_printf (XP_T("]")); break; case XP_AWK_NDE_NAMED: xp_assert (((xp_awk_nde_var_t*)nde)->id.idxa == (xp_size_t)-1); - xp_printf (XP_TEXT("%s"), ((xp_awk_nde_var_t*)nde)->id.name); + xp_printf (XP_T("%s"), ((xp_awk_nde_var_t*)nde)->id.name); xp_assert (((xp_awk_nde_var_t*)nde)->idx == XP_NULL); break; case XP_AWK_NDE_NAMEDIDX: xp_assert (((xp_awk_nde_var_t*)nde)->id.idxa == (xp_size_t)-1); - xp_printf (XP_TEXT("%s["), ((xp_awk_nde_var_t*)nde)->id.name); + xp_printf (XP_T("%s["), ((xp_awk_nde_var_t*)nde)->id.name); xp_assert (((xp_awk_nde_var_t*)nde)->idx != XP_NULL); __print_expression_list (((xp_awk_nde_var_t*)nde)->idx); - xp_printf (XP_TEXT("]")); + xp_printf (XP_T("]")); break; case XP_AWK_NDE_GLOBAL: if (((xp_awk_nde_var_t*)nde)->id.idxa != (xp_size_t)-1) { - xp_printf (XP_TEXT("__global%lu"), + xp_printf (XP_T("__global%lu"), (unsigned long)((xp_awk_nde_var_t*)nde)->id.idxa); } else { - xp_printf (XP_TEXT("%s"), ((xp_awk_nde_var_t*)nde)->id.name); + xp_printf (XP_T("%s"), ((xp_awk_nde_var_t*)nde)->id.name); } xp_assert (((xp_awk_nde_var_t*)nde)->idx == XP_NULL); break; @@ -237,27 +237,27 @@ static int __print_expression (xp_awk_nde_t* nde) case XP_AWK_NDE_GLOBALIDX: if (((xp_awk_nde_var_t*)nde)->id.idxa != (xp_size_t)-1) { - xp_printf (XP_TEXT("__global%lu["), + xp_printf (XP_T("__global%lu["), (unsigned long)((xp_awk_nde_var_t*)nde)->id.idxa); } else { - xp_printf (XP_TEXT("%s["), ((xp_awk_nde_var_t*)nde)->id.name); + xp_printf (XP_T("%s["), ((xp_awk_nde_var_t*)nde)->id.name); } xp_assert (((xp_awk_nde_var_t*)nde)->idx != XP_NULL); __print_expression_list (((xp_awk_nde_var_t*)nde)->idx); - xp_printf (XP_TEXT("]")); + xp_printf (XP_T("]")); break; case XP_AWK_NDE_LOCAL: if (((xp_awk_nde_var_t*)nde)->id.idxa != (xp_size_t)-1) { - xp_printf (XP_TEXT("__local%lu"), + xp_printf (XP_T("__local%lu"), (unsigned long)((xp_awk_nde_var_t*)nde)->id.idxa); } else { - xp_printf (XP_TEXT("%s"), ((xp_awk_nde_var_t*)nde)->id.name); + xp_printf (XP_T("%s"), ((xp_awk_nde_var_t*)nde)->id.name); } xp_assert (((xp_awk_nde_var_t*)nde)->idx == XP_NULL); break; @@ -265,27 +265,27 @@ static int __print_expression (xp_awk_nde_t* nde) case XP_AWK_NDE_LOCALIDX: if (((xp_awk_nde_var_t*)nde)->id.idxa != (xp_size_t)-1) { - xp_printf (XP_TEXT("__local%lu["), + xp_printf (XP_T("__local%lu["), (unsigned long)((xp_awk_nde_var_t*)nde)->id.idxa); } else { - xp_printf (XP_TEXT("%s["), ((xp_awk_nde_var_t*)nde)->id.name); + xp_printf (XP_T("%s["), ((xp_awk_nde_var_t*)nde)->id.name); } xp_assert (((xp_awk_nde_var_t*)nde)->idx != XP_NULL); __print_expression_list (((xp_awk_nde_var_t*)nde)->idx); - xp_printf (XP_TEXT("]")); + xp_printf (XP_T("]")); break; case XP_AWK_NDE_POS: - xp_printf (XP_TEXT("$")); + xp_printf (XP_T("$")); __print_expression (((xp_awk_nde_pos_t*)nde)->val); break; case XP_AWK_NDE_CALL: - xp_printf (XP_TEXT("%s ("), ((xp_awk_nde_call_t*)nde)->name); + xp_printf (XP_T("%s ("), ((xp_awk_nde_call_t*)nde)->name); if (__print_expression_list (((xp_awk_nde_call_t*)nde)->args) == -1) return -1; - xp_printf (XP_TEXT(")")); + xp_printf (XP_T(")")); break; default: @@ -303,7 +303,7 @@ static int __print_expression_list (xp_awk_nde_t* tree) { if (__print_expression(p) == -1) return -1; p = p->next; - if (p != XP_NULL) xp_printf (XP_TEXT(",")); + if (p != XP_NULL) xp_printf (XP_T(",")); } return 0; @@ -321,35 +321,35 @@ static void __print_statements (xp_awk_nde_t* tree, int depth) { case XP_AWK_NDE_NULL: __print_tabs (depth); - xp_printf (XP_TEXT(";\n")); + xp_printf (XP_T(";\n")); break; case XP_AWK_NDE_BLK: __print_tabs (depth); - xp_printf (XP_TEXT("{\n")); + xp_printf (XP_T("{\n")); if (((xp_awk_nde_blk_t*)p)->nlocals > 0) { __print_tabs (depth + 1); - xp_printf (XP_TEXT("local ")); + xp_printf (XP_T("local ")); for (i = 0; i < ((xp_awk_nde_blk_t*)p)->nlocals - 1; i++) { - xp_printf (XP_TEXT("__local%lu, "), (unsigned long)i); + xp_printf (XP_T("__local%lu, "), (unsigned long)i); } - xp_printf (XP_TEXT("__local%lu;\n"), (unsigned long)i); + xp_printf (XP_T("__local%lu;\n"), (unsigned long)i); } __print_statements (((xp_awk_nde_blk_t*)p)->body, depth + 1); __print_tabs (depth); - xp_printf (XP_TEXT("}\n")); + xp_printf (XP_T("}\n")); break; case XP_AWK_NDE_IF: __print_tabs (depth); - xp_printf (XP_TEXT("if (")); + xp_printf (XP_T("if (")); __print_expression (((xp_awk_nde_if_t*)p)->test); - xp_printf (XP_TEXT(")\n")); + xp_printf (XP_T(")\n")); xp_assert (((xp_awk_nde_if_t*)p)->then_part != XP_NULL); if (((xp_awk_nde_if_t*)p)->then_part->type == XP_AWK_NDE_BLK) @@ -360,7 +360,7 @@ static void __print_statements (xp_awk_nde_t* tree, int depth) if (((xp_awk_nde_if_t*)p)->else_part != XP_NULL) { __print_tabs (depth); - xp_printf (XP_TEXT("else\n")); + xp_printf (XP_T("else\n")); if (((xp_awk_nde_if_t*)p)->else_part->type == XP_AWK_NDE_BLK) __print_statements (((xp_awk_nde_if_t*)p)->else_part, depth); else @@ -369,9 +369,9 @@ static void __print_statements (xp_awk_nde_t* tree, int depth) break; case XP_AWK_NDE_WHILE: __print_tabs (depth); - xp_printf (XP_TEXT("while (")); + xp_printf (XP_T("while (")); __print_expression (((xp_awk_nde_while_t*)p)->test); - xp_printf (XP_TEXT(")\n")); + xp_printf (XP_T(")\n")); if (((xp_awk_nde_while_t*)p)->body->type == XP_AWK_NDE_BLK) { __print_statements (((xp_awk_nde_while_t*)p)->body, depth); @@ -384,7 +384,7 @@ static void __print_statements (xp_awk_nde_t* tree, int depth) case XP_AWK_NDE_DOWHILE: __print_tabs (depth); - xp_printf (XP_TEXT("do\n")); + xp_printf (XP_T("do\n")); if (((xp_awk_nde_while_t*)p)->body->type == XP_AWK_NDE_BLK) { __print_statements (((xp_awk_nde_while_t*)p)->body, depth); @@ -395,29 +395,29 @@ static void __print_statements (xp_awk_nde_t* tree, int depth) } __print_tabs (depth); - xp_printf (XP_TEXT("while (")); + xp_printf (XP_T("while (")); __print_expression (((xp_awk_nde_while_t*)p)->test); - xp_printf (XP_TEXT(");\n")); + xp_printf (XP_T(");\n")); break; case XP_AWK_NDE_FOR: __print_tabs (depth); - xp_printf (XP_TEXT("for (")); + xp_printf (XP_T("for (")); if (((xp_awk_nde_for_t*)p)->init != XP_NULL) { __print_expression (((xp_awk_nde_for_t*)p)->init); } - xp_printf (XP_TEXT("; ")); + xp_printf (XP_T("; ")); if (((xp_awk_nde_for_t*)p)->test != XP_NULL) { __print_expression (((xp_awk_nde_for_t*)p)->test); } - xp_printf (XP_TEXT("; ")); + xp_printf (XP_T("; ")); if (((xp_awk_nde_for_t*)p)->incr != XP_NULL) { __print_expression (((xp_awk_nde_for_t*)p)->incr); } - xp_printf (XP_TEXT(")\n")); + xp_printf (XP_T(")\n")); if (((xp_awk_nde_for_t*)p)->body->type == XP_AWK_NDE_BLK) { @@ -431,9 +431,9 @@ static void __print_statements (xp_awk_nde_t* tree, int depth) case XP_AWK_NDE_FOREACH: __print_tabs (depth); - xp_printf (XP_TEXT("for ")); + xp_printf (XP_T("for ")); __print_expression (((xp_awk_nde_foreach_t*)p)->test); - xp_printf (XP_TEXT("\n")); + xp_printf (XP_T("\n")); if (((xp_awk_nde_foreach_t*)p)->body->type == XP_AWK_NDE_BLK) { __print_statements (((xp_awk_nde_foreach_t*)p)->body, depth); @@ -446,32 +446,32 @@ static void __print_statements (xp_awk_nde_t* tree, int depth) case XP_AWK_NDE_BREAK: __print_tabs (depth); - xp_printf (XP_TEXT("break;\n")); + xp_printf (XP_T("break;\n")); break; case XP_AWK_NDE_CONTINUE: __print_tabs (depth); - xp_printf (XP_TEXT("continue;\n")); + xp_printf (XP_T("continue;\n")); break; case XP_AWK_NDE_RETURN: __print_tabs (depth); if (((xp_awk_nde_return_t*)p)->val == XP_NULL) { - xp_printf (XP_TEXT("return;\n")); + xp_printf (XP_T("return;\n")); } else { - xp_printf (XP_TEXT("return ")); + xp_printf (XP_T("return ")); xp_assert (((xp_awk_nde_return_t*)p)->val->next == XP_NULL); if (__print_expression(((xp_awk_nde_return_t*)p)->val) == 0) { - xp_printf (XP_TEXT(";\n")); + xp_printf (XP_T(";\n")); } else { xp_awk_nde_return_t* x = (xp_awk_nde_return_t*)p; - xp_printf (XP_TEXT("***INTERNAL ERROR: unknown nde type - %d\n"), x->type); + xp_printf (XP_T("***INTERNAL ERROR: unknown nde type - %d\n"), x->type); } } break; @@ -481,43 +481,43 @@ static void __print_statements (xp_awk_nde_t* tree, int depth) if (((xp_awk_nde_exit_t*)p)->val == XP_NULL) { - xp_printf (XP_TEXT("exit;\n")); + xp_printf (XP_T("exit;\n")); } else { - xp_printf (XP_TEXT("exit ")); + xp_printf (XP_T("exit ")); xp_assert (((xp_awk_nde_exit_t*)p)->val->next == XP_NULL); if (__print_expression(((xp_awk_nde_exit_t*)p)->val) == 0) { - xp_printf (XP_TEXT(";\n")); + xp_printf (XP_T(";\n")); } else { xp_awk_nde_exit_t* x = (xp_awk_nde_exit_t*)p; - xp_printf (XP_TEXT("***INTERNAL ERROR: unknown nde type - %d\n"), x->type); + xp_printf (XP_T("***INTERNAL ERROR: unknown nde type - %d\n"), x->type); } } break; case XP_AWK_NDE_NEXT: __print_tabs (depth); - xp_printf (XP_TEXT("next;\n")); + xp_printf (XP_T("next;\n")); break; case XP_AWK_NDE_NEXTFILE: __print_tabs (depth); - xp_printf (XP_TEXT("nextfile;\n")); + xp_printf (XP_T("nextfile;\n")); break; default: __print_tabs (depth); if (__print_expression(p) == 0) { - xp_printf (XP_TEXT(";\n")); + xp_printf (XP_T(";\n")); } else { - xp_printf (XP_TEXT("***INTERNAL ERROR: unknown type - %d\n"), p->type); + xp_printf (XP_T("***INTERNAL ERROR: unknown type - %d\n"), p->type); } } diff --git a/ase/awk/val.c b/ase/awk/val.c index 204721da..442b58a0 100644 --- a/ase/awk/val.c +++ b/ase/awk/val.c @@ -1,5 +1,5 @@ /* - * $Id: val.c,v 1.28 2006-04-30 17:10:30 bacon Exp $ + * $Id: val.c,v 1.29 2006-05-06 12:52:36 bacon Exp $ */ #include @@ -144,9 +144,9 @@ xp_awk_val_t* xp_awk_makerexval (const xp_char_t* str, xp_size_t len) static void __free_map_val (void* run, void* v) { /* -xp_printf (XP_TEXT("refdown in map free...")); +xp_printf (XP_T("refdown in map free...")); xp_awk_printval (v); -xp_printf (XP_TEXT("\n")); +xp_printf (XP_T("\n")); */ xp_awk_refdownval (run, v); } @@ -182,9 +182,9 @@ void xp_awk_freeval (xp_awk_run_t* run, xp_awk_val_t* val, xp_bool_t cache) { if (xp_awk_isbuiltinval(val)) return; -xp_printf (XP_TEXT("freeing [cache=%d] ... "), cache); +xp_printf (XP_T("freeing [cache=%d] ... "), cache); xp_awk_printval (val); -xp_printf (XP_TEXT("\n")); +xp_printf (XP_T("\n")); switch (val->type) { case XP_AWK_VAL_NIL: @@ -235,9 +235,9 @@ void xp_awk_refupval (xp_awk_val_t* val) { if (xp_awk_isbuiltinval(val)) return; /* -xp_printf (XP_TEXT("ref up ")); +xp_printf (XP_T("ref up ")); xp_awk_printval (val); -xp_printf (XP_TEXT("\n")); +xp_printf (XP_T("\n")); */ val->ref++; } @@ -247,10 +247,10 @@ void xp_awk_refdownval (xp_awk_run_t* run, xp_awk_val_t* val) if (xp_awk_isbuiltinval(val)) return; /* -xp_printf (XP_TEXT("%p, %p, %p\n"), xp_awk_val_nil, &__awk_nil, val); -xp_printf (XP_TEXT("ref down [count=>%d]\n"), (int)val->ref); +xp_printf (XP_T("%p, %p, %p\n"), xp_awk_val_nil, &__awk_nil, val); +xp_printf (XP_T("ref down [count=>%d]\n"), (int)val->ref); xp_awk_printval (val); -xp_printf (XP_TEXT("\n")); +xp_printf (XP_T("\n")); */ xp_assert (val->ref > 0); @@ -258,9 +258,9 @@ xp_printf (XP_TEXT("\n")); if (val->ref <= 0) { /* -xp_printf (XP_TEXT("**FREEING ")); +xp_printf (XP_T("**FREEING ")); xp_awk_printval (val); -xp_printf (XP_TEXT("\n")); +xp_printf (XP_T("\n")); */ xp_awk_freeval(run, val, xp_true); } @@ -323,9 +323,9 @@ xp_bool_t xp_awk_boolval (xp_awk_val_t* val) static int __print_pair (xp_awk_pair_t* pair, void* arg) { - xp_printf (XP_TEXT(" %s=>"), pair->key); + xp_printf (XP_T(" %s=>"), pair->key); xp_awk_printval (pair->val); - xp_printf (XP_TEXT(" ")); + xp_printf (XP_T(" ")); return 0; } @@ -335,46 +335,46 @@ void xp_awk_printval (xp_awk_val_t* val) switch (val->type) { case XP_AWK_VAL_NIL: - xp_printf (XP_TEXT("nil")); + xp_printf (XP_T("nil")); break; case XP_AWK_VAL_INT: #if defined(__LCC__) - xp_printf (XP_TEXT("%lld"), + xp_printf (XP_T("%lld"), (long long)((xp_awk_val_int_t*)val)->val); #elif defined(__BORLANDC__) || defined(_MSC_VER) - xp_printf (XP_TEXT("%I64d"), + xp_printf (XP_T("%I64d"), (__int64)((xp_awk_nde_int_t*)val)->val); #elif defined(vax) || defined(__vax) || defined(_SCO_DS) - xp_printf (XP_TEXT("%ld"), + xp_printf (XP_T("%ld"), (long)((xp_awk_val_int_t*)val)->val); #else - xp_printf (XP_TEXT("%lld"), + xp_printf (XP_T("%lld"), (long long)((xp_awk_val_int_t*)val)->val); #endif break; case XP_AWK_VAL_REAL: - xp_printf (XP_TEXT("%Lf"), + xp_printf (XP_T("%Lf"), (long double)((xp_awk_val_real_t*)val)->val); break; case XP_AWK_VAL_STR: - xp_printf (XP_TEXT("%s"), ((xp_awk_val_str_t*)val)->buf); + xp_printf (XP_T("%s"), ((xp_awk_val_str_t*)val)->buf); break; case XP_AWK_VAL_REX: - xp_printf (XP_TEXT("REX[%s]"), ((xp_awk_val_rex_t*)val)->buf); + xp_printf (XP_T("REX[%s]"), ((xp_awk_val_rex_t*)val)->buf); break; case XP_AWK_VAL_MAP: - xp_printf (XP_TEXT("MAP[")); + xp_printf (XP_T("MAP[")); xp_awk_map_walk (((xp_awk_val_map_t*)val)->map, __print_pair, XP_NULL); - xp_printf (XP_TEXT("]")); + xp_printf (XP_T("]")); break; default: xp_assert (!"should never happen - invalid value type"); - xp_printf (XP_TEXT("**** INTERNAL ERROR - INVALID VALUE TYPE ****\n")); + xp_printf (XP_T("**** INTERNAL ERROR - INVALID VALUE TYPE ****\n")); } } diff --git a/ase/macros.h b/ase/macros.h index d01e4858..6f056e06 100644 --- a/ase/macros.h +++ b/ase/macros.h @@ -1,5 +1,5 @@ /* - * $Id: macros.h,v 1.31 2006-04-03 10:40:26 bacon Exp $ + * $Id: macros.h,v 1.32 2006-05-06 12:52:36 bacon Exp $ */ #ifndef _XP_MACROS_H_ @@ -59,28 +59,56 @@ } \ } while (0); - +/* obsolete */ #define XP_MQUOTE(val) #val #define XP_MCHAR(ch) ((xp_mchar_t)ch) #define XP_MTEXT(txt) ((const xp_mchar_t*)txt) +/* new short form */ +#define XP_MQ(val) #val +#define XP_MC(ch) ((xp_mchar_t)ch) +#define XP_MS(str) ((const xp_mchar_t*)str) +#define XP_MT(txt) (txt) + /* TODO: if the compiler doesn't have the built-in wchar_t support * XP_WCHAR & XP_WTEXT must be defined differently. #define XP_WCHAR(ch) ((xp_wchar_t)ch) #define XP_WTEXT(txt) don't know yet... may have to call a function? */ + +/* obsolete */ #define XP_WQUOTE(val) ((const xp_char_t*)L###val) #define XP_WCHAR(ch) ((xp_wchar_t)L##ch) #define XP_WTEXT(txt) ((const xp_wchar_t*)L##txt) +/* new short form */ +#define XP_WQ(val) ((const xp_char_t*)L###val) +#define XP_WC(ch) ((xp_wchar_t)L##ch) +#define XP_WS(str) ((const xp_wchar_t*)L##str) +#define XP_WT(txt) (L##txt) + #if defined(XP_CHAR_IS_MCHAR) + /* obsolete */ #define XP_CHAR(ch) XP_MCHAR(ch) #define XP_TEXT(txt) XP_MTEXT(txt) #define XP_QUOTE(val) XP_MQUOTE(val) + + /* new short form */ + #define XP_C(ch) XP_MC(ch) + #define XP_S(str) XP_MS(str) + #define XP_T(txt) XP_MT(txt) + #define XP_Q(val) XP_MQ(val) #else + /* obsolete */ #define XP_CHAR(ch) XP_WCHAR(ch) #define XP_TEXT(txt) XP_WTEXT(txt) #define XP_QUOTE(val) XP_WQUOTE(val) + + /* new short form */ + #define XP_C(ch) XP_WC(ch) + #define XP_S(str) XP_WS(str) + #define XP_T(txt) XP_WT(txt) + #define XP_Q(val) XP_WQ(val) #endif #endif diff --git a/ase/types.h b/ase/types.h index db362fa8..07326be4 100644 --- a/ase/types.h +++ b/ase/types.h @@ -1,5 +1,5 @@ /* - * $Id: types.h,v 1.45 2006-04-30 17:35:37 bacon Exp $ + * $Id: types.h,v 1.46 2006-05-06 12:52:36 bacon Exp $ */ #ifndef _XP_TYPES_H_ @@ -208,6 +208,12 @@ typedef xp_uint_t xp_word_t; typedef char xp_mchar_t; typedef int xp_mcint_t; +#ifdef __cplusplus + /* C++ */ + typedef wchar_t xp_wchar_t; + typedef wchar_t xp_wcint_t; +#else + /* C */ #if defined(_WIN32) typedef unsigned short xp_wchar_t; typedef unsigned short xp_wcint_t; @@ -222,6 +228,8 @@ typedef int xp_mcint_t; typedef int xp_wcint_t; #endif +#endif + #if defined(_WIN32) && (defined(UNICODE)||defined(_UNICODE)) #define XP_CHAR_IS_WCHAR typedef xp_wchar_t xp_char_t;