diff --git a/ase/awk/extio.c b/ase/awk/extio.c index b0beed87..6b5f9fc6 100644 --- a/ase/awk/extio.c +++ b/ase/awk/extio.c @@ -1,5 +1,5 @@ /* - * $Id: extio.c,v 1.12 2006-06-28 03:44:39 bacon Exp $ + * $Id: extio.c,v 1.13 2006-06-28 08:56:59 bacon Exp $ */ #include @@ -133,6 +133,7 @@ int xp_awk_writeextio ( xp_assert (out_type >= 0 && out_type <= xp_countof(__out_type_map)); xp_assert (out_type >= 0 && out_type <= xp_countof(__out_opt_map)); + /* translate the out_type into the relevant extio type and option */ extio_type = __out_type_map[out_type]; extio_opt = __out_opt_map[out_type]; @@ -161,7 +162,17 @@ int xp_awk_writeextio ( /* look for the corresponding extio for name */ while (p != XP_NULL) { - /* TODO: should it be extio_type or out_type???? */ + /* the file "1.tmp", in the following code snippets, + * would be opened by the first print statement, but not by + * the second print statement. this is because + * both XP_AWK_OUT_FILE and XP_AWK_OUT_FILE_APPEND are + * translated to XP_AWK_EXTIO_FILE and it is used to + * keep track of file handles.. + * + * print "1111" >> "1.tmp" + * print "1111" > "1.tmp" + */ + if (p->type == extio_type && xp_strcmp(p->name,name) == 0) break; p = p->next; @@ -187,11 +198,6 @@ int xp_awk_writeextio ( return -1; } - /* TODO: should it be extio_type or out_type???? */ - /* TODO: should it be extio_type or out_type???? */ - /* TODO: should it be extio_type or out_type???? */ - /* TODO: should it be extio_type or out_type???? */ - /* TODO: should it be extio_type or out_type???? */ p->type = extio_type; p->handle = XP_NULL; p->next = XP_NULL; diff --git a/ase/awk/sa.c b/ase/awk/sa.c index c407ce22..7159ff31 100644 --- a/ase/awk/sa.c +++ b/ase/awk/sa.c @@ -1,5 +1,5 @@ /* - * $Id: sa.c,v 1.22 2006-06-23 11:48:19 bacon Exp $ + * $Id: sa.c,v 1.23 2006-06-28 08:56:59 bacon Exp $ */ #include @@ -72,7 +72,7 @@ int xp_strcmp (const xp_char_t* s1, const xp_char_t* s2) { while (*s1 == *s2) { - if (*s1 == XP_CHAR('\0')) return 0; + if (*s1 == XP_C('\0')) return 0; s1++, s2++; } diff --git a/ase/awk/val.c b/ase/awk/val.c index 8412c848..4db920c3 100644 --- a/ase/awk/val.c +++ b/ase/awk/val.c @@ -1,5 +1,5 @@ /* - * $Id: val.c,v 1.32 2006-06-26 15:09:28 bacon Exp $ + * $Id: val.c,v 1.33 2006-06-28 08:56:59 bacon Exp $ */ #include @@ -328,6 +328,22 @@ xp_bool_t xp_awk_valtobool (xp_awk_val_t* val) xp_char_t* xp_awk_valtostr (xp_awk_val_t* v, int* errnum, xp_str_t* buf) { + if (v->type == XP_AWK_VAL_NIL) + { + if (buf == XP_NULL) + { + xp_char_t* tmp; + tmp = xp_strdup (XP_T("")); + if (tmp == XP_NULL) *errnum = XP_AWK_ENOMEM; + return tmp; + } + else + { + xp_str_clear (buf); + return XP_STR_BUF(buf); + } + } + if (v->type == XP_AWK_VAL_INT) { xp_char_t* tmp; diff --git a/ase/test/awk/awk.c b/ase/test/awk/awk.c index 1fa2a5fc..a28a46b5 100644 --- a/ase/test/awk/awk.c +++ b/ase/test/awk/awk.c @@ -1,5 +1,5 @@ /* - * $Id: awk.c,v 1.44 2006-06-27 10:53:04 bacon Exp $ + * $Id: awk.c,v 1.45 2006-06-28 08:56:59 bacon Exp $ */ #include @@ -147,6 +147,7 @@ static xp_ssize_t process_extio_pipe ( else if (opt == XP_AWK_IO_PIPE_WRITE) mode = XP_T("w"); else return -1; /* TODO: any way to set the error number? */ +xp_printf (XP_TEXT("opending %s of type %d (pipe)\n"), epa->name, epa->type); handle = _tpopen (epa->name, mode); if (handle == NULL) return -1; epa->handle = (void*)handle; @@ -155,7 +156,7 @@ static xp_ssize_t process_extio_pipe ( case XP_AWK_IO_CLOSE: { -xp_printf (XP_TEXT("closing %s of type %d\n"), epa->name, epa->type); +xp_printf (XP_TEXT("closing %s of type (pipe) %d\n"), epa->name, epa->type); fclose ((FILE*)epa->handle); epa->handle = NULL; return 0; @@ -207,6 +208,7 @@ static xp_ssize_t process_extio_file ( mode = XP_T("a"); else return -1; /* TODO: any way to set the error number? */ +xp_printf (XP_TEXT("opending %s of type %d (file)\n"), epa->name, epa->type); handle = _tfopen (epa->name, mode); if (handle == NULL) return -1; epa->handle = (void*)handle; @@ -215,7 +217,7 @@ static xp_ssize_t process_extio_file ( case XP_AWK_IO_CLOSE: { -xp_printf (XP_TEXT("closing %s of type %d\n"), epa->name, epa->type); +xp_printf (XP_TEXT("closing %s of type %d (file)\n"), epa->name, epa->type); fclose ((FILE*)epa->handle); epa->handle = NULL; return 0; @@ -258,6 +260,7 @@ static xp_ssize_t process_extio_console ( /* opt: XP_AWK_IO_CONSOLE_READ, * XP_AWK_IO_CONSOLE_WRITE */ +xp_printf (XP_TEXT("opending %s of type %d (console)\n"), epa->name, epa->type); if (opt == XP_AWK_IO_CONSOLE_READ) epa->handle = stdin; else if (opt == XP_AWK_IO_CONSOLE_WRITE) @@ -267,6 +270,7 @@ static xp_ssize_t process_extio_console ( case XP_AWK_IO_CLOSE: { +xp_printf (XP_TEXT("closing %s of type %d (console)\n"), epa->name, epa->type); /* TODO: CloseConsole in GUI APPLICATION */ return 0; }