renamed some functions, variables, definitions, etc to shorten names.

- renamed global to gbl
- renamed local to lcl
This commit is contained in:
hyung-hwan 2009-02-02 08:28:04 +00:00
parent 0836d3e319
commit 1201d2890b
34 changed files with 1305 additions and 975 deletions

View File

@ -12,4 +12,4 @@ make
Generate the API documents with robodoc. Generate the API documents with robodoc.
robodoc --rc doc/robodoc.rc --src include/qse --doc ./doc/qse --multidoc --index --html --source_line_numbers --nopre robodoc --rc doc/robodoc.rc --css doc/robodoc.css --src include/qse --doc ./doc/qse --multidoc --index --html --source_line_numbers --nopre

View File

@ -174,7 +174,7 @@ static int on_run_enter (qse_awk_rtx_t* run, void* data)
if (fs == QSE_NULL) return -1; if (fs == QSE_NULL) return -1;
qse_awk_rtx_refupval (run, fs); qse_awk_rtx_refupval (run, fs);
qse_awk_rtx_setglobal (run, QSE_AWK_GLOBAL_FS, fs); qse_awk_rtx_setgbl (run, QSE_AWK_GBL_FS, fs);
qse_awk_rtx_refdownval (run, fs); qse_awk_rtx_refdownval (run, fs);
} }

303
qse/doc/robodoc.css Normal file
View File

@ -0,0 +1,303 @@
/****h* ROBODoc/ROBODoc Cascading Style Sheet
* FUNCTION
* This is the default cascading style sheet for documentation
* generated with ROBODoc.
* You can edit this file to your own liking and then use
* it with the option
* --css <filename>
*
* This style-sheet defines the following layout
* +----------------------------------------+
* | logo |
* +----------------------------------------+
* | extra |
* +----------------------------------------+
* | | navi- |
* | | gation |
* | content | |
* | | |
* +----------------------------------------+
* | footer |
* +----------------------------------------+
*
* This style-sheet is based on a style-sheet that was automatically
* generated with the Strange Banana stylesheet generator.
* See http://www.strangebanana.com/generator.aspx
*
******
* $Id: html_generator.c,v 1.93 2008/03/13 10:34:50 thuffir Exp $
*/
body
{
background-color: rgb(255,255,255);
color: rgb(98,84,55);
//font-family: Arial, serif;
border-color: rgb(226,199,143);
}
pre
{
font-family: monospace;
margin: 15px;
padding: 5px;
white-space: pre;
color: #000;
}
pre.source
{
background-color: #ffe;
border: dashed #aa9 1px;
}
p
{
margin:15px;
}
p.item_name
{
font-weight: bolder;
margin:5px;
//font-size: 120%;
}
#content
{
font-size: 100%;
color: rgb(0,0,0);
background-color: rgb(255,255,255);
border-left-width: 0px;
border-right-width: 0px;
border-top-width: 0px;
border-bottom-width: 0px;
border-left-style: none;
border-right-style: none;
border-top-style: none;
border-bottom-style: none;
padding: 40px 31px 14px 17px;
border-color: rgb(0,0,0);
text-align: justify;
}
#navigation
{
background-color: rgb(98,84,55);
color: rgb(230,221,202);
font-family: "Times New Roman", serif;
font-style: normal;
border-color: rgb(0,0,0);
}
a.menuitem
{
//font-size: 120%;
//font-size: 120%;
background-color: rgb(0,0,0);
color: rgb(195,165,100);
font-variant: normal;
text-transform: none;
font-weight: normal;
padding: 1px 8px 3px 1px;
margin-left: 5px;
margin-right: 5px;
margin-top: 5px;
margin-bottom: 5px;
border-color: rgb(159,126,57);
text-align: right;
}
#logo, #logo a
{
//font-size: 130%;
background-color: rgb(198,178,135);
color: rgb(98,84,55);
font-family: Georgia, serif;
font-style: normal;
font-variant: normal;
text-transform: none;
font-weight: bold;
padding: 20px 18px 20px 18px;
border-color: rgb(255,255,255);
text-align: right;
}
#extra, #extra a
{
//font-size: 128%;
background-color: rgb(0,0,0);
color: rgb(230,221,202);
font-style: normal;
font-variant: normal;
text-transform: none;
font-weight: normal;
border-left-width: 0px;
border-right-width: 0px;
border-top-width: 0px;
border-bottom-width: 0px;
border-left-style: none;
border-right-style: none;
border-top-style: none;
border-bottom-style: none;
padding: 12px 12px 12px 12px;
border-color: rgb(195,165,100);
text-align: center;
}
#content a
{
color: rgb(159,126,57);
text-decoration: none;
}
#content a:hover, #content a:active
{
color: rgb(255,255,255);
background-color: rgb(159,126,57);
}
a.indexitem
{
display: block;
}
h1, h2, h3, h4, h5, h6
{
background-color: rgb(221,221,221);
font-family: Arial, serif;
font-style: normal;
font-variant: normal;
text-transform: none;
font-weight: normal;
}
h1
{
font-size: 151%;
}
h2
{
font-size: 142%;
}
h3
{
font-size: 133%;
}
h4
{
font-size: 124%;
}
h5
{
font-size: 115%;
}
h6
{
font-size: 106%;
}
#navigation a
{
text-decoration: none;
}
.menuitem:hover
{
background-color: rgb(195,165,100);
color: rgb(0,0,0);
}
#extra a
{
text-decoration: none;
}
#logo a
{
text-decoration: none;
}
#extra a:hover
{
}
/* layout */
#navigation
{
width: 22%;
position: relative;
top: 0;
right: 0;
float: right;
text-align: center;
margin-left: 10px;
}
.menuitem {width: auto;}
#content {width: auto;}
.menuitem {display: block;}
div#footer
{
background-color: rgb(198,178,135);
color: rgb(98,84,55);
clear: left;
width: 100%;
font-size: 71%;
}
div#footer a
{
background-color: rgb(198,178,135);
color: rgb(98,84,55);
}
div#footer p
{
margin:0;
padding:5px 10px
}
span.keyword
{
color: #00F;
}
span.comment
{
color: #080;
}
span.quote
{
color: #F00;
}
span.squote
{
color: #F0F;
}
span.sign
{
color: #008B8B;
}
span.line_number
{
color: #808080;
}
@media print
{
#navigation {display: none;}
#content {padding: 0px;}
#content a {text-decoration: underline;}
}

View File

@ -37,8 +37,9 @@ remark end markers:
ignore files: ignore files:
.svn .svn
headertypes: headertypes:
o "Overview" robo_overview 0 o "Overview" robo_overview 10
b "Callbacks" robo_callbacks 1
options: options:
--nosort
--cmode --cmode
--nopre
--documenttitle "QSE"
--source_line_numbers

View File

@ -594,23 +594,23 @@ public:
enum Global enum Global
{ {
GBL_ARGC = QSE_AWK_GLOBAL_ARGC, GBL_ARGC = QSE_AWK_GBL_ARGC,
GBL_ARGV = QSE_AWK_GLOBAL_ARGV, GBL_ARGV = QSE_AWK_GBL_ARGV,
GBL_CONVFMT = QSE_AWK_GLOBAL_CONVFMT, GBL_CONVFMT = QSE_AWK_GBL_CONVFMT,
GBL_FILENAME = QSE_AWK_GLOBAL_FILENAME, GBL_FILENAME = QSE_AWK_GBL_FILENAME,
GBL_FNR = QSE_AWK_GLOBAL_FNR, GBL_FNR = QSE_AWK_GBL_FNR,
GBL_FS = QSE_AWK_GLOBAL_FS, GBL_FS = QSE_AWK_GBL_FS,
GBL_IGNORECASE = QSE_AWK_GLOBAL_IGNORECASE, GBL_IGNORECASE = QSE_AWK_GBL_IGNORECASE,
GBL_NF = QSE_AWK_GLOBAL_NF, GBL_NF = QSE_AWK_GBL_NF,
GBL_NR = QSE_AWK_GLOBAL_NR, GBL_NR = QSE_AWK_GBL_NR,
GBL_OFILENAME = QSE_AWK_GLOBAL_OFILENAME, GBL_OFILENAME = QSE_AWK_GBL_OFILENAME,
GBL_OFMT = QSE_AWK_GLOBAL_OFMT, GBL_OFMT = QSE_AWK_GBL_OFMT,
GBL_OFS = QSE_AWK_GLOBAL_OFS, GBL_OFS = QSE_AWK_GBL_OFS,
GBL_ORS = QSE_AWK_GLOBAL_ORS, GBL_ORS = QSE_AWK_GBL_ORS,
GBL_RLENGTH = QSE_AWK_GLOBAL_RLENGTH, GBL_RLENGTH = QSE_AWK_GBL_RLENGTH,
GBL_RS = QSE_AWK_GLOBAL_RS, GBL_RS = QSE_AWK_GBL_RS,
GBL_RSTART = QSE_AWK_GLOBAL_RSTART, GBL_RSTART = QSE_AWK_GBL_RSTART,
GBL_SUBSEP = QSE_AWK_GLOBAL_SUBSEP GBL_SUBSEP = QSE_AWK_GBL_SUBSEP
}; };
/** Represents the execution context */ /** Represents the execution context */

View File

@ -24,7 +24,7 @@
#include <qse/cmn/map.h> #include <qse/cmn/map.h>
#include <qse/cmn/str.h> #include <qse/cmn/str.h>
/****o* awk/awk interpreter /****o* AWK/AWK Interpreter
* DESCRIPTION * DESCRIPTION
* The library includes an AWK interpreter that can be embedded into other * The library includes an AWK interpreter that can be embedded into other
* applications or can run stand-alone. * applications or can run stand-alone.
@ -33,8 +33,22 @@
****** ******
*/ */
/****t* AWK/qse_awk_t
* NAME
* qse_awk_t - define an AWK type
* SYNOPSIS
*/
typedef struct qse_awk_t qse_awk_t; typedef struct qse_awk_t qse_awk_t;
/******/
/****t* AWK/qse_awk_rtx_t
* NAME
* qse_awk_rtx_t - define an AWK runtime context type
* SYNOPSIS
*/
typedef struct qse_awk_rtx_t qse_awk_rtx_t; /* (R)untime con(T)e(X)t */ typedef struct qse_awk_rtx_t qse_awk_rtx_t; /* (R)untime con(T)e(X)t */
/******/
typedef struct qse_awk_val_t qse_awk_val_t; typedef struct qse_awk_val_t qse_awk_val_t;
typedef struct qse_awk_eio_t qse_awk_eio_t; /* (E)xternal (IO) */ typedef struct qse_awk_eio_t qse_awk_eio_t; /* (E)xternal (IO) */
@ -434,35 +448,35 @@ enum qse_awk_eio_mode_t
QSE_AWK_EIO_CONSOLE_WRITE = 1 QSE_AWK_EIO_CONSOLE_WRITE = 1
}; };
enum qse_awk_global_id_t enum qse_awk_gbl_id_t
{ {
/* this table should match gtab in parse.c. /* this table should match gtab in parse.c.
* in addition, qse_awk_rtx_setglobal also counts * in addition, qse_awk_rtx_setgbl also counts
* on the order of these values */ * on the order of these values */
QSE_AWK_GLOBAL_ARGC, QSE_AWK_GBL_ARGC,
QSE_AWK_GLOBAL_ARGV, QSE_AWK_GBL_ARGV,
QSE_AWK_GLOBAL_CONVFMT, QSE_AWK_GBL_CONVFMT,
QSE_AWK_GLOBAL_FILENAME, QSE_AWK_GBL_FILENAME,
QSE_AWK_GLOBAL_FNR, QSE_AWK_GBL_FNR,
QSE_AWK_GLOBAL_FS, QSE_AWK_GBL_FS,
QSE_AWK_GLOBAL_IGNORECASE, QSE_AWK_GBL_IGNORECASE,
QSE_AWK_GLOBAL_NF, QSE_AWK_GBL_NF,
QSE_AWK_GLOBAL_NR, QSE_AWK_GBL_NR,
QSE_AWK_GLOBAL_OFILENAME, QSE_AWK_GBL_OFILENAME,
QSE_AWK_GLOBAL_OFMT, QSE_AWK_GBL_OFMT,
QSE_AWK_GLOBAL_OFS, QSE_AWK_GBL_OFS,
QSE_AWK_GLOBAL_ORS, QSE_AWK_GBL_ORS,
QSE_AWK_GLOBAL_RLENGTH, QSE_AWK_GBL_RLENGTH,
QSE_AWK_GLOBAL_RS, QSE_AWK_GBL_RS,
QSE_AWK_GLOBAL_RSTART, QSE_AWK_GBL_RSTART,
QSE_AWK_GLOBAL_SUBSEP, QSE_AWK_GBL_SUBSEP,
/* these are not not the actual IDs and are used internally only /* these are not not the actual IDs and are used internally only
* Make sure you update these values properly if you add more * Make sure you update these values properly if you add more
* ID definitions, however */ * ID definitions, however */
QSE_AWK_MIN_GLOBAL_ID = QSE_AWK_GLOBAL_ARGC, QSE_AWK_MIN_GBL_ID = QSE_AWK_GBL_ARGC,
QSE_AWK_MAX_GLOBAL_ID = QSE_AWK_GLOBAL_SUBSEP QSE_AWK_MAX_GBL_ID = QSE_AWK_GBL_SUBSEP
}; };
enum qse_awk_val_type_t enum qse_awk_val_type_t
@ -485,12 +499,12 @@ enum qse_awk_val_ref_id_t
/* keep these items in the same order as corresponding items /* keep these items in the same order as corresponding items
* in tree.h */ * in tree.h */
QSE_AWK_VAL_REF_NAMED, QSE_AWK_VAL_REF_NAMED,
QSE_AWK_VAL_REF_GLOBAL, QSE_AWK_VAL_REF_GBL,
QSE_AWK_VAL_REF_LOCAL, QSE_AWK_VAL_REF_LCL,
QSE_AWK_VAL_REF_ARG, QSE_AWK_VAL_REF_ARG,
QSE_AWK_VAL_REF_NAMEDIDX, QSE_AWK_VAL_REF_NAMEDIDX,
QSE_AWK_VAL_REF_GLOBALIDX, QSE_AWK_VAL_REF_GBLIDX,
QSE_AWK_VAL_REF_LOCALIDX, QSE_AWK_VAL_REF_LCLIDX,
QSE_AWK_VAL_REF_ARGIDX, QSE_AWK_VAL_REF_ARGIDX,
QSE_AWK_VAL_REF_POS QSE_AWK_VAL_REF_POS
}; };
@ -618,7 +632,7 @@ extern qse_awk_val_t* qse_awk_val_zero;
/** represents a numeric value 1 */ /** represents a numeric value 1 */
extern qse_awk_val_t* qse_awk_val_one; extern qse_awk_val_t* qse_awk_val_one;
/****f* awk/qse_awk_open /****f* AWK/qse_awk_open
* NAME * NAME
* qse_awk_open - create an awk object * qse_awk_open - create an awk object
* DESCRIPTION * DESCRIPTION
@ -637,7 +651,7 @@ qse_awk_t* qse_awk_open (
); );
/******/ /******/
/****f* awk/qse_awk_close /****f* AWK/qse_awk_close
* NAME * NAME
* qse_awk_close - destroy an awk object * qse_awk_close - destroy an awk object
* DESCRIPTION * DESCRIPTION
@ -653,7 +667,7 @@ int qse_awk_close (
); );
/******/ /******/
/****f* awk/qse_awk_getmmgr /****f* AWK/qse_awk_getmmgr
* NAME * NAME
* qse_awk_getmmgr - get the memory manager * qse_awk_getmmgr - get the memory manager
* DESCRIPTION * DESCRIPTION
@ -665,7 +679,7 @@ qse_mmgr_t* qse_awk_getmmgr (
); );
/******/ /******/
/****f* awk/qse_awk_setmmgr /****f* AWK/qse_awk_setmmgr
* NAME * NAME
* qse_awk_setmmgr - set the extension * qse_awk_setmmgr - set the extension
* DESCRIPTION * DESCRIPTION
@ -680,7 +694,7 @@ void qse_awk_setmmgr (
); );
/******/ /******/
/****f* awk/qse_awk_getxtn /****f* AWK/qse_awk_getxtn
* NAME * NAME
* qse_awk_getxtn - get the extension * qse_awk_getxtn - get the extension
* DESCRIPTION * DESCRIPTION
@ -695,7 +709,7 @@ void* qse_awk_getxtn (
); );
/******/ /******/
/****f* awk/qse_awk_getccls /****f* AWK/qse_awk_getccls
* NAME * NAME
* qse_awk_getccls - get a character classifier * qse_awk_getccls - get a character classifier
* SYNOPSIS * SYNOPSIS
@ -705,7 +719,7 @@ qse_ccls_t* qse_awk_getccls (
); );
/******/ /******/
/****f* awk/qse_awk_setccls /****f* AWK/qse_awk_setccls
* NAME * NAME
* qse_awk_setccls - set the character classfier * qse_awk_setccls - set the character classfier
* SYNOPSIS * SYNOPSIS
@ -716,7 +730,7 @@ void qse_awk_setccls (
); );
/******/ /******/
/****f* awk/qse_awk_getprmfns /****f* AWK/qse_awk_getprmfns
* NAME * NAME
* qse_awk_getprmfns - get primitive functions * qse_awk_getprmfns - get primitive functions
* SYNOPSIS * SYNOPSIS
@ -726,7 +740,7 @@ qse_awk_prmfns_t* qse_awk_getprmfns (
); );
/******/ /******/
/****f* awk/qse_awk_setprmfns /****f* AWK/qse_awk_setprmfns
* NAME * NAME
* qse_awk_setprmfns - set primitive functions * qse_awk_setprmfns - set primitive functions
* SYNOPSIS * SYNOPSIS
@ -737,7 +751,7 @@ void qse_awk_setprmfns (
); );
/******/ /******/
/****f* awk/qse_awk_clear /****f* AWK/qse_awk_clear
* NAME * NAME
* qse_awk_clear - clear a qse_awk_t object * qse_awk_clear - clear a qse_awk_t object
* DESCRIPTION * DESCRIPTION
@ -753,7 +767,7 @@ int qse_awk_clear (
); );
/******/ /******/
/****f* awk/qse_awk_geterrstr /****f* AWK/qse_awk_geterrstr
* NAME * NAME
* qse_awk_geterrstr - get a format string for an error * qse_awk_geterrstr - get a format string for an error
* DESCRIPTION * DESCRIPTION
@ -767,7 +781,7 @@ const qse_char_t* qse_awk_geterrstr (
); );
/******/ /******/
/****f* awk/qse_awk_seterrstr /****f* AWK/qse_awk_seterrstr
* NAME * NAME
* qse_awk_geterrstr - set a format string for an error * qse_awk_geterrstr - set a format string for an error
* DESCRIPTION * DESCRIPTION
@ -886,34 +900,74 @@ int qse_awk_setword (
qse_size_t nlen qse_size_t nlen
); );
/****f* awk/qse_awk_addglobal /****f* AWK/qse_awk_addgbl
* NAME * NAME
* qse_awk_addglobal - add an intrinsic global variable. * qse_awk_addgbl - add an intrinsic global variable.
* RETURN * RETURN
* The qse_awk_addglobal() function returns the ID of the global variable * The qse_awk_addgbl() function returns the ID of the global variable
* added on success and -1 on failure. * added on success and -1 on failure.
* SYNOPSIS * SYNOPSIS
*/ */
int qse_awk_addglobal ( int qse_awk_addgbl (
qse_awk_t* awk, qse_awk_t* awk,
const qse_char_t* name, const qse_char_t* name,
qse_size_t len qse_size_t len
); );
/******/ /******/
/****f* awk/qse_awk_delglobal /****f* AWK/qse_awk_delgbl
* NAME * NAME
* qse_awk_delglobal - delete an instrinsic global variable. * qse_awk_delgbl - delete an instrinsic global variable.
* SYNOPSIS * SYNOPSIS
*/ */
int qse_awk_delglobal ( int qse_awk_delgbl (
qse_awk_t* awk, qse_awk_t* awk,
const qse_char_t* name, const qse_char_t* name,
qse_size_t len qse_size_t len
); );
/******/ /******/
/****f* awk/qse_awk_parse /****f* AWK/qse_awk_addfnc
* NAME
* qse_awk_addfnc - add an intrinsic function
* SYNOPSIS
*/
void* qse_awk_addfnc (
qse_awk_t* awk,
const qse_char_t* name,
qse_size_t name_len,
int when_valid,
qse_size_t min_args,
qse_size_t max_args,
const qse_char_t* arg_spec,
int (*handler)(qse_awk_rtx_t*,const qse_char_t*,qse_size_t)
);
/******/
/****f* AWK/qse_awk_delfnc
* NAME
* qse_awk_delfnc - delete an intrinsic function
* SYNOPSIS
*/
int qse_awk_delfnc (
qse_awk_t* awk,
const qse_char_t* name,
qse_size_t len
);
/******/
/****f* AWK/qse_awk_clrfnc
* NAME
* qse_awk_clrfnc - delete all intrinsic functions
* SYNOPSIS
*/
void qse_awk_clrfnc (
qse_awk_t* awk
);
/*****/
/****f* AWK/qse_awk_parse
* NAME * NAME
* qse_awk_parse - parse source code * qse_awk_parse - parse source code
* SYNOPSIS * SYNOPSIS
@ -924,43 +978,7 @@ int qse_awk_parse (
); );
/******/ /******/
/****f* AWK/qse_awk_run
/****f* awk/qse_awk_opensimple
* NAME
* qse_awk_opensimple - create an awk object
* SYNOPSIS
*/
qse_awk_t* qse_awk_opensimple (
qse_size_t xtnsize /* size of extension area in bytes */
);
/******/
/****f* awk/qse_awk_parsesimple
* NAME
* qse_awk_parsesimple - parse source code
* SYNOPSIS
*/
int qse_awk_parsesimple (
qse_awk_t* awk,
const void* isp /* source file names or source string */,
int ist /* QSE_AWK_PARSE_FILES, QSE_AWK_PARSE_STRING */,
const qse_char_t* osf /* an output source file name */
);
/******/
/****f* awk/qse_awk_runsimple
* NAME
* qse_awk_runsimple - run a parsed program
* SYNOPSIS
*/
int qse_awk_runsimple (
qse_awk_t* awk,
qse_char_t** icf /* input console files */,
qse_awk_runcbs_t* cbs /* callbacks */
);
/******/
/****f* awk/qse_awk_run
* NAME * NAME
* qse_awk_run - execute a parsed program * qse_awk_run - execute a parsed program
* DESCRIPTION * DESCRIPTION
@ -987,29 +1005,126 @@ int qse_awk_run (
); );
/******/ /******/
/* functions to manipulate intrinsic functions */ /****f* AWK/qse_awk_opensimple
void* qse_awk_addfnc ( * NAME
* qse_awk_opensimple - create an awk object
* SYNOPSIS
*/
qse_awk_t* qse_awk_opensimple (
qse_size_t xtnsize /* size of extension area in bytes */
);
/******/
/****f* AWK/qse_awk_parsesimple
* NAME
* qse_awk_parsesimple - parse source code
* SYNOPSIS
*/
int qse_awk_parsesimple (
qse_awk_t* awk, qse_awk_t* awk,
const qse_char_t* name, const void* isp /* source file names or source string */,
qse_size_t name_len, int ist /* QSE_AWK_PARSE_FILES, QSE_AWK_PARSE_STRING */,
int when_valid, const qse_char_t* osf /* an output source file name */
qse_size_t min_args,
qse_size_t max_args,
const qse_char_t* arg_spec,
int (*handler)(qse_awk_rtx_t*,const qse_char_t*,qse_size_t)
); );
/******/
int qse_awk_delfnc ( /****f* AWK/qse_awk_runsimple
* NAME
* qse_awk_runsimple - run a parsed program
* SYNOPSIS
*/
int qse_awk_runsimple (
qse_awk_t* awk, qse_awk_t* awk,
const qse_char_t* name, qse_char_t** icf /* input console files */,
qse_size_t len qse_awk_runcbs_t* cbs /* callbacks */
);
/******/
/****f* AWK/qse_awk_alloc
* NAME
* qse_awk_alloc - allocate dynamic memory
* RETURN
* the pointer to the memory space allocated on success, QSE_NULL on failure
* SYNOPSIS
*/
void* qse_awk_alloc (
qse_awk_t* awk /* the pointer to a qse_awk_t instance */,
qse_size_t size /* the size of memory to allocate in bytes */
);
/******/
/****f* AWK/qse_awk_free
* NAME
* qse_awk_free - free dynamic memory
* SYNOPSIS
*/
void qse_awk_free (
qse_awk_t* awk /* the pointer to a qse_awk_t instance */,
void* ptr /* the pointer to the memory space to free */
);
/******/
/****f* AWK/qse_awk_strdup
* NAME
* qse_awk_strdup - duplicate a null-terminated string
* DESCRIPTION
* The qse_awk_strdup() function is used to duplicate a string using
* the memory manager used by the associated qse_awk_t instance.
* The new string should be freed using the qse_awk_free() function.
* RETURN
* The qse_awk_strdup() function returns the pointer to a new string which
* is a duplicate of the string s. It returns QSE_NULL on failure.
* SYNOPSIS
*/
qse_char_t* qse_awk_strdup (
qse_awk_t* awk /* the pointer to a qse_awk_t instance */,
const qse_char_t* str /* the pointer to a string */
);
/******/
/****f* AWK/qse_awk_strxdup
* NAME
* qse_awk_strxdup - duplicate a length-delimited string
* DESCRIPTION
* The qse_awk_strxdup() function is used to duplicate a string whose length
* is as long as len characters using the memory manager used by the
* qse_awk_t instance. The new string should be freed using the qse_awk_free()
* function.
* RETURN
* The qse_awk_strxdup() function returns the pointer to a new string which
* is a duplicate of the string s on success. It returns QSE_NULL on failure.
* SYNOPSIS
*/
qse_char_t* qse_awk_strxdup (
qse_awk_t* awk,
const qse_char_t* str,
qse_size_t len
);
/******/
qse_long_t qse_awk_strxtolong (
qse_awk_t* awk,
const qse_char_t* str,
qse_size_t len,
int base,
const qse_char_t** endptr
); );
void qse_awk_clrfnc ( qse_real_t qse_awk_strxtoreal (
qse_awk_t* awk qse_awk_t* awk,
const qse_char_t* str,
qse_size_t len,
const qse_char_t** endptr
); );
/****f* awk/qse_awk_stopall qse_size_t qse_awk_longtostr (
qse_long_t value,
int radix,
const qse_char_t* prefix,
qse_char_t* buf,
qse_size_t size
);
/****f* AWK/qse_awk_stopall
* NAME * NAME
* qse_awk_stopall - stop all runtime contexts * qse_awk_stopall - stop all runtime contexts
* DESCRIPTION * DESCRIPTION
@ -1022,7 +1137,7 @@ void qse_awk_stopall (
); );
/******/ /******/
/****f* awk/qse_awk_shouldstop /****f* AWK/qse_awk_shouldstop
* NAME * NAME
* qse_awk_shouldstop - test if qse_awk_rtx_stop() is called * qse_awk_shouldstop - test if qse_awk_rtx_stop() is called
* SYNOPSIS * SYNOPSIS
@ -1032,7 +1147,7 @@ qse_bool_t qse_awk_rtx_shouldstop (
); );
/******/ /******/
/****f* awk/qse_awk_rtx_stop /****f* AWK/qse_awk_rtx_stop
* NAME * NAME
* qse_awk_rtx_stop - stop a runtime context * qse_awk_rtx_stop - stop a runtime context
* DESCRIPTION * DESCRIPTION
@ -1045,7 +1160,7 @@ void qse_awk_rtx_stop (
); );
/******/ /******/
/****f* awk/qse_awk_rtx_getnargs /****f* AWK/qse_awk_rtx_getnargs
* NAME * NAME
* qse_awk_rtx_getnargs - get the number of arguments passed to qse_awk_run() * qse_awk_rtx_getnargs - get the number of arguments passed to qse_awk_run()
* SYNOPSIS * SYNOPSIS
@ -1055,7 +1170,7 @@ qse_size_t qse_awk_rtx_getnargs (
); );
/******/ /******/
/****f* awk/qse_awk_rtx_getarg /****f* AWK/qse_awk_rtx_getarg
* NAME * NAME
* qse_awk_rtx_getarg - get an argument passed to qse_awk_run * qse_awk_rtx_getarg - get an argument passed to qse_awk_run
* SYNOPSIS * SYNOPSIS
@ -1066,37 +1181,37 @@ qse_awk_val_t* qse_awk_rtx_getarg (
); );
/******/ /******/
/****f* awk/qse_awk_rtx_getglobal /****f* AWK/qse_awk_rtx_getgbl
* NAME * NAME
* qse_awk_rtx_getglobal - gets the value of a global variable * qse_awk_rtx_getgbl - gets the value of a global variable
* INPUTS * INPUTS
* * rtx - a runtime context * * rtx - a runtime context
* * id - a global variable ID. It is one of the predefined global * * id - a global variable ID. It is one of the predefined global
* variable IDs or a value returned by qse_awk_addglobal(). * variable IDs or a value returned by qse_awk_addgbl().
* RETURN * RETURN
* The pointer to a value is returned. This function never fails * The pointer to a value is returned. This function never fails
* so long as the ID is valid. Otherwise, you may fall into trouble. * so long as the ID is valid. Otherwise, you may fall into trouble.
* SYNOPSIS * SYNOPSIS
*/ */
qse_awk_val_t* qse_awk_rtx_getglobal ( qse_awk_val_t* qse_awk_rtx_getgbl (
qse_awk_rtx_t* rtx, qse_awk_rtx_t* rtx,
int id int id
); );
/******/ /******/
/****f* awk/qse_awk_rtx_setglobal /****f* AWK/qse_awk_rtx_setgbl
* NAME * NAME
* qse_awk_rtx_setglobal - set the value of a global variable * qse_awk_rtx_setgbl - set the value of a global variable
* SYNOPSIS * SYNOPSIS
*/ */
int qse_awk_rtx_setglobal ( int qse_awk_rtx_setgbl (
qse_awk_rtx_t* rtx, qse_awk_rtx_t* rtx,
int id, int id,
qse_awk_val_t* val qse_awk_val_t* val
); );
/******/ /******/
/****f* awk/qse_awk_rtx_setretval /****f* AWK/qse_awk_rtx_setretval
* NAME * NAME
* qse_awk_rtx_setretval - set the return value * qse_awk_rtx_setretval - set the return value
* DESCRIPTION * DESCRIPTION
@ -1114,7 +1229,7 @@ void qse_awk_rtx_setretval (
); );
/******/ /******/
/****f* awk/qse_awk_rtx_setfilename /****f* AWK/qse_awk_rtx_setfilename
* NAME * NAME
* qse_awk_rtx_setfilename - set FILENAME * qse_awk_rtx_setfilename - set FILENAME
* SYNOPSIS * SYNOPSIS
@ -1126,7 +1241,7 @@ int qse_awk_rtx_setfilename (
); );
/******/ /******/
/****f* awk/qse_awk_rtx_setofilename /****f* AWK/qse_awk_rtx_setofilename
* NAME * NAME
* qse_awk_rtx_setofilename - set OFILENAME * qse_awk_rtx_setofilename - set OFILENAME
* SYNOPSIS * SYNOPSIS
@ -1138,7 +1253,7 @@ int qse_awk_rtx_setofilename (
); );
/******/ /******/
/****f* awk/qse_awk_rtx_getawk /****f* AWK/qse_awk_rtx_getawk
* NAME * NAME
* qse_awk_rtx_getawk - get the owning awk object * qse_awk_rtx_getawk - get the owning awk object
* SYNOPSIS * SYNOPSIS
@ -1148,7 +1263,7 @@ qse_awk_t* qse_awk_rtx_getawk (
); );
/******/ /******/
/****f* awk/qse_awk_rtx_getmmgr /****f* AWK/qse_awk_rtx_getmmgr
* NAME * NAME
* qse_awk_rtx_getmmgr - get the memory manager of a runtime context * qse_awk_rtx_getmmgr - get the memory manager of a runtime context
* SYNOPSIS * SYNOPSIS
@ -1158,7 +1273,7 @@ qse_mmgr_t* qse_awk_rtx_getmmgr (
); );
/******/ /******/
/****f* awk/qse_awk_rtx_getdata /****f* AWK/qse_awk_rtx_getdata
* NAME * NAME
* qse_awk_rtx_getdata - get the user-specified data for a runtime context * qse_awk_rtx_getdata - get the user-specified data for a runtime context
* SYNOPSIS * SYNOPSIS
@ -1168,7 +1283,7 @@ void* qse_awk_rtx_getdata (
); );
/******/ /******/
/****f* awk/qse_awk_rtx_getnvmap /****f* AWK/qse_awk_rtx_getnvmap
* NAME * NAME
* qse_awk_rtx_getnvmap - get the map of named variables * qse_awk_rtx_getnvmap - get the map of named variables
* SYNOPSIS * SYNOPSIS
@ -1178,9 +1293,9 @@ qse_map_t* qse_awk_rtx_getnvmap (
); );
/******/ /******/
/****f* awk/qse_awk_rtx_geterrnum /****f* AWK/qse_awk_rtx_geterrnum
* NAME * NAME
* qse_awk_rtx_geterrnum - get the error number of a runtime context * qse_awk_rtx_geterrnum - get an error code of a runtime context
* SYNOPSIS * SYNOPSIS
*/ */
int qse_awk_rtx_geterrnum ( int qse_awk_rtx_geterrnum (
@ -1237,91 +1352,6 @@ int qse_awk_rtx_setrec (
qse_size_t len qse_size_t len
); );
/****f* awk/qse_awk_alloc
* NAME
* qse_awk_alloc - allocate dynamic memory
* RETURN
* the pointer to the memory area allocated on success, QSE_NULL on failure
* SYNOPSIS
*/
void* qse_awk_alloc (
qse_awk_t* awk /* the pointer to a qse_awk_t instance */,
qse_size_t size /* the size of memory to allocate in bytes */
);
/******/
/****f* awk/qse_awk_free
* NAME
* qse_awk_free - free dynamic memory
* SYNOPSIS
*/
void qse_awk_free (
qse_awk_t* awk /* the pointer to a qse_awk_t instance */,
void* ptr /* the pointer to the memory area to free */
);
/******/
/****f* awk/qse_awk_strdup
* NAME
* qse_awk_strdup - duplicate a null-terminated string
* DESCRIPTION
* The qse_awk_strdup() function is used to duplicate a string using
* the memory manager used by the associated qse_awk_t instance.
* The new string should be freed using the qse_awk_free() function.
* RETURN
* The qse_awk_strdup() function returns the pointer to a new string which
* is a duplicate of the string s. It returns QSE_NULL on failure.
* SYNOPSIS
*/
qse_char_t* qse_awk_strdup (
qse_awk_t* awk /* the pointer to a qse_awk_t instance */,
const qse_char_t* str /* the pointer to a string */
);
/******/
/****f* awk/qse_awk_strxdup
* NAME
* qse_awk_strxdup - duplicate a length-delimited string
* DESCRIPTION
* The qse_awk_strxdup() function is used to duplicate a string whose length
* is as long as len characters using the memory manager used by the
* qse_awk_t instance. The new string should be freed using the qse_awk_free()
* function.
* RETURN
* The qse_awk_strxdup() function returns the pointer to a new string which
* is a duplicate of the string s on success. It returns QSE_NULL on failure.
* SYNOPSIS
*/
qse_char_t* qse_awk_strxdup (
qse_awk_t* awk,
const qse_char_t* str,
qse_size_t len
);
/******/
qse_long_t qse_awk_strxtolong (
qse_awk_t* awk,
const qse_char_t* str,
qse_size_t len,
int base,
const qse_char_t** endptr
);
qse_real_t qse_awk_strxtoreal (
qse_awk_t* awk,
const qse_char_t* str,
qse_size_t len,
const qse_char_t** endptr
);
qse_size_t qse_awk_longtostr (
qse_long_t value,
int radix,
const qse_char_t* prefix,
qse_char_t* buf,
qse_size_t size
);
/* value manipulation functions */ /* value manipulation functions */
qse_awk_val_t* qse_awk_rtx_makeintval ( qse_awk_val_t* qse_awk_rtx_makeintval (
qse_awk_rtx_t* rtx, qse_awk_rtx_t* rtx,
@ -1413,7 +1443,7 @@ qse_char_t* qse_awk_rtx_valtostr (
qse_size_t* len qse_size_t* len
); );
/****f* awk/qse_awk_rtx_valtonum /****f* AWK/qse_awk_rtx_valtonum
* NAME * NAME
* qse_awk_rtx_valtonum - convert a value to a number * qse_awk_rtx_valtonum - convert a value to a number
* DESCRIPTION * DESCRIPTION
@ -1443,7 +1473,7 @@ int qse_awk_rtx_valtonum (
); );
/******/ /******/
/****f* awk/qse_awk_rtx_strtonum /****f* AWK/qse_awk_rtx_strtonum
* NAME * NAME
* qse_awk_rtx_strtonum - convert a string to a number * qse_awk_rtx_strtonum - convert a string to a number
* SYNOPSIS * SYNOPSIS

View File

@ -68,15 +68,13 @@ qse_size_t qse_mblen (
qse_size_t mblen qse_size_t mblen
); );
/****f* qse.cmn.chr/qse_mbtowc /****f* Common/qse_mbtowc
* NAME * NAME
* qse_mbtowc - convert a multibyte sequence to a wide character. * qse_mbtowc - convert a multibyte sequence to a wide character.
*
* RETURN * RETURN
* The qse_mbtowc() function returns 0 if an invalid multibyte sequence is * The qse_mbtowc() function returns 0 if an invalid multibyte sequence is
* detected, mblen + 1 if the sequence is incomplete. It returns the number * detected, mblen + 1 if the sequence is incomplete. It returns the number
* of bytes processed to form a wide character. * of bytes processed to form a wide character.
*
* SYNOPSIS * SYNOPSIS
*/ */
qse_size_t qse_mbtowc ( qse_size_t qse_mbtowc (
@ -86,15 +84,13 @@ qse_size_t qse_mbtowc (
); );
/******/ /******/
/****f* qse.cmn.chr/qse_wctomb /****f* Common/qse_wctomb
* NAME * NAME
* qse_wctomb - convert a wide character to a multibyte sequence * qse_wctomb - convert a wide character to a multibyte sequence
*
* RETURN * RETURN
* The qse_wctomb() functions returns 0 if the wide character is illegal, * The qse_wctomb() functions returns 0 if the wide character is illegal,
* mblen + 1 if mblen is not large enough to hold the multibyte sequence. * mblen + 1 if mblen is not large enough to hold the multibyte sequence.
* On successful conversion, it returns the number of bytes in the sequence. * On successful conversion, it returns the number of bytes in the sequence.
*
* SYNOPSIS * SYNOPSIS
*/ */
qse_size_t qse_wctomb ( qse_size_t qse_wctomb (

View File

@ -114,7 +114,7 @@ extern "C" {
QSE_DEFINE_COMMON_FUNCTIONS (fio) QSE_DEFINE_COMMON_FUNCTIONS (fio)
/****f* qse.cmn.fio/qse_fio_open /****f* Common/qse_fio_open
* NAME * NAME
* qse_fio_open - open a file * qse_fio_open - open a file
* *
@ -133,7 +133,7 @@ qse_fio_t* qse_fio_open (
); );
/******/ /******/
/****f* qse.cmn.fio/qse_fio_close /****f* Common/qse_fio_close
* NAME * NAME
* qse_fio_close - close a file * qse_fio_close - close a file
* *
@ -156,7 +156,7 @@ void qse_fio_fini (
qse_fio_t* fio qse_fio_t* fio
); );
/****f* qse.cmn.fio/qse_fio_gethandle /****f* Common/qse_fio_gethandle
* NAME * NAME
* qse_fio_gethandle - get the native file handle * qse_fio_gethandle - get the native file handle
* SYNOPSIS * SYNOPSIS
@ -166,7 +166,7 @@ qse_fio_hnd_t qse_fio_gethandle (
); );
/******/ /******/
/****f* qse.cmn.fio/qse_fio_sethandle /****f* Common/qse_fio_sethandle
* NAME * NAME
* qse_fio_sethandle - set the file handle * qse_fio_sethandle - set the file handle
* WARNING * WARNING
@ -192,7 +192,7 @@ int qse_fio_truncate (
qse_fio_off_t size qse_fio_off_t size
); );
/****f* qse.cmn.fio/qse_fio_read /****f* Common/qse_fio_read
* NAME * NAME
* qse_fio_read - read data * qse_fio_read - read data
* SYNOPSIS * SYNOPSIS
@ -204,7 +204,7 @@ qse_ssize_t qse_fio_read (
); );
/******/ /******/
/****f* qse.cmn.fio/qse_fio_write /****f* Common/qse_fio_write
* NAME * NAME
* qse_fio_write - write data * qse_fio_write - write data
* *
@ -223,7 +223,7 @@ qse_ssize_t qse_fio_write (
/******/ /******/
/****f* qse.cmn.fio/qse_fio_flush /****f* Common/qse_fio_flush
* NAME * NAME
* qse_fio_flush - flush data * qse_fio_flush - flush data
* *
@ -238,7 +238,7 @@ qse_ssize_t qse_fio_flush (
); );
/******/ /******/
/****f* qse.cmn.fio/qse_fio_chmod /****f* Common/qse_fio_chmod
* NAME * NAME
* qse_fio_chmod - change the file mode * qse_fio_chmod - change the file mode
* SYNOPSIS * SYNOPSIS
@ -249,7 +249,7 @@ int qse_fio_chmod (
); );
/******/ /******/
/****f* qse.cmn.fio/qse_fio_sync /****f* Common/qse_fio_sync
* NAME * NAME
* qse_fio_sync - synchronize file contents into storage media * qse_fio_sync - synchronize file contents into storage media
* DESCRIPTION * DESCRIPTION

View File

@ -22,12 +22,12 @@
#include <qse/types.h> #include <qse/types.h>
#include <qse/macros.h> #include <qse/macros.h>
/****o* qse.cmn.lda/linear dynamic array /****o* Common/linear dynamic array
* DESCRIPTION * DESCRIPTION
* <qse/cmn/lda.h> provides a linear dynamic array. It grows as more items * <Common.h> provides a linear dynamic array. It grows as more items
* are added. * are added.
* *
* #include <qse/cmn/lda.h> * #include <Common.h>
****** ******
*/ */
@ -62,7 +62,7 @@ typedef enum qse_lda_walk_t qse_lda_walk_t;
/****b* qse.cmn.lda/qse_lda_copier_t /****t* Common/qse_lda_copier_t
* NAME * NAME
* qse_lda_copier_t - define a node contruction callback * qse_lda_copier_t - define a node contruction callback
* *
@ -91,7 +91,7 @@ typedef void* (*qse_lda_copier_t) (
); );
/******/ /******/
/****b* qse.cmn.lda/qse_lda_freeer_t /****t* Common/qse_lda_freeer_t
* NAME * NAME
* qse_lda_freeer_t - define a node destruction callback * qse_lda_freeer_t - define a node destruction callback
* SYNOPSIS * SYNOPSIS
@ -103,7 +103,7 @@ typedef void (*qse_lda_freeer_t) (
); );
/******/ /******/
/****t* qse.cmn.lda/qse_lda_comper_t /****t* Common/qse_lda_comper_t
* NAME * NAME
* qse_lda_comper_t - define a data comparator * qse_lda_comper_t - define a data comparator
* *
@ -126,7 +126,7 @@ typedef int (*qse_lda_comper_t) (
); );
/******/ /******/
/****t* qse.cmn.lda/qse_lda_keeper_t /****t* Common/qse_lda_keeper_t
* NAME * NAME
* qse_lda_keeper_t - define a value keeper * qse_lda_keeper_t - define a value keeper
* *
@ -145,7 +145,7 @@ typedef void (*qse_lda_keeper_t) (
); );
/******/ /******/
/****t* qse.cmn.lda/qse_lda_sizer_t /****t* Common/qse_lda_sizer_t
* NAME * NAME
* qse_lda_sizer_t - define an array size calculator * qse_lda_sizer_t - define an array size calculator
* *
@ -167,7 +167,7 @@ typedef qse_lda_walk_t (*qse_lda_walker_t) (
void* arg /* user-defined data */ void* arg /* user-defined data */
); );
/****s* qse.cmn.lda/qse_lda_t /****s* Common/qse_lda_t
* NAME * NAME
* qse_lda_t - define a linear dynamic array * qse_lda_t - define a linear dynamic array
* *
@ -208,7 +208,7 @@ extern "C" {
QSE_DEFINE_COMMON_FUNCTIONS (lda) QSE_DEFINE_COMMON_FUNCTIONS (lda)
/****f* qse.cmn.lda/qse_lda_open /****f* Common/qse_lda_open
* NAME * NAME
* qse_lda_open - create a linear dynamic array * qse_lda_open - create a linear dynamic array
* *
@ -221,7 +221,7 @@ qse_lda_t* qse_lda_open (
); );
/******/ /******/
/****f* qse.cmn.lda/qse_lda_close /****f* Common/qse_lda_close
* NAME * NAME
* qse_lda_close - destroy a linear dynamic array * qse_lda_close - destroy a linear dynamic array
* *
@ -232,7 +232,7 @@ void qse_lda_close (
); );
/******/ /******/
/****f* qse.cmn.lda/qse_lda_init /****f* Common/qse_lda_init
* NAME * NAME
* qse_lda_init - initialize a linear dynamic array * qse_lda_init - initialize a linear dynamic array
* *
@ -245,7 +245,7 @@ qse_lda_t* qse_lda_init (
); );
/******/ /******/
/****f* qse.cmn.lda/qse_lda_fini /****f* Common/qse_lda_fini
* NAME * NAME
* qse_lda_fini - deinitialize a linear dynamic array * qse_lda_fini - deinitialize a linear dynamic array
* *
@ -260,7 +260,7 @@ int qse_lda_getscale (
qse_lda_t* lda /* a lda */ qse_lda_t* lda /* a lda */
); );
/****f* qse.cmn.lda/qse_lda_setscale /****f* Common/qse_lda_setscale
* NAME * NAME
* qse_lda_setscale - set the scale factor * qse_lda_setscale - set the scale factor
* *
@ -285,7 +285,7 @@ qse_lda_copier_t qse_lda_getcopier (
qse_lda_t* lda /* a lda */ qse_lda_t* lda /* a lda */
); );
/****f* qse.cmn.lda/qse_lda_setcopier /****f* Common/qse_lda_setcopier
* NAME * NAME
* qse_lda_setcopier - specify how to clone an element * qse_lda_setcopier - specify how to clone an element
* *
@ -309,7 +309,7 @@ qse_lda_freeer_t qse_lda_getfreeer (
qse_lda_t* lda /* a lda */ qse_lda_t* lda /* a lda */
); );
/****f* qse.cmn.lda/qse_lda_setfreeer /****f* Common/qse_lda_setfreeer
* NAME * NAME
* qse_lda_setfreeer - specify how to destroy an element * qse_lda_setfreeer - specify how to destroy an element
* *
@ -390,7 +390,7 @@ qse_size_t qse_lda_update (
qse_size_t dlen qse_size_t dlen
); );
/****f* qse.cmn.lda/qse_lda_delete /****f* Common/qse_lda_delete
* NAME * NAME
* qse_lda_delete - delete data * qse_lda_delete - delete data
* *
@ -410,7 +410,7 @@ qse_size_t qse_lda_delete (
); );
/******/ /******/
/****f* qse.cmn.lda/qse_lda_uplete /****f* Common/qse_lda_uplete
* NAME * NAME
* qse_lda_uplete - delete data node * qse_lda_uplete - delete data node
* *

View File

@ -22,7 +22,7 @@
#include <qse/types.h> #include <qse/types.h>
#include <qse/macros.h> #include <qse/macros.h>
/****o* qse.cmn.map/hash map /****o* Common/Hash Map
* DESCRIPTION * DESCRIPTION
* A hash map maintains buckets for key/value pairs with the same key hash * A hash map maintains buckets for key/value pairs with the same key hash
* chained under the same bucket. * chained under the same bucket.
@ -49,7 +49,7 @@ typedef struct qse_map_pair_t qse_map_pair_t;
typedef enum qse_map_walk_t qse_map_walk_t; typedef enum qse_map_walk_t qse_map_walk_t;
typedef enum qse_map_id_t qse_map_id_t; typedef enum qse_map_id_t qse_map_id_t;
/****b* qse.cmn.map/qse_map_copier_t /****t* Common/qse_map_copier_t
* NAME * NAME
* qse_map_copier_t - define a pair contruction callback * qse_map_copier_t - define a pair contruction callback
* SYNOPSIS * SYNOPSIS
@ -61,7 +61,7 @@ typedef void* (*qse_map_copier_t) (
); );
/******/ /******/
/****b* qse.cmn.map/qse_map_freeer_t /****t* Common/qse_map_freeer_t
* NAME * NAME
* qse_map_freeer_t - define a key/value destruction callback * qse_map_freeer_t - define a key/value destruction callback
* SYNOPSIS * SYNOPSIS
@ -80,7 +80,7 @@ typedef qse_size_t (*qse_map_hasher_t) (
qse_size_t klen /* the length of a key in bytes */ qse_size_t klen /* the length of a key in bytes */
); );
/****t* qse.cmn.map/qse_map_comper_t /****t* Common/qse_map_comper_t
* NAME * NAME
* qse_map_comper_t - define a key comparator * qse_map_comper_t - define a key comparator
* *
@ -103,7 +103,7 @@ typedef int (*qse_map_comper_t) (
); );
/******/ /******/
/****t* qse.cmn.map/qse_map_keeper_t /****t* Common/qse_map_keeper_t
* NAME * NAME
* qse_map_keeper_t - define a value keeper * qse_map_keeper_t - define a value keeper
* *
@ -122,7 +122,7 @@ typedef void (*qse_map_keeper_t) (
); );
/******/ /******/
/****t* qse.cmn.map/qse_map_sizer_t /****t* Common/qse_map_sizer_t
* NAME * NAME
* qse_map_sizer_t - define a bucket size calculator * qse_map_sizer_t - define a bucket size calculator
* *
@ -139,7 +139,7 @@ typedef qse_size_t (*qse_map_sizer_t) (
); );
/******/ /******/
/****t* qse.cmn.map/qse_map_walker_t /****t* Common/qse_map_walker_t
* NAME * NAME
* qse_map_walker_t - define a pair visitor * qse_map_walker_t - define a pair visitor
* *
@ -152,7 +152,7 @@ typedef qse_map_walk_t (*qse_map_walker_t) (
); );
/******/ /******/
/****s* qse.cmn.map/qse_map_pair_t /****s* Common/qse_map_pair_t
* NAME * NAME
* qse_map_pair_t - define a pair * qse_map_pair_t - define a pair
* *
@ -177,7 +177,7 @@ struct qse_map_pair_t
}; };
/*****/ /*****/
/****s* qse.cmn.map/qse_map_t /****s* Common/qse_map_t
* NAME * NAME
* qse_map_t - define a hash map * qse_map_t - define a hash map
* *
@ -206,7 +206,7 @@ struct qse_map_t
#define QSE_MAP_COPIER_SIMPLE ((qse_map_copier_t)1) #define QSE_MAP_COPIER_SIMPLE ((qse_map_copier_t)1)
#define QSE_MAP_COPIER_INLINE ((qse_map_copier_t)2) #define QSE_MAP_COPIER_INLINE ((qse_map_copier_t)2)
/****d* qse.cmn.map/QSE_MAP_SIZE /****d* Common/QSE_MAP_SIZE
* NAME * NAME
* QSE_MAP_SIZE - get the number of pairs * QSE_MAP_SIZE - get the number of pairs
* DESCRIPTION * DESCRIPTION
@ -216,7 +216,7 @@ struct qse_map_t
#define QSE_MAP_SIZE(m) ((m)->size) #define QSE_MAP_SIZE(m) ((m)->size)
/*****/ /*****/
/****d* qse.cmn.map/QSE_MAP_CAPA /****d* Common/QSE_MAP_CAPA
* NAME * NAME
* QSE_MAP_CAPA - get the capacity of a map * QSE_MAP_CAPA - get the capacity of a map
* *
@ -253,7 +253,7 @@ extern "C" {
QSE_DEFINE_COMMON_FUNCTIONS (map) QSE_DEFINE_COMMON_FUNCTIONS (map)
/****f* qse.cmn.map/qse_map_open /****f* Common/qse_map_open
* NAME * NAME
* qse_map_open - creates a hash map * qse_map_open - creates a hash map
* DESCRIPTION * DESCRIPTION
@ -280,7 +280,7 @@ qse_map_t* qse_map_open (
/******/ /******/
/****f* qse.cmn.map/qse_map_close /****f* Common/qse_map_close
* NAME * NAME
* qse_map_close - destroy a hash map * qse_map_close - destroy a hash map
* DESCRIPTION * DESCRIPTION
@ -317,7 +317,7 @@ int qse_map_getscale (
qse_map_id_t id /* QSE_MAP_KEY or QSE_MAP_VAL */ qse_map_id_t id /* QSE_MAP_KEY or QSE_MAP_VAL */
); );
/****f* qse.cmn.map/qse_map_setscale /****f* Common/qse_map_setscale
* NAME * NAME
* qse_map_setscale - set the scale factor * qse_map_setscale - set the scale factor
* *
@ -344,7 +344,7 @@ qse_map_copier_t qse_map_getcopier (
qse_map_id_t id /* QSE_MAP_KEY or QSE_MAP_VAL */ qse_map_id_t id /* QSE_MAP_KEY or QSE_MAP_VAL */
); );
/****f* qse.cmn.map/qse_map_setcopier /****f* Common/qse_map_setcopier
* NAME * NAME
* qse_map_setcopier - specify how to clone an element * qse_map_setcopier - specify how to clone an element
* *
@ -370,7 +370,7 @@ qse_map_freeer_t qse_map_getfreeer (
qse_map_id_t id /* QSE_MAP_KEY or QSE_MAP_VAL */ qse_map_id_t id /* QSE_MAP_KEY or QSE_MAP_VAL */
); );
/****f* qse.cmn.map/qse_map_setfreeer /****f* Common/qse_map_setfreeer
* NAME * NAME
* qse_map_setfreeer - specify how to destroy an element * qse_map_setfreeer - specify how to destroy an element
* *
@ -424,7 +424,7 @@ void qse_map_setsizer (
qse_map_sizer_t sizer qse_map_sizer_t sizer
); );
/****f* qse.cmn.map/qse_map_search /****f* Common/qse_map_search
* NAME * NAME
* qse_map_search - find a pair with a matching key * qse_map_search - find a pair with a matching key
* DESCRIPTION * DESCRIPTION
@ -443,7 +443,7 @@ qse_map_pair_t* qse_map_search (
); );
/******/ /******/
/****f* qse.cmn.map/qse_map_upsert /****f* Common/qse_map_upsert
* NAME * NAME
* qse_map_upsert - update an existing pair or inesrt a new pair * qse_map_upsert - update an existing pair or inesrt a new pair
* DESCRIPTION * DESCRIPTION
@ -465,7 +465,7 @@ qse_map_pair_t* qse_map_upsert (
); );
/******/ /******/
/****f* qse.cmn.map/qse_map_insert /****f* Common/qse_map_insert
* NAME * NAME
* qse_map_insert - insert a new pair with a key and a value * qse_map_insert - insert a new pair with a key and a value
* DESCRIPTION * DESCRIPTION

View File

@ -25,7 +25,7 @@
typedef struct qse_opt_t qse_opt_t; typedef struct qse_opt_t qse_opt_t;
typedef struct qse_opt_lng_t qse_opt_lng_t; typedef struct qse_opt_lng_t qse_opt_lng_t;
/****t* qse.cmn.opt/qse_opt_lng_t /****t* Common/qse_opt_lng_t
* NAME * NAME
* qse_opt_lng_t - define a long option * qse_opt_lng_t - define a long option
* SYNOPSIS * SYNOPSIS
@ -37,7 +37,7 @@ struct qse_opt_lng_t
}; };
/*****/ /*****/
/****t* qse.cmn.opt/qse_opt_t /****t* Common/qse_opt_t
* NAME * NAME
* qse_opt_t - define a command line option table * qse_opt_t - define a command line option table
* SYNOPSIS * SYNOPSIS
@ -67,7 +67,7 @@ struct qse_opt_t
extern "C" { extern "C" {
#endif #endif
/****f* qse.cmn.opt/qse_getopt /****f* Common/qse_getopt
* NAME * NAME
* qse_getopt - process command line options * qse_getopt - process command line options
* DESCRIPTION * DESCRIPTION

View File

@ -101,7 +101,7 @@ struct qse_pio_pin_t
qse_pio_t* self; qse_pio_t* self;
}; };
/****s* cmn/qse_pio_t /****s* Common/qse_pio_t
* NAME * NAME
* qse_pio_t - define an pipe IO type * qse_pio_t - define an pipe IO type
* SYNOPSIS * SYNOPSIS
@ -128,7 +128,7 @@ extern "C" {
QSE_DEFINE_COMMON_FUNCTIONS (pio) QSE_DEFINE_COMMON_FUNCTIONS (pio)
/****f* cmn/qse_pio_open /****f* Common/qse_pio_open
* NAME * NAME
* qse_pio_open - open pipes to a child process * qse_pio_open - open pipes to a child process
* *
@ -146,7 +146,7 @@ qse_pio_t* qse_pio_open (
); );
/******/ /******/
/****f* cmn/qse_pio_close /****f* Common/qse_pio_close
* NAME * NAME
* qse_pio_close - close pipes to a child process * qse_pio_close - close pipes to a child process
* *
@ -157,7 +157,7 @@ void qse_pio_close (
); );
/******/ /******/
/****f* cmn/qse_pio_init /****f* Common/qse_pio_init
* NAME * NAME
* qse_pio_init - initialize pipes to a child process * qse_pio_init - initialize pipes to a child process
* *
@ -171,7 +171,7 @@ qse_pio_t* qse_pio_init (
); );
/******/ /******/
/****f* cmn/qse_pio_fini /****f* Common/qse_pio_fini
* NAME * NAME
* qse_pio_fini - finalize pipes to a child process * qse_pio_fini - finalize pipes to a child process
* *
@ -192,7 +192,7 @@ void qse_pio_setflags (
int op int op
); );
/****f* cmn/qse_pio_geterrnum /****f* Common/qse_pio_geterrnum
* NAME * NAME
* qse_pio_geterrnum - get an error code * qse_pio_geterrnum - get an error code
* *
@ -203,7 +203,7 @@ qse_pio_err_t qse_pio_geterrnum (
); );
/******/ /******/
/****f* cmn/qse_pio_geterrmsg /****f* Common/qse_pio_geterrmsg
* NAME * NAME
* qse_pio_geterrstr - transllate an error code to a string * qse_pio_geterrstr - transllate an error code to a string
* *
@ -218,7 +218,7 @@ const qse_char_t* qse_pio_geterrstr (
); );
/******/ /******/
/****f* cmn/qse_pio_gethandle /****f* Common/qse_pio_gethandle
* NAME * NAME
* qse_pio_gethandle - get native handle * qse_pio_gethandle - get native handle
* *
@ -230,7 +230,7 @@ qse_pio_hnd_t qse_pio_gethandle (
); );
/******/ /******/
/****f* cmn/qse_pio_getchild /****f* Common/qse_pio_getchild
* NAME * NAME
* qse_pio_getchild - get the PID of a child process * qse_pio_getchild - get the PID of a child process
* *
@ -241,7 +241,7 @@ qse_pio_pid_t qse_pio_getchild (
); );
/******/ /******/
/****f* cmn/qse_pio_read /****f* Common/qse_pio_read
* NAME * NAME
* qse_pio_read - read data * qse_pio_read - read data
* SYNOPSIS * SYNOPSIS
@ -254,7 +254,7 @@ qse_ssize_t qse_pio_read (
); );
/******/ /******/
/****f* cmn/qse_pio_write /****f* Common/qse_pio_write
* NAME * NAME
* qse_pio_write - write data * qse_pio_write - write data
* DESCRIPTION * DESCRIPTION
@ -270,7 +270,7 @@ qse_ssize_t qse_pio_write (
); );
/******/ /******/
/****f* cmn/qse_pio_flush /****f* Common/qse_pio_flush
* NAME * NAME
* qse_pio_flush - flush data * qse_pio_flush - flush data
* *
@ -282,7 +282,7 @@ qse_ssize_t qse_pio_flush (
); );
/*****/ /*****/
/****f* cmn/qse_pio_end /****f* Common/qse_pio_end
* NAME * NAME
* qse_pio_end - close native handle * qse_pio_end - close native handle
* *
@ -294,7 +294,7 @@ void qse_pio_end (
); );
/******/ /******/
/****f* cmn/qse_pio_wait /****f* Common/qse_pio_wait
* NAME * NAME
* qse_pio_wait - wait for a child process * qse_pio_wait - wait for a child process
* DESCRIPTION * DESCRIPTION
@ -315,7 +315,7 @@ int qse_pio_wait (
); );
/******/ /******/
/****f* cmn/qse_pio_kill /****f* Common/qse_pio_kill
* NAME * NAME
* qse_pio_kill - terminate the child process * qse_pio_kill - terminate the child process
* NOTES * NOTES

View File

@ -128,7 +128,7 @@ qse_ssize_t qse_sio_putsn (
qse_size_t size qse_size_t size
); );
/****f* qse.cmn.sio/qse_sio_getpos /****f* Common/qse_sio_getpos
* NAME * NAME
* qse_sio_getpos - get the stream position * qse_sio_getpos - get the stream position
* *

View File

@ -22,15 +22,15 @@
#include <qse/types.h> #include <qse/types.h>
#include <qse/macros.h> #include <qse/macros.h>
/****o* qse.cmn.sll/singly linked list /****o* Common/Singly Linked List
* DESCRIPTION * DESCRIPTION
* <qse/cmn/sll.h> provides a singly linked list * <qse/cmn/sll.h> provides a singly linked list.
* *
* #include <qse/cmn/sll.h> * #include <qse/cmn/sll.h>
****** ******
*/ */
/****t* qse.cmn.sll/qse_sll_walk_t /****t* Common/qse_sll_walk_t
* NAME * NAME
* qse_sll_walk_t - define return values for qse_sll_walker_t * qse_sll_walk_t - define return values for qse_sll_walker_t
* SEE ALSO * SEE ALSO
@ -48,7 +48,7 @@ typedef struct qse_sll_t qse_sll_t;
typedef struct qse_sll_node_t qse_sll_node_t; typedef struct qse_sll_node_t qse_sll_node_t;
typedef enum qse_sll_walk_t qse_sll_walk_t; typedef enum qse_sll_walk_t qse_sll_walk_t;
/****b* qse.cmn.sll/qse_sll_copier_t /****t* Common/qse_sll_copier_t
* NAME * NAME
* qse_sll_copier_t - define a node contruction callback * qse_sll_copier_t - define a node contruction callback
* DESCRIPTION * DESCRIPTION
@ -74,7 +74,7 @@ typedef void* (*qse_sll_copier_t) (
); );
/******/ /******/
/****b* qse.cmn.sll/qse_sll_freeer_t /****t* Common/qse_sll_freeer_t
* NAME * NAME
* qse_sll_freeer_t - define a node destruction callback * qse_sll_freeer_t - define a node destruction callback
* SYNOPSIS * SYNOPSIS
@ -86,7 +86,7 @@ typedef void (*qse_sll_freeer_t) (
); );
/******/ /******/
/****t* qse.cmn.sll/qse_sll_comper_t /****t* Common/qse_sll_comper_t
* NAME * NAME
* qse_sll_comper_t - define a data comparator * qse_sll_comper_t - define a data comparator
* *
@ -109,7 +109,7 @@ typedef int (*qse_sll_comper_t) (
); );
/******/ /******/
/****b* qse.cmn.sll/qse_sll_walker_t /****t* Common/qse_sll_walker_t
* NAME * NAME
* qse_sll_walker_t - define a list traversal callback for each node * qse_sll_walker_t - define a list traversal callback for each node
* *
@ -132,7 +132,7 @@ typedef qse_sll_walk_t (*qse_sll_walker_t) (
); );
/******/ /******/
/****s* qse.cmn.sll/qse_sll_t /****s* Common/qse_sll_t
* NAME * NAME
* qse_sll_t - define a singly linked list * qse_sll_t - define a singly linked list
* *
@ -156,7 +156,7 @@ struct qse_sll_t
}; };
/******/ /******/
/****s* cmn/qse_sll_node_t /****s* Common/qse_sll_node_t
* NAME * NAME
* qse_sll_node_t - define a list node * qse_sll_node_t - define a list node
* DESCRIPTION * DESCRIPTION
@ -186,7 +186,7 @@ struct qse_sll_node_t
#define QSE_SLL_SIZE(sll) ((sll)->size) #define QSE_SLL_SIZE(sll) ((sll)->size)
#define QSE_SLL_SCALE(sll) ((sll)->scale) #define QSE_SLL_SCALE(sll) ((sll)->scale)
/****d* cmn/QSE_SLL_DPTR /****d* Common/QSE_SLL_DPTR
* NAME * NAME
* QSE_SLL_DPTR - get the data pointer in a node * QSE_SLL_DPTR - get the data pointer in a node
* SYNOPSIS * SYNOPSIS
@ -194,7 +194,7 @@ struct qse_sll_node_t
#define QSE_SLL_DPTR(node) ((node)->dptr) #define QSE_SLL_DPTR(node) ((node)->dptr)
/******/ /******/
/****d* cmn/QSE_SLL_DLEN /****d* Common/QSE_SLL_DLEN
* NAME * NAME
* QSE_SLL_DLEN - get the length of data in a node * QSE_SLL_DLEN - get the length of data in a node
* SYNOPSIS * SYNOPSIS
@ -202,7 +202,7 @@ struct qse_sll_node_t
#define QSE_SLL_DLEN(node) ((node)->dlen) #define QSE_SLL_DLEN(node) ((node)->dlen)
/******/ /******/
/****d* cmn/QSE_SLL_NEXT /****d* Common/QSE_SLL_NEXT
* NAME * NAME
* QSE_SLL_NEXT - get the next node * QSE_SLL_NEXT - get the next node
* SYNOPSIS * SYNOPSIS
@ -216,7 +216,7 @@ extern "C" {
QSE_DEFINE_COMMON_FUNCTIONS (sll) QSE_DEFINE_COMMON_FUNCTIONS (sll)
/****f* qse.cmn.sll/qse_sll_open /****f* Common/qse_sll_open
* NAME * NAME
* qse_sll_open - create a singly linked list with extension area * qse_sll_open - create a singly linked list with extension area
* *
@ -246,7 +246,7 @@ qse_sll_t* qse_sll_open (
); );
/******/ /******/
/****f* qse.cmn.sll/qse_sll_close /****f* Common/qse_sll_close
* NAME * NAME
* qse_sll_close - destroy a singly linked list * qse_sll_close - destroy a singly linked list
* *
@ -261,7 +261,7 @@ void qse_sll_close (
); );
/******/ /******/
/****f* qse.cmn.sll/qse_sll_init /****f* Common/qse_sll_init
* NAME * NAME
* qse_sll_init - initialize a singly linked list * qse_sll_init - initialize a singly linked list
* *
@ -283,7 +283,7 @@ qse_sll_t* qse_sll_init (
); );
/******/ /******/
/****f* qse.cmn.sll/qse_sll_fini /****f* Common/qse_sll_fini
* NAME * NAME
* qse_sll_init - deinitialize a singly linked list * qse_sll_init - deinitialize a singly linked list
* *
@ -294,7 +294,7 @@ void qse_sll_fini (
); );
/******/ /******/
/****f* qse.cmn.sll/qse_sll_getsize /****f* Common/qse_sll_getsize
* NAME * NAME
* qse_sll_getsize - get the number of nodes * qse_sll_getsize - get the number of nodes
* *
@ -310,7 +310,7 @@ qse_size_t qse_sll_getsize (
/******/ /******/
/****f* qse.cmn.sll/qse_sll_getscale /****f* Common/qse_sll_getscale
* NAME * NAME
* qse_sll_getscale - get the scale factor * qse_sll_getscale - get the scale factor
* *
@ -321,7 +321,7 @@ int qse_sll_getscale (
); );
/******/ /******/
/****f* qse.cmn.sll/qse_sll_setscale /****f* Common/qse_sll_setscale
* NAME * NAME
* qse_sll_setscale - set the scale factor * qse_sll_setscale - set the scale factor
* *
@ -342,7 +342,7 @@ void qse_sll_setscale (
); );
/******/ /******/
/****f* qse.cmn.sll/qse_sll_getcopier /****f* Common/qse_sll_getcopier
* NAME * NAME
* qse_sll_getfreeer - get the data copier * qse_sll_getfreeer - get the data copier
* *
@ -353,7 +353,7 @@ qse_sll_copier_t qse_sll_getcopier (
); );
/******/ /******/
/****f* qse.cmn.sll/qse_sll_setcopier /****f* Common/qse_sll_setcopier
* NAME * NAME
* qse_sll_setcopier - set a data copier * qse_sll_setcopier - set a data copier
* *
@ -373,7 +373,7 @@ void qse_sll_setcopier (
); );
/******/ /******/
/****f* qse.cmn.sll/qse_sll_getfreeer /****f* Common/qse_sll_getfreeer
* NAME * NAME
* qse_sll_getfreeer - get the data freeer * qse_sll_getfreeer - get the data freeer
* *
@ -384,7 +384,7 @@ qse_sll_freeer_t qse_sll_getfreeer (
); );
/******/ /******/
/****f* qse.cmn.sll/qse_sll_setfreeer /****f* Common/qse_sll_setfreeer
* NAME * NAME
* qse_sll_setfreeer - set a data freeer * qse_sll_setfreeer - set a data freeer
* *
@ -399,7 +399,7 @@ void qse_sll_setfreeer (
); );
/******/ /******/
/****f* qse.cmn.sll/qse_sll_getcomper /****f* Common/qse_sll_getcomper
* NAME * NAME
* qse_sll_getcomper - get the data comparator * qse_sll_getcomper - get the data comparator
* *
@ -410,7 +410,7 @@ qse_sll_comper_t qse_sll_getcomper (
); );
/******/ /******/
/****f* qse.cmn.sll/qse_sll_setcomper /****f* Common/qse_sll_setcomper
* NAME * NAME
* qse_sll_setcomper - set the data comparator * qse_sll_setcomper - set the data comparator
* *
@ -422,7 +422,7 @@ void qse_sll_setcomper (
); );
/******/ /******/
/****f* qse.cmn.sll/qse_sll_gethead /****f* Common/qse_sll_gethead
* NAME * NAME
* qse_sll_gethead - get the head node * qse_sll_gethead - get the head node
* *
@ -433,7 +433,7 @@ qse_sll_node_t* qse_sll_gethead (
); );
/******/ /******/
/****f* qse.cmn.sll/qse_sll_gettail /****f* Common/qse_sll_gettail
* NAME * NAME
* qse_sll_gettail - get the tail node * qse_sll_gettail - get the tail node
* *
@ -444,7 +444,7 @@ qse_sll_node_t* qse_sll_gettail (
); );
/******/ /******/
/****f* qse.cmn.sll/qse_sll_search /****f* Common/qse_sll_search
* NAME * NAME
* qse_sll_search - find a node * qse_sll_search - find a node
* *
@ -471,7 +471,7 @@ qse_sll_node_t* qse_sll_search (
); );
/******/ /******/
/****f* qse.cmn.sll/qse_sll_insert /****f* Common/qse_sll_insert
* NAME * NAME
* qse_sll_insert - insert data to a new node * qse_sll_insert - insert data to a new node
* *
@ -494,7 +494,7 @@ qse_sll_node_t* qse_sll_insert (
); );
/******/ /******/
/****f* qse.cmn.sll/qse_sll_delete /****f* Common/qse_sll_delete
* NAME * NAME
* qse_sll_delete - delete a node * qse_sll_delete - delete a node
* *
@ -509,7 +509,7 @@ void qse_sll_delete (
); );
/******/ /******/
/****f* qse.cmn.sll/qse_sll_clear /****f* Common/qse_sll_clear
* NAME * NAME
* qse_sll_clear - delete all nodes * qse_sll_clear - delete all nodes
* *
@ -545,7 +545,7 @@ void qse_sll_poptail (
qse_sll_t* sll qse_sll_t* sll
); );
/****f* qse.cmn.sll/qse_sll_walk /****f* Common/qse_sll_walk
* NAME * NAME
* qse_sll_walk - traverse s singly linked list * qse_sll_walk - traverse s singly linked list
* *

View File

@ -22,7 +22,7 @@
#include <qse/types.h> #include <qse/types.h>
#include <qse/macros.h> #include <qse/macros.h>
/****o* cmn/string /****o* Common/String
* DESCRIPTION * DESCRIPTION
* <qse/cmn/str.h> defines various functions, types, macros to manipulate * <qse/cmn/str.h> defines various functions, types, macros to manipulate
* strings. * strings.
@ -34,7 +34,6 @@
****** ******
*/ */
#define QSE_STR_LEN(s) ((s)->len) #define QSE_STR_LEN(s) ((s)->len)
#define QSE_STR_PTR(s) ((s)->ptr) #define QSE_STR_PTR(s) ((s)->ptr)
#define QSE_STR_CAPA(s) ((s)->capa) #define QSE_STR_CAPA(s) ((s)->capa)
@ -44,7 +43,7 @@
typedef struct qse_str_t qse_str_t; typedef struct qse_str_t qse_str_t;
typedef qse_size_t (*qse_str_sizer_t) (qse_str_t* data, qse_size_t hint); typedef qse_size_t (*qse_str_sizer_t) (qse_str_t* data, qse_size_t hint);
/****s* cmn/qse_str_t /****s* Common/qse_str_t
* NAME * NAME
* qse_str_t - define a dynamically resizable string * qse_str_t - define a dynamically resizable string
* SYNOPSIS * SYNOPSIS
@ -143,7 +142,7 @@ int qse_strxncmp (
int qse_strcasecmp ( int qse_strcasecmp (
const qse_char_t* s1, const qse_char_t* s2, qse_ccls_t* ccls); const qse_char_t* s1, const qse_char_t* s2, qse_ccls_t* ccls);
/****f* cmn/qse_strxncasecmp /****f* Common/qse_strxncasecmp
* NAME * NAME
* qse_strxncasecmp - compare strings ignoring case * qse_strxncasecmp - compare strings ignoring case
* DESCRIPTION * DESCRIPTION
@ -260,7 +259,7 @@ void qse_str_fini (
qse_str_t* str qse_str_t* str
); );
/****f* cmn/qse_str_yield /****f* Common/qse_str_yield
* NAME * NAME
* qse_str_yield - yield the buffer * qse_str_yield - yield the buffer
* *
@ -281,7 +280,7 @@ int qse_str_yield (
); );
/******/ /******/
/****f* cmn/qse_str_getsizer /****f* Common/qse_str_getsizer
* NAME * NAME
* qse_str_getsizer - get the sizer * qse_str_getsizer - get the sizer
* RETURN * RETURN
@ -292,7 +291,7 @@ qse_str_sizer_t qse_str_getsizer (
); );
/******/ /******/
/****f* cmn/qse_str_setsizer /****f* Common/qse_str_setsizer
* NAME * NAME
* qse_str_setsizer - specify a sizer * qse_str_setsizer - specify a sizer
* DESCRIPTION * DESCRIPTION
@ -380,7 +379,7 @@ qse_size_t qse_str_nccat (
qse_size_t len qse_size_t len
); );
/****f* cmn/qse_strspl /****f* Common/qse_strspl
* NAME * NAME
* qse_strspl - split a string * qse_strspl - split a string
* SYNOPSIS * SYNOPSIS
@ -394,7 +393,7 @@ int qse_strspl (
); );
/******/ /******/
/****f* cmn/qse_mbstowcs /****f* Common/qse_mbstowcs
* NAME * NAME
* qse_mbstowcs - convert a multibyte string to a wide character string * qse_mbstowcs - convert a multibyte string to a wide character string
* SYNOPSIS * SYNOPSIS
@ -406,7 +405,7 @@ qse_size_t qse_mbstowcs (
); );
/******/ /******/
/****f* cmn/qse_mbsntowcsn /****f* Common/qse_mbsntowcsn
* NAME * NAME
* qse_mbsntowcsn - convert a multibyte string to a wide character string * qse_mbsntowcsn - convert a multibyte string to a wide character string
* RETURN * RETURN
@ -421,7 +420,7 @@ qse_size_t qse_mbsntowcsn (
); );
/******/ /******/
/****f* cmn/qse_wcstombslen /****f* Common/qse_wcstombslen
* NAME * NAME
* qse_wcstombslen - get the length * qse_wcstombslen - get the length
* DESCRIPTION * DESCRIPTION
@ -440,7 +439,7 @@ qse_size_t qse_wcstombslen (
); );
/******/ /******/
/****f* cmn/qse_wcsntombsnlen /****f* Common/qse_wcsntombsnlen
* NAME * NAME
* qse_wcsntombsnlen - get the length * qse_wcsntombsnlen - get the length
* DESCRIPTION * DESCRIPTION
@ -460,7 +459,7 @@ qse_size_t qse_wcsntombsnlen (
); );
/******/ /******/
/****f* cmn/qse_wcstombs /****f* Common/qse_wcstombs
* NAME * NAME
* qse_wcstombs - convert a wide character string to a multibyte string. * qse_wcstombs - convert a wide character string to a multibyte string.
* DESCRIPTION * DESCRIPTION
@ -483,7 +482,7 @@ qse_size_t qse_wcstombs (
); );
/******/ /******/
/****f* cmn/qse_wcsntombsn /****f* Common/qse_wcsntombsn
* NAME * NAME
* qse_wcstombs - convert a wide character string to a multibyte string * qse_wcstombs - convert a wide character string to a multibyte string
* RETURN * RETURN
@ -498,7 +497,7 @@ qse_size_t qse_wcsntombsn (
); );
/******/ /******/
/****f* cmn/qse_wcstombs_strict /****f* Common/qse_wcstombs_strict
* NAME * NAME
* qse_wcstombs_strict - convert a wide character string to a multibyte string. * qse_wcstombs_strict - convert a wide character string to a multibyte string.
* DESCRIPTION * DESCRIPTION

View File

@ -72,7 +72,7 @@ struct qse_btime_t
extern "C" { extern "C" {
#endif #endif
/****f* qse.cmn.time/qse_gettime /****f* Common/qse_gettime
* NAME * NAME
* qse_gettime - get the current time * qse_gettime - get the current time
* SYNPOSIS * SYNPOSIS
@ -82,7 +82,7 @@ int qse_gettime (
); );
/******/ /******/
/****f* qse.cmn.time/qse_settime /****f* Common/qse_settime
* NAME * NAME
* qse_settime - set the current time * qse_settime - set the current time
* SYNOPSIS * SYNOPSIS
@ -93,7 +93,7 @@ int qse_settime (
/******/ /******/
/****f* qse.cmn.time/qse_gmtime /****f* Common/qse_gmtime
* NAME * NAME
* qse_gmtime - convert numeric time to broken-down time * qse_gmtime - convert numeric time to broken-down time
* SYNOPSIS * SYNOPSIS
@ -104,7 +104,7 @@ int qse_gmtime (
); );
/******/ /******/
/****f* qse.cmn.time/qse_localtime /****f* Common/qse_localtime
* NAME * NAME
* qse_localtime - convert numeric time to broken-down time * qse_localtime - convert numeric time to broken-down time
* SYNOPSIS * SYNOPSIS
@ -115,7 +115,7 @@ int qse_localtime (
); );
/******/ /******/
/****f* qse.cmn.time/qse_timegm /****f* Common/qse_timegm
* NAME * NAME
* qse_timegm - convert broken-down time to numeric time * qse_timegm - convert broken-down time to numeric time
* *
@ -127,7 +127,7 @@ int qse_timegm (
); );
/******/ /******/
/****f* qse.cmn.time/qse_timelocal /****f* Common/qse_timelocal
* NAME * NAME
* qse_timelocal - convert broken-down time to numeric time * qse_timelocal - convert broken-down time to numeric time
* *
@ -139,7 +139,7 @@ int qse_timelcoal (
); );
/******/ /******/
/****f* qse.cmn.time/qse_strftime /****f* Common/qse_strftime
* NAME * NAME
* qse_strftime - format time * qse_strftime - format time
* *

View File

@ -64,7 +64,7 @@ enum
typedef struct qse_tio_t qse_tio_t; typedef struct qse_tio_t qse_tio_t;
/****t* cmn/qse_tio_io_t /****t* Common/qse_tio_io_t
* NAME * NAME
* qse_tio_io_t - define a text IO handler type * qse_tio_io_t - define a text IO handler type
* SYNOPSIS * SYNOPSIS
@ -77,7 +77,7 @@ typedef qse_ssize_t (*qse_tio_io_t) (
); );
/******/ /******/
/****s* cmn/qse_tio_t /****s* Common/qse_tio_t
* NAME * NAME
* qse_tio_t - define a text IO type * qse_tio_t - define a text IO type
* DESCRIPTION * DESCRIPTION
@ -114,7 +114,7 @@ extern "C" {
QSE_DEFINE_COMMON_FUNCTIONS (tio) QSE_DEFINE_COMMON_FUNCTIONS (tio)
/****f* cmn/qse_tio_open /****f* Common/qse_tio_open
* NAME * NAME
* qse_tio_open - create an text IO processor * qse_tio_open - create an text IO processor
* SYNOPSIS * SYNOPSIS
@ -125,7 +125,7 @@ qse_tio_t* qse_tio_open (
); );
/******/ /******/
/****f* cmn/qse_tio_close /****f* Common/qse_tio_close
* NAME * NAME
* qse_tio_close - destroy an text IO processor * qse_tio_close - destroy an text IO processor
* SYNOPSIS * SYNOPSIS
@ -135,7 +135,7 @@ int qse_tio_close (
); );
/******/ /******/
/****f* cmn/qse_tio_init /****f* Common/qse_tio_init
* NAME * NAME
* qse_tio_init - initialize an text IO processor * qse_tio_init - initialize an text IO processor
* SYNOPSIS * SYNOPSIS
@ -146,7 +146,7 @@ qse_tio_t* qse_tio_init (
); );
/******/ /******/
/****f* cmn/qse_tio_fini /****f* Common/qse_tio_fini
* NAME * NAME
* qse_tio_fini - finalize an text IO processor * qse_tio_fini - finalize an text IO processor
* SYNOPSIS * SYNOPSIS
@ -156,7 +156,7 @@ int qse_tio_fini (
); );
/******/ /******/
/****f* cmn/qse_tio_geterrnum /****f* Common/qse_tio_geterrnum
* NAME * NAME
* qse_tio_geterrnum - get an error code * qse_tio_geterrnum - get an error code
* *
@ -167,7 +167,7 @@ qse_tio_err_t qse_tio_geterrnum (
); );
/******/ /******/
/****f* cmn/qse_tio_geterrmsg /****f* Common/qse_tio_geterrmsg
* NAME * NAME
* qse_tio_geterrmsg - translate an error code to a string * qse_tio_geterrmsg - translate an error code to a string
* RETURN * RETURN
@ -178,7 +178,7 @@ const qse_char_t* qse_tio_geterrmsg (
); );
/******/ /******/
/****f* cmn/qse_tio_attachin /****f* Common/qse_tio_attachin
* NAME * NAME
* qse_tio_attachin - attaches an input handler * qse_tio_attachin - attaches an input handler
* RETURN * RETURN
@ -192,7 +192,7 @@ int qse_tio_attachin (
); );
/******/ /******/
/****f* cmn/qse_tio_detachin /****f* Common/qse_tio_detachin
* NAME * NAME
* qse_tio_detachin - detach an input handler * qse_tio_detachin - detach an input handler
* RETURN * RETURN
@ -204,7 +204,7 @@ int qse_tio_detachin (
); );
/******/ /******/
/****f* cmn/qse_tio_attachout /****f* Common/qse_tio_attachout
* NAME * NAME
* qse_tio_attachout - attaches an output handler * qse_tio_attachout - attaches an output handler
* RETURN * RETURN
@ -218,7 +218,7 @@ int qse_tio_attachout (
); );
/******/ /******/
/****f* cmn/qse_tio_detachout /****f* Common/qse_tio_detachout
* NAME * NAME
* qse_tio_detachout - detaches an output handler * qse_tio_detachout - detaches an output handler
* RETURN * RETURN
@ -230,7 +230,7 @@ int qse_tio_detachout (
); );
/******/ /******/
/****f* cmn/qse_tio_flush /****f* Common/qse_tio_flush
* NAME * NAME
* qse_tio_flush - flush the output buffer * qse_tio_flush - flush the output buffer
* RETURNS * RETURNS
@ -243,7 +243,7 @@ qse_ssize_t qse_tio_flush (
); );
/******/ /******/
/****f* cmn/qse_tio_purge /****f* Common/qse_tio_purge
* NAME * NAME
* qse_tio_purge - empty input and output buffers * qse_tio_purge - empty input and output buffers
* SYNOPSIS * SYNOPSIS
@ -253,7 +253,7 @@ void qse_tio_purge (
); );
/******/ /******/
/****f* cmn/qse_tio_read /****f* Common/qse_tio_read
* NAME * NAME
* qse_tio_read - read text * qse_tio_read - read text
* SYNOPSIS * SYNOPSIS
@ -265,7 +265,7 @@ qse_ssize_t qse_tio_read (
); );
/******/ /******/
/****f* cmn/qse_tio_write /****f* Common/qse_tio_write
* NAME * NAME
* qse_tio_write - write text * qse_tio_write - write text
* DESCRIPTION * DESCRIPTION

View File

@ -16,27 +16,10 @@
# define QSE_NULL ((void*)0) # define QSE_NULL ((void*)0)
#endif #endif
/****d* qse/QSE_TRUE,qse/QSE_FALSE
* NAME /*#define QSE_TRUE (0 == 0)
* QSE_TRUE - represent a boolean true
* QSE_FALSE - represent a boolean false
******
*/
#define QSE_TRUE (0 == 0)
#define QSE_FALSE (0 != 0) #define QSE_FALSE (0 != 0)
*/
/****d* qse/QSE_ALIVE,qse/QSE_ZOMBIE,qse/QSE_DEAD
* NAME
* QSE_ALIVE - represent a living state
* QSE_ZOMBIE - represent a zombie state
* QSE_DEAD - represent a dead state
******
*/
#define QSE_ALIVE 1
#define QSE_ZOMBIE 0
#define QSE_DEAD -1
#define QSE_MCHAR_EOF ((qse_mcint_t)-1) #define QSE_MCHAR_EOF ((qse_mcint_t)-1)
#define QSE_WCHAR_EOF ((qse_wcint_t)-1) #define QSE_WCHAR_EOF ((qse_wcint_t)-1)
@ -157,7 +140,7 @@
# define QSE_END_NAMESPACE2(y,x) }} # define QSE_END_NAMESPACE2(y,x) }}
#endif #endif
/****d* qse/QSE_DEFINE_COMMON_FIELDS /****d* Base/QSE_DEFINE_COMMON_FIELDS
* NAME * NAME
* QSE_DEFINE_COMMON_FIELDS - define common fields * QSE_DEFINE_COMMON_FIELDS - define common fields
* SYNOPSIS * SYNOPSIS
@ -166,7 +149,7 @@
qse_mmgr_t* mmgr; qse_mmgr_t* mmgr;
/******/ /******/
/****d* qse/QSE_DEFINE_COMMON_FUNCTIONS /****d* Base/QSE_DEFINE_COMMON_FUNCTIONS
* NAME * NAME
* QSE_DEFINE_COMMON_FUNCTIONS - define common functions * QSE_DEFINE_COMMON_FUNCTIONS - define common functions
* SYNOPSIS * SYNOPSIS
@ -177,7 +160,7 @@ qse_mmgr_t* qse_##name##_getmmgr (qse_##name##_t* name); \
void* qse_##name##_getxtn (qse_##name##_t* name); void* qse_##name##_getxtn (qse_##name##_t* name);
/******/ /******/
/****d* qse/QSE_IMPLEMENT_COMMON_FUNCTIONS /****d* Base/QSE_IMPLEMENT_COMMON_FUNCTIONS
* NAME * NAME
* QSE_IMPLEMENT_COMMON_FUNCTIONS - implement common functions * QSE_IMPLEMENT_COMMON_FUNCTIONS - implement common functions
* SYNOPSIS * SYNOPSIS

View File

@ -7,7 +7,7 @@
#ifndef _QSE_TYPES_H_ #ifndef _QSE_TYPES_H_
#define _QSE_TYPES_H_ #define _QSE_TYPES_H_
/****o* qse/basic types /****o* Base/Basic Types
* DESCRIPTION * DESCRIPTION
* <qse/types.h> defines various common basic types. They are designed to be * <qse/types.h> defines various common basic types. They are designed to be
* cross-platform. These types are preferred over native data types in many * cross-platform. These types are preferred over native data types in many
@ -30,27 +30,40 @@
# error unsupported operating system # error unsupported operating system
#endif #endif
/****t* qse/qse_bool_t /****t* Base/qse_bool_t
* NAME * NAME
* qse_bool_t - define a boolean type * qse_bool_t - define a boolean type
* DESCRIPTION * DESCRIPTION
* The qse_bool_t type defines a boolean type that can represent QSE_TRUE * The qse_bool_t type defines a boolean type that can represent QSE_TRUE
* and QSE_FALSE. * and QSE_FALSE.
****** * SYNOPSIS
*/ */
typedef int qse_bool_t; enum qse_bool_t
{
QSE_TRUE = (0 == 0),
QSE_FALSE = (0 != 0)
};
/******/
typedef enum qse_bool_t qse_bool_t;
/****t* qse/qse_tri_t /****t* Base/qse_tri_t
* NAME * NAME
* qse_tri_t - define a tri-state type * qse_tri_t - define a tri-state type
* DESCRIPTION * DESCRIPTION
* The qse_tri_t type defines a tri-state type that can represent QSE_ALIVE, * The qse_tri_t type defines a tri-state type that can represent QSE_ALIVE,
* QSE_ZOMBIE, and QSE_DEAD. * QSE_ZOMBIE, and QSE_DEAD.
****** * SYNOPSIS
*/ */
typedef int qse_tri_t; enum qse_tri_t
{
QSE_ALIVE = 1,
QSE_ZOMBIE = 0,
QSE_DEAD = -1
};
/******/
typedef enum qse_tri_t qse_tri_t;
/****t* qse/qse_int_t,qse/qse_uint_t /****t* Base/qse_int_t,Base/qse_uint_t
* NAME * NAME
* qse_int_t - define a signed integer type as large as a pointer type * qse_int_t - define a signed integer type as large as a pointer type
* qse_uint_t - define an unsigned integer type as large as a pointer type * qse_uint_t - define an unsigned integer type as large as a pointer type
@ -82,7 +95,7 @@ typedef int qse_tri_t;
# error unsupported pointer size # error unsupported pointer size
#endif #endif
/****t* qse/qse_long_t,qse/qse_ulong_t /****t* Base/qse_long_t,Base/qse_ulong_t
* NAME * NAME
* qse_long_t - define the largest signed integer type supported * qse_long_t - define the largest signed integer type supported
* qse_ulong_t - define the largest unsigned integer type supported * qse_ulong_t - define the largest unsigned integer type supported
@ -99,7 +112,7 @@ typedef int qse_tri_t;
typedef unsigned long qse_ulong_t; typedef unsigned long qse_ulong_t;
#endif #endif
/****t* qse/qse_int8_t,qse/qse_uint8_t /****t* Base/qse_int8_t,Base/qse_uint8_t
* NAME * NAME
* qse_int8_t - define an 8-bit signed integer type * qse_int8_t - define an 8-bit signed integer type
* qse_uint8_t - define an 8-bit unsigned integer type * qse_uint8_t - define an 8-bit unsigned integer type
@ -113,7 +126,7 @@ typedef int qse_tri_t;
typedef unsigned __int8 qse_uint8_t; typedef unsigned __int8 qse_uint8_t;
#endif #endif
/****t* qse/qse_int16_t,qse/qse_uint16_t /****t* Base/qse_int16_t,Base/qse_uint16_t
* NAME * NAME
* qse_int16_t - define a 16-bit signed integer type * qse_int16_t - define a 16-bit signed integer type
* qse_uint16_t - define a 16-bit unsigned integer type * qse_uint16_t - define a 16-bit unsigned integer type
@ -127,7 +140,7 @@ typedef int qse_tri_t;
typedef unsigned __int16 qse_uint16_t; typedef unsigned __int16 qse_uint16_t;
#endif #endif
/****t* qse/qse_int32_t,qse/qse_uint32_t /****t* Base/qse_int32_t,Base/qse_uint32_t
* NAME * NAME
* qse_int32_t - define a 32-bit signed integer type * qse_int32_t - define a 32-bit signed integer type
* qse_uint32_t - define a 32-bit unsigned integer type * qse_uint32_t - define a 32-bit unsigned integer type
@ -144,7 +157,7 @@ typedef int qse_tri_t;
typedef unsigned __int32 qse_uint32_t; typedef unsigned __int32 qse_uint32_t;
#endif #endif
/****t* qse/qse_int64_t,qse/qse_uint64_t /****t* Base/qse_int64_t,Base/qse_uint64_t
* NAME * NAME
* qse_int64_t - define a 64-bit signed integer type * qse_int64_t - define a 64-bit signed integer type
* qse_uint64_t - define a 64-bit unsigned integer type * qse_uint64_t - define a 64-bit unsigned integer type
@ -194,14 +207,14 @@ typedef int qse_tri_t;
typedef unsigned __int128 qse_uint128_t; typedef unsigned __int128 qse_uint128_t;
#endif #endif
/****t* qse/qse_byte_t /****t* Base/qse_byte_t
* NAME * NAME
* qse_byte_t - define a byte type * qse_byte_t - define a byte type
****** ******
*/ */
typedef qse_uint8_t qse_byte_t; typedef qse_uint8_t qse_byte_t;
/****t* qse/qse_size_t /****t* Base/qse_size_t
* NAME * NAME
* qse_size_t - define an unsigned integer type that can hold a pointer value * qse_size_t - define an unsigned integer type that can hold a pointer value
****** ******
@ -212,14 +225,14 @@ typedef qse_uint8_t qse_byte_t;
typedef qse_uint_t qse_size_t; typedef qse_uint_t qse_size_t;
#endif #endif
/****t* qse/qse_ssize_t /****t* Base/qse_ssize_t
* NAME * NAME
* qse_ssize_t - define an signed integer type that can hold a pointer value * qse_ssize_t - define an signed integer type that can hold a pointer value
****** ******
*/ */
typedef qse_int_t qse_ssize_t; typedef qse_int_t qse_ssize_t;
/****t* qse/qse_word_t /****t* Base/qse_word_t
* NAME * NAME
* qse_word_t - define an integer type identical to qse_uint_t * qse_word_t - define an integer type identical to qse_uint_t
****** ******
@ -240,7 +253,7 @@ typedef qse_uint_t qse_word_t;
typedef double qse_real_t; typedef double qse_real_t;
#endif #endif
/****t* qse/qse_mchar_t,qse/qse_mcint_t /****t* Base/qse_mchar_t,Base/qse_mcint_t
* NAME * NAME
* qse_mchar_t - define a multi-byte character * qse_mchar_t - define a multi-byte character
* qse_mcint_t - define a type that can hold qse_mchar_t and QSE_MCHAR_EOF * qse_mcint_t - define a type that can hold qse_mchar_t and QSE_MCHAR_EOF
@ -249,7 +262,7 @@ typedef qse_uint_t qse_word_t;
typedef char qse_mchar_t; typedef char qse_mchar_t;
typedef int qse_mcint_t; typedef int qse_mcint_t;
/****t* qse/qse_wchar_t,qse/qse_wcint_t /****t* Base/qse_wchar_t,Base/qse_wcint_t
* NAME * NAME
* qse_wchar_t - define a wide character * qse_wchar_t - define a wide character
* qse_wcint_t - define a type that can hold qse_wchar_t and QSE_WCHAR_EOF * qse_wcint_t - define a type that can hold qse_wchar_t and QSE_WCHAR_EOF
@ -308,7 +321,7 @@ typedef int qse_mcint_t;
# error unsupported size of wchar_t # error unsupported size of wchar_t
#endif #endif
/****t* qse/qse_char_t,qse/qse_cint_t /****t* Base/qse_char_t,Base/qse_cint_t
* NAME * NAME
* qse_char_t - define a character * qse_char_t - define a character
* qse_cint_t - define a type that can hold qse_char_t and QSE_CHAR_EOF * qse_cint_t - define a type that can hold qse_char_t and QSE_CHAR_EOF
@ -350,7 +363,7 @@ typedef struct qse_cstr_t qse_cstr_t;
typedef struct qse_mmgr_t qse_mmgr_t; typedef struct qse_mmgr_t qse_mmgr_t;
typedef struct qse_ccls_t qse_ccls_t; typedef struct qse_ccls_t qse_ccls_t;
/****t* qse/qse_xstr_t /****t* Base/qse_xstr_t
* NAME * NAME
* qse_xstr_t - combine a pointer and length * qse_xstr_t - combine a pointer and length
* SYNOPSIS * SYNOPSIS
@ -362,7 +375,7 @@ struct qse_xstr_t
}; };
/******/ /******/
/****t* qse/qse_cstr_t /****t* Base/qse_cstr_t
* NAME * NAME
* qse_cstr_t - combine a constant pointer and length * qse_cstr_t - combine a constant pointer and length
* SYNOPSIS * SYNOPSIS
@ -374,7 +387,7 @@ struct qse_cstr_t
}; };
/******/ /******/
/****t* qse/qse_mmgr_t /****t* Base/qse_mmgr_t
* NAME * NAME
* qse_mmgr_t - define a memory manager * qse_mmgr_t - define a memory manager
* SYNOPSIS * SYNOPSIS
@ -388,7 +401,7 @@ struct qse_mmgr_t
}; };
/******/ /******/
/****t* qse/qse_ccls_type_t /****t* Base/qse_ccls_type_t
* NAME * NAME
* qse_ccls_type_t - define character class types * qse_ccls_type_t - define character class types
* SYNOPSIS * SYNOPSIS
@ -411,7 +424,7 @@ enum qse_ccls_type_t
typedef enum qse_ccls_type_t qse_ccls_type_t; typedef enum qse_ccls_type_t qse_ccls_type_t;
/****t* qse/qse_ccls_t /****t* Base/qse_ccls_t
* NAME * NAME
* qse_mmgr_t - define a character classifier * qse_mmgr_t - define a character classifier
* SYNOPSIS * SYNOPSIS

View File

@ -160,7 +160,7 @@ int Awk::Console::setFNR (long_t fnr)
if (tmp == QSE_NULL) return -1; if (tmp == QSE_NULL) return -1;
qse_awk_rtx_refupval (eio->rtx, tmp); qse_awk_rtx_refupval (eio->rtx, tmp);
n = qse_awk_rtx_setglobal (eio->rtx, QSE_AWK_GLOBAL_FNR, tmp); n = qse_awk_rtx_setgbl (eio->rtx, QSE_AWK_GBL_FNR, tmp);
qse_awk_rtx_refdownval (eio->rtx, tmp); qse_awk_rtx_refdownval (eio->rtx, tmp);
return n; return n;
@ -998,7 +998,7 @@ int Awk::Run::setGlobal (int id, long_t v)
if (tmp == QSE_NULL) return -1; if (tmp == QSE_NULL) return -1;
qse_awk_rtx_refupval (run, tmp); qse_awk_rtx_refupval (run, tmp);
int n = qse_awk_rtx_setglobal (this->run, id, tmp); int n = qse_awk_rtx_setgbl (this->run, id, tmp);
qse_awk_rtx_refdownval (run, tmp); qse_awk_rtx_refdownval (run, tmp);
return n; return n;
} }
@ -1011,7 +1011,7 @@ int Awk::Run::setGlobal (int id, real_t v)
if (tmp == QSE_NULL) return -1; if (tmp == QSE_NULL) return -1;
qse_awk_rtx_refupval (run, tmp); qse_awk_rtx_refupval (run, tmp);
int n = qse_awk_rtx_setglobal (this->run, id, tmp); int n = qse_awk_rtx_setgbl (this->run, id, tmp);
qse_awk_rtx_refdownval (run, tmp); qse_awk_rtx_refdownval (run, tmp);
return n; return n;
} }
@ -1024,24 +1024,24 @@ int Awk::Run::setGlobal (int id, const char_t* ptr, size_t len)
if (tmp == QSE_NULL) return -1; if (tmp == QSE_NULL) return -1;
qse_awk_rtx_refupval (run, tmp); qse_awk_rtx_refupval (run, tmp);
int n = qse_awk_rtx_setglobal (this->run, id, tmp); int n = qse_awk_rtx_setgbl (this->run, id, tmp);
qse_awk_rtx_refdownval (run, tmp); qse_awk_rtx_refdownval (run, tmp);
return n; return n;
} }
int Awk::Run::setGlobal (int id, const Return& global) int Awk::Run::setGlobal (int id, const Return& gbl)
{ {
QSE_ASSERT (this->run != QSE_NULL); QSE_ASSERT (this->run != QSE_NULL);
return qse_awk_rtx_setglobal (this->run, id, global.toVal()); return qse_awk_rtx_setgbl (this->run, id, gbl.toVal());
} }
int Awk::Run::getGlobal (int id, Argument& global) const int Awk::Run::getGlobal (int id, Argument& gbl) const
{ {
QSE_ASSERT (this->run != QSE_NULL); QSE_ASSERT (this->run != QSE_NULL);
global.clear (); gbl.clear ();
return global.init (qse_awk_rtx_getglobal(this->run,id)); return gbl.init (qse_awk_rtx_getgbl(this->run,id));
} }
void Awk::Run::setData (void* data) void Awk::Run::setData (void* data)
@ -1468,7 +1468,7 @@ int Awk::addGlobal (const char_t* name)
{ {
QSE_ASSERT (awk != QSE_NULL); QSE_ASSERT (awk != QSE_NULL);
int n = qse_awk_addglobal (awk, name, qse_strlen(name)); int n = qse_awk_addgbl (awk, name, qse_strlen(name));
if (n == -1) retrieveError (); if (n == -1) retrieveError ();
return n; return n;
} }
@ -1476,7 +1476,7 @@ int Awk::addGlobal (const char_t* name)
int Awk::deleteGlobal (const char_t* name) int Awk::deleteGlobal (const char_t* name)
{ {
QSE_ASSERT (awk != QSE_NULL); QSE_ASSERT (awk != QSE_NULL);
int n = qse_awk_delglobal (awk, name, qse_strlen(name)); int n = qse_awk_delgbl (awk, name, qse_strlen(name));
if (n == -1) retrieveError (); if (n == -1) retrieveError ();
return n; return n;
} }

View File

@ -41,7 +41,7 @@ StdAwk::StdAwk ()
{ {
} }
#define ADD_FUNC(name,min,max,impl) \ #define ADDFNC(name,min,max,impl) \
do { \ do { \
if (addFunction (name, min, max, \ if (addFunction (name, min, max, \
(FunctionHandler)impl) == -1) \ (FunctionHandler)impl) == -1) \
@ -56,18 +56,18 @@ int StdAwk::open ()
int n = Awk::open (); int n = Awk::open ();
if (n == -1) return n; if (n == -1) return n;
ADD_FUNC (QSE_T("sin"), 1, 1, &StdAwk::sin); ADDFNC (QSE_T("sin"), 1, 1, &StdAwk::sin);
ADD_FUNC (QSE_T("cos"), 1, 1, &StdAwk::cos); ADDFNC (QSE_T("cos"), 1, 1, &StdAwk::cos);
ADD_FUNC (QSE_T("tan"), 1, 1, &StdAwk::tan); ADDFNC (QSE_T("tan"), 1, 1, &StdAwk::tan);
ADD_FUNC (QSE_T("atan"), 1, 1, &StdAwk::atan); ADDFNC (QSE_T("atan"), 1, 1, &StdAwk::atan);
ADD_FUNC (QSE_T("atan2"), 2, 2, &StdAwk::atan2); ADDFNC (QSE_T("atan2"), 2, 2, &StdAwk::atan2);
ADD_FUNC (QSE_T("log"), 1, 1, &StdAwk::log); ADDFNC (QSE_T("log"), 1, 1, &StdAwk::log);
ADD_FUNC (QSE_T("exp"), 1, 1, &StdAwk::exp); ADDFNC (QSE_T("exp"), 1, 1, &StdAwk::exp);
ADD_FUNC (QSE_T("sqrt"), 1, 1, &StdAwk::sqrt); ADDFNC (QSE_T("sqrt"), 1, 1, &StdAwk::sqrt);
ADD_FUNC (QSE_T("int"), 1, 1, &StdAwk::fnint); ADDFNC (QSE_T("int"), 1, 1, &StdAwk::fnint);
ADD_FUNC (QSE_T("rand"), 0, 0, &StdAwk::rand); ADDFNC (QSE_T("rand"), 0, 0, &StdAwk::rand);
ADD_FUNC (QSE_T("srand"), 0, 1, &StdAwk::srand); ADDFNC (QSE_T("srand"), 0, 1, &StdAwk::srand);
ADD_FUNC (QSE_T("system"), 1, 1, &StdAwk::system); ADDFNC (QSE_T("system"), 1, 1, &StdAwk::system);
return 0; return 0;
} }

View File

@ -114,21 +114,21 @@ qse_awk_t* qse_awk_open (qse_mmgr_t* mmgr, qse_size_t ext)
qse_map_setcopier (awk->parse.named, QSE_MAP_VAL, QSE_MAP_COPIER_INLINE); qse_map_setcopier (awk->parse.named, QSE_MAP_VAL, QSE_MAP_COPIER_INLINE);
qse_map_setscale (awk->parse.named, QSE_MAP_KEY, QSE_SIZEOF(qse_char_t)); qse_map_setscale (awk->parse.named, QSE_MAP_KEY, QSE_SIZEOF(qse_char_t));
awk->parse.globals = qse_lda_open (mmgr, QSE_SIZEOF(awk), 128); awk->parse.gbls = qse_lda_open (mmgr, QSE_SIZEOF(awk), 128);
awk->parse.locals = qse_lda_open (mmgr, QSE_SIZEOF(awk), 64); awk->parse.lcls = qse_lda_open (mmgr, QSE_SIZEOF(awk), 64);
awk->parse.params = qse_lda_open (mmgr, QSE_SIZEOF(awk), 32); awk->parse.params = qse_lda_open (mmgr, QSE_SIZEOF(awk), 32);
if (awk->parse.globals == QSE_NULL || if (awk->parse.gbls == QSE_NULL ||
awk->parse.locals == QSE_NULL || awk->parse.lcls == QSE_NULL ||
awk->parse.params == QSE_NULL) goto oops; awk->parse.params == QSE_NULL) goto oops;
*(qse_awk_t**)qse_lda_getxtn(awk->parse.globals) = awk; *(qse_awk_t**)qse_lda_getxtn(awk->parse.gbls) = awk;
qse_lda_setcopier (awk->parse.globals, QSE_LDA_COPIER_INLINE); qse_lda_setcopier (awk->parse.gbls, QSE_LDA_COPIER_INLINE);
qse_lda_setscale (awk->parse.globals, QSE_SIZEOF(qse_char_t)); qse_lda_setscale (awk->parse.gbls, QSE_SIZEOF(qse_char_t));
*(qse_awk_t**)qse_lda_getxtn(awk->parse.locals) = awk; *(qse_awk_t**)qse_lda_getxtn(awk->parse.lcls) = awk;
qse_lda_setcopier (awk->parse.locals, QSE_LDA_COPIER_INLINE); qse_lda_setcopier (awk->parse.lcls, QSE_LDA_COPIER_INLINE);
qse_lda_setscale (awk->parse.locals, QSE_SIZEOF(qse_char_t)); qse_lda_setscale (awk->parse.lcls, QSE_SIZEOF(qse_char_t));
*(qse_awk_t**)qse_lda_getxtn(awk->parse.params) = awk; *(qse_awk_t**)qse_lda_getxtn(awk->parse.params) = awk;
qse_lda_setcopier (awk->parse.params, QSE_LDA_COPIER_INLINE); qse_lda_setcopier (awk->parse.params, QSE_LDA_COPIER_INLINE);
@ -139,10 +139,10 @@ qse_awk_t* qse_awk_open (qse_mmgr_t* mmgr, qse_size_t ext)
awk->errlin = 0; awk->errlin = 0;
awk->stopall = QSE_FALSE; awk->stopall = QSE_FALSE;
awk->parse.nlocals_max = 0; awk->parse.nlcls_max = 0;
awk->tree.nglobals = 0; awk->tree.ngbls = 0;
awk->tree.nbglobals = 0; awk->tree.nbgbls = 0;
awk->tree.begin = QSE_NULL; awk->tree.begin = QSE_NULL;
awk->tree.begin_tail = QSE_NULL; awk->tree.begin_tail = QSE_NULL;
awk->tree.end = QSE_NULL; awk->tree.end = QSE_NULL;
@ -186,7 +186,7 @@ qse_awk_t* qse_awk_open (qse_mmgr_t* mmgr, qse_size_t ext)
awk->assoc_data = QSE_NULL; awk->assoc_data = QSE_NULL;
if (qse_awk_initglobals (awk) == -1) goto oops; if (qse_awk_initgbls (awk) == -1) goto oops;
return awk; return awk;
@ -194,8 +194,8 @@ qse_awk_t* qse_awk_open (qse_mmgr_t* mmgr, qse_size_t ext)
oops: oops:
if (awk->fnc.user) qse_map_close (awk->fnc.user); if (awk->fnc.user) qse_map_close (awk->fnc.user);
if (awk->parse.params) qse_lda_close (awk->parse.params); if (awk->parse.params) qse_lda_close (awk->parse.params);
if (awk->parse.locals) qse_lda_close (awk->parse.locals); if (awk->parse.lcls) qse_lda_close (awk->parse.lcls);
if (awk->parse.globals) qse_lda_close (awk->parse.globals); if (awk->parse.gbls) qse_lda_close (awk->parse.gbls);
if (awk->parse.named) qse_map_close (awk->parse.named); if (awk->parse.named) qse_map_close (awk->parse.named);
if (awk->parse.funs) qse_map_close (awk->parse.funs); if (awk->parse.funs) qse_map_close (awk->parse.funs);
if (awk->tree.funs) qse_map_close (awk->tree.funs); if (awk->tree.funs) qse_map_close (awk->tree.funs);
@ -217,8 +217,8 @@ int qse_awk_close (qse_awk_t* awk)
qse_map_close (awk->fnc.user); qse_map_close (awk->fnc.user);
qse_lda_close (awk->parse.params); qse_lda_close (awk->parse.params);
qse_lda_close (awk->parse.locals); qse_lda_close (awk->parse.lcls);
qse_lda_close (awk->parse.globals); qse_lda_close (awk->parse.gbls);
qse_map_close (awk->parse.named); qse_map_close (awk->parse.named);
qse_map_close (awk->parse.funs); qse_map_close (awk->parse.funs);
@ -255,27 +255,27 @@ int qse_awk_clear (qse_awk_t* awk)
awk->src.shared.buf_pos = 0; awk->src.shared.buf_pos = 0;
awk->src.shared.buf_len = 0; awk->src.shared.buf_len = 0;
QSE_ASSERT (QSE_LDA_SIZE(awk->parse.globals) == awk->tree.nglobals); QSE_ASSERT (QSE_LDA_SIZE(awk->parse.gbls) == awk->tree.ngbls);
/* delete all non-builtin global variables */ /* delete all non-builtin global variables */
qse_lda_delete ( qse_lda_delete (
awk->parse.globals, awk->tree.nbglobals, awk->parse.gbls, awk->tree.nbgbls,
QSE_LDA_SIZE(awk->parse.globals) - awk->tree.nbglobals); QSE_LDA_SIZE(awk->parse.gbls) - awk->tree.nbgbls);
qse_lda_clear (awk->parse.locals); qse_lda_clear (awk->parse.lcls);
qse_lda_clear (awk->parse.params); qse_lda_clear (awk->parse.params);
qse_map_clear (awk->parse.named); qse_map_clear (awk->parse.named);
qse_map_clear (awk->parse.funs); qse_map_clear (awk->parse.funs);
awk->parse.nlocals_max = 0; awk->parse.nlcls_max = 0;
awk->parse.depth.cur.block = 0; awk->parse.depth.cur.block = 0;
awk->parse.depth.cur.loop = 0; awk->parse.depth.cur.loop = 0;
awk->parse.depth.cur.expr = 0; awk->parse.depth.cur.expr = 0;
/* clear parse trees */ /* clear parse trees */
awk->tree.ok = 0; awk->tree.ok = 0;
/*awk->tree.nbglobals = 0; /*awk->tree.nbgbls = 0;
awk->tree.nglobals = 0; */ awk->tree.ngbls = 0; */
awk->tree.nglobals = awk->tree.nbglobals; awk->tree.ngbls = awk->tree.nbgbls;
awk->tree.cur_fun.ptr = QSE_NULL; awk->tree.cur_fun.ptr = QSE_NULL;
awk->tree.cur_fun.len = 0; awk->tree.cur_fun.len = 0;

View File

@ -38,8 +38,8 @@ typedef struct qse_awk_tree_t qse_awk_tree_t;
#include "val.h" #include "val.h"
#include "misc.h" #include "misc.h"
#define QSE_AWK_MAX_GLOBALS 9999 #define QSE_AWK_MAX_GBLS 9999
#define QSE_AWK_MAX_LOCALS 9999 #define QSE_AWK_MAX_LCLS 9999
#define QSE_AWK_MAX_PARAMS 9999 #define QSE_AWK_MAX_PARAMS 9999
#define QSE_AWK_ALLOC(awk,size) QSE_MMGR_ALLOC((awk)->mmgr,size) #define QSE_AWK_ALLOC(awk,size) QSE_MMGR_ALLOC((awk)->mmgr,size)
@ -65,8 +65,8 @@ typedef struct qse_awk_tree_t qse_awk_tree_t;
struct qse_awk_tree_t struct qse_awk_tree_t
{ {
qse_size_t nglobals; /* total number of globals */ qse_size_t ngbls; /* total number of gbls */
qse_size_t nbglobals; /* number of intrinsic globals */ qse_size_t nbgbls; /* number of intrinsic gbls */
qse_cstr_t cur_fun; qse_cstr_t cur_fun;
qse_map_t* funs; /* awk function map */ qse_map_t* funs; /* awk function map */
@ -138,16 +138,16 @@ struct qse_awk_t
qse_map_t* named; qse_map_t* named;
/* global variables */ /* global variables */
qse_lda_t* globals; qse_lda_t* gbls;
/* local variables */ /* local variables */
qse_lda_t* locals; qse_lda_t* lcls;
/* parameters to a function */ /* parameters to a function */
qse_lda_t* params; qse_lda_t* params;
/* maximum number of local variables */ /* maximum number of local variables */
qse_size_t nlocals_max; qse_size_t nlcls_max;
qse_awk_nde_t* (*parse_block) ( qse_awk_nde_t* (*parse_block) (
qse_awk_t*,qse_size_t,qse_bool_t); qse_awk_t*,qse_size_t,qse_bool_t);
@ -331,7 +331,7 @@ struct qse_awk_rtx_t
qse_char_t* ptr; qse_char_t* ptr;
qse_size_t len; qse_size_t len;
} subsep; } subsep;
} global; } gbl;
/* eio chain */ /* eio chain */
struct struct

View File

@ -204,7 +204,7 @@ int qse_awk_readeio (
qse_str_clear (buf); qse_str_clear (buf);
/* get the record separator */ /* get the record separator */
rs = qse_awk_rtx_getglobal (run, QSE_AWK_GLOBAL_RS); rs = qse_awk_rtx_getgbl (run, QSE_AWK_GBL_RS);
qse_awk_rtx_refupval (run, rs); qse_awk_rtx_refupval (run, rs);
if (rs->type == QSE_AWK_VAL_NIL) if (rs->type == QSE_AWK_VAL_NIL)
@ -275,11 +275,11 @@ int qse_awk_readeio (
const qse_char_t* match_ptr; const qse_char_t* match_ptr;
qse_size_t match_len; qse_size_t match_len;
QSE_ASSERT (run->global.rs != QSE_NULL); QSE_ASSERT (run->gbl.rs != QSE_NULL);
n = QSE_AWK_MATCHREX ( n = QSE_AWK_MATCHREX (
run->awk, run->global.rs, run->awk, run->gbl.rs,
((run->global.ignorecase)? QSE_REX_IGNORECASE: 0), ((run->gbl.ignorecase)? QSE_REX_IGNORECASE: 0),
QSE_STR_PTR(buf), QSE_STR_LEN(buf), QSE_STR_PTR(buf), QSE_STR_LEN(buf),
&match_ptr, &match_len, &run->errnum); &match_ptr, &match_len, &run->errnum);
if (n == -1) if (n == -1)
@ -363,11 +363,11 @@ int qse_awk_readeio (
const qse_char_t* match_ptr; const qse_char_t* match_ptr;
qse_size_t match_len; qse_size_t match_len;
QSE_ASSERT (run->global.rs != QSE_NULL); QSE_ASSERT (run->gbl.rs != QSE_NULL);
n = QSE_AWK_MATCHREX ( n = QSE_AWK_MATCHREX (
run->awk, run->global.rs, run->awk, run->gbl.rs,
((run->global.ignorecase)? QSE_REX_IGNORECASE: 0), ((run->gbl.ignorecase)? QSE_REX_IGNORECASE: 0),
QSE_STR_PTR(buf), QSE_STR_LEN(buf), QSE_STR_PTR(buf), QSE_STR_LEN(buf),
&match_ptr, &match_len, &run->errnum); &match_ptr, &match_len, &run->errnum);
if (n == -1) if (n == -1)

View File

@ -652,7 +652,7 @@ static int fnc_split (
if (a2 == QSE_NULL) if (a2 == QSE_NULL)
{ {
/* get the value from FS */ /* get the value from FS */
t1 = qse_awk_rtx_getglobal (run, QSE_AWK_GLOBAL_FS); t1 = qse_awk_rtx_getgbl (run, QSE_AWK_GBL_FS);
if (t1->type == QSE_AWK_VAL_NIL) if (t1->type == QSE_AWK_VAL_NIL)
{ {
fs_ptr = QSE_T(" "); fs_ptr = QSE_T(" ");
@ -680,7 +680,7 @@ static int fnc_split (
if (fs_len > 1) if (fs_len > 1)
{ {
fs_rex = run->global.fs; fs_rex = run->gbl.fs;
fs_rex_free = QSE_NULL; fs_rex_free = QSE_NULL;
} }
} }
@ -1072,7 +1072,7 @@ static int __substitute (qse_awk_rtx_t* run, qse_long_t max_count)
} }
} }
opt = (run->global.ignorecase)? QSE_REX_IGNORECASE: 0; opt = (run->gbl.ignorecase)? QSE_REX_IGNORECASE: 0;
cur_ptr = a2_ptr; cur_ptr = a2_ptr;
cur_len = a2_len; cur_len = a2_len;
sub_count = 0; sub_count = 0;
@ -1291,7 +1291,7 @@ static int fnc_match (
if (a1->type != QSE_AWK_VAL_STR) QSE_AWK_FREE (run->awk, str1); if (a1->type != QSE_AWK_VAL_STR) QSE_AWK_FREE (run->awk, str1);
} }
opt = (run->global.ignorecase)? QSE_REX_IGNORECASE: 0; opt = (run->gbl.ignorecase)? QSE_REX_IGNORECASE: 0;
n = QSE_AWK_MATCHREX ( n = QSE_AWK_MATCHREX (
run->awk, rex, opt, str0, len0, run->awk, rex, opt, str0, len0,
&mat_ptr, &mat_len, &run->errnum); &mat_ptr, &mat_len, &run->errnum);
@ -1324,14 +1324,14 @@ static int fnc_match (
qse_awk_rtx_refupval (run, a1); qse_awk_rtx_refupval (run, a1);
if (qse_awk_rtx_setglobal (run, QSE_AWK_GLOBAL_RSTART, a0) == -1) if (qse_awk_rtx_setgbl (run, QSE_AWK_GBL_RSTART, a0) == -1)
{ {
qse_awk_rtx_refdownval (run, a1); qse_awk_rtx_refdownval (run, a1);
qse_awk_rtx_refdownval (run, a0); qse_awk_rtx_refdownval (run, a0);
return -1; return -1;
} }
if (qse_awk_rtx_setglobal (run, QSE_AWK_GLOBAL_RLENGTH, a1) == -1) if (qse_awk_rtx_setgbl (run, QSE_AWK_GBL_RLENGTH, a1) == -1)
{ {
qse_awk_rtx_refdownval (run, a1); qse_awk_rtx_refdownval (run, a1);
qse_awk_rtx_refdownval (run, a0); qse_awk_rtx_refdownval (run, a0);

View File

@ -738,7 +738,7 @@ qse_char_t* qse_awk_strxntok (
{ {
/* each token is delimited by one of charaters /* each token is delimited by one of charaters
* in the delimeter set "delim". */ * in the delimeter set "delim". */
if (run->global.ignorecase) if (run->gbl.ignorecase)
{ {
while (p < end) while (p < end)
{ {
@ -773,7 +773,7 @@ qse_char_t* qse_awk_strxntok (
* in the delimeter set "delim". however, all space characters * in the delimeter set "delim". however, all space characters
* surrounding the token are removed */ * surrounding the token are removed */
while (p < end && QSE_AWK_ISSPACE(run->awk,*p)) p++; while (p < end && QSE_AWK_ISSPACE(run->awk,*p)) p++;
if (run->global.ignorecase) if (run->gbl.ignorecase)
{ {
while (p < end) while (p < end)
{ {
@ -846,7 +846,7 @@ qse_char_t* qse_awk_strxntokbyrex (
{ {
n = QSE_AWK_MATCHREX ( n = QSE_AWK_MATCHREX (
run->awk, rex, run->awk, rex,
((run->global.ignorecase)? QSE_REX_IGNORECASE: 0), ((run->gbl.ignorecase)? QSE_REX_IGNORECASE: 0),
ptr, left, (const qse_char_t**)&match_ptr, &match_len, ptr, left, (const qse_char_t**)&match_ptr, &match_len,
errnum); errnum);
if (n == -1) return QSE_NULL; if (n == -1) return QSE_NULL;

View File

@ -116,7 +116,7 @@ enum token_t
enum enum
{ {
PARSE_GLOBAL, PARSE_GBL,
PARSE_FUNCTION, PARSE_FUNCTION,
PARSE_BEGIN, PARSE_BEGIN,
PARSE_END, PARSE_END,
@ -145,18 +145,18 @@ struct binmap_t
static int parse (qse_awk_t* awk); static int parse (qse_awk_t* awk);
static qse_awk_t* parse_progunit (qse_awk_t* awk); static qse_awk_t* parse_progunit (qse_awk_t* awk);
static qse_awk_t* collect_globals (qse_awk_t* awk); static qse_awk_t* collect_gbls (qse_awk_t* awk);
static void adjust_static_globals (qse_awk_t* awk); static void adjust_static_gbls (qse_awk_t* awk);
static qse_size_t get_global ( static qse_size_t get_gbl (
qse_awk_t* awk, const qse_char_t* name, qse_size_t len); qse_awk_t* awk, const qse_char_t* name, qse_size_t len);
static qse_size_t find_global ( static qse_size_t find_gbl (
qse_awk_t* awk, const qse_char_t* name, qse_size_t len); qse_awk_t* awk, const qse_char_t* name, qse_size_t len);
static int add_global ( static int add_gbl (
qse_awk_t* awk, const qse_char_t* name, qse_size_t len, qse_awk_t* awk, const qse_char_t* name, qse_size_t len,
qse_size_t line, int force); qse_size_t line, int force);
static qse_awk_t* collect_locals ( static qse_awk_t* collect_lcls (
qse_awk_t* awk, qse_size_t nlocals, qse_bool_t istop); qse_awk_t* awk, qse_size_t nlcls, qse_bool_t istop);
static qse_awk_nde_t* parse_function (qse_awk_t* awk); static qse_awk_nde_t* parse_function (qse_awk_t* awk);
static qse_awk_nde_t* parse_begin (qse_awk_t* awk); static qse_awk_nde_t* parse_begin (qse_awk_t* awk);
@ -291,16 +291,16 @@ static kwent_t kwtab[] =
{ QSE_NULL, 0, 0, 0 } { QSE_NULL, 0, 0, 0 }
}; };
typedef struct global_t global_t; typedef struct gbl_t gbl_t;
struct global_t struct gbl_t
{ {
const qse_char_t* name; const qse_char_t* name;
qse_size_t name_len; qse_size_t name_len;
int valid; int valid;
}; };
static global_t gtab[] = static gbl_t gtab[] =
{ {
{ QSE_T("ARGC"), 4, 0 }, { QSE_T("ARGC"), 4, 0 },
{ QSE_T("ARGV"), 4, 0 }, { QSE_T("ARGV"), 4, 0 },
@ -455,7 +455,7 @@ void qse_awk_setmaxdepth (qse_awk_t* awk, int types, qse_size_t depth)
} }
} }
const qse_char_t* qse_awk_rtx_getglobalname ( const qse_char_t* qse_awk_rtx_getgblname (
qse_awk_t* awk, qse_size_t idx, qse_size_t* len) qse_awk_t* awk, qse_size_t idx, qse_size_t* len)
{ {
/* /*
@ -463,10 +463,10 @@ const qse_char_t* qse_awk_rtx_getglobalname (
return gtab[idx].name; return gtab[idx].name;
*/ */
QSE_ASSERT (idx < QSE_LDA_SIZE(awk->parse.globals)); QSE_ASSERT (idx < QSE_LDA_SIZE(awk->parse.gbls));
*len = QSE_LDA_DLEN(awk->parse.globals,idx); *len = QSE_LDA_DLEN(awk->parse.gbls,idx);
return QSE_LDA_DPTR(awk->parse.globals,idx); return QSE_LDA_DPTR(awk->parse.gbls,idx);
} }
qse_cstr_t* qse_awk_getkw (qse_awk_t* awk, int id, qse_cstr_t* s) qse_cstr_t* qse_awk_getkw (qse_awk_t* awk, int id, qse_cstr_t* s)
@ -528,7 +528,7 @@ static int parse (qse_awk_t* awk)
return -1; return -1;
} }
adjust_static_globals (awk); adjust_static_gbls (awk);
#define EXIT_PARSE(v) do { n = (v); goto exit_parse; } while(0) #define EXIT_PARSE(v) do { n = (v); goto exit_parse; } while(0)
@ -580,7 +580,7 @@ static int parse (qse_awk_t* awk)
} }
} }
QSE_ASSERT (awk->tree.nglobals == QSE_LDA_SIZE(awk->parse.globals)); QSE_ASSERT (awk->tree.ngbls == QSE_LDA_SIZE(awk->parse.gbls));
if (awk->src.ios.out != QSE_NULL) if (awk->src.ios.out != QSE_NULL)
{ {
@ -611,7 +611,7 @@ exit_parse:
static qse_awk_t* parse_progunit (qse_awk_t* awk) static qse_awk_t* parse_progunit (qse_awk_t* awk)
{ {
/* /*
global xxx, xxxx; gbl xxx, xxxx;
BEGIN { action } BEGIN { action }
END { action } END { action }
pattern { action } pattern { action }
@ -622,20 +622,20 @@ static qse_awk_t* parse_progunit (qse_awk_t* awk)
if ((awk->option & QSE_AWK_EXPLICIT) && MATCH(awk,TOKEN_GLOBAL)) if ((awk->option & QSE_AWK_EXPLICIT) && MATCH(awk,TOKEN_GLOBAL))
{ {
qse_size_t nglobals; qse_size_t ngbls;
awk->parse.id.block = PARSE_GLOBAL; awk->parse.id.block = PARSE_GBL;
if (get_token(awk) == -1) return QSE_NULL; if (get_token(awk) == -1) return QSE_NULL;
QSE_ASSERT (awk->tree.nglobals == QSE_LDA_SIZE(awk->parse.globals)); QSE_ASSERT (awk->tree.ngbls == QSE_LDA_SIZE(awk->parse.gbls));
nglobals = awk->tree.nglobals; ngbls = awk->tree.ngbls;
if (collect_globals (awk) == QSE_NULL) if (collect_gbls (awk) == QSE_NULL)
{ {
qse_lda_delete ( qse_lda_delete (
awk->parse.globals, nglobals, awk->parse.gbls, ngbls,
QSE_LDA_SIZE(awk->parse.globals) - nglobals); QSE_LDA_SIZE(awk->parse.gbls) - ngbls);
awk->tree.nglobals = nglobals; awk->tree.ngbls = ngbls;
return QSE_NULL; return QSE_NULL;
} }
} }
@ -870,7 +870,7 @@ static qse_awk_nde_t* parse_function (qse_awk_t* awk)
} }
/* check if it coincides to be a global variable name */ /* check if it coincides to be a global variable name */
g = find_global (awk, name, name_len); g = find_gbl (awk, name, name_len);
if (g != QSE_LDA_NIL) if (g != QSE_LDA_NIL)
{ {
SETERRARG ( SETERRARG (
@ -945,7 +945,7 @@ static qse_awk_nde_t* parse_function (qse_awk_t* awk)
/* NOTE: the following is not a conflict. /* NOTE: the following is not a conflict.
* so the parameter is not checked against * so the parameter is not checked against
* global variables. * global variables.
* global x; * gbl x;
* function f (x) { print x; } * function f (x) { print x; }
* x in print x is a parameter * x in print x is a parameter
*/ */
@ -1213,10 +1213,10 @@ static qse_awk_nde_t* parse_block (
{ {
qse_awk_nde_t* head, * curr, * nde; qse_awk_nde_t* head, * curr, * nde;
qse_awk_nde_blk_t* block; qse_awk_nde_blk_t* block;
qse_size_t nlocals, nlocals_max, tmp; qse_size_t nlcls, nlcls_max, tmp;
nlocals = QSE_LDA_SIZE(awk->parse.locals); nlcls = QSE_LDA_SIZE(awk->parse.lcls);
nlocals_max = awk->parse.nlocals_max; nlcls_max = awk->parse.nlcls_max;
/* local variable declarations */ /* local variable declarations */
if (awk->option & QSE_AWK_EXPLICIT) if (awk->option & QSE_AWK_EXPLICIT)
@ -1228,16 +1228,16 @@ static qse_awk_nde_t* parse_block (
if (get_token(awk) == -1) if (get_token(awk) == -1)
{ {
qse_lda_delete ( qse_lda_delete (
awk->parse.locals, nlocals, awk->parse.lcls, nlcls,
QSE_LDA_SIZE(awk->parse.locals)-nlocals); QSE_LDA_SIZE(awk->parse.lcls)-nlcls);
return QSE_NULL; return QSE_NULL;
} }
if (collect_locals (awk, nlocals, istop) == QSE_NULL) if (collect_lcls (awk, nlcls, istop) == QSE_NULL)
{ {
qse_lda_delete ( qse_lda_delete (
awk->parse.locals, nlocals, awk->parse.lcls, nlcls,
QSE_LDA_SIZE(awk->parse.locals)-nlocals); QSE_LDA_SIZE(awk->parse.lcls)-nlcls);
return QSE_NULL; return QSE_NULL;
} }
} }
@ -1258,8 +1258,8 @@ static qse_awk_nde_t* parse_block (
if (MATCH(awk,TOKEN_EOF)) if (MATCH(awk,TOKEN_EOF))
{ {
qse_lda_delete ( qse_lda_delete (
awk->parse.locals, nlocals, awk->parse.lcls, nlcls,
QSE_LDA_SIZE(awk->parse.locals) - nlocals); QSE_LDA_SIZE(awk->parse.lcls) - nlcls);
if (head != QSE_NULL) qse_awk_clrpt (awk, head); if (head != QSE_NULL) qse_awk_clrpt (awk, head);
SETERRLIN (awk, QSE_AWK_EENDSRC, awk->token.prev.line); SETERRLIN (awk, QSE_AWK_EENDSRC, awk->token.prev.line);
@ -1272,8 +1272,8 @@ static qse_awk_nde_t* parse_block (
if (get_token(awk) == -1) if (get_token(awk) == -1)
{ {
qse_lda_delete ( qse_lda_delete (
awk->parse.locals, nlocals, awk->parse.lcls, nlcls,
QSE_LDA_SIZE(awk->parse.locals)-nlocals); QSE_LDA_SIZE(awk->parse.lcls)-nlcls);
if (head != QSE_NULL) qse_awk_clrpt (awk, head); if (head != QSE_NULL) qse_awk_clrpt (awk, head);
return QSE_NULL; return QSE_NULL;
} }
@ -1286,8 +1286,8 @@ static qse_awk_nde_t* parse_block (
if (nde == QSE_NULL) if (nde == QSE_NULL)
{ {
qse_lda_delete ( qse_lda_delete (
awk->parse.locals, nlocals, awk->parse.lcls, nlcls,
QSE_LDA_SIZE(awk->parse.locals)-nlocals); QSE_LDA_SIZE(awk->parse.lcls)-nlcls);
if (head != QSE_NULL) qse_awk_clrpt (awk, head); if (head != QSE_NULL) qse_awk_clrpt (awk, head);
return QSE_NULL; return QSE_NULL;
} }
@ -1316,21 +1316,21 @@ static qse_awk_nde_t* parse_block (
if (block == QSE_NULL) if (block == QSE_NULL)
{ {
qse_lda_delete ( qse_lda_delete (
awk->parse.locals, nlocals, awk->parse.lcls, nlcls,
QSE_LDA_SIZE(awk->parse.locals)-nlocals); QSE_LDA_SIZE(awk->parse.lcls)-nlcls);
qse_awk_clrpt (awk, head); qse_awk_clrpt (awk, head);
SETERRLIN (awk, QSE_AWK_ENOMEM, line); SETERRLIN (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL; return QSE_NULL;
} }
tmp = QSE_LDA_SIZE(awk->parse.locals); tmp = QSE_LDA_SIZE(awk->parse.lcls);
if (tmp > awk->parse.nlocals_max) awk->parse.nlocals_max = tmp; if (tmp > awk->parse.nlcls_max) awk->parse.nlcls_max = tmp;
/* remove all locals to move it up to the top level */ /* remove all lcls to move it up to the top level */
qse_lda_delete (awk->parse.locals, nlocals, tmp - nlocals); qse_lda_delete (awk->parse.lcls, nlcls, tmp - nlcls);
/* adjust the number of locals for a block without any statements */ /* adjust the number of lcls for a block without any statements */
/* if (head == QSE_NULL) tmp = 0; */ /* if (head == QSE_NULL) tmp = 0; */
block->type = QSE_AWK_NDE_BLK; block->type = QSE_AWK_NDE_BLK;
@ -1345,13 +1345,13 @@ static qse_awk_nde_t* parse_block (
/* migrate all block-local variables to a top-level block */ /* migrate all block-local variables to a top-level block */
if (istop) if (istop)
{ {
block->nlocals = awk->parse.nlocals_max - nlocals; block->nlcls = awk->parse.nlcls_max - nlcls;
awk->parse.nlocals_max = nlocals_max; awk->parse.nlcls_max = nlcls_max;
} }
else else
{ {
/*block->nlocals = tmp - nlocals;*/ /*block->nlcls = tmp - nlcls;*/
block->nlocals = 0; block->nlcls = 0;
} }
return (qse_awk_nde_t*)block; return (qse_awk_nde_t*)block;
@ -1377,81 +1377,81 @@ static qse_awk_nde_t* parse_block_dc (
return nde; return nde;
} }
int qse_awk_initglobals (qse_awk_t* awk) int qse_awk_initgbls (qse_awk_t* awk)
{ {
int id; int id;
/* qse_awk_initglobals is not generic-purpose. call this from /* qse_awk_initgbls is not generic-purpose. call this from
* qse_awk_open only. */ * qse_awk_open only. */
QSE_ASSERT (awk->tree.nbglobals == 0 && awk->tree.nglobals == 0); QSE_ASSERT (awk->tree.nbgbls == 0 && awk->tree.ngbls == 0);
awk->tree.nbglobals = 0; awk->tree.nbgbls = 0;
awk->tree.nglobals = 0; awk->tree.ngbls = 0;
for (id = QSE_AWK_MIN_GLOBAL_ID; id <= QSE_AWK_MAX_GLOBAL_ID; id++) for (id = QSE_AWK_MIN_GBL_ID; id <= QSE_AWK_MAX_GBL_ID; id++)
{ {
qse_size_t g; qse_size_t g;
g = qse_lda_insert ( g = qse_lda_insert (
awk->parse.globals, awk->parse.gbls,
QSE_LDA_SIZE(awk->parse.globals), QSE_LDA_SIZE(awk->parse.gbls),
(qse_char_t*)gtab[id].name, (qse_char_t*)gtab[id].name,
gtab[id].name_len); gtab[id].name_len);
if (g == QSE_LDA_NIL) return -1; if (g == QSE_LDA_NIL) return -1;
QSE_ASSERT ((int)g == id); QSE_ASSERT ((int)g == id);
awk->tree.nbglobals++; awk->tree.nbgbls++;
awk->tree.nglobals++; awk->tree.ngbls++;
} }
QSE_ASSERT (awk->tree.nbglobals == QSE_ASSERT (awk->tree.nbgbls ==
QSE_AWK_MAX_GLOBAL_ID-QSE_AWK_MIN_GLOBAL_ID+1); QSE_AWK_MAX_GBL_ID-QSE_AWK_MIN_GBL_ID+1);
return 0; return 0;
} }
static void adjust_static_globals (qse_awk_t* awk) static void adjust_static_gbls (qse_awk_t* awk)
{ {
int id; int id;
QSE_ASSERT (awk->tree.nbglobals >= QSE_ASSERT (awk->tree.nbgbls >=
QSE_AWK_MAX_GLOBAL_ID - QSE_AWK_MAX_GLOBAL_ID + 1); QSE_AWK_MAX_GBL_ID - QSE_AWK_MAX_GBL_ID + 1);
for (id = QSE_AWK_MIN_GLOBAL_ID; id <= QSE_AWK_MAX_GLOBAL_ID; id++) for (id = QSE_AWK_MIN_GBL_ID; id <= QSE_AWK_MAX_GBL_ID; id++)
{ {
if (gtab[id].valid != 0 && if (gtab[id].valid != 0 &&
(awk->option & gtab[id].valid) != gtab[id].valid) (awk->option & gtab[id].valid) != gtab[id].valid)
{ {
/*awk->parse.globals.buf[id].name.len = 0;*/ /*awk->parse.gbls.buf[id].name.len = 0;*/
QSE_LDA_DLEN(awk->parse.globals,id) = 0; QSE_LDA_DLEN(awk->parse.gbls,id) = 0;
} }
else else
{ {
/*awk->parse.globals.buf[id].name.len = gtab[id].name_len;*/ /*awk->parse.gbls.buf[id].name.len = gtab[id].name_len;*/
QSE_LDA_DLEN(awk->parse.globals,id) = gtab[id].name_len; QSE_LDA_DLEN(awk->parse.gbls,id) = gtab[id].name_len;
} }
} }
} }
typedef struct check_global_t check_global_t; typedef struct check_gbl_t check_gbl_t;
struct check_global_t struct check_gbl_t
{ {
qse_cstr_t name; qse_cstr_t name;
qse_size_t index; qse_size_t index;
qse_lda_walk_t walk; qse_lda_walk_t walk;
}; };
static qse_lda_walk_t check_global (qse_lda_t* lda, qse_size_t index, void* arg) static qse_lda_walk_t check_gbl (qse_lda_t* lda, qse_size_t index, void* arg)
{ {
qse_cstr_t tmp; qse_cstr_t tmp;
qse_awk_t* awk = *(qse_awk_t**)qse_lda_getxtn(lda); qse_awk_t* awk = *(qse_awk_t**)qse_lda_getxtn(lda);
check_global_t* cg = (check_global_t*)arg; check_gbl_t* cg = (check_gbl_t*)arg;
tmp.ptr = QSE_LDA_DPTR(lda,index); tmp.ptr = QSE_LDA_DPTR(lda,index);
tmp.len = QSE_LDA_DLEN(lda,index); tmp.len = QSE_LDA_DLEN(lda,index);
if (index < awk->tree.nbglobals) if (index < awk->tree.nbgbls)
{ {
qse_map_pair_t* pair; qse_map_pair_t* pair;
@ -1472,10 +1472,10 @@ static qse_lda_walk_t check_global (qse_lda_t* lda, qse_size_t index, void* arg)
return cg->walk; return cg->walk;
} }
static qse_size_t get_global ( static qse_size_t get_gbl (
qse_awk_t* awk, const qse_char_t* name, qse_size_t len) qse_awk_t* awk, const qse_char_t* name, qse_size_t len)
{ {
check_global_t cg; check_gbl_t cg;
cg.name.ptr = name; cg.name.ptr = name;
cg.name.len = len; cg.name.len = len;
@ -1483,34 +1483,34 @@ static qse_size_t get_global (
cg.walk = QSE_LDA_WALK_BACKWARD; cg.walk = QSE_LDA_WALK_BACKWARD;
/* return qse_lda_rsearch ( /* return qse_lda_rsearch (
awk->parse.globals, QSE_LDA_SIZE(awk->parse.globals), awk->parse.gbls, QSE_LDA_SIZE(awk->parse.gbls),
name, len); */ name, len); */
qse_lda_rwalk (awk->parse.globals, check_global, &cg); qse_lda_rwalk (awk->parse.gbls, check_gbl, &cg);
return cg.index; return cg.index;
} }
static qse_size_t find_global ( static qse_size_t find_gbl (
qse_awk_t* awk, const qse_char_t* name, qse_size_t len) qse_awk_t* awk, const qse_char_t* name, qse_size_t len)
{ {
check_global_t cg; check_gbl_t cg;
cg.name.ptr = name; cg.name.ptr = name;
cg.name.len = len; cg.name.len = len;
cg.index = QSE_LDA_NIL; cg.index = QSE_LDA_NIL;
cg.walk = QSE_LDA_WALK_FORWARD; cg.walk = QSE_LDA_WALK_FORWARD;
/* return qse_lda_search (awk->parse.globals, 0, name, len); */ /* return qse_lda_search (awk->parse.gbls, 0, name, len); */
qse_lda_walk (awk->parse.globals, check_global, &cg); qse_lda_walk (awk->parse.gbls, check_gbl, &cg);
return cg.index; return cg.index;
} }
static int add_global ( static int add_gbl (
qse_awk_t* awk, const qse_char_t* name, qse_size_t len, qse_awk_t* awk, const qse_char_t* name, qse_size_t len,
qse_size_t line, int disabled) qse_size_t line, int disabled)
{ {
qse_size_t nglobals; qse_size_t ngbls;
#if 0 #if 0
if (awk->option & QSE_AWK_UNIQUEFN) if (awk->option & QSE_AWK_UNIQUEFN)
@ -1548,41 +1548,41 @@ static int add_global (
#endif #endif
/* check if it conflicts with other global variable names */ /* check if it conflicts with other global variable names */
if (find_global (awk, name, len) != QSE_LDA_NIL) if (find_gbl (awk, name, len) != QSE_LDA_NIL)
{ {
SETERRARG (awk, QSE_AWK_EDUPGBL, line, name, len); SETERRARG (awk, QSE_AWK_EDUPGBL, line, name, len);
return -1; return -1;
} }
nglobals = QSE_LDA_SIZE (awk->parse.globals); ngbls = QSE_LDA_SIZE (awk->parse.gbls);
if (nglobals >= QSE_AWK_MAX_GLOBALS) if (ngbls >= QSE_AWK_MAX_GBLS)
{ {
SETERRLIN (awk, QSE_AWK_EGBLTM, line); SETERRLIN (awk, QSE_AWK_EGBLTM, line);
return -1; return -1;
} }
if (qse_lda_insert (awk->parse.globals, if (qse_lda_insert (awk->parse.gbls,
QSE_LDA_SIZE(awk->parse.globals), QSE_LDA_SIZE(awk->parse.gbls),
(qse_char_t*)name, len) == QSE_LDA_NIL) (qse_char_t*)name, len) == QSE_LDA_NIL)
{ {
SETERRLIN (awk, QSE_AWK_ENOMEM, line); SETERRLIN (awk, QSE_AWK_ENOMEM, line);
return -1; return -1;
} }
QSE_ASSERT (nglobals == QSE_LDA_SIZE(awk->parse.globals) - 1); QSE_ASSERT (ngbls == QSE_LDA_SIZE(awk->parse.gbls) - 1);
/* the disabled item is inserted normally but /* the disabled item is inserted normally but
* the name length is reset to zero. */ * the name length is reset to zero. */
if (disabled) QSE_LDA_DLEN(awk->parse.globals,nglobals) = 0; if (disabled) QSE_LDA_DLEN(awk->parse.gbls,ngbls) = 0;
awk->tree.nglobals = QSE_LDA_SIZE (awk->parse.globals); awk->tree.ngbls = QSE_LDA_SIZE (awk->parse.gbls);
QSE_ASSERT (nglobals == awk->tree.nglobals-1); QSE_ASSERT (ngbls == awk->tree.ngbls-1);
/* return the id which is the index to the global table. */ /* return the id which is the index to the gbl table. */
return (int)nglobals; return (int)ngbls;
} }
int qse_awk_addglobal ( int qse_awk_addgbl (
qse_awk_t* awk, const qse_char_t* name, qse_size_t len) qse_awk_t* awk, const qse_char_t* name, qse_size_t len)
{ {
int n; int n;
@ -1593,38 +1593,38 @@ int qse_awk_addglobal (
return -1; return -1;
} }
if (awk->tree.nglobals > awk->tree.nbglobals) if (awk->tree.ngbls > awk->tree.nbgbls)
{ {
/* this function is not allow after qse_awk_parse is called */ /* this function is not allow after qse_awk_parse is called */
SETERR (awk, QSE_AWK_ENOPER); SETERR (awk, QSE_AWK_ENOPER);
return -1; return -1;
} }
n = add_global (awk, name, len, 0, 0); n = add_gbl (awk, name, len, 0, 0);
/* update the count of the static globals. /* update the count of the static gbls.
* the total global count has been updated inside add_global. */ * the total gbl count has been updated inside add_gbl. */
if (n >= 0) awk->tree.nbglobals++; if (n >= 0) awk->tree.nbgbls++;
return n; return n;
} }
int qse_awk_delglobal ( int qse_awk_delgbl (
qse_awk_t* awk, const qse_char_t* name, qse_size_t len) qse_awk_t* awk, const qse_char_t* name, qse_size_t len)
{ {
qse_size_t n; qse_size_t n;
#define QSE_AWK_NUM_STATIC_GLOBALS \ #define QSE_AWK_NUM_STATIC_GBLS \
(QSE_AWK_MAX_GLOBAL_ID-QSE_AWK_MIN_GLOBAL_ID+1) (QSE_AWK_MAX_GBL_ID-QSE_AWK_MIN_GBL_ID+1)
if (awk->tree.nglobals > awk->tree.nbglobals) if (awk->tree.ngbls > awk->tree.nbgbls)
{ {
/* this function is not allow after qse_awk_parse is called */ /* this function is not allow after qse_awk_parse is called */
SETERR (awk, QSE_AWK_ENOPER); SETERR (awk, QSE_AWK_ENOPER);
return -1; return -1;
} }
n = qse_lda_search (awk->parse.globals, n = qse_lda_search (awk->parse.gbls,
QSE_AWK_NUM_STATIC_GLOBALS, name, len); QSE_AWK_NUM_STATIC_GBLS, name, len);
if (n == QSE_LDA_NIL) if (n == QSE_LDA_NIL)
{ {
SETERRARG (awk, QSE_AWK_ENOENT, 0, name, len); SETERRARG (awk, QSE_AWK_ENOENT, 0, name, len);
@ -1633,20 +1633,20 @@ int qse_awk_delglobal (
/* invalidate the name if deletion is requested. /* invalidate the name if deletion is requested.
* this approach does not delete the entry. * this approach does not delete the entry.
* if qse_awk_addglobal is called with the same name * if qse_awk_addgbl is called with the same name
* again, the entry will be appended again. * again, the entry will be appended again.
* never call this funciton unless it is really required. */ * never call this funciton unless it is really required. */
/* /*
awk->parse.globals.buf[n].name.ptr[0] = QSE_T('\0'); awk->parse.gbls.buf[n].name.ptr[0] = QSE_T('\0');
awk->parse.globals.buf[n].name.len = 0; awk->parse.gbls.buf[n].name.len = 0;
*/ */
n = qse_lda_uplete (awk->parse.globals, n, 1); n = qse_lda_uplete (awk->parse.gbls, n, 1);
QSE_ASSERT (n == 1); QSE_ASSERT (n == 1);
return 0; return 0;
} }
static qse_awk_t* collect_globals (qse_awk_t* awk) static qse_awk_t* collect_gbls (qse_awk_t* awk)
{ {
while (1) while (1)
{ {
@ -1656,7 +1656,7 @@ static qse_awk_t* collect_globals (qse_awk_t* awk)
return QSE_NULL; return QSE_NULL;
} }
if (add_global ( if (add_gbl (
awk, awk,
QSE_STR_PTR(awk->token.name), QSE_STR_PTR(awk->token.name),
QSE_STR_LEN(awk->token.name), QSE_STR_LEN(awk->token.name),
@ -1681,10 +1681,10 @@ static qse_awk_t* collect_globals (qse_awk_t* awk)
return awk; return awk;
} }
static qse_awk_t* collect_locals ( static qse_awk_t* collect_lcls (
qse_awk_t* awk, qse_size_t nlocals, qse_bool_t istop) qse_awk_t* awk, qse_size_t nlcls, qse_bool_t istop)
{ {
qse_xstr_t local; qse_xstr_t lcl;
qse_size_t n; qse_size_t n;
while (1) while (1)
@ -1695,8 +1695,8 @@ static qse_awk_t* collect_locals (
return QSE_NULL; return QSE_NULL;
} }
local.ptr = QSE_STR_PTR(awk->token.name); lcl.ptr = QSE_STR_PTR(awk->token.name);
local.len = QSE_STR_LEN(awk->token.name); lcl.len = QSE_STR_LEN(awk->token.name);
#if 0 #if 0
if (awk->option & QSE_AWK_UNIQUEFN) if (awk->option & QSE_AWK_UNIQUEFN)
@ -1705,12 +1705,12 @@ static qse_awk_t* collect_locals (
#endif #endif
/* check if it conflict with a builtin function name /* check if it conflict with a builtin function name
* function f() { local length; } */ * function f() { lcl length; } */
if (qse_awk_getfnc (awk, local.ptr, local.len) != QSE_NULL) if (qse_awk_getfnc (awk, lcl.ptr, lcl.len) != QSE_NULL)
{ {
SETERRARG ( SETERRARG (
awk, QSE_AWK_EFNCRED, awk->token.line, awk, QSE_AWK_EFNCRED, awk->token.line,
local.ptr, local.len); lcl.ptr, lcl.len);
return QSE_NULL; return QSE_NULL;
} }
@ -1720,25 +1720,25 @@ static qse_awk_t* collect_locals (
{ {
iscur = (qse_strxncmp ( iscur = (qse_strxncmp (
awk->tree.cur_fun.ptr, awk->tree.cur_fun.len, awk->tree.cur_fun.ptr, awk->tree.cur_fun.len,
local.ptr, local.len) == 0); lcl.ptr, lcl.len) == 0);
} }
if (iscur || qse_map_search (awk->tree.funs, local.ptr, local.len) != QSE_NULL) if (iscur || qse_map_search (awk->tree.funs, lcl.ptr, lcl.len) != QSE_NULL)
{ {
SETERRARG ( SETERRARG (
awk, QSE_AWK_EFUNRED, awk->token.line, awk, QSE_AWK_EFUNRED, awk->token.line,
local.ptr, local.len); lcl.ptr, lcl.len);
return QSE_NULL; return QSE_NULL;
} }
/* check if it conflict with a function name /* check if it conflict with a function name
* caught in the function call table */ * caught in the function call table */
if (qse_map_search (awk->parse.funs, if (qse_map_search (awk->parse.funs,
local.ptr, local.len) != QSE_NULL) lcl.ptr, lcl.len) != QSE_NULL)
{ {
SETERRARG ( SETERRARG (
awk, QSE_AWK_EFUNRED, awk->token.line, awk, QSE_AWK_EFUNRED, awk->token.line,
local.ptr, local.len); lcl.ptr, lcl.len);
return QSE_NULL; return QSE_NULL;
} }
} }
@ -1747,39 +1747,39 @@ static qse_awk_t* collect_locals (
if (istop) if (istop)
{ {
/* check if it conflicts with a paremeter name */ /* check if it conflicts with a paremeter name */
n = qse_lda_search (awk->parse.params, 0, local.ptr, local.len); n = qse_lda_search (awk->parse.params, 0, lcl.ptr, lcl.len);
if (n != QSE_LDA_NIL) if (n != QSE_LDA_NIL)
{ {
SETERRARG ( SETERRARG (
awk, QSE_AWK_EPARRED, awk->token.line, awk, QSE_AWK_EPARRED, awk->token.line,
local.ptr, local.len); lcl.ptr, lcl.len);
return QSE_NULL; return QSE_NULL;
} }
} }
/* check if it conflicts with other local variable names */ /* check if it conflicts with other local variable names */
n = qse_lda_search ( n = qse_lda_search (
awk->parse.locals, awk->parse.lcls,
nlocals, /*((awk->option&QSE_AWK_SHADING)? nlocals:0)*/ nlcls, /*((awk->option&QSE_AWK_SHADING)? nlcls:0)*/
local.ptr, local.len); lcl.ptr, lcl.len);
if (n != QSE_LDA_NIL) if (n != QSE_LDA_NIL)
{ {
SETERRARG ( SETERRARG (
awk, QSE_AWK_EDUPLCL, awk->token.line, awk, QSE_AWK_EDUPLCL, awk->token.line,
local.ptr, local.len); lcl.ptr, lcl.len);
return QSE_NULL; return QSE_NULL;
} }
/* check if it conflicts with global variable names */ /* check if it conflicts with global variable names */
n = find_global (awk, local.ptr, local.len); n = find_gbl (awk, lcl.ptr, lcl.len);
if (n != QSE_LDA_NIL) if (n != QSE_LDA_NIL)
{ {
if (n < awk->tree.nbglobals) if (n < awk->tree.nbgbls)
{ {
/* conflicting with a static global variable */ /* conflicting with a static global variable */
SETERRARG ( SETERRARG (
awk, QSE_AWK_EDUPLCL, awk->token.line, awk, QSE_AWK_EDUPLCL, awk->token.line,
local.ptr, local.len); lcl.ptr, lcl.len);
return QSE_NULL; return QSE_NULL;
} }
@ -1789,22 +1789,22 @@ static qse_awk_t* collect_locals (
/* conflicting with a normal global variable */ /* conflicting with a normal global variable */
SETERRARG ( SETERRARG (
awk, QSE_AWK_EDUPLCL, awk->token.line, awk, QSE_AWK_EDUPLCL, awk->token.line,
local.ptr, local.len); lcl.ptr, lcl.len);
return QSE_NULL; return QSE_NULL;
} }
#endif #endif
} }
if (QSE_LDA_SIZE(awk->parse.locals) >= QSE_AWK_MAX_LOCALS) if (QSE_LDA_SIZE(awk->parse.lcls) >= QSE_AWK_MAX_LCLS)
{ {
SETERRLIN (awk, QSE_AWK_ELCLTM, awk->token.line); SETERRLIN (awk, QSE_AWK_ELCLTM, awk->token.line);
return QSE_NULL; return QSE_NULL;
} }
if (qse_lda_insert ( if (qse_lda_insert (
awk->parse.locals, awk->parse.lcls,
QSE_LDA_SIZE(awk->parse.locals), QSE_LDA_SIZE(awk->parse.lcls),
local.ptr, local.len) == QSE_LDA_NIL) lcl.ptr, lcl.len) == QSE_LDA_NIL)
{ {
SETERRLIN (awk, QSE_AWK_ENOMEM, awk->token.line); SETERRLIN (awk, QSE_AWK_ENOMEM, awk->token.line);
return QSE_NULL; return QSE_NULL;
@ -3296,7 +3296,7 @@ static qse_awk_nde_t* parse_primary_ident (qse_awk_t* awk, qse_size_t line)
if (nde == QSE_NULL) QSE_AWK_FREE (awk, name_dup); if (nde == QSE_NULL) QSE_AWK_FREE (awk, name_dup);
return (qse_awk_nde_t*)nde; return (qse_awk_nde_t*)nde;
} }
else if ((idxa = qse_lda_rsearch (awk->parse.locals, QSE_LDA_SIZE(awk->parse.locals), name_dup, name_len)) != QSE_LDA_NIL) else if ((idxa = qse_lda_rsearch (awk->parse.lcls, QSE_LDA_SIZE(awk->parse.lcls), name_dup, name_len)) != QSE_LDA_NIL)
{ {
/* local variable */ /* local variable */
@ -3319,7 +3319,7 @@ static qse_awk_nde_t* parse_primary_ident (qse_awk_t* awk, qse_size_t line)
return QSE_NULL; return QSE_NULL;
} }
nde->type = QSE_AWK_NDE_LOCAL; nde->type = QSE_AWK_NDE_LCL;
nde->line = line; nde->line = line;
nde->next = QSE_NULL; nde->next = QSE_NULL;
/*nde->id.name.ptr = QSE_NULL;*/ /*nde->id.name.ptr = QSE_NULL;*/
@ -3364,7 +3364,7 @@ static qse_awk_nde_t* parse_primary_ident (qse_awk_t* awk, qse_size_t line)
return (qse_awk_nde_t*)nde; return (qse_awk_nde_t*)nde;
} }
else if ((idxa = get_global (awk, name_dup, name_len)) != QSE_LDA_NIL) else if ((idxa = get_gbl (awk, name_dup, name_len)) != QSE_LDA_NIL)
{ {
/* global variable */ /* global variable */
@ -3387,7 +3387,7 @@ static qse_awk_nde_t* parse_primary_ident (qse_awk_t* awk, qse_size_t line)
return QSE_NULL; return QSE_NULL;
} }
nde->type = QSE_AWK_NDE_GLOBAL; nde->type = QSE_AWK_NDE_GBL;
nde->line = line; nde->line = line;
nde->next = QSE_NULL; nde->next = QSE_NULL;
/*nde->id.name = QSE_NULL;*/ /*nde->id.name = QSE_NULL;*/
@ -3570,10 +3570,15 @@ static qse_awk_nde_t* parse_hashidx (
} }
/* search the local variable list */ /* search the local variable list */
idxa = qse_lda_rsearch (awk->parse.locals, QSE_LDA_SIZE(awk->parse.locals), name, name_len); idxa = qse_lda_rsearch (
awk->parse.lcls,
QSE_LDA_SIZE(awk->parse.lcls),
name,
name_len
);
if (idxa != QSE_LDA_NIL) if (idxa != QSE_LDA_NIL)
{ {
nde->type = QSE_AWK_NDE_LOCALIDX; nde->type = QSE_AWK_NDE_LCLIDX;
nde->line = line; nde->line = line;
nde->next = QSE_NULL; nde->next = QSE_NULL;
/*nde->id.name = QSE_NULL; */ /*nde->id.name = QSE_NULL; */
@ -3602,10 +3607,10 @@ static qse_awk_nde_t* parse_hashidx (
} }
/* gets the global variable index */ /* gets the global variable index */
idxa = get_global (awk, name, name_len); idxa = get_gbl (awk, name, name_len);
if (idxa != QSE_LDA_NIL) if (idxa != QSE_LDA_NIL)
{ {
nde->type = QSE_AWK_NDE_GLOBALIDX; nde->type = QSE_AWK_NDE_GBLIDX;
nde->line = line; nde->line = line;
nde->next = QSE_NULL; nde->next = QSE_NULL;
/*nde->id.name = QSE_NULL;*/ /*nde->id.name = QSE_NULL;*/
@ -5597,20 +5602,20 @@ static int assign_to_opcode (qse_awk_t* awk)
static int is_plain_var (qse_awk_nde_t* nde) static int is_plain_var (qse_awk_nde_t* nde)
{ {
return nde->type == QSE_AWK_NDE_GLOBAL || return nde->type == QSE_AWK_NDE_GBL ||
nde->type == QSE_AWK_NDE_LOCAL || nde->type == QSE_AWK_NDE_LCL ||
nde->type == QSE_AWK_NDE_ARG || nde->type == QSE_AWK_NDE_ARG ||
nde->type == QSE_AWK_NDE_NAMED; nde->type == QSE_AWK_NDE_NAMED;
} }
static int is_var (qse_awk_nde_t* nde) static int is_var (qse_awk_nde_t* nde)
{ {
return nde->type == QSE_AWK_NDE_GLOBAL || return nde->type == QSE_AWK_NDE_GBL ||
nde->type == QSE_AWK_NDE_LOCAL || nde->type == QSE_AWK_NDE_LCL ||
nde->type == QSE_AWK_NDE_ARG || nde->type == QSE_AWK_NDE_ARG ||
nde->type == QSE_AWK_NDE_NAMED || nde->type == QSE_AWK_NDE_NAMED ||
nde->type == QSE_AWK_NDE_GLOBALIDX || nde->type == QSE_AWK_NDE_GBLIDX ||
nde->type == QSE_AWK_NDE_LOCALIDX || nde->type == QSE_AWK_NDE_LCLIDX ||
nde->type == QSE_AWK_NDE_ARGIDX || nde->type == QSE_AWK_NDE_ARGIDX ||
nde->type == QSE_AWK_NDE_NAMEDIDX; nde->type == QSE_AWK_NDE_NAMEDIDX;
} }
@ -5666,11 +5671,11 @@ static int deparse (qse_awk_t* awk)
#define EXIT_DEPARSE() do { n = -1; goto exit_deparse; } while(0) #define EXIT_DEPARSE() do { n = -1; goto exit_deparse; } while(0)
if (awk->tree.nglobals > awk->tree.nbglobals) if (awk->tree.ngbls > awk->tree.nbgbls)
{ {
qse_size_t i, len; qse_size_t i, len;
QSE_ASSERT (awk->tree.nglobals > 0); QSE_ASSERT (awk->tree.ngbls > 0);
qse_awk_getkw (awk, KW_GLOBAL, &kw); qse_awk_getkw (awk, KW_GLOBAL, &kw);
if (qse_awk_putsrcstrx(awk,kw.ptr,kw.len) == -1) if (qse_awk_putsrcstrx(awk,kw.ptr,kw.len) == -1)
@ -5682,7 +5687,7 @@ static int deparse (qse_awk_t* awk)
EXIT_DEPARSE (); EXIT_DEPARSE ();
} }
for (i = awk->tree.nbglobals; i < awk->tree.nglobals - 1; i++) for (i = awk->tree.nbgbls; i < awk->tree.ngbls - 1; i++)
{ {
if ((awk->option & QSE_AWK_EXPLICIT) && if ((awk->option & QSE_AWK_EXPLICIT) &&
!(awk->option & QSE_AWK_IMPLICIT)) !(awk->option & QSE_AWK_IMPLICIT))
@ -5690,8 +5695,8 @@ static int deparse (qse_awk_t* awk)
/* use the actual name if no named variable /* use the actual name if no named variable
* is allowed */ * is allowed */
if (qse_awk_putsrcstrx (awk, if (qse_awk_putsrcstrx (awk,
QSE_LDA_DPTR(awk->parse.globals,i), QSE_LDA_DPTR(awk->parse.gbls,i),
QSE_LDA_DLEN(awk->parse.globals,i)) == -1) QSE_LDA_DLEN(awk->parse.gbls,i)) == -1)
{ {
EXIT_DEPARSE (); EXIT_DEPARSE ();
} }
@ -5715,8 +5720,8 @@ static int deparse (qse_awk_t* awk)
!(awk->option & QSE_AWK_IMPLICIT)) !(awk->option & QSE_AWK_IMPLICIT))
{ {
if (qse_awk_putsrcstrx (awk, if (qse_awk_putsrcstrx (awk,
QSE_LDA_DPTR(awk->parse.globals,i), QSE_LDA_DPTR(awk->parse.gbls,i),
QSE_LDA_DLEN(awk->parse.globals,i)) == -1) QSE_LDA_DLEN(awk->parse.gbls,i)) == -1)
{ {
EXIT_DEPARSE (); EXIT_DEPARSE ();
} }

View File

@ -55,12 +55,12 @@ int qse_awk_putsrcstr (qse_awk_t* awk, const qse_char_t* str);
int qse_awk_putsrcstrx ( int qse_awk_putsrcstrx (
qse_awk_t* awk, const qse_char_t* str, qse_size_t len); qse_awk_t* awk, const qse_char_t* str, qse_size_t len);
const qse_char_t* qse_awk_rtx_getglobalname ( const qse_char_t* qse_awk_rtx_getgblname (
qse_awk_t* awk, qse_size_t idx, qse_size_t* len); qse_awk_t* awk, qse_size_t idx, qse_size_t* len);
qse_cstr_t* qse_awk_getkw (qse_awk_t* awk, int id, qse_cstr_t* s); qse_cstr_t* qse_awk_getkw (qse_awk_t* awk, int id, qse_cstr_t* s);
int qse_awk_initglobals (qse_awk_t* awk); int qse_awk_initgbls (qse_awk_t* awk);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -107,7 +107,7 @@ static int split_record (qse_awk_rtx_t* run)
QSE_ASSERT (run->inrec.nflds == 0); QSE_ASSERT (run->inrec.nflds == 0);
/* get FS */ /* get FS */
fs = qse_awk_rtx_getglobal (run, QSE_AWK_GLOBAL_FS); fs = qse_awk_rtx_getgbl (run, QSE_AWK_GBL_FS);
if (fs->type == QSE_AWK_VAL_NIL) if (fs->type == QSE_AWK_VAL_NIL)
{ {
fs_ptr = QSE_T(" "); fs_ptr = QSE_T(" ");
@ -143,7 +143,7 @@ static int split_record (qse_awk_rtx_t* run)
else else
{ {
p = qse_awk_strxntokbyrex (run, p, len, p = qse_awk_strxntokbyrex (run, p, len,
run->global.fs, &tok, &tok_len, &errnum); run->gbl.fs, &tok, &tok_len, &errnum);
if (p == QSE_NULL && errnum != QSE_AWK_ENOERR) if (p == QSE_NULL && errnum != QSE_AWK_ENOERR)
{ {
if (fs_free != QSE_NULL) if (fs_free != QSE_NULL)
@ -200,7 +200,7 @@ static int split_record (qse_awk_rtx_t* run)
else else
{ {
p = qse_awk_strxntokbyrex (run, p, len, p = qse_awk_strxntokbyrex (run, p, len,
run->global.fs, &tok, &tok_len, &errnum); run->gbl.fs, &tok, &tok_len, &errnum);
if (p == QSE_NULL && errnum != QSE_AWK_ENOERR) if (p == QSE_NULL && errnum != QSE_AWK_ENOERR)
{ {
if (fs_free != QSE_NULL) if (fs_free != QSE_NULL)
@ -237,7 +237,7 @@ static int split_record (qse_awk_rtx_t* run)
if (v == QSE_NULL) return -1; if (v == QSE_NULL) return -1;
qse_awk_rtx_refupval (run, v); qse_awk_rtx_refupval (run, v);
if (qse_awk_rtx_setglobal (run, QSE_AWK_GLOBAL_NF, v) == -1) if (qse_awk_rtx_setgbl (run, QSE_AWK_GBL_NF, v) == -1)
{ {
qse_awk_rtx_refdownval (run, v); qse_awk_rtx_refdownval (run, v);
return -1; return -1;
@ -270,8 +270,8 @@ int qse_awk_rtx_clrrec (qse_awk_rtx_t* run, qse_bool_t skip_inrec_line)
} }
run->inrec.nflds = 0; run->inrec.nflds = 0;
if (qse_awk_rtx_setglobal ( if (qse_awk_rtx_setgbl (
run, QSE_AWK_GLOBAL_NF, qse_awk_val_zero) == -1) run, QSE_AWK_GBL_NF, qse_awk_val_zero) == -1)
{ {
/* first of all, this should never happen. /* first of all, this should never happen.
* if it happened, it would return an error * if it happened, it would return an error
@ -352,8 +352,8 @@ static int recomp_record_fields (
{ {
if (qse_str_ncat ( if (qse_str_ncat (
&run->inrec.line, &run->inrec.line,
run->global.ofs.ptr, run->gbl.ofs.ptr,
run->global.ofs.len) == (qse_size_t)-1) run->gbl.ofs.len) == (qse_size_t)-1)
{ {
qse_awk_rtx_seterror ( qse_awk_rtx_seterror (
run, QSE_AWK_ENOMEM, 0, QSE_NULL, 0); run, QSE_AWK_ENOMEM, 0, QSE_NULL, 0);
@ -432,7 +432,7 @@ static int recomp_record_fields (
} }
} }
v = qse_awk_rtx_getglobal (run, QSE_AWK_GLOBAL_NF); v = qse_awk_rtx_getgbl (run, QSE_AWK_GBL_NF);
QSE_ASSERT (v->type == QSE_AWK_VAL_INT); QSE_ASSERT (v->type == QSE_AWK_VAL_INT);
if (((qse_awk_val_int_t*)v)->val != max) if (((qse_awk_val_int_t*)v)->val != max)
@ -441,7 +441,7 @@ static int recomp_record_fields (
if (v == QSE_NULL) return -1; if (v == QSE_NULL) return -1;
qse_awk_rtx_refupval (run, v); qse_awk_rtx_refupval (run, v);
if (qse_awk_rtx_setglobal (run, QSE_AWK_GLOBAL_NF, v) == -1) if (qse_awk_rtx_setgbl (run, QSE_AWK_GBL_NF, v) == -1)
{ {
qse_awk_rtx_refdownval (run, v); qse_awk_rtx_refdownval (run, v);
return -1; return -1;

File diff suppressed because it is too large Load Diff

View File

@ -671,8 +671,8 @@ static qse_ssize_t awk_eio_console (
return -1; return -1;
} }
if (qse_awk_rtx_setglobal ( if (qse_awk_rtx_setgbl (
epa->rtx, QSE_AWK_GLOBAL_FNR, qse_awk_val_zero) == -1) epa->rtx, QSE_AWK_GBL_FNR, qse_awk_val_zero) == -1)
{ {
/* need to reset FNR */ /* need to reset FNR */
qse_sio_close (fp); qse_sio_close (fp);
@ -1184,24 +1184,24 @@ skip_system:
return 0; return 0;
} }
#define ADD_FUNC(awk,name,min,max,fnc) \ #define ADDFNC(awk,name,min,max,fnc) \
if (qse_awk_addfnc (\ if (qse_awk_addfnc (\
(awk), (name), qse_strlen(name), \ (awk), (name), qse_strlen(name), \
0, (min), (max), QSE_NULL, (fnc)) == QSE_NULL) return -1; 0, (min), (max), QSE_NULL, (fnc)) == QSE_NULL) return -1;
static int add_functions (qse_awk_t* awk) static int add_functions (qse_awk_t* awk)
{ {
ADD_FUNC (awk, QSE_T("sin"), 1, 1, fnc_sin); ADDFNC (awk, QSE_T("sin"), 1, 1, fnc_sin);
ADD_FUNC (awk, QSE_T("cos"), 1, 1, fnc_cos); ADDFNC (awk, QSE_T("cos"), 1, 1, fnc_cos);
ADD_FUNC (awk, QSE_T("tan"), 1, 1, fnc_tan); ADDFNC (awk, QSE_T("tan"), 1, 1, fnc_tan);
ADD_FUNC (awk, QSE_T("atan"), 1, 1, fnc_atan); ADDFNC (awk, QSE_T("atan"), 1, 1, fnc_atan);
ADD_FUNC (awk, QSE_T("atan2"), 2, 2, fnc_atan2); ADDFNC (awk, QSE_T("atan2"), 2, 2, fnc_atan2);
ADD_FUNC (awk, QSE_T("log"), 1, 1, fnc_log); ADDFNC (awk, QSE_T("log"), 1, 1, fnc_log);
ADD_FUNC (awk, QSE_T("exp"), 1, 1, fnc_exp); ADDFNC (awk, QSE_T("exp"), 1, 1, fnc_exp);
ADD_FUNC (awk, QSE_T("sqrt"), 1, 1, fnc_sqrt); ADDFNC (awk, QSE_T("sqrt"), 1, 1, fnc_sqrt);
ADD_FUNC (awk, QSE_T("int"), 1, 1, fnc_int); ADDFNC (awk, QSE_T("int"), 1, 1, fnc_int);
ADD_FUNC (awk, QSE_T("rand"), 0, 0, fnc_rand); ADDFNC (awk, QSE_T("rand"), 0, 0, fnc_rand);
ADD_FUNC (awk, QSE_T("srand"), 0, 1, fnc_srand); ADDFNC (awk, QSE_T("srand"), 0, 1, fnc_srand);
ADD_FUNC (awk, QSE_T("system"), 1, 1, fnc_system); ADDFNC (awk, QSE_T("system"), 1, 1, fnc_system);
return 0; return 0;
} }

View File

@ -401,7 +401,7 @@ static int print_expression (qse_awk_t* awk, qse_awk_nde_t* nde)
break; break;
} }
case QSE_AWK_NDE_GLOBAL: case QSE_AWK_NDE_GBL:
{ {
qse_awk_nde_var_t* px = (qse_awk_nde_var_t*)nde; qse_awk_nde_var_t* px = (qse_awk_nde_var_t*)nde;
@ -415,7 +415,7 @@ static int print_expression (qse_awk_t* awk, qse_awk_nde_t* nde)
* use the actual name */ * use the actual name */
PUT_SRCSTRX (awk, px->id.name.ptr, px->id.name.len); PUT_SRCSTRX (awk, px->id.name.ptr, px->id.name.len);
} }
else if (px->id.idxa < awk->tree.nbglobals) else if (px->id.idxa < awk->tree.nbgbls)
{ {
/* static global variables */ /* static global variables */
PUT_SRCSTRX (awk, px->id.name.ptr, px->id.name.len); PUT_SRCSTRX (awk, px->id.name.ptr, px->id.name.len);
@ -440,7 +440,7 @@ static int print_expression (qse_awk_t* awk, qse_awk_nde_t* nde)
break; break;
} }
case QSE_AWK_NDE_GLOBALIDX: case QSE_AWK_NDE_GBLIDX:
{ {
qse_awk_nde_var_t* px = (qse_awk_nde_var_t*)nde; qse_awk_nde_var_t* px = (qse_awk_nde_var_t*)nde;
@ -453,7 +453,7 @@ static int print_expression (qse_awk_t* awk, qse_awk_nde_t* nde)
* use the actual name */ * use the actual name */
PUT_SRCSTRX (awk, px->id.name.ptr, px->id.name.len); PUT_SRCSTRX (awk, px->id.name.ptr, px->id.name.len);
} }
else if (px->id.idxa < awk->tree.nbglobals) else if (px->id.idxa < awk->tree.nbgbls)
{ {
/* static global variables */ /* static global variables */
PUT_SRCSTRX (awk, px->id.name.ptr, px->id.name.len); PUT_SRCSTRX (awk, px->id.name.ptr, px->id.name.len);
@ -482,7 +482,7 @@ static int print_expression (qse_awk_t* awk, qse_awk_nde_t* nde)
break; break;
} }
case QSE_AWK_NDE_LOCAL: case QSE_AWK_NDE_LCL:
{ {
qse_size_t n; qse_size_t n;
qse_awk_nde_var_t* px = (qse_awk_nde_var_t*)nde; qse_awk_nde_var_t* px = (qse_awk_nde_var_t*)nde;
@ -503,7 +503,7 @@ static int print_expression (qse_awk_t* awk, qse_awk_nde_t* nde)
break; break;
} }
case QSE_AWK_NDE_LOCALIDX: case QSE_AWK_NDE_LCLIDX:
{ {
qse_size_t n; qse_size_t n;
qse_awk_nde_var_t* px = (qse_awk_nde_var_t*)nde; qse_awk_nde_var_t* px = (qse_awk_nde_var_t*)nde;
@ -636,14 +636,14 @@ static int print_statement (qse_awk_t* awk, qse_awk_nde_t* p, int depth)
PUT_SRCSTR (awk, QSE_T("{")); PUT_SRCSTR (awk, QSE_T("{"));
PUT_NEWLINE (awk); PUT_NEWLINE (awk);
if (px->nlocals > 0) if (px->nlcls > 0)
{ {
PRINT_TABS (awk, depth + 1); PRINT_TABS (awk, depth + 1);
qse_awk_getkw (awk, KW_LOCAL, &kw); qse_awk_getkw (awk, KW_LOCAL, &kw);
PUT_SRCSTRX (awk, kw.ptr, kw.len); PUT_SRCSTRX (awk, kw.ptr, kw.len);
PUT_SRCSTR (awk, QSE_T(" ")); PUT_SRCSTR (awk, QSE_T(" "));
for (i = 0; i < px->nlocals - 1; i++) for (i = 0; i < px->nlcls - 1; i++)
{ {
PUT_SRCSTR (awk, QSE_T("__l")); PUT_SRCSTR (awk, QSE_T("__l"));
n = qse_awk_longtostr ( n = qse_awk_longtostr (
@ -1223,8 +1223,8 @@ void qse_awk_clrpt (qse_awk_t* awk, qse_awk_nde_t* tree)
} }
case QSE_AWK_NDE_NAMED: case QSE_AWK_NDE_NAMED:
case QSE_AWK_NDE_GLOBAL: case QSE_AWK_NDE_GBL:
case QSE_AWK_NDE_LOCAL: case QSE_AWK_NDE_LCL:
case QSE_AWK_NDE_ARG: case QSE_AWK_NDE_ARG:
{ {
qse_awk_nde_var_t* px = (qse_awk_nde_var_t*)p; qse_awk_nde_var_t* px = (qse_awk_nde_var_t*)p;
@ -1236,8 +1236,8 @@ void qse_awk_clrpt (qse_awk_t* awk, qse_awk_nde_t* tree)
} }
case QSE_AWK_NDE_NAMEDIDX: case QSE_AWK_NDE_NAMEDIDX:
case QSE_AWK_NDE_GLOBALIDX: case QSE_AWK_NDE_GBLIDX:
case QSE_AWK_NDE_LOCALIDX: case QSE_AWK_NDE_LCLIDX:
case QSE_AWK_NDE_ARGIDX: case QSE_AWK_NDE_ARGIDX:
{ {
qse_awk_nde_var_t* px = (qse_awk_nde_var_t*)p; qse_awk_nde_var_t* px = (qse_awk_nde_var_t*)p;

View File

@ -63,12 +63,12 @@ enum qse_awk_nde_type_t
* to change eval_incpre and eval_incpst in run.c as well as * to change eval_incpre and eval_incpst in run.c as well as
* QSE_AWK_VAL_REF_XXX in awk.h */ * QSE_AWK_VAL_REF_XXX in awk.h */
QSE_AWK_NDE_NAMED, QSE_AWK_NDE_NAMED,
QSE_AWK_NDE_GLOBAL, QSE_AWK_NDE_GBL,
QSE_AWK_NDE_LOCAL, QSE_AWK_NDE_LCL,
QSE_AWK_NDE_ARG, QSE_AWK_NDE_ARG,
QSE_AWK_NDE_NAMEDIDX, QSE_AWK_NDE_NAMEDIDX,
QSE_AWK_NDE_GLOBALIDX, QSE_AWK_NDE_GBLIDX,
QSE_AWK_NDE_LOCALIDX, QSE_AWK_NDE_LCLIDX,
QSE_AWK_NDE_ARGIDX, QSE_AWK_NDE_ARGIDX,
QSE_AWK_NDE_POS, QSE_AWK_NDE_POS,
/* ---------------------------------- */ /* ---------------------------------- */
@ -162,7 +162,7 @@ struct qse_awk_nde_t
struct qse_awk_nde_blk_t struct qse_awk_nde_blk_t
{ {
QSE_AWK_NDE_HDR; QSE_AWK_NDE_HDR;
qse_size_t nlocals; qse_size_t nlcls;
qse_awk_nde_t* body; qse_awk_nde_t* body;
}; };
@ -243,10 +243,10 @@ struct qse_awk_nde_rex_t
void* code; void* code;
}; };
/* QSE_AWK_NDE_NAMED, QSE_AWK_NDE_GLOBAL, /* QSE_AWK_NDE_NAMED, QSE_AWK_NDE_GBL,
* QSE_AWK_NDE_LOCAL, QSE_AWK_NDE_ARG * QSE_AWK_NDE_LCL, QSE_AWK_NDE_ARG
* QSE_AWK_NDE_NAMEDIDX, QSE_AWK_NDE_GLOBALIDX, * QSE_AWK_NDE_NAMEDIDX, QSE_AWK_NDE_GBLIDX,
* QSE_AWK_NDE_LOCALIDX, QSE_AWK_NDE_ARGIDX */ * QSE_AWK_NDE_LCLIDX, QSE_AWK_NDE_ARGIDX */
struct qse_awk_nde_var_t struct qse_awk_nde_var_t
{ {
QSE_AWK_NDE_HDR; QSE_AWK_NDE_HDR;

View File

@ -1002,13 +1002,13 @@ static qse_char_t* val_real_to_str (
if (opt & QSE_AWK_VALTOSTR_PRINT) if (opt & QSE_AWK_VALTOSTR_PRINT)
{ {
tmp = run->global.ofmt.ptr; tmp = run->gbl.ofmt.ptr;
tmp_len = run->global.ofmt.len; tmp_len = run->gbl.ofmt.len;
} }
else else
{ {
tmp = run->global.convfmt.ptr; tmp = run->gbl.convfmt.ptr;
tmp_len = run->global.convfmt.len; tmp_len = run->gbl.convfmt.len;
} }
if (qse_str_init (&out, run->awk->mmgr, 256) == QSE_NULL) if (qse_str_init (&out, run->awk->mmgr, 256) == QSE_NULL)