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.
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;
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);
}

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:
.svn
headertypes:
o "Overview" robo_overview 0
b "Callbacks" robo_callbacks 1
o "Overview" robo_overview 10
options:
--nosort
--cmode
--nopre
--documenttitle "QSE"
--source_line_numbers

View File

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

View File

@ -24,7 +24,7 @@
#include <qse/cmn/map.h>
#include <qse/cmn/str.h>
/****o* awk/awk interpreter
/****o* AWK/AWK Interpreter
* DESCRIPTION
* The library includes an AWK interpreter that can be embedded into other
* 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;
/******/
/****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_val_t qse_awk_val_t;
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
};
enum qse_awk_global_id_t
enum qse_awk_gbl_id_t
{
/* 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 */
QSE_AWK_GLOBAL_ARGC,
QSE_AWK_GLOBAL_ARGV,
QSE_AWK_GLOBAL_CONVFMT,
QSE_AWK_GLOBAL_FILENAME,
QSE_AWK_GLOBAL_FNR,
QSE_AWK_GLOBAL_FS,
QSE_AWK_GLOBAL_IGNORECASE,
QSE_AWK_GLOBAL_NF,
QSE_AWK_GLOBAL_NR,
QSE_AWK_GLOBAL_OFILENAME,
QSE_AWK_GLOBAL_OFMT,
QSE_AWK_GLOBAL_OFS,
QSE_AWK_GLOBAL_ORS,
QSE_AWK_GLOBAL_RLENGTH,
QSE_AWK_GLOBAL_RS,
QSE_AWK_GLOBAL_RSTART,
QSE_AWK_GLOBAL_SUBSEP,
QSE_AWK_GBL_ARGC,
QSE_AWK_GBL_ARGV,
QSE_AWK_GBL_CONVFMT,
QSE_AWK_GBL_FILENAME,
QSE_AWK_GBL_FNR,
QSE_AWK_GBL_FS,
QSE_AWK_GBL_IGNORECASE,
QSE_AWK_GBL_NF,
QSE_AWK_GBL_NR,
QSE_AWK_GBL_OFILENAME,
QSE_AWK_GBL_OFMT,
QSE_AWK_GBL_OFS,
QSE_AWK_GBL_ORS,
QSE_AWK_GBL_RLENGTH,
QSE_AWK_GBL_RS,
QSE_AWK_GBL_RSTART,
QSE_AWK_GBL_SUBSEP,
/* these are not not the actual IDs and are used internally only
* Make sure you update these values properly if you add more
* ID definitions, however */
QSE_AWK_MIN_GLOBAL_ID = QSE_AWK_GLOBAL_ARGC,
QSE_AWK_MAX_GLOBAL_ID = QSE_AWK_GLOBAL_SUBSEP
QSE_AWK_MIN_GBL_ID = QSE_AWK_GBL_ARGC,
QSE_AWK_MAX_GBL_ID = QSE_AWK_GBL_SUBSEP
};
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
* in tree.h */
QSE_AWK_VAL_REF_NAMED,
QSE_AWK_VAL_REF_GLOBAL,
QSE_AWK_VAL_REF_LOCAL,
QSE_AWK_VAL_REF_GBL,
QSE_AWK_VAL_REF_LCL,
QSE_AWK_VAL_REF_ARG,
QSE_AWK_VAL_REF_NAMEDIDX,
QSE_AWK_VAL_REF_GLOBALIDX,
QSE_AWK_VAL_REF_LOCALIDX,
QSE_AWK_VAL_REF_GBLIDX,
QSE_AWK_VAL_REF_LCLIDX,
QSE_AWK_VAL_REF_ARGIDX,
QSE_AWK_VAL_REF_POS
};
@ -618,7 +632,7 @@ extern qse_awk_val_t* qse_awk_val_zero;
/** represents a numeric value 1 */
extern qse_awk_val_t* qse_awk_val_one;
/****f* awk/qse_awk_open
/****f* AWK/qse_awk_open
* NAME
* qse_awk_open - create an awk object
* DESCRIPTION
@ -637,7 +651,7 @@ qse_awk_t* qse_awk_open (
);
/******/
/****f* awk/qse_awk_close
/****f* AWK/qse_awk_close
* NAME
* qse_awk_close - destroy an awk object
* DESCRIPTION
@ -653,7 +667,7 @@ int qse_awk_close (
);
/******/
/****f* awk/qse_awk_getmmgr
/****f* AWK/qse_awk_getmmgr
* NAME
* qse_awk_getmmgr - get the memory manager
* DESCRIPTION
@ -665,7 +679,7 @@ qse_mmgr_t* qse_awk_getmmgr (
);
/******/
/****f* awk/qse_awk_setmmgr
/****f* AWK/qse_awk_setmmgr
* NAME
* qse_awk_setmmgr - set the extension
* DESCRIPTION
@ -680,7 +694,7 @@ void qse_awk_setmmgr (
);
/******/
/****f* awk/qse_awk_getxtn
/****f* AWK/qse_awk_getxtn
* NAME
* qse_awk_getxtn - get the extension
* DESCRIPTION
@ -695,7 +709,7 @@ void* qse_awk_getxtn (
);
/******/
/****f* awk/qse_awk_getccls
/****f* AWK/qse_awk_getccls
* NAME
* qse_awk_getccls - get a character classifier
* SYNOPSIS
@ -705,7 +719,7 @@ qse_ccls_t* qse_awk_getccls (
);
/******/
/****f* awk/qse_awk_setccls
/****f* AWK/qse_awk_setccls
* NAME
* qse_awk_setccls - set the character classfier
* SYNOPSIS
@ -716,7 +730,7 @@ void qse_awk_setccls (
);
/******/
/****f* awk/qse_awk_getprmfns
/****f* AWK/qse_awk_getprmfns
* NAME
* qse_awk_getprmfns - get primitive functions
* SYNOPSIS
@ -726,7 +740,7 @@ qse_awk_prmfns_t* qse_awk_getprmfns (
);
/******/
/****f* awk/qse_awk_setprmfns
/****f* AWK/qse_awk_setprmfns
* NAME
* qse_awk_setprmfns - set primitive functions
* SYNOPSIS
@ -737,7 +751,7 @@ void qse_awk_setprmfns (
);
/******/
/****f* awk/qse_awk_clear
/****f* AWK/qse_awk_clear
* NAME
* qse_awk_clear - clear a qse_awk_t object
* DESCRIPTION
@ -753,7 +767,7 @@ int qse_awk_clear (
);
/******/
/****f* awk/qse_awk_geterrstr
/****f* AWK/qse_awk_geterrstr
* NAME
* qse_awk_geterrstr - get a format string for an error
* DESCRIPTION
@ -767,7 +781,7 @@ const qse_char_t* qse_awk_geterrstr (
);
/******/
/****f* awk/qse_awk_seterrstr
/****f* AWK/qse_awk_seterrstr
* NAME
* qse_awk_geterrstr - set a format string for an error
* DESCRIPTION
@ -886,34 +900,74 @@ int qse_awk_setword (
qse_size_t nlen
);
/****f* awk/qse_awk_addglobal
/****f* AWK/qse_awk_addgbl
* NAME
* qse_awk_addglobal - add an intrinsic global variable.
* qse_awk_addgbl - add an intrinsic global variable.
* 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.
* SYNOPSIS
*/
int qse_awk_addglobal (
int qse_awk_addgbl (
qse_awk_t* awk,
const qse_char_t* name,
qse_size_t len
);
/******/
/****f* awk/qse_awk_delglobal
/****f* AWK/qse_awk_delgbl
* NAME
* qse_awk_delglobal - delete an instrinsic global variable.
* qse_awk_delgbl - delete an instrinsic global variable.
* SYNOPSIS
*/
int qse_awk_delglobal (
int qse_awk_delgbl (
qse_awk_t* awk,
const qse_char_t* name,
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
* qse_awk_parse - parse source code
* SYNOPSIS
@ -924,43 +978,7 @@ int qse_awk_parse (
);
/******/
/****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
/****f* AWK/qse_awk_run
* NAME
* qse_awk_run - execute a parsed program
* DESCRIPTION
@ -987,29 +1005,126 @@ int qse_awk_run (
);
/******/
/* functions to manipulate intrinsic functions */
void* qse_awk_addfnc (
/****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 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)
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 */
);
/******/
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,
const qse_char_t* name,
qse_size_t len
qse_char_t** icf /* input console files */,
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_awk_t* awk
qse_real_t qse_awk_strxtoreal (
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
* qse_awk_stopall - stop all runtime contexts
* DESCRIPTION
@ -1022,7 +1137,7 @@ void qse_awk_stopall (
);
/******/
/****f* awk/qse_awk_shouldstop
/****f* AWK/qse_awk_shouldstop
* NAME
* qse_awk_shouldstop - test if qse_awk_rtx_stop() is called
* 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
* qse_awk_rtx_stop - stop a runtime context
* DESCRIPTION
@ -1045,7 +1160,7 @@ void qse_awk_rtx_stop (
);
/******/
/****f* awk/qse_awk_rtx_getnargs
/****f* AWK/qse_awk_rtx_getnargs
* NAME
* qse_awk_rtx_getnargs - get the number of arguments passed to qse_awk_run()
* 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
* qse_awk_rtx_getarg - get an argument passed to qse_awk_run
* 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
* qse_awk_rtx_getglobal - gets the value of a global variable
* qse_awk_rtx_getgbl - gets the value of a global variable
* INPUTS
* * rtx - a runtime context
* * 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
* The pointer to a value is returned. This function never fails
* so long as the ID is valid. Otherwise, you may fall into trouble.
* SYNOPSIS
*/
qse_awk_val_t* qse_awk_rtx_getglobal (
qse_awk_val_t* qse_awk_rtx_getgbl (
qse_awk_rtx_t* rtx,
int id
);
/******/
/****f* awk/qse_awk_rtx_setglobal
/****f* AWK/qse_awk_rtx_setgbl
* NAME
* qse_awk_rtx_setglobal - set the value of a global variable
* qse_awk_rtx_setgbl - set the value of a global variable
* SYNOPSIS
*/
int qse_awk_rtx_setglobal (
int qse_awk_rtx_setgbl (
qse_awk_rtx_t* rtx,
int id,
qse_awk_val_t* val
);
/******/
/****f* awk/qse_awk_rtx_setretval
/****f* AWK/qse_awk_rtx_setretval
* NAME
* qse_awk_rtx_setretval - set the return value
* DESCRIPTION
@ -1114,7 +1229,7 @@ void qse_awk_rtx_setretval (
);
/******/
/****f* awk/qse_awk_rtx_setfilename
/****f* AWK/qse_awk_rtx_setfilename
* NAME
* qse_awk_rtx_setfilename - set FILENAME
* SYNOPSIS
@ -1126,7 +1241,7 @@ int qse_awk_rtx_setfilename (
);
/******/
/****f* awk/qse_awk_rtx_setofilename
/****f* AWK/qse_awk_rtx_setofilename
* NAME
* qse_awk_rtx_setofilename - set OFILENAME
* SYNOPSIS
@ -1138,7 +1253,7 @@ int qse_awk_rtx_setofilename (
);
/******/
/****f* awk/qse_awk_rtx_getawk
/****f* AWK/qse_awk_rtx_getawk
* NAME
* qse_awk_rtx_getawk - get the owning awk object
* 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
* qse_awk_rtx_getmmgr - get the memory manager of a runtime context
* 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
* qse_awk_rtx_getdata - get the user-specified data for a runtime context
* SYNOPSIS
@ -1168,7 +1283,7 @@ void* qse_awk_rtx_getdata (
);
/******/
/****f* awk/qse_awk_rtx_getnvmap
/****f* AWK/qse_awk_rtx_getnvmap
* NAME
* qse_awk_rtx_getnvmap - get the map of named variables
* 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
* 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
*/
int qse_awk_rtx_geterrnum (
@ -1237,91 +1352,6 @@ int qse_awk_rtx_setrec (
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 */
qse_awk_val_t* qse_awk_rtx_makeintval (
qse_awk_rtx_t* rtx,
@ -1413,7 +1443,7 @@ qse_char_t* qse_awk_rtx_valtostr (
qse_size_t* len
);
/****f* awk/qse_awk_rtx_valtonum
/****f* AWK/qse_awk_rtx_valtonum
* NAME
* qse_awk_rtx_valtonum - convert a value to a number
* DESCRIPTION
@ -1443,7 +1473,7 @@ int qse_awk_rtx_valtonum (
);
/******/
/****f* awk/qse_awk_rtx_strtonum
/****f* AWK/qse_awk_rtx_strtonum
* NAME
* qse_awk_rtx_strtonum - convert a string to a number
* SYNOPSIS

View File

@ -68,15 +68,13 @@ qse_size_t qse_mblen (
qse_size_t mblen
);
/****f* qse.cmn.chr/qse_mbtowc
/****f* Common/qse_mbtowc
* NAME
* qse_mbtowc - convert a multibyte sequence to a wide character.
*
* RETURN
* The qse_mbtowc() function returns 0 if an invalid multibyte sequence is
* detected, mblen + 1 if the sequence is incomplete. It returns the number
* of bytes processed to form a wide character.
*
* SYNOPSIS
*/
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
* qse_wctomb - convert a wide character to a multibyte sequence
*
* RETURN
* 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.
* On successful conversion, it returns the number of bytes in the sequence.
*
* SYNOPSIS
*/
qse_size_t qse_wctomb (

View File

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

View File

@ -22,12 +22,12 @@
#include <qse/types.h>
#include <qse/macros.h>
/****o* qse.cmn.lda/linear dynamic array
/****o* Common/linear dynamic array
* 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.
*
* #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
* 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
* qse_lda_freeer_t - define a node destruction callback
* 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
* 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
* 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
* 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 */
);
/****s* qse.cmn.lda/qse_lda_t
/****s* Common/qse_lda_t
* NAME
* qse_lda_t - define a linear dynamic array
*
@ -208,7 +208,7 @@ extern "C" {
QSE_DEFINE_COMMON_FUNCTIONS (lda)
/****f* qse.cmn.lda/qse_lda_open
/****f* Common/qse_lda_open
* NAME
* 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
* 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
* 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
* qse_lda_fini - deinitialize a linear dynamic array
*
@ -260,7 +260,7 @@ int qse_lda_getscale (
qse_lda_t* lda /* a lda */
);
/****f* qse.cmn.lda/qse_lda_setscale
/****f* Common/qse_lda_setscale
* NAME
* qse_lda_setscale - set the scale factor
*
@ -285,7 +285,7 @@ qse_lda_copier_t qse_lda_getcopier (
qse_lda_t* lda /* a lda */
);
/****f* qse.cmn.lda/qse_lda_setcopier
/****f* Common/qse_lda_setcopier
* NAME
* 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 */
);
/****f* qse.cmn.lda/qse_lda_setfreeer
/****f* Common/qse_lda_setfreeer
* NAME
* qse_lda_setfreeer - specify how to destroy an element
*
@ -390,7 +390,7 @@ qse_size_t qse_lda_update (
qse_size_t dlen
);
/****f* qse.cmn.lda/qse_lda_delete
/****f* Common/qse_lda_delete
* NAME
* 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
* qse_lda_uplete - delete data node
*

View File

@ -22,7 +22,7 @@
#include <qse/types.h>
#include <qse/macros.h>
/****o* qse.cmn.map/hash map
/****o* Common/Hash Map
* DESCRIPTION
* A hash map maintains buckets for key/value pairs with the same key hash
* 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_id_t qse_map_id_t;
/****b* qse.cmn.map/qse_map_copier_t
/****t* Common/qse_map_copier_t
* NAME
* qse_map_copier_t - define a pair contruction callback
* 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
* qse_map_freeer_t - define a key/value destruction callback
* SYNOPSIS
@ -80,7 +80,7 @@ typedef qse_size_t (*qse_map_hasher_t) (
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
* 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
* 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
* 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
* 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
* 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
* 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_INLINE ((qse_map_copier_t)2)
/****d* qse.cmn.map/QSE_MAP_SIZE
/****d* Common/QSE_MAP_SIZE
* NAME
* QSE_MAP_SIZE - get the number of pairs
* DESCRIPTION
@ -216,7 +216,7 @@ struct qse_map_t
#define QSE_MAP_SIZE(m) ((m)->size)
/*****/
/****d* qse.cmn.map/QSE_MAP_CAPA
/****d* Common/QSE_MAP_CAPA
* NAME
* QSE_MAP_CAPA - get the capacity of a map
*
@ -253,7 +253,7 @@ extern "C" {
QSE_DEFINE_COMMON_FUNCTIONS (map)
/****f* qse.cmn.map/qse_map_open
/****f* Common/qse_map_open
* NAME
* qse_map_open - creates a hash map
* DESCRIPTION
@ -280,7 +280,7 @@ qse_map_t* qse_map_open (
/******/
/****f* qse.cmn.map/qse_map_close
/****f* Common/qse_map_close
* NAME
* qse_map_close - destroy a hash map
* DESCRIPTION
@ -317,7 +317,7 @@ int qse_map_getscale (
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
* 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 */
);
/****f* qse.cmn.map/qse_map_setcopier
/****f* Common/qse_map_setcopier
* NAME
* 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 */
);
/****f* qse.cmn.map/qse_map_setfreeer
/****f* Common/qse_map_setfreeer
* NAME
* qse_map_setfreeer - specify how to destroy an element
*
@ -424,7 +424,7 @@ void qse_map_setsizer (
qse_map_sizer_t sizer
);
/****f* qse.cmn.map/qse_map_search
/****f* Common/qse_map_search
* NAME
* qse_map_search - find a pair with a matching key
* 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
* qse_map_upsert - update an existing pair or inesrt a new pair
* 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
* qse_map_insert - insert a new pair with a key and a value
* DESCRIPTION

View File

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

View File

@ -101,7 +101,7 @@ struct qse_pio_pin_t
qse_pio_t* self;
};
/****s* cmn/qse_pio_t
/****s* Common/qse_pio_t
* NAME
* qse_pio_t - define an pipe IO type
* SYNOPSIS
@ -128,7 +128,7 @@ extern "C" {
QSE_DEFINE_COMMON_FUNCTIONS (pio)
/****f* cmn/qse_pio_open
/****f* Common/qse_pio_open
* NAME
* 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
* 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
* 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
* qse_pio_fini - finalize pipes to a child process
*
@ -192,7 +192,7 @@ void qse_pio_setflags (
int op
);
/****f* cmn/qse_pio_geterrnum
/****f* Common/qse_pio_geterrnum
* NAME
* 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
* 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
* 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
* 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
* qse_pio_read - read data
* SYNOPSIS
@ -254,7 +254,7 @@ qse_ssize_t qse_pio_read (
);
/******/
/****f* cmn/qse_pio_write
/****f* Common/qse_pio_write
* NAME
* qse_pio_write - write data
* DESCRIPTION
@ -270,7 +270,7 @@ qse_ssize_t qse_pio_write (
);
/******/
/****f* cmn/qse_pio_flush
/****f* Common/qse_pio_flush
* NAME
* 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
* 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
* qse_pio_wait - wait for a child process
* DESCRIPTION
@ -315,7 +315,7 @@ int qse_pio_wait (
);
/******/
/****f* cmn/qse_pio_kill
/****f* Common/qse_pio_kill
* NAME
* qse_pio_kill - terminate the child process
* NOTES

View File

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

View File

@ -22,15 +22,15 @@
#include <qse/types.h>
#include <qse/macros.h>
/****o* qse.cmn.sll/singly linked list
/****o* Common/Singly Linked List
* DESCRIPTION
* <qse/cmn/sll.h> provides a singly linked list
* <qse/cmn/sll.h> provides a singly linked list.
*
* #include <qse/cmn/sll.h>
******
*/
/****t* qse.cmn.sll/qse_sll_walk_t
/****t* Common/qse_sll_walk_t
* NAME
* qse_sll_walk_t - define return values for qse_sll_walker_t
* 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 enum qse_sll_walk_t qse_sll_walk_t;
/****b* qse.cmn.sll/qse_sll_copier_t
/****t* Common/qse_sll_copier_t
* NAME
* qse_sll_copier_t - define a node contruction callback
* 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
* qse_sll_freeer_t - define a node destruction callback
* 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
* 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
* 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
* 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
* qse_sll_node_t - define a list node
* DESCRIPTION
@ -186,7 +186,7 @@ struct qse_sll_node_t
#define QSE_SLL_SIZE(sll) ((sll)->size)
#define QSE_SLL_SCALE(sll) ((sll)->scale)
/****d* cmn/QSE_SLL_DPTR
/****d* Common/QSE_SLL_DPTR
* NAME
* QSE_SLL_DPTR - get the data pointer in a node
* SYNOPSIS
@ -194,7 +194,7 @@ struct qse_sll_node_t
#define QSE_SLL_DPTR(node) ((node)->dptr)
/******/
/****d* cmn/QSE_SLL_DLEN
/****d* Common/QSE_SLL_DLEN
* NAME
* QSE_SLL_DLEN - get the length of data in a node
* SYNOPSIS
@ -202,7 +202,7 @@ struct qse_sll_node_t
#define QSE_SLL_DLEN(node) ((node)->dlen)
/******/
/****d* cmn/QSE_SLL_NEXT
/****d* Common/QSE_SLL_NEXT
* NAME
* QSE_SLL_NEXT - get the next node
* SYNOPSIS
@ -216,7 +216,7 @@ extern "C" {
QSE_DEFINE_COMMON_FUNCTIONS (sll)
/****f* qse.cmn.sll/qse_sll_open
/****f* Common/qse_sll_open
* NAME
* 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
* 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
* 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
* 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
* 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
* 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
* 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
* 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
* 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
* 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
* 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
* 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
* 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
* 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
* 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
* 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
* 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
* 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
* qse_sll_clear - delete all nodes
*
@ -545,7 +545,7 @@ void qse_sll_poptail (
qse_sll_t* sll
);
/****f* qse.cmn.sll/qse_sll_walk
/****f* Common/qse_sll_walk
* NAME
* qse_sll_walk - traverse s singly linked list
*

View File

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

View File

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

View File

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

View File

@ -16,27 +16,10 @@
# define QSE_NULL ((void*)0)
#endif
/****d* qse/QSE_TRUE,qse/QSE_FALSE
* NAME
* QSE_TRUE - represent a boolean true
* QSE_FALSE - represent a boolean false
******
*/
#define QSE_TRUE (0 == 0)
/*#define QSE_TRUE (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_WCHAR_EOF ((qse_wcint_t)-1)
@ -157,7 +140,7 @@
# define QSE_END_NAMESPACE2(y,x) }}
#endif
/****d* qse/QSE_DEFINE_COMMON_FIELDS
/****d* Base/QSE_DEFINE_COMMON_FIELDS
* NAME
* QSE_DEFINE_COMMON_FIELDS - define common fields
* SYNOPSIS
@ -166,7 +149,7 @@
qse_mmgr_t* mmgr;
/******/
/****d* qse/QSE_DEFINE_COMMON_FUNCTIONS
/****d* Base/QSE_DEFINE_COMMON_FUNCTIONS
* NAME
* QSE_DEFINE_COMMON_FUNCTIONS - define common functions
* SYNOPSIS
@ -177,7 +160,7 @@ qse_mmgr_t* qse_##name##_getmmgr (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
* QSE_IMPLEMENT_COMMON_FUNCTIONS - implement common functions
* SYNOPSIS

View File

@ -7,7 +7,7 @@
#ifndef _QSE_TYPES_H_
#define _QSE_TYPES_H_
/****o* qse/basic types
/****o* Base/Basic Types
* DESCRIPTION
* <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
@ -30,27 +30,40 @@
# error unsupported operating system
#endif
/****t* qse/qse_bool_t
/****t* Base/qse_bool_t
* NAME
* qse_bool_t - define a boolean type
* DESCRIPTION
* The qse_bool_t type defines a boolean type that can represent QSE_TRUE
* 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
* qse_tri_t - define a tri-state type
* DESCRIPTION
* The qse_tri_t type defines a tri-state type that can represent QSE_ALIVE,
* 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
* 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
@ -82,7 +95,7 @@ typedef int qse_tri_t;
# error unsupported pointer size
#endif
/****t* qse/qse_long_t,qse/qse_ulong_t
/****t* Base/qse_long_t,Base/qse_ulong_t
* NAME
* qse_long_t - define the largest signed 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;
#endif
/****t* qse/qse_int8_t,qse/qse_uint8_t
/****t* Base/qse_int8_t,Base/qse_uint8_t
* NAME
* qse_int8_t - define an 8-bit signed 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;
#endif
/****t* qse/qse_int16_t,qse/qse_uint16_t
/****t* Base/qse_int16_t,Base/qse_uint16_t
* NAME
* qse_int16_t - define a 16-bit signed 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;
#endif
/****t* qse/qse_int32_t,qse/qse_uint32_t
/****t* Base/qse_int32_t,Base/qse_uint32_t
* NAME
* qse_int32_t - define a 32-bit signed 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;
#endif
/****t* qse/qse_int64_t,qse/qse_uint64_t
/****t* Base/qse_int64_t,Base/qse_uint64_t
* NAME
* qse_int64_t - define a 64-bit signed 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;
#endif
/****t* qse/qse_byte_t
/****t* Base/qse_byte_t
* NAME
* qse_byte_t - define a byte type
******
*/
typedef qse_uint8_t qse_byte_t;
/****t* qse/qse_size_t
/****t* Base/qse_size_t
* NAME
* 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;
#endif
/****t* qse/qse_ssize_t
/****t* Base/qse_ssize_t
* NAME
* qse_ssize_t - define an signed integer type that can hold a pointer value
******
*/
typedef qse_int_t qse_ssize_t;
/****t* qse/qse_word_t
/****t* Base/qse_word_t
* NAME
* 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;
#endif
/****t* qse/qse_mchar_t,qse/qse_mcint_t
/****t* Base/qse_mchar_t,Base/qse_mcint_t
* NAME
* qse_mchar_t - define a multi-byte character
* 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 int qse_mcint_t;
/****t* qse/qse_wchar_t,qse/qse_wcint_t
/****t* Base/qse_wchar_t,Base/qse_wcint_t
* NAME
* qse_wchar_t - define a wide character
* 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
#endif
/****t* qse/qse_char_t,qse/qse_cint_t
/****t* Base/qse_char_t,Base/qse_cint_t
* NAME
* qse_char_t - define a character
* 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_ccls_t qse_ccls_t;
/****t* qse/qse_xstr_t
/****t* Base/qse_xstr_t
* NAME
* qse_xstr_t - combine a pointer and length
* SYNOPSIS
@ -362,7 +375,7 @@ struct qse_xstr_t
};
/******/
/****t* qse/qse_cstr_t
/****t* Base/qse_cstr_t
* NAME
* qse_cstr_t - combine a constant pointer and length
* SYNOPSIS
@ -374,7 +387,7 @@ struct qse_cstr_t
};
/******/
/****t* qse/qse_mmgr_t
/****t* Base/qse_mmgr_t
* NAME
* qse_mmgr_t - define a memory manager
* SYNOPSIS
@ -388,7 +401,7 @@ struct qse_mmgr_t
};
/******/
/****t* qse/qse_ccls_type_t
/****t* Base/qse_ccls_type_t
* NAME
* qse_ccls_type_t - define character class types
* SYNOPSIS
@ -411,7 +424,7 @@ enum 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
* qse_mmgr_t - define a character classifier
* SYNOPSIS

View File

@ -160,7 +160,7 @@ int Awk::Console::setFNR (long_t fnr)
if (tmp == QSE_NULL) return -1;
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);
return n;
@ -998,7 +998,7 @@ int Awk::Run::setGlobal (int id, long_t v)
if (tmp == QSE_NULL) return -1;
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);
return n;
}
@ -1011,7 +1011,7 @@ int Awk::Run::setGlobal (int id, real_t v)
if (tmp == QSE_NULL) return -1;
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);
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;
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);
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);
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);
global.clear ();
return global.init (qse_awk_rtx_getglobal(this->run,id));
gbl.clear ();
return gbl.init (qse_awk_rtx_getgbl(this->run,id));
}
void Awk::Run::setData (void* data)
@ -1468,7 +1468,7 @@ int Awk::addGlobal (const char_t* name)
{
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 ();
return n;
}
@ -1476,7 +1476,7 @@ int Awk::addGlobal (const char_t* name)
int Awk::deleteGlobal (const char_t* name)
{
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 ();
return n;
}

View File

@ -41,7 +41,7 @@ StdAwk::StdAwk ()
{
}
#define ADD_FUNC(name,min,max,impl) \
#define ADDFNC(name,min,max,impl) \
do { \
if (addFunction (name, min, max, \
(FunctionHandler)impl) == -1) \
@ -56,18 +56,18 @@ int StdAwk::open ()
int n = Awk::open ();
if (n == -1) return n;
ADD_FUNC (QSE_T("sin"), 1, 1, &StdAwk::sin);
ADD_FUNC (QSE_T("cos"), 1, 1, &StdAwk::cos);
ADD_FUNC (QSE_T("tan"), 1, 1, &StdAwk::tan);
ADD_FUNC (QSE_T("atan"), 1, 1, &StdAwk::atan);
ADD_FUNC (QSE_T("atan2"), 2, 2, &StdAwk::atan2);
ADD_FUNC (QSE_T("log"), 1, 1, &StdAwk::log);
ADD_FUNC (QSE_T("exp"), 1, 1, &StdAwk::exp);
ADD_FUNC (QSE_T("sqrt"), 1, 1, &StdAwk::sqrt);
ADD_FUNC (QSE_T("int"), 1, 1, &StdAwk::fnint);
ADD_FUNC (QSE_T("rand"), 0, 0, &StdAwk::rand);
ADD_FUNC (QSE_T("srand"), 0, 1, &StdAwk::srand);
ADD_FUNC (QSE_T("system"), 1, 1, &StdAwk::system);
ADDFNC (QSE_T("sin"), 1, 1, &StdAwk::sin);
ADDFNC (QSE_T("cos"), 1, 1, &StdAwk::cos);
ADDFNC (QSE_T("tan"), 1, 1, &StdAwk::tan);
ADDFNC (QSE_T("atan"), 1, 1, &StdAwk::atan);
ADDFNC (QSE_T("atan2"), 2, 2, &StdAwk::atan2);
ADDFNC (QSE_T("log"), 1, 1, &StdAwk::log);
ADDFNC (QSE_T("exp"), 1, 1, &StdAwk::exp);
ADDFNC (QSE_T("sqrt"), 1, 1, &StdAwk::sqrt);
ADDFNC (QSE_T("int"), 1, 1, &StdAwk::fnint);
ADDFNC (QSE_T("rand"), 0, 0, &StdAwk::rand);
ADDFNC (QSE_T("srand"), 0, 1, &StdAwk::srand);
ADDFNC (QSE_T("system"), 1, 1, &StdAwk::system);
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_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.locals = qse_lda_open (mmgr, QSE_SIZEOF(awk), 64);
awk->parse.gbls = qse_lda_open (mmgr, QSE_SIZEOF(awk), 128);
awk->parse.lcls = qse_lda_open (mmgr, QSE_SIZEOF(awk), 64);
awk->parse.params = qse_lda_open (mmgr, QSE_SIZEOF(awk), 32);
if (awk->parse.globals == QSE_NULL ||
awk->parse.locals == QSE_NULL ||
if (awk->parse.gbls == QSE_NULL ||
awk->parse.lcls == QSE_NULL ||
awk->parse.params == QSE_NULL) goto oops;
*(qse_awk_t**)qse_lda_getxtn(awk->parse.globals) = awk;
qse_lda_setcopier (awk->parse.globals, QSE_LDA_COPIER_INLINE);
qse_lda_setscale (awk->parse.globals, QSE_SIZEOF(qse_char_t));
*(qse_awk_t**)qse_lda_getxtn(awk->parse.gbls) = awk;
qse_lda_setcopier (awk->parse.gbls, QSE_LDA_COPIER_INLINE);
qse_lda_setscale (awk->parse.gbls, QSE_SIZEOF(qse_char_t));
*(qse_awk_t**)qse_lda_getxtn(awk->parse.locals) = awk;
qse_lda_setcopier (awk->parse.locals, QSE_LDA_COPIER_INLINE);
qse_lda_setscale (awk->parse.locals, QSE_SIZEOF(qse_char_t));
*(qse_awk_t**)qse_lda_getxtn(awk->parse.lcls) = awk;
qse_lda_setcopier (awk->parse.lcls, QSE_LDA_COPIER_INLINE);
qse_lda_setscale (awk->parse.lcls, QSE_SIZEOF(qse_char_t));
*(qse_awk_t**)qse_lda_getxtn(awk->parse.params) = awk;
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->stopall = QSE_FALSE;
awk->parse.nlocals_max = 0;
awk->parse.nlcls_max = 0;
awk->tree.nglobals = 0;
awk->tree.nbglobals = 0;
awk->tree.ngbls = 0;
awk->tree.nbgbls = 0;
awk->tree.begin = QSE_NULL;
awk->tree.begin_tail = 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;
if (qse_awk_initglobals (awk) == -1) goto oops;
if (qse_awk_initgbls (awk) == -1) goto oops;
return awk;
@ -194,8 +194,8 @@ qse_awk_t* qse_awk_open (qse_mmgr_t* mmgr, qse_size_t ext)
oops:
if (awk->fnc.user) qse_map_close (awk->fnc.user);
if (awk->parse.params) qse_lda_close (awk->parse.params);
if (awk->parse.locals) qse_lda_close (awk->parse.locals);
if (awk->parse.globals) qse_lda_close (awk->parse.globals);
if (awk->parse.lcls) qse_lda_close (awk->parse.lcls);
if (awk->parse.gbls) qse_lda_close (awk->parse.gbls);
if (awk->parse.named) qse_map_close (awk->parse.named);
if (awk->parse.funs) qse_map_close (awk->parse.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_lda_close (awk->parse.params);
qse_lda_close (awk->parse.locals);
qse_lda_close (awk->parse.globals);
qse_lda_close (awk->parse.lcls);
qse_lda_close (awk->parse.gbls);
qse_map_close (awk->parse.named);
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_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 */
qse_lda_delete (
awk->parse.globals, awk->tree.nbglobals,
QSE_LDA_SIZE(awk->parse.globals) - awk->tree.nbglobals);
awk->parse.gbls, awk->tree.nbgbls,
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_map_clear (awk->parse.named);
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.loop = 0;
awk->parse.depth.cur.expr = 0;
/* clear parse trees */
awk->tree.ok = 0;
/*awk->tree.nbglobals = 0;
awk->tree.nglobals = 0; */
awk->tree.nglobals = awk->tree.nbglobals;
/*awk->tree.nbgbls = 0;
awk->tree.ngbls = 0; */
awk->tree.ngbls = awk->tree.nbgbls;
awk->tree.cur_fun.ptr = QSE_NULL;
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 "misc.h"
#define QSE_AWK_MAX_GLOBALS 9999
#define QSE_AWK_MAX_LOCALS 9999
#define QSE_AWK_MAX_GBLS 9999
#define QSE_AWK_MAX_LCLS 9999
#define QSE_AWK_MAX_PARAMS 9999
#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
{
qse_size_t nglobals; /* total number of globals */
qse_size_t nbglobals; /* number of intrinsic globals */
qse_size_t ngbls; /* total number of gbls */
qse_size_t nbgbls; /* number of intrinsic gbls */
qse_cstr_t cur_fun;
qse_map_t* funs; /* awk function map */
@ -138,16 +138,16 @@ struct qse_awk_t
qse_map_t* named;
/* global variables */
qse_lda_t* globals;
qse_lda_t* gbls;
/* local variables */
qse_lda_t* locals;
qse_lda_t* lcls;
/* parameters to a function */
qse_lda_t* params;
/* maximum number of local variables */
qse_size_t nlocals_max;
qse_size_t nlcls_max;
qse_awk_nde_t* (*parse_block) (
qse_awk_t*,qse_size_t,qse_bool_t);
@ -331,7 +331,7 @@ struct qse_awk_rtx_t
qse_char_t* ptr;
qse_size_t len;
} subsep;
} global;
} gbl;
/* eio chain */
struct

View File

@ -204,7 +204,7 @@ int qse_awk_readeio (
qse_str_clear (buf);
/* 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);
if (rs->type == QSE_AWK_VAL_NIL)
@ -275,11 +275,11 @@ int qse_awk_readeio (
const qse_char_t* match_ptr;
qse_size_t match_len;
QSE_ASSERT (run->global.rs != QSE_NULL);
QSE_ASSERT (run->gbl.rs != QSE_NULL);
n = QSE_AWK_MATCHREX (
run->awk, run->global.rs,
((run->global.ignorecase)? QSE_REX_IGNORECASE: 0),
run->awk, run->gbl.rs,
((run->gbl.ignorecase)? QSE_REX_IGNORECASE: 0),
QSE_STR_PTR(buf), QSE_STR_LEN(buf),
&match_ptr, &match_len, &run->errnum);
if (n == -1)
@ -363,11 +363,11 @@ int qse_awk_readeio (
const qse_char_t* match_ptr;
qse_size_t match_len;
QSE_ASSERT (run->global.rs != QSE_NULL);
QSE_ASSERT (run->gbl.rs != QSE_NULL);
n = QSE_AWK_MATCHREX (
run->awk, run->global.rs,
((run->global.ignorecase)? QSE_REX_IGNORECASE: 0),
run->awk, run->gbl.rs,
((run->gbl.ignorecase)? QSE_REX_IGNORECASE: 0),
QSE_STR_PTR(buf), QSE_STR_LEN(buf),
&match_ptr, &match_len, &run->errnum);
if (n == -1)

View File

@ -652,7 +652,7 @@ static int fnc_split (
if (a2 == QSE_NULL)
{
/* 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)
{
fs_ptr = QSE_T(" ");
@ -680,7 +680,7 @@ static int fnc_split (
if (fs_len > 1)
{
fs_rex = run->global.fs;
fs_rex = run->gbl.fs;
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_len = a2_len;
sub_count = 0;
@ -1291,7 +1291,7 @@ static int fnc_match (
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 (
run->awk, rex, opt, str0, len0,
&mat_ptr, &mat_len, &run->errnum);
@ -1324,14 +1324,14 @@ static int fnc_match (
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, a0);
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, a0);

View File

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

View File

@ -116,7 +116,7 @@ enum token_t
enum
{
PARSE_GLOBAL,
PARSE_GBL,
PARSE_FUNCTION,
PARSE_BEGIN,
PARSE_END,
@ -145,18 +145,18 @@ struct binmap_t
static int parse (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 void adjust_static_globals (qse_awk_t* awk);
static qse_awk_t* collect_gbls (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);
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);
static int add_global (
static int add_gbl (
qse_awk_t* awk, const qse_char_t* name, qse_size_t len,
qse_size_t line, int force);
static qse_awk_t* collect_locals (
qse_awk_t* awk, qse_size_t nlocals, qse_bool_t istop);
static qse_awk_t* collect_lcls (
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_begin (qse_awk_t* awk);
@ -291,16 +291,16 @@ static kwent_t kwtab[] =
{ 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;
qse_size_t name_len;
int valid;
};
static global_t gtab[] =
static gbl_t gtab[] =
{
{ QSE_T("ARGC"), 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)
{
/*
@ -463,10 +463,10 @@ const qse_char_t* qse_awk_rtx_getglobalname (
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);
return QSE_LDA_DPTR(awk->parse.globals,idx);
*len = QSE_LDA_DLEN(awk->parse.gbls,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)
@ -528,7 +528,7 @@ static int parse (qse_awk_t* awk)
return -1;
}
adjust_static_globals (awk);
adjust_static_gbls (awk);
#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)
{
@ -611,7 +611,7 @@ exit_parse:
static qse_awk_t* parse_progunit (qse_awk_t* awk)
{
/*
global xxx, xxxx;
gbl xxx, xxxx;
BEGIN { action }
END { 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))
{
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;
QSE_ASSERT (awk->tree.nglobals == QSE_LDA_SIZE(awk->parse.globals));
nglobals = awk->tree.nglobals;
if (collect_globals (awk) == QSE_NULL)
QSE_ASSERT (awk->tree.ngbls == QSE_LDA_SIZE(awk->parse.gbls));
ngbls = awk->tree.ngbls;
if (collect_gbls (awk) == QSE_NULL)
{
qse_lda_delete (
awk->parse.globals, nglobals,
QSE_LDA_SIZE(awk->parse.globals) - nglobals);
awk->tree.nglobals = nglobals;
awk->parse.gbls, ngbls,
QSE_LDA_SIZE(awk->parse.gbls) - ngbls);
awk->tree.ngbls = ngbls;
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 */
g = find_global (awk, name, name_len);
g = find_gbl (awk, name, name_len);
if (g != QSE_LDA_NIL)
{
SETERRARG (
@ -945,7 +945,7 @@ static qse_awk_nde_t* parse_function (qse_awk_t* awk)
/* NOTE: the following is not a conflict.
* so the parameter is not checked against
* global variables.
* global x;
* gbl x;
* function f (x) { print x; }
* 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_blk_t* block;
qse_size_t nlocals, nlocals_max, tmp;
qse_size_t nlcls, nlcls_max, tmp;
nlocals = QSE_LDA_SIZE(awk->parse.locals);
nlocals_max = awk->parse.nlocals_max;
nlcls = QSE_LDA_SIZE(awk->parse.lcls);
nlcls_max = awk->parse.nlcls_max;
/* local variable declarations */
if (awk->option & QSE_AWK_EXPLICIT)
@ -1228,16 +1228,16 @@ static qse_awk_nde_t* parse_block (
if (get_token(awk) == -1)
{
qse_lda_delete (
awk->parse.locals, nlocals,
QSE_LDA_SIZE(awk->parse.locals)-nlocals);
awk->parse.lcls, nlcls,
QSE_LDA_SIZE(awk->parse.lcls)-nlcls);
return QSE_NULL;
}
if (collect_locals (awk, nlocals, istop) == QSE_NULL)
if (collect_lcls (awk, nlcls, istop) == QSE_NULL)
{
qse_lda_delete (
awk->parse.locals, nlocals,
QSE_LDA_SIZE(awk->parse.locals)-nlocals);
awk->parse.lcls, nlcls,
QSE_LDA_SIZE(awk->parse.lcls)-nlcls);
return QSE_NULL;
}
}
@ -1258,8 +1258,8 @@ static qse_awk_nde_t* parse_block (
if (MATCH(awk,TOKEN_EOF))
{
qse_lda_delete (
awk->parse.locals, nlocals,
QSE_LDA_SIZE(awk->parse.locals) - nlocals);
awk->parse.lcls, nlcls,
QSE_LDA_SIZE(awk->parse.lcls) - nlcls);
if (head != QSE_NULL) qse_awk_clrpt (awk, head);
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)
{
qse_lda_delete (
awk->parse.locals, nlocals,
QSE_LDA_SIZE(awk->parse.locals)-nlocals);
awk->parse.lcls, nlcls,
QSE_LDA_SIZE(awk->parse.lcls)-nlcls);
if (head != QSE_NULL) qse_awk_clrpt (awk, head);
return QSE_NULL;
}
@ -1286,8 +1286,8 @@ static qse_awk_nde_t* parse_block (
if (nde == QSE_NULL)
{
qse_lda_delete (
awk->parse.locals, nlocals,
QSE_LDA_SIZE(awk->parse.locals)-nlocals);
awk->parse.lcls, nlcls,
QSE_LDA_SIZE(awk->parse.lcls)-nlcls);
if (head != QSE_NULL) qse_awk_clrpt (awk, head);
return QSE_NULL;
}
@ -1316,21 +1316,21 @@ static qse_awk_nde_t* parse_block (
if (block == QSE_NULL)
{
qse_lda_delete (
awk->parse.locals, nlocals,
QSE_LDA_SIZE(awk->parse.locals)-nlocals);
awk->parse.lcls, nlcls,
QSE_LDA_SIZE(awk->parse.lcls)-nlcls);
qse_awk_clrpt (awk, head);
SETERRLIN (awk, QSE_AWK_ENOMEM, line);
return QSE_NULL;
}
tmp = QSE_LDA_SIZE(awk->parse.locals);
if (tmp > awk->parse.nlocals_max) awk->parse.nlocals_max = tmp;
tmp = QSE_LDA_SIZE(awk->parse.lcls);
if (tmp > awk->parse.nlcls_max) awk->parse.nlcls_max = tmp;
/* remove all locals to move it up to the top level */
qse_lda_delete (awk->parse.locals, nlocals, tmp - nlocals);
/* remove all lcls to move it up to the top level */
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; */
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 */
if (istop)
{
block->nlocals = awk->parse.nlocals_max - nlocals;
awk->parse.nlocals_max = nlocals_max;
block->nlcls = awk->parse.nlcls_max - nlcls;
awk->parse.nlcls_max = nlcls_max;
}
else
{
/*block->nlocals = tmp - nlocals;*/
block->nlocals = 0;
/*block->nlcls = tmp - nlcls;*/
block->nlcls = 0;
}
return (qse_awk_nde_t*)block;
@ -1377,81 +1377,81 @@ static qse_awk_nde_t* parse_block_dc (
return nde;
}
int qse_awk_initglobals (qse_awk_t* awk)
int qse_awk_initgbls (qse_awk_t* awk)
{
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_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.nglobals = 0;
awk->tree.nbgbls = 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;
g = qse_lda_insert (
awk->parse.globals,
QSE_LDA_SIZE(awk->parse.globals),
awk->parse.gbls,
QSE_LDA_SIZE(awk->parse.gbls),
(qse_char_t*)gtab[id].name,
gtab[id].name_len);
if (g == QSE_LDA_NIL) return -1;
QSE_ASSERT ((int)g == id);
awk->tree.nbglobals++;
awk->tree.nglobals++;
awk->tree.nbgbls++;
awk->tree.ngbls++;
}
QSE_ASSERT (awk->tree.nbglobals ==
QSE_AWK_MAX_GLOBAL_ID-QSE_AWK_MIN_GLOBAL_ID+1);
QSE_ASSERT (awk->tree.nbgbls ==
QSE_AWK_MAX_GBL_ID-QSE_AWK_MIN_GBL_ID+1);
return 0;
}
static void adjust_static_globals (qse_awk_t* awk)
static void adjust_static_gbls (qse_awk_t* awk)
{
int id;
QSE_ASSERT (awk->tree.nbglobals >=
QSE_AWK_MAX_GLOBAL_ID - QSE_AWK_MAX_GLOBAL_ID + 1);
QSE_ASSERT (awk->tree.nbgbls >=
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 &&
(awk->option & gtab[id].valid) != gtab[id].valid)
{
/*awk->parse.globals.buf[id].name.len = 0;*/
QSE_LDA_DLEN(awk->parse.globals,id) = 0;
/*awk->parse.gbls.buf[id].name.len = 0;*/
QSE_LDA_DLEN(awk->parse.gbls,id) = 0;
}
else
{
/*awk->parse.globals.buf[id].name.len = gtab[id].name_len;*/
QSE_LDA_DLEN(awk->parse.globals,id) = gtab[id].name_len;
/*awk->parse.gbls.buf[id].name.len = 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_size_t index;
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_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.len = QSE_LDA_DLEN(lda,index);
if (index < awk->tree.nbglobals)
if (index < awk->tree.nbgbls)
{
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;
}
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)
{
check_global_t cg;
check_gbl_t cg;
cg.name.ptr = name;
cg.name.len = len;
@ -1483,34 +1483,34 @@ static qse_size_t get_global (
cg.walk = QSE_LDA_WALK_BACKWARD;
/* return qse_lda_rsearch (
awk->parse.globals, QSE_LDA_SIZE(awk->parse.globals),
awk->parse.gbls, QSE_LDA_SIZE(awk->parse.gbls),
name, len); */
qse_lda_rwalk (awk->parse.globals, check_global, &cg);
qse_lda_rwalk (awk->parse.gbls, check_gbl, &cg);
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)
{
check_global_t cg;
check_gbl_t cg;
cg.name.ptr = name;
cg.name.len = len;
cg.index = QSE_LDA_NIL;
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;
}
static int add_global (
static int add_gbl (
qse_awk_t* awk, const qse_char_t* name, qse_size_t len,
qse_size_t line, int disabled)
{
qse_size_t nglobals;
qse_size_t ngbls;
#if 0
if (awk->option & QSE_AWK_UNIQUEFN)
@ -1548,41 +1548,41 @@ static int add_global (
#endif
/* 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);
return -1;
}
nglobals = QSE_LDA_SIZE (awk->parse.globals);
if (nglobals >= QSE_AWK_MAX_GLOBALS)
ngbls = QSE_LDA_SIZE (awk->parse.gbls);
if (ngbls >= QSE_AWK_MAX_GBLS)
{
SETERRLIN (awk, QSE_AWK_EGBLTM, line);
return -1;
}
if (qse_lda_insert (awk->parse.globals,
QSE_LDA_SIZE(awk->parse.globals),
if (qse_lda_insert (awk->parse.gbls,
QSE_LDA_SIZE(awk->parse.gbls),
(qse_char_t*)name, len) == QSE_LDA_NIL)
{
SETERRLIN (awk, QSE_AWK_ENOMEM, line);
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 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);
QSE_ASSERT (nglobals == awk->tree.nglobals-1);
awk->tree.ngbls = QSE_LDA_SIZE (awk->parse.gbls);
QSE_ASSERT (ngbls == awk->tree.ngbls-1);
/* return the id which is the index to the global table. */
return (int)nglobals;
/* return the id which is the index to the gbl table. */
return (int)ngbls;
}
int qse_awk_addglobal (
int qse_awk_addgbl (
qse_awk_t* awk, const qse_char_t* name, qse_size_t len)
{
int n;
@ -1593,38 +1593,38 @@ int qse_awk_addglobal (
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 */
SETERR (awk, QSE_AWK_ENOPER);
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.
* the total global count has been updated inside add_global. */
if (n >= 0) awk->tree.nbglobals++;
/* update the count of the static gbls.
* the total gbl count has been updated inside add_gbl. */
if (n >= 0) awk->tree.nbgbls++;
return n;
}
int qse_awk_delglobal (
int qse_awk_delgbl (
qse_awk_t* awk, const qse_char_t* name, qse_size_t len)
{
qse_size_t n;
#define QSE_AWK_NUM_STATIC_GLOBALS \
(QSE_AWK_MAX_GLOBAL_ID-QSE_AWK_MIN_GLOBAL_ID+1)
#define QSE_AWK_NUM_STATIC_GBLS \
(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 */
SETERR (awk, QSE_AWK_ENOPER);
return -1;
}
n = qse_lda_search (awk->parse.globals,
QSE_AWK_NUM_STATIC_GLOBALS, name, len);
n = qse_lda_search (awk->parse.gbls,
QSE_AWK_NUM_STATIC_GBLS, name, len);
if (n == QSE_LDA_NIL)
{
SETERRARG (awk, QSE_AWK_ENOENT, 0, name, len);
@ -1633,20 +1633,20 @@ int qse_awk_delglobal (
/* invalidate the name if deletion is requested.
* 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.
* never call this funciton unless it is really required. */
/*
awk->parse.globals.buf[n].name.ptr[0] = QSE_T('\0');
awk->parse.globals.buf[n].name.len = 0;
awk->parse.gbls.buf[n].name.ptr[0] = QSE_T('\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);
return 0;
}
static qse_awk_t* collect_globals (qse_awk_t* awk)
static qse_awk_t* collect_gbls (qse_awk_t* awk)
{
while (1)
{
@ -1656,7 +1656,7 @@ static qse_awk_t* collect_globals (qse_awk_t* awk)
return QSE_NULL;
}
if (add_global (
if (add_gbl (
awk,
QSE_STR_PTR(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;
}
static qse_awk_t* collect_locals (
qse_awk_t* awk, qse_size_t nlocals, qse_bool_t istop)
static qse_awk_t* collect_lcls (
qse_awk_t* awk, qse_size_t nlcls, qse_bool_t istop)
{
qse_xstr_t local;
qse_xstr_t lcl;
qse_size_t n;
while (1)
@ -1695,8 +1695,8 @@ static qse_awk_t* collect_locals (
return QSE_NULL;
}
local.ptr = QSE_STR_PTR(awk->token.name);
local.len = QSE_STR_LEN(awk->token.name);
lcl.ptr = QSE_STR_PTR(awk->token.name);
lcl.len = QSE_STR_LEN(awk->token.name);
#if 0
if (awk->option & QSE_AWK_UNIQUEFN)
@ -1705,12 +1705,12 @@ static qse_awk_t* collect_locals (
#endif
/* check if it conflict with a builtin function name
* function f() { local length; } */
if (qse_awk_getfnc (awk, local.ptr, local.len) != QSE_NULL)
* function f() { lcl length; } */
if (qse_awk_getfnc (awk, lcl.ptr, lcl.len) != QSE_NULL)
{
SETERRARG (
awk, QSE_AWK_EFNCRED, awk->token.line,
local.ptr, local.len);
lcl.ptr, lcl.len);
return QSE_NULL;
}
@ -1720,25 +1720,25 @@ static qse_awk_t* collect_locals (
{
iscur = (qse_strxncmp (
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 (
awk, QSE_AWK_EFUNRED, awk->token.line,
local.ptr, local.len);
lcl.ptr, lcl.len);
return QSE_NULL;
}
/* check if it conflict with a function name
* caught in the function call table */
if (qse_map_search (awk->parse.funs,
local.ptr, local.len) != QSE_NULL)
lcl.ptr, lcl.len) != QSE_NULL)
{
SETERRARG (
awk, QSE_AWK_EFUNRED, awk->token.line,
local.ptr, local.len);
lcl.ptr, lcl.len);
return QSE_NULL;
}
}
@ -1747,39 +1747,39 @@ static qse_awk_t* collect_locals (
if (istop)
{
/* 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)
{
SETERRARG (
awk, QSE_AWK_EPARRED, awk->token.line,
local.ptr, local.len);
lcl.ptr, lcl.len);
return QSE_NULL;
}
}
/* check if it conflicts with other local variable names */
n = qse_lda_search (
awk->parse.locals,
nlocals, /*((awk->option&QSE_AWK_SHADING)? nlocals:0)*/
local.ptr, local.len);
awk->parse.lcls,
nlcls, /*((awk->option&QSE_AWK_SHADING)? nlcls:0)*/
lcl.ptr, lcl.len);
if (n != QSE_LDA_NIL)
{
SETERRARG (
awk, QSE_AWK_EDUPLCL, awk->token.line,
local.ptr, local.len);
lcl.ptr, lcl.len);
return QSE_NULL;
}
/* 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 < awk->tree.nbglobals)
if (n < awk->tree.nbgbls)
{
/* conflicting with a static global variable */
SETERRARG (
awk, QSE_AWK_EDUPLCL, awk->token.line,
local.ptr, local.len);
lcl.ptr, lcl.len);
return QSE_NULL;
}
@ -1789,22 +1789,22 @@ static qse_awk_t* collect_locals (
/* conflicting with a normal global variable */
SETERRARG (
awk, QSE_AWK_EDUPLCL, awk->token.line,
local.ptr, local.len);
lcl.ptr, lcl.len);
return QSE_NULL;
}
#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);
return QSE_NULL;
}
if (qse_lda_insert (
awk->parse.locals,
QSE_LDA_SIZE(awk->parse.locals),
local.ptr, local.len) == QSE_LDA_NIL)
awk->parse.lcls,
QSE_LDA_SIZE(awk->parse.lcls),
lcl.ptr, lcl.len) == QSE_LDA_NIL)
{
SETERRLIN (awk, QSE_AWK_ENOMEM, awk->token.line);
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);
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 */
@ -3319,7 +3319,7 @@ static qse_awk_nde_t* parse_primary_ident (qse_awk_t* awk, qse_size_t line)
return QSE_NULL;
}
nde->type = QSE_AWK_NDE_LOCAL;
nde->type = QSE_AWK_NDE_LCL;
nde->line = line;
nde->next = 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;
}
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 */
@ -3387,7 +3387,7 @@ static qse_awk_nde_t* parse_primary_ident (qse_awk_t* awk, qse_size_t line)
return QSE_NULL;
}
nde->type = QSE_AWK_NDE_GLOBAL;
nde->type = QSE_AWK_NDE_GBL;
nde->line = line;
nde->next = QSE_NULL;
/*nde->id.name = QSE_NULL;*/
@ -3570,10 +3570,15 @@ static qse_awk_nde_t* parse_hashidx (
}
/* 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)
{
nde->type = QSE_AWK_NDE_LOCALIDX;
nde->type = QSE_AWK_NDE_LCLIDX;
nde->line = line;
nde->next = QSE_NULL;
/*nde->id.name = QSE_NULL; */
@ -3602,10 +3607,10 @@ static qse_awk_nde_t* parse_hashidx (
}
/* gets the global variable index */
idxa = get_global (awk, name, name_len);
idxa = get_gbl (awk, name, name_len);
if (idxa != QSE_LDA_NIL)
{
nde->type = QSE_AWK_NDE_GLOBALIDX;
nde->type = QSE_AWK_NDE_GBLIDX;
nde->line = line;
nde->next = 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)
{
return nde->type == QSE_AWK_NDE_GLOBAL ||
nde->type == QSE_AWK_NDE_LOCAL ||
return nde->type == QSE_AWK_NDE_GBL ||
nde->type == QSE_AWK_NDE_LCL ||
nde->type == QSE_AWK_NDE_ARG ||
nde->type == QSE_AWK_NDE_NAMED;
}
static int is_var (qse_awk_nde_t* nde)
{
return nde->type == QSE_AWK_NDE_GLOBAL ||
nde->type == QSE_AWK_NDE_LOCAL ||
return nde->type == QSE_AWK_NDE_GBL ||
nde->type == QSE_AWK_NDE_LCL ||
nde->type == QSE_AWK_NDE_ARG ||
nde->type == QSE_AWK_NDE_NAMED ||
nde->type == QSE_AWK_NDE_GLOBALIDX ||
nde->type == QSE_AWK_NDE_LOCALIDX ||
nde->type == QSE_AWK_NDE_GBLIDX ||
nde->type == QSE_AWK_NDE_LCLIDX ||
nde->type == QSE_AWK_NDE_ARGIDX ||
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)
if (awk->tree.nglobals > awk->tree.nbglobals)
if (awk->tree.ngbls > awk->tree.nbgbls)
{
qse_size_t i, len;
QSE_ASSERT (awk->tree.nglobals > 0);
QSE_ASSERT (awk->tree.ngbls > 0);
qse_awk_getkw (awk, KW_GLOBAL, &kw);
if (qse_awk_putsrcstrx(awk,kw.ptr,kw.len) == -1)
@ -5682,7 +5687,7 @@ static int deparse (qse_awk_t* awk)
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) &&
!(awk->option & QSE_AWK_IMPLICIT))
@ -5690,8 +5695,8 @@ static int deparse (qse_awk_t* awk)
/* use the actual name if no named variable
* is allowed */
if (qse_awk_putsrcstrx (awk,
QSE_LDA_DPTR(awk->parse.globals,i),
QSE_LDA_DLEN(awk->parse.globals,i)) == -1)
QSE_LDA_DPTR(awk->parse.gbls,i),
QSE_LDA_DLEN(awk->parse.gbls,i)) == -1)
{
EXIT_DEPARSE ();
}
@ -5715,8 +5720,8 @@ static int deparse (qse_awk_t* awk)
!(awk->option & QSE_AWK_IMPLICIT))
{
if (qse_awk_putsrcstrx (awk,
QSE_LDA_DPTR(awk->parse.globals,i),
QSE_LDA_DLEN(awk->parse.globals,i)) == -1)
QSE_LDA_DPTR(awk->parse.gbls,i),
QSE_LDA_DLEN(awk->parse.gbls,i)) == -1)
{
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 (
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_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
}

View File

@ -107,7 +107,7 @@ static int split_record (qse_awk_rtx_t* run)
QSE_ASSERT (run->inrec.nflds == 0);
/* 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)
{
fs_ptr = QSE_T(" ");
@ -143,7 +143,7 @@ static int split_record (qse_awk_rtx_t* run)
else
{
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 (fs_free != QSE_NULL)
@ -200,7 +200,7 @@ static int split_record (qse_awk_rtx_t* run)
else
{
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 (fs_free != QSE_NULL)
@ -237,7 +237,7 @@ static int split_record (qse_awk_rtx_t* run)
if (v == QSE_NULL) return -1;
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);
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;
if (qse_awk_rtx_setglobal (
run, QSE_AWK_GLOBAL_NF, qse_awk_val_zero) == -1)
if (qse_awk_rtx_setgbl (
run, QSE_AWK_GBL_NF, qse_awk_val_zero) == -1)
{
/* first of all, this should never happen.
* if it happened, it would return an error
@ -352,8 +352,8 @@ static int recomp_record_fields (
{
if (qse_str_ncat (
&run->inrec.line,
run->global.ofs.ptr,
run->global.ofs.len) == (qse_size_t)-1)
run->gbl.ofs.ptr,
run->gbl.ofs.len) == (qse_size_t)-1)
{
qse_awk_rtx_seterror (
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);
if (((qse_awk_val_int_t*)v)->val != max)
@ -441,7 +441,7 @@ static int recomp_record_fields (
if (v == QSE_NULL) return -1;
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);
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;
}
if (qse_awk_rtx_setglobal (
epa->rtx, QSE_AWK_GLOBAL_FNR, qse_awk_val_zero) == -1)
if (qse_awk_rtx_setgbl (
epa->rtx, QSE_AWK_GBL_FNR, qse_awk_val_zero) == -1)
{
/* need to reset FNR */
qse_sio_close (fp);
@ -1184,24 +1184,24 @@ skip_system:
return 0;
}
#define ADD_FUNC(awk,name,min,max,fnc) \
#define ADDFNC(awk,name,min,max,fnc) \
if (qse_awk_addfnc (\
(awk), (name), qse_strlen(name), \
0, (min), (max), QSE_NULL, (fnc)) == QSE_NULL) return -1;
static int add_functions (qse_awk_t* awk)
{
ADD_FUNC (awk, QSE_T("sin"), 1, 1, fnc_sin);
ADD_FUNC (awk, QSE_T("cos"), 1, 1, fnc_cos);
ADD_FUNC (awk, QSE_T("tan"), 1, 1, fnc_tan);
ADD_FUNC (awk, QSE_T("atan"), 1, 1, fnc_atan);
ADD_FUNC (awk, QSE_T("atan2"), 2, 2, fnc_atan2);
ADD_FUNC (awk, QSE_T("log"), 1, 1, fnc_log);
ADD_FUNC (awk, QSE_T("exp"), 1, 1, fnc_exp);
ADD_FUNC (awk, QSE_T("sqrt"), 1, 1, fnc_sqrt);
ADD_FUNC (awk, QSE_T("int"), 1, 1, fnc_int);
ADD_FUNC (awk, QSE_T("rand"), 0, 0, fnc_rand);
ADD_FUNC (awk, QSE_T("srand"), 0, 1, fnc_srand);
ADD_FUNC (awk, QSE_T("system"), 1, 1, fnc_system);
ADDFNC (awk, QSE_T("sin"), 1, 1, fnc_sin);
ADDFNC (awk, QSE_T("cos"), 1, 1, fnc_cos);
ADDFNC (awk, QSE_T("tan"), 1, 1, fnc_tan);
ADDFNC (awk, QSE_T("atan"), 1, 1, fnc_atan);
ADDFNC (awk, QSE_T("atan2"), 2, 2, fnc_atan2);
ADDFNC (awk, QSE_T("log"), 1, 1, fnc_log);
ADDFNC (awk, QSE_T("exp"), 1, 1, fnc_exp);
ADDFNC (awk, QSE_T("sqrt"), 1, 1, fnc_sqrt);
ADDFNC (awk, QSE_T("int"), 1, 1, fnc_int);
ADDFNC (awk, QSE_T("rand"), 0, 0, fnc_rand);
ADDFNC (awk, QSE_T("srand"), 0, 1, fnc_srand);
ADDFNC (awk, QSE_T("system"), 1, 1, fnc_system);
return 0;
}

View File

@ -401,7 +401,7 @@ static int print_expression (qse_awk_t* awk, qse_awk_nde_t* nde)
break;
}
case QSE_AWK_NDE_GLOBAL:
case QSE_AWK_NDE_GBL:
{
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 */
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 */
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;
}
case QSE_AWK_NDE_GLOBALIDX:
case QSE_AWK_NDE_GBLIDX:
{
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 */
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 */
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;
}
case QSE_AWK_NDE_LOCAL:
case QSE_AWK_NDE_LCL:
{
qse_size_t n;
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;
}
case QSE_AWK_NDE_LOCALIDX:
case QSE_AWK_NDE_LCLIDX:
{
qse_size_t n;
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_NEWLINE (awk);
if (px->nlocals > 0)
if (px->nlcls > 0)
{
PRINT_TABS (awk, depth + 1);
qse_awk_getkw (awk, KW_LOCAL, &kw);
PUT_SRCSTRX (awk, kw.ptr, kw.len);
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"));
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_GLOBAL:
case QSE_AWK_NDE_LOCAL:
case QSE_AWK_NDE_GBL:
case QSE_AWK_NDE_LCL:
case QSE_AWK_NDE_ARG:
{
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_GLOBALIDX:
case QSE_AWK_NDE_LOCALIDX:
case QSE_AWK_NDE_GBLIDX:
case QSE_AWK_NDE_LCLIDX:
case QSE_AWK_NDE_ARGIDX:
{
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
* QSE_AWK_VAL_REF_XXX in awk.h */
QSE_AWK_NDE_NAMED,
QSE_AWK_NDE_GLOBAL,
QSE_AWK_NDE_LOCAL,
QSE_AWK_NDE_GBL,
QSE_AWK_NDE_LCL,
QSE_AWK_NDE_ARG,
QSE_AWK_NDE_NAMEDIDX,
QSE_AWK_NDE_GLOBALIDX,
QSE_AWK_NDE_LOCALIDX,
QSE_AWK_NDE_GBLIDX,
QSE_AWK_NDE_LCLIDX,
QSE_AWK_NDE_ARGIDX,
QSE_AWK_NDE_POS,
/* ---------------------------------- */
@ -162,7 +162,7 @@ struct qse_awk_nde_t
struct qse_awk_nde_blk_t
{
QSE_AWK_NDE_HDR;
qse_size_t nlocals;
qse_size_t nlcls;
qse_awk_nde_t* body;
};
@ -243,10 +243,10 @@ struct qse_awk_nde_rex_t
void* code;
};
/* QSE_AWK_NDE_NAMED, QSE_AWK_NDE_GLOBAL,
* QSE_AWK_NDE_LOCAL, QSE_AWK_NDE_ARG
* QSE_AWK_NDE_NAMEDIDX, QSE_AWK_NDE_GLOBALIDX,
* QSE_AWK_NDE_LOCALIDX, QSE_AWK_NDE_ARGIDX */
/* QSE_AWK_NDE_NAMED, QSE_AWK_NDE_GBL,
* QSE_AWK_NDE_LCL, QSE_AWK_NDE_ARG
* QSE_AWK_NDE_NAMEDIDX, QSE_AWK_NDE_GBLIDX,
* QSE_AWK_NDE_LCLIDX, QSE_AWK_NDE_ARGIDX */
struct qse_awk_nde_var_t
{
QSE_AWK_NDE_HDR;

View File

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