* added QSE_SIO_NOCLOSE.

* enhanced qse_sed_comp() to accept an array of qse_sed_iostd_t
This commit is contained in:
2011-10-03 01:25:23 +00:00
parent 8f3563b73e
commit 7505e0723f
28 changed files with 1065 additions and 285 deletions

View File

@ -406,15 +406,19 @@ int qse_fio_init (
void qse_fio_fini (qse_fio_t* fio)
{
if (fio->tio != QSE_NULL) qse_tio_close (fio->tio);
if (!(fio->flags & QSE_FIO_NOCLOSE))
{
#if defined(_WIN32)
CloseHandle (fio->handle);
CloseHandle (fio->handle);
#elif defined(__OS2__)
DosClose (fio->handle);
DosClose (fio->handle);
#elif defined(__DOS__)
close (fio->handle);
close (fio->handle);
#else
QSE_CLOSE (fio->handle);
QSE_CLOSE (fio->handle);
#endif
}
}
qse_fio_hnd_t qse_fio_gethandle (qse_fio_t* fio)
@ -437,7 +441,10 @@ qse_fio_off_t qse_fio_seek (
FILE_CURRENT,
FILE_END
};
LARGE_INTEGER x, y;
LARGE_INTEGER x;
#if 0
LARGE_INTEGER y;
#endif
QSE_ASSERT (QSE_SIZEOF(offset) <= QSE_SIZEOF(x.QuadPart));
@ -856,13 +863,18 @@ static qse_ssize_t fio_output (qse_tio_cmd_t cmd, void* arg, void* buf, qse_size
int qse_getstdfiohandle (qse_fio_std_t std, qse_fio_hnd_t* hnd)
{
#if defined(_WIN32)
DWORD tab[] =
{
STD_INPUT_HANDLE,
STD_OUTPUT_HANDLE,
STD_ERROR_HANDLE
};
#else
qse_fio_hnd_t tab[] =
{
#if defined(_WIN32)
(HANDLE)STD_INPUT_HANDLE,
(HANDLE)STD_OUTPUT_HANDLE,
(HANDLE)STD_ERROR_HANDLE
#elif defined(__OS2__)
#if defined(__OS2__)
(HFILE)0, (HFILE)1, (HFILE)2
#elif defined(__DOS__)
0, 1, 2
@ -871,6 +883,8 @@ int qse_getstdfiohandle (qse_fio_std_t std, qse_fio_hnd_t* hnd)
#endif
};
#endif
if (std < 0 || std >= QSE_COUNTOF(tab)) return -1;
#if defined(_WIN32)

View File

@ -43,8 +43,8 @@
/* Returns number of bytes to add to (char *)ptr to make it
properly aligned for the type. */
#define ALIGN(ptr, type) \
((((long)ptr) % sizeof(type))? \
(sizeof(type) - (((long)ptr) % QSE_SIZEOF(type))) : 0)
((((qse_uintptr_t)ptr) % QSE_SIZEOF(type))? \
(QSE_SIZEOF(type) - (((qse_uintptr_t)ptr) % QSE_SIZEOF(type))) : 0)
QSE_IMPLEMENT_COMMON_FUNCTIONS (pma)
@ -133,7 +133,7 @@ void* qse_pma_alloc (qse_pma_t* pma, qse_size_t size)
}
/* Make sure the next pointer will be aligned. */
size += ALIGN((long)(pma->ptr + size), long);
size += ALIGN((qse_uintptr_t)(pma->ptr + size), qse_uintptr_t);
/* Allocate from current block. */
ptr = pma->ptr;

View File

@ -41,6 +41,8 @@ static qse_sio_t __sio_in =
0, /* errnum */
#if defined(_WIN32)
/* this is not a handle. it is adjusted to
* an actual handle in __sio_input () */
(HANDLE)STD_INPUT_HANDLE, /* handle */
#elif defined(__OS2__)
(HFILE)0, /* handle */
@ -85,6 +87,8 @@ static qse_sio_t __sio_out =
0,
#if defined(_WIN32)
/* this is not a handle. it is adjusted to
* an actual handle in __sio_output () */
(HANDLE)STD_OUTPUT_HANDLE,
#elif defined(__OS2__)
(HFILE)1,
@ -129,6 +133,8 @@ static qse_sio_t __sio_err =
0,
#if defined(_WIN32)
/* this is not a handle. it is adjusted to
* an actual handle in __sio_output () */
(HANDLE)STD_ERROR_HANDLE,
#elif defined(__OS2__)
(HFILE)2,
@ -200,7 +206,7 @@ qse_sio_t* qse_sio_openstd (
qse_fio_hnd_t hnd;
if (qse_getstdfiohandle (std, &hnd) <= -1) return QSE_NULL;
return qse_sio_open (mmgr, xtnsize,
(const qse_char_t*)&hnd, flags | QSE_SIO_HANDLE);
(const qse_char_t*)&hnd, flags | QSE_SIO_HANDLE /*| QSE_SIO_NOCLOSE*/);
}
void qse_sio_close (qse_sio_t* sio)

View File

@ -178,16 +178,16 @@ tre_tnfa_run_parallel(qse_mmgr_t* mmgr, const tre_tnfa_t *tnfa, const void *stri
/* Get the various pointers within tmp_buf (properly aligned). */
tmp_tags = (void *)buf;
tmp_buf = buf + tbytes;
tmp_buf += ALIGN(tmp_buf, long);
tmp_buf += ALIGN(tmp_buf, qse_uintptr_t);
reach_next = (void *)tmp_buf;
tmp_buf += rbytes;
tmp_buf += ALIGN(tmp_buf, long);
tmp_buf += ALIGN(tmp_buf, qse_uintptr_t);
reach = (void *)tmp_buf;
tmp_buf += rbytes;
tmp_buf += ALIGN(tmp_buf, long);
tmp_buf += ALIGN(tmp_buf, qse_uintptr_t);
reach_pos = (void *)tmp_buf;
tmp_buf += pbytes;
tmp_buf += ALIGN(tmp_buf, long);
tmp_buf += ALIGN(tmp_buf, qse_uintptr_t);
for (i = 0; i < tnfa->num_states; i++)
{
reach[i].tags = (void *)tmp_buf;

View File

@ -281,8 +281,8 @@ typedef enum { STR_WIDE, STR_BYTE, STR_MBS, STR_USER } tre_str_type_t;
/* Returns number of bytes to add to (char *)ptr to make it
properly aligned for the type. */
#define ALIGN(ptr, type) \
((((long)ptr) % sizeof(type)) \
? (sizeof(type) - (((long)ptr) % sizeof(type))) \
((((qse_uintptr_t)ptr) % QSE_SIZEOF(type)) \
? (QSE_SIZEOF(type) - (((qse_uintptr_t)ptr) % QSE_SIZEOF(type))) \
: 0)
#undef MAX