diff --git a/ase/test/awk/awk.c b/ase/test/awk/awk.c index def6a617..fff2e3db 100644 --- a/ase/test/awk/awk.c +++ b/ase/test/awk/awk.c @@ -1,5 +1,5 @@ /* - * $Id: awk.c,v 1.139 2006-12-16 16:12:07 bacon Exp $ + * $Id: awk.c,v 1.140 2006-12-17 12:33:31 bacon Exp $ */ #include @@ -1111,7 +1111,7 @@ int xp_main (int argc, ase_char_t* argv[]) } #endif -#if defined(__unix) || defined(__unix__) +#if defined(__unix) xp_setlocale (); #endif diff --git a/ase/types.h b/ase/types.h index a64097ee..fe770a83 100644 --- a/ase/types.h +++ b/ase/types.h @@ -1,5 +1,5 @@ /* - * $Id: types.h,v 1.62 2006-12-17 10:33:41 bacon Exp $ + * $Id: types.h,v 1.63 2006-12-17 12:33:31 bacon Exp $ */ #ifndef _ASE_TYPES_H_ @@ -11,7 +11,7 @@ #include #elif defined(__MSDOS__) || defined(_MSDOS) || defined(MSDOS) #include -#elif defined(__unix__) || defined(__unix) || defined(__NetBSD__) +#elif defined(__unix__) || defined(__unix) || defined(__NetBSD__) || defined(__OpenBSD__) #if !defined(__unix__) #define __unix__ #endif diff --git a/ase/utl/main.c b/ase/utl/main.c new file mode 100644 index 00000000..f58d4fc1 --- /dev/null +++ b/ase/utl/main.c @@ -0,0 +1,81 @@ +/* + * $Id: main.c,v 1.1 2006-12-17 12:33:31 bacon Exp $ + */ + +#include +#include +#include +#include +#include +#include +#include + +#if defined(ASE_CHAR_IS_WCHAR) && defined(__unix) + +int main (int argc, char* argv[]/*, char** envp*/) +{ + int i, ret; + ase_char_t** v; + + setlocale (LC_ALL, ""); + + v = (ase_char_t**) malloc (argc * ASE_SIZEOF(ase_char_t*)); + if (v == NULL) return -1; + + for (i = 0; i < argc; i++) v[i] = NULL; + for (i = 0; i < argc; i++) + { + ase_size_t n, len, rem; + char* p = argv[i]; + + len = 0; rem = strlen (p); + while (*p != '\0') + { + int x = mblen (p, rem); + if (x == -1) + { + ret = -1; + goto exit_main; + } + if (x == 0) break; + p += x; rem -= x; len++; + } + + v[i] = (ase_char_t*) malloc ( + (len + 1) * ASE_SIZEOF(ase_char_t)); + if (v[i] == NULL) + { + ret = -1; + goto exit_main; + } + + n = mbstowcs (v[i], argv[i], len); + if (n == (size_t)-1) + { + /* error */ + return -1; + } + + if (n == len) v[i][len] = ASE_T('\0'); + } + + for (i = 0; i < argc; i++) + { + printf ("[%ls]\n", v[i]); + } + + /* TODO: envp... */ + //ret = _tmain (argc, v, NULL); + +exit_main: + for (i = 0; i < argc; i++) + { + if (v[i] != NULL) free (v[i]); + } + free (v); + + return ret; +} + +#endif +