changed qse_runmain() to ignore mbwc error by calling qse_mbstowcsalldup().

added qse_mbstowcsalldup() and its variants
This commit is contained in:
2012-01-15 15:25:28 +00:00
parent 52710a87c9
commit fa850168ee
16 changed files with 246 additions and 46 deletions

View File

@ -58,7 +58,8 @@ public:
class SourceFile: public Source
{
public:
SourceFile (const char_t* name): name (name)
SourceFile (const char_t* name, qse_cmgr_t* cmgr = QSE_NULL):
name (name), cmgr (cmgr)
{
dir.ptr = QSE_NULL; dir.len = 0;
}
@ -71,6 +72,7 @@ public:
protected:
const char_t* name;
qse_cstr_t dir;
qse_cmgr_t* cmgr;
};
///

View File

@ -39,8 +39,12 @@
* This programs shows how to specify multiple console output files.
*/
/**
* The qse_awk_parsestd_type_t type defines the types of source I/O.
*/
enum qse_awk_parsestd_type_t
{
QSE_AWK_PARSESTD_NULL = 0, /* invalid type */
QSE_AWK_PARSESTD_FILE = 1,
QSE_AWK_PARSESTD_STR = 2
};
@ -56,12 +60,30 @@ struct qse_awk_parsestd_t
union
{
/**
* You can create a sio stream in advance and pass it to
* qse_awk_parsestd() via this field. */
qse_sio_t* sio;
struct
{
/** file path to open. QSE_NULL or '-' for stdin/stdout. */
const qse_char_t* path;
qse_cmgr_t* cmgr;
/* the streams created with the file path is set with this
* cmgr if it is not #QSE_NULL. */
qse_cmgr_t* cmgr;
} file;
/**
* For input, the ptr and the len field of str indicates the
* pointer and the length of a string to read.
*
* For output, the ptr and the len field of str indicates the
* pointer and the length of a deparsed source string. The output
* string is dynamically allocated. You must free this output
* pointer using #QSE_MMGR_FREE once you're done with it to avoid
* memory leaks.
*/
qse_xstr_t str;
} u;
};
@ -107,18 +129,19 @@ void* qse_awk_getxtnstd (
* and deparses it out to a buffer 'buf'.
* @code
* int n;
* qse_awk_parsestd_in_t in;
* qse_awk_parsestd_out_t out;
* qse_char_t buf[1000];
*
* qse_memset (buf, QSE_T(' '), QSE_COUNTOF(buf));
* buf[QSE_COUNTOF(buf)-1] = QSE_T('\0');
* in.type = QSE_AWK_PARSESTD_CP;
* in.u.cp = QSE_T("BEGIN { print 10; }");
* out.type = QSE_AWK_PARSESTD_CP;
* out.u.cp = buf;
* qse_awk_parsestd_t in;
* qse_awk_parsestd_t out;
*
* in.type = QSE_AWK_PARSESTD_STR;
* in.u.str.ptr = QSE_T("BEGIN { print 10; }");
* in.u.str.len = qse_strlen(in.u.str.ptr);
* out.type = QSE_AWK_PARSESTD_STR;
* n = qse_awk_parsestd (awk, &in, &out);
* if (n >= 0)
* {
* qse_printf (QSE_T("%s\n"), out.u.str.ptr);
* QSE_MMGR_FREE (out.u.str.ptr);
* }
* @endcode
*/
int qse_awk_parsestd (
@ -130,7 +153,8 @@ int qse_awk_parsestd (
/**
* The qse_awk_rtx_openstd() function creates a standard runtime context.
* The caller should keep the contents of @a icf and @a ocf valid throughout
* the lifetime of the runtime context created.
* the lifetime of the runtime context created. The @a cmgr is set to the
* streams created with @a icf and @a ocf if it is not #QSE_NULL.
*/
qse_awk_rtx_t* qse_awk_rtx_openstd (
qse_awk_t* awk,

View File

@ -52,6 +52,14 @@ int qse_mbstowcswithcmgr (
qse_cmgr_t* cmgr
);
int qse_mbstowcsallwithcmgr (
const qse_mchar_t* mbs,
qse_size_t* mbslen,
qse_wchar_t* wcs,
qse_size_t* wcslen,
qse_cmgr_t* cmgr
);
int qse_mbsntowcsnwithcmgr (
const qse_mchar_t* mbs,
qse_size_t* mbslen,
@ -60,6 +68,14 @@ int qse_mbsntowcsnwithcmgr (
qse_cmgr_t* cmgr
);
int qse_mbsntowcsnallwithcmgr (
const qse_mchar_t* mbs,
qse_size_t* mbslen,
qse_wchar_t* wcs,
qse_size_t* wcslen,
qse_cmgr_t* cmgr
);
int qse_mbsntowcsnuptowithcmgr (
const qse_mchar_t* mbs,
qse_size_t* mbslen,
@ -75,12 +91,24 @@ qse_wchar_t* qse_mbstowcsdupwithcmgr (
qse_cmgr_t* cmgr
);
qse_wchar_t* qse_mbstowcsalldupwithcmgr (
const qse_mchar_t* mbs,
qse_mmgr_t* mmgr,
qse_cmgr_t* cmgr
);
qse_wchar_t* qse_mbsatowcsdupwithcmgr (
const qse_mchar_t* mbs[],
qse_mmgr_t* mmgr,
qse_cmgr_t* cmgr
);
qse_wchar_t* qse_mbsatowcsalldupwithcmgr (
const qse_mchar_t* mbs[],
qse_mmgr_t* mmgr,
qse_cmgr_t* cmgr
);
int qse_wcstombswithcmgr (
const qse_wchar_t* wcs, /**< [in] wide-character string to convert*/
qse_size_t* wcslen, /**< [out] number of wide-characters handled */
@ -147,6 +175,15 @@ int qse_mbstowcs (
number of characters in the buffer for out */
);
int qse_mbstowcsall (
const qse_mchar_t* mbs, /**< [in] multibyte string to convert */
qse_size_t* mbslen, /**< [out] number of multibyte characters
handled */
qse_wchar_t* wcs, /**< [out] wide-character string buffer */
qse_size_t* wcslen /**< [in,out] buffer size for in,
number of characters in the buffer for out */
);
/**
* The qse_mbsntowcsn() function converts a multibyte string to a
* wide character string.
@ -165,6 +202,13 @@ int qse_mbsntowcsn (
qse_size_t* wcslen
);
int qse_mbsntowcsnall (
const qse_mchar_t* mbs,
qse_size_t* mbslen,
qse_wchar_t* wcs,
qse_size_t* wcslen
);
/**
* The qse_mbsntowcsnupto() function is the same as qse_mbsntowcsn()
* except that it stops once it has processed the @a stopper character.
@ -182,11 +226,21 @@ qse_wchar_t* qse_mbstowcsdup (
qse_mmgr_t* mmgr
);
qse_wchar_t* qse_mbstowcsalldup (
const qse_mchar_t* mbs,
qse_mmgr_t* mmgr
);
qse_wchar_t* qse_mbsatowcsdup (
const qse_mchar_t* mbs[],
qse_mmgr_t* mmgr
);
qse_wchar_t* qse_mbsatowcsalldup (
const qse_mchar_t* mbs[],
qse_mmgr_t* mmgr
);
/**
* The qse_wcstombs() function converts a null-terminated wide character
* string @a wcs to a multibyte string and writes it into the buffer pointed to

View File

@ -48,8 +48,9 @@ public:
{
public:
FileStream (const char_t* infile = QSE_NULL,
const char_t* outfile = QSE_NULL):
infile(infile), outfile(outfile)
const char_t* outfile = QSE_NULL,
qse_cmgr_t* cmgr = QSE_NULL):
infile(infile), outfile(outfile), cmgr(cmgr)
{
}
@ -61,6 +62,7 @@ public:
protected:
const char_t* infile;
const char_t* outfile;
qse_cmgr_t* cmgr;
};
class StringStream: public Stream