renamed qse_awk_getwerrmsg() to qse_awk_geterrmsgaswcs.
renamed qse_awk_getmerrmsg() to qse_awk_geterrmsgasmbs()
This commit is contained in:
parent
510bde2abc
commit
24bcca71bf
@ -1126,11 +1126,11 @@ static void open_mpi (mpi_t* mpi, int argc, qse_achar_t* argv[])
|
||||
#if defined(USE_LTDL)
|
||||
|
||||
#if defined(QSE_ACHAR_IS_MCHAR)
|
||||
if (qse_mbscmp (qse_mbsbasename(argv[0]), QSE_MT("qseawkmp")) != 0 &&
|
||||
qse_mbscmp (qse_mbsbasename(argv[0]), QSE_MT("qseawkmpi")) != 0) return;
|
||||
if (qse_mbscmp (qse_basenameasmbs(argv[0]), QSE_MT("qseawkmp")) != 0 &&
|
||||
qse_mbscmp (qse_basenameasmbs(argv[0]), QSE_MT("qseawkmpi")) != 0) return;
|
||||
#else
|
||||
if (qse_wcscmp (qse_wcsbasename(argv[0]), QSE_WT("qseawkmp")) != 0 &&
|
||||
qse_wcscmp (qse_wcsbasename(argv[0]), QSE_WT("qseawkmpi")) != 0) return;
|
||||
if (qse_wcscmp (qse_basenameaswcs(argv[0]), QSE_WT("qseawkmp")) != 0 &&
|
||||
qse_wcscmp (qse_basenameaswcs(argv[0]), QSE_WT("qseawkmpi")) != 0) return;
|
||||
#endif
|
||||
|
||||
if (lt_dlinit () != 0) return;
|
||||
|
@ -879,7 +879,7 @@ found:
|
||||
if (apath)
|
||||
{
|
||||
const qse_mchar_t* base;
|
||||
base = qse_mbsbasename (apath);
|
||||
base = qse_basenameasmbs (apath);
|
||||
|
||||
for (i = 0; i < QSE_COUNTOF(loccfg->auth_rule); i++)
|
||||
{
|
||||
@ -977,7 +977,7 @@ found:
|
||||
#endif
|
||||
if (!qinfo->xpath_nx)
|
||||
{
|
||||
xpath_base = qse_mbsbasename (qinfo->xpath);
|
||||
xpath_base = qse_basenameasmbs (qinfo->xpath);
|
||||
for (i = 0; i < QSE_COUNTOF(loccfg->cgi); i++)
|
||||
{
|
||||
struct cgi_t* cgi;
|
||||
@ -1004,7 +1004,7 @@ found:
|
||||
qse_size_t i;
|
||||
const qse_mchar_t* xpath_base;
|
||||
|
||||
xpath_base = qse_mbsbasename (qinfo->xpath);
|
||||
xpath_base = qse_basenameasmbs (qinfo->xpath);
|
||||
|
||||
*(const qse_mchar_t**)result = QSE_NULL;
|
||||
for (i = 0; i < QSE_COUNTOF(loccfg->mime); i++)
|
||||
@ -1043,7 +1043,7 @@ found:
|
||||
|
||||
id = (code == QSE_HTTPD_SERVERSTD_DIRACC)? 0: 1;
|
||||
|
||||
xpath_base = qse_mbsbasename (qinfo->xpath);
|
||||
xpath_base = qse_basenameasmbs (qinfo->xpath);
|
||||
|
||||
*(int*)result = 200;
|
||||
for (i = 0; i < QSE_COUNTOF(loccfg->access[id]); i++)
|
||||
|
@ -1707,30 +1707,30 @@ QSE_EXPORT const qse_awk_loc_t* qse_awk_geterrloc (
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_awk_getmerrmsg() function returns the error message describing
|
||||
* The qse_awk_geterrmsgasmbs() function returns the error message describing
|
||||
* the last error occurred.
|
||||
*
|
||||
* \return error message
|
||||
*/
|
||||
QSE_EXPORT const qse_mchar_t* qse_awk_getmerrmsg (
|
||||
QSE_EXPORT const qse_mchar_t* qse_awk_geterrmsgasmbs (
|
||||
qse_awk_t* awk /**< awk */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_awk_getwerrmsg() function returns the error message describing
|
||||
* The qse_awk_geterrmsgaswcs() function returns the error message describing
|
||||
* the last error occurred.
|
||||
*
|
||||
* \return error message
|
||||
*/
|
||||
QSE_EXPORT const qse_wchar_t* qse_awk_getwerrmsg (
|
||||
QSE_EXPORT const qse_wchar_t* qse_awk_geterrmsgaswcs (
|
||||
qse_awk_t* awk /**< awk */
|
||||
);
|
||||
|
||||
|
||||
#if defined(QSE_CHAR_IS_MCHAR)
|
||||
# define qse_awk_geterrmsg qse_awk_getmerrmsg
|
||||
# define qse_awk_geterrmsg qse_awk_geterrmsgasmbs
|
||||
#else
|
||||
# define qse_awk_geterrmsg qse_awk_getwerrmsg
|
||||
# define qse_awk_geterrmsg qse_awk_geterrmsgaswcs
|
||||
#endif
|
||||
|
||||
|
||||
@ -2231,15 +2231,31 @@ QSE_EXPORT qse_awk_val_t* qse_awk_rtx_loop (
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_awk_rtx_findfun() function finds the function structure by name
|
||||
* and returns the pointer to it if one is found. It returns #QSE_NULL if
|
||||
* it fails to find a function by the \a name.
|
||||
* The qse_awk_rtx_findfunwithmbs() function finds the function structure by
|
||||
* name and returns the pointer to it if one is found. It returns #QSE_NULL
|
||||
* if it fails to find a function by the \a name.
|
||||
*/
|
||||
QSE_EXPORT qse_awk_fun_t* qse_awk_rtx_findfun (
|
||||
qse_awk_rtx_t* rtx, /**< runtime context */
|
||||
const qse_char_t* name /**< function name */
|
||||
QSE_EXPORT qse_awk_fun_t* qse_awk_rtx_findfunwithmbs (
|
||||
qse_awk_rtx_t* rtx, /**< runtime context */
|
||||
const qse_mchar_t* name /**< function name */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_awk_rtx_findfunwithwcs() function finds the function structure by
|
||||
* name and returns the pointer to it if one is found. It returns #QSE_NULL
|
||||
* if it fails to find a function by the \a name.
|
||||
*/
|
||||
QSE_EXPORT qse_awk_fun_t* qse_awk_rtx_findfunwithwcs (
|
||||
qse_awk_rtx_t* rtx, /**< runtime context */
|
||||
const qse_wchar_t* name /**< function name */
|
||||
);
|
||||
|
||||
#if defined(QSE_CHAR_IS_MCHAR)
|
||||
# define qse_awk_rtx_findfun qse_awk_rtx_findfunwithmbs
|
||||
#else
|
||||
# define qse_awk_rtx_findfun qse_awk_rtx_findfunwithwcs
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The qse_awk_rtx_callfun() function invokes an AWK function described by
|
||||
* the structure pointed to by \a fun.
|
||||
@ -2253,7 +2269,7 @@ QSE_EXPORT qse_awk_val_t* qse_awk_rtx_callfun (
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_awk_rtx_call() function invokes an AWK function named \a name.
|
||||
* The qse_awk_rtx_callwithmbs() function invokes an AWK function named \a name.
|
||||
* However, it is not able to invoke an intrinsic function such as split().
|
||||
* The #QSE_AWK_PABLOCK option can be turned off to make illegal the BEGIN
|
||||
* blocks, the pattern-action blocks, and the END blocks.
|
||||
@ -2263,9 +2279,9 @@ QSE_EXPORT qse_awk_val_t* qse_awk_rtx_callfun (
|
||||
* rtx = qse_awk_rtx_open (awk, 0, rio);
|
||||
* if (rtx)
|
||||
* {
|
||||
* v = qse_awk_rtx_call (rtx, QSE_T("init"), QSE_NULL, 0);
|
||||
* v = qse_awk_rtx_callwithmbs (rtx, QSE_MT("init"), QSE_NULL, 0);
|
||||
* if (v) qse_awk_rtx_refdownval (rtx, v);
|
||||
* qse_awk_rtx_call (rtx, QSE_T("fini"), QSE_NULL, 0);
|
||||
* qse_awk_rtx_callwithmbs (rtx, QSE_MT("fini"), QSE_NULL, 0);
|
||||
* if (v) qse_awk_rtx_refdownval (rtx, v);
|
||||
* qse_awk_rtx_close (rtx);
|
||||
* }
|
||||
@ -2273,13 +2289,47 @@ QSE_EXPORT qse_awk_val_t* qse_awk_rtx_callfun (
|
||||
*
|
||||
* \return 0 on success, -1 on failure
|
||||
*/
|
||||
QSE_EXPORT qse_awk_val_t* qse_awk_rtx_call (
|
||||
qse_awk_rtx_t* rtx, /**< runtime context */
|
||||
const qse_char_t* name, /**< function name */
|
||||
qse_awk_val_t* args[], /**< arguments to the function */
|
||||
qse_size_t nargs /**< the number of arguments */
|
||||
QSE_EXPORT qse_awk_val_t* qse_awk_rtx_callwithmbs (
|
||||
qse_awk_rtx_t* rtx, /**< runtime context */
|
||||
const qse_mchar_t* name, /**< function name */
|
||||
qse_awk_val_t* args[], /**< arguments to the function */
|
||||
qse_size_t nargs /**< the number of arguments */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_awk_rtx_callwithwcs() function invokes an AWK function named \a name.
|
||||
* However, it is not able to invoke an intrinsic function such as split().
|
||||
* The #QSE_AWK_PABLOCK option can be turned off to make illegal the BEGIN
|
||||
* blocks, the pattern-action blocks, and the END blocks.
|
||||
*
|
||||
* The example shows typical usage of the function.
|
||||
* \code
|
||||
* rtx = qse_awk_rtx_open (awk, 0, rio);
|
||||
* if (rtx)
|
||||
* {
|
||||
* v = qse_awk_rtx_callwithwcs (rtx, QSE_WT("init"), QSE_NULL, 0);
|
||||
* if (v) qse_awk_rtx_refdownval (rtx, v);
|
||||
* qse_awk_rtx_callwithwcs (rtx, QSE_WT("fini"), QSE_NULL, 0);
|
||||
* if (v) qse_awk_rtx_refdownval (rtx, v);
|
||||
* qse_awk_rtx_close (rtx);
|
||||
* }
|
||||
* \endcode
|
||||
*
|
||||
* \return 0 on success, -1 on failure
|
||||
*/
|
||||
QSE_EXPORT qse_awk_val_t* qse_awk_rtx_callwithwcs (
|
||||
qse_awk_rtx_t* rtx, /**< runtime context */
|
||||
const qse_wchar_t* name, /**< function name */
|
||||
qse_awk_val_t* args[], /**< arguments to the function */
|
||||
qse_size_t nargs /**< the number of arguments */
|
||||
);
|
||||
|
||||
#if defined(QSE_CHAR_IS_MCHAR)
|
||||
# define qse_awk_rtx_call qse_awk_rtx_callwithmbs
|
||||
#else
|
||||
# define qse_awk_rtx_call qse_awk_rtx_callwithwcs
|
||||
#endif
|
||||
|
||||
/**
|
||||
* The qse_awk_rtx_callwithstrs() function is the same as qse_awk_rtx_call()
|
||||
* except that you pass pointers to null-terminated strings. It creates values
|
||||
@ -2501,27 +2551,27 @@ QSE_EXPORT const qse_awk_loc_t* qse_awk_rtx_geterrloc (
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_awk_rtx_getmerrmsg() function gets the string describing the last
|
||||
* The qse_awk_rtx_geterrmsgasmbs() function gets the string describing the last
|
||||
* error occurred during runtime.
|
||||
* \return error message
|
||||
*/
|
||||
QSE_EXPORT const qse_mchar_t* qse_awk_rtx_getmerrmsg (
|
||||
QSE_EXPORT const qse_mchar_t* qse_awk_rtx_geterrmsgasmbs (
|
||||
qse_awk_rtx_t* rtx /**< runtime context */
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_awk_rtx_getwerrmsg() function gets the string describing the last
|
||||
* The qse_awk_rtx_geterrmsgaswcs() function gets the string describing the last
|
||||
* error occurred during runtime.
|
||||
* \return error message
|
||||
*/
|
||||
QSE_EXPORT const qse_wchar_t* qse_awk_rtx_getwerrmsg (
|
||||
QSE_EXPORT const qse_wchar_t* qse_awk_rtx_geterrmsgaswcs (
|
||||
qse_awk_rtx_t* rtx /**< runtime context */
|
||||
);
|
||||
|
||||
#if defined(QSE_CHAR_IS_MCHAR)
|
||||
# define qse_awk_rtx_geterrmsg qse_awk_rtx_getmerrmsg
|
||||
# define qse_awk_rtx_geterrmsg qse_awk_rtx_geterrmsgasmbs
|
||||
#else
|
||||
# define qse_awk_rtx_geterrmsg qse_awk_rtx_getwerrmsg
|
||||
# define qse_awk_rtx_geterrmsg qse_awk_rtx_geterrmsgaswcs
|
||||
#endif
|
||||
|
||||
QSE_EXPORT const qse_char_t* qse_awk_rtx_backuperrmsg (
|
||||
@ -3262,6 +3312,34 @@ static QSE_INLINE void qse_awk_rtx_freemem (qse_awk_rtx_t* rtx, void* ptr)
|
||||
# define qse_awk_rtx_freemem(rtx,ptr) qse_awk_freemem(((qse_awk_rtx_alt_t*)rtx)->awk, ptr)
|
||||
#endif
|
||||
|
||||
|
||||
QSE_EXPORT qse_wchar_t* qse_awk_rtx_mbstowcsdup (
|
||||
qse_awk_rtx_t* rtx,
|
||||
const qse_mchar_t* mbs,
|
||||
qse_size_t* wcslen
|
||||
);
|
||||
|
||||
QSE_EXPORT qse_wchar_t* qse_awk_rtx_mbsntowcsdup (
|
||||
qse_awk_rtx_t* rtx,
|
||||
const qse_mchar_t* mbs,
|
||||
qse_size_t mbslen,
|
||||
qse_size_t* wcslen
|
||||
);
|
||||
|
||||
QSE_EXPORT qse_mchar_t* qse_awk_rtx_wcstombsdup (
|
||||
qse_awk_rtx_t* rtx,
|
||||
const qse_wchar_t* wcs,
|
||||
qse_size_t* mbslen
|
||||
);
|
||||
|
||||
qse_mchar_t* qse_awk_rtx_wcsntombsdup (
|
||||
qse_awk_rtx_t* rtx,
|
||||
const qse_wchar_t* wcs,
|
||||
qse_size_t wcslen,
|
||||
qse_size_t* mbslen
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* The qse_getawknilval() function returns the pointer to the predefined
|
||||
* nil value. you can call this without creating a runtime context.
|
||||
|
@ -129,10 +129,10 @@ QSE_EXPORT int qse_ismbsdrivecurpath (
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_mbsbasename() function returns the pointer to the file name
|
||||
* The qse_basenameasmbs() function returns the pointer to the file name
|
||||
* segment in a multibyte path name.
|
||||
*/
|
||||
QSE_EXPORT const qse_mchar_t* qse_mbsbasename (
|
||||
QSE_EXPORT const qse_mchar_t* qse_basenameasmbs (
|
||||
const qse_mchar_t* path
|
||||
);
|
||||
|
||||
@ -237,10 +237,10 @@ QSE_EXPORT int qse_iswcsdrivecurpath (
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_wcsbasename() function returns the pointer to the file name
|
||||
* The qse_basenameaswcs() function returns the pointer to the file name
|
||||
* segment in a wide-character path name.
|
||||
*/
|
||||
QSE_EXPORT const qse_wchar_t* qse_wcsbasename (
|
||||
QSE_EXPORT const qse_wchar_t* qse_basenameaswcs (
|
||||
const qse_wchar_t* path
|
||||
);
|
||||
|
||||
@ -313,7 +313,7 @@ QSE_EXPORT qse_wchar_t* qse_mergewcspathdup (
|
||||
# define qse_isdrivepath(p) qse_ismbsdrivepath(p)
|
||||
# define qse_isdriveabspath(p) qse_ismbsdriveabspath(p)
|
||||
# define qse_isdrivecurpath(p) qse_ismbsdrivecurpath(p)
|
||||
# define qse_basename(path) qse_mbsbasename(path)
|
||||
# define qse_basename(path) qse_basenameasmbs(path)
|
||||
# define qse_pathcore(p) qse_mbspathcore(p)
|
||||
# define qse_canonpath(p,c,f) qse_canonmbspath(p,c,f)
|
||||
# define qse_mergepathdup(d,f,m) qse_mergembspathdup(d,f,m)
|
||||
@ -323,7 +323,7 @@ QSE_EXPORT qse_wchar_t* qse_mergewcspathdup (
|
||||
# define qse_isdrivepath(p) qse_iswcsdrivepath(p)
|
||||
# define qse_isdriveabspath(p) qse_iswcsdriveabspath(p)
|
||||
# define qse_isdrivecurpath(p) qse_iswcsdrivecurpath(p)
|
||||
# define qse_basename(path) qse_wcsbasename(path)
|
||||
# define qse_basename(path) qse_basenameaswcs(path)
|
||||
# define qse_pathcore(p) qse_wcspathcore(p)
|
||||
# define qse_canonpath(p,c,f) qse_canonwcspath(p,c,f)
|
||||
# define qse_mergepathdup(d,f,m) qse_mergewcspathdup(d,f,m)
|
||||
|
@ -1208,20 +1208,20 @@ int StdAwk::SourceFile::open (Data& io)
|
||||
file = ioname;
|
||||
if (io.getPrevHandle())
|
||||
{
|
||||
const char_t* outer;
|
||||
const qse_char_t* outer;
|
||||
|
||||
outer = qse_sio_getpath ((qse_sio_t*)io.getPrevHandle());
|
||||
if (outer)
|
||||
{
|
||||
const qse_char_t* base;
|
||||
|
||||
base = qse_basename (outer);
|
||||
base = qse_basename(outer);
|
||||
if (base != outer && ioname[0] != QSE_T('/'))
|
||||
{
|
||||
size_t tmplen, totlen, dirlen;
|
||||
|
||||
dirlen = base - outer;
|
||||
totlen = qse_strlen(ioname) + dirlen;
|
||||
totlen = qse_strlen(ioname) + dirlen;
|
||||
if (totlen >= QSE_COUNTOF(fbuf))
|
||||
{
|
||||
dbuf = (qse_char_t*) QSE_MMGR_ALLOC (
|
||||
@ -1309,7 +1309,7 @@ int StdAwk::SourceString::open (Data& io)
|
||||
{
|
||||
const qse_char_t* base;
|
||||
|
||||
base = qse_basename (outer);
|
||||
base = qse_basename(outer);
|
||||
if (base != outer && ioname[0] != QSE_T('/'))
|
||||
{
|
||||
size_t tmplen, totlen, dirlen;
|
||||
@ -1318,7 +1318,7 @@ int StdAwk::SourceString::open (Data& io)
|
||||
totlen = qse_strlen(ioname) + dirlen;
|
||||
if (totlen >= QSE_COUNTOF(fbuf))
|
||||
{
|
||||
dbuf = (qse_char_t*) QSE_MMGR_ALLOC (
|
||||
dbuf = (qse_char_t*)QSE_MMGR_ALLOC(
|
||||
((Awk*)io)->getMmgr(),
|
||||
QSE_SIZEOF(qse_char_t) * (totlen + 1)
|
||||
);
|
||||
|
@ -194,7 +194,7 @@ const qse_awk_loc_t* qse_awk_geterrloc (qse_awk_t* awk)
|
||||
return &awk->errinf.loc;
|
||||
}
|
||||
|
||||
const qse_mchar_t* qse_awk_getmerrmsg (qse_awk_t* awk)
|
||||
const qse_mchar_t* qse_awk_geterrmsgasmbs (qse_awk_t* awk)
|
||||
{
|
||||
#if defined(QSE_CHAR_IS_MCHAR)
|
||||
return (awk->errinf.msg[0] == QSE_T('\0'))?
|
||||
@ -213,7 +213,7 @@ const qse_mchar_t* qse_awk_getmerrmsg (qse_awk_t* awk)
|
||||
#endif
|
||||
}
|
||||
|
||||
const qse_wchar_t* qse_awk_getwerrmsg (qse_awk_t* awk)
|
||||
const qse_wchar_t* qse_awk_geterrmsgaswcs (qse_awk_t* awk)
|
||||
{
|
||||
#if defined(QSE_CHAR_IS_MCHAR)
|
||||
const qse_char_t* msg;
|
||||
@ -310,7 +310,7 @@ const qse_awk_loc_t* qse_awk_rtx_geterrloc (qse_awk_rtx_t* rtx)
|
||||
return &rtx->errinf.loc;
|
||||
}
|
||||
|
||||
const qse_mchar_t* qse_awk_rtx_getmerrmsg (qse_awk_rtx_t* rtx)
|
||||
const qse_mchar_t* qse_awk_rtx_geterrmsgasmbs (qse_awk_rtx_t* rtx)
|
||||
{
|
||||
#if defined(QSE_CHAR_IS_MCHAR)
|
||||
return (rtx->errinf.msg[0] == QSE_T('\0')) ?
|
||||
@ -329,7 +329,7 @@ const qse_mchar_t* qse_awk_rtx_getmerrmsg (qse_awk_rtx_t* rtx)
|
||||
#endif
|
||||
}
|
||||
|
||||
const qse_wchar_t* qse_awk_rtx_getwerrmsg (qse_awk_rtx_t* rtx)
|
||||
const qse_wchar_t* qse_awk_rtx_geterrmsgaswcs (qse_awk_rtx_t* rtx)
|
||||
{
|
||||
#if defined(QSE_CHAR_IS_MCHAR)
|
||||
const qse_char_t* msg;
|
||||
|
@ -1021,3 +1021,101 @@ void* qse_awk_rtx_callocmem (qse_awk_rtx_t* rtx, qse_size_t size)
|
||||
return ptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
qse_wchar_t* qse_awk_rtx_mbstowcsdup (qse_awk_rtx_t* rtx, const qse_mchar_t* mbs, qse_size_t* _wcslen)
|
||||
{
|
||||
qse_size_t mbslen, wcslen;
|
||||
qse_wchar_t* wcs;
|
||||
|
||||
/* if i use qse_mbstowcsdupwithcmgr(), i cannot pinpoint the exact failure cause.
|
||||
* let's do it differently. */
|
||||
if (qse_mbstowcswithcmgr(mbs, &mbslen, QSE_NULL, &wcslen, qse_awk_rtx_getcmgr(rtx)) <= -1)
|
||||
{
|
||||
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EINVAL, QSE_NULL);
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
wcslen = wcslen + 1; /* for terminating null */
|
||||
|
||||
wcs = qse_awk_rtx_allocmem(rtx, QSE_SIZEOF(*wcs) * wcslen);
|
||||
if (!wcs) return QSE_NULL;
|
||||
|
||||
qse_mbstowcswithcmgr (mbs, &mbslen, wcs, &wcslen, qse_awk_rtx_getcmgr(rtx));
|
||||
if (_wcslen) *_wcslen = wcslen;
|
||||
return wcs;
|
||||
}
|
||||
|
||||
qse_mchar_t* qse_awk_rtx_wcstombsdup (qse_awk_rtx_t* rtx, const qse_wchar_t* wcs, qse_size_t* _mbslen)
|
||||
{
|
||||
qse_size_t mbslen, wcslen;
|
||||
qse_mchar_t* mbs;
|
||||
|
||||
if (qse_wcstombswithcmgr(wcs, &wcslen, QSE_NULL, &mbslen, qse_awk_rtx_getcmgr(rtx)) <= -1)
|
||||
{
|
||||
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EINVAL, QSE_NULL);
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
mbslen = mbslen + 1; /* for terminating null */
|
||||
|
||||
mbs = qse_awk_rtx_allocmem(rtx, QSE_SIZEOF(*mbs) * mbslen);
|
||||
if (!mbs) return QSE_NULL;
|
||||
|
||||
qse_wcstombswithcmgr (wcs, &wcslen, mbs, &mbslen, qse_awk_rtx_getcmgr(rtx));
|
||||
if (_mbslen) *_mbslen = mbslen;
|
||||
return mbs;
|
||||
}
|
||||
|
||||
|
||||
qse_wchar_t* qse_awk_rtx_mbsntowcsdup (qse_awk_rtx_t* rtx, const qse_mchar_t* mbs, qse_size_t _mbslen, qse_size_t* _wcslen)
|
||||
{
|
||||
qse_size_t mbslen, wcslen;
|
||||
qse_wchar_t* wcs;
|
||||
|
||||
/* if i use qse_mbstowcsdupwithcmgr(), i cannot pinpoint the exact failure cause.
|
||||
* let's do it differently. */
|
||||
mbslen = _mbslen;
|
||||
if (qse_mbsntowcsnwithcmgr(mbs, &mbslen, QSE_NULL, &wcslen, qse_awk_rtx_getcmgr(rtx)) <= -1)
|
||||
{
|
||||
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EINVAL, QSE_NULL);
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
wcs = qse_awk_rtx_allocmem(rtx, QSE_SIZEOF(*wcs) * (wcslen + 1));
|
||||
if (!wcs) return QSE_NULL;
|
||||
|
||||
mbslen= _mbslen;
|
||||
qse_mbsntowcsnwithcmgr (mbs, &mbslen, wcs, &wcslen, qse_awk_rtx_getcmgr(rtx));
|
||||
wcs[wcslen] = QSE_WT('\0');
|
||||
|
||||
if (_wcslen) *_wcslen = wcslen;
|
||||
return wcs;
|
||||
}
|
||||
|
||||
|
||||
qse_mchar_t* qse_awk_rtx_wcsntombsdup (qse_awk_rtx_t* rtx, const qse_wchar_t* wcs, qse_size_t _wcslen, qse_size_t* _mbslen)
|
||||
{
|
||||
qse_size_t mbslen, wcslen;
|
||||
qse_mchar_t* mbs;
|
||||
|
||||
wcslen = _wcslen;
|
||||
if (qse_wcsntombsnwithcmgr(wcs, &wcslen, QSE_NULL, &mbslen, qse_awk_rtx_getcmgr(rtx)) <= -1)
|
||||
{
|
||||
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EINVAL, QSE_NULL);
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
mbs = qse_awk_rtx_allocmem(rtx, QSE_SIZEOF(*mbs) * (mbslen + 1));
|
||||
if (!mbs) return QSE_NULL;
|
||||
|
||||
wcslen = _wcslen;
|
||||
qse_wcsntombsnwithcmgr (wcs, &wcslen, mbs, &mbslen, qse_awk_rtx_getcmgr(rtx));
|
||||
mbs[mbslen] = QSE_MT('\0');
|
||||
|
||||
if (_mbslen) *_mbslen = mbslen;
|
||||
return mbs;
|
||||
}
|
||||
|
@ -1508,7 +1508,7 @@ qse_awk_val_t* qse_awk_rtx_loop (qse_awk_rtx_t* rtx)
|
||||
}
|
||||
|
||||
/* find an AWK function by name */
|
||||
qse_awk_fun_t* qse_awk_rtx_findfun (qse_awk_rtx_t* rtx, const qse_char_t* name)
|
||||
static qse_awk_fun_t* find_fun (qse_awk_rtx_t* rtx, const qse_char_t* name)
|
||||
{
|
||||
qse_htb_pair_t* pair;
|
||||
|
||||
@ -1528,6 +1528,36 @@ qse_awk_fun_t* qse_awk_rtx_findfun (qse_awk_rtx_t* rtx, const qse_char_t* name)
|
||||
return (qse_awk_fun_t*)QSE_HTB_VPTR(pair);
|
||||
}
|
||||
|
||||
qse_awk_fun_t* qse_awk_rtx_findfunwithmbs (qse_awk_rtx_t* rtx, const qse_mchar_t* name)
|
||||
{
|
||||
#if defined(QSE_CHAR_IS_MCHAR)
|
||||
return find_fun(rtx, name);
|
||||
#else
|
||||
qse_mcstr_t mbs;
|
||||
qse_awk_fun_t* fun;
|
||||
mbs.ptr = qse_awk_rtx_wcstombsdup(rtx, name, &mbs.len);
|
||||
if (!mbs.ptr) return -1;
|
||||
fun = find_fun(rtx, mbs.ptr);
|
||||
qse_awk_rtx_freemem (rtx, mbs.ptr);
|
||||
return fun;
|
||||
#endif
|
||||
}
|
||||
|
||||
qse_awk_fun_t* qse_awk_rtx_findfunwithwcs (qse_awk_rtx_t* rtx, const qse_wchar_t* name)
|
||||
{
|
||||
#if defined(QSE_CHAR_IS_MCHAR)
|
||||
qse_wcstr_t wcs;
|
||||
qse_awk_fun_t* fun;
|
||||
wcs.ptr = qse_awk_rtx_mbstowcsdup(rtx, name, &wcs.len);
|
||||
if (!wcs.ptr) return -1;
|
||||
fun = find_fun(rtx, wcs.ptr);
|
||||
qse_awk_rtx_freemem (rtx, wcs.ptr);
|
||||
return fun;
|
||||
#else
|
||||
return find_fun(rtx, name);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* call an AWK function by the function structure */
|
||||
qse_awk_val_t* qse_awk_rtx_callfun (qse_awk_rtx_t* rtx, qse_awk_fun_t* fun, qse_awk_val_t* args[], qse_size_t nargs)
|
||||
{
|
||||
@ -1606,11 +1636,21 @@ qse_awk_val_t* qse_awk_rtx_callfun (qse_awk_rtx_t* rtx, qse_awk_fun_t* fun, qse_
|
||||
}
|
||||
|
||||
/* call an AWK function by name */
|
||||
qse_awk_val_t* qse_awk_rtx_call (qse_awk_rtx_t* rtx, const qse_char_t* name, qse_awk_val_t* args[], qse_size_t nargs)
|
||||
qse_awk_val_t* qse_awk_rtx_callwithmbs (qse_awk_rtx_t* rtx, const qse_mchar_t* name, qse_awk_val_t* args[], qse_size_t nargs)
|
||||
{
|
||||
qse_awk_fun_t* fun;
|
||||
|
||||
fun = qse_awk_rtx_findfun(rtx, name);
|
||||
fun = qse_awk_rtx_findfunwithmbs(rtx, name);
|
||||
if (!fun) return QSE_NULL;
|
||||
|
||||
return qse_awk_rtx_callfun(rtx, fun, args, nargs);
|
||||
}
|
||||
|
||||
qse_awk_val_t* qse_awk_rtx_callwithwcs (qse_awk_rtx_t* rtx, const qse_wchar_t* name, qse_awk_val_t* args[], qse_size_t nargs)
|
||||
{
|
||||
qse_awk_fun_t* fun;
|
||||
|
||||
fun = qse_awk_rtx_findfunwithwcs(rtx, name);
|
||||
if (!fun) return QSE_NULL;
|
||||
|
||||
return qse_awk_rtx_callfun(rtx, fun, args, nargs);
|
||||
|
@ -30,7 +30,7 @@
|
||||
#define IS_MSEP(c) QSE_ISPATHMBSEP(c)
|
||||
#define IS_WSEP(c) QSE_ISPATHWCSEP(c)
|
||||
|
||||
const qse_mchar_t* qse_mbsbasename (const qse_mchar_t* path)
|
||||
const qse_mchar_t* qse_basenameasmbs (const qse_mchar_t* path)
|
||||
{
|
||||
const qse_mchar_t* p, * last = QSE_NULL;
|
||||
|
||||
@ -42,7 +42,7 @@ const qse_mchar_t* qse_mbsbasename (const qse_mchar_t* path)
|
||||
return (last == QSE_NULL)? path: (last + 1);
|
||||
}
|
||||
|
||||
const qse_wchar_t* qse_wcsbasename (const qse_wchar_t* path)
|
||||
const qse_wchar_t* qse_basenameaswcs (const qse_wchar_t* path)
|
||||
{
|
||||
const qse_wchar_t* p, * last = QSE_NULL;
|
||||
|
||||
@ -61,7 +61,7 @@ qse_mchar_t* qse_substmbsbasenamedup (const qse_mchar_t* path, const qse_mchar_t
|
||||
qse_mcstr_t seg[3];
|
||||
qse_size_t idx = 0;
|
||||
|
||||
b = qse_mbsbasename(path);
|
||||
b = qse_basenameasmbs(path);
|
||||
if (b)
|
||||
{
|
||||
seg[idx].ptr = (qse_mchar_t*)path;
|
||||
@ -85,7 +85,7 @@ qse_wchar_t* qse_substwcsbasenamedup (const qse_wchar_t* path, const qse_wchar_t
|
||||
qse_wcstr_t seg[3];
|
||||
qse_size_t idx = 0;
|
||||
|
||||
b = qse_wcsbasename(path);
|
||||
b = qse_basenameaswcs(path);
|
||||
if (b)
|
||||
{
|
||||
seg[idx].ptr = (qse_wchar_t*)path;
|
||||
|
@ -43,12 +43,12 @@
|
||||
#if defined(QSE_HTTPD_DEBUG)
|
||||
# include <qse/si/sio.h>
|
||||
# include <qse/cmn/path.h>
|
||||
# define HTTPD_DBGOUT0(fmt) qse_putmbsf("%06d %-20hs " fmt, (int)__LINE__, qse_mbsbasename(__FILE__))
|
||||
# define HTTPD_DBGOUT1(fmt,a1) qse_putmbsf("%06d %-20hs " fmt, (int)__LINE__, qse_mbsbasename(__FILE__), (a1))
|
||||
# define HTTPD_DBGOUT2(fmt,a1,a2) qse_putmbsf("%06d %-20hs " fmt, (int)__LINE__, qse_mbsbasename(__FILE__), (a1), (a2))
|
||||
# define HTTPD_DBGOUT3(fmt,a1,a2,a3) qse_putmbsf("%06d %-20hs " fmt, (int)__LINE__, qse_mbsbasename(__FILE__), (a1), (a2), (a3))
|
||||
# define HTTPD_DBGOUT4(fmt,a1,a2,a3,a4) qse_putmbsf("%06d %-20hs " fmt, (int)__LINE__, qse_mbsbasename(__FILE__), (a1), (a2), (a3), (a4))
|
||||
# define HTTPD_DBGOUT5(fmt,a1,a2,a3,a4,a5) qse_putmbsf("%06d %-20hs " fmt, (int)__LINE__, qse_mbsbasename(__FILE__), (a1), (a2), (a3), (a4), (a5))
|
||||
# define HTTPD_DBGOUT0(fmt) qse_putmbsf("%06d %-20hs " fmt, (int)__LINE__, qse_basenameasmbs(__FILE__))
|
||||
# define HTTPD_DBGOUT1(fmt,a1) qse_putmbsf("%06d %-20hs " fmt, (int)__LINE__, qse_basenameasmbs(__FILE__), (a1))
|
||||
# define HTTPD_DBGOUT2(fmt,a1,a2) qse_putmbsf("%06d %-20hs " fmt, (int)__LINE__, qse_basenameasmbs(__FILE__), (a1), (a2))
|
||||
# define HTTPD_DBGOUT3(fmt,a1,a2,a3) qse_putmbsf("%06d %-20hs " fmt, (int)__LINE__, qse_basenameasmbs(__FILE__), (a1), (a2), (a3))
|
||||
# define HTTPD_DBGOUT4(fmt,a1,a2,a3,a4) qse_putmbsf("%06d %-20hs " fmt, (int)__LINE__, qse_basenameasmbs(__FILE__), (a1), (a2), (a3), (a4))
|
||||
# define HTTPD_DBGOUT5(fmt,a1,a2,a3,a4,a5) qse_putmbsf("%06d %-20hs " fmt, (int)__LINE__, qse_basenameasmbs(__FILE__), (a1), (a2), (a3), (a4), (a5))
|
||||
#else
|
||||
# define HTTPD_DBGOUT0(fmt)
|
||||
# define HTTPD_DBGOUT1(fmt,a1)
|
||||
|
@ -94,14 +94,14 @@
|
||||
# define canon_fspath(path,canon,flags) qse_canonmbspath(path,canon,flags)
|
||||
# define merge_fspath_dup(dir,file,mmgr) qse_mergembspathdup(dir,file,mmgr)
|
||||
# define get_fspath_core(fspath) qse_mbspathcore(fspath)
|
||||
# define get_fspath_base(fspath) qse_mbsbasename(fspath)
|
||||
# define get_fspath_base(fspath) qse_basenameasmbs(fspath)
|
||||
# define IS_FSPATHSEP(x) QSE_ISPATHMBSEP(x)
|
||||
# define QSE_FS_T(x) QSE_MT(x)
|
||||
#else
|
||||
# define canon_fspath(fspath,canon,flags) qse_canonwcspath(fspath,canon,flags)
|
||||
# define merge_fspath_dup(dir,file,mmgr) qse_mergewcspathdup(dir,file,mmgr)
|
||||
# define get_fspath_core(fspath) qse_wcspathcore(fspath)
|
||||
# define get_fspath_base(fspath) qse_wcsbasename(fspath)
|
||||
# define get_fspath_base(fspath) qse_basenameaswcs(fspath)
|
||||
# define IS_FSPATHSEP(x) QSE_ISPATHWCSEP(x)
|
||||
# define QSE_FS_T(x) QSE_WT(x)
|
||||
#endif
|
||||
|
@ -211,7 +211,7 @@ static qse_ssize_t sf_in_open (qse_xli_t* xli, qse_xli_io_arg_t* arg, xtn_t* xtn
|
||||
const qse_char_t* base;
|
||||
|
||||
/* i'm being included from another file */
|
||||
base = qse_basename (outer);
|
||||
base = qse_basename(outer);
|
||||
if (base != outer && arg->name[0] != QSE_T('/'))
|
||||
{
|
||||
qse_size_t tmplen, totlen, dirlen;
|
||||
@ -438,7 +438,7 @@ static qse_ssize_t sf_out_open (qse_xli_t* xli, qse_xli_io_arg_t* arg, xtn_t* xt
|
||||
const qse_char_t* base;
|
||||
|
||||
/* i'm being included from another file */
|
||||
base = qse_basename (outer);
|
||||
base = qse_basename(outer);
|
||||
if (base != outer && arg->name[0] != QSE_T('/'))
|
||||
{
|
||||
qse_size_t tmplen, totlen, dirlen;
|
||||
|
@ -166,7 +166,7 @@ int main (int argc, char* argv[])
|
||||
switch (c)
|
||||
{
|
||||
case 'h':
|
||||
print_usage (qse_mbsbasename(argv[0]));
|
||||
print_usage (qse_basenameasmbs(argv[0]));
|
||||
return 0;
|
||||
|
||||
case 'k':
|
||||
@ -200,7 +200,7 @@ int main (int argc, char* argv[])
|
||||
|
||||
case '?':
|
||||
case ':':
|
||||
print_usage (qse_mbsbasename(argv[0]));
|
||||
print_usage (qse_basenameasmbs(argv[0]));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user