changed qse_awk_parsestd_t and related code.

changed to use windows API for WIN32 in slmb.c
This commit is contained in:
2012-01-06 14:38:11 +00:00
parent 42431d2642
commit 70090bc117
22 changed files with 665 additions and 521 deletions

View File

@ -22,6 +22,7 @@
#define _QSE_AWK_STD_H_
#include <qse/awk/awk.h>
#include <qse/cmn/sio.h>
/** @file
* This file defines functions and data types that help you create
@ -38,49 +39,34 @@
* This programs shows how to specify multiple console output files.
*/
/**
* The qse_awk_parsestd_type_t type defines a source script type
*/
enum qse_awk_parsestd_type_t
{
QSE_AWK_PARSESTD_FILE = 0, /**< file name */
QSE_AWK_PARSESTD_CP = 1, /**< character pointer */
QSE_AWK_PARSESTD_CPL = 2, /**< character pointer + length */
QSE_AWK_PARSESTD_STDIO = 3 /**< standard input/output */
QSE_AWK_PARSESTD_FILE = 1,
QSE_AWK_PARSESTD_STR = 2
};
typedef enum qse_awk_parsestd_type_t qse_awk_parsestd_type_t;
/**
* The qse_awk_parsestd_in_t type defines a source input.
* The qse_awk_parsestd_t type defines a source I/O.
*/
struct qse_awk_parsestd_in_t
struct qse_awk_parsestd_t
{
qse_awk_parsestd_type_t type;
union
{
const qse_char_t* file;
const qse_char_t* cp;
qse_cstr_t cpl;
qse_sio_t* sio;
struct
{
const qse_char_t* path;
qse_cmgr_t* cmgr;
} file;
qse_xstr_t str;
} u;
};
typedef struct qse_awk_parsestd_in_t qse_awk_parsestd_in_t;
/**
* The qse_awk_parsestd_out_t type defines a source output.
*/
struct qse_awk_parsestd_out_t
{
qse_awk_parsestd_type_t type;
union
{
const qse_char_t* file;
qse_char_t* cp;
qse_xstr_t cpl;
} u;
};
typedef struct qse_awk_parsestd_out_t qse_awk_parsestd_out_t;
typedef struct qse_awk_parsestd_t qse_awk_parsestd_t;
#ifdef __cplusplus
extern "C" {
@ -136,9 +122,9 @@ void* qse_awk_getxtnstd (
* @endcode
*/
int qse_awk_parsestd (
qse_awk_t* awk,
const qse_awk_parsestd_in_t* in,
qse_awk_parsestd_out_t* out
qse_awk_t* awk,
qse_awk_parsestd_t* in,
qse_awk_parsestd_t* out
);
/**

View File

@ -24,6 +24,12 @@
#include <qse/types.h>
#include <qse/macros.h>
/** @file
* This file provides functions, types, macros for
* multibyte/wide-character conversion based on system locale.
*
*
*/
/**
* The qse_mbstate_t type defines a structure large enough to hold
@ -114,7 +120,7 @@ qse_size_t qse_slmblen (
* The qse_slmblenmax() function returns the value of MB_CUR_MAX.
* Note that QSE_MBLEN_MAX defines MB_LEN_MAX.
*/
int qse_slmblenmax (
qse_size_t qse_slmblenmax (
void
);

View File

@ -24,6 +24,14 @@
#include <qse/types.h>
#include <qse/macros.h>
/** @file
* This file provides functions, types, macros for utf8 conversion.
*/
/**
* The QSE_UTF8LEN_MAX macro defines the maximum number of bytes
* needed to form a single unicode character.
*/
#if QSE_SIZEOF_WCHAR_T == 2
# define QSE_UTF8LEN_MAX 3
#elif QSE_SIZEOF_WCHAR_T == 4
@ -36,24 +44,19 @@
extern "C" {
#endif
/**
* The qse_uctoutf8len() function returns the number bytes in the utf8 sequence
* that would result from the original unicode character.
* @return
* - 0 is returned if @a uc is invalid.
* - A positive integer is returned in all other cases.
*/
qse_size_t qse_uctoutf8len (
qse_wchar_t uc
);
/**
* The qse_uctoutf8() function converts a unicode character to a utf8 sequence.
* @return
* - 0 is returned if @a uc is invalid.
* - An integer greater than @a size is returned if the utf8 sequence buffer is
* not large enough.
* - An integer greater than @a size is returned if the @a utf8 sequence buffer
* is not #QSE_NULL and not large enough. This integer is actually the number
* of bytes needed.
* - If @a utf8 is #QSE_NULL, the number of bytes that would have been stored
* into @a utf8 if it had not been #QSE_NULL is returned.
* - An integer between 1 and size inclusive is returned in all other cases.
* @note
* This function doesn't check invalid unicode code points and performs
* conversion compuationally.
*/
qse_size_t qse_uctoutf8 (
qse_wchar_t uc,
@ -61,17 +64,40 @@ qse_size_t qse_uctoutf8 (
qse_size_t size
);
/**
* The qse_utf8touc() function converts a utf8 sequence to a unicode character.
* @return
* - 0 is returned if the @a utf8 sequence is invalid.
* - An integer greater than @a size is returned if the @a utf8 sequence is
* not complete.
* - An integer between 1 and size inclusive is returned in all other cases.
*/
qse_size_t qse_utf8touc (
const qse_mchar_t* utf8,
qse_size_t size,
qse_wchar_t* uc
);
/**
* The qse_utf8lenmax() function scans at most @a size bytes from the @a utf8
* sequence and returns the number of bytes needed to form a single unicode
* character.
* @return
* - 0 is returned if the @a utf8 sequence is invalid.
* - An integer greater than @a size is returned if the @a utf8 sequence is
* not complete.
* - An integer between 1 and size inclusive is returned in all other cases.
*/
qse_size_t qse_utf8len (
const qse_mchar_t* utf8,
qse_size_t len
qse_size_t size
);
/**
* The qse_utf8lenmax() function returns the maximum number of bytes needed
* to form a single unicode character. Use #QSE_UTF8LEN_MAX if you need a
* compile-time constant.
*/
qse_size_t qse_utf8lenmax (
void
);

View File

@ -46,16 +46,20 @@ struct qse_sed_iostd_t
enum
{
QSE_SED_IOSTD_NULL, /** invalid resource */
QSE_SED_IOSTD_SIO,
QSE_SED_IOSTD_FILE,
QSE_SED_IOSTD_MEM
QSE_SED_IOSTD_STR,
QSE_SED_IOSTD_SIO
} type;
union
{
struct
{
const qse_char_t* path;
qse_cmgr_t* cmgr;
} file;
qse_xstr_t str;
qse_sio_t* sio;
const qse_char_t* file;
qse_xstr_t mem;
} u;
};
@ -113,22 +117,28 @@ int qse_sed_compstd (
/**
* The qse_sed_compstdfile() function compiles a sed script from
* a single file @a infile.
* a single file @a infile. If @a infile is #QSE_NULL, it reads
* the script from the standard input.
* When #QSE_CHAR_IS_WCHAR is defined, it converts the multibyte
* sequences in the file @a infile to wide characters via the
* #qse_cmgr_t interface @a cmgr. If @a cmgr is #QSE_NULL, it uses
* the default interface. It calls cmgr->mbtowc() for conversion.
* @return 0 on success, -1 on failure
*/
int qse_sed_compstdfile (
qse_sed_t* sed,
const qse_char_t* infile
const qse_char_t* infile,
qse_cmgr_t* cmgr
);
/**
* The qse_sed_compstdmem() function compiles a sed script stored
* in a null-terminated string pointed to by @a str.
* The qse_sed_compstd() function compiles a sed script stored
* in a null-terminated string pointed to by @a script.
* @return 0 on success, -1 on failure
*/
int qse_sed_compstdmem (
int qse_sed_compstdstr (
qse_sed_t* sed,
const qse_char_t* str
const qse_char_t* script
);
/**
@ -164,7 +174,8 @@ int qse_sed_execstd (
int qse_sed_execstdfile (
qse_sed_t* sed,
const qse_char_t* infile,
const qse_char_t* outfile
const qse_char_t* outfile,
qse_cmgr_t* cmgr
);
#ifdef __cplusplus

View File

@ -697,7 +697,7 @@ typedef void* (*qse_mmgr_realloc_t) (void* ctx, void* ptr, qse_size_t n);
typedef void (*qse_mmgr_free_t) (void* ctx, void* ptr);
/**
* The qse_mmgr_t type defines a set of functions for memory management.
* The qse_mmgr_t type defines the memory management interface.
* As the type is merely a structure, it is just used as a single container
* for memory management functions with a pointer to user-defined data.
* The user-defined data pointer @a ctx is passed to each memory management
@ -730,7 +730,10 @@ typedef qse_size_t (*qse_cmgr_wctomb_t) (
/**
* The qse_cmgr_t type defines the character-level interface to
* multibyte/wide-character string conversion.
* multibyte/wide-character conversion. This interface doesn't
* provide any facility to store conversion state in a context
* independent manner. This leads to the limitation that it can
* handle a stateless multibyte encoding only.
*/
struct qse_cmgr_t
{