From 6c99da0073e52ba572cd808299c19e8563e2cd7a Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Tue, 24 Oct 2006 04:48:52 +0000 Subject: [PATCH] *** empty log message *** --- ase/awk/awk.h | 14 +- ase/awk/awk_i.h | 9 +- ase/awk/func.c | 18 +- ase/awk/misc.c | 4 +- ase/awk/misc.h | 5 +- ase/test/awk/awk.c | 348 +++++++++++++++++++-------------------- ase/test/awk/makefile.cl | 7 +- 7 files changed, 196 insertions(+), 209 deletions(-) diff --git a/ase/awk/awk.h b/ase/awk/awk.h index 75476764..c67181a5 100644 --- a/ase/awk/awk.h +++ b/ase/awk/awk.h @@ -1,5 +1,5 @@ /* - * $Id: awk.h,v 1.133 2006-10-24 04:10:12 bacon Exp $ + * $Id: awk.h,v 1.134 2006-10-24 04:48:52 bacon Exp $ */ #ifndef _ASE_AWK_AWK_H_ @@ -316,6 +316,14 @@ enum ASE_AWK_EXTIO_NUM }; +/* assertion statement */ +#ifdef NDEBUG + #define ase_awk_assert(awk,expr) ((void)0) +#else + #define ase_awk_assert(awk,expr) (void)((expr) || \ + (ase_awk_assertfail (awk, ASE_T(#expr), ASE_T(__FILE__), __LINE__), 0)) +#endif + #ifdef __cplusplus extern "C" { #endif @@ -411,6 +419,10 @@ ase_char_t* ase_awk_strxnstr ( const ase_char_t* str, ase_size_t strsz, const ase_char_t* sub, ase_size_t subsz); +/* abort function for assertion. use ase_awk_assert instead */ +int ase_awk_assertfail (ase_awk_t* awk, + const ase_char_t* expr, const ase_char_t* file, int line); + /* utility functions to convert an error number ot a string */ const ase_char_t* ase_awk_geterrstr (int errnum); diff --git a/ase/awk/awk_i.h b/ase/awk/awk_i.h index 87782635..760f6ad9 100644 --- a/ase/awk/awk_i.h +++ b/ase/awk/awk_i.h @@ -1,5 +1,5 @@ /* - * $Id: awk_i.h,v 1.72 2006-10-24 04:10:12 bacon Exp $ + * $Id: awk_i.h,v 1.73 2006-10-24 04:48:52 bacon Exp $ */ #ifndef _ASE_AWK_AWKI_H_ @@ -21,13 +21,6 @@ typedef struct ase_awk_tree_t ase_awk_tree_t; #include #include -#ifdef NDEBUG - #define ase_awk_assert(awk,expr) ((void)0) -#else - #define ase_awk_assert(awk,expr) (void)((expr) || \ - (ase_awk_abort(awk, ASE_T(#expr), ASE_T(__FILE__), __LINE__), 0)) -#endif - #ifdef _MSC_VER #pragma warning (disable: 4996) #endif diff --git a/ase/awk/func.c b/ase/awk/func.c index e3cb718c..38cdd01c 100644 --- a/ase/awk/func.c +++ b/ase/awk/func.c @@ -1,17 +1,9 @@ /* - * $Id: func.c,v 1.68 2006-10-24 04:10:12 bacon Exp $ + * $Id: func.c,v 1.69 2006-10-24 04:48:52 bacon Exp $ */ #include -#ifdef _WIN32 - #include - #include -#else - #include - #include -#endif - static int __bfn_close (ase_awk_run_t* run); static int __bfn_fflush (ase_awk_run_t* run); static int __bfn_index (ase_awk_run_t* run); @@ -23,8 +15,6 @@ static int __bfn_toupper (ase_awk_run_t* run); static int __bfn_gsub (ase_awk_run_t* run); static int __bfn_sub (ase_awk_run_t* run); static int __bfn_match (ase_awk_run_t* run); -static int __bfn_system (ase_awk_run_t* run); -/*static int __bfn_sin (ase_awk_run_t* run);*/ /* TODO: move it under the awk structure... */ static ase_awk_bfn_t __sys_bfn[] = @@ -44,10 +34,6 @@ static ase_awk_bfn_t __sys_bfn[] = {ASE_T("sub"), 3, 0, 2, 3, ASE_T("xvr"), __bfn_sub}, {ASE_T("match"), 5, 0, 2, 2, ASE_T("vx"), __bfn_match}, - /* TODO: remove these two functions */ - {ASE_T("system"), 6, 0, 1, 1, ASE_NULL, __bfn_system}, - /*{ ASE_T("sin"), 3, 0, 1, 1, ASE_NULL, __bfn_sin},*/ - {ASE_NULL, 0, 0, 0, 0, ASE_NULL, ASE_NULL} }; @@ -1253,6 +1239,7 @@ static int __bfn_match (ase_awk_run_t* run) return 0; } +#if 0 static int __bfn_system (ase_awk_run_t* run) { ase_size_t nargs; @@ -1289,7 +1276,6 @@ static int __bfn_system (ase_awk_run_t* run) } /* math functions */ -#if 0 static int __bfn_sin (ase_awk_run_t* run) { ase_size_t nargs; diff --git a/ase/awk/misc.c b/ase/awk/misc.c index edc1ef9e..dac51d1d 100644 --- a/ase/awk/misc.c +++ b/ase/awk/misc.c @@ -1,5 +1,5 @@ /* - * $Id: misc.c,v 1.31 2006-10-24 04:10:12 bacon Exp $ + * $Id: misc.c,v 1.32 2006-10-24 04:48:52 bacon Exp $ */ #include @@ -1060,7 +1060,7 @@ exit_loop: } } -int ase_awk_abort (ase_awk_t* awk, +int ase_awk_assertfail (ase_awk_t* awk, const ase_char_t* expr, const ase_char_t* file, int line) { awk->syscas.dprintf ( diff --git a/ase/awk/misc.h b/ase/awk/misc.h index 4e5d03cc..28c6bb7f 100644 --- a/ase/awk/misc.h +++ b/ase/awk/misc.h @@ -1,5 +1,5 @@ /* - * $Id: misc.h,v 1.7 2006-10-24 04:10:12 bacon Exp $ + * $Id: misc.h,v 1.8 2006-10-24 04:48:52 bacon Exp $ */ #ifndef _ASE_AWK_MISC_H_ @@ -38,9 +38,6 @@ ase_char_t* ase_awk_strxntokbyrex ( ase_awk_run_t* run, const ase_char_t* s, ase_size_t len, void* rex, ase_char_t** tok, ase_size_t* tok_len, int* errnum); -int ase_awk_abort (ase_awk_t* awk, - const ase_char_t* expr, const ase_char_t* file, int line); - #ifdef __cplusplus } #endif diff --git a/ase/test/awk/awk.c b/ase/test/awk/awk.c index 2740644e..5d170047 100644 --- a/ase/test/awk/awk.c +++ b/ase/test/awk/awk.c @@ -1,14 +1,14 @@ /* - * $Id: awk.c,v 1.101 2006-10-22 12:39:30 bacon Exp $ + * $Id: awk.c,v 1.102 2006-10-24 04:48:52 bacon Exp $ */ -#include +#include #include #include #include #include -#ifdef SSE_CHAR_IS_WCHAR +#ifdef ASE_CHAR_IS_WCHAR #include #include #endif @@ -25,9 +25,9 @@ #include #include #ifndef PATH_MAX - #define SSE_PATH_MAX 4096 + #define ASE_PATH_MAX 4096 #else - #define SSE_PATH_MAX PATH_MAX + #define ASE_PATH_MAX PATH_MAX #endif #ifdef _WIN32 @@ -66,7 +66,7 @@ static FILE* fopen_t (const xp_char_t* path, const xp_char_t* mode) #ifdef _WIN32 return _tfopen (path, mode); #else - #ifdef SSE_CHAR_IS_MCHAR + #ifdef ASE_CHAR_IS_MCHAR const xp_mchar_t* path_mb; const xp_mchar_t* mode_mb; #else @@ -74,14 +74,14 @@ static FILE* fopen_t (const xp_char_t* path, const xp_char_t* mode) xp_mchar_t mode_mb[32]; #endif - #ifdef SSE_CHAR_IS_MCHAR + #ifdef ASE_CHAR_IS_MCHAR path_mb = path; mode_mb = mode; #else if (xp_wcstomcs_strict ( - path, path_mb, xp_countof(path_mb)) == -1) return SSE_NULL; + path, path_mb, xp_countof(path_mb)) == -1) return ASE_NULL; if (xp_wcstomcs_strict ( - mode, mode_mb, xp_countof(mode_mb)) == -1) return SSE_NULL; + mode, mode_mb, xp_countof(mode_mb)) == -1) return ASE_NULL; #endif return fopen (path_mb, mode_mb); @@ -100,9 +100,9 @@ static int __dprintf (const xp_char_t* fmt, ...) #ifdef _WIN32 n = xp_vsprintf (buf, xp_countof(buf), fmt, ap); #if defined(_MSC_VER) && (_MSC_VER>=1400) - MessageBox (NULL, buf, SSE_T("\uD655\uC778\uC2E4\uD328 Assertion Failure"), MB_OK | MB_ICONERROR); + MessageBox (NULL, buf, ASE_T("\uD655\uC778\uC2E4\uD328 Assertion Failure"), MB_OK | MB_ICONERROR); #else - MessageBox (NULL, buf, SSE_T("Assertion Failure"), MB_OK | MB_ICONERROR); + MessageBox (NULL, buf, ASE_T("Assertion Failure"), MB_OK | MB_ICONERROR); #endif #else @@ -117,7 +117,7 @@ static FILE* popen_t (const xp_char_t* cmd, const xp_char_t* mode) #ifdef _WIN32 return _tpopen (cmd, mode); #else - #ifdef SSE_CHAR_IS_MCHAR + #ifdef ASE_CHAR_IS_MCHAR const xp_mchar_t* cmd_mb; const xp_mchar_t* mode_mb; #else @@ -125,14 +125,14 @@ static FILE* popen_t (const xp_char_t* cmd, const xp_char_t* mode) xp_mchar_t mode_mb[32]; #endif - #ifdef SSE_CHAR_IS_MCHAR + #ifdef ASE_CHAR_IS_MCHAR cmd_mb = cmd; mode_mb = mode; #else if (xp_wcstomcs_strict ( - cmd, cmd_mb, xp_countof(cmd_mb)) == -1) return SSE_NULL; + cmd, cmd_mb, xp_countof(cmd_mb)) == -1) return ASE_NULL; if (xp_wcstomcs_strict ( - mode, mode_mb, xp_countof(mode_mb)) == -1) return SSE_NULL; + mode, mode_mb, xp_countof(mode_mb)) == -1) return ASE_NULL; #endif return popen (cmd_mb, mode_mb); @@ -143,7 +143,7 @@ static FILE* popen_t (const xp_char_t* cmd, const xp_char_t* mode) #define fgets_t _fgetts #define fputs_t _fputts #else - #ifdef SSE_CHAR_IS_MCHAR + #ifdef ASE_CHAR_IS_MCHAR #define fgets_t fgets #define fputs_t fputs #else @@ -158,28 +158,28 @@ static xp_ssize_t process_source ( struct src_io* src_io = (struct src_io*)arg; xp_char_t c; - if (cmd == SSE_AWK_IO_OPEN) + if (cmd == ASE_AWK_IO_OPEN) { - if (src_io->input_file == SSE_NULL) return 0; - src_io->input_handle = fopen_t (src_io->input_file, SSE_T("r")); + if (src_io->input_file == ASE_NULL) return 0; + src_io->input_handle = fopen_t (src_io->input_file, ASE_T("r")); if (src_io->input_handle == NULL) return -1; return 1; } - else if (cmd == SSE_AWK_IO_CLOSE) + else if (cmd == ASE_AWK_IO_CLOSE) { - if (src_io->input_file == SSE_NULL) return 0; + if (src_io->input_file == ASE_NULL) return 0; fclose ((FILE*)src_io->input_handle); return 0; } - else if (cmd == SSE_AWK_IO_READ) + else if (cmd == ASE_AWK_IO_READ) { if (size <= 0) return -1; - #ifdef SSE_CHAR_IS_MCHAR + #ifdef ASE_CHAR_IS_MCHAR c = fgetc ((FILE*)src_io->input_handle); #else c = fgetwc ((FILE*)src_io->input_handle); #endif - if (c == SSE_CHAR_EOF) return 0; + if (c == ASE_CHAR_EOF) return 0; *data = c; return 1; } @@ -192,14 +192,14 @@ static xp_ssize_t dump_source ( { /*struct src_io* src_io = (struct src_io*)arg;*/ - if (cmd == SSE_AWK_IO_OPEN) return 1; - else if (cmd == SSE_AWK_IO_CLOSE) return 0; - else if (cmd == SSE_AWK_IO_WRITE) + if (cmd == ASE_AWK_IO_OPEN) return 1; + else if (cmd == ASE_AWK_IO_CLOSE) return 0; + else if (cmd == ASE_AWK_IO_WRITE) { xp_size_t i; for (i = 0; i < size; i++) { - #ifdef SSE_CHAR_IS_MCHAR + #ifdef ASE_CHAR_IS_MCHAR fputc (data[i], stdout); #else fputwc (data[i], stdout); @@ -214,56 +214,56 @@ static xp_ssize_t dump_source ( static xp_ssize_t process_extio_pipe ( int cmd, void* arg, xp_char_t* data, xp_size_t size) { - sse_awk_extio_t* epa = (sse_awk_extio_t*)arg; + ase_awk_extio_t* epa = (ase_awk_extio_t*)arg; switch (cmd) { - case SSE_AWK_IO_OPEN: + case ASE_AWK_IO_OPEN: { FILE* handle; const xp_char_t* mode; - if (epa->mode == SSE_AWK_IO_PIPE_READ) - mode = SSE_T("r"); - else if (epa->mode == SSE_AWK_IO_PIPE_WRITE) - mode = SSE_T("w"); + if (epa->mode == ASE_AWK_IO_PIPE_READ) + mode = ASE_T("r"); + else if (epa->mode == ASE_AWK_IO_PIPE_WRITE) + mode = ASE_T("w"); else return -1; /* TODO: any way to set the error number? */ -xp_printf (SSE_TEXT("opending %s of type %d (pipe)\n"), epa->name, epa->type); +xp_printf (ASE_TEXT("opending %s of type %d (pipe)\n"), epa->name, epa->type); handle = popen_t (epa->name, mode); if (handle == NULL) return -1; epa->handle = (void*)handle; return 1; } - case SSE_AWK_IO_CLOSE: + case ASE_AWK_IO_CLOSE: { -xp_printf (SSE_TEXT("closing %s of type (pipe) %d\n"), epa->name, epa->type); +xp_printf (ASE_TEXT("closing %s of type (pipe) %d\n"), epa->name, epa->type); fclose ((FILE*)epa->handle); epa->handle = NULL; return 0; } - case SSE_AWK_IO_READ: + case ASE_AWK_IO_READ: { - if (fgets_t (data, size, (FILE*)epa->handle) == SSE_NULL) + if (fgets_t (data, size, (FILE*)epa->handle) == ASE_NULL) return 0; - return sse_awk_strlen(data); + return ase_awk_strlen(data); } - case SSE_AWK_IO_WRITE: + case ASE_AWK_IO_WRITE: { /* TODO: size... */ fputs_t (data, (FILE*)epa->handle); return size; } - case SSE_AWK_IO_FLUSH: + case ASE_AWK_IO_FLUSH: { - if (epa->mode == SSE_AWK_IO_PIPE_READ) return -1; + if (epa->mode == ASE_AWK_IO_PIPE_READ) return -1; else return 0; } - case SSE_AWK_IO_NEXT: + case ASE_AWK_IO_NEXT: { return -1; } @@ -275,24 +275,24 @@ xp_printf (SSE_TEXT("closing %s of type (pipe) %d\n"), epa->name, epa->type); static xp_ssize_t process_extio_file ( int cmd, void* arg, xp_char_t* data, xp_size_t size) { - sse_awk_extio_t* epa = (sse_awk_extio_t*)arg; + ase_awk_extio_t* epa = (ase_awk_extio_t*)arg; switch (cmd) { - case SSE_AWK_IO_OPEN: + case ASE_AWK_IO_OPEN: { FILE* handle; const xp_char_t* mode; - if (epa->mode == SSE_AWK_IO_FILE_READ) - mode = SSE_T("r"); - else if (epa->mode == SSE_AWK_IO_FILE_WRITE) - mode = SSE_T("w"); - else if (epa->mode == SSE_AWK_IO_FILE_APPEND) - mode = SSE_T("a"); + if (epa->mode == ASE_AWK_IO_FILE_READ) + mode = ASE_T("r"); + else if (epa->mode == ASE_AWK_IO_FILE_WRITE) + mode = ASE_T("w"); + else if (epa->mode == ASE_AWK_IO_FILE_APPEND) + mode = ASE_T("a"); else return -1; /* TODO: any way to set the error number? */ -xp_printf (SSE_TEXT("opending %s of type %d (file)\n"), epa->name, epa->type); +xp_printf (ASE_TEXT("opending %s of type %d (file)\n"), epa->name, epa->type); handle = fopen_t (epa->name, mode); if (handle == NULL) return -1; @@ -300,35 +300,35 @@ xp_printf (SSE_TEXT("opending %s of type %d (file)\n"), epa->name, epa->type); return 1; } - case SSE_AWK_IO_CLOSE: + case ASE_AWK_IO_CLOSE: { -xp_printf (SSE_TEXT("closing %s of type %d (file)\n"), epa->name, epa->type); +xp_printf (ASE_TEXT("closing %s of type %d (file)\n"), epa->name, epa->type); fclose ((FILE*)epa->handle); epa->handle = NULL; return 0; } - case SSE_AWK_IO_READ: + case ASE_AWK_IO_READ: { - if (fgets_t (data, size, (FILE*)epa->handle) == SSE_NULL) + if (fgets_t (data, size, (FILE*)epa->handle) == ASE_NULL) return 0; - return sse_awk_strlen(data); + return ase_awk_strlen(data); } - case SSE_AWK_IO_WRITE: + case ASE_AWK_IO_WRITE: { /* TODO: how to return error or 0 */ fputs_t (data, /*size,*/ (FILE*)epa->handle); return size; } - case SSE_AWK_IO_FLUSH: + case ASE_AWK_IO_FLUSH: { if (fflush ((FILE*)epa->handle) == EOF) return -1; return 0; } - case SSE_AWK_IO_NEXT: + case ASE_AWK_IO_NEXT: { return -1; } @@ -338,56 +338,56 @@ xp_printf (SSE_TEXT("closing %s of type %d (file)\n"), epa->name, epa->type); return -1; } -static int open_extio_console (sse_awk_extio_t* epa); -static int close_extio_console (sse_awk_extio_t* epa); -static int next_extio_console (sse_awk_extio_t* epa); +static int open_extio_console (ase_awk_extio_t* epa); +static int close_extio_console (ase_awk_extio_t* epa); +static int next_extio_console (ase_awk_extio_t* epa); static xp_size_t infile_no = 0; static const xp_char_t* infiles[10000] = { - SSE_T(""), - SSE_NULL + ASE_T(""), + ASE_NULL }; static xp_ssize_t process_extio_console ( int cmd, void* arg, xp_char_t* data, xp_size_t size) { - sse_awk_extio_t* epa = (sse_awk_extio_t*)arg; + ase_awk_extio_t* epa = (ase_awk_extio_t*)arg; - if (cmd == SSE_AWK_IO_OPEN) + if (cmd == ASE_AWK_IO_OPEN) { return open_extio_console (epa); } - else if (cmd == SSE_AWK_IO_CLOSE) + else if (cmd == ASE_AWK_IO_CLOSE) { return close_extio_console (epa); } - else if (cmd == SSE_AWK_IO_READ) + else if (cmd == ASE_AWK_IO_READ) { - while (fgets_t (data, size, epa->handle) == SSE_NULL) + while (fgets_t (data, size, epa->handle) == ASE_NULL) { /* it has reached the end of the current file. * open the next file if available */ - if (infiles[infile_no] == SSE_NULL) + if (infiles[infile_no] == ASE_NULL) { /* no more input console */ /* is this correct??? */ /* - if (epa->handle != SSE_NULL && + if (epa->handle != ASE_NULL && epa->handle != stdin && epa->handle != stdout && epa->handle != stderr) fclose (epa->handle); - epa->handle = SSE_NULL; + epa->handle = ASE_NULL; */ return 0; } - if (infiles[infile_no][0] == SSE_T('\0')) + if (infiles[infile_no][0] == ASE_T('\0')) { - if (epa->handle != SSE_NULL && + if (epa->handle != ASE_NULL && epa->handle != stdin && epa->handle != stdout && epa->handle != stderr) fclose (epa->handle); @@ -395,40 +395,40 @@ static xp_ssize_t process_extio_console ( } else { - FILE* fp = fopen_t (infiles[infile_no], SSE_T("r")); - if (fp == SSE_NULL) + FILE* fp = fopen_t (infiles[infile_no], ASE_T("r")); + if (fp == ASE_NULL) { -xp_printf (SSE_TEXT("failed to open the next console of type %x - fopen failure\n"), epa->type); +xp_printf (ASE_TEXT("failed to open the next console of type %x - fopen failure\n"), epa->type); return -1; } - if (epa->handle != SSE_NULL && + if (epa->handle != ASE_NULL && epa->handle != stdin && epa->handle != stdout && epa->handle != stderr) fclose (epa->handle); -xp_printf (SSE_TEXT("open the next console [%s]\n"), infiles[infile_no]); +xp_printf (ASE_TEXT("open the next console [%s]\n"), infiles[infile_no]); epa->handle = fp; } infile_no++; } - return sse_awk_strlen(data); + return ase_awk_strlen(data); } - else if (cmd == SSE_AWK_IO_WRITE) + else if (cmd == ASE_AWK_IO_WRITE) { /* TODO: how to return error or 0 */ fputs_t (data, /*size,*/ (FILE*)epa->handle); /*MessageBox (NULL, data, data, MB_OK);*/ return size; } - else if (cmd == SSE_AWK_IO_FLUSH) + else if (cmd == ASE_AWK_IO_FLUSH) { if (fflush ((FILE*)epa->handle) == EOF) return -1; return 0; } - else if (cmd == SSE_AWK_IO_NEXT) + else if (cmd == ASE_AWK_IO_NEXT) { return next_extio_console (epa); } @@ -436,44 +436,44 @@ xp_printf (SSE_TEXT("open the next console [%s]\n"), infiles[infile_no]); return -1; } -static int open_extio_console (sse_awk_extio_t* epa) +static int open_extio_console (ase_awk_extio_t* epa) { /* TODO: OpenConsole in GUI APPLICATION */ /* epa->name is always empty for console */ - xp_assert (epa->name[0] == SSE_T('\0')); + xp_assert (epa->name[0] == ASE_T('\0')); -xp_printf (SSE_TEXT("opening console[%s] of type %x\n"), epa->name, epa->type); +xp_printf (ASE_TEXT("opening console[%s] of type %x\n"), epa->name, epa->type); - if (epa->mode == SSE_AWK_IO_CONSOLE_READ) + if (epa->mode == ASE_AWK_IO_CONSOLE_READ) { - if (infiles[infile_no] == SSE_NULL) + if (infiles[infile_no] == ASE_NULL) { /* no more input file */ -xp_printf (SSE_TEXT("console - no more file\n"));; +xp_printf (ASE_TEXT("console - no more file\n"));; return 0; } - if (infiles[infile_no][0] == SSE_T('\0')) + if (infiles[infile_no][0] == ASE_T('\0')) { -xp_printf (SSE_T(" console(r) - \n")); +xp_printf (ASE_T(" console(r) - \n")); epa->handle = stdin; } else { /* a temporary variable fp is used here not to change * any fields of epa when the open operation fails */ - FILE* fp = fopen_t (infiles[infile_no], SSE_T("r")); - if (fp == SSE_NULL) + FILE* fp = fopen_t (infiles[infile_no], ASE_T("r")); + if (fp == ASE_NULL) { -xp_printf (SSE_TEXT("failed to open console of type %x - fopen failure\n"), epa->type); +xp_printf (ASE_TEXT("failed to open console of type %x - fopen failure\n"), epa->type); return -1; } -xp_printf (SSE_T(" console(r) - %s\n"), infiles[infile_no]); - if (sse_awk_setconsolename ( +xp_printf (ASE_T(" console(r) - %s\n"), infiles[infile_no]); + if (ase_awk_setconsolename ( epa->run, infiles[infile_no], - sse_awk_strlen(infiles[infile_no])) == -1) + ase_awk_strlen(infiles[infile_no])) == -1) { fclose (fp); return -1; @@ -485,11 +485,11 @@ xp_printf (SSE_T(" console(r) - %s\n"), infiles[infile_no]); infile_no++; return 1; } - else if (epa->mode == SSE_AWK_IO_CONSOLE_WRITE) + else if (epa->mode == ASE_AWK_IO_CONSOLE_WRITE) { -xp_printf (SSE_T(" console(w) - \n")); +xp_printf (ASE_T(" console(w) - \n")); /* TODO: does output console has a name??? */ - /*sse_awk_setconsolename (SSE_T(""));*/ + /*ase_awk_setconsolename (ASE_T(""));*/ epa->handle = stdout; return 1; } @@ -497,11 +497,11 @@ xp_printf (SSE_T(" console(w) - \n")); return -1; } -static int close_extio_console (sse_awk_extio_t* epa) +static int close_extio_console (ase_awk_extio_t* epa) { -xp_printf (SSE_TEXT("closing console of type %x\n"), epa->type); +xp_printf (ASE_TEXT("closing console of type %x\n"), epa->type); - if (epa->handle != SSE_NULL && + if (epa->handle != ASE_NULL && epa->handle != stdin && epa->handle != stdout && epa->handle != stderr) @@ -513,11 +513,11 @@ xp_printf (SSE_TEXT("closing console of type %x\n"), epa->type); return 0; } -static int next_extio_console (sse_awk_extio_t* epa) +static int next_extio_console (ase_awk_extio_t* epa) { int n; FILE* fp = epa->handle; -xp_printf (SSE_TEXT("switching console[%s] of type %x\n"), epa->name, epa->type); +xp_printf (ASE_TEXT("switching console[%s] of type %x\n"), epa->name, epa->type); n = open_extio_console(epa); if (n == -1) return -1; @@ -528,14 +528,14 @@ xp_printf (SSE_TEXT("switching console[%s] of type %x\n"), epa->name, epa->type) return 0; } - if (fp != SSE_NULL && fp != stdin && + if (fp != ASE_NULL && fp != stdin && fp != stdout && fp != stderr) fclose (fp); return n; } -sse_awk_t* app_awk = NULL; +ase_awk_t* app_awk = NULL; void* app_run = NULL; #ifdef _WIN32 @@ -544,7 +544,7 @@ static BOOL WINAPI __stop_run (DWORD ctrl_type) if (ctrl_type == CTRL_C_EVENT || ctrl_type == CTRL_CLOSE_EVENT) { - sse_awk_stop (app_awk, app_run); + ase_awk_stop (app_awk, app_run); return TRUE; } @@ -554,27 +554,27 @@ static BOOL WINAPI __stop_run (DWORD ctrl_type) static void __stop_run (int sig) { signal (SIGINT, SIG_IGN); - sse_awk_stop (app_awk, app_run); - //sse_awk_stoprun (awk, handle); - /*sse_awk_stopallruns (awk); */ + ase_awk_stop (app_awk, app_run); + //ase_awk_stoprun (awk, handle); + /*ase_awk_stopallruns (awk); */ signal (SIGINT, __stop_run); } #endif -static void __on_run_start (sse_awk_t* awk, void* handle, void* arg) +static void __on_run_start (ase_awk_t* awk, void* handle, void* arg) { app_awk = awk; app_run = handle; -xp_printf (SSE_T("AWK PRORAM ABOUT TO START...\n")); +xp_printf (ASE_T("AWK PRORAM ABOUT TO START...\n")); } -static void __on_run_end (sse_awk_t* awk, void* handle, int errnum, void* arg) +static void __on_run_end (ase_awk_t* awk, void* handle, int errnum, void* arg) { - if (errnum != SSE_AWK_ENOERR) + if (errnum != ASE_AWK_ENOERR) { - xp_printf (SSE_T("AWK PRORAM ABOUT TO END WITH AN ERROR - %d - %s\n"), errnum, sse_awk_geterrstr (errnum)); + xp_printf (ASE_T("AWK PRORAM ABOUT TO END WITH AN ERROR - %d - %s\n"), errnum, ase_awk_geterrstr (errnum)); } - else xp_printf (SSE_T("AWK PRORAM ENDED SUCCESSFULLY\n")); + else xp_printf (ASE_T("AWK PRORAM ENDED SUCCESSFULLY\n")); app_awk = NULL; app_run = NULL; @@ -625,27 +625,27 @@ static int __main (int argc, char* argv[]) static int __main (int argc, xp_char_t* argv[]) #endif { - sse_awk_t* awk; - sse_awk_srcios_t srcios; - sse_awk_runcbs_t runcbs; - sse_awk_runios_t runios; - sse_awk_runarg_t runarg[10]; - sse_awk_syscas_t syscas; + ase_awk_t* awk; + ase_awk_srcios_t srcios; + ase_awk_runcbs_t runcbs; + ase_awk_runios_t runios; + ase_awk_runarg_t runarg[10]; + ase_awk_syscas_t syscas; struct src_io src_io = { NULL, NULL }; int opt, i, file_count = 0; #ifdef _WIN32 syscas_data_t syscas_data; #endif - opt = SSE_AWK_EXPLICIT | SSE_AWK_UNIQUE | SSE_AWK_HASHSIGN | - /*SSE_AWK_DBLSLASHES |*/ - SSE_AWK_SHADING | SSE_AWK_IMPLICIT | SSE_AWK_SHIFT | - SSE_AWK_EXTIO | SSE_AWK_BLOCKLESS | SSE_AWK_STRINDEXONE | - SSE_AWK_STRIPSPACES | SSE_AWK_NEWLINE; + opt = ASE_AWK_EXPLICIT | ASE_AWK_UNIQUE | ASE_AWK_HASHSIGN | + /*ASE_AWK_DBLSLASHES |*/ + ASE_AWK_SHADING | ASE_AWK_IMPLICIT | ASE_AWK_SHIFT | + ASE_AWK_EXTIO | ASE_AWK_BLOCKLESS | ASE_AWK_STRINDEXONE | + ASE_AWK_STRIPSPACES | ASE_AWK_NEWLINE; if (argc <= 1) { - xp_printf (SSE_T("Usage: %s [-m] source_file [data_file ...]\n"), argv[0]); + xp_printf (ASE_T("Usage: %s [-m] source_file [data_file ...]\n"), argv[0]); return -1; } @@ -654,10 +654,10 @@ static int __main (int argc, xp_char_t* argv[]) #if defined(__STAND_ALONE) && !defined(_WIN32) if (strcmp(argv[i], "-m") == 0) #else - if (sse_awk_strcmp(argv[i], SSE_T("-m")) == 0) + if (ase_awk_strcmp(argv[i], ASE_T("-m")) == 0) #endif { - opt |= SSE_AWK_RUNMAIN; + opt |= ASE_AWK_RUNMAIN; } else if (file_count == 0) { @@ -667,12 +667,12 @@ static int __main (int argc, xp_char_t* argv[]) else if (file_count >= 1 && file_count < xp_countof(infiles)-1) { infiles[file_count-1] = argv[i]; - infiles[file_count] = SSE_NULL; + infiles[file_count] = ASE_NULL; file_count++; } else { - xp_printf (SSE_T("Usage: %s [-m] [-f source_file] [data_file ...]\n"), argv[0]); + xp_printf (ASE_T("Usage: %s [-m] [-f source_file] [data_file ...]\n"), argv[0]); return -1; } } @@ -685,7 +685,7 @@ static int __main (int argc, xp_char_t* argv[]) syscas.lock = NULL; syscas.unlock = NULL; -#ifdef SSE_CHAR_IS_MCHAR +#ifdef ASE_CHAR_IS_MCHAR syscas.is_upper = isupper; syscas.is_lower = islower; syscas.is_alpha = isalpha; @@ -724,43 +724,43 @@ static int __main (int argc, xp_char_t* argv[]) syscas_data.heap = HeapCreate (0, 1000000, 1000000); if (syscas_data.heap == NULL) { - xp_printf (SSE_T("Error: cannot create an awk heap\n")); + xp_printf (ASE_T("Error: cannot create an awk heap\n")); return -1; } syscas.custom_data = &syscas_data; #endif - if ((awk = sse_awk_open(&syscas)) == SSE_NULL) + if ((awk = ase_awk_open(&syscas)) == ASE_NULL) { #ifdef _WIN32 HeapDestroy (syscas_data.heap); #endif - xp_printf (SSE_T("Error: cannot open awk\n")); + xp_printf (ASE_T("Error: cannot open awk\n")); return -1; } - sse_awk_setopt (awk, opt); + ase_awk_setopt (awk, opt); srcios.in = process_source; srcios.out = dump_source; srcios.custom_data = &src_io; - if (sse_awk_parse (awk, &srcios) == -1) + if (ase_awk_parse (awk, &srcios) == -1) { - int errnum = sse_awk_geterrnum(awk); -#if defined(__STAND_ALONE) && !defined(_WIN32) && defined(SSE_CHAR_IS_WCHAR) + int errnum = ase_awk_geterrnum(awk); +#if defined(__STAND_ALONE) && !defined(_WIN32) && defined(ASE_CHAR_IS_WCHAR) xp_printf ( - SSE_T("ERROR: cannot parse program - line %u [%d] %ls\n"), - (unsigned int)sse_awk_getsrcline(awk), - errnum, sse_awk_geterrstr(errnum)); + ASE_T("ERROR: cannot parse program - line %u [%d] %ls\n"), + (unsigned int)ase_awk_getsrcline(awk), + errnum, ase_awk_geterrstr(errnum)); #else xp_printf ( - SSE_T("ERROR: cannot parse program - line %u [%d] %s\n"), - (unsigned int)sse_awk_getsrcline(awk), - errnum, sse_awk_geterrstr(errnum)); + ASE_T("ERROR: cannot parse program - line %u [%d] %s\n"), + (unsigned int)ase_awk_getsrcline(awk), + errnum, ase_awk_geterrstr(errnum)); #endif - sse_awk_close (awk); + ase_awk_close (awk); return -1; } @@ -771,41 +771,41 @@ static int __main (int argc, xp_char_t* argv[]) #endif runios.pipe = process_extio_pipe; - runios.coproc = SSE_NULL; + runios.coproc = ASE_NULL; runios.file = process_extio_file; runios.console = process_extio_console; runcbs.on_start = __on_run_start; runcbs.on_end = __on_run_end; - runcbs.custom_data = SSE_NULL; + runcbs.custom_data = ASE_NULL; - runarg[0].ptr = SSE_T("argument 0"); - runarg[0].len = sse_awk_strlen(runarg[0].ptr); - runarg[1].ptr = SSE_T("argumetn 1"); - runarg[1].len = sse_awk_strlen(runarg[1].ptr); - runarg[2].ptr = SSE_T("argumetn 2"); - runarg[2].len = sse_awk_strlen(runarg[2].ptr); - runarg[3].ptr = SSE_NULL; + runarg[0].ptr = ASE_T("argument 0"); + runarg[0].len = ase_awk_strlen(runarg[0].ptr); + runarg[1].ptr = ASE_T("argumetn 1"); + runarg[1].len = ase_awk_strlen(runarg[1].ptr); + runarg[2].ptr = ASE_T("argumetn 2"); + runarg[2].len = ase_awk_strlen(runarg[2].ptr); + runarg[3].ptr = ASE_NULL; runarg[3].len = 0; - if (sse_awk_run (awk, &runios, &runcbs, runarg) == -1) + if (ase_awk_run (awk, &runios, &runcbs, runarg) == -1) { - int errnum = sse_awk_geterrnum(awk); -#if defined(__STAND_ALONE) && !defined(_WIN32) && defined(SSE_CHAR_IS_WCHAR) + int errnum = ase_awk_geterrnum(awk); +#if defined(__STAND_ALONE) && !defined(_WIN32) && defined(ASE_CHAR_IS_WCHAR) xp_printf ( - SSE_T("error: cannot run program - [%d] %ls\n"), - errnum, sse_awk_geterrstr(errnum)); + ASE_T("error: cannot run program - [%d] %ls\n"), + errnum, ase_awk_geterrstr(errnum)); #else xp_printf ( - SSE_T("error: cannot run program - [%d] %s\n"), - errnum, sse_awk_geterrstr(errnum)); + ASE_T("error: cannot run program - [%d] %s\n"), + errnum, ase_awk_geterrstr(errnum)); #endif - sse_awk_close (awk); + ase_awk_close (awk); return -1; } - sse_awk_close (awk); + ase_awk_close (awk); #ifdef _WIN32 HeapDestroy (syscas_data.heap); #endif @@ -994,25 +994,25 @@ int xp_main (int argc, xp_char_t* argv[]) { xp_char_t buf[xp_sizeof(xp_long_t)*8+2+2]; xp_size_t n; -n = sse_awk_longtostr (-0x7FFFFFFFFFFFFFFFi64, 16, SSE_T("0x"), buf, xp_countof(buf)); +n = ase_awk_longtostr (-0x7FFFFFFFFFFFFFFFi64, 16, ASE_T("0x"), buf, xp_countof(buf)); if (n == (xp_size_t)-1) { - xp_printf (SSE_T("cannot convert...\n")); + xp_printf (ASE_T("cannot convert...\n")); } -else xp_printf (SSE_T("%d, %s\n"), n, buf); +else xp_printf (ASE_T("%d, %s\n"), n, buf); } if (IsDebuggerPresent ()) { - xp_printf (SSE_T("Running application in a debugger....\n")); + xp_printf (ASE_T("Running application in a debugger....\n")); } if (is_debugger_present ()) { - xp_printf (SSE_T("Running application in a debugger by is_debugger_present...\n")); + xp_printf (ASE_T("Running application in a debugger by is_debugger_present...\n")); } if (is_debugger_present2 ()) { - xp_printf (SSE_T("Running application in a debugger by is_debugger_present2...\n")); + xp_printf (ASE_T("Running application in a debugger by is_debugger_present2...\n")); } #endif diff --git a/ase/test/awk/makefile.cl b/ase/test/awk/makefile.cl index 0e69ee33..dec7cb8c 100644 --- a/ase/test/awk/makefile.cl +++ b/ase/test/awk/makefile.cl @@ -1,8 +1,7 @@ CC = cl -#CFLAGS = /nologo /MT /W3 /GR- /D_WIN32_WINNT=0x0400 -I..\..\.. -CFLAGS = /nologo /MT /W3 /GR- /D_WIN32_WINNT=0x0400 -I..\..\.. -D__STAND_ALONE -LDFLAGS = /libpath:..\..\bas /libpath:..\..\awk -LIBS = xpbas.lib xpawk.lib user32.lib +CFLAGS = /nologo /MT /W3 /GR- -I..\..\.. -I$(XPKIT) -D_WIN32_WINNT=0x0400 -D__STAND_ALONE +LDFLAGS = /libpath:..\..\awk /libpath:$(XPKIT)\xp\bas +LIBS = aseawk.lib xpbas.lib kernel32.lib user32.lib all: awk #rex2 rex3