* added qse_mbscasebeg()/qse_wcscasebeg()

* touched up the _WIN32 part of qse_fio_t a bit
This commit is contained in:
2011-08-15 09:59:55 +00:00
parent 6e2dd10655
commit 8da90da039
8 changed files with 78 additions and 21 deletions

View File

@ -23,8 +23,6 @@
#include <qse/cmn/str.h>
#include "mem.h"
#include <qse/cmn/stdio.h>
#if defined(_WIN32)
# include <windows.h>
#endif

View File

@ -1,5 +1,5 @@
/*
* $Id: fio.c 452 2011-05-04 15:11:23Z hyunghwan.chung $
* $Id: fio.c 550 2011-08-14 15:59:55Z hyunghwan.chung $
*
Copyright 2006-2011 Chung, Hyung-Hwan.
This file is part of QSE.
@ -650,7 +650,7 @@ static int get_devname_from_handle (
/* create a file mapping object */
map = CreateFileMapping (
handle,
NULL,
NULL,
PAGE_READONLY,
0,
1,
@ -684,10 +684,10 @@ static int get_volname_from_handle (
{
if (get_devname_from_handle (handle, buf, len) == -1) return -1;
if (_tcsnicmp(QSE_T("\\Device\\LanmanRedirector\\"), buf, 25) == 0)
if (qse_strcasebeg (buf, QSE_T("\\Device\\LanmanRedirector\\")))
{
buf[0] = QSE_T('\\');
_tcscpy (&buf[1], &buf[24]);
/*buf[0] = QSE_T('\\');*/
qse_strcpy (&buf[1], &buf[24]);
}
else
{
@ -712,14 +712,14 @@ static int get_volname_from_handle (
drv[2] = QSE_T('\0');
if (QueryDosDevice (drv, path, QSE_COUNTOF(path)))
{
qse_size_t pl = _tcslen(path);
qse_size_t bl = _tcslen(buf);
qse_size_t pl = qse_strlen(path);
qse_size_t bl = qse_strlen(buf);
if (bl > pl && buf[pl] == QSE_T('\\') &&
_tcsnicmp(path, buf, pl) == 0)
qse_strxncasecmp(buf, pl, path, pl) == 0)
{
buf[0] = drv[0];
buf[1] = QSE_T(':');
_tcscpy (&buf[2], &buf[pl]);
qse_strcpy (&buf[2], &buf[pl]);
break;
}
}
@ -741,6 +741,8 @@ int qse_fio_chmod (qse_fio_t* fio, int mode)
/* it is a best effort implementation. if the file size is 0,
* it can't even get the file name from the handle and thus fails.
* if GENERIC_READ is not set in CreateFile, CreateFileMapping fails.
* so if this fio is opened without QSE_FIO_READ, this function fails.
*/
if (get_volname_from_handle (
fio->handle, name, QSE_COUNTOF(name)) == -1) return -1;

View File

@ -1,5 +1,5 @@
/*
* $Id: opt.c 462 2011-05-18 14:36:40Z hyunghwan.chung $
* $Id: opt.c 550 2011-08-14 15:59:55Z hyunghwan.chung $
*
Copyright 2006-2011 Chung, Hyung-Hwan.
This file is part of QSE.
@ -55,10 +55,6 @@
* --------------------------------------------------------------------------
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define BADCH QSE_T('?')
#define BADARG QSE_T(':')
#define EMSG QSE_T("")

View File

@ -1,5 +1,5 @@
/*
* $Id: str_beg.c 443 2011-04-25 14:56:05Z hyunghwan.chung $
* $Id: str_beg.c 550 2011-08-14 15:59:55Z hyunghwan.chung $
*
Copyright 2006-2011 Chung, Hyung-Hwan.
This file is part of QSE.
@ -19,6 +19,7 @@
*/
#include <qse/cmn/str.h>
#include <qse/cmn/chr.h>
qse_mchar_t* qse_mbsbeg (const qse_mchar_t* str, const qse_mchar_t* sub)
{
@ -83,6 +84,18 @@ qse_mchar_t* qse_mbsxnbeg (
return (qse_mchar_t*)str;
}
qse_mchar_t* qse_mbscasebeg (const qse_mchar_t* str, const qse_mchar_t* sub)
{
while (*sub != QSE_MT('\0'))
{
if (QSE_TOMUPPER(*str) != QSE_TOMUPPER(*sub)) return QSE_NULL;
str++; sub++;
}
/* returns the pointer to the next character of the match */
return (qse_mchar_t*)str;
}
qse_wchar_t* qse_wcsbeg (const qse_wchar_t* str, const qse_wchar_t* sub)
{
while (*sub != QSE_WT('\0'))
@ -146,3 +159,14 @@ qse_wchar_t* qse_wcsxnbeg (
return (qse_wchar_t*)str;
}
qse_wchar_t* qse_wcscasebeg (const qse_wchar_t* str, const qse_wchar_t* sub)
{
while (*sub != QSE_WT('\0'))
{
if (QSE_TOWUPPER(*str) != QSE_TOWUPPER(*sub)) return QSE_NULL;
str++; sub++;
}
/* returns the pointer to the next character of the match */
return (qse_wchar_t*)str;
}