touched up awk for OS2

This commit is contained in:
2011-04-18 09:28:22 +00:00
parent 212a71460f
commit ea724c784c
16 changed files with 1605 additions and 330 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: awk.c 365 2010-10-29 13:54:36Z hyunghwan.chung $
* $Id: awk.c 436 2011-04-17 15:28:22Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
This file is part of QSE.
@ -223,6 +223,10 @@ qse_awk_t* qse_awk_open (qse_mmgr_t* mmgr, qse_size_t xtn, qse_awk_prm_t* prm)
qse_lda_setcopier (awk->parse.params, QSE_LDA_COPIER_INLINE);
awk->option = QSE_AWK_CLASSIC;
#if defined(_WIN32) || defined(__OS2__)
awk->option |= QSE_AWK_CRLF;
#endif
awk->errinf.num = QSE_AWK_ENOERR;
awk->errinf.loc.line = 0;
awk->errinf.loc.colm = 0;

View File

@ -1,5 +1,5 @@
/*
* $Id: err.c 311 2009-12-09 11:35:54Z hyunghwan.chung $
* $Id: err.c 436 2011-04-17 15:28:22Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
This file is part of QSE.
@ -303,3 +303,4 @@ void qse_awk_rtx_seterror (
if (errloc != QSE_NULL) rtx->errinf.loc = *errloc;
}

View File

@ -1,5 +1,5 @@
/*
* $Id: run.c 365 2010-10-29 13:54:36Z hyunghwan.chung $
* $Id: run.c 436 2011-04-17 15:28:22Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
This file is part of QSE.
@ -731,14 +731,15 @@ qse_awk_rtx_t* qse_awk_rtx_open (
}
/* initialize the run object */
if (init_rtx (rtx, awk, rio) == -1)
if (init_rtx (rtx, awk, rio) <= -1)
{
QSE_AWK_FREE (awk, rtx);
return QSE_NULL;
}
if (init_globals (rtx, arg) == -1)
if (init_globals (rtx, arg) <= -1)
{
awk->errinf = rtx->errinf; /* transfer error info */
fini_rtx (rtx, 0);
QSE_AWK_FREE (awk, rtx);
return QSE_NULL;

View File

@ -1,5 +1,5 @@
/*
* $Id: std.c 434 2011-04-16 14:55:26Z hyunghwan.chung $
* $Id: std.c 436 2011-04-17 15:28:22Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
This file is part of QSE.
@ -32,6 +32,24 @@
#include <stdlib.h>
#include <math.h>
#if defined(_WIN32)
# include <tchar.h>
#endif
#ifndef QSE_HAVE_CONFIG_H
# if defined(__OS2__) || defined(_WIN32)
# define HAVE_POW
# define HAVE_SIN
# define HAVE_COS
# define HAVE_TAN
# define HAVE_ATAN
# define HAVE_ATAN2
# define HAVE_LOG
# define HAVE_EXP
# define HAVE_SQRT
# endif
#endif
typedef struct xtn_t
{
struct
@ -914,7 +932,7 @@ static int open_rio_console (qse_awk_rtx_t* rtx, qse_awk_rio_arg_t* riod)
}
if (qse_awk_rtx_setfilename (
rtx, file, qse_strlen(file)) == -1)
rtx, file, qse_strlen(file)) <= -1)
{
if (sio != qse_sio_in) qse_sio_close (sio);
qse_awk_rtx_free (rtx, out.u.cpldup.ptr);
@ -986,7 +1004,7 @@ static int open_rio_console (qse_awk_rtx_t* rtx, qse_awk_rio_arg_t* riod)
}
if (qse_awk_rtx_setofilename (
rtx, file, qse_strlen(file)) == -1)
rtx, file, qse_strlen(file)) <= -1)
{
qse_sio_close (sio);
return -1;
@ -1094,9 +1112,9 @@ static qse_ssize_t awk_rio_console (
}
qse_awk_rtx_t* qse_awk_rtx_openstd (
qse_awk_t* awk,
qse_size_t xtnsize,
const qse_char_t* id,
qse_awk_t* awk,
qse_size_t xtnsize,
const qse_char_t* id,
const qse_char_t*const icf[],
const qse_char_t*const ocf[])
{
@ -1176,6 +1194,40 @@ qse_awk_rtx_t* qse_awk_rtx_openstd (
rxtn->c.out.index = 0;
rxtn->c.out.count = 0;
if (icf && icf[0])
{
/* If an explicit console file name is given,
* set FILENAME in advance in case FILENAME printing
* is the first output statement executed. FILENAME
* would be printed as an empty string without this
* as FILENAME is resolved before the I/O handler is
* executed.
*/
if (qse_awk_rtx_setfilename (rtx, icf[0], qse_strlen(icf[0])) <= -1)
{
awk->errinf = rtx->errinf; /* transfer error info */
qse_awk_rtx_close (rtx);
return QSE_NULL;
}
}
if (ocf && ocf[0])
{
/* If an explicit console file name is given,
* set OFILENAME in advance in case OFILENAME printing
* is the first output statement executed. OFILENAME
* would be printed as an empty string without this
* as OFILENAME is resolved before the I/O handler is
* executed.
*/
if (qse_awk_rtx_setofilename (rtx, ocf[0], qse_strlen(ocf[0])) <= -1)
{
awk->errinf = rtx->errinf; /* transfer error info */
qse_awk_rtx_close (rtx);
return QSE_NULL;
}
}
return rtx;
}