fixed a bug in configure.ac and bugs in awk sample programs

This commit is contained in:
hyung-hwan 2014-06-08 14:11:12 +00:00
parent d40eb87b85
commit 4bb71a765e
25 changed files with 202 additions and 127 deletions

2
qse/configure vendored
View File

@ -20676,7 +20676,7 @@ fi
test "${HAVE_CXX}" = "yes" || enable_cxx_is="no"
test "${HAVE_CXX_NAMESPACE_STD}" = "yes" || enable_cxx_is="no"
test "${ax_cv_cxx_have_std_namespace}" = "yes" || enable_cxx_is="no"
if test "${enable_cxx_is}" = "yes" ; then
ENABLE_CXX_TRUE=

View File

@ -578,9 +578,9 @@ AC_ARG_ENABLE([cxx],
)
dnl disable c++ if no c++ compiler was found
[test "${HAVE_CXX}" = "yes" || enable_cxx_is="no"]
test "${HAVE_CXX}" = "yes" || enable_cxx_is="no"
dnl disable c++ if the compiler is too old.
[test "${HAVE_CXX_NAMESPACE_STD}" = "yes" || enable_cxx_is="no"]
test "${ax_cv_cxx_have_std_namespace}" = "yes" || enable_cxx_is="no"
AM_CONDITIONAL(ENABLE_CXX, test "${enable_cxx_is}" = "yes" )

View File

@ -22,7 +22,6 @@
#define _QSE_AWK_STDAWK_H_
#include <qse/awk/awk.h>
#include <qse/cmn/sio.h>
/** \file
* This file defines functions and data types that help you create

View File

@ -449,6 +449,7 @@ QSE_EXPORT qse_ssize_t qse_errputwcsvf (
#define qse_vprintf qse_putstrvf
#define qse_fprintf qse_sio_putstrf
#define qse_vfprintf qse_sio_putstrvf
#define qse_fflush qse_sio_flush
#ifdef __cplusplus

View File

@ -31,8 +31,11 @@
#include <stdlib.h>
#include <math.h>
#if defined(HAVE_QUADMATH_H)
extern "C" { // some gcc distros don't have extern "C" declared in the header file.
# include <quadmath.h>
}
#endif
#if defined(_WIN32)

View File

@ -1,4 +1,5 @@
#include <qse/awk/stdawk.h>
#include <qse/cmn/sio.h>
static const qse_char_t* script = QSE_T("BEGIN { print \"hello, world\"; }");

View File

@ -1,5 +1,6 @@
#include <qse/awk/stdawk.h>
#include <qse/cmn/str.h>
#include <qse/cmn/sio.h>
#include <qse/cmn/main.h>
#include "awk00.h"

View File

@ -1,5 +1,6 @@
#include <qse/awk/stdawk.h>
#include <qse/cmn/str.h>
#include <qse/cmn/sio.h>
#include <qse/cmn/main.h>
#include "awk00.h"

View File

@ -1,4 +1,5 @@
#include <qse/awk/stdawk.h>
#include <qse/cmn/sio.h>
#include <qse/cmn/main.h>
#include "awk00.h"

View File

@ -1,4 +1,5 @@
#include <qse/awk/stdawk.h>
#include <qse/cmn/sio.h>
#include <qse/cmn/main.h>
#include "awk00.h"

View File

@ -1,4 +1,5 @@
#include <qse/awk/stdawk.h>
#include <qse/cmn/sio.h>
#include <qse/cmn/main.h>
#include "awk00.h"

View File

@ -1,4 +1,5 @@
#include <qse/awk/stdawk.h>
#include <qse/cmn/sio.h>
#include <qse/cmn/main.h>
#include "awk00.h"

View File

@ -1,6 +1,6 @@
#include <qse/awk/stdawk.h>
#include <qse/cmn/sio.h>
#include <qse/cmn/main.h>
#include <qse/cmn/stdio.h>
#include "awk00.h"
static const qse_char_t* src = QSE_T(
@ -126,7 +126,11 @@ oops:
int qse_main (int argc, qse_achar_t* argv[])
{
int x;
qse_openstdsios ();
init_awk_sample_locale ();
return qse_runmain (argc, argv, awk_main);
x = qse_runmain (argc, argv, awk_main);
qse_closestdsios ();
return x;
}

View File

@ -1,8 +1,8 @@
#include <qse/awk/stdawk.h>
#include <qse/cmn/sio.h>
#include <qse/cmn/main.h>
#include <qse/cmn/mem.h>
#include <qse/cmn/path.h>
#include <qse/cmn/stdio.h>
#include "awk00.h"
static const qse_char_t* src = QSE_T(
@ -133,7 +133,11 @@ oops:
int qse_main (int argc, qse_achar_t* argv[])
{
int x;
qse_openstdsios ();
init_awk_sample_locale ();
return qse_runmain (argc, argv, awk_main);
x = qse_runmain (argc, argv, awk_main);
qse_closestdsios ();
return x;
}

View File

@ -1,8 +1,8 @@
#include <qse/awk/stdawk.h>
#include <qse/cmn/sio.h>
#include <qse/cmn/main.h>
#include <qse/cmn/mem.h>
#include <qse/cmn/path.h>
#include <qse/cmn/stdio.h>
#include "awk00.h"
static const qse_char_t* src = QSE_T(
@ -146,6 +146,10 @@ oops:
int qse_main (int argc, qse_achar_t* argv[])
{
int x;
qse_openstdsios ();
init_awk_sample_locale ();
return qse_runmain (argc, argv, awk_main);
x = qse_runmain (argc, argv, awk_main);
qse_closestdsios ();
return x;
}

View File

@ -19,7 +19,7 @@
*/
#include <qse/awk/stdawk.h>
#include <qse/cmn/stdio.h>
#include <qse/cmn/sio.h>
const qse_char_t* src = QSE_T("BEGIN { print \"hello, world\" | \"dir\"; }");
@ -72,6 +72,8 @@ int main ()
qse_awk_parsestd_t psin[2];
int ret = -1;
qse_openstdsios ();
awk = qse_awk_openstd (0);
if (awk == QSE_NULL)
{
@ -122,6 +124,8 @@ int main ()
oops:
if (rtx != QSE_NULL) qse_awk_rtx_close (rtx);
if (awk != QSE_NULL) qse_awk_close (awk);
qse_closestdsios ();
return ret;
}

View File

@ -1,5 +1,5 @@
#include <qse/awk/stdawk.h>
#include <qse/cmn/stdio.h>
#include <qse/cmn/sio.h>
/* this sample produces 8 text files containing multiplication chart. */
@ -25,17 +25,19 @@ int main ()
const qse_char_t* output_files[] =
{
QSE_T("awk09.out.2"),
QSE_T("awk09.out.3"),
QSE_T("awk09.out.4"),
QSE_T("awk09.out.5"),
QSE_T("awk09.out.6"),
QSE_T("awk09.out.7"),
QSE_T("awk09.out.8"),
QSE_T("awk09.out.9"),
QSE_T("awk12.out.2"),
QSE_T("awk12.out.3"),
QSE_T("awk12.out.4"),
QSE_T("awk12.out.5"),
QSE_T("awk12.out.6"),
QSE_T("awk12.out.7"),
QSE_T("awk12.out.8"),
QSE_T("awk12.out.9"),
QSE_NULL
};
qse_openstdsios ();
awk = qse_awk_openstd (0);
if (awk == QSE_NULL)
{
@ -62,7 +64,7 @@ int main ()
rtx = qse_awk_rtx_openstd (
awk,
0,
QSE_T("awk09"),
QSE_T("awk12"),
QSE_NULL, /* stdin */
output_files,
QSE_NULL /* default cmgr */
@ -88,6 +90,8 @@ int main ()
oops:
if (rtx != QSE_NULL) qse_awk_rtx_close (rtx);
if (awk != QSE_NULL) qse_awk_close (awk);
qse_closestdsios ();
return ret;
}

View File

@ -21,7 +21,7 @@
#include <qse/awk/awk.h>
#include <qse/awk/stdawk.h>
#include <qse/cmn/mem.h>
#include <qse/cmn/stdio.h>
#include <qse/cmn/sio.h>
static const qse_char_t* src = QSE_T(
"BEGIN {"
@ -45,6 +45,8 @@ int main ()
int ret;
qse_openstdsios ();
awk = qse_awk_openstd (0);
if (awk == QSE_NULL)
{
@ -104,6 +106,8 @@ int main ()
oops:
if (rtx != QSE_NULL) qse_awk_rtx_close (rtx);
if (awk != QSE_NULL) qse_awk_close (awk);
qse_closestdsios ();
return -1;
}

View File

@ -1,5 +1,5 @@
#include <qse/awk/StdAwk.hpp>
#include <qse/cmn/stdio.h>
#include <qse/cmn/sio.h>
#include <string>
#if defined(QSE_CHAR_IS_WCHAR)
@ -117,6 +117,7 @@ int main (int argc, char* argv[])
{
MyAwk awk;
qse_openstdsios ();
int ret = awk.open ();
if (ret >= 0) ret = run_awk (awk);
@ -127,6 +128,7 @@ int main (int argc, char* argv[])
}
awk.close ();
qse_closestdsios ();
return ret;
}

View File

@ -1,5 +1,5 @@
#include <qse/awk/StdAwk.hpp>
#include <qse/cmn/stdio.h>
#include <qse/cmn/sio.h>
#include <string>
#if defined(QSE_CHAR_IS_WCHAR)
@ -170,6 +170,7 @@ int main (int argc, char* argv[])
{
MyAwk awk;
qse_openstdsios ();
int ret = awk.open ();
if (ret >= 0) ret = run_awk (awk);
@ -180,6 +181,7 @@ int main (int argc, char* argv[])
}
awk.close ();
qse_closestdsios ();
return ret;
}

View File

@ -19,7 +19,7 @@
*/
#include <qse/awk/StdAwk.hpp>
#include <qse/cmn/stdio.h>
#include <qse/cmn/sio.h>
#include <qse/cmn/main.h>
#include <qse/cmn/mbwc.h>
@ -151,23 +151,32 @@ static int awk_main (int argc, qse_char_t* argv[])
int qse_main (int argc, qse_achar_t* argv[])
{
#if defined(_WIN32)
char locale[100];
UINT codepage = GetConsoleOutputCP();
if (codepage == CP_UTF8)
int x;
qse_openstdsios ();
{
/*SetConsoleOUtputCP (CP_UTF8);*/
qse_setdflcmgrbyid (QSE_CMGR_UTF8);
}
else
{
sprintf (locale, ".%u", (unsigned int)codepage);
setlocale (LC_ALL, locale);
#if defined(_WIN32)
char locale[100];
UINT codepage = GetConsoleOutputCP();
if (codepage == CP_UTF8)
{
/*SetConsoleOUtputCP (CP_UTF8);*/
qse_setdflcmgrbyid (QSE_CMGR_UTF8);
}
else
{
sprintf (locale, ".%u", (unsigned int)codepage);
setlocale (LC_ALL, locale);
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
}
#else
setlocale (LC_ALL, "");
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
#endif
}
#else
setlocale (LC_ALL, "");
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
#endif
return qse_runmain (argc,argv,awk_main);
x = qse_runmain (argc,argv,awk_main);
qse_closestdsios ();
return x;
}

View File

@ -22,7 +22,7 @@
#include <qse/cmn/opt.h>
#include <qse/cmn/main.h>
#include <qse/cmn/mbwc.h>
#include <qse/cmn/stdio.h>
#include <qse/cmn/sio.h>
#include <cstring>
#include <locale.h>
@ -84,7 +84,7 @@ public:
return -1;
}
long_t x = args[0].toInt();
Awk::int_t x = args[0].toInt();
/*Value arg;
if (run.getGlobal(idLastSleep, arg) == 0)
@ -263,7 +263,7 @@ static void unset_signal (void)
#endif
}
static void print_usage (QSE_FILE* out, const qse_char_t* argv0)
static void print_usage (qse_sio_t* out, const qse_char_t* argv0)
{
qse_fprintf (out, QSE_T("USAGE: %s [options] -f sourcefile [ -- ] [datafile]*\n"), argv0);
qse_fprintf (out, QSE_T(" %s [options] [ -- ] sourcestring [datafile]*\n"), argv0);
@ -444,40 +444,45 @@ int qse_main (int argc, qse_achar_t* argv[])
{
int ret;
#if defined(_WIN32)
char locale[100];
UINT codepage;
WSADATA wsadata;
qse_openstdsios ();
codepage = GetConsoleOutputCP();
if (codepage == CP_UTF8)
{
/*SetConsoleOUtputCP (CP_UTF8);*/
qse_setdflcmgrbyid (QSE_CMGR_UTF8);
}
else
{
sprintf (locale, ".%u", (unsigned int)codepage);
setlocale (LC_ALL, locale);
#if defined(_WIN32)
char locale[100];
UINT codepage;
WSADATA wsadata;
codepage = GetConsoleOutputCP();
if (codepage == CP_UTF8)
{
/*SetConsoleOUtputCP (CP_UTF8);*/
qse_setdflcmgrbyid (QSE_CMGR_UTF8);
}
else
{
sprintf (locale, ".%u", (unsigned int)codepage);
setlocale (LC_ALL, locale);
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
}
if (WSAStartup (MAKEWORD(2,0), &wsadata) != 0)
{
print_error (QSE_T("Failed to start up winsock\n"));
return -1;
}
#else
setlocale (LC_ALL, "");
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
#endif
}
if (WSAStartup (MAKEWORD(2,0), &wsadata) != 0)
{
print_error (QSE_T("Failed to start up winsock\n"));
return -1;
}
#else
setlocale (LC_ALL, "");
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
#endif
ret = qse_runmain (argc, argv, awk_main);
#if defined(_WIN32)
WSACleanup ();
#endif
qse_closestdsios ();
return ret;
}

View File

@ -19,7 +19,7 @@
*/
#include <qse/awk/StdAwk.hpp>
#include <qse/cmn/stdio.h>
#include <qse/cmn/sio.h>
#include <qse/cmn/main.h>
#include <qse/cmn/mbwc.h>
@ -82,24 +82,31 @@ static int awk_main (int argc, qse_char_t* argv[])
int qse_main (int argc, qse_achar_t* argv[])
{
#if defined(_WIN32)
char locale[100];
UINT codepage = GetConsoleOutputCP();
if (codepage == CP_UTF8)
{
/*SetConsoleOUtputCP (CP_UTF8);*/
qse_setdflcmgrbyid (QSE_CMGR_UTF8);
}
else
{
sprintf (locale, ".%u", (unsigned int)codepage);
setlocale (LC_ALL, locale);
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
}
#else
setlocale (LC_ALL, "");
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
#endif
int x;
return qse_runmain (argc,argv,awk_main);
qse_openstdsios ();
{
#if defined(_WIN32)
char locale[100];
UINT codepage = GetConsoleOutputCP();
if (codepage == CP_UTF8)
{
/*SetConsoleOUtputCP (CP_UTF8);*/
qse_setdflcmgrbyid (QSE_CMGR_UTF8);
}
else
{
sprintf (locale, ".%u", (unsigned int)codepage);
setlocale (LC_ALL, locale);
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
}
#else
setlocale (LC_ALL, "");
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
#endif
}
x = qse_runmain (argc,argv,awk_main);
qse_closestdsios ();
return x;
}

View File

@ -19,7 +19,7 @@
*/
#include <qse/awk/StdAwk.hpp>
#include <qse/cmn/stdio.h>
#include <qse/cmn/sio.h>
#include <qse/cmn/main.h>
#include <qse/cmn/mbwc.h>
@ -109,23 +109,32 @@ static int awk_main (int argc, qse_char_t* argv[])
int qse_main (int argc, qse_achar_t* argv[])
{
#if defined(_WIN32)
char locale[100];
UINT codepage = GetConsoleOutputCP();
if (codepage == CP_UTF8)
int x;
qse_openstdsios ();
{
/*SetConsoleOUtputCP (CP_UTF8);*/
qse_setdflcmgrbyid (QSE_CMGR_UTF8);
}
else
{
sprintf (locale, ".%u", (unsigned int)codepage);
setlocale (LC_ALL, locale);
#if defined(_WIN32)
char locale[100];
UINT codepage = GetConsoleOutputCP();
if (codepage == CP_UTF8)
{
/*SetConsoleOUtputCP (CP_UTF8);*/
qse_setdflcmgrbyid (QSE_CMGR_UTF8);
}
else
{
sprintf (locale, ".%u", (unsigned int)codepage);
setlocale (LC_ALL, locale);
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
}
#else
setlocale (LC_ALL, "");
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
#endif
}
#else
setlocale (LC_ALL, "");
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
#endif
return qse_runmain (argc,argv,awk_main);
x = qse_runmain (argc,argv,awk_main);
qse_closestdsios ();
return x;
}

View File

@ -19,7 +19,7 @@
*/
#include <qse/awk/StdAwk.hpp>
#include <qse/cmn/stdio.h>
#include <qse/cmn/sio.h>
#include <qse/cmn/main.h>
#include <qse/cmn/mbwc.h>
#include <qse/cmn/str.h>
@ -95,7 +95,7 @@ protected:
return -1;
}
ssize_t read (StdAwk::Console& io, StdAwk::char_t* data, size_t size)
StdAwk::ssize_t read (StdAwk::Console& io, StdAwk::char_t* data, size_t size)
{
if (this->inptr >= this->inend) return 0; // EOF
size_t x = qse_strxncpy (data, size, inptr, inend - inptr);
@ -103,7 +103,7 @@ protected:
return x;
}
ssize_t write (StdAwk::Console& io, const StdAwk::char_t* data, size_t size)
StdAwk::ssize_t write (StdAwk::Console& io, const StdAwk::char_t* data, size_t size)
{
try { this->output.append (data, size); }
catch (...)
@ -217,24 +217,31 @@ static int awk_main (int argc, qse_char_t* argv[])
int qse_main (int argc, qse_achar_t* argv[])
{
#if defined(_WIN32)
char locale[100];
UINT codepage = GetConsoleOutputCP();
if (codepage == CP_UTF8)
{
/*SetConsoleOUtputCP (CP_UTF8);*/
qse_setdflcmgrbyid (QSE_CMGR_UTF8);
}
else
{
sprintf (locale, ".%u", (unsigned int)codepage);
setlocale (LC_ALL, locale);
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
}
#else
setlocale (LC_ALL, "");
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
#endif
int x;
qse_openstdsios ();
return qse_runmain (argc,argv,awk_main);
{
#if defined(_WIN32)
char locale[100];
UINT codepage = GetConsoleOutputCP();
if (codepage == CP_UTF8)
{
/*SetConsoleOUtputCP (CP_UTF8);*/
qse_setdflcmgrbyid (QSE_CMGR_UTF8);
}
else
{
sprintf (locale, ".%u", (unsigned int)codepage);
setlocale (LC_ALL, locale);
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
}
#else
setlocale (LC_ALL, "");
qse_setdflcmgrbyid (QSE_CMGR_SLMB);
#endif
}
x = qse_runmain (argc,argv,awk_main);
qse_closestdsios ();
return x;
}